DIGITAL ELECTRONICS Lecture Notes 1 - 071216
DIGITAL ELECTRONICS Lecture Notes 1 - 071216
Prepared by
Objectives: The main objective of this course is to obtain a basic level of Digital Electronics knowledge and
set the stage to perform the analysis and design of complex digital electronic circuits. The most significant
evolution of digital electronics in recent years has been on the degree of complexity of the systems that are
carried with it, from simple components to complete systems performing
Content: Number systems and Codes, Combinational logic, and Sequential logic
GENERAL INTRODUCTION
Digital electronics is essential to understanding the design and working of a wide range of applications,
from consumer and industrial electronics to communications; from embedded systems, and computers to
security and military equipment. As the devices used in these applications decrease in size and employ
more complex technology, it is essential for engineers and students to fully understand both the
fundamentals of Digital Electronics.
CHAPTER ONE: NUMBER SYSTEMS
Binary number system is based on two-level logic, conventionally noted as 0 (low level) and 1 (high
level). It is a system with a radix of two. The binary number system is a radix-2 number system with
‘0’ and ‘1’ as the two independent digits. All larger binary numbers are represented in terms of ‘0’ and
‘1’. The procedure for writing higher order binary numbers after ‘1’ is similar to the one explained in
the case of the decimal number system. For example, the first 16 numbers in the binary number system
would be 0, 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010, 1011, 1100, 1101, 1110 and 1111. The
next number after 1111 is 10000, which is the lowest binary number with five digits.
A bit is an abbreviation of the term ‘binary digit’ and is the smallest unit of information. It is either ‘0’
or ‘1’. A byte is a string of eight bits. The byte is the basic unit of data operated upon as a single unit
in computers. A computer word is again a string of bits whose size, called the ‘word length’ or ‘word
size’, is fixed for a specified computer, although it may vary from computer to computer. The word
length may equal one byte, two bytes, and four bytes or be even larger.
The 1’s complement of a binary number is obtained by complementing all its bits, i.e. by replacing 0s
with 1s and 1s with 0s. For example, the 1’s complement of (10010110) 2 is (01101001)2. The 2’s
complement of a binary number is obtained by adding ‘1’ to its 1’s complement. The 2’s complement
of (10010110)2 is (01101010)2
3
the binary and decimal number systems described above. The independent digits are 0, 1, 2, 3, 4, 5, 6
and 7. The next 10 numbers that follow ‘7’, for example, would be 10, 11, 12, 13, 14, 15, 16, 17, 20
and 21. In fact, if we omit all the numbers containing the digits 8 or 9, or both, from the decimal number
system, we end up with an octal number system. The place values for the different digits in the octal
number system are 80, 81, 82 and so on (for the integer part) and 8-1, 8-2, 8-3 and so on (for the fractional
part).
4
1.7 Hexadecimal-to-Decimal Conversion
The decimal equivalent of the hexadecimal number (1E0.2A)16 is determined as follows:
The integer part = 1E0
The decimal equivalent = 0 × 160 + 14 × 161 + 1 × 162 = 0 + 224 + 256 = 480
The fractional part = 2A
The decimal equivalent = 2 × 16-1 + 10 × 16-2 = 0.164
5
The binary equivalent of (0.375)10 = (.011)2
Therefore, the binary equivalent of (13.375)10 = (1101.011)2
Solution
The process of decimal-to-hexadecimal conversion is also similar. Since the hexadecimal number
system has a base of 16, the progressive division and multiplication factor in this case is 16. The process
is illustrated further with the help of an example.
6
Divisor Dividend Remainder
16 82 —
16 5 2—
0 5
The hexadecimal equivalent of (82)10 = (52)16
An octal number can be converted into its binary equivalent by replacing each octal digit with its three-
bit binary equivalent. We take the three-bit equivalent because the base of the octal number system is
8 and it is the third power of the base of the binary number system, i.e. 2. All we have then to remember
is the three-bit binary equivalents of the basic digits of the octal number system. A binary number can
be converted into an equivalent octal number by splitting the integer and fractional parts into groups
of three bits, starting from the binary point on both sides. The 0s can be added to complete the outside
groups if needed.
Example
Let us find the binary equivalent of (374.26)8 and the octal equivalent of (1110100.0100111)2 Solution
The given octal number = (374.26)8
Any 0s on the extreme left of the integer part and extreme right of the fractional part of the equivalent
binary number should be omitted. Therefore, (011111100.010110) 2 = (11111100.01011)2
(1110100.0100111)2 =(1 110 100.010 011 1)2 = (001 110 100.010 011 100)2 = (164.234)8 Hex–Binary
and Binary–Hex Conversions
A hexadecimal number can be converted into its binary equivalent by replacing each hex digit with its
four-bit binary equivalent. We take the four-bit equivalent because the base of the hexadecimal number
system is 16 and it is the fourth power of the base of the binary number system. All we have then to
remember is the four-bit binary equivalents of the basic digits of the hexadecimal number system. A
7
given binary number can be converted into an equivalent hexadecimal number by splitting the integer
and fractional parts into groups of four bits, starting from the binary point on both sides. The 0s can be
added to complete the outside groups if needed.
Example
Let us find the binary equivalent of (17E.F6)16 and the hex equivalent of (1011001110.011011101)2
Solution
= (101111110.1111011)2
The 0s on the extreme left of the integer part and on the extreme right of the fractional part have been
omitted.
The given binary number= (1011001110.011011101)2 = (10 1100 1110.0110 1110 1)2
For hexadecimal–octal conversion, the given hex number is firstly converted into its binary equivalent
which is further converted into its octal equivalent. An alternative approach is firstly to convert the
given hexadecimal number into its decimal equivalent and then convert the decimal number into an
equivalent octal number. The former method is definitely more convenient and straightforward. For
octal–hexadecimal conversion, the octal number may first be converted into an equivalent binary
number and then the binary number transformed into its hex equivalent. The other option is firstly to
convert the given octal number into its decimal equivalent and then convert the decimal number into
its hex equivalent. The former approach is definitely the preferred one. Two types of conversion are
illustrated in the following example.
Let us find the octal equivalent of (2F.C4)16 and the hex equivalent of (762.013)8
Solution
8
The given octal number = (762.013)8
The octal number = (762.013)8 = (111 110 010.000 001 011)2 = (111110010.000001011)2 = (0001
1111 0010.0000 0101 1000)2 = (1F2.058)16
The binary coded decimal (BCD) is a type of binary code used to represent a given decimal number in
an equivalent binary form. BCD-to-decimal and decimal-to-BCD conversions are very easy and
straightforward. It is also far less cumbersome an exercise to represent a given decimal number in an
equivalent BCD code than to represent it in the equivalent straight binary form discussed in the previous
section.
The BCD equivalent of a decimal number is written by replacing each decimal digit in the integer and
fractional parts with its four-bit binary equivalent. As an example, the BCD equivalent of (23.15)10
is written as (0010 0011.0001 0101) BCD. The BCD code described above is more precisely known as
the 8421 BCD code, with 8, 4, 2 and 1 representing the weights of different bits in the four-bit groups,
starting from MSB and proceeding towards LSB. This feature makes it a weighted code, which means
that each bit in the four-bit group representing a given decimal digit has an assigned
9
weight. Other weighted BCD codes include the 4221 BCD and 5421 BCD codes. Again, 4, 2, 2 and 1
in the 4221 BCD code and 5, 4, 2 and 1 in the 5421 BCD code represent weights of the relevant bits.
The table above shows a comparison of 8421, 4221 and 5421 BCD codes. As an example, (98.16)10
will be written as 1111 1110.0001 1100 in 4221 BCD code and 1100 1011.0001 1001 in 5421 BCD
code. Since the 8421 code is the most popular of all the BCD codes, it is simply referred to as the BCD
code.
The binary equivalent of 29.75 can be determined to be 11101 for the integer part and .11 for the
fractional part.
The process of binary-to-BCD conversion is the same as the process of BCD-to-binary conversion
executed in reverse order. A given binary number can be converted into an equivalent BCD number by
first determining its decimal equivalent and then writing the corresponding BCD equivalent. As an
example, we will find the BCD equivalent of the binary number 10101011.101:
10
The BCD equivalent can then be written as 0001 0111 0001.0110 0010 0101.
The excess-3 code is another important BCD code. It is particularly significant for arithmetic operations
as it overcomes the shortcomings encountered while using the 8421 BCD code to add two decimal
digits whose sum exceeds 9. The excess-3 code has no such limitation, and it considerably simplifies
arithmetic operations. The table below lists the excess-3 code for the decimal numbers 0–9. The excess-
3 code for a given decimal number is determined by adding
‘3’ to each decimal digit in the given number and then replacing each digit of the newly found decimal
number by its four-bit binary equivalent. It may be mentioned here that, if the addition of ‘3’ to a digit
produces a carry, as is the case with the digits 7, 8 and 9, that carry should not be taken forward. The
result of addition should be taken as a single entity and subsequently replaced with its excess-3 code
equivalent. As an example, let us find the excess-3 code for the decimal number 597:
The addition of ‘3’ to each digit yields the three new digits/numbers ‘8’, ‘12’ and ‘10’.
The corresponding four-bit binary equivalents are 1000, 1100 and 1010 respectively.
The excess-3 code for 597 is therefore given by: 1000 1100 1010=100011001010.
Also, it is normal practice to represent a given decimal digit or number using the maximum number of
digits that the digital system is capable of handling. For example, in four-digit decimal arithmetic, 5
and 37 would be written as 0005 and 0037 respectively. The corresponding 8421 BCD equivalents
would be 0000000000000101 and 0000000000110111 and the excess-3 code equivalents would be
0011001100111000 and 0011001101101010.
Corresponding to a given excess-3 code, the equivalent decimal number can be determined by first
splitting the number into four-bit groups, starting from the radix point, and then subtracting 0011 from
each four-bit group. The new number is the 8421 BCD equivalent of the given excess-3 code, which
can subsequently be converted into the equivalent decimal number. As an example, following these
steps, the decimal equivalent of excess-3 number 01010110.10001010 would be 23.57.
11
Another significant feature that makes this code attractive for performing arithmetic operations is that
the complement of the excess-3 code of a given decimal number yields the excess-3 code for 9’s
complement of the decimal number. As adding 9’s complement of a decimal number B to a decimal
number A achieves A – B, the excess-3 code can be used effectively for both addition and subtraction
of decimal numbers. As an example:
Find (a) the excess-3 equivalent of (237.75)10 and (b) the decimal equivalent of the excess-3 number
110010100011.01110101
Solution
(a) Integer part =237. The excess-3 code for (237)10 is obtained by replacing 2, 3 and 7 with the four-
bit binary equivalents of 5, 6 and 10 respectively. This gives the excess-3 code for (237)10 as: 0101
0110 1010 = 010101101010.
Fractional part = .75. The excess-3 code for (.75)10 is obtained by replacing 7 and 5 with the four-bit
binary equivalents of 10 and 8 respectively. That is, the excess-3 code for (.75)10 = .10101000.
Combining the results of the integral and fractional parts, the excess-3 code for (237.75)10 =
010101101010.10101000.
Subtracting 0011 from each four-bit group, we obtain the new number as: 1001 0111
0000.01000010. Therefore, the decimal equivalent = (970.42)10
The Gray code was designed by Frank Gray at Bell Labs and patented in 1953. It is an unweighted
binary code in which two successive values differ only by 1 bit. Owing to this feature, the maximum
error that can creep into a system using the binary Gray code to encode data is much less than the worst-
case error encountered in the case of straight binary encoding. The table below lists the binary and Gray
code equivalents of decimal numbers 0–15. An examination of the four-bit Gray code numbers, as listed
in Table, shows that the last entry rolls over to the first entry. That is, the last and the first entry also
differ by only 1 bit. This is known as the cyclic property of the Gray code. Although there can be more
than one Gray code for a given word length, the term was first applied to a specific binary code for non-
negative integers and called the binary-reflected Gray code or simply the Gray code.
There are various ways by which Gray codes with a given number of bits can be remembered. One such
way is to remember that the least significant bit follows a repetitive pattern of ‘2’ (11, 00, 11,….), the
next higher adjacent bit follows a pattern of ‘4’ (1111, 0000, 1111,…..) and so on. We can also generate
12
the n-bit Gray code recursively by prefixing a ‘0’ to the Gray code for n−1 bits to obtain the first 2n−1
numbers, and then prefixing ‘1’ to the reflected Gray code for n−1 bits to obtain the remaining 2 n−1
numbers. The reflected Gray code is nothing but the code written in reverse order. The process of
generation of higher-bit Gray codes using the reflect and-prefix method is illustrated in the table below.
The columns of bits between those representing the Gray codes give the intermediate step of writing
the code followed by the same written in reverse order.
A given binary number can be converted into its Gray code equivalent by going through the following
steps:
1. Begin with the most significant bit (MSB) of the binary number. The MSB of the Gray code
equivalent is the same as the MSB of the given binary number.
2. The second most significant bit, adjacent to the MSB, in the Gray code number is obtained by
adding the MSB and the second MSB of the binary number and ignoring the carry, if any. That is, if
the MSB and the bit adjacent to it are both ‘1’, then the corresponding Gray code bit would be a ‘0’.
3. The third most significant bit, adjacent to the second MSB, in the Gray code number is obtained
by adding the second MSB and the third MSB in the binary number and ignoring the carry, if any.
4. The process continues until we obtain the LSB of the Gray code number by the addition of the
LSB and the next higher adjacent bit of the binary number.
13
The conversion process is further illustrated with the help of an example showing step-by-step
conversion of (11001)2 into its Gray code equivalent:
A given Gray code number can be converted into its binary equivalent by going through the following
steps:
1. Begin with the most significant bit (MSB). The MSB of the binary number is the same as the MSB
of the Gray code number.
2. The bit next to the MSB (the second MSB) in the binary number is obtained by adding the MSB in
the binary number to the second MSB in the Gray code number and disregarding the carry, if any.
3. The third MSB in the binary number is obtained by adding the second MSB in the binary number to
the third MSB in the Gray code number. Again, carry, if any, is to be ignored.
4. The process continues until we obtain the LSB of the binary number.
The conversion process is further illustrated with the help of an example showing step-by-step
conversion of the Gray code number (10111)gray into its binary equivalent:
14
So the equivalent binary code is 11010
The ASCII (American Standard Code for Information Interchange), pronounced ‘ask-ee’, is strictly a
seven-bit code based on the English alphabet. ASCII codes are used to represent alphanumeric data in
computers, communications equipment and other related devices. The code was first published as a
standard in 1967. It was subsequently updated and published as ANSI X3.4-1968, then as ANSI X3.4-
1977 and finally as ANSI X3.4-1986. Since it is a seven bit code, it can at the most represent 128
characters. It currently defines 95 printable characters including 26 upper-case letters (A to Z), 26
lower-case letters (a to z), 10 numerals (0 to 9) and 33 special characters including mathematical
symbols, punctuation marks and space character. In addition, it defines codes for 33 non printing,
mostly obsolete control characters that affect how text is processed. With the exception of ‘carriage
return’ and/or ‘line feed’, all other characters have been rendered obsolete by modern mark-up
languages and communication protocols, the shift from text-based devices to graphical devices and the
elimination of teleprinters, punch cards and paper tapes. An eight-bit version of the ASCII code, known
as US ASCII-8 or ASCII-8, has also been developed. The eight-bit version can represent a maximum
of 256 characters. Table 3.6 lists the ASCII codes for all 128 characters. When the ASCII code was
introduced, many computers dealt with eight-bit groups (or bytes) as the smallest unit of information.
The eighth bit was commonly used as a parity bit for error detection on communication lines and other
device-specific functions. Machines that did not use the parity bit typically set the eighth bit to ‘0’.
15
Table 3.6 continues
16
17
Looking at the structural features of the code as reflected in Table 3.6, we can see that the digits 0 to 9
are represented with their binary values prefixed with 0011. That is, numerals 0 to 9 are represented by
binary sequences from 0011 0000 to 0011 1001 respectively. Also, lower-case and upper-case letters
differ in bit pattern by a single bit. While upper-case letters ‘A’ to ‘O’ are represented by 0100 0001 to
0100 1111, lower-case letters ‘a’ to ‘o’ are represented by 0110 0001 to 0110 1111. Similarly, while
upper-case letters ‘P’ to ‘Z’ are represented by 0101 0000 to 0101 1010, lower-case letters ‘p’ to ‘z’
are represented by 0111 0000 to 0111 1010.
With widespread use of computer technology, many variants of the ASCII code have evolved over the
years to facilitate the expression of non-English languages that use a Roman-based alphabet. In some
of these variants, all ASCII printable characters are identical to their sevenbit ASCII code
representations. For example, the eight-bit standard ISO/IEC 8859 was developed as a true extension
of ASCII, leaving the original character mapping intact in the process of inclusion of additional values.
This made possible representation of a broader range of languages. In spite of the standard suffering
from incompatibilities and limitations, ISO8859-1, its variant Windows-1252 and the original seven-
bit ASCII continue to be the most common character encodings in use today.
18