Digital Logic Circuits Logic Design (Part ) Combinational Logic Circuits (Chapter 3) ² We saw how we can build the simple logic gates using transistors ² Use these gates as building blocks to build more complex combinational circuits Decoder: based on value of n-bit input control signal, select one of N outputs Multiplexer: based on value of N-bit input control signal, select one of N inputs. dder: add two binary numbers any boolean function ased on slides McGraw-Hill dditional material 4/5/6 Lewis/Martin dditional material 8 Roth dditional material Taylor dditional material 3 Farmer dditional material 4 Narahari Digital Logic Design Current ummary ² MO transistors used as switches to implement logic functions. n-type: connect to GND, turn on (with ) to pull down to p-type: connect to +.9V, turn on (with ) to pull up to ² asic gates: NOT, NND Logic functions are usually expressed with ND, OR, and NOT ² Review: a little theory behind combinational logic design and some basic combinational devices DeMorgan s Law Combinational logic devices: Ø Decoder, Multiplexer, dder, PL oolean lgebra review from C 3 (Discrete ) oolean lgebra George oole Famous Mathematician/Logician Ø oolean lgebra branch of lgebra, where variables can only have values of true () or false () Ø Instead of +, -, x, /, oolean operators: ND(x), OR(+), NOT(!) NOT is simply an Inverter With oolean lgebra: Ø We create functions using boolean variables and operators Ø ny logical function can be expressed in terms of the three elementary operations: ND, OR and NOT Ø oolean functions can be rearranged and sometimes simplified by applying algebraic identities ig idea you can write a logical function as a boolean algebraic expression and then use various identities to rewrite that function in an equivalent (usually simpler) form. 3-4
oolean Functions function can be thought of as a mapping from inputs to outputs. Ø Think of a black box with n binary inputs and binary output We can express the action of this function in terms of a truth table which says what the output should be for every input pattern. This function implements a binary adder! C in Truth table (describes behavior) C in oolean Functions ² Function on boolean variables F(x,y) x, y are boolean variables ( or values) F(x,y) is a boolean output ² If numbers are represented using binary, then all functions are boolean functions dd lock Diagram 3-5 Completeness: Very Important Concept ² It can be shown that any truth table (i.e. any binary function of binary variables) can be reduced to combinations of the ND & NOT functions, or of the OR & NOT functions. This result extends also to functions of more than two variables Methodology: Karnaugh Maps ² In fact, it turns out to be convenient to use a basic set of three logic gates: oolean Function ² Output(s) is a function of input boolean variables ² y = f(x,y, ) ² The operators used are any of the boolean logic operators ND, OR, NOT, NND, etc. ² How do we represent boolean functions? ND, OR & NOT or NND, NOR & NOT In fact, can implement all logic functions using just NND!
Representation of Logic Functions ² logic function can be represented as a truth table a logic expression a logic circuit ² Example f = a.(b.c + d) + a.c = a.b.c + a.d + a.c a b c d f a b c d f Truth Table to oolean Function ² Definition: literal is a boolean variable x or its complement x x means x= in truth table ² Definition: minterm is product (ND) of literals where each variable/literal appears once in the term ² Disjunctive normal form (DNF): an OR of minterms DNF gives a two level circuit implementation Truth Table to DNF: ² simple boolean function for output F For each row where F=, find minterm Ø Ex: if F= when x=, x=, x3= then minterm= (x x x3) oolean function in DNF is sum ( OR) of all minterms where F= How to design combinational circuit Combinational and equential Circuits ² nalyze the problem Determine inputs and outputs (they must be binary) ² Determine boolean variables inputs x,x, Outputs y, y, ² Derive truth table Value of each yi for each combination of inputs x,x, ² For simple circuit, find DNF from truth table ² To find optimal (minimum size) -level circuit, derive Karnaugh map and find terms ² circuit is a collection of devices that are physically connected by wires Combinational circuit equential circuit ² In Combinational circuit the input determines output ² In sequential circuit, the input and the previous state (previous values) determine output and next state Need circuit to implement concept of storage 3
Combinational Devices ² Use basic gates to build more complex combinational logic functions ² dder: add two binary numbers ² Decoder: enable one of many outputs ² Multiplexer: select one of many inputs Problem ² No one will buy your new computer design unless it can do at least some math, say, like adding! ² How to build hardware for adding binary numbers using what we have learnt so far? ² First look at the function performed by addition we saw this last week it by bit addition, right to left, propagate carry Inputs:, and Carry-in Output: sum bit and carry-out (to next bit position) inary rithmetic: Half dder ² Logical Function: Half dder, implement Carry Out: um C out H (C out ) um Half dder s Logic Function: UM=(( ND ) OR ( ND )) C=( ( ND ) OR ( ND ) OR ( ND ) ) Realize though: C= ( ND ), this isn t always best way! Chaining asic Components Together: ² Let s create an incrementer Input: Output: = + Why? Recall how to create C number? We flip bits then add ² pproach # (impractical) Use PL-like techniques to implement circuit Problem: 8 or 56 rows, 8 output columns In theory, possible; in practice, intractable Ø Imagine a 6-bit incrementer! ² pproach # (pragmatic) Create a -bit incrementer circuit Replicate it 6 times We already have! half adder can be used to just add 8 8 + 8-bit incrementer (just adds ) + 4
One-bit Incrementer ² Implement a single-column of an incrementer using a half adder C out n n + n + C in This is the same operation as a half adder We can call it a half adder or -bit incrementer n H (C out ) um ame functionality, just relabeled inputs N-bit Incrementer ² Chain N -bit incrementers together + 3 + + 3 + 3 3 4 4 + but how do we start off the least-significant bit? 4-bit incrementer implemented using 4, -bit half-adders N-bit Incrementer, continued ² How do we handle the least-significant bit? + + C in = No longer needed; implicitly encoded with C in We carry in a + + +... ddition: Full dders ² There is a limit with the half adder It can t implement multiple-bit addition H um (C out ) C out + It works for least significant bit, but won t work for the next C in F um + C out um We need an adder that has 3 inputs and outputs 3- um 5
Truth Table Carry In Out Carry Out Truth Table for inary ddition Carry In Out Carry Out Full dder -bit Full dder Carry OUT Carry IN ² dd two bits and carry-in, produce one-bit sum and carry-out. C in C out UM-OUT 6
N-bit dder Four-bit dder ² Use the building block of the full-adder to build N-bit adder Need to connect carry-out to carry-in of next significant bit N-bit dder dd dd dd... 6 6 + 6 : useful for detecting overflow 3-7 : assumed to be zero if not present Truth Table Carry In Out Carry Out 7
How about a subtractor? ² uild a subtracter from out multi-bit adder Calculate = + Negate Recall = NOT() + pproach# pproach# We carry in a (no longer need incrementer) Can we put this together? ² In a CPU, we d like to do OTH addition and subtraction Can we give the CPU the ability to choose between two pieces of hardware? Yes! Ø We need another small piece of logic to do it: MUX 6 6 6 + 6 adder 6 6 6 6 adder 6 Now, let s create an adder/subtracter 3-3 The Multiplexer (MUX) The selector ² elector/chooser of signals Imagine witching Railroad Tracks Multi-way switch -to- Mux 4-to- Mux = O Problem: electing one of many ² You have m input signals and you want to use the logical value on one of them determined by a set control signals/wires n control signals Each student sends a signal ( or ) I want to select Tim s signal so I can process his answer Ø Need to give Tim s code of to select his answer m O n Input selects or to attach to O output cts like an IF/ELE statement 3-3 out 8
Multiplexer (MUX) C D Out 4-to- MUX: Out takes the value of,, C or D depending on the value of (,,, ) In general, a MUX has Ø n data inputs Ø n select (or control) lines Ø and output. It behaves like a channel selector. Out =.. +.. + C.. + D.. C D [:] The Multiplexer (MUX) ² In general N select bits chooses from N inputs n incredibly useful building block ² Multi-bit muxes Can switch an entire bus or group of signals witch n-bits with n muxes with the same select bits 6 6 6 6 6 Out dder/ubtracter - pproach # dder ubtracter 6 6 6 6 6 6 6 dder/ubtracter 6 dd/ub 6 6 6 6 6 dder/ubtracter - pproach # 6 6 dder 6 6 ubtracter 6 6 dder/ubtracter dd/ub 6 6 6 6 6 9
nother useful device the Decoder ² You have an n bit binary number assigned as unique ID to each student. How do we select & physically connect to a specific student with ID y? ² In /W, a case /switch statement: One of the cases will be evaluated depending on value of input ² cenario: 4 light bulbs, switch one of them ON depending on bit input oolean function for decoder ² Need to select one of four: bits needed to encode the four outcomes a a ² 4 outputs associated with each signal x 3 x x x ² What is the boolean function? ² When is each x i set to : x = a.a (NOT a ND NOT a ) x = a.a x = a.a x 3 = a.a Truth table Decoder a a x x x x 3 i =, iff, is n n input decoder has n outputs. i = i = i = 3, iff, is, iff, is - Tim, iff, is Output i is iff the binary value of the n-bit input is i. t any time, exactly one output is, all others are. -bit decoder (4 input decoder)
Combinational vs. equential ² Combinational Circuit always gives the same output for a given set of inputs Ø ex: adder always generates sum and carry, regardless of previous inputs ² equential Circuit stores information output depends on stored information (state) plus input Ø so a given input might produce different outputs, depending on the stored information example: vending machine Ø Current total increases when you insert coins Ø output depends on previous state useful for building memory elements and state machines Next.. equential Circuits ² First we need to build a device that can store a bit uilding memory follows ² How to model sequential circuits/machines Finite state machine ² How to build a sequential circuit? Limitations of sequential machines..more in Foundations course ² can we use a sequential circuit to control how computations take place in a processor?