NAND and NOR Implementation
NAND and NOR Implementation
Not equivalent
OR equivalent
AND equivalent
Example: implement the following logic circuit using NAND gates only
DrOdayA.L.ARidha
29
Solution:
Step 1:
Step 2:
30
Parity bit
Generated
P
000
001
010
011
100
101
110
111
1
0
0
1
0
1
1
0
DrOdayA.L.ARidha
BC
A
00 01 11 10
0 1
1
1
1
1
P = ( A B C ) = A B C
31
Check
E
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
1
0
0
1
0
1
1
0
0
1
1
0
1
0
0
1
AB
CP
00
00
01
01
11
1
11
10
10
1
1
E = ABC P
Parallel adder
A4 B 4
C5
FA
4
S4
A3 B 3
C4
FA
3
S3
A2 B 2
C3
FA
2
A1 B 1
C2
S2
FA
1
C1
S1
DrOdayA.L.ARidha
32
Carry propagation
An
Bn
Cn+1
HA
HA
Cn
FA n
A2
B2
HA
C3
HA
C2
FA 2
A1
B1
HA
Sn
S2
C2
HA
C1
S1
FA 1
Pi = Ai Bi
Gi = Ai Bi
DrOdayA.L.ARidha
33
Now we can write the Boolean function for the carry output of each
stage and substitute for each its value from the previous equations:
C 2 = G1 + P1C1
C3 = G2 + P2C2 = G2 + P2 (G1 + P1C1 ) = G2 + P2G1 + P2 P1C1
C4 = G3 + P3C3 = G3 + P3G2 + P3 P2G1 + P3 P2 P1C1
Since the Boolean function for each output carry is expressed in sum
of products, each function can be implemented with one level of AND gates
follows by an OR gate. Note that Cn does not have to wait for Cn-1, Cn-2, ...,
and C1 to propagate; in fact, Cn is propagated at the same time as C1, and C2.
A4
B4
P4
C5
C4
C5
P4
S4
P3
S3
P2
S2
G4
A3
B3
P3
C3
Lookahead carry
P2 generator C2
G3
A2
B2
G2
A1
B1
P1
P1
S1
G1
C1
C1
BCD adder
Is a circuit that adds two BCD digits with a possible carry from previous
stage, in parallel, and produces a sum digit also in BCD. Since each input
digit doesnt exceed 9, the output sum cannot be greater 19, (9+9+1).
Suppose we apply two BCD digits to a 4-bit binary adder. The adder
will form the sum in binary and produce a result which may range from 0 to
19. These binary numbers are listed in the table below and are labeled by
symbols K, Z8, Z4, Z2, Z1. K is the carry, and subscripts under the letter Z
represent the weights that can be assigned to the four bits in the BCD code.
The first column in the table lists the binary sums as they appear in the
outputs of a 4-bit binary adder. The output sum of two decimal digits must
DrOdayA.L.ARidha
34
be represented in BCD and should appear in the form listed in the second
column of the table.
K
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
Z8
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
0
0
0
0
Binary sum
Z4
0
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1
0
0
0
0
Z2
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
Z1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
C
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
1
1
S8
0
0
0
0
0
0
0
0
1
1
0
0
0
0
0
0
0
0
1
1
BCD sum
S4
S2
0
0
0
0
0
1
0
1
1
0
1
0
1
1
1
1
0
0
0
0
0
0
0
0
0
1
0
1
1
0
1
0
1
1
1
1
0
0
0
0
S1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
Decimal
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
In examination the contents of the table, it is apparent that when the sum is
equal or less than 9, the corresponding BCD number is identical, and
therefore no conversion is needed. When the binary sum is greater than 9,
we obtain a nonvalid BCD representation. The addition of 6 to the binary
sum converts it to the correct BCD representation and also produces an
output carry as required.
The logic circuit that detects the necessary correction can be derived from
the table entries. It obvious that correction is needed when the binary sum
has an output carry K=1. The other six combinations from 1010 to 1111 that
need a correction have a 1 in position Z8. To distinguish them from binary
1000 and 1001 which also have a 1 in position Z8, we specify further that
either Z4 or Z2 must have a 1. The condition for a correction and an output
carry can be expressed by the Boolean function:
C = K + Z8Z 4 + Z8Z 2
When C=1, it is necessary to add 6 to the binary sum and provide an output
carry for next stage.
DrOdayA.L.ARidha
35
Addend
Augend
Carry in
Z8
Z4
Z2
Z1
0
4-bit binary adder
S8
S4
S2
S1
Output Carry
Magnitude Comparator
The comparison of two numbers is an operation that determines if one
number is greater than, less than, or equal to the other number. A magnitude
comparator is a combinational circuit that compares two numbers, A and B,
and determines their relative magnitude. The outcome of the comparison is
specified by three binary variables that indicate whether A>B, A=B, or A<B.
If
A = A3 A2 A1 A0
B = B3 B2 B1 B0
We define
xi = Ai Bi + AiBi
i=0, 1, 2, 3
Then
( A = B) = x3 x 2 x1 x0
( A > B) = A3 B3 + x3 A2 B2 + x3 x 2 A1 B1 + x3 x 2 x1 A0 B0
( A < B) = A3 B3 + x3 A2 B2 + x3 x 2 A1B1 + x3 x 2 x1 A0 B0
DrOdayA.L.ARidha
36
Decoders
Discrete quantities of information are represented in digital system with
binary codes. A binary code of n bits is capable of representing up 2n distinct
elements of the coded information. Decoder is a combinational circuit that
converts binary information from n input lines to a maximum of 2n unique
output lines. If n-bit decoded information has unused or dont-care
conditions, the output decoder will have less than 2n output. The name
decoder is also used in conjunction with some code converters such as BCDto-seven-segment decoder.
Inputs
Outputs
XYZ
D0
D1
D2
D3
D4
D5
D6
D7
000
001
010
011
100
101
110
111
1
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
A
B
C
38
Decoder
En
D0
D1
D2
D3
D4
D5
D6
D7
38
Decoder
En
DrOdayA.L.ARidha
D8
D9
D2
D11
D12
D13
D14
D15
37
Outputs
D7
D6
D5
D4
D3
D2
D1
D0
XYZ
0
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
0
0
0
0
0
0
000
001
010
011
100
101
110
111
0
1
2
3
41
MUX
S0 S1
Output
S1
S0
I0
I1
I2
I3
Select
DrOdayA.L.ARidha
38
I1
I2
I3
I4
I5
I6
I7
10
11
12
13
14
15
I0
I1
I2
I3
I4
I5
I6
I7
81
MUX
B
C
D
DrOdayA.L.ARidha
39
Demultiplexers
It is a combinational logic circuit that receives information on a single line
and transmits this information on one of 2n possible output lines. The
selection of a specific output line is controlled by the bit values of n
selection lines. A decoder with an enable input can function as a
demultiplexer.
14
Demultiplexer
E
Input
D0
D1
D2
D3
A
B
E
Enable
A
B
Select
A
0
0
1
1
B
0
1
0
1
D0
E
0
0
0
D1
0
E
0
0
D2
0
0
E
0
D0
D1
D2
D3
24
Decoder
E
0
1
1
1
1
D3
0
0
0
E
A
X
0
0
1
1
B
X
0
1
0
1
D0
0
1
0
0
0
D1
0
0
1
0
0
D2
0
0
0
1
0
D3
0
0
0
0
1
n Inputs
(Address)
2nm
ROM
m Outputs
(Data)
Memory size=2nm
DrOdayA.L.ARidha
40
ROM types
1) Mask programming ROM
2) Programmable ROM (PROM)
3) Erasable Programmable ROM (EPROM)
4) Electrically Erasable Programmable ROM (E2PROM)
Example: Design a combinational circuit that accept a 3-bit number and
generates an output binary number equal to the square of the input number.
Use a minimum ROM size.
Solution:
Inputs
XYZ
000
001
010
011
100
101
110
111
Outputs
D5
0
0
0
0
0
0
1
1
DrOdayA.L.ARidha
D4
0
0
0
0
1
1
0
1
D3
0
0
0
1
0
1
0
0
D2
0
0
1
0
0
0
1
0
D1
0
0
0
0
0
0
0
0
D0
0
1
0
1
0
1
0
1
X
Y
Z
D5
D4
2 4
ROM
D3
D2
D1
D0
41