week 6 processor components microprocessors
play

Week 6: Processor Components Microprocessors So far, weve been - PowerPoint PPT Presentation

Week 6: Processor Components Microprocessors So far, weve been about making devices, such such as adders, counters and registers. The ultimate goal is to make a microprocessor, which is a digital device that processes input, can


  1. Week 6: Processor Components

  2. Microprocessors § So far, we’ve been about making devices, such such as adders, counters and registers. § The ultimate goal is to make a microprocessor, which is a digital device that processes input, can store values and produces output, according to a set of on- board instructions.

  3. Microprocessors § Microprocessors are a combination of the units that we’ve discussed so far: ú Registers to store values. ú Adders and shifters to process data. ú Finite state machines to control the process. § Microprocessors have been the basis of all computing since the 1970’s, and can be found in nearly every sort of electronics.

  4. To get to this Assembly Language Processors Arithmetic Finite State Logic Units Machines Devices Flip-flops Circuits Logic Gates Transistors We build these

  5. The Final Destination

  6. The Final Destination PCWriteCond Control PCSource Unit PCWrite ALUOp IorD ALUSrcB MemRead ALUSrcA MemWrite RegWrite MemtoReg RegDst IRWrite Opcode 0 1 2 Shift left 2 Instruction Registers [31-26] 0 Read reg 1 Instruction 0 A PC [25-21] Address Zero Read 1 A 1 data 1 Instruction Read reg 2 Memory [20-16] data ALU ALU result Instruction 0 Out Write [15-0] data Write reg Read B 0 1 data 2 4 1 B ALU Instruction 2 Write data Memory Register 3 0 Memory 1 data register Sign Shift left 2 extend

  7. Deconstructing processors § Simpler at a high level: Controller Thing “Datapath” Storage Arithmetic Thing Thing

  8. The “Arithmetic Thing” aka: the Arithmetic Logic Unit (ALU)

  9. Arithmetic Logic Unit § The first microprocessor applications were calculators. ú Remember adders and subtractors? ú These are part of a larger structure called the arithmetic logic unit (ALU). ú You made a simple one for a lab! § This larger structure is responsible for the processing of all data values in a basic CPU.

  10. ALU inputs A B § The ALU performs all of the arithmetic operations S, C in VCNZ covered in this course so far, and logical operations G as well (AND, OR, NOT, etc.) ú Input S represents select bits (in this case, S 2 S 1 & S 0 ) that specify which operation to perform. For example: S2 is a mode select bit, indicating whether the ALU is in arithmetic or logic mode ú The carry-in bit C in is used in operations such as incrementing an input value or the overall result.

  11. ALU outputs A B § In addition to the input S, C in VCNZ signals, there are output signals V, C, N & Z which indicate special conditions G in the arithmetic result: ú V: overflow condition The result of the operation could not be stored in the n bits of G, meaning that the result is incorrect. ú C: carry-out bit ú N: Negative indicator ú Z: Zero-condition indicator

  12. The “A” of ALU § To understand how the ALU does all of these operations, let’s start with the arithmetic side. § Fundamentally, this side is made of an adder / subtractor unit, which we’ve seen already: Sub Y 3 Y 2 Y 1 Y 0 X 3 X 2 X 1 X 0 C in C out C 3 C 2 C 1 FA FA FA FA S 3 S 2 S 1 S 0

  13. Arithmetic components C in n n A X G G = X + Y + C in n-bit n n parallel B Y adder B input logic S 0 S 1 C out § In addition to addition and subtraction, many more operations can be performed by manipulating what is added to input A , as shown in the diagram above.

  14. Arithmetic operations § If the input logic circuit on the left sends B straight through to the adder, result is G = A+B § What if B was replaced by all-ones instead? ú Result of addition operation: G = A-1 § What if B was replaced by B ? ú Result of addition operation: G = A-B-1 § And what if B was replaced by all zeroes? ú Result is: G = A. ( Not interesting, but useful!) à Instead of a Sub signal, the operation you want is signaled using the select bits S 0 & S 1 .

  15. Operation selection G = A + Y Select Y bits Result Operation Input S 1 S 0 0 0 All 0 s G = A Transfer 0 1 B G = A+B Addition 1 0 B G = A+B Subtraction - 1 1 1 All 1 s G = A-1 Decrement § This is a good start! But something is missing… § Wait, what about the carry-in bit?

  16. Full operation selection Select Input Operation S 1 S 0 Y C in =0 C in =1 0 0 All 0 s G = A (transfer) G = A+1 (increment) 0 1 B G = A+B (add) G = A+B+1 1 0 B G = A+B G = A+B+1 (subtract) 1 1 All 1 s G = A-1 (decrement) G = A (transfer) § Based on the values on the select bits and the carry bit, we can perform any number of basic arithmetic operations by manipulating what value is added to A .

  17. Full operation selection Select Input Operation S 1 S 0 Y C in =0 C in =1 0 0 All 0 s G = A (transfer) G = A+1 (increment) 0 1 B G = A+B (add) G = A+B+1 1 0 B G = A+B G = A+B+1 (subtract) 1 1 All 1 s G = A-1 (decrement) G = A (transfer) § Based on the values on the select bits and the carry bit, we can perform any number of basic arithmetic operations by manipulating what value is added to A .

  18. The “L” of ALU § We also want a circuit that can perform S 0 S 1 logical operations, in addition to G A 4-to-1 0 arithmetic ones. mux B 1 § How do we tell 2 which operation to perform? 3 ú Another select bit! § If S 2 = 1, then logic circuit block is activated. § Multiplexer is used to determine which block (logical or arithmetic) goes to the output.

  19. Single ALU Stage C i+1 C i C i V N A i A i Z Arithmetic B i B i G i circuit S 0 S 0 0 S 1 S 1 G i 1 A i B i Logic G i circuit S 0 S 1 S 2

  20. ALU block diagram § In addition to data inputs and outputs, this circuit also has: ú outputs indicating the different conditions, ú inputs specifying the operation to perform (similar to Sub ). A 0 A 1 Data input A ... G 0 … G 1 A n-1 ... Data output G … B 0 G n-1 B 1 Data input B ... n-bit … B n-1 ALU C out Carry output V Overflow indicator Carry input C in N Negative indicator S 0 Operation & S 1 Z Zero indicator Mode select S 2

  21. What about multiplication? § Multiplication (and division) operations are more complicated than other arithmetic (plus, minus) or logical (AND, OR) operations. § Three major ways that multiplication can be implemented in circuitry: ú Layered rows of adder units. ú An adder/shifter circuit with accumulator. ú Booth’s Algorithm

  22. Break

  23. Multiplication § Revisiting grade 3 math… 12 3 123 x 456 123 x 456 x 456 1368 1368 912 1 2 3 1 23 456 x 456 x 456 56088 1368 1368 912 912 456

  24. Binary Multiplication 5*6 (unsigned) § And now, in binary… 10 1 101 101 x 110 x 110 x 110 110 110 000 110 1 0 1 1 01 x 110 x 110 11110 110 110 000 000 110 Result: 30

  25. Binary Multiplication § Or seen another way…. 101 101 x 11 0 101 x 110 x 110 000 000 101 101 101 101 x 1 1 0 x 1 10 11110 000 000 101 101 101

  26. Binary Multiplication

  27. Implementation § Implementing this in circuitry involves the summation of several AND terms. ú AND gates combine input signals. ú Adders combine the outputs of the AND gates.

  28. Multiplication § This implementation results in an array of adder circuits to make the multiplier circuit. § This can get a little expensive as the size of the operands grows. ú N-bit numbers à O(1) clock cycles, but O(N 2 ) size. § Is there an alternative to this circuit?

  29. Accumulator circuits § What if you could perform each stage of the multiplication operation, one after the other? ú This circuit would only Register Y need a single row of c out adders and a couple Register X Shift Left 1 of shift registers. 1 x n AND ú How wide does register R have Shift Left 1 Adder to be? ú Is there a simpler Register R way to do this?

  30. Sign Extension § To subtract 4-bit number from 8-bit number…. § How do we convert a 4-bit two’s complement number to 8-bit? § Sign extend: replicate most significant bit 0101 à 0000 0101 1001 à 1111 1001 (5) (still 5) (-7) (still -7) § Arithmetic shift right: shift right and replicate sign bit (you saw this in lab!)

  31. Booth’s Algorithm § Devised as a way to take advantage of circuits where shifting is cheaper than adding, or where space is at a premium. ú Based on the premise that when multiplying by certain values (e.g. 99 ), it can be easier to think of this operation as a difference between two products. § Consider the shortcut method when multiplying a given decimal value X by 9999 : X*9999 = X*10000 – X*1 ú § Now consider the equivalent problem in binary: ú X*001111 = X*010000 – X*1

  32. Booth’s Example in Decimal § Compute 999 x 5 à ú 1000 x 5 – 1 x 5 à 5,000 – 5 = 4,995 § Compute 99,900 x 5 à ú 100,000 x 5 – 100 x 5 = 500,000 – 500 = 499,500 § Compute 999,099 x 5 à ú 1,000,000 x 5 – 1,000 x 5 à 5,000,000 – 5,000 = 4,995,000 ú 100 x 5 – 1 x 5 à 500 – 5 = 495 ú 4,995,000 + 495 = 4,995,495

  33. Booth’s Algorithm § This idea is triggered on cases where two neighboring digits in an operand are different. § Go through digits from n-1 to 0 ú If digits at i and i-1 are 0 and 1 , the multiplicand is added to the result at position i . ú If digits at i and i-1 are 1 and 0 , the multiplicand is subtracted from the result at position i . § The result is always a value whose size is the sum of the sizes of the two multiplicands.

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend