Presentation is loading. Please wait.

Presentation is loading. Please wait.

Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -1 Arithmetic Circuits (Part II) Randy H. Katz University of.

Similar presentations


Presentation on theme: "Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -1 Arithmetic Circuits (Part II) Randy H. Katz University of."— Presentation transcript:

1 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -1 Arithmetic Circuits (Part II) Randy H. Katz University of California, Berkeley Fall 2005

2 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -2 Overview BCD Circuits Combinational Multiplier Circuit Design Case Study: 8 Bit Multiplier Sequential Multiplier Circuit

3 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -3 BCD Addition BCD Number Representation Decimal digits 0 thru 9 represented as 0000 thru 1001 in binary Addition: 5 = 0101 3 = 0011 1000 = 8 5 = 0101 8 = 1000 1101 = 13! Problem when digit sum exceeds 9 Solution: add 6 (0110) if sum exceeds 9! 5 = 0101 8 = 1000 1101 6 = 0110 1 0011 = 1 3 in BCD 9 = 1001 7 = 0111 1 0000 = 16 in binary 6 = 0110 1 0110 = 1 6 in BCD

4 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -4 BCD Addition Adder Design Add 0110 to sum whenever it exceeds 1001 (11XX or 1X1X) FAFAFAFA FAFA Cin A 3 A 2 A 1 A 0 B 3 B 2 B 1 B 0 CoutS 3 S 2 S 1 S 0 0 COCI S COCI S COCI S COCI S COCI S COCI S 11XX A1 A2 1X1X

5 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -5 Combinational Multiplier Basic Concept multiplicand multiplier 1101 (13) 1011 (11) 1101 0000 1101 * 10001111 (143) Partial products product of 2 4-bit numbers is an 8-bit number

6 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -6 Combinational Multiplier Partial Product Accumulation A0 B0 A0 B0 A1 B1 A1 B0 A0 B1 A2 B2 A2 B0 A1 B1 A0 B2 A3 B3 A3 B0 A2 B1 A1 B2 A0 B3 A3 B1 A2 B2 A1 B3 A3 B2 A2 B3 A3 B3 S6 S5 S4 S3S2 S1S0 S7

7 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -7 Combinational Multiplier Partial Product Accumulation Note use of parallel carry-outs to form higher order sums 12 Adders, if full adders, this is 6 gates each = 72 gates 16 gates form the partial products total = 88 gates! A 0 B 0 A 1 B 0 A 0 B 1 A 0 B 2 A 1 B 1 A 2 B 0 A 0 B 3 A 1 B 2 A 2 B 1 A 3 B 0 A 1 B 3 A 2 B 2 A 3 B 1 A 2 B 3 A 3 B 2 A 3 B 3 HA S 0 S 1 FA FA S 3 FA FA S 4 FA S 2 FA FA S 5 FA S 6 S 7

8 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -8 C CCCC CCCC CCC Combinational Multiplier Another Representation of the Circuit SSSS C SSSS SSSS SSSS B0 B1 B2 P7P6P5P4P3P2P1P0 A3A2 A1 A0 Building block: full adder + and 4 x 4 array of building blocks FA X Y AB S CICO Cin Sum In Sum Out Cout A3 B0A2 B0A1 B0A0 B0 A3 B1A2 B1A1 B1A0 B1 A3 B2A2 B2A1 B2A0 B2 A3 B3A2 B3A1 B3A0 B3 B3 0 0 0 0

9 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -9 Case Study: 8 x 8 Multiplier TTL Multipliers Two chip implementation of 4 x 4 multipler

10 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -10 Case Study: 8 x 8 Multiplier Problem Decomposition How to implement 8 x 8 multiply in terms of 4 x 4 multiplies? A7-4 B7-4 A3-0 B3-0 * A3-0 * B3-0 A7-4 * B3-0 A3-0 * B7-4 A7-4 * B7-4 = PP0 = PP1 = PP2 = PP3 P15-12 P11-8 P7-4 P3-0 8 bit products P3-0 = PP0 P7-4 = PP0 + PP1 + PP2 P11-8 = PP1 + PP2 + PP3 P15-12 = PP3 3-0 7-4 3-0 7-4 + Carry-in

11 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -11 Case Study: 8 x 8 Multiplier Calculation of Partial Products Use 4 4x4 multipliers to create the 4 partial products

12 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -12 Case Study: 8 x 8 Multiplier Three-At-A-Time Adder Clever use of the Carry Inputs Sum A[3-0], B[3-0], C[3-0]: Two Level Full Adder Circuit Note: Carry lookahead schemes also possible!

13 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -13 Case Study: 8 x 8 Multiplier Three-At-A-Time Adder with TTL Components Full Adders (2 per package) Standard ALU configured as 4-bit cascaded adder (with internal carry lookahead) Note the off-set in the outputs Full Adder Full Adder Full Adder Full Adder 4-bit ALU/Adder

14 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -14 Case Study: 8 x 8 Multiplier Accumulation of Partial Products Just a case of cascaded three-at-a-time adders! 4-bit ALU/Adder FA

15 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -15 Case Study: 8 x 8 Multiplier The Complete System (Actual TTL packages)

16 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -16 Case Study: 8 x 8 Multiplier Package Count and Performance 4 74284/74285 pairs = 8 packages 4 74183, 3 74181, 1 74182 = 8 packages 16 packages total Partial product calculation (74284/285) = 40 ns typ, 60 ns max Intermediate sums (74183) = 9 ns/20ns = 15 ns average, 33 ns max Second stage sums w/carry lookahead 74LS181: carry G and P = 20 ns typ, 30 ns max 74182: second level carries = 13 ns typ, 22 ns max 74LS181: formations of sums = 15 ns typ, 26 ns max 103 ns typ, 171 ns max

17 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -17 Sequential Multiplier 4-Bit Multiplier Example: 3 x 4 = 12 –Four cycles to completion CycleMultiplierMultiplicandProduct Initialize00110000 01000000 Cycle 0, Multiplier[0]=100010000 10000000 0100 Cycle 1, Multiplier[0]=100000001 00000000 1100 Cycle 2, Multiplier[0]=000000010 00000000 1100 Cycle 3, Multiplier[0]=000000100 00000000 1100 Product = 0 For i = 0 to 3 do If Multiplier[0] = 1 then Product = Product + Multiplicand Shift right the Multiplier Shift left the Multiplicand

18 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -18 Sequential Multiplier Datapath and Control Block Diagram –External load signals for Multiplier and Multiplicand –Low order bit of multiplier: if 0, shift; if 1, shift and add Multiplicand Multiplier Product ‘0’ Accumulator 16 Shift Load3 Control Start Digit ShiftLoad3 Clock Clear ‘0’ 88 8 Load1 Load2

19 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -19 Sequential Multiplier State Diagram –One state for each bit Start/Clear Idle Reset S0 S1 S2 S3 S4 S5 S6 S7 Digit/Load3,Shift Digit’/Shift Start’ Digit/Load3,Shift Digit’/Shift

20 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -20 Sequential Multiplier Control Timing Behavior IdleS0 Clk State Start Clear Load Shift S1S2S3S4S5S6S7Idle Digit0Digit1Digit2Digit3Digit4Digit5Digit6Digit7

21 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -21 Sequential Multiplier Slightly Revised Block Diagram –If multiplier low order bit is 0 than assert 0 into accumulator –Else pass multiplicand through to accumulator –Simplifies the control! Pass or Zero Pass/Zero’ Multiplicand Multiplier Product ‘0’ Accumulator 16 Load3-Shift Digit Clear ‘0’ 88 8 Load1 Load2 16 Control Start Load3-Shift Clock Clear

22 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -22 Sequential Multiplier Revised State Diagram –Fewer control outputs! Start/Clear Idle Reset S0 S1 S2 S3 S4 S5 S6 S7 Load3-Shift Start’ Load3-Shift

23 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -23 Sequential Multiplier Symbolic/Encoded State Transition Table –State assignment chosen as follows: »Idle state set to 0000, i.e., START resets the state FFs »States S0 to S7 set to 1000 to 1111, easy to implement as a counter Current State Start Next State Clear Load3-Shift Idle000000000Idle 0 0 Idle000011000S0 1 0 S01000-1001S1 0 1 S11001-1010S2 0 1 S21010-1011S3 0 1 S31011-1100S4 0 1 S41100-1101S5 0 1 S51101-1110S6 0 1 S61110-1111S7 0 1 S71111-0000Idle 0 1

24 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -24 Booth Multiplier Tricky encoding scheme to reduce the number of stages in a binary multiplier Considers two bits at a time rather than one—this cuts the number of multiplier steps in half Each step is slightly more complex compared to the simple multiplier, but is almost as fast as the basic multiplier stage that it replaces Searching for ways to speed up the basic multiply step

25 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -25 Alternative Multiply Hardware 32-bit Multiplicand reg, 32 -bit ALU, 64-bit Product reg, (0-bit Multiplier reg) Rather than shift multiplier right and multiplicand left, we can shift BOTH the product and the multiplier to the right … Product (Multiplier) Multiplicand 32-bit ALU Write Control 32 bits 64 bits Shift Right

26 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -26 Multiply Control MultiplicandProduct 0010 0000 0011 Done Yes: 32 repetitions 2. Shift the Product register right 1 bit. No: < 32 repetitions 1.Test Product0 Product0 = 0 Product0 = 1 1a. Add multiplicand to the left half of product & place the result in the left half of Product register 32nd repetition? Start

27 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -27 Motivation for Booth’s Algorithm Example 2 x 6 = 0010 x 0110: 0010 x 0110 + 0000 shift (0 in multiplier) + 0010 add (1 in multiplier) + 0010 add (1 in multiplier) + 0000 shift (0 in multiplier) 00001100 If ALU can subtract as well as add, get same result as follows: 6= – 2 + 8 0110 = – 00010 + 01000 = 11110 + 01000 For example 0010 x 0110 0000 shift (0 in multiplier) – 0010 sub(first 1 in multiplier) 0000 shift (mid string of 1s) + 0010 add (prior step had last 1) 00001100 Just add 1111110 (twos complement of 2)

28 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -28 Booth Multiplier: an Introduction Recode each 1 in multiplier as “+2-1” –Converts sequences of 1 to 10…0(-1) –Might reduce the number of 1’s 0 0 1 1 1 1 1 1 0 0 +1-1 0 1 0 0 0 0 0-1 0 0

29 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -29 Recoding (Encoding) Example If you use the last row in multiplication, you should get exactly the same result as using the first row (after all, they represent the same number!) 0 1 1 0 1 1 1 0 0 0 1 0 (+1 -1) (+1 -1) (+1 -1) (+1 -1) (+1 -1) (+1 -1) +1 0 -1 +1 0 0 -1 0 0 +1 -1 0

30 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -30 0 0 1 1 0 6x 0 1 1 1 014 +1 0 0-1 0 0 0 0 0 0 1 1 0 1 0(-6) 0 0 0 0 0 0 0 1 1 0 0 0 1 0 1 0 1 0 084 Booth Multiplication Example 111111 Sign extension

31 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -31 Booth’s Algorithm: Implementation Approach Current BitBit to the RightExplanationExampleOp 10Begins run of 1s0001111000sub 11Middle of run of 1s0001111000none 01End of run of 1s0001111000add 00Middle of run of 0s0001111000none Originally for Speed (when shift is faster than add, it is advantageous to replace adds and subs with shifts) Basic idea: replace a string of 1s in multiplier with an initial subtract for rightmost 1 in a run of 1’s, then later add back a 1 for the bit to the left of the last 1 in the run 0 1 1 1 1 0 beginning of run end of run middle of run –1 + 10000 01111

32 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -32 Booth’s Example (2 x 7) 1a. P = P - m1110 +1110 1110 0111 0 shift P (sign ext) 1b. 00101111 0011 1 11 -> nop, shift 2.00101111 1001 1 11 -> nop, shift 3.00101111 1100 1 01 -> add 4a.0010 +0010 0001 1100 1 shift 4b.00100000 1110 0 done OperationMultiplicandProductnext? 0. initial value0010 0000 0111 010 -> sub

33 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -33 Booth’s Example (2 x -3) 1a. P = P - m1110 +1110 1110 1101 0 shift P (sign ext) 1b. 00101111 0110 101 -> add + 0010 2a.0001 0110 1shift P 2b.00100000 1011 010 -> sub +1110 3a.00101110 1011 0shift 3b.0010 1111 0101 111 -> nop 4a1111 0101 1 shift 4b.00101111 1010 1 done OperationMultiplicandProductnext? 0. initial value00100000 1101 010 -> sub

34 Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -34 Lecture Review We have covered: BCD Adders Simple extension of binary adders Multipliers 4 x 4 multiplier: partial product accumulation extension to 8 x 8 case Sequential Multipliers Booth Multiply Step Recoding to speed up the calculation


Download ppt "Contemporary Logic Design Arithmetic Circuits © R.H. Katz Lecture #24: Arithmetic Circuits -1 Arithmetic Circuits (Part II) Randy H. Katz University of."

Similar presentations


Ads by Google