Download presentation
Presentation is loading. Please wait.
Published byShana Dalton Modified over 9 years ago
2
Lecture 2
3
Processor Organization Control needs to have the Ability to fetch instructions from memory Logic and means to control instruction sequencing Logic and means to issue signals that control the way information flows between datapath components Logic and means to control what operations the datapath’s functional units perform Datapath needs to have the Components - functional units (e.g., adder) and storage locations (e.g., register file) - needed to execute instructions Components interconnected so that the instructions can be accomplished Ability to load data from and store data to memory
4
What Happens Next? Processor Control Datapath Memory Devices Input Output 000000 00000 00101 0001000010000000 000000 00100 00010 0001000000100000 100011 00010 01111 0000000000000000 100011 00010 10000 0000000000000100 101011 00010 10000 0000000000000000 101011 00010 01111 0000000000000100 000000 11111 00000 0000000000001000 FetchDecodeExec
5
Output Data Stored in Memory Processor Control Datapath Memory Devices Input Output 00000100010100000000000000000000 00000000010011110000000000000100 00000011111000000000000000001000 At program completion the data to be output resides in memory
6
Output Device Outputs Data Processor Control Datapath Memory Devices Input Output 00000100010100000000000000000000 00000000010011110000000000000100 00000011111000000000000000001000
7
The Instruction Set Architecture instruction set architecture software hardware The interface description separating the software and hardware.
8
MIPS R3000 Instruction Set Architecture ISA Instruction Categories Load/Store Computational Jump and Branch Floating Point coprocessor Memory Management Special R0 - R31 PC HI LO OP rs rt rdsafunct rs rt immediate jump target 3 BASIC Instruction Formats: all 32 bits wide Registers Q: How many already familiar with MIPS ISA?
9
How Do the Pieces Fit Together? I/O systemInstr. Set Proc. Compiler Operating System Application Digital Design Circuit Design Instruction Set Architecture Firmware Coordination of many levels of abstraction Under a rapidly changing set of forces Design, measurement, and evaluation Memory system Datapath & Control
10
9 Number Systems Refresh on Binary Numbers
11
10 Number Systems In grade school: decimal system To interpret a sequence of digits: assign each digit to a column, multiply each digit by the column, add them all together HundredsTensOnes 237 2 x 100 + 3 x 10 +7 x 1’s = 237
12
11 Number Systems: Decimal System Decimal System = Base 10 Hundreds 10 2 Tens 10 1 Ones 10 0 0-9 Base 10 uses digits 0 – 9 Largest number represented with 3 columns? How do we represent a larger number?
13
12 Interpreting Number Systems For any Base B, use digits 0 – (B-1) Each column represents B raised to an exponent, increasing to the left BnBn B…B… B2B2 B1B1 B0B0 0 - (B-1)
14
13 Other Number Systems Octal system (base 8) uses digits 0 – 7 8282 8181 8080 237 2 x 8 2 + 3 x 8 1 + 7 x 8 0 = 159 base10 The interpretation of any digit sequence is dependent on the number system
15
14 Other Number Systems Hexadecimal system (base 16) uses digits 0 – 9, A-F 16 2 16 1 16 0 2BD 2 x 16 2 + 11 x 16 1 + 13 x 16 0 = 701 base10 The interpretation of any symbolic sequence is dependent on the number system
16
15 Binary Number System Binary system (base 2) uses digits 0 – 1 Machine Language uses base 2 2525 2424 23232 2121 2020 237 101100 Invalid Valid
17
16 Conversion from Binary to Decimal Convert 100111 base 2 to ??? base 10 1.Assign each digit to a column (columns represent base raised to exponents increasing to left) 2525 2424 23232 2121 2020 100111
18
17 Conversion from Binary to Decimal 2. Multiply each digit by the column and then add them all together 2525 2424 23232 2121 2020 100111 1 x 2 5 + 0 x 2 4 + 0 x 2 3 + 1 x 2 2 + 1 x 2 1 + 1 x 2 0 = 32 + 0 + 0 + 4 + 2 + 1 = 39 base10
19
18 Conversion from Decimal to Binary Convert 237 base10 to ?????? base 2 1. Find the largest power of 2 in the decimal number (trial and error) 2. Record this largest power in its column 3. Subtract this largest power: 237 – 128 = 109 2 8 256 2 7 128 2 6 64 2 5 32 2 4 16 2382382 224224 2 1 2 2 0 1 1
20
19 Conversion from Decimal to Binary 4. REPEAT 1-3 with remainder, until 0 5. Record 0 for all powers not subtracted 109 45 13 5 1 - 64 = 2 6 - 32 = 2 5 - 8 = 2 3 - 4 = 2 2 - 1 = 2 0 45 13 5 1 0 2 8 256 2 7 128 2 6 64 2 5 32 2 4 16 2382382 224224 2 1 2 201201 11101101 237 base10 = 11101101 base 2
21
20 An algorithm for converting to decimal to other bases Let N be the number (assume it is an integer now) to be converted and b the base. Divide N by b and record the remainder r 0. Next divide the partial quotient from the previous step by b and record the remainder r 1. Continue this process until the partial quotient is 0 and record the final remainder r n. The number N in base b is given by r n... r 1 r 0. Example 315 decimal is converted to base 8 by 315/8 = 39 + 3 39/8 = 4 + 7 4/8 = 0 + 4 So 315 10 = 473 8.
22
21 Suppose N is not an integer Convert the integer part as on the previous slide. Now convert the fractional part as follows. Multiply by the base and record the integer part as r-1, then multiply the new fractional part by the base and record the integer part as r-2. Continue this process until the result of multiplying gives zero, or until a product is repeated, or until a certain number of places is obtained. If zero is reached, or the max number of digits is reached, then the result is 0. r -1 r -2... r -m. On the other hand if a product is repeated then it is clear that the pattern just seen will repeat so one gets an infinite repeating pattern in the fractional representation. Example: Represent.315 base 10 as a base 8 number with 8 digits..315 (8) = 2.52.52 (8) = 4.16.16 (8) = 1.28.28 (8) = 2.24.24 (8) = 1.92.92 (8) = 7.36.36 (8) = 2.88.88 (8) = 7.04 Now.315 10 is approximately.24121727 8.
23
22 Converting from one base to another The general problem of converting from base r to base s can be done by converting the base r number first to decimal, and then converting the base 10 number to base s as shown previously. For example 375 9 = 3×9 2 + 7×9 + 5 = 243 + 63 + 5 = 311. If we want to convert to base 3 we go through the process below. 311/3 = 103 remainder 2 103/3 = 34 remainder 1 34/3 = 11 remainder 1 11/3 = 3 remainder 2 3/3 = 1 remainder 0 1/3 = 0 remainder 1. Therefore 375 9 = 102112 3
24
23 Class Example 1: Convert Binary to Decimal Convert 1011 base 2 to ?? base 10
25
24 Class Example 2: Convert Decimal to Binary Convert 22 base10 to ????? base 2
26
25 Class Example: Convert Decimal to Binary Convert 22 base10 to ????? base 2 22 6 2 - 16 = 2 4 - 4 = 2 2 - 2 = 2 1 6 2 0 2 4 16 2382382 224224 2 1 2 201201 10110 22 base10 = 10110 base 2
27
26 Example continued Now do it with the algorithm if you didn’t previously
28
27 Counting in the Binary Number System 23232 2121 2020 Base 10 00 11 102 113 1004 1015 1106 1117 10008 10019 101010
29
28 Computer arithmetic When performing computations in a computer precision is limited to a finite number of bits. (In MIPS this is 32). We will look at a couple of problems with limited size words. In the first one below suppose we have 8 bits and are looking at different ways of doing the arithmetic. -71 – 109 = ? Change 71 and 109 to binary, 71 = 1000111, 109 = 1101101.
30
29 Sign and magnitude -71 = 11000111 and -109 = 11101101. Since both are negative we add the magnitudes 1000111 + 1101101 and append the 1 in the sign place. 1000111 + 1101101 = 10110100 which causes overflow since the magnitude will not fit into 7 places allowed for the magnitude. -71 + 109 on the other hand is 1101101 – 1000111 = 100110 and the result is positive since the magnitude of the positive number is larger. Therefore the result in sign and magnitude is 00100110 where the first 0 is the sign designator.
31
30 1’s complement The 1’s complement of 71 = 01000111 is 10111000 and the 1’s complement of 109 = 01101101 is 10010010 (note we have to add the leading zero since we are using 8 bits.). Now 10111000 + 10010010 = 1 01001010 = 01001010 + 1 (end around carry) = 01001011. But this is a positive number representation which indicates overflow has occurred. Note: In 1’s complement any overflow out of the allotted bits, in this case 8, is added back to the sum and the overflow bit is deleted. On the other hand if we perform -71 + 109 we get 10111000 + 01101101 = 1 00100101 = 00100101 + 1 = 00100110 = 38.
32
31 2’s complement The 2’s complement of 71 = 01000111 is 10111001 and the 2’s complement of 109 = 01101101 is 10010011 (note we have to add the leading zero since we are using 8 bits.). Now 10111001 + 10010011 = 1 01001100 = 01001010. But this is a positive number representation which indicates overflow has occurred. Note: In 2’s complement any overflow out of the allotted bits, in this case 8, does not by itself indicate overflow. On the other hand if we perform -71 + 109 we get 10111001 + 01101101 = 1 00100110 = 00100110 = 38.
33
32 A hex example 3C5D28E2 – ED5E3026 (change to 16s complement and add) = 3C5D28E2 + (12A1CFD9 + 1) = 4EFEF8BC Another example: 7F5D28E2 – ED5E3026 = 7F5D28E2 + 12A1CFDA = 91FEF8BC. However this is an overflow since the sum of two positive numbers gives a negative as indicated by the 9 in the most significant place. The important point to note here is that these addition or subtraction results have to fit in the 8 hex digits (32 bits). To form the 16’s complement each hex digit x is replaced by hex digit y such that x + y = F and then 1 is added to the result.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.