Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 5 Arithmetic Logic Functions. Page 2 This Chapter..  We will be looking at multi-valued arithmetic and logic functions  Bitwise AND, OR, EXOR,

Similar presentations


Presentation on theme: "Chapter 5 Arithmetic Logic Functions. Page 2 This Chapter..  We will be looking at multi-valued arithmetic and logic functions  Bitwise AND, OR, EXOR,"— Presentation transcript:

1 Chapter 5 Arithmetic Logic Functions

2 Page 2 This Chapter..  We will be looking at multi-valued arithmetic and logic functions  Bitwise AND, OR, EXOR, SHIFT etc: Logic functions  ADD, SUBTRACT, etc. Arithmetic functions

3 Page 3 Iterative Functions and circuits  Multi-bit logical functions (AND, OR, etc.) have functional independence between bits  E.G. for a multi-bit AND where we want to find F= A. B we have  On the other hand, Arithmetic functions DO have dependence bit to bit (carry or borrow)  The functions are the same at each bit position but dependent on the previous bit  These functions are known as ITERATIVE

4 Page 4 Iterative Functions cell or stage i-1 cell or stage i cell or stage n-1 cell or stage 0 BiBi AiAi FiFi XiXi YiYi B i-1 A i-1 F i-1 X i-1 Y i-1 B0B0 A0A0 F0F0 X0X0 Y0Y0 B n-1 A n-1 F n-1 X n-1 Y n-1...

5 Page 5 Networks for Binary Addition Half Adder - adds two bits together; generates sum and carry Half-adder Schematic Carry Sum A i B i Ai 0 0 1 1 Bi 0 1 0 1 Sum 0 1 1 0 Carry 0 0 0 1 Ai Bi 01 0 1 01 10 Sum = Ai Bi + Ai Bi = Ai + Bi Ai Bi 01 0 1 00 10 Carry = Ai Bi

6 Page 6 Networks for Binary Addition Full Adder - adds three bits, one being a carry bit Cascaded Multi-bit Adder usually interested in adding more than two bits this motivates the need for the full adder stage 0 B0B0 A0A0 S0S0 C1C1 stage 1 S1S1 C2C2 stage 0 S2S2 C3C3 stage 0 S3S3 C4C4 B1B1 A1A1 B2B2 A2A2 B3B3 A3A3 C0C0

7 Page 7 Networks for Binary Addition Full Adder S = C in xor A xor B C out = B C in + A C in + A B But we can also write in long form =AB+C in A’B+C in AB’ = C in (A xor B) + A B A 0 0 0 0 1 1 1 1 B 0 0 1 1 0 0 1 1 Cin 0 1 0 1 0 1 0 1 S 0 1 1 0 1 0 0 1 Cout 0 0 0 1 0 1 1 1 A B Cin 0 1 00011110 0 1 1 0 1 0 0 1 A B C in 0 1 00011110 0 0 0 1 0 1 1 1 S C Out x

8 Page 8 Networks for Binary Addition Full Adder/Half Adder implementation Alternative Implementation: 5 Gates Standard Approach: 6 Gates A A A B B B Cin S Cout Half Adder A B Half Adder A + B Cin A + B + Cin SS Cout Cin (A+ B) A B S Cout Cout= A B + Cin (A xor B)

9 Page 9 Networks for Binary Addition

10 Page 10 Parallel(Ripple-Carry) Adder

11 Page 11 Parallel Adder-Subtractor  Parallel Adder-Subtractor with 2’s complement numbers:  To subtract, we take the 2’s complement of the second number and add  To take 2’s complement use the approach: Take 1’s complement(Complement bit by bit) and add 1.  To add 1, we will use the carry-in to the rightmost FA.  Assume a select line called Add/subtract

12 Page 12 Networks for Binary Addition Parallel Adder/Subtractor - assumes 2’s complement representation A - B = A + (-B) = A + B + 1 Remember subtraction is the same as taking the 2’s complement and adding,so if add/subtract=1, complement b and add 1 from the rightmost Cin 2x1 mux

13 Page 13 Networks for Binary Addition  The Propagation Delay in Above Circuit:  3 gate delays for each full adder, but waits for 2 gate delays  For a 32 bit adder/subtractor, longest total delay is 32*2+1= 65 gate delays(will show in the next slide)  Too long-should be a shorter way  Assume A, B and C0 are presented to the input at the same time and all gates have the same delay

14 Page 14 Networks for Binary Addition Carry Lookahead Circuits - making things fast Critical delay: the propagation of carry from low to high order stages late arriving signal two gate delays to compute Cout 4 stage adder final sum and carry @N+2 A 0 B 0 C 0 S 0 @2 A 1 B 1 C 1 @3 S 1 @4 A 2 B 2 C 2 @5 S 2 @6 A 3 B 3 C 3 @7 S 3 @8 C 4 @9 0 1 2 3 A A B B Cin Cout @0 @N @1 @N+1 Calculated in parallel

15 Page 15 Networks for Binary Addition Carry Lookahead Logic Carry Generate G i = A i B i must generate carry when A = B = 1 Carry Propagate P i = A i xor B i carry in will equal carry out here S i = A i xor B i xor C i = P i xor C i C i+1 = A i B i + C i (A i xor B i ) C i+1 = G i + C i P i Sum and Carry can be reexpressed in terms of generate/propagate: Idea: each carry can be expressed in terms of Ai, Bi and C 0

16 Page 16 Networks for Binary Addition Carry Lookahead Logic Reexpress the carry logic as follows: C1 = G0 + P0 C0 C2 = G1 + P1 C1 = G1 + P1 G0 + P1 P0 C0 C3 = G2 + P2 C2 = G2 + P2 G1 + P2 P1 G0 + P2 P1 P0 C0 C4 = G3 + P3 C3 = G3 + P3 G2 + P3 P2 G1 + P3 P2 P1 G0 + P3 P2 P1 P0 C0 Each of the carry equations can be implemented in a two-level logic network Variables are the adder inputs and carry in to stage 0!

17 Page 17 Networks for Binary Addition Carry Lookahead Implementation Adder with Propagate and Generate Outputs Increasingly complex logic C0 G3 Pi @ 1 gate delay Ci Si @ 2 gate delays Bi Ai Gi @ 1 gate delay C0 P0 G0 C1 C0 P0 G0 P1 G1 C2 P0 G0 P1 G1 P2 G2 C3 C0 P0 G0 P1 G1 P2 G2 P3 C4

18 Page 18 Networks for Binary Addition Carry Lookahead Logic Cascaded Carry Lookahead Carry lookahead logic generates individual carries sums computed much faster

19 Page 19 Ripple Carry adder Carry-save adder Carry-lookahead unit Partial Full Adder

20 Page 20 Networks for Binary Addition  Propagation Delay in CLA Adder:  Assume a 4-bit adder  Since each carry will be generated in with a 2-level And-or network, there will be a delay of 2 in CLA unit  Other delays: 2 in PFA  So total delay: 4  Ripple carry delay: was 8

21 Page 21  When the number of bits increase, the savings become more appearent but the CLA fan-in will increase unacceptably  What to do? Use cascaded approach

22 Page 22 Networks for Binary Addition Carry Lookahead Logic Cascaded Carry Lookahead 4 bit adders with internal carry lookahead second level carry lookahead unit, extends lookahead to 16 bits

23 Page 23 BCD Addition 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

24 Page 24 BCD Addition Adder Design Add 0110 to sum whenever it exceeds 1001 (11XX or 1X1X)

25 Page 25 Incrementing and Decrementing by 1  Use ‘value fixing’  İf you want S= A+1, then use adder/subtractor as:  A= A, B=0 Cin= 1, function: add  How about S= A-1?  A=A, B= 00001, Cin=0, Fn: subtract Or, B=1111111, Cin=0, fn: add  May have inc/dec in the same circuit  Make at home

26 Page 26 Multiplication and Division by Constants  Shift function: a word can be shifted right or left as many positions as you like with proper circuitry  For a binary number, shifting left one digit means dividing by 2! Shifting right means multiplying by 2!  But be careful with inserted digits.  Will study later with shift registers.


Download ppt "Chapter 5 Arithmetic Logic Functions. Page 2 This Chapter..  We will be looking at multi-valued arithmetic and logic functions  Bitwise AND, OR, EXOR,"

Similar presentations


Ads by Google