Comparator.

Slides:



Advertisements
Similar presentations
Kuliah Rangkaian Digital Kuliah 7: Unit Aritmatika
Advertisements

1 ECE 4436ECE 5367 Computer Arithmetic I-II. 2 ECE 4436ECE 5367 Addition concepts 1 bit adder –2 inputs for the operands. –Third input – carry in from.
Comparators Combinational Design.
Chapter 4 -- Modular Combinational Logic. Decoders.
Combinational Circuits. Analysis Diagram Designing Combinational Circuits In general we have to do following steps: 1. Problem description 2. Input/output.
L10 – Transistors Logic Math 1 Comp 411 – Spring /22/07 Arithmetic Circuits Didn’t I learn how to do addition in the second grade?
Datorteknik ArithmeticCircuits bild 1 Computer arithmetic Somet things you should know about digital arithmetic: Principles Architecture Design.
ECE 331 – Digital System Design
EECS Components and Design Techniques for Digital Systems Lec 17 – Addition, Subtraction, and Negative Numbers David Culler Electrical Engineering.
CSE-221 Digital Logic Design (DLD)
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
ECE 301 – Digital Electronics
ECE 301 – Digital Electronics
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.
EECS Components and Design Techniques for Digital Systems Lec 15 – Addition, Subtraction, and Negative Numbers David Culler Electrical Engineering.
Outline Analysis of Combinational Circuits Signed Number Arithmetic
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
Topic: Arithmetic Circuits Course: Digital Systems Slide no. 1 Chapter # 5: Arithmetic Circuits.
5-1 Programmable and Steering Logic Chapter # 5: Arithmetic Circuits.
ECE 3110: Introduction to Digital Systems Chapter 6 Combinational Logic Design Practices Adders, subtractors, ALUs.
Logic Gates Logic gates are electronic digital circuit perform logic functions. Commonly expected logic functions are already having the corresponding.
Computing Systems Designing a basic ALU.
درس مدارهای منطقی دانشگاه قم مدارهای منطقی محاسباتی تهیه شده توسط حسین امیرخانی مبتنی بر اسلایدهای درس مدارهای منطقی دانشگاه.
Arithmetic Functions BIL- 223 Logic Circuit Design Ege University Department of Computer Engineering.
CHAPTER 4 Combinational Logic Design- Arithmetic Operation (Section 4.6&4.9)
COE 202: Digital Logic Design Combinational Circuits Part 2 KFUPM Courtesy of Dr. Ahmad Almulhem.
ECE 3110: Introduction to Digital Systems Chapter 5 Combinational Logic Design Practices X-OR gates and Parity circuits Comparators Adders, subtractors,
1 Lecture 12 Time/space trade offs Adders. 2 Time vs. speed: Linear chain 8-input OR function with 2-input gates Gates: 7 Max delay: 7.
EE2174: Digital Logic and Lab Professor Shiyan Hu Department of Electrical and Computer Engineering Michigan Technological University CHAPTER 8 Arithmetic.
Combinational Circuits
Topics covered: Arithmetic CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
ECE 331 – Digital System Design Multi-bit Adder Circuits, Adder/Subtractor Circuit, and Multiplier Circuit (Lecture #12)
1 Chapter 4 Combinational Logic Logic circuits for digital systems may be combinational or sequential. A combinational circuit consists of input variables,
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.
CEC 220 Digital Circuit Design
CHAPTER 2 Digital Combinational Logic/Arithmetic Circuits
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.
ECE DIGITAL LOGIC LECTURE 15: COMBINATIONAL CIRCUITS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2015, 10/20/2015.
ETE 204 – Digital Electronics Combinational Logic Design Single-bit and Multiple-bit Adder Circuits [Lecture: 9] Instructor: Sajib Roy Lecturer, ETE,ULAB.
1 Arithmetic Building Blocks Today: Signed ArithmeticFirst Hour: Signed Arithmetic –Section 5.1 of Katz’s Textbook –In-class Activity #1 Second Hour: Adder.
Computer Arthmetic Chapter Four P&H.
Lecture Adders Half adder.
Computer Organization and Design Arithmetic & Logic Circuits
Combinational Circuits
ECE 331 – Digital System Design
Arithmetic Circuits Didn’t I learn how
CSE Winter 2001 – Arithmetic Unit - 1
Lecture 14 Logistics Last lecture Today
King Fahd University of Petroleum and Minerals
Arithmetic Functions & Circuits
Computer Organization and Design Arithmetic & Logic Circuits
Arithmetic Circuits (Part I) Randy H
Combinational logic design case studies
Digital Systems Section 12 Binary Adders. Digital Systems Section 12 Binary Adders.
Digital System Design Combinational Logic
Overview Part 1 – Design Procedure Part 2 – Combinational Logic
Instructor: Mozafar Bag-Mohammadi University of Ilam
Lecture 14 Logistics Last lecture Today
Overview Iterative combinational circuits Binary adders
Addition and multiplication
74LS283 4-Bit Binary Adder with Fast Carry
Presentation transcript:

Comparator

Two-Bit Comparator A B C D LT EQ GT 0 0 0 0 0 1 0 0 1 1 0 0 1 0 1 0 0 0 0 0 0 0 1 0 0 1 1 0 0 1 0 1 0 0 1 1 1 0 0 0 1 0 0 0 0 1 0 1 0 1 0 1 0 0 0 0 0 1 0 1 0 0 1 1 0 0 1 0 1 1 0 0 0 0 1 1 0 0 0 1 1 1 0 1 0 LT EQ GT A B < C D A B = C D A B > C D A B C D N1 N2 block diagram and truth table we'll need a 4-variable Karnaugh map for each of the 3 output functions

Two-Bit Comparator (cont’d) B C' D' + A C' + A B D' 0 0 1 0 D A 1 1 0 1 B C 1 0 0 1 0 0 D A B C 0 1 0 0 1 1 D A 1 0 B C A'B'C'D' + A'BC'D + ABCD + AB'CD’ A' B' D + A' C + B' C D K-map for LT K-map for EQ K-map for GT LT = EQ = GT = = (A xnor C) • (B xnor D)

Equality Comparator XNOR X Y Z 0 0 1 0 1 0 X 1 0 0 Z 1 1 1 Y 0 0 1 0 1 0 1 0 0 1 1 1 X Z Y Z = X XNOR Y

4-bit Equality Detector A_EQ_B B[3..0]

4-Bit Equality Comparator A_EQ_B B1 A2 B2 C2 A3 B3 C3

4-bit Magnitude Comparator A_LT_B A[3..0] Magnitude Detector A_EQ_B B[3..0] A_GT_B

Magnitude Comparator How can we find A_GT_B? How many rows would a truth table have? 28 = 256!

Magnitude Comparator Find A_GT_B Because A3 > B3 i.e. A3 . B3’ = 1 If A = 1001 and B = 0111 is A > B? Why? Therefore, one term in the logic equation for A_GT_B is A3 . B3’

Magnitude Comparator A_GT_B = A3 . B3’ + ….. Because A3 = B3 and + ….. Because A3 = B3 and A2 > B2 i.e. C3 = 1 and A2 . B2’ = 1 If A = 1101 and B = 1011 is A > B? Why? Therefore, the next term in the logic equation for A_GT_B is C3 . A2 . B2’

Magnitude Comparator A_GT_B = A3 . B3’ + C3 . A2 . B2’ + ….. + ….. Because A3 = B3 and A2 = B2 and A1 > B1 i.e. C3 = 1 and C2 = 1 and A1 . B1’ = 1 If A = 1010 and B = 1001 is A > B? Why? Therefore, the next term in the logic equation for A_GT_B is C3 . C2 . A1 . B1’

Magnitude Comparator A_GT_B = A3 . B3’ + C3 . A2 . B2’ + C3 . C2 . A1 . B1’ + ….. Because A3 = B3 and A2 = B2 and A1 = B1 and A0 > B0 i.e. C3 = 1 and C2 = 1 and C1 = 1 and A0 . B0’ = 1 If A = 1011 and B = 1010 is A > B? Why? Therefore, the last term in the logic equation for A_GT_B is C3 . C2 . C1 . A0 . B0’

Magnitude Comparator A_GT_B = A3 . B3’ + C3 . A2 . B2’ + C3 . C2 . A1 . B1’ + C3 . C2 . C1 . A0 . B0’

Magnitude Comparator Find A_LT_B A_LT_B = A3’ . B3 + C3 . A2’ . B2 + C3 . C2 . A1’ . B1 + C3 . C2 . C1 . A0’ . B0

TTL 74x85 4 B A g e l gt eq lt

TTL 74x85 if (A>B) lt=0, eq=0, gt=1 if (A<B) lt=1, eq=0, gt=0 if (A=B) lt=l, eq=e, gt=g The three l, e and g inputs are used when cascading. 4 B A g e l gt eq lt

Comparator (continued…) Let us now cascade four of the 74x85 to construct a 16 bit comparator. Exercise: Analyze it.

TTL 74x682 8-bit Comparator Arithmetic conditions derived from 74x682 outputs? And their circuits?

Maximum Finder Design a maximum finder a b 4

Adder

Adder Review 01_numbers.ppt

اعمال رياضي باينري: جمع قوانين: مانند جمع دسيمال با اين تفاوت که1+1 = 10  توليد نقلي 0+0 = 0c0 (sum 0 with carry 0) 0+1 = 1+0 = 1c0 1+1 = 0c1 1+1+1 = 1c1 Carry 1 Augend Addend Result

مکمل 2: نمايش اعداد n N* = 2 - N 4 2 = 10000 7 = 0111 sub 2 = 10000 7 = 0111 1001 = repr. of -7 مکمل 2: sub Example: Twos complement of 7 4 Example: Twos complement of -7 2 = 10000 -7 = 1001 0111 = repr. of 7 sub Shortcut method: Twos complement = bitwise complement + 1 0111 -> 1000 + 1 -> 1001 (representation of -7) 1001 -> 0110 + 1 -> 0111 (representation of 7)

جمع و تفريق مکمل 2 4 + 3 7 0100 0011 0111 -4 + (-3) -7 1100 1101 11001 If )carry-in to sign = carry-out ( then ignore carry if )carry-in ≠ carry-out( then overflow 4 - 3 1 0100 1101 10001 -4 + 3 -1 1100 0011 1111 Simpler addition scheme makes twos complement the most common choice for integer number systems within digital systems

سرريز Overflow Conditions Add two positive numbers to get a negative number or two negative numbers to get a positive number -1 +0 -1 +0 -2 1111 0000 +1 -2 1111 0000 +1 1110 1110 -3 0001 -3 0001 +2 1101 +2 1101 0010 0010 -4 -4 1100 +3 0011 1100 +3 0011 -5 -5 1011 1011 0100 +4 0100 +4 -6 1010 -6 1010 0101 0101 +5 +5 1001 1001 0110 0110 -7 +6 -7 1000 +6 0111 1000 0111 -8 +7 -8 +7 5 + 3 = -8 -7 - 2 = +7

سرريز Overflow Conditions 0 1 1 1 1 0 0 0 0 1 0 1 1 0 0 1 5 -7 0 0 1 1 -2 7 1 0 0 0 1 0 0 1 1 1 0 0 1 0 1 1 1 Overflow 5 3 -8 Overflow 5 2 7 0 0 0 0 0 1 0 1 0 0 1 0 0 1 1 1 No overflow -3 -5 -8 1 1 1 1 1 1 0 1 1 0 1 1 1 1 0 0 0 No overflow Overflow when carry in to sign ≠ carry out

Half Adder (HA) Add single bits Ai Bi 1 Ai Bi 1 Ai Bi Sum Carry 1 1 1 1 Ai Bi 1 Ai Bi Sum Carry 1 1 1 1 1 1 1 Sum = Ai Bi + Ai Bi = AiBi Carry = Ai . Bi

Full Adder Add multiple bits

Full Adder (FA) S = CI xor A xor B A B CI 1 00 01 11 10 A 1 B CI S CO S A B CI 1 00 01 11 10 CO S = CI xor A xor B CO = B CI + A CI + A B = CI (A + B) + A B

Full Adder Using 2 Half Adders A full adder can also be realized with two half adders and an OR gate, since Ci+1 can also be expressed as: Ci+1 = AiBi + (Ai  Bi)Ci and Si = (Ai  Bi)  Ci Ai Bi Si Ci+1 Ci

Example: 4-bit Ripple Carry Adder C4 C3 C2 C1 C0 A3 A2 A1 A0 +B3 B2 B1 B0 -------------- S3 S2 S1 S0

Delay Analysis of Ripple Adder Carry out of a single stage can be implemented in 2 gate delays after CI is ready. For a 16 bit adder, the 16th bit carry is generated after about 16 * 2 = 32 gate delays. The sum bit takes one additional gate delay to generate the sum of the 16th bit after 15th bit carry ~ 15 * 2 + 1 = 31 gate delays Takes too long - need to investigate FASTER adders!

Delay Analysis of Ripple Adder B CI CO @0 @N @1 @N+1 @N+2 late arriving signal two gate delays to compute CO A B C S @2 1 @3 A B CI S @0 @N @N+1 4 stage adder A 1 B S @4 C 2 @5 A 2 B S @6 C 3 @7 A 3 B S @8 C 4 @9

Carry Lookahead Adder Carry Generate Carry Propagate Gi = Ai Bi must generate carry when A = B = 1 Carry Propagate Pi = Ai xor Bi carry-in will equal carry-out here Sum and Carry can be reexpressed in terms of generate/propagate: Si = Ai xor Bi xor Ci = Pi xor Ci Ci+1 = Ai Bi + Ai Ci + Bi Ci = Ai Bi + Ci (Ai + Bi) = Ai Bi + Ci (Ai xor Bi) = Gi + Ci Pi

Carry Lookahead Adder 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!

CLA Increasingly complex logic Ai Pi Bi Si Ci Gi @0 @1 @0 @t+1 @t @1

Delay Analysis of CLA Ci’s are generated independent of N B C S @2 1 @3 A 1 B S @4 C 2 @3 4 stage adder A 2 B S @4 C 3 @3 A 3 B S @4 C 4 @3 final sum and carry NOTE HOWEVER THIS ASSUMES ALL GATE DELAYS ARE SAME Not true, delays depand on fan-ins and fan-out

Cascaded CLA CLA CLA CLA

Adder/Subtractor A - B = A + (-B) = A + B’ + 1

4-bit Binary Adder/Subtractor (cont.) S=0 selects addition

4-bit Binary Adder/Subtractor (cont.) 1 S=1 selects subtraction

Overflow Overflow can occur ONLY when both numbers have the same sign. This condition can be detected when the carry out (Cn) is different than the carry at the previous position (Cn-1).

The Overflow problem in Signed-2’s Complement (cont.) Example 1: M=6510 and N=6510 (In an 8-bit 2’s complement system). M = N = 010000012 M+N = 10000010 with Cn=0. (clearly wrong!) Bring Cn as the MSB to get 0100000102 (13010) which is correct, but requires 9-bits  overflow occurs. Example 2: M=-6510 and N=-6510 M = N = 101111112 M+N = 01111110 with Cn=1. (wrong again!) Bring Cn as the MSB to get 1011111102 (-13010) which is correct, but also requires 9-bits  overflow occurs.

Overflow Detection in Signed-2’s Complement Cn-1 Cn C n-bit Adder/Subtractor C =1 indicates overflow condition when adding/subtr. unsigned numbers. V=1 indicates overflow condition when adding/subtr. signed-2’s complement numbers

2x2-bit Multiplier A2 A1 B2 B1 P8 P4 P2 P1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 1 1 0 0 0 1 0 1 1 0 0 1 1 1 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 1 0 0 1 1 0 1 1 0 1 1 0 0 0 0 0 0 0 1 0 0 1 1 1 0 0 1 1 0 1 1 1 0 0 1 P1 P2 P4 P8 A1 A2 B1 B2 4-variable K-map for each of the 4 output functions

2x2-bit Multiplier (cont’d) 0 0 B1 A2 1 0 A1 B2 0 0 B1 A2 0 1 1 1 A1 B2 K-map for P8 K-map for P4 P4 = A2B2B1' + A2A1'B2 P8 = A2A1B2B1 0 0 1 1 B1 A2 0 1 1 0 A1 B2 0 0 0 1 1 0 B1 A2 A1 B2 K-map for P2 K-map for P1 P1 = A1B1 P2 = A2'A1B2 + A1B2B1' + A2B2'B1 + A2A1'B1

Multiplier X3 Y3 X3 Y2 X2 Y3 X3 Y1 X2 Y2 X1 Y3 X3 Y3 X2 Y0 X2 Y1 X1 Y2 Z7 Z6 Z5 Z4 Z3 Z2 Z1 Z0

4-Bit ALU 74181 TTL ALU Arithmetic-Logic Unit

4-Bit ALU

BCD Addition Addition: 5 = 0101 3 = 0011 1000 = 8 5 = 0101 8 = 1000 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

اعداد در مبناهاي مختلف Add 0110 to sum whenever it exceeds 1001 (11XX or 1X1X)

BCD Adder Add 0110 to sum whenever it exceeds 1001 (11XX or 1X1X) A B 3 B 3 A 2 B 2 A 1 B 1 A B CO F A CI CO F A CI CO F A CI CO F A CI Cin S S S S 1 1XX A1 1X1X A2 CO F A CI CO F A CI S S Cout S 3 S 2 S 1 S Add 0110 to sum whenever it exceeds 1001 (11XX or 1X1X)