Unit 3. Logic Design

Similar documents
(CSC-3501) Lecture 6 (31 Jan 2008) Seung-Jong Park (Jay) CSC S.J. Park. Announcement

UNIT-IV Combinational Logic

CS302 Digital Logic Design Solved Objective Midterm Papers For Preparation of Midterm Exam

Chapter 3 Combinational Logic Design

Combinational Logic Circuits. Combinational Logic

Combinational Circuits DC-IV (Part I) Notes

Digital Electronics 8. Multiplexer & Demultiplexer

UNIT III. Designing Combinatorial Circuits. Adders

Encoders. Lecture 23 5

Digital Logic and Design (Course Code: EE222) Lecture 14: Combinational Contd.. Decoders/Encoders

Digital Electronics. Functions of Combinational Logic

TABLE 3-2 Truth Table for Code Converter Example

LOGIC DIAGRAM: HALF ADDER TRUTH TABLE: A B CARRY SUM. 2012/ODD/III/ECE/DE/LM Page No. 1

Module 4: Design and Analysis of Combinational Circuits 1. Module-4. Design and Analysis of Combinational Circuits

Function Table of an Odd-Parity Generator Circuit


Odd-Prime Number Detector The table of minterms is represented. Table 13.1

CHW 261: Logic Design

LIST OF EXPERIMENTS. KCTCET/ /Odd/3rd/ETE/CSE/LM

SRV ENGINEERING COLLEGE SEMBODAI RUKMANI VARATHARAJAN ENGINEERING COLLEGE SEMBODAI

MSI Design Examples. Designing a circuit that adds three 4-bit numbers

Combinational Circuits: Multiplexers, Decoders, Programmable Logic Devices

COMBINATIONAL CIRCUIT

Digital Integrated CircuitDesign

Structural VHDL Implementation of Wallace Multiplier

An Optimized Implementation of CSLA and CLLA for 32-bit Unsigned Multiplier Using Verilog

Fan in: The number of inputs of a logic gate can handle.

Number system: the system used to count discrete units is called number. Decimal system: the number system that contains 10 distinguished

UNIT-2: BOOLEAN EXPRESSIONS AND COMBINATIONAL LOGIC CIRCUITS

WEEK 4.1. ECE124 Digital Circuits and Systems Page 1

Combinational logic. ! Regular logic: multiplexers, decoders, LUTs and FPGAs. ! Switches, basic logic and truth tables, logic functions

Asst. Prof. Thavatchai Tayjasanant, PhD. Power System Research Lab 12 th Floor, Building 4 Tel: (02)

2 Building Blocks. There is often the need to compare two binary values.

Department of Electronics and Communication Engineering

Laboratory Manual CS (P) Digital Systems Lab

FUNCTION OF COMBINATIONAL LOGIC CIRCUIT

Digital Fundamentals

CHAPTER 3 ANALYSIS OF LOW POWER, AREA EFFICIENT AND HIGH SPEED ADDER TOPOLOGIES

MAHALAKSHMI ENGINEERING COLLEGE TIRUCHIRAPALLI

Chapter 3 Digital Logic Structures

Topic Notes: Digital Logic

Introduction to CMOS VLSI Design (E158) Lecture 5: Logic

Subtractor Logic Schematic

E2.11/ISE2.22 Digital Electronics II

Logic Circuit Design

Subject: Analog and Digital Electronics Code:15CS32

Lecture 02: Digital Logic Review

Combinational Logic. Rab Nawaz Khan Jadoon DCS. Lecturer COMSATS Lahore Pakistan. Department of Computer Science

Propagation Delay, Circuit Timing & Adder Design. ECE 152A Winter 2012

Propagation Delay, Circuit Timing & Adder Design

A Highly Efficient Carry Select Adder

COMBINATIONAL LOGIC CIRCUIT First Class. Dr. AMMAR ABDUL-HAMED KHADER

16 Multiplexers and De-multiplexers using gates and ICs. (74150, 74154)

Digital Logic Design ELCT 201

ISSN Vol.02, Issue.11, December-2014, Pages:

Combinational Logic. Combinational Logic Design Process, Three State Buffers, Decoders, Multiplexers, Encoders, Demultiplexers, Other Considerations

PUBLICATIONS OF PROBLEMS & APPLICATION IN ENGINEERING RESEARCH - PAPER CSEA2012 ISSN: ; e-issn:

CSE 370 Winter Homework 5 Solutions

Experiment # 4. Binary Addition & Subtraction. Eng. Waleed Y. Mousa

Chapter 11. Digital Integrated Circuit Design II. $Date: 2016/04/21 01:22:37 $ ECE 426/526, Chapter 11.

IES Digital Mock Test

Dr. Nicola Nicolici COE/EE2DI4 Midterm Test #1 Oct 18, 2006

EXPERIMENT NO 1 TRUTH TABLE (1)

An Optimized Wallace Tree Multiplier using Parallel Prefix Han-Carlson Adder for DSP Processors

CHAPTER 3 BASIC & COMBINATIONAL LOGIC CIRCUIT

A Survey on A High Performance Approximate Adder And Two High Performance Approximate Multipliers

International Journal of Scientific & Engineering Research, Volume 5, Issue 5, May-2014 ISSN

DELD UNIT 3. Question Option A Option B Option C Option D Correct Option A B C

JDT EFFECTIVE METHOD FOR IMPLEMENTATION OF WALLACE TREE MULTIPLIER USING FAST ADDERS

Gates and Circuits 1

CHAPTER 4 ANALYSIS OF LOW POWER, AREA EFFICIENT AND HIGH SPEED MULTIPLIER TOPOLOGIES

Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates

Data output signals May or may not be same a input signals

CHAPTER 5 DESIGN OF COMBINATIONAL LOGIC CIRCUITS IN QCA

Comparative Analysis of Various Adders using VHDL

UNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering. Digital Computer Arithmetic ECE 666

LOGIC GATES AND LOGIC CIRCUITS A logic gate is an elementary building block of a Digital Circuit. Most logic gates have two inputs and one output.

In this lecture: Lecture 8: ROM & Programmable Logic Devices

Electronics. Digital Electronics

Chapter 1: Digital logic

Digital Applications (CETT 1415) Credit: 4 semester credit hours (3 hours lecture, 4 hours lab) Prerequisite: CETT 1403 & CETT 1405

COMPUTER ARCHITECTURE AND ORGANIZATION

Adder (electronics) - Wikipedia, the free encyclopedia

Project Part 1 A. The task was to design a 4 to 1 multiplexer that uses 8 bit buses on the inputs with an output of a single 8 bit bus.

Overview. This lab exercise requires. A windows computer running Xilinx WebPack A Digilent board. Contains material Digilent, Inc.

COLLEGE OF ENGINEERING, NASIK

DESIGN OF BINARY MULTIPLIER USING ADDERS

DO NOT COPY DO NOT COPY

2 Logic Gates THE INVERTER. A logic gate is an electronic circuit which makes logic decisions. It has one output and one or more inputs.

DIGITAL ELECTRONICS QUESTION BANK

Datapath Components. Control vs. Datapath, Registers, Adders (Binary Addition) Copyright (c) 2012 Sean Key

Lesson: Binary Arithmetic and Arithmetic Circuits-2. Lesson Developer: Dr. Divya Haridas

Combinational Logic Design CH002

Design of a Power Optimal Reversible FIR Filter ASIC Speech Signal Processing

Comparison among Different Adders

Chapter 3. H/w s/w interface. hardware software Vijaykumar ECE495K Lecture Notes: Chapter 3 1

UNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering. Digital Computer Arithmetic ECE 666

Design of an optimized multiplier based on approximation logic

SIGNED PIPELINED MULTIPLIER USING HIGH SPEED COMPRESSORS

Gates and and Circuits

Transcription:

EE 2: Digital Logic Circuit Design Dr Radwan E Abdel-Aal, COE Logic and Computer Design Fundamentals Unit 3 Chapter Combinational 3 Combinational Logic Logic Design - Introduction to Analysis & Design with Examples - Arithmetic Part Functions Implementation and Circuits Technology and Logic -MSI Functional Blocks: Design Decoders, Encoders, etc. Charles Kime & Thomas Kaminski 24 Pearson Education, Inc. Terms of Use (Hyperlinks are active in View Show mode) Unit 3: Combinational Logic (CL) Design Contents. Procedures for Analysis and Design of CL circuits. Example: BCD to Excess-3 Code Converter 2. Iterative Arithmetic Circuits: Half & Full adders, Ripple Carry Adder, Carry Look-ahead adder 3. CL MSI Functional Blocks: Decoders, Demultiplexrs, Encoders, Multiplexers, in addition to adders/subtractors, Decimal Adder, Magnitude comparator 4. Implementing combinational functions using: Decoders and Multiplexers Chapter 3 - Part 2

Combinational Logic Circuits A combinational logic circuit that has: A set of m Boolean inputs, A set of n Boolean outputs Performs n logic functions, each mapping the 2 m input combinations to an output Outputs are determined only by the present inputs (appearing after some delay) - No feedback paths - No memory elements Effect of Previous inputs is NOT remembered Each Output = F (the m inputs) Chapter 3 - Part 3 CL Circuit Analysis Procedure: Analysis: Given: a CL Circuit* (logic diagram), Determine: the logic function implemented by the circuit We can describe such a logic function by: - A set of Boolean Equations, or - A truth table, or - A word description *Ensure circuit is combinational: It should not have O/P to I/P feedback through storage elements Chapter 3 - Part 4 2

4-Step Procedure to get O/P Function:. Label the outputs of gates that are functions of only the circuit inputs and obtain the Boolean function of each output 2. Label the outputs of gates that are functions of the inputs and the outputs of gates in step, and obtain the Boolean function of each output 3. Repeat 2 until you obtain the final output of the circuit 4. Use direct substitution to determine each output as a function of the external circuit inputs, e.g. as a SOP Chapter 3 - Part 5 O/P Function: Example Chapter 3 - Part 6 3

Truth Table: Example O/P O/P2 Truth Table: 2 Ways:. Step by step- T, T2 etc. 2. Get eqn. of the final output and plot it on the table Chapter 3 - Part 7 CL Design Procedure: 5 Steps Given: A specification of required functionality (as a Word description, Truth table, Boolean Equations), Determine: The logic diagram for an optimal circuit that provides the functionality. From the Specification given, determine the number of inputs, number of outputs and label them 2. Work out the truth table specification for each output (if not given) 3. Obtain an optimized* logic expression for each outputs (using K-maps etc.). Global optimization if multiple outputs 4. Get logic diagram and truth table of circuit used and verify that it fulfils the required specification manually or using a simulator 4. Implement with a universal gate if required *Note: In practice, other physical parameters need also to be optimized and verified, e.g. propagation delay, area on the chip, power consumption, etc. Chapter 3 - Part 8 4

Design Example: BCD to Excess 3 Code Converter Specifications The circuit should convert a BCD input code (decimal digits -9) to the corresponding Excess-3 code Inputs: BCD code words for digits through 9: 4-bit patterns to, respectively Outputs: Excess-3 code words for digits through 9: 4-bit patterns obtained by adding 3 (binary ) to each BCD code input???? Utilize Don t cares! 4? BCD Input Code Converter Excess 3 Output 9 Design Example: BCD to Excess 3 Code Converter, 2: Formulation How many outputs we need? Name them The Truth Table I/P Variables - BCD: A,B,C,D O/P Variables - Excess-3 W,X,Y,Z Don t Cares - BCD codes to Chapter 3 - Part 5

Design Example : BCD to Excess 3 Code Converter 3. z Logic Optimization 2-level using K-maps W = A + BC + BD X = BC + BD + BCD Y = CD + CD Z = D Standard SOP 2-level Form (Directly from the K-maps) A A Optimized each O/P separately Z map C 3 2 4 5 7 6 X X X 2 3 5 4 8 9 D X X X X map C 3 2 4 5 7 6 X X X 2 3 5 4 8 9 D X X X B B A A Y map C 3 2 4 5 7 6 2 3 5 4 8 9 D W map C Chapter 3 - Part X X X D X X X 3 2 4 5 7 6 X X X 2 3 5 4 X X X 8 9 B B Design Example 2: BCD to Excess 3 Code Converter 3. Contd. Global Logic Optimization b. Further optimization through multi-level, from: W = A + BC + BD X = BC + BD + BCD For circuits having Multiple Outputs (here 4) Y = CD + CD Z = D By taking common factors: Let T = C + D W = A + BT X = BT + BCD Y = CD + CD Z = D Simpler but non-standard Form (no longer SOP, i.e. > 2 logic levels- (multi-level logic) Now (C+D) is generated only once and used by the 2 outputs W, X! Chapter 3 - Part 2 6

Design Example 2: BCD to Excess 3 Code Converter Multilevel (non-standard) implementation Optimizes the logic but can increase propagation delay Chapter 3 - Part 3 Design Example : BCD to Excess 3 Code Converter 4. Verification- Get the truth table of the actual circuit implemented (analysis) and show it satisfies the specified truth table: Input BCD Output Excess-3 A B C D WXYZ Truth table matched that for the Chapter specifications 3 - Part 4 7

Arithmetic Combinational Circuits: Iterative Cells (Repeated - in space or time) Practical Arithmetic Functions: Operate on binary bit vectors (e.g. a 32-bit adder adds two 32-bit numbers and produces a 32-bit sum) Use same basic sub-function for each bit position Designing circuits that handle the I/P vectors directly can be very difficult (large # of inputs & outputs! large K-maps, Huge truth tables!) Solution: Design functional block for sub-function (e.g. for a bit) and repeat it (iterate it, reuse it) to obtain a functional block for the overall operation Cell = sub-function block Iterative array = An array of interconnected such cells Chapter 3 - Part 5 Block Diagram of a -D Iterative Array Adder/Subtractor for two n-bit integers: C=A+/-B A n- B n- A B A B X n X n- Y n- X 2 Y 2 Cell n- Cell Y n X Y Cell X Y C n- Example: n = 32: Direct Implementation Number of inputs =? (K-map size) Truth table rows =? Equations in up to? input variables Equations with a huge number of literals Flat Design: impractical! Iterative array takes advantage of regularity to make designs more feasible C C Chapter 3 - Part 6 8

Functional Blocks: Addition Binary addition is used frequently in computers Adder Design: -bit adder cell (i.e. does the addition for digit) Half-Adder (HA), a 2-input bit-wise addition functional block Full-Adder (FA), a 3-input bit-wise addition functional block For an n-bit iterative adder: Combine n -bit FA adder cells together- Two ways: Ripple Carry Adder (RCA): Carry ripples through the adder from LSB to MSB slows down the addition operation Carry-Look-Ahead Adder (CLA), Speeds up addition by letting each bit stage generate its carry input from scratch (i.e. from the input numbers directly) to avoid waiting for the carry to ripple through all previous stages Chapter 3 - Part 7 The Functional Blocks: Half-Adder (HA) A 2-input (no carry input), -bit wide binary adder that performs the following computations: Y X X -bit + Y + + + + Adder C S C S A half adder adds two bits, giving two outputs: S & C I/Ps O/Ps The result is expressed as a X Y C S sum bit S and a carry bit C The half adder can be specified by the truth table Applications: - Use as the st stage of n-bit adder (no carry I/P) - Use two HAs to make a full adder (FA)- see later Chapter 3 - Part 8 9

Logic Simplification: Half-Adder (HA) The K-maps for S, C are: S Y C Y X 2 3 X 2 3 By inspection: S X Y X Y X Y C X Y Chapter 3 - Part 9 Functional Block: Full-Adder A full adder is similar to a half adder, but includes a carry-in bit from the lower stage. Like the half-adder, it computes a sum bit, S and a carry bit, C. For a carry-in (Z) of, it is the same as the half-adder: For a carry- in (Z) of : C Y -bit Adder X S Z Z X + Y + + + + C S Z X + Y + + + + C S Chapter 3 - Part 2

Logic Optimization: Full-Adder X Full-Adder Truth Table: Full-Adder K-Maps: S map Y C map Y 3 2 4 5 7 6 Z Z X 3 2 4 5 7 6 X Y Z C S Carry-In S X Y Z The Odd function Generated Carry Propagated Carry Chapter 3 - Part 2 Full-Adder (FA): Implementation Using two Half-Adders (HAs) + OR Gate Half-Adder Sh X Y Ch X Y HA HA2 Full-Adder S X Y Z Sh Z C X Y (X Y). Z Ch Sh. Z Generated Carry Propagated Carry Chapter 3 - Part 22

Worst Case (Critical Path) Propagation Delay for a FA Stage Assume: XOR: 3 standard gate delays OR: standard gate delay, AND: standard gate delay critical delay path for the FA 3 3 3+3 = 6 for S 3++ = 5 for C Path from input (X,Y,Z) to S is the critical path (largest delay to output) Hence propagation delay is 6 standard gate delays If this gate delay is 5 ns FA propagation delay = 6 x 5 = 3 ns. - How many additions per sec?? Chapter 3 - Part 23 4-bit binary adder block using 4 FA stages. The ripple carry approach (simple but slow) - Mimics what we do when adding multiple bits with paper and pencil - Carry output from FA stage i is fed + as carry input to FA stage (i+) Chapter 3 - Part 24 2

4-bit Ripple-Carry Binary Adder Four-bit Ripple Carry Adder made from four -bit Full Adder cells: B 3 A 3 B 2 A 2 B A B A FA C 3 C 2 C FA FA FA C C 4 S 3 S 2 S S Problem: Carry has to ripple through till the end stage for the final result to appear Slow addition speed for large number of stages (bits) n 25 4-bit Ripple-Carry Binary Adder Propagation Delay Analysis Total Worst Case Delay = 3 + 2 + 2 + 2 + 3 = 2 gate delays = 6 + (n-) 2, n = 4 stages 26 3

Full-Adder Alternative Formulation Carry: Generated or Propagated Input Carry Propagation Control Generated Carry Input Carry Propagated Output Carry Input Carry Output carry occurs if either: Carry is generated on the stage (if Ai=Bi=). or Input carry to the stage (Ci=) is propagated through it if Pi= Note: Ai, Bi (hence Pi and Gi) and C are not affected by ripple delay We can avoid carry ripple delay problem if we generate Ci+ from Pis, Gis and C Chapter 3 - Part 27 27 Carry Lookahead Binary Adder Speed up at the expense of more complex hardware C i+ outputs by all stages are derived in parallel with a set of equations using A, B, C inputs only Beginning at cell with carry in C : Note: All P i, G i are functions of (A i, B i ) Only! Carry does not ripple anymore! All 4 carry outputs can be generated in one go from: C and the two input numbers to be added (A,B) C = G + P C (No change) C 2 = G + P C = G + P (G + P C ) 2-Level logic (Only 2 gate delays) C 2 = G + P G + P P C C 3 = G 2 + P 2 C 2 = G 2 + P 2 (G + P G + P P C ) C 3 = G 2 + P 2 G + P 2 P G + P 2 P P C C 4 = G 3 + P 3 C 3 = G 3 + P 3 G 2 + P 3 P 2 G + P 3 P 2 P G + P 3 P 2 P P C No Rippling Carry Propagated Carry generated within the 4-bit block through the 4-bit block Chapter 3 - Part 28 4

Carry Lookahead Generator Box (for 4-bit adder) C to C4 are generated - Only C-C3 shown See slide 27 Stage 2 Carry Lookahead Generator Box Stage Stage Input Carry Chapter 3 - Part 29 4-bit Carry Lookahead Adder: A+B = C4 S End Carry Out: C4 Inputs: A: A3.A See slide 27 B: B3 B Carry In: C Box See Previous Slide 3 5

Delay reduction for the 4-bit Carry Lookahead adder: Consider last stage G 3 A 3 B 3 Delay from {A,B, C} to S3 (sum from last bit) is 3 ns (in XOR) + max (delay of P3, Delay of C3) C 3 = G 2 + P 2 G + P 2 P G + P 2 P P C 3 P 3 C 3 3 XOR 5 Ps are the slowest Inputs to the SOP (3 ns) 3 ns for inputs to SOP + ns for the AND (Product) + ns the OR (Sum) All Ps are calculated simultaneously 5 Gate delays for C3 C 4 S 3 Delay =? Critical delay path Last stage of the CLA 4-bit adder = 3 + max (3,5) = 3 + 5 = 8 ns (Regardless of the # of stages!!) Vs 2 ns for the 4-bit carry ripple adder Chapter 3 - Part 3 Adder/Subtractor Combined Hardware In Signed 2 s Complement Notation Only one adder computes A + B or A B, as specified by Sub/Add I/P For Control input = (add): B is passed through to the adder as is, C = i.e. result = A+B For Control input = (subtract): 2 s complement of B is obtained using XORs to form the s comp, + applied to C of st stage A + 2 s comp. of B, i.e. result = A-B All inputs and result are represented in the 2 s Complement Notation Where is the sign bit? Control I/P Subtract/Add = when the 2 end carries are different A +/- B Chapter 3 - Part 32 6

BCD Decimal Adder 4 BCD BCD Adder Stage ( BCD Digit) 4 Cin Cout A circuit that adds two decimal digits (-9) (in BCD) with a possible carry input and gives the sum as a BCD + a carry out 4 BCD 9 inputs, 5 outputs + carry 6 2 8 = 8 (<9) + carry 7 4 2 + 9 9 = 2 (>9) = 8 (>9) 8 carry Chapter 3 - Part 33 Using a standard 4-bit binary adder - What changes are needed? For sums binary and BCD are identical- No correction For sums, we should subtract ) d and send a carry to next BCD stage Instead of subtracting ) d, =, we add its 2 s complement which is Use the binary adder o/ps to determine if correction is needed Binary Carry Binary Adder Performance adder Identical- No Change Corrections Needed BCD Carry Required BCD Performance adder sum For sum 34 Subtract (add 6) and set Carry 7

BCD decimal adder Numbers that need correction (add 6) are: K Z8 Z4 Z2 Z () () (2) (3) (4) (5) (6) (7) (8) (9) BCD Carry To next BCD Stage C = K + Z8Z4 +Z8Z2 Binary Carry Correction Decision BCD Carry = Add = Add 6 (Add or 6) 35 Binary Multiplier Binary multination is done in the same way as decimal multiplication. Multiplicand is multiplied by each bit of the multiplier. Shift results -bit for each bit of multiplier. Add. 36 8

Binary Multiplier: 2-bit x 2-bit multiplicand multiplier multiplier multiplicand C = A * B C does not stand for Carry here 37 4-bit by 3-bit Binary Multiplier B3 B2 B B A2 A A AB3 AB2 AB AB AB3 AB2 AB AB Carry S3 S2 S S A2B3 A2B2 A2B A2B Carry S3 S2 S S C6 C5 C4 C3 C2 Largest Results: Carry 5 x 7 = 5 (7 bits are enough) 38 9

4-bit Magnitude Comparator A3<B3 MSB LSB A3>B3 A3=B3 Based on Bit-level Operations LSB xi = bit equality = x XNOR y A > B: if A3>B3 or A3=B3 & A2>B2 or A= B= LSB A3=B3 & A2=B2 & A>B or A3=B3 & A2=B2 & A=B & A>B An alternative way (from the other two outputs?) 39 4-bit Magnitude Comparator for an n-bit comparator (Bit-level Operations) 4 2

Other Combinational Logic Functions Functions & Functional Blocks that implement them Enabling Encoding, Encoding with Priority in mind Decoding, Demultiplexing (Data routing) Multiplexing (Data selecting) Implementing any combinational function using: Decoders & OR gates Multiplexers (with inverters if needed) MSI Functional Block Applications Chapter 3 - Part 4 Functions and Functional Blocks We consider here functions that are useful in designing and building other (higher-level) combinational and sequential circuits Such functions may exist as functional blocks In the past, many such blocks were implemented as discrete integrated circuits (ICs): SSI (small scale integration), MSI, and LSI e.g. the 7483 is a 4-bit CLA adder, 7457 is a 4-bit Multiplexer Today, they are often available as components in a design library for use within larger VLSI circuits Chapter 3 - Part 42 2

. Enabling Function Enable: Allow an input signal to pass through to an output Disable: block an input signal from passing through to an output, replacing it with a fixed state. This could be HiZ,,, depending on the gate used) Later we use the enable function to implement decoders and multiplexers Two Examples: EN = Enable, EN = Disable When I/P disabled, output = Tri-State Buffer When I/P disabled, output = Chapter 3 - Part 43 Encoding & Decoding m = 2 n For full Decoders/Encoders Encoder: For each unique activated input line, Generate the corresponding code I/P Lines (only one active at a time) m Encoder n Code of activated line Decoder: For each input code, Activate the unique corresponding output line Encoder is the opposite of Decoder Will start with Decoding Input Code n n-to-m decoder Decoder Smallest decoder is? m Output Lines Only the line Corr. to the I/P code is activated Chapter 3 - Part 44 22

Code Input Decoder 2. Decoding n Output Lines m A decoder converts an n-bit input code to a unique state on m outputs where 2 m 2 n (with m = 2 n we call it a Full Decoder) For each valid input code, only one unique output line is activated Decoder functional blocks: Are called n-to-m line decoders, where m 2 n, and Generate 2 n (or fewer) minterms from the n input variables Chapter 3 - Part 45 Decoder Design: 3-to-8 Example Direct Approach: Generate All Minterms of the code I/Ps m LSB Function Table Notice that each output line is the minterm corresponding to the input code, e.g. D 5 is m 5 For this input combination, Which is the Output that will be? m7 Chapter 3 - Part 46 23

Hierarchical Decoder Design (Decoder Expansion) Using simpler decoders to build more complex ones -to-2-line Decoder to 2 - The simplest Decoder 2-to-4-Line Decoder MSB A A D Decoder Expansion(a) D D 2 D 3 A A Note that the 2-4-line made up of 2 -to-2- line decoders and 4 AND gates. A D D LSB A (a) Basic -to-2 Controlling -to-2-2 Decoder -to-2 Decoder (b) -2 Decoder D 5 A A D 5 A A D 2 5 A A D 5 A D 5 A Enabling/Disabling Block of ANDs D 3 = 5 A A For the 2-to-4: Logically, we get same Circuit (b) of the formal design (the 4 minterms!) AND Chapter Gates 3 - Part 47 = = = = = 4 minterms We better design each decoder to have its own enable input! n-to-m Decoder with Enable (EN) Use the EN input to open/close the minterm-forming gates See truth table below for function Note use of X s to denote both and at the inputs Combination containing two X s represent four input binary combinations 2-to-4 with Enable: Disabled decoder has all outputs = Allows simple expansion e.g. to 3-to-8 EN A Also, will use to make a demultiplexer (see later) 2-to-4 with Enable A D Decoder is disabled Decoder Enabled: Normal Operation EN A A D D D 2 D 3 X X All s (Disabled) D D 2 D 3 (a) (b) 4 minterm-forming Chapter & Enabling 3 - Part gates 48 24

Decoder Expansion Example: 3-to-8 from two (2-to-4 with EN) Using two 2-to-4 decoders & one -to-2 decoder D Top Top 2-to-4 decoder -to-2 decoder D Bottom Bottom 2-to-4 decoder Chapter 3 - Part 49 2-to-4 Decoder With Enable Polarities for E and O/Ps can be reversed Note: Here polarity of the Enable I/P and the decoder outputs is reversed. NAND Gates (not ANDs): Selected Decoder O/P = (not ) Decoder is activated with E = - Not Correction Chapter 3 - Part 5 25

4. Encoding I/P Lines ( active) Encoding - the opposite of decoding An encoder converts m input lines to an n-bit output code where 2 m 2 n - such that each activated input line produces the corresponding unique output code If the input lines have exactly only one active line (e.g. at logic ) output is the binary code corresponds to the position of that input (exact opposite of decoder) If not, we need to consider priority m Encoder n Code of active line What is the smallest Chapter Encoder? 3 - Part 5 Example: 8-to-3 Encoder I/P Lines ( active) 8 Encoder 3 Code Inputs (D,, D 7 ): 8 lines corresponding to digits through 7 Outputs (A 2, A, A ) : 3 bits of the binary code Function: If the ith input line D i is a, the output (A 2, A, A ) = the binary code for i Initially for simplicity: Assume that at least one and only one of the 8 inputs is active at any given time. So we have only 8 valid input combinations out of the 2 8 = 256 possible combinations. Remaining rows are don t care simplifies the design considerably Chapter 3 - Part 52 26

Example: 8-to-3 Encoder Octal-to-binary encoder Assuming only (and at least ) Input line being active at a time I/P Lines Encoder - At least restrictions 3 - Only at a time 8 The 256-row truth table is thus reduced to only these 8 valid rows Equations: A = D + D 3 + D 5 + D 7 A = D 2 + D 3 + D 6 + D 7 A 2 = D 4 + D 5 + D 6 + D 7 Ambiguities arise if conditions above are not met:. O/P = for: D active, also for no active line 2. If two lines become active simultaneously, O/P code is wrong (represents neither of them!) e.g. if both D3 and D6 are active, output= (wrong) So, We need Chapter priority 3 -encoding.! Part 53 Priority Encoder If none or more than one input line is active (at logic ), then the encoder just described does not work properly An encoder that can accept all possible combinations of input values and still produces meaningful output is called a priority encoder Among all the s that appear at the I/Ps simultaneously, it selects the I/P having the highest designated priority and produces its corresponding binary code- ignoring all other lower-priority s that may exist with it. So the code generated is for the input of the highest priority that is active (=) (all higher priority inputs = ), regardless of the state of all lower priority inputs Chapter 3 - Part 54 27

4-to-2 Priority Encoder Example: 3 Higher Priority K-map cells Included 2,3 4,5,6,7 8,9,,,2,3,4,5 Should be 2 4 = 6 rows/cells in total! Higher: s Higher Priority LSB Lower: Xs 4 I/P Lines (no restrictions) Encoder 2 V Valid O/P (= OR of all I/Ps) Note the difference Between a don t care (X) in the inputs and a don t care (X) in the outputs! 3 2 4 5 6 7 2 3 5 4 8 9 A map A map Chapter 3 - Part 55 4-to-2 Priority Encoder Example V = D + D + D 2 + D 3 O/P Code Validity = O/P Code Valid Chapter 3 Par 56 28

5. Selecting (Multiplexing): 2 n -to- A multiplexer (MUX) selects one of 2 n data input lines based on an n-bit address, directing it to one output line A typical multiplexer has: 2 n Information inputs (I n (2 ), I ) (to select from) n Select (control or address) inputs (S n -, S ) (to select with)) Information output Y (to select to) Will implement it using a decoder, see next slide MUX selection circuits can be duplicated m times (with the same selection controls) to provide m-wide data widths, e.g. select one of four input bytes using 8-wide 4-to- MUX 4-to- MUX Chapter 3 - Part 57 The Simplest Multiplexer n = 2 -to- MUX The single selection variable S has two values: S = selects input I S = selects input I Truth Table 3-input K-map optimization gives the output equation: The circuit: Can also be seen As: -to-2 decoder + Enabling + Selection S 2 n Minterms Decoder I I 2 n I Inputs Enabling Circuits Selection OR Chapter 3 - Part 58 Y 29

Example: 4-to--line Multiplexer, Using Size of the Select Inputs = Log 2 (4) 2-to-4 decoder + 4 2-I/P AND-OR for Enabling/Selection Or merged Design 4 Information I/Ps 2-to-4 Decoder O/P 2 Select I/Ps To MUX But here the Decoder gates are merged With gates for MUX information selection! Chapter 3 - Part 59. Duplicating the MUX in Width: m-wide 2 n -to- MUX Example: Quad 2-to- MUX with E Selection Capability Is the same Only widths extended 2-to- Selection Logic (Repeated 4 Times) -to-2 Decoder (for 2-to- Selection) Enable here is Active Low or Active High? One 2-to- (two 4-bits I/Ps) 4 A Or: 4 Layers I of 2-to- 4 MUXs I 2 B Quad 2-to- E Y 4 S (select) =?, =? Importance of labeling inputs and outputs Chapter 3 - Part 6 3

2. MUX Expansion: Expanding the selection capability Example: Using 2-to- MUXs to do 4-to- Muxing How many 2-to- MUXs do you need? Selection with the lower significant bits (I or I)/(i2 or I3) Selection with the higher significant bits (I, I) or (I2,I3) 3. Demultiplexer- Opposite of Multiplexer MUX: Many-to-One One-to-Many MUX De MUX (Select Source Line) Multiplexer (Select Destination Line) Demultiplexer A decoder with Enable is Called a: Decoder/Demultiplexer DeMUX A device that moves data arriving on a single input (E) to one of m outputs (Ds) determined by the value of (log 2 m) select inputs (As) Chapter 3 - Part 62 3

2-to-4 Decoder with Enable = -to-4 Demultiplexer! From Truth Table, decoder can be viewed as distributing the value of the EN input to of 4 outputs From this perspective, it is a Demultiplexer! 2 Address I/Ps Data Input EN A 4 A Minterms D The 4 Data Outputs EN A A D D D 2 D 3 Decoder is disabled X X No s Normal Decoder Operation (a) (b) D D 2 D 3 Chapter 3 - Part 63 Implementing Combinational Functions Using Functional Blocks Two implementation techniques from the SOm canonical form (no simplification): Using a Decoder + OR gates Using a Multiplexer + Inverters (if needed) We always said Canonical forms give complex implementations! But now we have most of the complexity hidden inside the ready-made function block!! (e.g. decoder or MUX) Utilize it! Chapter 3 - Part 64 32

. Using a Decoder + OR Gates: From Canonical Form: Truth Table (or m Form) n Inputs Combinational Function m Outputs Functions of n inputs and m outputs: Specification: As a Truth Table (has n input columns and m output columns) or m SOm expressions [ m( )] Implementation requires: One n-to-2 n -line decoder m OR gates: one gate for each output Procedure: From the truth table: For each output: For a in truth table row (i), connect the corresponding D i output of the decoder to the OR of that output Or From the m minterm expression [ m( )]: Connect the decoder D i outputs corresponding to the minterms of each output to the OR of that output Chapter 3 - Part 65 Decoder + OR Gates: Example -bit adder (with carries at I/P and O/P) 3 Inputs 2 Outputs LSB 3 I/Ps and 2 O/Ps: 2 SOm expressions We need: 3-to-2 3 Decoder 2 OR gates of appropriate # of inputs S(x, y, z) C(x, y, z) m m (,2,4,7) (3,5,6,7) LSB Larger # of s require larger ORs. If so, Consider expressing F and using a NOR instead of the OR! Chapter 3 - Part 66 33

Using Multiplexers: from Truth Table, or canonical Form Implementing a logic circuit of n inputs and m outputs requires: Specification: Truth table, or Som or PoM forms Implementation: Use m x 2 n -to- multiplexer Design: Example: 5 input, 3 output circuit: Need 3 x 2 5 -to- MUX In the same order they appear in the truth table: Apply the n input variables to the MUX select inputs S n-,, S (i.e. Observe bit significance, i.e. LS variable goes to S) Label the outputs of the multiplexer with the output variables Value-fix the I inputs to the multiplexer using the values from the truth table. For don t cares, use either or. Chapter 3 - Part 67 Using Multiplexers: Example:. Conventional approach, n inputs Use 2 n -to- MUX Row Index 3 Inputs LSB Output 2 3 -to- MUX Order Is important Select LSB MUX Output Order Is important MUX Information I/Ps (8) What if we have 2 outputs? We use a dual (i.e. x 2) 8-to- MUX Importance of labeling inputs and outputs Chapter 3 - Part 68 34

Using Multiplexers: Example: Full adder- 2. Smarter approach uses a smaller MUX: n input variables Use 2 n- -to- MUX (/2 previous size) Use ½ the MUX size needed earlier: 2 2 -to- MUX Connect MS 2 input variables to select, and express F as,, Z, or Z for each value of XY and apply to the I inputs of the MUX. 3 Inputs Output LSB XY Index z z LSB What if we have 2 outputs? We use a dual 4-to- MUX Chapter 3 - Part 69 Using Multiplexers: Example F (A,B,C,D) = m(,3,4,,2,3,4,5) 6 rows in truth table 6-to- MUX (conventional approach) But using the more efficient approach will use only an 8-to- MUX + inverter Chapter 3 - Part 7 35

Designing MUXes Using 3-State Buffers for Selection 2-to- MUX 4-to- MUX O/Ps Connected ( Effectively an OR gate) 2 Tri-State Buffers -to-2 Decoder O/Ps Connected ( an OR gate) This replaces the selection network: Chapter 7 Design Examples Using MSI Combinational Functional Blocks. Adding three 4-bit numbers 2. Adding two 6-bit numbers using 4-bit adders 3. Building a 4-to-6 Decoders using several 2-to-4 Decoders (with Enable) 4. Selecting the larger of two 4-bit numbers 5. BCD to Excess-3 Code Converter using binary decoders and encoders only 6. Building multi-function combinational circuit (e.g. a cct that adds, subtracts, doubles, etc. according to a set of function select I/Ps) Important in these problems: Must Label Clearly all inputs/outputs of all function blocks 36

Example : Adding three unsigned 4-bit digits Problem: Add three 4-bit numbers (X, Y, Z) using 2 standard MSI 4-bit adders Solution: Let the numbers be X 3 X 2 X X, Y 3 Y 2 Y Y, Z 3 Z 2 Z Z, X 3 X 2 X X + Y 3 Y 2 Y Y ------------------- C 4 S 3 S 2 S S S 3 S 2 S S + Z 3 Z 2 Z Z ------------------- D 4 F 3 F 2 F F Note: C 4 and D 4 are generated in digit position 4. They must be added in the same position to generate the most significant bits of the result Adding three unsigned 4-bit digits 5 +5 +5 45 X Wrong Needs 6 bits Decimal Example: 64 + 59 + 89 C S 6-bit Result the 2 carries 64 59 + 23 89 + 22 37

Example 2: Adding two 6-bit numbers using a number of 4-bit adders Solution: Four 4-bit adder blocks are connected in cascade, with carries rippling in between Chapter 3 - Part Example 3: Design a 4-to-6 Decoder Using a number of 2-to-4 Decoders (each with Enable) Problem: Design a 4-to-6 Decoder using a number of 2-to-4 Decoders with Enable Select of the 4 Common to all 4 2-to-4 decoders 2-to-4 decoders A 3 A 2 = A 3 A 2 A A Active Output D D D 2 Solution: - Four 2-to-4 decoders are fed with A A (in parallel) to generate the 6 output lines - The remaining 2 input lines A3 A2 drive a 5 th 2-to-4 decoder to select (Enable) one of the 4 decoders to perform decoding for its group of 4 lines A 3 A 2 = A 3 A 2 = A 3 A 2 = D 3 D 4 D 5 D 6 D 7 D 8 D 9 D D D 2 D 3 D 4 D 5 38

4-to-6 Decoder A A LS I/P Bits are Common to all Output MUXs A A 2x4 Decoder E D D D 2 D 3 A 2 A 3 2x4 Decoder D D D 2 D 3 A A 2x4 Decoder D 4 D 5 D 6 D 7 Enable for the full 4-to6 decoder E A A 2x4 Decoder D 8 D 9 D D A A 2x4 Decoder D 2 D 3 D 4 D 5 Example 4: Hardware that compares two unsigned 4-bit numbers and selects (passes) the smaller of the two to the O/P Solution: We will use a magnitude comparator and a Quad 2-to- MUX. Always mark inputs & be careful with assigning Them! S MSI Block Only bit Active at a time 39

Example 5: BCD to Excess-3 Code Converter using a decoder and straight binary encoder Index 2 3 4 5 6 7 8 9 BCD Excess-3 BCD: - 9 Does it need to be a Priority Encoder? Excess-3: 3-2 Example 6: Building multiple-function combinational circuit (e.g. add, subtract, Max,..) Inputs n n n add Functional unit n I General Architecture of an m-function combinational circuit with n-bit data width Example Function Table S S O is equal to Max(A, B) Min(A, B) 2 A Inputs n Functional unit 2 subtract n I n m-to- MUX n-wide m-to- MUX n O A B n Inputs n Functional unit m n Im- etc. Function selection Log2 (m) bits S S Select of the m functions 4