07 decoders 121
TRANSCRIPT

8/3/2019 07 Decoders 121
1/25
September 22, 2003 Decoders
Review: Additional Boolean operations
NAND(NOTAND)
NOR(NOTOR)
XOR(eXclusive OR)
(xy) = x + y (x + y) = x y x y = xy + xy
Operation:
Expressions:
Truth table:
Logic gates:

8/3/2019 07 Decoders 121
2/25
September 22, 2003 Decoders
XOR gates
A twoinput XOR gate outputs true when exactly one of its inputs is true:
XOR corresponds more closely to typical English usage of or, as in eat
your vegetables or you wont get any pudding. Several fascinating properties of the XOR operation:
x y = x y + x y

8/3/2019 07 Decoders 121
3/25
September 22, 2003 Decoders
More XOR tidbits
The general XOR function is true when an odd number of its arguments aretrue.
For example, we can use Boolean algebra to simplify a threeinput XOR tothe following expression and truth table.
XOR is especially useful for building adders (as well see on later) and errordetection/correction circuits.
x (y z)= x (yz + yz) [ Definition of XOR ]
= x(yz + yz) + x(yz + yz) [ Definition of XOR ]= xyz + xyz + x(yz + yz) [ Distributive ]= xyz + xyz + x((yz) (yz)) [ DeMorgans ]= xyz + xyz + x((y + z)(y + z)) [ DeMorgans ]= xyz + xyz + x(yz + yz) [ Distributive ]= xyz + xyz + xyz + xyz [ Distributive ]

8/3/2019 07 Decoders 121
4/25
September 22, 2003 Decoders
XNOR gates
Finally, the complement of the XOR function is the XNOR function. A twoinput XNOR gate is true when its inputs are equal:
(x y) = xy + xy

8/3/2019 07 Decoders 121
5/25
September 22, 2003 Decoders
Design considerations, and where they come from
Circuits made up of gates, that dont have any feedback, are calledcombinatorial circuitso
No feedback: outputs are not connected to inputso If you change the inputs, and wait for a while, the correct outputs show
up. Why? Capacitive loading:
fill up the water level analogy. So, when such ckts are used in a computer, the time it takes to get stable
outputs is important. For the same reason, a single output cannot drive too many inputso Will be too slow to fill them upo May not have enough power
So, the design criteria are:o Propagation delay (how many gets in a sequence from in to out)o Fanouto Fanin (Number of inputs to a single gate)

8/3/2019 07 Decoders 121
6/25
September 22, 2003 Decoders
Decoders
Next, well look at some commonly used circuits: decoders and multiplexers.o These serve as examples of the circuit analysis and design techniques
from last lecture.o They can be used to implement arbitrary functions.o We are introduced to abstraction and modularity as hardware design
principles. Throughout the semester, well often use decoders and multiplexers as
building blocks in designing more complex hardware.

8/3/2019 07 Decoders 121
7/25
September 22, 2003 Decoders
What is a decoder
In older days, the (good) printers used be like typewriters:o To print A, a wheel turned, brought the A key up, which then was
struck on the paper. Letters are encoded as 8 bit codes inside the computer.o When the particular combination of bits that encodes A is detected, we
want to activate the output line corresponding to Ao (Not actually how the wheels worked)
How to do this detection : decoder
General idea: given a k bit input,o Detect which of the 2^k combinations is representedo Produce 2^k outputs, only one of which is 1.

8/3/2019 07 Decoders 121
8/25
September 22, 2003 Decoders
What a decoder does
A nto2ndecodertakes an nbit input and produces 2n outputs. The n inputsrepresent a binary number that determines which of the 2n outputs is
uniquelytrue. A 2to4 decoder operates according to the following truth table.o The 2bit input is called S1S0, and the four outputs are Q0Q3.o If the input is the binary number i, then output Qi is uniquely true.
For instance, if the input S1 S0 = 10 (decimal 2), then output Q2 is true, andQ0, Q1, Q3 are all false.
This circuit decodes a binary number into a oneoffour code.

8/3/2019 07 Decoders 121
9/25
September 22, 2003 Decoders
How can you build a 2to4 decoder?
Follow the design procedures from last time! We have a truth table, so wecan write equations for each of the four outputs (Q0Q3), based on the two
inputs (S0S1).
In this case theres not much to be simplified. Here are the equations:
Q0 = S1 S0Q1 = S1 S0Q2 = S1 S0Q3 = S1 S0

8/3/2019 07 Decoders 121
10/25
September 22, 2003 Decoders
A picture of a 2to4 decoder

8/3/2019 07 Decoders 121
11/25
September 22, 2003 Decoders
Enable inputs
Many devices have an additional enable input, which is used to activate ordeactivate the device.
For a decoder,o EN=1 activates the decoder, so it behaves as specified earlier. Exactly
one of the outputs will be 1.o EN=0 deactivates the decoder. By convention, that means allof the
decoders outputs are 0. We can include this additional input in the decoders truth table:

8/3/2019 07 Decoders 121
12/25
September 22, 2003 Decoders
An aside: abbreviated truth tables
In this table, note that wheneverEN=0, the outputs are always 0,
regardless of inputs S1 and S0. We can abbreviate the table bywriting xs in the input columns forS1 and S0.

8/3/2019 07 Decoders 121
13/25
September 22, 2003 Decoders
Decoders are common enough that we want to encapsulate them and treatthem as an individual entity.
Block diagrams for 2to4 decoders are shown here. The names of theinputs and outputs, not their order, is what matters.
A decoder block provides abstraction:o You can use the decoder as long as you know its truth table or
equations, without knowing exactly whats inside.o It makes diagrams simpler by hiding the internal circuitry.o It simplifies hardware reuse. You dont have to keep rebuilding the
decoder from scratch every time you need it. These blocks are like functions in programming!
Blocks and abstraction
Q0 = S1 S0Q1 = S1 S0Q2 = S1 S0
Q3 = S1 S0

8/3/2019 07 Decoders 121
14/25
September 22, 2003 Decoders
A 3to8 decoder
Larger decoders are similar. Here is a 3to8 decoder.o The block symbol is on the right.o
A truth table (without EN) is below.o Output equations are at the bottom right. Again, only one output is true for any input combination.
Q0 = S2 S1 S0Q1 = S2 S1 S0Q2 = S2 S1 S0Q3 = S2 S1 S0Q4 = S2 S1 S0
Q5 = S2 S1 S0Q6 = S2 S1 S0Q7 = S2 S1 S0

8/3/2019 07 Decoders 121
15/25
September 22, 2003 Decoders
So what good is a decoder?
Do the truth table and equations look familiar?
Decoders are sometimes called minterm generators.o For each of the input combinations, exactly one output is true.o Each output equation contains all of the input variables.o These properties hold for all sizes of decoders.
This means that you can implement arbitrary functions with decoders. If youhave a sum of minterms equation for a function, you can easily use adecoder (a minterm generator) to implement that function.
Q0 = S1 S0Q1 = S1 S0Q2 = S1 S0Q3 = S1 S0

8/3/2019 07 Decoders 121
16/25
September 22, 2003 Decoders
Design example: addition
Lets make a circuit that adds three 1bit inputs X, Y and Z. We will need two bits to represent the total; lets call them C and S, for
carry and sum. Note that C and S are two separate functionsof the sameinputs X, Y and Z. Here are a truth table and sumofminterms equations for C and S.
1 + 1 + 1 =11
0 + 1 + 1 = 10C(X,Y,Z) = m(3,5,6,7)S(X,Y,Z) = m(1,2,4,7)

8/3/2019 07 Decoders 121
17/25
September 22, 2003 Decoders
Here, two 3to8 decoders implement C and S as sums of minterms.
The +5V symbol (5 volts) is how you represent a constant 1 or true inLogicWorks. We use it here so the decoders are always active.
Decoderbased adder
C(X,Y,Z) = m(3,5,6,7)
S(X,Y,Z) = m(1,2,4,7)

8/3/2019 07 Decoders 121
18/25
September 22, 2003 Decoders
Using just one decoder
C(X,Y,Z) = m(3,5,6,7)S(X,Y,Z) = m(1,2,4,7)
Since the two functions C and S both have the same inputs, we could usejust one decoder instead of two.

8/3/2019 07 Decoders 121
19/25
September 22, 2003 Decoders
Building a 3to8 decoder
You could build a 3to8 decoder directly from the truth table and equationsbelow, just like how we built the 2to4 decoder.
Another way to design a decoder is to break it into smaller pieces. Notice some patterns in the table below:o When S2 = 0, outputs Q0Q3 are generated as in a 2to4 decoder.o When S2 = 1, outputs Q4Q7 are generated as in a 2to4 decoder.
Q0 = S2 S1 S0 = m0Q1 = S2 S1 S0 = m1Q2 = S2 S1 S0 = m2Q3 = S2 S1 S0 = m3
Q4 = S2 S1 S0 = m4Q5 = S2 S1 S0 = m5Q6 = S2 S1 S0 = m6Q7 = S2 S1 S0 = m7

8/3/2019 07 Decoders 121
20/25
September 22, 2003 Decoders
Decoder expansion
You can use enable inputs to string decoders together. Heres a 3to8decoder constructed from two 2to4 decoders:

8/3/2019 07 Decoders 121
21/25
September 22, 2003 Decoders
Modularity
Be careful not to confuse the inner inputs and outputs of the 2to4decoders with the outer inputs and outputs of the 3to8 decoder (which
are in boldface). This is similar to having several functions in a program which all use aformal parameter x.
You could verify that this circuit is a 3to8 decoder, by using equations forthe 2to4 decoders to derive equations for the 3to8.

8/3/2019 07 Decoders 121
22/25
September 22, 2003 Decoders
A variation of the standard decoder
The decoders weve seen so far are activehigh decoders.
An activelow decoderis the same thing, but with an inverted EN input andinverted outputs.

8/3/2019 07 Decoders 121
23/25
September 22, 2003 Decoders
Separated at birth?
Activehigh decoders generate minterms, as weve already seen.
The output equations for an activelow decoder are mysteriously similar, yetsomehow different.
It turns out that activelow decoders generate maxterms.
Q3 = S1 S0Q2 = S1 S0Q1 = S1 S0Q0 = S1 S0
Q3 = (S1 S0) = S1 + S0Q2 = (S1 S0) = S1 + S0Q1 = (S1 S0) = S1 + S0Q0 = (S1 S0) = S1 + S0

8/3/2019 07 Decoders 121
24/25
September 22, 2003 Decoders
Activelow decoder example
So we can use activelow decoders to implement arbitrary functions too, butas a product of maxterms.
For example, here is an implementation of the function from the previouspage, f(x,y,z) = M(4,5,7),using an activelow decoder.
The ground symbol connected to EN represents logical 0, so this decoderis always enabled.
Remember that you need an AND gate for a product of sums.

8/3/2019 07 Decoders 121
25/25
September 22, 2003 Decoders
Summary
A nto2n decoder generates the minterms of an nvariable function. As such, decoders can be used to implement arbitrary functions.
Later on well see other uses for decoders too. Some variations of the basic decoder include:o Adding an enable input.o Using activelow inputs and outputs to generate maxterms.o We also talked about:o Applying our circuit analysis and design techniques to understand and
work with decoders. Using block symbols to encapsulate common circuits like decoders. Building larger decoders from smafhxhcller ones.
o ller ones.o ller ones.o ller ones.o ller ones.
ller ones. ller ones.
o ller ones.o ller ones.o ller ones.o ller ones.o ller ones.