Digital Day1
Digital Day1
• Logic gates
• Multiplexers
• Demultiplexer
• Decoder
• Encoder
• Binary Adders
• Subtractor
• Combinational circuit designing
Apply Your Knowledge
1. Decimal 43 in hexadecimal and BCD number system is respectively……. and ……..
2. For the gate in the given figure the output will be ……….
3. P is a 8-bit signed integer. The 2's complement representation of P is (F8)hexa. The 2's
complement representation of 8*P
4. For the truth table of the given figure Y = ………….
Designing logic circuits from Statement
P1’.P2’.P3’
Designing logic circuits from Statement
X Y
NOT X' 𝑋 ~X X Y 0 1
1 0
X Y Z
X 0 0 0
AND X•Y XY XY Y Z 0 1 0
1 0 0
1 1 1
X X Y Z
OR X+Y XY Z 0 0 0
Y 0 1 1
1 0 1
1 1 1
Logic gates
NAND X Y Z
X 0 0 1
Z 0 1 1
Y
1 0 1
1 1 0
NOR X Y Z
X 0 0 1
Z 0 1 0
Y 1 0 0
1 1 0
XOR X Y X
X
0
Y
0
Z
0 X xor Y = X Y' + X' Y
Z
Y 0 1 1 X or Y but not both
1 0 1 ("inequality", "difference")
1 1 0
XNOR X = Y X Y Z X xnor Y = X Y + X' Y'
X 0 0 1
Z 0 1 0
X and Y are the same
Y
1 0 0 ("equality", "coincidence")
1 1 1
From Boolean expressions to logic gates
A.B A+B
A’.B A xor B
NANDs are special!
The NAND gate is universal: it can replace all other gates!
NOT x’ = (xx)’ [ because xx = x ]
AND
OR
x+y
= (x’ y’)’ [ xx = x, and yy = y ]
= ((xx)’ (yy)’)’ [ DeMorgan’s law ]
Making NAND circuits
• The easiest way to make a NAND circuit is to start with a regular,
primitive gate-based diagram.
• Two-level circuits are trivial to convert, so here is a slightly more
complex random example.
Converting to a NAND circuit
• Step 1: Convert all AND gates to NAND gates using AND-NOT symbols, and convert
all OR gates to NAND gates using NOT-OR symbols.
Converting to NAND, concluded
• Step 2: Make sure you added bubbles along lines in pairs ((x’)’ = x). If not, then
either add inverters or complement the input variables.
NOR gates
Technology independent
Canonical forms
Two-level forms
Multi-level forms
Technology choices
Packages of a few gates
Regular logic
Two-level programmable logic
Multi-level programmable logic
Canonical Form of Boolean Expressions
A B C F F'
0 0 0 0 1
0 0 1 1 0
0 1 0 0 1
0 1 1 1 0
1 0 0 0 1
1 0 1 1 0
1 1 0 1 0
1 1 1 1 0 F' = A'B'C' + A'BC' + AB'C'
Sum-of-products canonical form (cont’d)
Product term (or minterm)
ANDed product of literals – input combination for which output is true
Each variable appears exactly once, in true or inverted form (but not both)
A B C minterms F in canonical form:
0 0 0 A'B'C' m0 F(A, B, C) = m(1,3,5,6,7)
0 0 1 A'B'C m1 = m1 + m3 + m5 + m6 + m7
0 1 0 A'BC' m2 = A'B'C + A'BC + AB'C + ABC' + ABC
0 1 1 A'BC m3
1 0 0 AB'C' m4 canonical form minimal form
1 0 1 AB'C m5 F(A, B, C) = A'B'C + A'BC + AB'C + ABC + ABC'
1 1 0 ABC' m6 = (A'B' + A'B + AB' + AB)C + ABC'
1 1 1 ABC m7 = ((A' + A)(B' + B))C + ABC'
= C + ABC'
short-hand notation for = ABC' + C
minterms of 3 variables = AB + C
Product-of-sums canonical form
Also known as conjunctive normal form
Also known as maxterm expansion
A B C F F'
0 0 0 0 1
0 0 1 1 0
0 1 0 0 1
0 1 1 1 0
1 0 0 0 1
1 0 1 1 0
1 1 0 1 0
1 1 1 1 0
F' = (A + B + C') (A + B' + C') (A' + B + C') (A' + B' + C) (A' + B' + C')
Product-of-sums canonical form (cont’d)
• Sum term (or maxterm)
ORed sum of literals – input combination for which output is false
each variable appears exactly once, in true or inverted form (but not both)
A B C maxterms F in canonical form:
0 0 0 A+B+C M0 F(A, B, C) = M(0,2,4)
0 0 1 A+B+C' M1 = M0 • M2 • M4
0 1 0 A+B'+C M2 = (A + B + C) (A + B' + C) (A' + B + C)
0 1 1 A+B'+C' M3
1 0 0 A'+B+C M4 canonical form minimal form
1 0 1 A'+B+C' M5 F(A, B, C) = (A + B + C) (A + B' + C) (A' + B + C)
1 1 0 A'+B'+C M6
= (A + B + C) (A + B' + C) (A + B + C) (A' + B + C)
1 1 1 A'+B'+C' M7
= (A + C) (B + C)
minimized sum-of-products
F2 F(A, B, C) = (A + B + C) (A + B' + C) (A' + B + C)
= (A + C) (B + C)
canonical product-of-sums
F3
minimized product-of-sums
F4
Karnaugh maps
Flat map of Boolean cube
Wrap–around at edges
Hard to draw and visualize for more than 4 dimensions
Virtually impossible for more than 6 dimensions
Alternative to truth-tables to help visualize adjacencies
Guide to applying the uniting theorem
On-set elements with only one variable changing value are adjacent unlike the
situation in a linear truth-table A B F
A 0 0 1
B 0 1
0 1 1 0 1 0
0 2
1 0 1
1 0 0
1 3 1 1 0
Karnaugh maps (cont’d)
Numbering scheme based on Gray–code
e.g., 00, 01, 11, 10
Only a single bit changes in code for adjacent map cells
AB A
C 00 01 11 10
A
0
0 2 6 4
0 4 12 8
C 1
1 3 7 5
1 5 13 9 D
B
A 3 7 15 11
C
0 2 6 4 2 6 14 10
B
C 13 = 1101= ABC’D
1 3 7 5
B
Adjacencies in Karnaugh maps
011 111
A
110
000 010 110 100 010
B 001
C 001 011 111 101 C 101
B 100
000 A
Karnaugh map examples
F=
A
1 1
Cout = B’
B 0 0
f(A,B,C) = m(0,4,6,7)
A
0 0 1 0 AB + ACin + BCin
Cin 0 1 1 1
A B
1 0 0 1
obtain the
C 0 0 1 1
complement
B AC + B’C’ + AB’
of the function
by covering 0s
with subcubes
More Karnaugh map examples
A
0 0 1 1
G(A,B,C) = A
C 0 0 1 1
B
A
1 0 0 1
F(A,B,C) = m(0,4,5,7) = AC + B’C’
C 0 0 1 1
B
A
F' simply replace 1's with 0's and vice versa
0 1 1 0
F'(A,B,C) = m(1,2,3,6) = BC’ + A’C
C 1 1 0 0
B
Karnaugh map: 4-variable example
F(A,B,C,D) = m(0,2,3,5,6,7,8,10,11,14,15)
F=
C + A’BD + B’D’
A 1111
0111
1 0 0 1
0 1 0 0
D
Y
1 1 1 1 Z
W
C 1000
1 1 1 1 0000 X
B
f = A’D + B’C’D
A
0 0 X 0
1 1 X 1
D
1 1 0 0
C
0 X 0 0
B
Karnaugh maps: don’t cares (cont’d)
f(A,B,C,D) = m(1,3,5,7,9) + d(6,12,13)
f = A'D + B'C'D without don't cares
f= with don't cares
A'D + C'D
A
by using don't care as a "1"
0 0 X 0
a 2-cube can be formed
1 1 X 1
rather than a 1-cube to cover
D this node
1 1 0 0
C don't cares can be treated as
0 X 0 0 1s or 0s
B depending on which is more
advantageous
Multiplexer
MUX
Inputs Output
• MUX Types (sources) (destination)
MP3 Player
Docking Station
D0
Laptop
D1
MUX
Sound Card Y
D2
D3
S Y
0 I0
1 I1
4-to-1 Multiplexer (MUX)
D0
MUX
D1
Y
D2
D3
B A
B A Y
0 0 D0
0 1 D1
1 0 D2
1 1 D3
8-to-1 Multiplexer
1 1 1 IN7
Mux as a Universal Gate
Implement XOR, NAND gate using 2:1 mux
A B
(Select (input XOR NAND B D0 XOR 1 D0 NAND
line) line)
B’ D1 B’ D1
0 0 0 1
B 1
0 1 1 1 s s
A A
1 0 1 1
B’ B’
1 1 0 0
Implement S and CN of full adder multiplexers.
The figure below shows a multiplexer where s1 and s0 are the select lines.
I0 to I3 are the input datalines, EN is the enable line, and F(P,Q,R) is the
output. F is ___
Option a
A four-variable Boolean function is realized using 4 1 multiplexers as shown in the
figure
Option C
The minimized expression for F( U, V, W, X)
Consider the circuit shown in the figure
Option B
The Boolean expression F implemented by the circuit
Demultiplexer
DEMUX
the input is connected to. 1 2N
Input Outputs
(source) (destinations)
• DEMUX Types
1-to-2 (1 select line)
1-to-4 (2 select lines) N
1-to-8 (3 select lines) Select
1-to-16 (4 select lines) Lines 46
Typical Application of a DEMUX
Single Source Selector Multiple Destinations
B/W Laser
Printer
Fax
Machine
D0
DEMUX
X D1
D2 Color Inkjet
Printer
D3
B A Selected Destination
0 0 B/W Laser Printer Pen
0 1 Fax Machine Plotter
47
1-to-2 De-Multiplexer (DEMUX)
S D0 D1
0 I 0
1 0 I
1-to-4 De-Multiplexer (DEMUX)
D0
DEMUX
D1
X
D2
D3
B A
B A D0 D1 D2 D3
0 0 X 0 0 0
0 1 0 X 0 0
1 0 0 0 X 0
1 1 0 0 0 X
Decoder
51
What a decoder does
• A n-to-2n decoder takes an n-bitn input and produces 2n outputs. The n inputs represent a binary number
that determines which of the 2 outputs is uniquely true.
• A 2-to-4 decoder operates according to the following truth table.
The 2-bit input is called S1S0, and the four outputs are Q0-Q3.
If the input is the binary number i, then output Qi is uniquely true.
S1 S0 Q0 Q1 Q2 Q3
0 0 1 0 0 0
0 1 0 1 0 0
1 0 0 0 1 0
1 1 0 0 0 1
• For instance, if the input S1 S0 = 10 (decimal 2), then output Q2 is true, and Q0, Q1, Q3 are all false.
• This circuit “decodes” a binary number into a “one-of-four” code.
52
How can you build a 2-to-4 decoder?
• Follow the design procedures from last time! We have a truth table, so we can write
equations for each of the four outputs (Q0-Q3), based on the two inputs (S0-S1).
S1 S0 Q0 Q1 Q2 Q3
0 0 1 0 0 0
0 1 0 1 0 0
1 0 0 0 1 0
1 1 0 0 0 1
• In this case there’s not much to be simplified. Here are the equations:
Q0 = S1’ S0’
Q1 = S1’ S0
Q2 = S1 S0’
Q3 = S1 S0
53
A picture of a 2-to-4 decoder
S1 S0 Q0 Q1 Q2 Q3
0 0 1 0 0 0
0 1 0 1 0 0
1 0 0 0 1 0
1 1 0 0 0 1
54
Enable inputs
• Many devices have an additional enable input, which is used to “activate” or
“deactivate” the device.
• For a decoder,
EN=1 activates the decoder, so it behaves as specified earlier. Exactly one of the outputs will be
1.
EN=0 “deactivates” the decoder. By convention, that means all of the decoder’s outputs are 0.
• We can include this additional input in the decoder’s truth table:
EN S1 S0 Q0 Q1 Q2 Q3
0 0 0 0 0 0 0
0 0 1 0 0 0 0
0 1 0 0 0 0 0
0 1 1 0 0 0 0
1 0 0 1 0 0 0
1 0 1 0 1 0 0
1 1 0 0 0 1 0
1 1 1 0 0 0 1
55
An aside: abbreviated truth tables
EN S1 S0 Q0 Q1 Q2 Q3
• In this table, note that whenever EN=0,
0 0 0 0 0 0 0
the outputs are always 0, regardless of 0 0 1 0 0 0 0
inputs S1 and S0. 0 1 0 0 0 0 0
0 1 1 0 0 0 0
1 0 0 1 0 0 0
1 0 1 0 1 0 0
1 1 0 0 0 1 0
1 1 1 0 0 0 1
56
A 3-to-8 decoder
• Larger decoders are similar. Here is a 3-to-8 decoder.
The block symbol is on the right.
A truth table (without EN) is below.
Output equations are at the bottom right.
• Again, only one output is true for any input combination.
S2 S1 S0 Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7
0 0 0 1 0 0 0 0 0 0 0 Q0 = S2’ S1’ S0’
0 0 1 0 1 0 0 0 0 0 0 Q1 = S2’ S1’ S0
0 1 0 0 0 1 0 0 0 0 0 Q2 = S2’ S1 S0’
0 1 1 0 0 0 1 0 0 0 0 Q3 = S2’ S1 S0
1 0 0 0 0 0 0 1 0 0 0 Q4 = S2 S1’ S0’
1 0 1 0 0 0 0 0 1 0 0 Q5 = S2 S1’ S0
1 1 0 0 0 0 0 0 0 1 0 Q6 = S2 S1 S0’
1 1 1 0 0 0 0 0 0 0 1 Q7 = S2 S1 S0
57
So what good is a decoder?
• Do the truth table and equations look familiar?
S1 S0 Q0 Q1 Q2 Q3
0 0 1 0 0 0 Q0 = S1’ S0’
0 1 0 1 0 0 Q1 = S1’ S0
1 0 0 0 1 0 Q2 = S1 S0’
1 1 0 0 0 1 Q3 = S1 S0
• Decoders are sometimes called minterm generators.
For each of the input combinations, exactly one output is true.
Each output equation contains all of the input variables.
These properties hold for all sizes of decoders.
• This means that you can implement arbitrary functions with decoders. If you have a sum of
minterms equation for a function, you can easily use a decoder (a minterm generator) to implement
that function.
58
Design example: addition
59
Using just one decoder
• Since the two functions C and S both have the same inputs, we could
use just one decoder instead of two.
C(X,Y,Z) = m(3,5,6,7)
S(X,Y,Z) = m(1,2,4,7)
60
Encoder
Encoder
• Symbol to coded format conversion
Example: 4 to 2 Encoder
i3 i2 i1 i0 Valid y1 Y0
i3 i2 i1 i0 y1 Y0 0 0 0 0 0 X X
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X X
0 0 0 1 1 0 0
0 0 1 X 1 0 1
0 1 X X 1 1 0
1 X X X 1 1 1
Binary Adders
A B Cin C
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 1
Carry Look-ahead Adder
Half Subtractor
Half Subtractor
Design example 1: Comparing 2-bit numbers
• Let’s design a circuit that compares two 2-bit numbers, A and B. The
circuit should have three outputs:
G (“Greater”) should be 1 only when A > B.
E (“Equal”) should be 1 only when A = B.
L (“Lesser”) should be 1 only when A < B.
• Make sure you understand the problem.
Inputs A and B will be 00, 01, 10, or 11 (0, 1, 2 or 3 in decimal).
For any inputs A and B, exactly one of the three outputs will be 1.
Step 1: How many inputs and outputs?
• Two 2-bit numbers means a total of four inputs.
We should name each of them.
Let’s say the first number consists of digits A1 and A0 from left to right, and the second number is B1
and B0.
• The problem specifies three outputs: G, E and L.
• Here is a block diagram that shows the inputs and outputs explicitly.
• Now we just have to design the circuitry that goes into the box.
Step 2: Functional specification
• For this problem, it’s probably easiest to start A1 A0 B1 B0 G E L
with a truth table. This way, we can explicitly 0 0 0 0
show the relationship (>, =, <) between inputs. 0 0 0 1
0 0 1 0
• A four-input function has a sixteen-row truth 0 0 1 1
table. 0 1 0 0
0 1 0 1
• It’s usually clearest to put the truth table rows in 0 1 1 0 0 0 1
binary numeric order; in this case, from 0000 to 0 1 1 1
1111 for A1, A0, B1 and B0. 1 0 0 0
1 0 0 1
• Example: 01 < 10, so the sixth row of the truth 1 0 1 0
table (corresponding to inputs A=01 and B=10) 1 0 1 1
shows that output L=1, while G and E are both 0. 1 1 0 0
1 1 0 1
1 1 1 0
1 1 1 1
Step 2: Functional specification
• For this problem, it’s probably easiest to start A1 A0 B1 B0 G E L
with a truth table. This way, we can explicitly 0 0 0 0 0 1 0
show the relationship (>, =, <) between inputs. 0 0 0 1 0 0 1
0 0 1 0 0 0 1
• A four-input function has a sixteen-row truth 0 0 1 1 0 0 1
table. 0 1 0 0 1 0 0
0 1 0 1 0 1 0
• It’s usually clearest to put the truth table rows in 0 1 1 0 0 0 1
binary numeric order; in this case, from 0000 to 0 1 1 1 0 0 1
1111 for A1, A0, B1 and B0. 1 0 0 0 1 0 0
1 0 0 1 1 0 0
• Example: 01 < 10, so the sixth row of the truth 1 0 1 0 0 1 0
table (corresponding to inputs A=01 and B=10) 1 0 1 1 0 0 1
shows that output L=1, while G and E are both 0. 1 1 0 0 1 0 0
1 1 0 1 1 0 0
1 1 1 0 1 0 0
1 1 1 1 0 1 0
Step 3: Simplified Boolean expressions
Let’s use K-maps. There are three functions (each with the same inputs A1 A0 B1 B0), so we
need three K-maps.
B1 B1 B1
0 0 0 0 1 0 0 0 0 1 1 1
1 0 0 0 0 1 0 0 0 0 1 1
A0 A0 A0
1 1 0 1 0 0 1 0 0 0 0 0
A1 A1 A1
1 1 0 0 0 0 0 1 0 0 1 0
B0 B0 B0
4-variable K-map
for each of the 4
output functions
Design example 2: 2x2-bit multiplier (cont’d)
A2 A2
K-map for P8 K-map for P4
0 0 0 0 0 0 0 0
P4 = A2B2B1'
0 0 0 0 0 0 0 0
B1 + A2A1'B2 B1
0 0 1 0 0 0 0 1
B2 P8 = A2A1B2B1 B2
0 0 0 0 0 0 1 1
A1 A1
A2 A2
0 0 0 0
K-map for P2 K-map for P1 0 0 0 0
P1 = A1B1
0 0 1 1 0 1 1 0
B1 B1
0 1 0 1 0 1 1 0
B2 P2 = A2'A1B2 B2
0 1 1 0 + A1B2B1' 0 0 0 0
A1 + A2B2'B1 A1
+ A2A1'B1
Incrementer and Decrementer
Design example 3: BCD increment by 1
I8 I4 I2 I1 O8 O4 O2 O1
0 0 0 0 0 0 0 1
0 0 0 1 0 0 1 0
0 0 1 0 0 0 1 1
0 0 1 1 0 1 0 0
I1 O1 0 1 0 0 0 1 0 1
0 1 0 1 0 1 1 0
I2 O2 0 1 1 0 0 1 1 1
I4 O4 0 1 1 1 1 0 0 0
1 0 0 0 1 0 0 1
I8 O8 1 0 0 1 0 0 0 0
1 0 1 0 X X X X
1 0 1 1 X X X X
1 1 0 0 X X X X
1 1 0 1 X X X X
block diagram 1 1 1 0 X X X X
and 1 1 1 1 X X X X
truth table
4-variable K-map for each of
the 4 output functions
Design example 3: BCD increment by 1 (cont’d)
I8 I8
O8 O4
0 0 X 1 0 1 X 0
0 0 X 0 0 1 X 0
I1 I1
0 1 X X O8 = I4 I2 I1 + I8 I1' 1 0 X X
I2 O4 = I4 I2' + I4 I1' + I4’ I2 I1 I2
0 0 X X 0 1 X X
I4 O2 = I8’ I2’ I1 + I2 I1' I4
I8
O1 = I1' I8
O2 O1
0 0 X 0 1 1 X 1
1 1 X 0 0 0 X 0
I1 I1
0 0 X X 0 0 X X
I2 I2
1 1 X X 1 1 X X
I4 I4
Thank You