Digital Electronics I - All Lecture Notes
Digital Electronics I - All Lecture Notes
Chapter 1
1.1 Introduction
Digital quantities can only take on discrete values while analog quantities vary over
a continuous range of values. Examples of analog quantities include temperature,
speed. A digital system is a combination of devices designed to manipulate phys-
ical quantities that are represented in digital form as opposed to analog systems
which manipulate systems which are represented in analog form. Examples of dig-
ital systems include electronic calculators, digital watches, digital voltmeters and
digital computers. Examples of analog devices include pointer-type instruments like
speedometers, voltmeters, analog computers, etc. Advantages of digital systems over
analog quantities are:
All number systems are based on an ordered set of numbers called digits. The total
number of digits used in a system is called the base or radix of the system e.g. base
10 (or radix 10) uses then ten digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9. The four number
systems that are used in digital systems are:
Page 1 of 110
112
Digital Electronics I Lecture Notes
iii) Octal
iv) Hexadecimal - This number system, along with the Octal system are used as
shorthand notation for the Binary number system.
This is a positional-value system, that is, the value of a digit depends on its position in
the number. It is possible to design a digital system with ten states (decimal) but this
would not be easy to design as it would mean designing a circuit with ten discrete
voltage levels.
PSfrag replacements
This is known as Base 2 or Radix 2. Uses only two digits, 0 and 1. In digital systems,
these two digits are known as bits. The binary system is a positional value system,
with the weights weights as shown in Figure 1.1.
binary point
The decimal equivalent of the binary number an an−1 · · · a1 a0 .a−1 a−2 · · · a−m is given
by:
Example:
1010.1012 = (23 ×1)+(22 ×0)+(21 ×1)+(20 ×0)+(2−1 ×1)+(2−2 ×0)+(2−3 ×1) = 10.62510
Page 2 of 110
112
Digital Electronics I Lecture Notes
Integers For integers, we use repeated division by 2 (also known as successive divi-
sion by 2). The example shown on Figure 1.2 shows how to apply this method
PSfrag replacements
to convert 5310 to binary.
2 53
2 26 R1
2 13 R0
2 06 R1
2 03 R0
2 01 R1
00 R1
The binary number is read in the direction shown by the arrow (upwards). In
this case, we can see that 5310 = 1101012
Fractions In this case we use repeated (or successive) multiplication by 2. The table
below shows this procedure to convert 0.812510 to binary.
DECIMAL BINARY
0.8125 × 2 = 1.625
1.625 − 1 = 0.625 1
0.625 × 2 = 1.250
1.250 − 1 = 0.250 1
0.250 × 2 = 0.500
0
0.500 × 2 = 1
1−1 = 0 1
Page 3 of 110
112
Digital Electronics I Lecture Notes
DECIMAL BINARY
0.485 × 2 = 0.970
0
0.970 × 2 = 1.940
1.940 − 1 = 0.940 1
0.940 × 2 = 1.880
1.880 − 1 = 0.880 1
0.880 × 2 = 1.760
1.760 − 1 = 0.760 1
0.760 × 2 = 1.520
1.520 − 1 = 0.520 1
0.520 × 2 = 1.040
1.040 − 1 = 0.040 1
0.040 × 2 = 0.080
0
0.080 × 2 = 0.160
0
.. ..
. .
From the above computations, we can see that 0.48510 cannot be represented in
binary using a finite number of bits, hence 0.48510 = 0.01111100 · · · . Normally,
the conversion in such cases is done until the required number of decimal places
is obtained. To four decimal places, we can write that 0.48510 = 0.01112 , to eight
PSfragdecimal places: 0.48510 = 0.01111100, and so on.
replacements
This is base 8 system, and it uses the eight digits 0, 1, 2, 3, 4, 5, 6 and 7. The
weighting factors are shown in Figure 1.3.
octal point
The decimal equivalent of the octal number an an−1 · · · a1 a0 .a−1 a−2 · · · a−m is given by:
Example:
Page 4 of 110
112
Digital Electronics I Lecture Notes
8 459
8 57 R3
8 07 R1
00 R7
The octal number is read in the direction shown by the arrow (upwards). In
this case, we can see that 45910 = 7138 .
Fractions In this case we use repeated (or successive) multiplication by 8. The table
below shows this procedure to convert 0.7812510 to octal.
DECIMAL OCTAL
0.78125 × 8 = 6.25
6.25 − 6 = 0.25 6
0.25 × 8 = 2.00
2−2 = 0 2
The procedure here is to convert each octal digit to its 3-bit binary equivalent then to
juxtapose these codes to give us the equivalent binary code. The 3-bit binary codes
corresponding to the octal digits are shown on the table below:
OCTAL BINARY
0 000
1 001
2 010
3 011
4 100
5 101
6 110
7 111
Page 5 of 112
110
Digital Electronics I Lecture Notes
As an example, suppose we would like to convert 713.628 to binary. From the above
table, we can see that the 3-bit binary codes for 7, 1, 3, 6 and 2 are respectively 111,
001, 011, 110 and 010. We can therefore directly write that 713.628 = 111001011.1100102.
In this case, we divide the binary number in groups of 3 bits, starting from the binary
point. We then use the table shown in the previous section to get the corresponding
octal digits. As an example, suppose we want to convert 10111101.11112 to octal. The
procedure is illustrated on Figure 1.5.
2 7 5 7 4
Page 6 of 110
112
Digital Electronics I Lecture Notes
hexadecimal point
The decimal equivalent of the hexadecimal number an an−1 · · · a1 a0 .a−1 a−2 · · · a−m is
given by:
Example:
Integers For integers, we use repeated (successive) division by 16. Note that when
a remainder exceeds 9, we replace it with the corresponding hexadecimal digit
as shown in the above table. The example shown on Figure 1.7 shows how to
apply this method to convert 42810 to hexadecimal.
The hexadecimal number is read in the direction shown by the arrow (upwards).
In this case, we can see that 42810 = 1AC16 .
Page 7 of 110
112
Digital Electronics I Lecture Notes
16 428
16 26 R 12
16 01 R 10
00 R1
Fractions In this case we use repeated (or successive) multiplication by 16. The
table below shows this procedure in converting 0.7539062510 .
DECIMAL HEXADECIMAL
0.75390625 × 16 = 12.0625
12.0625 − 12 = 0.0625 12 = C
0.0625 × 16 = 1.00
1−1=0 1
The procedure is similar to that of Octal to Binary conversion, the only difference
being that we first convert each hexadecimal digit into 4-bit binary. The 4-bit binary
codes representing each hexadecimal digit are tabulated at the beginning of this
section.
As an example, suppose we want to convert 2EA.B16 to binary. From the above table,
we can see that the 4-bit binary codes for 2, E, A, and B are respectively 0010, 1110,
1010 and 1011 so we can therefore directly write that 2EA16 = 001011101010.10112.
In this case, we divide the binary number in groups of 4 bits, starting from the bi-
nary point. We then use the table shown at the beginning of this section to get
the corresponding hexadecimal digits. As an example, suppose we want to convert
110110011.010112 to octal. The procedure is illustrated on Figure 1.8 below.
Hence 110110011.010112 = 1B3.5816 .
110
Page 8 of 112
Digital Electronics I Lecture Notes
1 B 3 5 8
Our discussion so far has assumed that we are dealing with positive numbers. The
binary numbers discussed so far are known as unsigned binary numbers.
Digital systems represent all information with binary digits (bits 0,1). Since digital
computers and calculators handle negative as well as positive numbers, some means
is required for representing the sign of the number (+ or -). This is done by the use
of a sign bit. The most significant bit of a binary number is used to denote the sign
of the number.
There are three notations that are commonly used representing signed numbers.
These are:
i) Sign-Magnitude Notation
In all these notations, positive numbers have the Most Significant Bit (MSB) as zero,
while negative numbers have an MSB of 1.
To obtain the sign-magnitude notation of a given number, we first obtain its unsigned
binary equivalent using the methods described in the previous sections. If the num-
ber is positive, we then add a zero (0) to become the MSB, and if the number is
negative, we add a one (1) to become the MSB.
Example
Convert+53 and -53 to binary in sign-magnitude notation.
Page 9 of 110
112
Digital Electronics I Lecture Notes
Solution:
The unsigned binary code for 53 can be obtained by successive division by 2 as
110101. For +53, we add a ‘0’ sign bit as MSB to give the binary sign-magnitude
code for +53 as 0110101. For -53, we add a ‘1’ for a sign bit to get 1110101. We can
tabulate the decimal equivalents of the 4-bit binary codes, assuming these codes are
in sign-magnitude notation, as shown below:
Sign-Magnitude Code Decimal
0000 +0
0001 +1
0010 +2
0011 +3
0100 +4
0101 +5
0110 +6
0111 +7
1000 -0
1001 -1
1010 -2
1011 -3
1100 -4
1101 -5
1110 -6
1111 -7
Generally, for N bits, the range of integers which can be represented using this nota-
tion = − 2(N −1) − 1 ≤ I ≤ 2(N −1) − 1 .
However, as you can see from the above table, this notation has two distinct patterns
for zero, a positive zero and a negative zero. This creates complications in arithmetic
operations, and for this reason, this notation is not commonly used.
To get the ones complement notation for a positive number, the unsigned binary
notation of the number is obtained, after which the a zero (0) is added to the number
as the MSB (This is similar to the Sign-Magnitude notation).
The ones complement notation of a negative number is obtained from the corre-
sponding positive binary number by changing each zero in the digit to a 1, and each
1 in the positive binary number to a zero. As an example, we saw in the previous sec-
tion that 53 = 110101 in unsigned binary. +53 would be represented by 0110101 in
Ones Complement Notation (OCN). To represent -53 in OCN, we simply complement
all the bits in +53 to get 1001010. We can have a table similar to one in the previous
section, this time assuming the binary codes are in the Ones Complement Notation.
110
Page 10 of 112
Digital Electronics I Lecture Notes
Generally, for N bits, the range of integers which can be represented using this nota-
tion = − 2(N −1) − 1 ≤ I ≤ 2(N −1) − 1 .
Just as in the previous case, you can see from the above table that this notation also
has two distinct patterns for zero, a positive zero and a negative zero.
To illustrate the problem created by the two patterns for zero, suppose we want to
perform the operation (7−4). This can be rewritten as 7+(−4). From the above table,
+7 = 0111 and −4 = 1011. Adding these two codes gives 10010. Since we are dealing
with 4-bit binary in this case, we can ignore the fifth bit to get 0010. From the above
table once again, we see that 0010 corresponds to +2. But we know that 7 − 4 = +3.
The incorrect result obtained above is as a result of having two zeros. Generally, the
presence of two distinct patterns for zero complicates arithmetic operations and for
this reason, this notation is not commonly used.
The procedure for obtaining the Twos Complement Notation (TCN) of a positive
number is similar to that of obtaining OCN for a positive number. For a negative
number, you add 1 to the Least Significant Bit (LSB) position of the ones complement
notation of the number.
Example
Obtain the TCN of +53 and -53.
Solution:
53 = 110101 in unsigned binary. Adding a sign bit gives +53 = 0110101 in TCN.
To obtain the code for -53, we first obtain the ones complement notation of the code
0110101, which is 1001010. We then add 1 to the LSB position to get 1001011,
which is the TCN of -53.
The decimal equivalent of the TCN binary code an an−1 · · · a1 a0 .a−1 a−2 · · · a−m is given
Page 11 of 112
Page 11 of 110
Digital Electronics I Lecture Notes
by:
A table showing 4-bit TCN codes and their decimal equivalents is shown below:
Twos Complement Decimal
0000 +0
0001 +1
0010 +2
0011 +3
0100 +4
0101 +5
0110 +6
0111 +7
1000 -8
1001 -7
1010 -6
1011 -5
1100 -4
1101 -3
1110 -2
1111 -1
Generally, for N bits, the range of integers which can be represented using this nota-
tion = −2(N −1) ≤ I ≤ 2(N −1) − 1.
In this case, there is only one zero, so there are no problems with arithmetic. In
fact, digital computers use twos complement binary in arithmetic operations since
addition can be carried out just as addition (e.g. 7 − 4 = 7 + (−4). This means that
the same circuit can be used for both addition and subtraction, which saves on the
hardware to be used for these operations.
Example
Convert -29.625 into Twos Complement Binary.
Solution:
29.625 = 1 1 1 0 1 . 1 0 1 (unsigned)
+29.625 = 0 1 1 1 0 1 . 1 0 1 (signed)
-29.625 = 1 0 0 0 1 0 . 0 1 0 (OCN)
+ 1
-29.625 = 1 0 0 0 1 0 . 0 1 1 (TCN)
Hence the Twos Complement notation for -29.625 = 100010.011. As a cross-check,
using the formula for converting a TCN number to decimal, we get:
(−25 ×1)+(24 ×0)+(23 ×0)+(22 ×0)+(21 ×1)+(20 ×0)+(2−1 ×1)+(2−2 ×0)+(2−3 ×1)
Page 12 of 110
112
Digital Electronics I Lecture Notes
29.625 = 1 1 1 0 1 . 1 0 1 (unsigned)
+29.625 = 0 0 0 0 0 0 0 0 1 1 1 0 1 . 1 0 1 (signed)
-29.625 = 1 1 1 1 1 1 1 1 0 0 0 1 0 . 0 1 0 (OCN)
+ 1
-29.625 = 1 1 1 1 1 1 1 1 0 0 0 1 0 . 0 1 1 (TCN)
As we can see, after obtaining the unsigned binary, we add leading zeros and a ‘0’
sign-bit to make 16 bits then we proceed as usual. Use the formula for TCN to
decimal conversion to show that the result obtained, 1111111100010.011 is equal
to -29.625.
BCD code represents each digit of a decimal number by a 4-bit binary number. The
codes used are tabulated below:
DECIMAL BCD
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
Note that BCD code uses binary codes 0000 to 1001 to represent decimal digits, it
does not use codes 1010, 1011, 1100, 1101, 1110 and 1111. It is a weighted code.
The weightings for a 12-bit BCD number are shown below:
To convert a decimal number to BCD code, we simply write out the BCD code for
each digit e.g. to convert the decimal number 137 to BCD, we can see from the
above table that the BCD code for 1 is 0001, for 3 is 0011 and for 7 is 0111, so the
BCD code for 137 is 000100110111.
To convert a BCD code number to decimal, we simply group the bits in groups of 4
bits each and write out the decimal digit corresponding to each decimal digit.
Page 13 of 110
112
Digital Electronics I Lecture Notes
The main advantage of BCD code is the relative ease of converting to and from dec-
imal. BCD code is used in digital machines whenever decimal information is either
applied as inputs or displayed as outputs e.g. digital voltmeters, digital clocks, e.t.c.
use BCD because they display information in decimal. Electronic calculators use BCD
because the input numbers are entered in decimal via the keypad and the output
numbers displayed in decimal.
However, BCD code is not used in modern high-speed digital computers because:
• The arithmetic with BCD is more complicated (can you explain these points??)
The excess-3 code (also known as Xs-3 code) for a decimal number is obtained in the
same manner as for BCD, except that 3 is added to each digit before encoding it in
binary. The example below shows how to convert 59 to Xs-3 code.
5 9
+ 3 + 3
—— ——
8 12
↓ ↓
1000 1100
The Xs-3 code for 59 is therefore 10001100. The table below shows the codes used
by Xs-3 code, and these are listed alongside BCD codes.
DECIMAL BCD Xs-3 CODE
0 0000 0011
1 0001 0100
2 0010 0101
3 0011 0110
4 0100 0111
5 0101 1000
6 0110 1001
7 0111 1010
8 1000 1011
9 1001 1100
The Xs-3 code does not use codes 0000, 0001, 0010, 1101, 1110 and 1111.
The advantage of this code is that at least one 1 is present in all codes, providing an
error-detection ability.
110
Page 14 of 112
Digital Electronics I Lecture Notes
In gray code, only one bit changes in going from one number to the next. It is a non-
weighted code - bit positions in the code do not have any specific weights attached
to them.
ii) Add the binary MSB to the next bit position, record the sum and neglect any
carries.
Applying this procedure on the binary code 101110110, we get the equivalent Gray
Code to be 111001101.
ii) Add the binary MSB to the next significant bit position of the Gray Code num-
ber, again recording the sum and ignoring any carries.
110
Page 15 of 112
Digital Electronics I Lecture Notes
Observe that only one bit position changes in the binary code in moving from one
number to the next. Gray code is often used in situations where other codes might
produce erroneous or ambiguous results during those transitions in which more than
1 bit of the code is changing e.g. in the transition from 7 to 8 in binary, all bit
positions change, and in a practical circuit, these bit positions may not change at
exactly the same time and this could cause problems in some circuits.
110
Page 16 of 112
Digital Electronics I Lecture Notes
Chapter 2
2.1 Introduction
In Boolean algebra, the variables (known as Boolean variables) are allowed to have
only two possible values, usually denoted as 0 and 1, unlike ordinary algebra where
variables can take on infinitely many values.
In Boolean algebra, we can have expressions such as:
x = f (A, B)
which is read as “x is a function of variables A and B”. A and B are Boolean variables
and can only take on two possible values, 0 or 1. f () is the Boolean operation on the
variables.
iii) Logical complementation (the NOT operation). Different books have different
symbols for this operation, including ∗ , 0 and¯
Any Boolean function, however complex, can be broken down to a combination of these
three operations.
17
Page 17 of 110
112
Digital Electronics I Lecture Notes
x=A+B
is read as “x equals A OR B”. We can write the operation of the 2-variable in the
form of a table as shown below:
A B x
0 0 0
0 1 1
1 0 1
1 1 1
A table, such as the one above, which shows how a logic circuit’s outputs respond to
various combinations of logic levels at the inputs is known as a truth-table.
From the truth-table above, we can write that:
0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 1
In general, a truth-table of m inputs has 2m input combinations e.g. a 3-input OR
operation (for the operation x = A + B + C) has 23 = 8 input combinations, and it is
shown on the table below:
A B C x
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 1
1 0 0 1
1 0 1 1
1 1 0 1
1 1 1 1
The OR operation is implemented using an OR gate. The Figure 2.1 shows a 2-input
OR gate and a 3-input OR gate.
In general, the OR operation produces a result of 1 when any of the input variables
is 1. The OR operation produces a result of zero only when all the input variables are
0.
110
Page 18 of 112
Digital Electronics I Lecture Notes
PSfrag replacements
A A
x B x
B C
2−input OR gate 3−input OR gate
x=A·B
is read as “x = A AND B”. Note that in most cases, the dot between A and B is
omitted and the expression simply written as x = AB. The truth-table for the 2-
input AND operation is shown below:
A B x
0 0 0
0 1 0
1 0 0
1 1 1
The AND operation is implemented using an AND gate, and Figure 2.2 shows a 2-
input and 3-input AND gate.
PSfrag replacements
A A
x B x
B
C
2−input AND gate 3−input AND gate
For the AND operation, an output equal to 1 occurs only for the single case when all
the inputs are 1. The output is 0 for any case where one or more inputs are 0.
The inputs have to be reduced to a single variable before a NOT operation can be
performed. It is the inversion or complementation function.
If this operation is to be applied on a variable A, we can then write:
x=A
110
Page 19 of 112
Digital Electronics I Lecture Notes
which is read as “x = NOT A”. The truth-table for this is shown below:
A x
0 1
1 0
This means that 0 = 1 (NOT ‘0’ = ‘1’) and 1 = 0 (NOT ‘1’ = ‘0’). Note also that 0 = 0
and 1 = 1.
The NOT operation is implemented using a NOT gate, illustrated on Figure 2.3. The
NOT gate is also known as an inverter.
PSfrag replacements
A A
x=A+B
In this case, we read this as “x equals NOT (A OR B). This case is equivalent to a
2-input OR gate and an inverter connected in series. The symbol for a 2-input NOR
gate is shown on Figure 2.4.
PSfrag replacements
A
A+B
110
Page 20 of 112
Digital Electronics I Lecture Notes
x=A·B·C
In this case, we read this as “x equals NOT (A AND B AND C). This is equivalent
to a 3-input AND gate and an inverter connected in series. The symbol for a 3-input
NAND gatePSfrag replacements
is shown on Figure 2.5.
A
A·B·C
B
C
x=A⊕B
Page 21 of 110
112
Digital Electronics I Lecture Notes
PSfrag replacements
A
A⊕B
This is usually abbreviated as XNOR or EXNOR gate. It is the complement of the XOR
operation. For variables A and B,
x=A B =A⊕B
PSfrag replacements
A
A⊕B
Just as for the XOR gate, the XNOR gate has only two inputs.
Basic Theorems
A+0=A A·1 =A
A+1=1 A·0=0
A+A=A A·A=A
A + Ā = 1 A · Ā = 0
Looking at the above table, we can see that the corresponding laws on either side are
related by:
110
Page 22 of 112
Digital Electronics I Lecture Notes
Theorems which are related to another by this double interchange are known as
duals.
Other theorems, each listed along with its dual, are tabulated below:
Example
Use a truth-table to prove that AB + AC + BC = AB + AC.
Solution:
A B C AB AC BC AB + AC + BC AB + AC
0 0 0 0 0 0 0 0
0 0 1 0 1 0 1 1
0 1 0 0 0 0 0 0
0 1 1 0 1 1 1 1
1 0 0 0 0 0 0 0
1 0 1 0 0 0 0 0
1 1 0 1 0 0 1 1
1 1 1 1 0 1 1 1
Page 23 of 112
110
Digital Electronics I Lecture Notes
Looking at the table above, we can see that the columns for AB + AC + BC and
AB + AC are identical so the two expressions are equivalent. This has been shown
by means of a truth-table. Proving Boolean expressions by use of truth-table is known
as proof by perfect induction.
This requires a masterly of the laws of Boolean algebra so a lot of practice is needed
to be able to use this technique effectively.
Example
Use algebraic means to show that A + A · B = A
Solution:
A+A·B =A·1+A·B
= A · (1 + B) = A · 1 = A
Example
Use algebraic means to show that A + A · B = A + B
Solution:
A+A·B =A+A·B +A·B
= A + (A + A) · B = A + B · (1)
=A+B
There are two standard forms for Boolean expressions: Standard sum of products
form and Standard product of sums form.
Given a function:
f (A, B, C) = (AB + C)(B + AC)
we can use the distributive rule (informally known as opening the brackets) to write:
f (A, B, C) = AB + BC + ABC + AC
110
Page 24 of 112
Digital Electronics I Lecture Notes
From the expression above, the terms AB, BC, ABC and AC are products, and
they are all combined with an OR operation (logical addition or summation) so the
expression is said to be in Sum of Products form. (Note however that expressions like
ABC + ABC are not in Sum of Products form since the inversion signs cover more
than one variable).
Now consider the expression we obtained above:
f (A, B, C) = AB + BC + ABC + AC
This is a function of variables A, B and C, but not all the product terms contain all
these variables e.g. the product term AB lacks the variable C, BC lacks the variable
A, and so on. To express the function in Standard Sum of Product form, we must add
the missing variables to all the product terms so that every variable appears in each
product term (either in its true form or in its complement form). To do this, we use
the Boolean algebra laws:
(A + A) = 1 and A·1=A
110
Page 25 of 112
Digital Electronics I Lecture Notes
Going back to the function we started off with and using the above table, we can
write:
f (A, B, C) = m7 + m6 + m3 + m5
Sometimes the above expression is written as:
f (A, B, C) = Σm(3, 5, 6, 7)
Given a function:
f (A, B, C) = (AB + C)(B + AC)
we can use the distributive rule to write:
= (A + B)(A + C)(B + C)
The above expression is said to be in product of sums form. To convert this to the
Standard product of sums form, we add the missing variables in each term, using the
Boolean rules:
A·A=0 and (A + 0) = A
We can therefore write:
110
Page 26 of 112
Digital Electronics I Lecture Notes
A B C maxterm
0 0 0 M0 =A+B+C
0 0 1 M1 = A + B + C̄
0 1 0 M2 = A + B̄ + C
0 1 1 M3 = A + B̄ + C̄
1 0 0 M4 = Ā + B + C
1 0 1 M5 = Ā + B + C̄
1 1 0 M6 = Ā + B̄ + C
1 1 1 M7 = Ā + B̄ + C̄
We can therefore write:
f (A, B, C) = M0 · M1 · M2 · M4
f (A, B, C) = ΠM (0, 1, 2, 4)
110
Page 27 of 112
Digital Electronics I Lecture Notes
Chapter 3
SIMPLIFICATION OF BOOLEAN
EXPRESSIONS AND COMBINATIONAL
LOGIC CIRCUIT DESIGN
Introduction
B x
PSfrag replacements
C
28
Page 28 of 110
112
Digital Electronics I Lecture Notes
= AB A(B + C)
= AB AB + AC
= ABAB + ABAC
= AB C
This canPSfrag
be implemented using only two gates, as shown on Figure 3.2.
replacements
A
B x
C
To use this method, you need to know the theorems of Boolean algebra very well -
you will need a lot of practice to improve your skills. There are generally two steps
when using this method:
i) Put the expression in Sum of Products form (not Standard Sum of Products
form). This may require the use of De Morgan’s theorem or the distributive
rules.
ii) Check for common factors and factor out whenever possible. Factoring usually
results in the elimination of some of the terms.
Page 29 of 110
112
Digital Electronics I Lecture Notes
Example
Simplify algebraically:
ABC + AB C̄ + AB̄C
The expression is already in sum of products form, so we shall just factor out the
expression:
ABC + AB C̄ + AB̄C = AB C + C̄ + AB̄C
= AB + AB̄C = A B + B̄C
= A (B + C) = AB + AC
Example
Simplify algebraically:
x = ABC + AB ĀC̄
This expression is not in sum of products form, so we shall first apply De Morgan’s
Theorems to get:
x = ABC + A + B A + C
= ABC + A + B (A + C)
= ABC + AC + AB + BC
Now the expression is in sum of products form, so we can proceed with the simplifi-
cation:
x = C A + AB + AB + BC
= C A + B + AB + BC
= AC + BC + BC + AB
= AC + B + B C + AB
= AC + C + AB
= C + AB
Example
A student may register for course X only if he satisfies the following conditions:
(1) Has completed at least 20 courses AND is an engineering student AND of good
conduct, OR
(2) Has completed at least 20 courses AND is an engineering student AND has
departmental approval, OR
(3) Has completed fewer than 20 courses AND is an engineering student AND not
of good conduct, OR
110
Page 30 of 112
Digital Electronics I Lecture Notes
B: Is an engineering student
C: Is of good conduct
Y = ABC + ABD + AB C + CD + B D
= ABC + B D + AD + AB C + CD + B D
= ABC + B D + A + AB C + CD
= (ABC + AB) + B D + AB C + CD
= AB + AB C + B D + CD
= B A + ĀC̄ + B D + CD
= B A + C + B D + CD
= AB + B C + B D + CD
Recall the theorem:
AB + AC + BC = AB + AC
We can use this theorem to rewrite the expression in brackets above as:
BD + CD = BD + CD + BC
Hence:
Y = AB + B C + B D + CD + BC
= AB + B C + C + B D + CD
= AB + B + B D + CD
= B + B D + CD
= B + CD
Hence a student may register for the course X if he is an engineering student OR he
is of good conduct AND has departmental approval.
110
Page 31 of 112
Digital Electronics I Lecture Notes
Introduction
A A
B 0 1 B 0 1
0 m0 m2 0 1 0
1 m1 m3 1 1 0
The K-map may be alternatively drawn with the variable A on the vertical side and
variable B on the horizontal side, as shown on Figure 3.4:
3-variable K-map
Page 32 of 110
112
PSfrag replacements Digital Electronics I Lecture Notes
B B
A 0 1 A 0 1
0 m0 m1 0 1 1
PSfrag replacements 1 m2 m3 1 0 0
A B C x minterm
0 0 0 1 m0
0 0 1 1 m1
0 1 0 1 m2
0 1 1 0 m3
1 0 0 0 m4
1 0 1 0 m5
1 1 0 1 m6
1 1 1 0 m7
AB AB
C 00 01 11 10 C 00 01 11 10
0 m0 m2 m6 m4 0 1 1 1 0
PSfrag replacements
1 m1 m3 m7 m5 1 1 0 0 0
Note that the K-map cells are labelled in such a way that adjacent cells differ only in
one variable.
The 3-variable K-map may be alternatively drawn as shown on Figure 3.6.
C C
AB 0 1 AB 0 1
00 m0 m1 00 1 1
01 m2 m3 01 1 0
11 m6 m7 11 1 0
10 m4 m5 10 0 0
Note that the two representations shown (Figure 3.5 and Figure 3.6) are equivalent,
and you may work with whichever representation that you are more comfortable
Page 33 of 110
112
Digital Electronics I Lecture Notes
with. The only thing you should keep in mind is the order in which the variables
appear – in this case, they appear in the order A (MSB), B and C (LSB).
PSfrag replacements
4-variable K-map
AB AB
CD 00 01 11 10 CD 00 01 11 10
00 m0 m4 m12 m8 00 0 0 0 0
01 m1 m5 m13 m9 01 1 1 1 0
11 m3 m7 m15 m11 11 0 0 1 0
10 m2 m6 m14 m10 10 0 0 0 0
3.1.3 Looping
The Logic function can be simplified by properly combining those squares in the that
contain 1s. The process of combining 1s is called looping. The number of 1s that can
be looped together should be a power of 2 (1, 2, 4, 8, 16 e.t.c.).
Page 34 of 110
112
Digital Electronics I Lecture Notes
CD CD
AB 00 01 11 10 AB 00 01 11 10
00 m0 m1 m3 m2 00 0 1 0 0
01 m4 m5 m7 m6 01 0 1 0 0
10 m8 m9 m11 m10 10 0 0 0 0
Groups of 2 (Pairs)
Two ones can be looped together if they are horizontally or vertically adjacent. Two
PSfrag replacements
ones next to each other diagonally are not adjacent. Looping a pair of adjacent 1s in a
K-map eliminates the variable that appears in the complemented and uncomplemented form.
Variables that are the same C
for all cells of the loop must appear in the final expression.
Example
Consider the K-map shown on Figure 3.9.
AB
C ĀB̄ ĀB AB AB̄
C̄ 0 1 1 0
C 0 0 0 0
The two 1s shown in the K-map are horizontally adjacent and can be looped together
as a pair as shown in the figure. Looking at the cells enclosed in the loop, we can
see that variable A appears as Ā in one cell (complemented form) and as A (uncom-
plemented form) in the other cell hence it is eliminated. Variable B appears as B in
both cells and variable C appears as C̄ so the simplified expression is:
x = B C̄
Example
Consider the K-map shown on Figure 3.10.
The two ones are vertically adjacent and the variable C is the one that changes and
is eliminated hence:
x = ĀB
Page 35 of 110
112
Digital Electronics I Lecture Notes
C
AB
C ĀB̄ ĀB AB AB̄
C̄ 0 1 0 0
C 0 1 0 0
PSfrag replacements
The leftmost column and the rightmost column of the K-map are considered to be
adjacent. Similarly, the top row and the bottom row of a K-map are considered to be
adjacent. C
Example
Consider the K-map shown on Figure 3.11.
AB
C ĀB̄ ĀB AB AB̄
C̄ 1 0 0 1
C 0 0 0 0
In this case,
x = B̄ C̄
Groups of 4 (Quads)
Four 1s PSfrag
can be replacements
looped together if they are horizontally adjacent, vertically adjacent
or form a square. A loop of four 1s eliminates 2 variables that appear in both com-
plemented and uncomplemented
C form.
Example
Consider the K-map shown on Figure 3.12.
AB
C ĀB̄ ĀB AB AB̄
C̄ 0 0 0 0
C 1 1 1 1
Page 36 of 110
112
Digital Electronics I Lecture Notes
The four 1s are horizontally adjacent and are looped together to give:
PSfrag replacements
x=C
Example
Consider the K-map shown on Figure 3.13.
AB
CD ĀB̄ ĀB AB AB̄
C̄ D̄ 0 1 0 0
C̄D 0 1 0 0
CD 0 1 0 0
C D̄ 0 1 0 0
The four 1s are vertically adjacent and are looped together to give:
PSfrag replacements
x = ĀB
Example
AB
CD ĀB̄ ĀB AB AB̄
C̄ D̄ 0 1 1 0
C̄D 0 1 1 0
CD 0 0 0 0
C D̄ 0 0 0 0
The four 1s in Figure 3.14 form a square and are looped together to give:
x = B C̄
Other examples of quads are shown on Figure 3.15, where x = B̄D for the K-map on
the left and x = B D̄ for the K-map on the right.
Page 37 of 110
112
Digital Electronics I Lecture Notes
AB AB
CD ĀB̄ ĀB AB AB̄ CD ĀB̄ ĀB AB AB̄
C̄ D̄ 0 0 0 0 C̄ D̄ 0 1 1 0
C̄D 1 0 0 1 C̄D 0 0 0 0
PSfrag replacements
CD 1 0 0 1 CD 0 0 0 0
C D̄ 0 0 0 0 C D̄ 0 1 1 0
Figure 3.16: The 1s at the corners are adjacent and can looped together
Since the top row of a K-map is adjacent to the bottom row, and the right column to
the left, the corner cells of a K-map are also considered adjacent and can be looped
together if they all contain 1s, as shown on Figure 3.16.
PSfragInreplacements
this case, x = B̄ D̄.
Groups of 8 (octets)
Eight ones may be looped together if they are adjacent. A loop of eight 1s eliminates
3 variables. Examples of octets are shown on Figure 3.17.
AB AB
CD ĀB̄ ĀB AB AB̄ CD ĀB̄ ĀB AB AB̄
C̄ D̄ 1 1 0 0 C̄ D̄ 1 1 1 1
C̄D 1 1 0 0 C̄D 0 0 0 0
CD 1 1 0 0 CD 0 0 0 0
C D̄ 1 1 0 0 C D̄ 1 1 1 1
x = Ā x = D̄
Page 38 of 110
112
Digital Electronics I Lecture Notes
2. Examine the map and loop those 1s which are not adjacent to any other 1s.
these are called isolated 1s.
3. Identify those 1s that are adjacent to only one other 1. Loop any pair containing
such a 1. Adjacent ones which can be combined in more than one way are
temporarily bypassed.
4. Identify those 1s which can be combined with three other 1s in only one way.
If not all four 1s so involved have already been looped as pairs, loop the four
1s. The 1s that can be looped in a group of four in more than one way are
temporarily bypassed.
6. Loop any quad that contains one or more 1s that have not yet been looped.
7. Loop any pairs necessary to include any 1s that have not yet been looped, mak-
ing sure to use the minimum number of loops.
Note: If the expression you obtain using the steps above can be simplified further by
algebraic means, it means you have not looped properly - you may be using too many
loops and/or your loops may not be large enough.
Carefully go through the examples below, and see if you can come up with the same
loops. These examples have been looped in such a way as to obtain the simplest
possible expressions.
Example
110
Page 39 of 112
PSfrag replacements
Digital Electronics I Lecture Notes
AB
CD ĀB̄ ĀB AB AB̄
C̄ D̄ 0 0 0 1
C̄D 0 1 1 0
PSfrag replacements CD 0 1 1 0
C D̄ 0 0 1 0
C̄D 0 1 1 1
PSfrag replacements
CD 1 1 1 0
C D̄ 0 0 1 0
So far, we have talked about obtaining Sum of Products expressions from K-maps. It
is also possible to obtain Product of Sums expressions – only this time we loop the
zeros together, not the ones. The examples below illustrate the procedure.
Example
From Figure 3.21, x = B̄ + C̄ + D̄ A + D̄
Example
Page 40 of 110
112
Digital Electronics I Lecture Notes
AB
CD 00 01 11 10
00 1 1 1 1
01 0 0 1 1
11 0 0 0 1
10 1 1 1 1
Figure 3.21:replacements
PSfrag Example: looping the 0s to obtain a product of sums expression
AB
CD 00 01 11 10
00 0 0 1 1
01 1 0 0 1
11 0 0 0 0
10 1 0 0 1
From Figure 3.22, x = (A + C + D) B̄ + D̄ C̄ + D̄ B̄ + C̄
Note that for a given K-map, looping the 1s and looping the zeros gives the same results,
only that the results are expressed in different ways. Consider the example shown on
PSfragFigure 3.23 where in one case the 1s are looped and in the other case the 0s are
replacements
looped.
AB AB
CD 00 01 11 10 CD 00 01 11 10
00 0 0 0 0 00 0 0 0 0
01 0 1 1 1 01 0 1 1 1
11 0 1 1 1 11 0 1 1 1
10 0 1 1 1 10 0 1 1 1
Figure 3.23: Example: looping 0s or 1s gives same result expressed in different ways
x = AD + BD + BC + AC
Page 41 of 110
112
Digital Electronics I Lecture Notes
x = (C + D) (A + B)
Opening the brackets of the Product of Sums expression will yield the Sum of Prod-
ucts expression obtained by looping the 1s, showing the two expressions are equiva-
lent.
These are also referred to as Unused terms, Forbidden terms or Redundant terms.
These terms describe combinations of variables which never occur in practice. In a
truth-table or a K-map, these inputs are represented by an X, an R or a d. As an
example, suppose that we have a digital circuit with three inputs and one output,
and the input combinations 000, 001 and 010 give an output 0, input combinations
101, 110 and 111 give an output 1, and input combinations 011 and 100 never occur
in practice. The truth-table for this circuit is as shown below:
A B C output
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 X
1 0 0 X
1 0 1 1
1 1 0 1
PSfrag replacements
1 1 1 1
When designing with K-maps containing don’t care variables, the designer can make
the output of any don’t care condition either a 1 or a 0 in order to produce the sim-
plest output expression. This is illustrated on Figure 3.24 for the truth-table above.
AB AB
C ĀB̄ ĀB AB AB̄ C ĀB̄ ĀB AB AB̄
C̄ 0 0 1 X C̄ 0 0 1 1
C 0 X 1 1 C 0 0 1 1
x = Ā
Figure 3.24: Example: simplifying a Boolean expression with don’t care terms
Page 42 of 110
112
Digital Electronics I Lecture Notes
1. Derive the minimized expression for the function in sum of products form (ob-
tained by minimizing Boolean expressions algebraically or by looping 1s in a
K-map).
x = AB + BC + AC = AB + BC + AC
= AB · BC · AC
which is implemented as shown on Figure 3.25.
A
PSfrag replacements
B x
1. Derive the minimized expression for the function in product of sums form (ob-
tained by looping the 0s in a K-map).
Page 43 of 110
112
Digital Electronics I Lecture Notes
and we were to implement this expression using NOR gates only, we then apply the
above steps as follows:
x = (A + B) (B + C) (A + C) = (A + B) (B + C) (A + C)
= (A + B) + (B + C) + (A + C)
which is implemented as shown on Figure 3.26.
A
PSfrag replacements
B x
3.4.1 Introduction
SSI Small Scale Integration - Digital ICs with less than 12 gates
A Combinational logic circuit is a logic circuit whose outputs are functions of the
present inputs only. It cannot ‘remember’ the effects of the previous inputs.
Page 44 of 110
112
Digital Electronics I Lecture Notes
– Done to minimize the number of gates used in the design and hence min-
imize costs, reduce power consumption and increase circuit reliability.
4. Conversion of the minimized expressions to the form that allows the implemen-
tation of the circuit using the available gates.
Example
+5V
R
SW1
+5V
R
Page 45 of 110
112
Digital Electronics I Lecture Notes
Figure 3.27 shows four switches that are part of a control circuitry in a copy machine.
The switches are at various points along the path of the copy paper as the paper
passes through the machine. Each switch is normally open and as the paper passes
over a switch, the switch closes. It is impossible for switches SW1 and SW4 to be
closed at the same time (they are far apart and the paper cannot cover them at
the same time). The LED is to light if two or more switches are closed. Design a
combinational logic circuit for the system.
Solution
The inputs in this case are switches SW1, SW2, SW3 and SW4. We shall denote
these switches as A, B, C and D respectively. Note that if a switch is open, the
corresponding input to the circuit is HIGH (Logic 1), and if a switch is closed, the
corresponding input is LOW (Logic 0). The output of the circuit is denoted as z (and
the state of this output is visually indicated by the LED): when two or more switches
closed, the output of the circuit should be HIGH (LED is LIT), otherwise the output
should be 0 (LED NOT LIT). The truth-table for the circuit is shown below:
A B C D z
0 0 0 0 X
0 0 0 1 1
0 0 1 0 X
0 0 1 1 1
0 1 0 0 X
0 1 0 1 1
0 1 1 0 X
0 1 1 1 0
1 0 0 0 1
1 0 0 1 1
PSfrag replacements 1 0 1 0 1
1 0 1 1 0
1 1 0 0 1
1 1 0 1 0
1 1 1 0 0
1 1 1 1 0
AB
CD ĀB̄ ĀB AB AB̄
C̄ D̄ X X 1 1
C̄D 1 1 0 1
CD 1 0 0 0
C D̄ X X 0 1
Figure 3.29 shows the best way to convert the don’t care variables to 1s and 0s,
achieving the biggest loops possible, and minimizing the number of loops used. The
loops have been made to obtain the minimized sum of products expression.
Page 46 of 110
112
PSfrag replacements
AB
CD ĀB̄ ĀB AB AB̄
C̄ D̄ 1 1 1 1
C̄D 1 1 0 1
CD 1 0 0 0
C D̄ 1 0 0 1
z = B̄ D̄ + C̄ D̄ + ĀB̄ + ĀC̄ + B̄ C̄
For implementation using NOR gates only, a simplified product of sums expression is
required, and this is obtained by looping the zeros as shown on Figure 3.30.
AB
CD ĀB̄ ĀB AB AB̄
C̄ D̄ 1 1 1 1
C̄D 1 1 0 1
CD 1 0 0 0
C D̄ 1 0 0 1
= Ā + B̄ + D̄ Ā + C̄ + D̄ B̄ + C̄
= Ā + B̄ + D̄ + Ā + C̄ + D̄ + B̄ + C̄
Example
Design a circuit to convert (4-bit) BCD code to Xs-3 code.
Page 47 of 110
112
Digital Electronics I Lecture Notes
Solution
The truth-table for this is shown below:
BCD CODE EXCESS-3 CODE
A B C D W X Y Z
0 0 0 0 0 0 1 1
0 0 0 1 0 1 0 0
0 0 1 0 0 1 0 1
0 0 1 1 0 1 1 0
0 1 0 0 0 1 1 1
0 1 0 1 1 0 0 0
0 1 1 0 1 0 0 1
0 1 1 1 1 0 1 0
1 0 0 0 1 0 1 1
1 0 0 1 1 1 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
1 1 1 0 X X X X
1 1 1 1 X X X X
Do you understand how to derive the truth-table above? Complete the rest of the
exercise.
Exercise
A majority function combinational logic circuit is a circuit whose output is equal to
1 if the input variables have more ones than zeros. The output is zero otherwise.
Design a 4-input majority function combinational logic circuit and implement the
circuit using NAND gates only.
Exercise
In a certain corporation, the four board members A, B, C and D own all stock, which
is distributed as follows:
A: 40%
B: 30%
C: 20%
D: 10%
Each member has a percentage vote equal to his holdings and a total vote greater
than 50% is required to pass a motion. In the boardroom, each member is to have a
switch with which to indicate a YES or NO vote. A lamp is to light if the total vote
cast is more than 50% indicating the motion being voted on is passed. Design an
electronic voting system for the corporation and implement the circuit using:
i) NAND gates only.
110
Page 48 of 112
Digital Electronics I Lecture Notes
Exercise
Figure 3.31 shows a diagram for an automobile circuit used to detect certain unde-
sirable conditions. The 4 switches D, I, L and S are used to indicate the status of the
driver’s door, the ignition, the headlights and the driver’s seatbelt respectively. The
LED is to light under the following undesirable conditions:
Under any of these undesirable conditions, the logic circuit should produce a HIGH
output z to light the LED. Design a logic circuit to light the LED when an undesirable
condition occurs, and implement the circuit using
+5V
OPEN
DOOR (D)
CLOSED
+5V
ON
IGNITION (I)
OFF
LOGIC LED
z LED
+5V CIRCUIT driver
ON
LIGHTS (L)
OFF
+5V
FASTENED
PSfrag replacementsUNFASTENED SEATBELT (S)
Figure 3.31:
Page 49 of 110
112
Digital Electronics I Lecture Notes
Chapter 4
4.1 Introduction
So far, we have dealt with combinational logic circuits, whose outputs are functions of
the current inputs only. This chapter deals with sequential logic circuits. A sequential
logic circuit is a circuit whose present outputs are functions of the present inputs, as
well as previous inputs. It has in it a unit called the memory which stores the effect of
the previous sequence of inputs. The stored effects of the previous inputs are called
the STATE of the circuit.
A sequential circuit can be represented by the block diagram on Figure 4.1.
external outputs
Combinational
inputs Logic
Circuit
state
Flip−flops
Clock
pulses
4.2 Flip-Flops
A flip-flop is a logic circuit that is capable of storing one bit of information (0 or 1).
It stores the one bit of information as long as power is supplied to the circuit. It is the
50
Page 50 of 110
112
Digital Electronics I Lecture Notes
normal
Q output
PSfrag replacementsinputs
inverted
Q output
A Flip-flop can have one or more inputs, but it has only two outputs, the normal
output Q and the inverted (or complemented) output Q. Under normal operating
conditions Q and Q are always complements of each other, i.e. either Q = 0 and Q = 1,
or Q = 1 and Q = 0.
When we refer to the STATE of a flip-flop, we are referring to the state of its normal
(Q) output i.e. if we say that the state of a flip-flop is 1, we mean Q = 1.
The NAND-gate latch is the simplest flip-flop. It is also referred to as a bistable latch.
It is illustrated on Figure 4.3.
PSfrag replacementsA
Q
B Q
The truth-table for the NAND-gate latch is shown below (Qn stands for present state,
while Qn+1 stands for next state):
110
Page 51 of 112
Digital Electronics I Lecture Notes
A B Qn Qn+1 Q̄n+1
0 0 0 1 1
0 0 1 1 1
0 1 0 1 0
0 1 1 1 0
1 0 0 0 1
1 0 1 0 1
1 1 0 0 1
1 1 1 1 0
The truth-table can be summarized as shown below:
A B Qn+1
0 0 Disallowed as it causes Q = Q̄ = 1
0 1 1
1 0 0
1 1 Qn - ‘remembers’ previous state (Memory State)
A NAND-gate latch is used as a building block for other more complicated flip-flops,
and for debouncing switches. Figure 4.4 shows how the NAND gate latch can be used
to debounce a switch.
+5V
output
time
+5V
switch switch
in in
output position 1 bouncing position 2
+5V
1
output
time
+5V
Page 52 of 110
112
Digital Electronics I Lecture Notes
SET
Q
PSfrag replacements
RESET
Q
PSfrag replacementsD Q
It is a modified version of the SET -RESET flip-flop where SET = RESET . It has
only one input, D. The truth-table for this flip-flop is shown below:
D Qn+1
0 0
1 1
110
Page 53 of 112
Digital Electronics I Lecture Notes
From the truth-table, we can see that Q transparently follows the input D, and for
this reason, the D flip-flop is sometimes referred to as a transparent latch.
PSfrag replacements Q
T
Q
PSfrag replacements
J Q
K Q
110
Page 54 of 112
Digital Electronics I Lecture Notes
J K Qn Qn+1
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 0
1 0 0 1
1 0 1 1
1 1 0 1
1 1 1 0
This truth-table can be summarized as shown below:
J K Qn+1
0 0 Qn
0 1 0
1 0 1
1 1 Q̄n
From the truth-table above, we can see that the JK flip-flop does not have invalid
inputs and it can complement. These properties make the JK flip-flop very versatile,
and it is used in many sequential logic circuits.
4.3.1 Introduction
Clock waveforms
A clock signal is a rectangular pulse train or a square wave. A clock waveform can
have many shapes, as shown on Figure 4.9.
Duty cycle
110
Page 55 of 112
Digital Electronics I Lecture Notes
0
1
Asynchronous Outputs of a logic circuit change any time one or more of the inputs
change. This kind of circuits are difficult to troubleshoot since the outputs can
change at any time.
Synchronous Outputs can only change at specific instants of time, these instants
determined by the clock.
• Master-Slave flip-flops
• Edge-triggered flip-flops
The first two types are no longer used in modern digital systems, but are covered
here for completeness.
Page 56 of 110
112
Digital Electronics I Lecture Notes
A Level-driven flip-flop is one where one level of the clock enables the data inputs
to affect the state of the flip-flop, whereas the other level disables the data inputs
from affecting the state of the flip-flop. This type of flip-flop is illustrated using a JK
flip-flop, which is shown in Figure 4.10.
PSfrag replacementsJ
Q
CLOCK (CLK)
K Q
From the figure, we can see that when the CLK signal is at logic level 0, X = Y = 1,
and from the truth-table of the NAND gate latch, we can see that the flip-flop will be
in the memory state, hence the inputs J and K will not have any effect on the outputs
Q and Q̄. This means that the inputs J and K are disabled from affecting the state of
the flip-flop when CLK = 0.
When the CLK signal is HIGH, X = J · Q̄ and Y = K · Q , hence the next state of
the flip-flop is determined by the inputs J and K. This means that when CLK = 1, the
flip-flop inputs (J and K) are enabled to affect the state of the flip-flop.
In this case, we say that the enabling level of the clock is HIGH (Logic 1).
Figure 4.11 below shows the logic symbols for level driven JK flip-flops, one case
having the enabling level of the clock as HIGH as in the case above, and the other
case with the enabling level of the clock being LOW.
PSfrag replacements
J Q J Q
K K
Q Q
CLK CLK
Enabling level Enabling level
of clock = HIGH of clock = LOW
Exercise
Draw the circuit diagrams for level-driven SET-RESET flip-flop, D flip-flop and the T
flip-flop and explain their operation.
110
Page 57 of 112
Digital Electronics I Lecture Notes
MASTER FF SLAVE FF
Q Q
primary
inputs outputs
PSfrag replacements Q Q
CLK CLK
Assume that the basic flip-flops are enabled by the HIGH level of the clock:
CLK = HIGH Primary inputs are enabled to determine the next state of the Master
flip-flop. Clock input to the Slave flip-flop is LOW so that the Slave inputs are
disabled from affecting the state of the Slave flip-flop.
CLK = LOW Primary inputs are disabled from affecting the state of the Master flip-
flop. Clock input to the Slave flip-flop is HIGH so that the Master’s outputs
PSfrag replacements
are transferred to the Slave flip-flop to determine the next state of the Slave
flip-flop.
J W Q1 Y
Q2
Q1
Q2
K
X Z
CLK
CLK = 1: W = J Q̄ and X = (KQ), hence the primary inputs J and K determine
the next state of the Master flip-flop. At the same time, Y = Z = 1 hence the
slave flip-flop cannot change state when CLK = 1.
1
About the “political correctness” of the Master-Slave notation, see a news article at
http://www.cnn.com/2003/TECH/ptech/11/26/master.term.reut/
110
Page 58 of 112
Digital Electronics I Lecture Notes
CLK = 0: W = X = 1 hence the Master flip-flop cannot change states. At the same
time, Y = Q̄1 and Z = Q1 hence the outputs of the Master are transferred to
the Slave flip-flop to determine the next output of the Master-Slave flip-flop.
The symbolPSfrag
for a JK Master-Slave flip-flop is shown on Figure 4.15.
replacements
J Q
K
CLK Q
Exercise
Draw the circuit diagram for SET-RESET Master-Slave flip-flop and explain its opera-
tion.
Edge triggered flip-flops are those that only change state during the clock transitions
(HIGH to LOW or LOW to HIGH). The flip-flops that change state during the HIGH to
LOW transitions of the clock (negative going transitions) are known as negative edge
triggered flip-flops, while those that change state at the LOW to HIGH transitions
of the clock are known as positive edge triggered flip-flops. Note that there are no
flip-flops that trigger on both the positive and the negative going transitions of the
clock.
Figure 4.16 shows the logic symbol for a positive edge triggered JK flip-flop.
The corresponding truth-table is shown below:
110
Page 59 of 112
Digital Electronics I Lecture Notes
PSfrag replacements
J
Q
Q
CLK
J K CLK Qn+1
0 0 ↑ Qn
0 1 ↑ 0
1 0 ↑ 1
1 1 ↑ Q̄n
The interpretation of the truth-table is as follows:
If the inputs of the flip-flop are J = 0, K = 0 and a Positive Going Transition (PGT) of
the clock occurs, the flip-flop will remain in its present state (Qn ), while if the inputs
are J = 0, K = 1, then a PGT of the clock will make the output to be LOW (0) e.t.c.
Figure 4.17 shows the logic symbol for a negative edge triggered JK flip-flop.
PSfrag replacements
J
Q
Q
CLK
110
Page 60 of 112
Digital Electronics I Lecture Notes
1
PSfrag replacementsCLK
0
1
J
0
1
K
0
1
Q
0
t0 t1 t2 t3 t4 t5
The flip-flop inputs we have talked about so far (J,K, D, SET, RESET, T) are known as
synchronous inputs. This is because the effect of these inputs to the flip-flop output
is synchronized with the clock.
There is another type of inputs known as asynchronous inputs. Asynchronous inputs
operate independently of the clock input. There are two asynchronous inputs in a
flip-flop, the PRESET (sometimes referred to as SET) and CLEAR (sometimes referred
to as RESET). The PRESET input is used to set the state of the flip-flop to 1 (Q = 1)
regardless of the state of the synchronous inputs and the clock, while the CLEAR
input is used to reset the flip-flop (Q = 0). These inputs are usually active-LOW, and
a JK flip-flop having these two inputs is shown on Figure 4.19.
PSfrag replacements
P RESET
J Q
K
CLK Q
CLEAR
112
Page 61 of 110
Digital Electronics I Lecture Notes
4.3.6 IC flip-flops
Examples of flip-flop ICs are the 7474 Dual D-type positive edge-triggered flip-flop IC,
the 74107A Dual JK negative edge-triggered flip-flop IC, the 74109 Dual JK positive-
edge triggered flip-flop IC, etc.
1. Set-up time tS - Minimum time just before the triggering edge of the clock
arrives during which the synchronous inputs must be held stable (5-50ns for
TTL devices).
2. Hold-time tH - Minimum time after the triggering edge of the clock during
which the inputs must be held stable (about 10ns for TTL devices).
3. Propagation delays
– tP LH Time taken after the triggering edge of the clock for the output Q to
change from LOW to HIGH.
– tP HL Time taken after the triggering edge of the clock for the output Q to
change from HIGH to LOW.
5. Clock pulse HIGH and LOW times - The manufacturer will specify the maximum
duration that the clock must remain LOW before it goes HIGH (tw (L)), and the
minimum time that the clock must be kept HIGH before it goes LOW (tw (H)).
6. Asynchronous active pulse width - Minimum time duration that the PRESET or
the CLEAR input has to be kept in its active state in order to reliably set or clear
a flip-flop.
110
Page 62 of 112
Digital Electronics I Lecture Notes
7. Clock transition times - The time the clock pulse takes to change from LOW to
HIGH (tr ), and from HIGH to LOW (tf ) should be short for reliable triggering.
(for TTL devices, tr and tf ≤ 50ns, for CMOS devices, tr and tf ≤ 200ns
SET-RESET flip-flop
Qn Qn+1 SET RESET
0 0 0 X
0 1 1 0
1 0 0 1
1 1 X 0
JK flip-flop
Qn Qn+1 J K
0 0 0 X
0 1 1 X
1 0 X 1
1 1 X 0
D flip-flop
Qn Qn+1 D
0 0 0
0 1 1
1 0 0
1 1 1
T flip-flop
Qn Qn+1 T
0 0 0
0 1 1
1 0 1
1 1 0
Exercise
Starting form the characteristic tables of the SET-RESET, JK, D and T flip-flops, derive
the excitation tables above.
110
Page 63 of 112
Digital Electronics I Lecture Notes
The procedure:
1. Construct the state transition table for the required flip-flop function.
2. Determine the combination of inputs of the flip-flop being used that gives the
same transition (this is done with the help of the flip-flop excitation tables in
section 4.5 above.
3. Determine the relationship between the required inputs and the available flip-
flop inputs.
Example
Realize a JK flip-flop function using a SET-RESET (SR) flip-flop.
REQUIRED FUNCTION FLIP-FLOP BEING USED
J K Qn Qn+1 S R
0 0 0 0 0 X
0 0 1 1 X 0
0 1 0 0 0 X
PSfrag replacements 0 1 1 0 0 1
1 0 0 1 1 0
1 0 1 1 X 0
1 1 0 1 1 0
1 1 1 0 0 1
The K-maps for S and R are shown on Figure 4.20.
JK JK
Q ¯ JK J K̄
J¯K̄ JK Q ¯ JK J K̄
J¯K̄ JK
Q̄ 0 0 1 1 Q̄ X X 0 0
Q X 0 0 X Q 0 1 1 0
S R
S = J Q̄ and R = KQ
Page 64 of 110
112
Digital Electronics I Lecture Notes
PSfrag replacements
J S Q Q
K R
CLK
Q Q
JK flip−flop
Example
Realize a D flip-flop function using an SR flip-flop.
REQUIRED FUNCTION FLIP-FLOP BEING USED
D Qn Qn+1 S R
0 0 0 0 X
0 1 0 0 1
1 0
PSfrag replacements 1 1 0
1 1 1 X 0
The K-maps for S and R are shown on Figure 4.22.
D D
Q D D Q D D
Q 0 1 Q X 0
Q 0 X Q 1 0
S R
S=D and R = D̄
110
Page 65 of 112
Digital Electronics I Lecture Notes
PSfrag replacements
D S Q Q
R
CLK
Q Q
D flip−flop
JK
Q ¯
J¯K̄ JK JK J K̄
Q̄ 0 0 1 1
Q 1 0 0 1
D = J Q̄ + K̄Q
Page 66 of 110
112
Digital Electronics I Lecture Notes
PSfrag replacements
J D Q Q
K
CLK Q Q
JK flip−flop
X Qn Qn+1
0 0
0 1
1 0
PSfrag replacements
1 1
1
P RESET
X J Q
K
CLK Q
CLEAR
4.7 Counters
1. Count events - convert a given number of event cycles into a prescribed binary
code.
2. To time events - The duration of an event can be determined from the count
and the clock frequency.
112
Page 67 of 110
Digital Electronics I Lecture Notes
the heart of a logic sequencer. Such a circuit generates the next-state informa-
tion as well as the control information.
4. Frequency division
1. Mode of operation
2. Modulus of the counter - The maximum number that a counter can sequence
through is called the modulus of the counter, e.g. if the counter goes through
the sequence 000, 001, 010, 011, 100, it goes through five states hence the
modulus of the counter is five. A modulus N counter is also referred to as a
MOD N counter or a DIVIDE by N counter hence the above counter can be
referred to as a MOD 5 counter or a DIVIDE by 5 counter.
Generally speaking, a counter that can sequence through N states is known as
a MODULO N counter or a DIVIDE by N counter. If N is a power of 2 (2, 4, 8,
16 e.t.c.), the counter is called a binary counter. If N is a power of 10 (10, 100,
1000 e.t.c.), the counter is known as a decimal or a decade counter.
ii) Synchronous - Counter in which all the flip-flops are clocked simultane-
ously. This is illustrated on Figure 4.28.
Page 68 of 112
110
Digital Electronics I Lecture Notes
PSfrag replacements Q Q Q
CLK CLK CLK
Q Q Q
include Gray Code counters and the shift register counters (ring counter and
Johnson counters).
Note that counters can be designed using a combination of flip-flops and gates, and
counters are also available in I.C. form. In the next sections, we shall look at counters
designed using a combination of flip-flops and gates.
1 1 1
MSB J J LSB J
Q3 Q2 Q1
CLK
Q3 1 Q2 K
1 Q1 K
1
K
110
Page 69 of 112
Digital Electronics I Lecture Notes
1
CLK
0
1
Q1
0
PSfrag replacements
1
Q2
0
1
Q3
0
Q3 Q2 Q1 clock pulses
0 0 0 before applying clock pulses
0 0 1 after clock pulse #1
0 1 0 after clock pulse #2
0 1 1 after clock pulse #3
1 0 0 after clock pulse #4
1 0 1 after clock pulse #5
1 1 0 after clock pulse #6
1 1 1 after clock pulse #7
0 0 0 recycles to 000 after clock pulse #8
0 0 1 after clock pulse #9
From the table above, we can see that the counter has eight distinct states and it is an
up counter. The counter is therefore a modulo-8 up asynchronous (ripple) counter.
Note that the frequency of the waveform for Q3 is 18 of the clock frequency hence this
can also be referred to as a divide by 8 counter.
Generally, for N negative-edge triggered JK flip-flops connected in the form shown
on Figure 4.29, the counter formed is a Modulo-2N ripple up counter also known as
a Divide by 2N ripple up counter. For any ripple counter, the output from the last
flip-flop in the chain divides the input clock frequency by the MOD number of the
counter.
Example
Consider the circuit shown on Figure 4.31.
Assuming that we start with Q3 = Q2 = Q1 = 0, we can draw the waveforms shown
on Figure 4.32.
We then get the truth-table for Q1 , Q2 and Q3 , which is shown below:
Page 70 of 110
112
Digital Electronics I Lecture Notes
PSfrag replacements
1 1 1
MSB J J LSB J
Q3 Q2 Q1
CLK
Q3 1 Q2 K
1 Q1 K
1
K
Figure 4.31:
1
CLK
0
1
Q1
0
1
Q1
0
PSfrag replacements 1
Q2
0
1
Q2
0
1
Q3
0
Q3 Q2 Q1 clock pulses
0 0 0 before applying clock pulses
1 1 1 after clock pulse #1
1 1 0 after clock pulse #2
1 0 1 after clock pulse #3
1 0 0 after clock pulse #4
0 1 1 after clock pulse #5
0 1 0 after clock pulse #6
0 0 1 after clock pulse #7
0 0 0 recycles to 000 after clock pulse #8
1 1 1 after clock pulse #9
From the table above, we can see that the counter has eight distinct states and it is
a down counter. The counter is therefore a modulo-8 down asynchronous (ripple)
counter or a divide by 8 down asynchronous counter.
Note: Negative-edge triggered JK flip-flops connected as shown on Figure 4.29 form
Page 71 of 110
112
Digital Electronics I Lecture Notes
up-counters, while those connected as in Figure 4.31 form down counters. If positive-
edge triggered JK flip-flops were used, the situation would reverse, such that a connection
similar to that of Figure 4.29 would yield a down counter, while a connection such as the
one of Figure 4.31 would yield an up-counter. Draw the waveforms for positive-edge
triggered JK flip-flops and verify this.
1. For a modulo-k counter, find the smallest number of flip-flops N such that
2N −1 < k < 2N , and connect them as a ripple counter.
2. Connect a NAND gate output to the asynchronous CLEAR inputs of all the flip-
flops.
3. Determine which flip-flops will be in the HIGH state at a count k and then
connect the normal outputs of these flip-flops to the NAND gate inputs.
Example
Design a JK flip-flop-based modulo-6 asynchronous up counter.
Solution
The MOD number k = 6, and this is not a power of 2. Using the equation above:
2N −1 < 6 < 2N
we find that the value of N which satisfies this is N = 3, hence we use three flip-flops
which we connect as a ripple counter. k = 6 = 1102 , hence the two most-significant
digits of the counter are the ones that should be connected to the input of the NAND
gate, to yield the circuit shown on Figure 4.33.
PSfrag replacements
1 1 LSB 1
Q3 J Q2 J Q1 J
CLK
Q3 1 Q2 1 Q1 1
K K K
CLEAR CLEAR CLEAR
Page 72 of 110
112
Digital Electronics I Lecture Notes
1
Q1
0
1
PSfrag replacements Q2
0
1
Q3
0
1
X
0
From Figure 4.34, we can see that when Q3 and Q2 go HIGH, the output of the NAND
gate (X) goes LOW, and this clears all the flip-flops (Q3 , Q2 and Q1 are taken to the
LOW state). When Q3 and Q2 go LOW, the NAND gate output goes HIGH and the
counter resumes normal operation. The duration of the resetting pulse is very short,
typically < 100ns, so the counter state 110 a temporary state and is not considered
as a valid state of the counter. Assuming that we start with Q3 = Q2 = Q1 = 0, we
can draw the truth-table for this counter as shown below:
Q3 Q2 Q1 clock pulses
0 0 0 before applying clock pulses
0 0 1 after clock pulse #1
0 1 0 after clock pulse #2
0 1 1 after clock pulse #3
1 0 0 after clock pulse #4
1 0 1 after clock pulse #5
1 1 0 temporary state, cannot be observed
0 0 0 recycles to 000 after clock pulse #6
0 0 1 after clock pulse #7
0 1 0 after clock pulse #8
The counter has 6 stable states (000, 001, 010, 011, 100 and 101) hence it is a
modulo-6 up asynchronous counter.
NOTE: Cascading a MOD k1 ripple counter with a MOD k2 ripple counter results in a
MOD k1 k2 counter.
110
Page 73 of 112
Digital Electronics I Lecture Notes
Exercise
ii) Cascade two of these MOD 3 counters and show that they form a MOD 9
counter which goes through the sequence 0000 → 0001 → 0010 → 0100 →
0101 → 0110 → 1000 → 1001 → 1010 → 0000
iii) Describe how propagation delays affect the performance of ripple counters.
These are counters in which all the flip-flops are clocked simultaneously, and as a
result, all flip-flop output changes occur simultaneously. Propagation delays do not
add together hence synchronous counters can work at much higher frequencies than
ripple counters.
The design procedure is as follows:
iii) Implement the logic circuit using flip-flops and a suitable set of logic gates.
Example
Design a JK flip-flop based circuit whose state diagram is shown on Figure 4.35.
00
01 11
10
Figure 4.35:
Solution
Since we are to use JK flip-flops to implement this function, we shall use the JK flip-
flop excitation table given in section 4.5. We then construct the table shown below:
Page 74 of 110
112
Digital Electronics I Lecture Notes
QA QA
QB 0 1 QB 0 1
0 0 X 0 X 0
PSfrag replacements
1 1 X 1 X 1
JA KA
QA QA
QB 0 1 QB 0 1
0 1 1 0 X X
1 X X 1 1 1
JB KB
MSB
QA JA JB 1
QB
KA KB 1
QA QB
CLK CLK
110
Page 75 of 112
Digital Electronics I Lecture Notes
Example
Design a JK flip-flop based circuit whose state diagram is shown on Figure 4.38.
000 111
001 110
010 101
011 100
Figure 4.38:
Using the JK flip-flop excitation table given in section 4.5, we construct the table
shown below:
PRESENT STATE NEXT STATE FLIP-FLOP INPUTS
QA QB QC QA+1 QB+1 QC+1 JA KA JB KB JC KC
0 0 0 0 0 1 0 X 0 X 1 X
0 0 1 0 1 0 0 X 1 X X 1
0 1 0 0 1 1 0 X X 0 1 X
0 1 1 1 0 0 1 X X 1 X 1
1 0 0 1 0 1 X 0 0 X 1 X
1 0 1 1 1 0 X 0 1 X X 1
1 1 0 1 1 1 X 0 X 0 1 X
1 1 1 0 0 0 X 1 X 1 X 1
The K-maps corresponding to the four flip-flop inputs are shown on Figure 4.39.
From Figure 4.39, we can see that:
JA = K A = Q B Q C , JB = K B = Q C and J C = KC = 1
112
Page 76 of 110
Digital Electronics I Lecture Notes
QA QB QA QB
QC 00 01 11 10 QC 00 01 11 10
PSfrag replacements 0 X X 0 0
0 0 0 X X
1 0 1 X X 1 X X 1 0
JA KA
QA QB QA QB
QC 00 01 11 10 QC 00 01 11 10
0 0 X X 0 0 X 0 0 X
1 1 X X 1 1 X 1 1 X
JB KB
QA QB QA QB
PSfrag replacements QC 00 01 11 10 QC 00 01 11 10
0 1 1 1 1 0 X X X X
1 X X X X 1 1 1 1 1
JC KC
MSB
QA JA QB JB QC JC 1
KA KB KC 1
QA QB QC
CLK
CLK CLK
000
010 101
011
Figure 4.41:
Page 77 of 110
112
Digital Electronics I Lecture Notes
The K-maps corresponding to the four flip-flop inputs are shown on Figure 4.42.
QA QB QA QB
QC 00 01 11 10 QC 00 01 11 10
PSfrag replacements 0 X X
0 0 0 X X X X
1 X 1 X X 1 X X X 1
JA KA
QA QB QA QB
QC 00 01 11 10 QC 00 01 11 10
0 1 X X X 0 X 0 X X
1 X X X 0 1 X 1 X X
JB KB
QA QB QA QB
QC 00 01 11 10 QC 00 01 11 10
0 0 1 X X 0 X X X X
1 X X X X 1 X 0 X 1
JC KC
JA = QC , KA = 1, JB = Q̄C , KB = QC , JC = QB , KC = QA
Note that KA and JB may be looped in more than one way – we can loop such that
KA = QC or KA = QA , and JB = Q̄A , which are also acceptable.
Page 78 of 110
112
Digital Electronics I Lecture Notes
MSB
QA JA QB JB QC JC
KA 1 KB QC KC
QA QB
CLK CLK
CLK
Figure 4.43:
All shift register counters use feedback whereby the output of the last flip-flop in the
shift register is in some way connected to the first flip-flop.
Ring counter
PSfrag replacements
This is a circulating shift register connected so that the last flip-flop shifts its value
into the first flip-flop. It operates by recirculating either a single ‘1’ or a ‘0’. An example
of a 4-bit ring counter is shown on Figure 4.44.
D Q3 D Q2 D Q1 D Q0
Q3 Q2 Q1 Q0
CLK CLK CLK CLK
Assuming that the initial state of the circuit is Q3 Q2 Q1 Q0 = 1000, the timing wave-
forms for the circuit are shown on Figure 4.45.
The waveforms can be summarized by the table below:
110
Page 79 of 112
Digital Electronics I Lecture Notes
1
CLK
0
1
Q
PSfrag replacements 3 0
1
Q2
0
1
Q1
0
1
Q0
0
Q3 Q2 Q1 Q0 clock pulses
1 0 0 0 before applying clock pulses
0 1 0 0 after clock pulse #1
0 0 1 0 after clock pulse #2
0 0 0 1 after clock pulse #3
1 0 0 0 after clock pulse #4 - recycles
Note that although this does not progress through the normal binary counting sequence,
it is still a counter because each count corresponds to a particular state of the counter.
The circuit shown on Figure 4.44 is therefore a MOD 4 ring counter which recircu-
lates a ‘1’. In general, a MOD N ring counter requires N flip-flops. This type of a
counter is mostly used in sequencing operations.
Johnson Counter
D Q2 D Q1 D Q0
Q2 Q1 Q0
CLK CLK CLK
Assuming the initial state is Q2 Q1 Q0 = 000, the timing waveforms are shown on
Figure 4.47.
110
Page 80 of 112
Digital Electronics I Lecture Notes
1
CLK
0
1
PSfrag replacementsQ
2
0
1
Q1
0
1
Q0
0
Although counters can be constructed using flip-flops, they are also available as
ICs. Examples of IC counters include the asynchronous 4-bit ripple counter 74293,
synchronous 4-bit 74193 and the decade counter 7490. Other IC counters include
the 74176, 74196, 74177, 74197 etc. More information on the operation of these
counter ICs can be obtained from the data books and the references listed at the end
of this handout.
4.8 Registers
A flip-flop is used to store 1 bit of information. When flip-flops are organized to store
many bits of information, they are called registers. We can therefore say that a flip-
flop is a single bit register. Registers can be implemented using discrete components
(flip-flops and gates), and are also available in IC form.
Data can be entered into a register in parallel form (all bits simultaneously), or in
Page 81 of 110
112
Digital Electronics I Lecture Notes
PSfrag replacements
serial form (one bit at a time). If data is entered to all flip-flops in a register at
the same time, the register is referred to as a parallel register. If data is entered
and removed one bit at a time, the register is known as a serial register or a shift
register. Figure 4.48 shows a 3-bit parallel register while Figure 4.49 shows a 3-bit
shift (serial) register.
D2 D1 D0
D Q2 D Q1 D Q0
Q2 Q1 Q0
CLK CLK CLK
PSfrag replacements
Q2 Q1 Q0
CLK CLK CLK
The operation most often performed on data that is stored in a flip-flop is the trans-
fer operation. This involves the transfer of data from one register to another. A
transfer operation is said to be a synchronous transfer when the clock inputs are
used to perform the transfer, and asynchronous transfer when the asynchronous in-
puts (P RESET , CLEAR) are used. Figure 4.50 shows a synchronous parallel data
transfer while Figure 4.51 shows a synchronous serial data transfer.
Registers available in IC form can be classified in the following categories:
i) Serial In Serial Out (SISO) - For this kind of registers, data can only be entered
in serial form, and removed in serial form e.g. 7491 8-bit register.
ii) Serial In Parallel Out (SIPO) - Data entered in serial form, read in parallel form
e.g. 74164 8-bit register.
NOTE
• Some shift registers allow a combination of the operation modes above e.g. the
74165 can be operated in SISO and PISO modes.
Page 82 of 110
112
Digital Electronics I Lecture Notes
REGISTER A REGISTER B
D Q2A D Q2B
CLK CLK
PSfrag replacements
D Q1A D Q1B
CLK CLK
D Q0A D Q0B
PSfrag replacements
CLK CLK
• A shift register where data can only be shifted to the right is known as a right-
shift register, while the ones where data can only be shifted to the left are known
as left-shift registers. The shift registers where data can be shifted both left and
right are known as bidirectional shift registers.
• If a register can be operated in all the four modes above (SISO, SIPO, PISO,
PIPO), and has a bidirectional shift, it is referred to as a universal register e.g.
74194.
Page 83 of 110
112
Digital Electronics I Lecture Notes
Chapter 5
5.1 Introduction
Digital ICs are often categorized according to their circuit complexity as measured by
the number of gates they contain:
Complexity Number of gates
Small Scale Integration (SSI) Less than 12 gates
Medium Scale Integration (MSI) 12 to 99 gates
Large Scale Integration (LSI) 100-9999 gates
Very Large Scale Integration (VLSI) More than 10000 gates
¯
f (A, B, C, D) = ĀB C̄ + BCD + ABD.
102
Page 84 of 110
112
Digital Electronics I Lecture Notes
Using AND-OR-NOT logic, this circuit requires three 3-input AND gates, one 3-input
OR gate and 3 inverters, a minimum of 3 SSI ICs. If the circuit were to be imple-
mented using NAND gates only, three 2-input NAND gates and four 3-input NAND
gates would be required, again requiring a minimum of 3 SSI ICs. However, as we
shall later see, it is possible to implement this function using a single multiplexer
IC without any additional components, which considerably reduces the circuit com-
plexity, power consumption and increases circuit reliability. Furthermore, for imple-
mentation using a multiplexer, the Boolean function does not need to be simplified
first.
Examples of MSI devices are decoders, encoders, multiplexers, demultiplexers, adders,
subtractors and magnitude comparators.
5.3 Decoders
N−bit M
input code DECODER output lines
A decoder
In general for a decoder, M ≤ 2N . For each combination of inputs, only one of the
output lines will be activated. The activated output can be HIGH (Logic 1) while
other outputs are LOW (Logic 0), or the activated output can be LOW while all other
outputs are HIGH. If the activated output of the decoder is HIGH while other outputs
are LOW, the decoder is said to have active-HIGH outputs, and if the activated output
is LOW with all other outputs HIGH, the decoder is said to have active-LOW outputs.
The logic symbols for decoders with active-HIGH outputs and active-LOW outputs
are shown in Figure 6.2.
Figure 6.3 shows an example of a decoder.
This decoder generates all the minterms for the input variables A (MSB), B and C
Page 85 of 110
112
Digital Electronics I Lecture Notes
active−HIGH active−LOW
outputs outputs
O0 = ĀB̄ C̄
O1 = ĀB̄C
O3 = ĀBC outputs
O4 = AB̄ C̄
O5 = AB̄C
O6 = AB C̄
O7 = ABC
(LSB). This decoder can thus be thought of as a minterm generator. This makes it
useful in the design of combinational logic circuits. The truth-table for this decoder
is given below.
Page 86 of 110
112
Digital Electronics I Lecture Notes
A B C O0 O1 O2 O3 O4 O5 O6 O7
0 0 0 1 0 0 0 0 0 0 0
0 0 1 0 1 0 0 0 0 0 0
0 1 0 0 0 1 0 0 0 0 0
0 1 1 0 0 0 1 0 0 0 0
1 0 0 0 0 0 0 1 0 0 0
1 0 1 0 0 0 0 0 1 0 0
1 1 0 0 0 0 0 0 0 1 0
1 1 1 0 0 0 0 0 0 0 1
The decoder shown in Figure 6.3 is referred to as
• binary to octal decoder (since the input is a 3-bit binary code and at any time,
only one of 8 outputs (octal) is activated), or
Some decoders have one or more ENABLE inputs that are used to control the oper-
ation of the decoder. If a decoder has ENABLE inputs, it will only function normally
if the ENABLE inputs are at the right logic levels. Most of the decoders which are
available in IC form have ENABLE inputs.
The ENABLE inputs are used for two reasons:
110
Page 87 of 112
Digital Electronics I Lecture Notes
inputs
A B C E0 E1 E2
O0
PSfrag replacements O1
O2
O3
O4
O5
O6
PSfrag replacements
O7
Figure 6.4: Circuit diagram for the 74138 3 line to 8 line decoder
The logic symbol for the 74138 decoder is shown in Figure 6.5. (A0 is the LSB while
A2 is the MSB.)
O0
A2
data A1
O1
inputs O2
74138
A0
O3 active−LOW
O4
outputs
E2
ENABLE O5
inputs E1
O6
E0
O7
Example
Design a 4-line to-16 decoder based on the 74138 decoder.
Solution
Page 88 of 112
110
Digital Electronics I Lecture Notes
PSfrag replacements
The 74138 decoder has 3 data inputs and 8 outputs. To build a 4-line-to-16-line
decoder, two 74138 decoders are needed. The 4-line-to-16-line decoder has 4 data
inputs A3 (MSB), A2 , A1 and A0 (LSB) but since the 74138 decoder has only 3 data
inputs A2 (MSB), A1 and A0 (LSB), the inputs A2 , A1 and A0 are connected directly
to the data inputs of the 74138 decoders while the data input A3 is connected to the
ENABLE inputs of the decoders in a suitable manner such that when A3 = 0, one of
the decoders is selected, and when A3 = 1, the other decoder is selected.
Figure 6.6 shows the 4-line-to-16 line decoder.
A3
A2
A1
A0
+5V
E 0 E 1 E2 A0 A1 A2 E 0 E 1 E2 A0 A1 A2
74138 74138
Exercise
You are provided with 2-line-to-4-line decoders of the form shown in Figure 6.7. (A0
isPSfrag
the LSB while A1 is the MSB.) Using as many of these decoders as you need and
replacements
no other components, design a 4-line-to-16-line decoder.
A1 O0
data
inputs
A0 O1 active−LOW
outputs
ENABLE O2
input E
O3
110
Page 89 of 112
Digital Electronics I Lecture Notes
The 7442 is a 4-line-to-10-line decoder (or a 1 of 10 decoder). This decoder does not
have an enable input. This decoder is shown in Figure 6.8.
O0
O1
O2
D O3
7442
BCD C O4
inputs B O5
A O6
O7
O8
O9
Selection of memory chips (ICs) when the input code is an address from the
central processing unit of a computer.
110
Page 90 of 112
Digital Electronics I Lecture Notes
Used as demultiplexers.
In general, a decoder provides 2N minterms for N input variables. Since any Boolean
function can be expressed as a sum of minterms, a decoder can be used to generate
the minterms and an external OR gate used to form the sum. (If the decoder has
active-LOW outputs, the outputs are connected using a NAND gate).
Example
Implement the Boolean function
X
S(X, Y, Z) = m(1, 2, 4, 7) (6.3)
X
C(X, Y, Z) = m(3, 5, 6, 7) (6.4)
b) a 74138 decoder.
O0
O1
A2 (MSB) O2
O3
A1
O4
A0 (LSB) O5
O6
O7
Figure 6.9:
Solution
a)
b) X
S(X, Y, Z) = m(1, 2, 4, 7) = m1 + m2 + m4 + m7
= m 1 + m 2 + m 4 + m 7 = m 1 · m2 · m4 · m7 .
Page 91 of 110
112
PSfrag replacements
Digital Electronics I Lecture Notes
O0
O1
X A2 (MSB) O2 S
O3
Y A1
O4
Z A0 (LSB) O5
O6 C
O7
PSfrag replacements
Figure 6.10:
Similarly,
C(X, Y, Z) = m3 · m5 · m6 · m7 .
The circuit implementation using a 74138 decoder is shown in Figure 6.11.
Note that the decoder is permanently enabled.
O0
X A2
O1
Y A1 S
O2
Z A0
O3
O4
+5V E2
O5
E1 C
O6
E0
O7
Figure 6.11:
Exercise
Design a 3-bit binary to Gray code converter using a 74138 decoder and a minimum
of logic gates.
In this case, a decoder is used to provide outputs to drive a display so that the binary
number is displayed as a decimal digit. When a decoder is combined with a high
current driving output, it is called a decoder/driver. The high current driving output
is required because LEDs used in many decimal displays require a high current which
an ordinary decoder cannot provide.
A commonly used display is the 7-segment display shown in Figure 6.12. The seg-
ments are either LEDs or Liquid Crystal Displays (LCDs). The 7-segment LED displays
are available in two configurations: the common-anode connection or the common
cathode connection. These configurations are illustrated in Figure 6.13.
Page 92 of 112
110
Digital Electronics I Lecture Notes
f b
g
PSfrag replacements
e c
a a
b b
c c
d d
e e
f f
g g
7447 a
b
D (MSB)
c
BCD C
d
input B
e
A (LSB)
f
g
Page 93 of 110
112
Digital Electronics I Lecture Notes
D C B A a b c d e f g
0 0 0 0 0 0 0 0 0 0 1
0 0 0 1 1 0 0 1 1 1 1
0 0 1 0 0 0 1 0 0 1 0
0 0 1 1 0 0 0 0 1 1 0
0 1 0 0 1 0 0 1 1 0 0
0 1 0 1 0 1 0 0 1 0 0
0 1 1 0 0 1 0 0 0 0 0
0 1 1 1 0 0 0 1 1 1 1
1 0 0 0 0 0 0 0 0 0 0
1 0 0 1 0 0 0 0 1 0 0
1 0 1 0 1 1 1 1 1 1 1
1 0 1 1 1 1 1 1 1 1 1
1 1 0 0 1 1 1 1 1 1 1
1 1 0 1 1 1 1 1 1 1 1
1 1 1 0 1 1 1 1 1 1 1
1 1 1 0 1 1 1 1 1 1 1
Note from the truth table above that if the input code is not a valid BCD code, none
of the decoder outputs is activated (all outputs are HIGH). Also note that for valid
BCD codes, more than one output is activated for each binary code, but nevertheless,
the 7447 is still referred to as a decoder.
PSfrag replacements
Figure 6.15 shows how a 7447 can be connected to a 7-segment display. Since this
decoder has active-LOW outputs, it is connected to a common-anode 7-segment dis-
play.
VCC
7447
a a
b b
D (MSB) c c
C
BCD d d
input B e e
A (LSB) f f
g g
6.4 Encoders
An encoder has a number of input lines, only one of which is activated at a given time,
and produces an N -bit output code, which depends on which input is activated.
An encoder is functionally the opposite of an encoder. As an example, a binary-to-
octal decoder accepts a 3-bit binary input code and activates only one of 8 output
lines. An octal to binary encoder operates in the opposite manner in that it has 8
Page 94 of 112
110
Digital Electronics I Lecture Notes
M N−bit
inputs ENCODER output code
input lines, only one of which is activated at a given time, and it produces a 3-bit
binary output code which depends on which input line is activated. An octal-to-
binary encoder is shown in Figure 6.17
A0
A1
A2 O2
8 input A3
3−bit
O1
lines A4 binary code
A5 O0
A6
A7
O2 = A 4 + A 5 + A 6 + A 7 ,
O1 = A 2 + A 3 + A 6 + A 7 ,
O0 = A 1 + A 3 + A 5 + A 7 .
The above equations can be implemented using the circuit shown in Figure 6.18.
From the truth-table above, we can see that not all the possible combinations of
the input variables are considered hence the circuit shown in Figure 6.18 will work
properly only if only one output is activated at a time. This problem is solved by use
of a priority encoder. A priority encoder works in such a way that if more than one
110
Page 95 of 112
Digital Electronics I Lecture Notes
A0 A1 A2 A3 A4 A5 A6 A7
PSfrag replacements O2
O1
O0
Figure 6.18:
input is activated, the output code will correspond to the highest numbered of the
activated inputs. (For more information on how to design priority encoders, see the
references
PSfragatreplacements
the end of this handout.) Examples of priority encoders are the 74148
8-line-to-3-line priority encoder (with active-HIGH outputs), and the 74147 decimal-
to-BCD priority encoder (with active-LOW outputs). The 74147 encoder is shown in
Figure 6.19.
A0
A1
A2
A3 O3
74147
A4 O2
A5 O1
A6 O0
A7
A8
A9
Page 96 of 112
110
Digital Electronics I Lecture Notes
Ā0 Ā1 Ā2 Ā3 Ā4 Ā5 Ā6 Ā7 Ā8 Ā9 0̄3 Ō2 Ō1 Ō0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 all outputs inactive
0 1 1 1 1 1 1 1 1 1 1 1 1 1 A0 activated
X 0 1 1 1 1 1 1 1 1 1 1 1 0
X X 0 1 1 1 1 1 1 1 1 1 0 1
X X X 0 1 1 1 1 1 1 1 1 0 0
X X X X 0 1 1 1 1 1 1 0 1 1
X X X X X 0 1 1 1 1 1 0 1 0
X X X X X X 0 1 1 1 1 0 0 1
X X X X X X X 0 1 1 1 0 0 0
X X X X X X X X 0 1 0 1 1 1
X X X X X X X X X 0 0 1 1 0
The 74147 is commonly used as a switch encoder. Consider the circuit shown in
Figure 6.20.
+5V
R
A9
SW9
+5V
R
A8
SW8
PSfrag replacements +5V
R
A7
SW7
+5V
R
SW6
A6
+5V
O0
R
74147
A5
SW5 O1
+5V BCD
R code
A4 O2
SW4
+5V
O3
R
SW3
A3
+5V
R
SW2
A2
+5V
R
SW1
A1
+5V
R
A0
SW0
Page 97 of 112
110
Digital Electronics I Lecture Notes
6.5 Multiplexers
Data output
inputs MUX
SELECT
inputs
I1
PSfrag replacements
z I0 2−line to z
1−line
I1 MUX
I0
S
S
z = I1 S + I0 S.
Page 98 of 110
112
Digital Electronics I Lecture Notes
It is clear from the truth-table that the input signals are routed to the output depend-
ing on the SELECT input S.
I0
PSfrag replacements
I1 I0
I1 4−line to z
z 1−line
I2 MUX
I2
I3
S0
S1
I3 S1 S0
S1 S0
z = I 0 S 1 S 0 + I 1 S 1 S0 + I 2 S1 S 0 + I 3 S1 S0 .
Figure 6.24 shows a 4-line to 1-line multiplexer with an ENABLE input. The truth-
table for this multiplexer is given below:
E S1 S0 z
0 X X 0
1 0 0 I0
1 0 1 I1
1 1 0 I2
1 1 1 I3
110
Page 99 of 112
Digital Electronics I Lecture Notes
PSfrag replacementsI0
I1 I0
I1 4−line to z
z 1−line
I2 MUX
S0I2 I3
S1
I3 S1 S0 E
S1 S0 E
I0 I1 I2 I3 I4 I5 I6 I7
S2 (MSB)
S1 74151
S0 (LSB)
E Z Z
E S2 S1 S0 Z Z
1 X X X 0 1
0 0 0 0 I0 I0
0 0 0 1 I1 I1
0 0 1 0 I2 I2
0 0 1 1 I3 I3
0 1 0 0 I4 I4
PSfrag replacements 0 1 0 1 I5 I5
0 1 1 0 I6 I6
0 1 1 1 I7 I7
Another example is the 74157 quad 2-input multiplexer IC (has four 2-input multi-
plexers). The circuit diagram for this multiplexer is shown in Figure 6.26.
IIa IOa IIb IOb IIc IOc IId IOd
PSfrag replacements
Za Zb Zc Zd
Figure 6.26: Circuit diagram for the 74157 Quad 2-input multiplexer
E S Za Zb Zc Zd
1 X 0 0 0 0
0 0 IOa IOb IOc IOd
0 1 IIa IIb IIc IId
The ENABLE input(s) in multiplexers make it possible to connect two or more multi-
plexer ICs to form a multiplexer with a large number of inputs.
Exercise
An application requires a 16-input, 1-output multiplexer but the only multiplexer IC
available is the 8-input 74151. Using two 74151 multiplexers and a minimum of
logic gates, show how the required multiplexer can be realized.
BCD to 7−segment
decoder−driver
7−segment display
SELECT Display
0 Contents of BCD counter 1 displayed
1 Contents of BCD counter 2 displayed
Parallel to serial conversion: Figure 6.29 shows how a multiplexer can be used to
convert data from parallel to serial form.
I0
I1
I2
PSfrag replacements
REGISTER serial
MUX output
IM
S0 S1 SN
data in
parallel form
COUNTER
The SELECT inputs are used as the logic variables and each data input is con-
nected permanently HIGH or LOW as necessary to satisfy the truth-table.
Example
Implement the Boolean function
X
f (C, B, A) = m(1, 2, 7) (6.5)
C B A f
0 0 0 0
0 0 1 1
PSfrag replacements 0 1 0 1
0 1 1 0
1 0 0 0
1 0 1 0
1 1 0 0
1 1 1 1
+5V
I0 I1 I2 I3 I4 I5 I6 I7
C S2
B S1 74151
A S0
E Z
Figure 6.30:
This type of design is carried out when the number of logic variables exceeds
the number of SELECT inputs by one. As an example, recall the Boolean func-
tion (6.1) given in Section 6.2, and reproduced here for convenience:
X
f (A, B, C, D) = m(4, 5, 7, 9, 11, 15). (6.6)
This function has 4 logic variables A, B, C and D, and to implement this func-
tion as described in the previous section, a multiplexer with 16 data inputs and
4 SELECT inputs is required. To implement this function using an 8-input mul-
tiplexer (which has 3 SELECT inputs), type 1 MUX design is applied. The least
significant input bit is partitioned off in the truth-table as shown below. A new
column is then created where the output is expressed as 0, 1, and the LSB.
+5V
D
I0 I1 I2 I3 I4 I5 I6 I7
A S2
B S1 74151
C S0
E Z
Figure 6.31:
Exercise
Implement the Boolean function
X
f (A, B, C, D) = m(4, 5, 6, 7, 10, 14)
6.6 Demultiplexers
O0
O1
PSfrag replacements O2
O3
O4
O5
O6
O7
the circuit of Figure 6.32 shows that the circuit is similar to that of a 3-line-to-8-line
decoder where the data inputs of the decoder are used the SELECT inputs and the
ENABLE input used as the data input. As such, it is possible to use a decoder as a
demultiplexer: the data inputs of the decoder are used as the SELECT inputs and the
ENABLE input serves as the data input.
In general:
If the decoder has active-HIGH outputs, one of the active-HIGH ENABLE in-
puts should be used as the data input.
If the decoder has active-LOW outputs, one of the active-LOW ENABLE inputs
should be used as the data input.
Exercise
Verify the validity of the above statements.
Exercise
Show how the 74138 decoder can be used as a demultiplexer.
Given two bits X and Y , the truth table below shows the arithmetic sum S and the
carry C resulting from the addition of the two bits.
X Y sum S carry C
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
From the truth-table above,
S = X̄Y + X Ȳ = X ⊕ Y
and
C = XY.
The Boolean function given in the truth-table above is implemented as shown in
Figure 6.33. This circuit provides the sum and carry for two bits but does not take
into consideration the carry from a lower significant bit position. Such a circuit is
known as a half-adder (HA).
110
Page 107 of 112
Digital Electronics I Lecture Notes
PSfrag replacements
X
Y S X S
HA
C Y C
The full adder takes in bits X and Y and a carry from the lower significant bit position
Cin , and gives the arithmetic sum S of the three bits, and a carry Cout to the next
higher bit position. The truth-table for a full adder (FA) is given below:
X Y Cin S Cout
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
S = X̄ Ȳ Cin + X̄Y C̄in + XY Cin + X Ȳ C̄in = X ⊕ Y ⊕ Cin
and
Cout = XY + Y Cin + XCin .
PSfrag replacements
Figure 6.34 shows the schematic diagram for a full adder.
X
S
Y FA
Cin Cout
Given two bits X and Y , the truth table below shows the arithmetic difference D and
the borrow B resulting from the subtraction of Y from X (X − Y ).
X Y difference D borrow B
0 0 0 0
0 1 1 1
1 0 1 0
1 1 0 0
From the truth-table above,
D = X̄Y + X Ȳ = X ⊕ Y
and
B = X̄Y.
PSfrag replacements
The function given in the truth-table above is implemented as shown in Figure 6.35.
X
Y D X D
HS
B Y B
This circuit provides the difference and borrow for two bits but does not take into
consideration the borrow from a lower significant bit position. Such a circuit is
known as a half subtractor (HS).
The full subtractor carries out the arithmetic operation (X − Y − Bin ), where Bin is
a borrow from a lower significant bit position, and gives the difference D and the
borrow Bout . The truth-table for a full subtractor (FS) is given below:
X Y Bin D Bout
0 0 0 0 0
0 0 1 1 1
0 1 0 1 1
0 1 1 0 1
1 0 0 1 0
1 0 1 0 0
1 1 0 0 0
1 1 1 1 1
D = X̄ Ȳ Bin + X̄Y B̄in + XY Bin + X Ȳ B̄in = X ⊕ Y ⊕ Bin
and
Bout = X̄Y + X̄Bin + Y Bin .
Figure 6.36 shows the schematic diagram for a full subtractor.
PSfrag replacements
X
D
Y FS
Bin Bout