1 / 19

IT253: Computer Organization

Tonga Institute of Higher Education. IT253: Computer Organization. Lecture 8: Computer Arithmetic: Making a Processor. Computer Arithmetic. The next step after designing basic circuits is to create more complicated circuits that will lead us to our CPU

duane
Download Presentation

IT253: Computer Organization

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Tonga Institute of Higher Education IT253: Computer Organization Lecture 8: Computer Arithmetic: Making a Processor

  2. Computer Arithmetic • The next step after designing basic circuits is to create more complicated circuits that will lead us to our CPU • We will look at computer arithmetic and an ALU, and then start to look into the processor design. • An ALU is an Arithmetic-Logic Unit. It is an important part of a processor. • It does the adding, subtracting and logical operations (AND,OR,NOT) in a computer. • An "ALU Slice" is an ALU for just 2 bits.

  3. Addition and our 1-bit Adder Gate Implementation of 1-Bit Adder Truth Table for Adding

  4. Full Adder/Ripple Adder • It is simple to put the full adders together. • With that we can form a ripple adder, or an adder that will add any number of bits. • If we want a 16 bit adder, we just need to put 16 full • adders together.

  5. ALU Slice • Now that we have an adder, we can create most of the ALU. • We still need to do subtracting, but we can make an ALU Slice. • This will do logic operations and adding

  6. Subtracting and our New ALU Slice • For a more complete ALU we need to put in subtracting. • There is an easy way to do this. • We just need to realize we are using 2's complement • Then we just invert the second number • To do this we add an extra input. • Binv will choose to subtract (by inverting B) if Binv is 1. • If it is zero, then it does not change anything and the operation stays as an add. • When we need to add +1 • (because it’s 2’s complement) • we just set Cin=1 for first bit

  7. Overflow • All we need now is a way to detect overflow and we will have a full ALU. • We don’t need to stop it, but we need a way to tell the computer that there was overflow, so that the computer can do the right thing. • To see if there is overflow, we can take the XOR of the carry in and the carry out of the last bit. • If they are not the same, then there is overflow

  8. Overflow If we take the XOR of the carry in and the carry out of the last bit, we can see if there is overflow.

  9. The Whole ALU • Remember the ripple adder where we put full adders together. If we wanted to add 16 bits, we would put 16 full adders together. • The same works with the ALU. To make a full ALU, put together 32 of them and you can use 32 bit numbers (means you can add, subtract, AND,OR,NOT with 32 bit numbers)

  10. Making a smaller ALU • We need an easy way to draw the ALU, • Just like the full adder, we will make a little box

  11. Integer Multiplication • We’ve done adding, subtracting, AND,OR. We also need a way to multiply numbers. • Example • Product = Multiplicand * Multiplier Multiplicand 101 Multiplier x 110 000 1010 + 10100 Product 11110

  12. Multiplication • What we need is an algorithm (a series of steps) that can do a multiplication operation. • Algorithm: • If multiplier digit is 1, add a shifted copy of multiplicand to product • If multiplier digit is 0, add zero to product • This means for a 32 bit number, it will take 32 steps to multiply a number

  13. Multiplication Hardware The Multiplicand will keep getting shifted over. It has to be 64 bits. The Product will also be 64 bits. Multiplier only needs 32 bits

  14. Multiplication and Division • This algorithm is a simple and very inefficient (slow) algorithm. • There are better algorithms, but they are complicated • Division will use the same hardware as multiplication, we will just change a few simple things • With division we will shift the remainder left, inside of the divisor right Divisor Hardware

  15. Floating Point Addition • We have seen how to add, subtract, multiply and divide whole integers, but what about numbers with decimals? • The algorithm for floating point addition: • Example: 1.610 x 10-1 + 9.999 x 102 • Step 1: Align decimal points • 0.016 x 101 +99.99 x 101 • Step 2: Add together • 0.016 x 101 +99.99 x 101 = 100.015 x 101 • Step 3: Normalize • 100.015 x 101 = 1.00015 x 103 • Step 4: Round (because we only have so many mantissa spots) • Example (to show rounding) • 1.00015 x 103 = 1.0002 x 103

  16. Floating Point Hardware • Hardware will do all the steps of the algorithm. • Align numbers • Add • Normalize • Round • Sometimes you may need to normalize and round more than once to get the level of accuracy that your hardware can support. (For example, if you have a 32 bit number, it will be less accurate than 64 bits)

  17. Problems with Floating Points • Accuracy is a big issue with floating points. • For example, is (x + y) + z = x + (y + z) • the first operation, inside the parentheses, may round the number so that it is a different result • Computers only have a limited size (mostly 32 bits), so you can only have numbers that are accurate to a limited point

  18. Exceptions • Exceptions are errors that the computer hardware will notify the user about. • There are a few exceptions we need to make sure the computer knows about • Overflows, underflows and division by zero • Square root of -1, infinity. • These are examples of things we would have to consider when making hardware

  19. Summary • We looked at how to implement a full ALU and make it work with 32 bit numbers. • We also looked at some other elements we need on a processor. • We tried to make hardware to do multiplication and division. • We also looked at what we would need for floating point numbers • Next time: Designing our processor

More Related