Presentation is loading. Please wait.

Presentation is loading. Please wait.

Today’s topics Architecture overview Architecture overview Machine instructions Machine instructions Instruction Execution Cycle Instruction Execution.

Similar presentations


Presentation on theme: "Today’s topics Architecture overview Architecture overview Machine instructions Machine instructions Instruction Execution Cycle Instruction Execution."— Presentation transcript:

1 Today’s topics Architecture overview Architecture overview Machine instructions Machine instructions Instruction Execution Cycle Instruction Execution Cycle CISC machines CISC machines Microprograms Microprograms RISC machines RISC machines Parallelism Parallelism Instruction-level Instruction-level Processor-level Processor-level Internal representation Internal representation Limits of representation Limits of representation External representation External representation Binary, octal, decimal, hexadecimal number systems Binary, octal, decimal, hexadecimal number systems

2

3 Terms CPU: Central Processing Unit CPU: Central Processing Unit ALU: Arithmetic/Logic Unit ALU: Arithmetic/Logic Unit Memory: storage for data and programs (separate from CPU) Memory: storage for data and programs (separate from CPU) Register: fast temporary storage inside the CPU Register: fast temporary storage inside the CPU Bus: parallel "wires" for transferring a set of electrical signals simultaneously Bus: parallel "wires" for transferring a set of electrical signals simultaneously Internal: Transfers signals among CPU components Internal: Transfers signals among CPU components Control: Carries signals for memory and I/O operations Control: Carries signals for memory and I/O operations Address: Links to specific memory locations Address: Links to specific memory locations Data: Carries data CPU  memory Data: Carries data CPU  memory Microprogram: sequence of micro-instructions required to execute a machine instruction Microprogram: sequence of micro-instructions required to execute a machine instruction Cache: temporary storage for faster access Cache: temporary storage for faster access Note: caching takes place at many levels in a computer system Note: caching takes place at many levels in a computer system

4 Registers General/Temporary: fast local memory inside the CPU General/Temporary: fast local memory inside the CPU one type of cache one type of cache Control: dictates current state of the machine Control: dictates current state of the machine Status: indicates error conditions Status: indicates error conditions IR: Instruction Register (holds current instruction) IR: Instruction Register (holds current instruction) IP: Instruction Pointer (holds memory address of next instruction) IP: Instruction Pointer (holds memory address of next instruction) MAR: Memory Address Register (holds address of memory location currently referenced) MAR: Memory Address Register (holds address of memory location currently referenced) MDR: Memory Data Register: holds data being set to or retrieved from the memory address in the MAR MDR: Memory Data Register: holds data being set to or retrieved from the memory address in the MAR

5 Machine instructions Each computer architecture provides a set of machine-level instructions Each computer architecture provides a set of machine-level instructions Instruction Set Architecture (ISA) Instruction Set Architecture (ISA) Specific to one particular architecture Specific to one particular architecture Like everything inside a computer, machine instructions are implemented electrically Like everything inside a computer, machine instructions are implemented electrically Micro-instructions set the switches in the control register Micro-instructions set the switches in the control register

6

7 Hypothetical CISC* machine Shows hardware components Shows hardware components Does not show digital logic level or microprograms. Does not show digital logic level or microprograms. Shows how machine-level instructions can be stored and executed. Shows how machine-level instructions can be stored and executed. Illustrates Illustrates Finite-state machine Finite-state machine *CISC *CISC Complex Instruction Set Computer Complex Instruction Set Computer VonNeumann architecture VonNeumann architecture Instruction execution cycle Instruction execution cycle

8 Real computers … Use the “stored program” concept Use the “stored program” concept VonNeumann architecture VonNeumann architecture Program is stored in memory, and is executed under the control of the operating system Program is stored in memory, and is executed under the control of the operating system Operate using an Instruction Execution Cycle Operate using an Instruction Execution Cycle

9 Instruction Execution Cycle 1.Fetch next instruction (at address in IP) into IR. 2.Increment IP to point to next instruction. 3.Decode instruction in IR 4.If instruction requires memory access, A.Determine memory address. B.Fetch operand from memory into a CPU register, or send operand from a CPU register to memory. 5.Execute micro-program for instruction 6.Go to step 1. Note: default execution is sequential

10 Example CISC Instruction ADDR1, mem1 ;(Add contents of memory location mem1 to register R1) 1.Copy contents of R1 to ALU Operand_1 2.Move address of mem1 to MAR 3.Signal memory fetch (gets contents of memory address currently in MAR into MDR) 4.Copy contents of MDR into ALU Operand_2 5.Signal ALU addition 6.Check Status Register 7.Copy contents of ALU Result to R1 Example ADD Microprogram (each microinstruction executes in one clock cycle)

11 Improving CISC CISC speed (and convenience) is increased by CISC speed (and convenience) is increased by more efficient microprograms more efficient microprograms more powerful ISA level instructions more powerful ISA level instructions cache memory cache memory more registers more registers wider buses wider buses making it smaller making it smaller more processors more processors floating point instructions floating point instructions Etc. Etc.

12 Clock Cycles So how “slow” is this? So how “slow” is this? It isn’t slow It isn’t slow Execution near light-speed Execution near light-speed Clock cycle length determines CPU speed Clock cycle length determines CPU speed (mostly) (mostly)

13 Limitations of CISC Improving a specific architecture requires instructions to be backward compatible. So … how about a different architecture?

14 RISC machines Reduced Instruction Set Computer Much smaller set of instructions at ISA level Much smaller set of instructions at ISA level Instructions are like CISC micro-instructions Instructions are like CISC micro-instructions RISC assembly level programs look much longer (more instructions) than CISC assembly level programs, but they execute faster. Why? RISC assembly level programs look much longer (more instructions) than CISC assembly level programs, but they execute faster. Why?

15 RISC design principles Instructions executed directly by hardware (no microprograms). Instructions executed directly by hardware (no microprograms). Maximize rate of fetching instructions. Maximize rate of fetching instructions. Instruction cache Instruction cache Instructions easy to decode Instructions easy to decode Fetching operands, etc. Fetching operands, etc. Only LOAD and STORE instructions reference memory. Only LOAD and STORE instructions reference memory. Plenty of registers Plenty of registers

16 More speed improvement Minimize memory and I/O accesses Minimize memory and I/O accesses Cache Cache Separate I/O unit (buffers/processing) Separate I/O unit (buffers/processing) Separate network communication unit (NIC) Separate network communication unit (NIC) Etc. Etc. Parallel processing Parallel processing

17 Parallelism (overview) Instruction-level parallelism Instruction-level parallelism pipeline pipeline cache cache Processor-level parallelism Processor-level parallelism multiprocessor (multiple CPUs, common memory) multiprocessor (multiple CPUs, common memory) multicomputer (multiple CPUs, each with own memory) multicomputer (multiple CPUs, each with own memory)

18 Pipelining

19 Instruction Caching Hardware provides area for multiple instructions in the CPU Hardware provides area for multiple instructions in the CPU Reduces number of memory accesses Reduces number of memory accesses Instructions are available for immediate execution Instructions are available for immediate execution Might cause problems with decision, repetition, and procedure structures in programs Might cause problems with decision, repetition, and procedure structures in programs

20 Multiprocessor (shared memory)

21 Multicomputer (distributed memory)

22 Comparisons Cache and Pipelining Cache and Pipelining Implemented in hardware Implemented in hardware Multiprocessor Multiprocessor Difficult to build Difficult to build Relatively easy to program Relatively easy to program Multicomputer Multicomputer Easy to build (given networking technology) Easy to build (given networking technology) Extremely difficult to program Extremely difficult to program

23 Other types of parallelism Hybrid systems Hybrid systems Scalable architectures Scalable architectures Add more processors (nodes), without having to re-invent the system Add more processors (nodes), without having to re-invent the system Simulated parallelism Simulated parallelism

24 Applications of Parallelism Multi-user systems Multi-user systems Networks Networks Internet Internet Speed up single processes Speed up single processes Chess example Chess example Expert systems Expert systems Other AI applications Other AI applications

25 Parallelism Parallelism … more later … more later Internal representation Internal representation Data Data Instructions Instructions Addresses Addresses

26 Internal representation Just like everything else in a computer, the representation of numbers is implemented electrically Just like everything else in a computer, the representation of numbers is implemented electrically switches set to off or on switches set to off or on with open/closed gates. with open/closed gates. There are two states for each gate There are two states for each gate The binary number system uses two digits (0 and 1) The binary number system uses two digits (0 and 1) In order to simplify discussion, we use the standard shorthand to transcribe the computer representation: In order to simplify discussion, we use the standard shorthand to transcribe the computer representation: off is written as digit 0 off is written as digit 0 on is written as digit 1 on is written as digit 1

27 External representation Use the binary number system to represent numeric values electrically. Use the binary number system to represent numeric values electrically. Switches (gates) are grouped into bytes, words, etc., to represent the digits of a binary number. Switches (gates) are grouped into bytes, words, etc., to represent the digits of a binary number. Note: The number of gates in a group depends on the computer architecture and the type of data represented. E.G., Note: The number of gates in a group depends on the computer architecture and the type of data represented. E.G., For Intel-based architectures For Intel-based architectures byte = 8-bits, word = 2 bytes (16 bits) byte = 8-bits, word = 2 bytes (16 bits) integers use 2, 4, 8, or 10 bytes integers use 2, 4, 8, or 10 bytes

28 Binary number system has 2 digits: 0 and 1 (binary digit) has 2 digits: 0 and 1 (binary digit) has places and place values determined by powers of 2. has places and place values determined by powers of 2. (in theory) can uniquely represent any integer value (in theory) can uniquely represent any integer value A binary representation is just another way of writing a number that we are accustomed to seeing in decimal form. A binary representation is just another way of writing a number that we are accustomed to seeing in decimal form. (in practice, inside the computer) representation is finite (in practice, inside the computer) representation is finite Representations with too many digits get chopped. Representations with too many digits get chopped.

29 Internal representation Place values (right-to-left) are 2 0,2 1,2 2,2 3,2 4, etc. Place values (right-to-left) are 2 0,2 1,2 2,2 3,2 4, etc. Bits are numbered (right-to-left) starting at 0 Bits are numbered (right-to-left) starting at 0 Place value depends on number of "bits" defined for the type. Place value depends on number of "bits" defined for the type. Example: Example: A 16-bit integer might be(red is "on") A 16-bit integer might be(red is "on") 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 (bit numbers) … transcribed by a human as 0000000010110010 To convert to its familiar decimal representation, just add up the place values of the places that are "on".

30 0 0 0 0 0 0 0 0 1 0 1 1 0 0 1 0 in decimal form: 128 + 32 + 16 + 2 = 178 How many different codes (integers) can be represented using 16 bits? What is the largest (unsigned) integer that can be represented using 16 bits? What is the largest (unsigned) integer that can be represented using 32 bits? Prove that for n-bit representation, number of codes is 2 n, largest unsigned integer is 2 n – 1, and largest signed integer is 2 n-1 - 1 2 15 32768 2 14 16384 2 13 8192 2 12 4096 2 11 2048 2 10 1024 2 9 512 2 8 256 2 7 128 2 6 64 2 5 32 2 4 16 2323882323888 2222442222444 2121222121222 2020112020111 Converting binary to decimal

31 Converting decimal to binary Method 1:Removing largest powers of 2 Method 1:Removing largest powers of 2 Method 2:Successive division by 2 Method 2:Successive division by 2

32 Converting decimal to binary Example: 157 Example: 157 Method 1:Removing largest powers of 2 Method 1:Removing largest powers of 2 157 – 128 = 29 29 – 16 = 13 13 – 8 = 5 5 – 4 = 1 1 – 1 = 0 1 0 0 1 1 1 0 1 1 0 0 1 1 1 0 1 Method 2:Successive division by 2 Method 2:Successive division by 2 157 ÷ 2 =78 R 1 78 ÷ 2 =39 R 0 39 ÷ 2 =19 R 1 19 ÷ 2 =9 R 1 9 ÷ 2 =4 R 1 4 ÷ 2 =2 R 0 2 ÷ 2 =1 R 0 1 ÷ 2 =0 R 1 1 0 0 1 1 1 0 1 1 0 0 1 1 1 0 1

33 Numeric representation We will show (later) exactly how an electrical operation can be performed on two electrical numeric representations to give an electrical result that is consistent with the rules of arithmetic. We will show (later) exactly how an electrical operation can be performed on two electrical numeric representations to give an electrical result that is consistent with the rules of arithmetic.

34 … but not quite consistent … Since the number of gates in each group (byte, word, etc.) is finite, computers can represent numbers with finite precision only. Since the number of gates in each group (byte, word, etc.) is finite, computers can represent numbers with finite precision only. Example: Example: Suppose that signed integer data is represented using 16 gates. Then the largest integer that can be represented is 65535. What happens if we add 1 ? Suppose that signed integer data is represented using 16 gates. Then the largest integer that can be represented is 65535. What happens if we add 1 ? If necessary, representations are truncated; overflow / underflow can occur, and the Status Register will be set If necessary, representations are truncated; overflow / underflow can occur, and the Status Register will be set

35 Representing negative integers Must specify size! Must specify size! Specify n: number of bits (8, 16, 32, etc.) Specify n: number of bits (8, 16, 32, etc.) There are 2 n possible "codes" There are 2 n possible "codes" Separate the "codes" so that half of them represent negative numbers. Separate the "codes" so that half of them represent negative numbers. Note that exactly half of the codes have 1 in the "leftmost" bit.) Note that exactly half of the codes have 1 in the "leftmost" bit.)

36 Binary form of negative numbers Several methods, each with disadvantages. Several methods, each with disadvantages. We will focus on twos-complement form We will focus on twos-complement form For a negative number x : For a negative number x : specify number of bits specify number of bits start with binary representation of |x| start with binary representation of |x| change every bit to its opposite, then add 1 to the result. change every bit to its opposite, then add 1 to the result.

37 Binary form of negative numbers Example: -13 in 16-bit twos-complement Example: -13 in 16-bit twos-complement |-13| = 13 = 0000000000001101 |-13| = 13 = 0000000000001101 ones-complement is 1111111111110010 ones-complement is 1111111111110010 add 1 to get 1111111111110011 = -13 add 1 to get 1111111111110011 = -13 Note that -(-13) should give 13. Try it. Note that -(-13) should give 13. Try it. Hexadecimal representation? Hexadecimal representation? Convert binary to hex in the usual way Convert binary to hex in the usual way -13 = 1111111111110011 = FFF3 H = 0xfff3 -13 = 1111111111110011 = FFF3 H = 0xfff3 Note: For byte, word, etc., if the first hex digit is greater than or equal to 8, the value is negative. Note: For byte, word, etc., if the first hex digit is greater than or equal to 8, the value is negative. Convert negative binary to decimal? Convert negative binary to decimal? Find twos complement, convert, and prepend a minus sign. Find twos complement, convert, and prepend a minus sign.

38 Signed numbers using 4-bit twos-complement form Notice that all of the negative numbers have 1 in the leftmost bit. All of the non-negative numbers have 0 in the leftmost bit. Notice that all of the negative numbers have 1 in the leftmost bit. All of the non-negative numbers have 0 in the leftmost bit. For this reason, the leftmost bit is called the sign bit For this reason, the leftmost bit is called the sign bit Note: Nobody uses 4-bit representations (“nibble”), but there’s not enough room to show 8-bit representations here. Note: Nobody uses 4-bit representations (“nibble”), but there’s not enough room to show 8-bit representations here. You can extend this diagram to 8-bit, 16-bit, etc. You can extend this diagram to 8-bit, 16-bit, etc. -8-7-6-5-4-3-201234567 1000100110101011110011011110111100000001001000110100010101100111

39 n-bit twos-complement form The 2 n possible codes give The 2 n possible codes give all zero all zero 2 n-1 - 1 positive numbers 2 n-1 - 1 positive numbers 2 n-1 negative numbers 2 n-1 negative numbers Note: zero is its own complement Note: zero is its own complement Note: there is one “weird” number Note: there is one “weird” number 01111111 + 1 = 10000000 01111111 + 1 = 10000000 127 + 1 = -128 127 + 1 = -128 (inconsistent with rules of arithmetic) (inconsistent with rules of arithmetic) 127 is the largest number that can be represented in 8 bits. This means that -(-128) cannot be represented with 8 bits. 127 is the largest number that can be represented in 8 bits. This means that -(-128) cannot be represented with 8 bits. i.e., the 2's-complement of 10000000 is 10000000 i.e., the 2's-complement of 10000000 is 10000000

40 Signed or Unsigned? A 16-bit representation could be used for signed or unsigned numbers A 16-bit representation could be used for signed or unsigned numbers 16-bit signed range is -32768.. +32767 16-bit signed range is -32768.. +32767 16-bit unsigned range is 0.. 65535 16-bit unsigned range is 0.. 65535 Both forms use the same 2 16 codes Both forms use the same 2 16 codes Example: Example: 1010101010101010 unsigned is 43690 decimal 1010101010101010 unsigned is 43690 decimal 1010101010101010 signed is -21846 1010101010101010 signed is -21846 Programmer must tell the computer which form is being used. Programmer must tell the computer which form is being used.

41 Other representations Every integer number has a unique representation in each "base"  2 Every integer number has a unique representation in each "base"  2 Hexadecimal is commonly used for easily converting binary to a more manageable form. Hexadecimal is commonly used for easily converting binary to a more manageable form. example 16-bit binary  hexadecimal: example 16-bit binary  hexadecimal: Binary 0001 0111 1011 1101 Hexadecimal 1 7 B D Write it as 0x17BD or 17BDh

42 Questions? Read Irvine Chapter 17.1


Download ppt "Today’s topics Architecture overview Architecture overview Machine instructions Machine instructions Instruction Execution Cycle Instruction Execution."

Similar presentations


Ads by Google