1 Arithmetic Building Blocks Today: Signed ArithmeticFirst Hour: Signed Arithmetic –Section 5.1 of Katz’s Textbook –In-class Activity #1 Second Hour: Adder.

Slides:



Advertisements
Similar presentations
L10 – Transistors Logic Math 1 Comp 411 – Spring /22/07 Arithmetic Circuits Didn’t I learn how to do addition in the second grade?
Advertisements

Comparator.
ELEC353 S. al Zahir UBC Sign-Magnitude Representation High order bit is sign: 0 = positive (or zero), 1 = negative Low order bits represent the magnitude:
Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design.
ECE 331 – Digital System Design
Contemporary Logic Design Multi-Level Logic © R.H. Katz Transparency No Chapter # 3: Multi-Level Combinational Logic 3.3 and Time Response.
EECS Components and Design Techniques for Digital Systems Lec 17 – Addition, Subtraction, and Negative Numbers David Culler Electrical Engineering.
Overview Iterative combinational circuits Binary adders
ECE C03 Lecture 61 Lecture 6 Arithmetic Logic Circuits Hai Zhou ECE 303 Advanced Digital Design Spring 2002.
Chapter # 5: Arithmetic Circuits Contemporary Logic Design Randy H
Lecture 8 Arithmetic Logic Circuits
Design of Arithmetic Circuits – Adders, Subtractors, BCD adders
Overview Iterative combinational circuits Binary adders
ECE 301 – Digital Electronics
ECE 301 – Digital Electronics
Overview Iterative combinational circuits Binary adders
1 CSE-221 Digital Logic Design (DLD) Lecture-1: Digital Systems & Number Systems.
Chapter 5 Arithmetic Logic Functions. Page 2 This Chapter..  We will be looking at multi-valued arithmetic and logic functions  Bitwise AND, OR, EXOR,
Charles Kime & Thomas Kaminski © 2008 Pearson Education, Inc. (Hyperlinks are active in View Show mode) Chapter 4 – Arithmetic Functions Logic and Computer.
Lecture # 12 University of Tehran
Logic Design CS221 1 st Term combinational circuits Cairo University Faculty of Computers and Information.
Digital Arithmetic and Arithmetic Circuits
Chapter 4 – Arithmetic Functions and HDLs Logic and Computer Design Fundamentals.
Fall 2004EE 3563 Digital Systems Design EE 3563 Comparators  Comparators determine if two binary inputs are equal  Some will signal greater than/less.
Chapter # 5: Arithmetic Circuits
Chapter 6-1 ALU, Adder and Subtractor
Charles Kime & Thomas Kaminski © 2008 Pearson Education, Inc. (Hyperlinks are active in View Show mode) Chapter 4 – Arithmetic Functions Logic and Computer.
Topic: Arithmetic Circuits Course: Digital Systems Slide no. 1 Chapter # 5: Arithmetic Circuits.
5-1 Programmable and Steering Logic Chapter # 5: Arithmetic Circuits.
درس مدارهای منطقی دانشگاه قم مدارهای منطقی محاسباتی تهیه شده توسط حسین امیرخانی مبتنی بر اسلایدهای درس مدارهای منطقی دانشگاه.
1 Arithmetic I Instructor: Mozafar Bag-Mohammadi Ilam University.
Topics covered: Arithmetic CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
COMP541 Arithmetic Circuits
69 Decimal (Base 10) Numbers n Positional system - each digit position has a value n 2534 = 2*1, * *10 + 4*1 n Alternate view: Digit position.
ECE 331 – Digital System Design Multi-bit Adder Circuits, Adder/Subtractor Circuit, and Multiplier Circuit (Lecture #12)
1 Carry Lookahead Logic Carry Generate Gi = Ai Bi must generate carry when A = B = 1 Carry Propagate Pi = Ai xor Bi carry in will equal carry out here.
CS 151: Digital Design Chapter 4: Arithmetic Functions and Circuits
1 Fundamentals of Computer Science Combinational Circuits.
ECE/CS 552: Arithmetic I Instructor:Mikko H Lipasti Fall 2010 University of Wisconsin-Madison Lecture notes partially based on set created by Mark Hill.
1 Lecture 14 Binary Adders and Subtractors. 2 Overview °Addition and subtraction of binary data is fundamental Need to determine hardware implementation.
Lecture #23: Arithmetic Circuits-1 Arithmetic Circuits (Part I) Randy H. Katz University of California, Berkeley Fall 2005.
President UniversityErwin SitompulDigital Systems 7/1 Lecture 7 Digital Systems Dr.-Ing. Erwin Sitompul President University
ETE 204 – Digital Electronics Combinational Logic Design Single-bit and Multiple-bit Adder Circuits [Lecture: 9] Instructor: Sajib Roy Lecturer, ETE,ULAB.
Arithmetic Circuits I. 2 Iterative Combinational Circuits Like a hierachy, except functional blocks per bit.
Gunjeet Kaur Dronacharya Group of Institutions. Binary Adder-Subtractor A combinational circuit that performs the addition of two bits is called a half.
Haifeng Liu 2014 Fall College of Computer Science and Technology, Zhejiang University Chapter 4 – Arithmetic Functions and Circuits.
Combinational Circuits
Digital Systems and Number Systems
Digital Systems Section 8 Multiplexers. Digital Systems Section 8 Multiplexers.
FUNCTION OF COMBINATIONAL LOGIC CIRCUIT
ECE 331 – Digital System Design
CSE Winter 2001 – Arithmetic Unit - 1
King Fahd University of Petroleum and Minerals
Arithmetic Functions & Circuits
Arithmetic Circuits (Part I) Randy H
Subtraction The arithmetic we did so far was limited to unsigned (positive) integers. Today we’ll consider negative numbers and subtraction. The main problem.
EE207: Digital Systems I, Semester I 2003/2004
Instructor: Alexander Stoytchev
Combinational logic design case studies
Digital Systems Section 12 Binary Adders. Digital Systems Section 12 Binary Adders.
Overview Part 1 – Design Procedure Part 2 – Combinational Logic
Instructor: Alexander Stoytchev
Instructor: Mozafar Bag-Mohammadi University of Ilam
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Overview Iterative combinational circuits Binary adders
ECE 352 Digital System Fundamentals
Instructor: Alexander Stoytchev
Combinational Circuits
Presentation transcript:

1 Arithmetic Building Blocks Today: Signed ArithmeticFirst Hour: Signed Arithmetic –Section 5.1 of Katz’s Textbook –In-class Activity #1 Second Hour: Adder Circuits. Section 5.1 of Katz’s Textbook –In-class Activity #2

2 Recap: Building Blocks we’ve learned about thus far: –Programmable Logic Arrays –Multiplexors & De-multiplexors –Read-only Memory Today: Representation of Negative Numbers Building Blocks: Adders and Subtractors

3 Sign & Magnitude Representation Sign equals the High order bit:Sign equals the High order bit:0 = positive or zero (non-negative) 1 = negative Magnitude equals the three low order bits:Magnitude equals the three low order bits: 0 = 000 thru 7 = 111 n The number range =  7 for 4 bit numbers; for n bits,  2 n-1 -1 Two Representations for 0 (redundant & problematic) = = sign - sign 4 bit example

4 Sign & Magnitude (-3) Sign of the result: the same as the operands' sign (Don’t add sign bits) Operands have the same sign 4 + (-3) Sign of the result: the sign of operand with the larger magnitude Magnitude of the result: subtraction operation Operands have different signs Addition

5 Sign & Magnitude (-3) Sign of the result: the same as the operands' sign (Don’t subtract sign bits) Operands have the same sign 4 - (-3) Sign of the result: the sign of operand with the larger magnitude Magnitude of the result: addition operation Operands have different signs Subtraction

6 AdditionAddition –Addition when signs of operand the same –Subtraction when signs of operands differ –Must compare magnitudes to determine sign of result SubtractionSubtraction –Subtraction when signs of operand the same –Addition when signs of operands differ –Must compare magnitudes to determine sign of result Complicated implementationComplicated implementation –Adder unit –Subtractor unit –Comparator unit Sign & Magnitude

7 Sign Magnitude One's Complement Two's Complement 000 = = = = = = = = = = = = = = = = = = = = = = = = - 1 Issues: balance, number of zeros, ease of operations Two’s complement is ideal because hardware is simpler Same circuit for addition and subtraction Signed Representations

8 Pizza Pie Diagram Only one zero

9 MSB = The Sign Bit MSB=0 For zero and positive numbers Positive numbers are the same as in Sign-Magnitude

10 MSB = The Sign Bit MSB=1 For negative numbers

11 More Negative Numbers than Positives One more negative number. No +4

12 Recognizing Overflow 3+1 = -4 Wrong sign Indicates overflow

13 Carries Twos-Complement Calculations overflow no overflow Overflow occurs when the carry in to the sign position does not equal the carry out of the sign position Also, wrong sign  Overflow

14 AdditionAddition –Addition not dependent on the signs of operand –No need to compare magnitudes to determine sign of result SubtractionSubtraction –Subtraction is treated as an addition –Add the negative of the subtrahend to the minuend Simple implementationSimple implementation –Adder unit –Negation circuit unit Twos-Complement Simpler addition/subtraction scheme makes twos-complement the most common choice for integer number systems within digital systems Simpler addition/subtraction scheme makes twos-complement the most common choice for integer number systems within digital systems

15 Do Activity #1 Now Get to know two’s complement arithmetic

16 Half Adder Adder With twos-complement, adders are sufficient Half-adder Carry Sum A i B i A i B i Sum Carry 0 1

17 Full Adder S = A  B  CI CO = B CI + A CI + A B = (A + B) CI + A B S = A  B  CI CO = B CI + A CI + A B = (A + B) CI + A B A B CI S CO A B CI A B CI S CO 1 1

18 Multi-Bit Adder A3B3 S3 A2B2 S2 A1B1 S1 A0B0 S0C1C2C3 C0 using Full Adder Units FA C4

19 Full Adder Full Adder from Half Adders S = A  B  CI Alternative Implementation: 5 Gates - 2 XOR, 2 AND, & 1 OR CO = A B + (A  B) CI = A B + B CI + A CI + Half Adder A B Half Adder A  B CI SS CO (A  B) CI A B S CO Standard Approach: 6 Gates A A A B B B CI S CO

20 AB CO S +CI AB CO S +CI AB CO S +CI AB CO S +CI 01 Add/Subtract A 3 B 3 B 3 01 A 2 B 2 B 2 01 A 1 B 1 B 1 01 A 0 B 0 B 0 Sel S 3 S 2 S 1 S 0 Adder/Subtractor A - B = A + (-B) = A + (B + 1) 2s complement negative Overflow

21 How Fast is it? A i B i Inputs A i & B i are available time 0 C I The C I from lower bit additions take time. Suppose CI is time N one gate delay from N to compute S one gate delay from N to compute S A B 1 two gate delays from N to compute CO two gate delays from N to compute CO A A B B 2

22 The Carry bit Ripples Slowly means signal is available after n gate delays 4 stage adder A 0 B 0 C 0 S A 1 B 1 C S A 2 B 2 C S A 3 B 3 C S C Critical delay: Critical delay: the propagation of carry from low to high order stages

23 Timing Diagram The propagation of carry from low to high order stages worst case addition worst case addition T0: Inputs to the adder are valid T2: Stage 0 carry out (C1) T4: Stage 1 carry out (C2) T6: Stage 2 carry out (C3) T8: Stage 3 carry out (C4) N + 2 delays to compute sum But last carry is not ready until 6 delays later, N = 6 until 6 delays later, N = 6 N + 2 delays to compute sum But last carry is not ready until 6 delays later, N = 6 until 6 delays later, N = 6 T0T2T4T6T8 S0, C1 ValidS1, C2 ValidS2, C3 ValidS3, C4 Valid

24 A Faster Adder To make our adder faster, we must compute the carry faster Just how fast can it be? Ultimately, the adder is just a large combinational circuit. We should be able to realize it using 2-state logic. Price to pay: more gates. Plan: Express each carry directly in terms of the A i, B i, and C 0

25 Observe: A B CI S CO CO = 0 CO = CI CO = 1 (if AB=1, Carry out =1 regardless of carry in) CARRY GENERATED if A  B, Carry out =Carry in CARRY PROPAGATED

26 Carry Lookahead Logic Carry Generate G i = A i B i Carry Generate G i = A i B i must generate carry when A = B = 1 Carry Propagate P i = A i  B i Carry Propagate P i = A i  B i carry in will equal carry out here Carry Generate G i = A i B i Carry Generate G i = A i B i must generate carry when A = B = 1 Carry Propagate P i = A i  B i Carry Propagate P i = A i  B i carry in will equal carry out here S i = A i  B i  C i = P i  C i C i+1 = A i B i + A i C i + B i C i = A i B i + C i (A i + B i ) = A i B i + C i (A i + B i ) = A i B i + C i (A i  B i ) = A i B i + C i (A i  B i ) = G i + C i P i = G i + C i P i Let CI = C i, then CO = C i+1 show logical equivalence

27 Expand it out C 1 = G 0 + P 0 C 0 C 2 = G 1 + P 1 C 1 = G 1 + P 1 G 0 + P 1 P 0 C 0 C 3 = G 2 + P 2 C 2 = G 2 + P 2 G 1 + P 2 P 1 G 0 + P 2 P 1 P 0 C 0 C 4 = G 3 + P 3 C 3 = G 3 + P 3 G 2 + P 3 P 2 G 1 + P 3 P 2 P 1 G 0 + P 3 P 2 P 1 P 0 C 0 two-level 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!

28 Implementation Increasingly complex logic Adder with Sum, Propagate and Generate Outputs Adder with Sum, Propagate and Generate Outputs P 1 gate delay CiCi S 2 gate delays BiBi AiAi G 1 gate delay

29 Carry Lookahead Delays First Level Carry Lookahead Carry lookahead logic generates individual Result: sums computed faster Result: sums computed faster A 0 B 0 C 0 S A 1 B 1 C S A 2 B 2 C S A 3 B 3 C S C Reduced slowest output from 8 to 4 gate delays!

30 Building Larger Adders Second Level Carry Look-ahead 4 bit adders with internal carry look-ahead Second level carry lookahead unit, extends look-ahead to 16 bits 4 bit adders with internal carry look-ahead Second level carry lookahead unit, extends look-ahead to 16 bits

31 Do Activity #2 Now Due: End of Class Today RETAIN THE LAST PAGE (#3)!! For Next Class: Bring Randy Katz Textbook, & TTL Data Book Required Reading: – Sec 3.4 & 5.3 of Katz This reading is necessary for getting points in the Studio Activity!