You are on page 1of 18

EE202 DIGITAL ELECTRONICS CHAPTER 1

! !"#$%&' )&*&'#+ ,-%!,.&/0



upon Lhe compleLlon of Lhls chapLer, sLudenLs should be able Lo:

" 1234 567 839934:2; 2<=>7? @A@57=@0 B7C:=D9E >:2D?AE 3C5D9 D2B
67FDB7C:=D9 D2B C32G7?5 567 2<=>7?@ 8?3= 327 @A@57= 53 D23567?

" -2B7?@5D2B 3C5D9 2<=>7? @A@57=

" -2B7?@5D2B 67FDB7C:=D9 2<=>7? @A@57=

" -2B7?@5D2B 634 >:2D?A C3B7@ D?7 <@7B :2 C3=H<57?@ ?7H?7@725:2;
B7C:=D9 B:;:5@E D9H6D2<=7?:C C6D?DC57?@ D2B @A=>39@




! I*%',J-!%I,*


The field of digital electronics is currently developing rapidly. The development has
resulted in the invention of electronic devices that are small in size but are to perform
more complex and sophisticated function. Some examples of such electronic devices
are computers, calculators, digital cameras, mobile phones and DVD players. The
readouts on most measuring instruments such as thermometers, blood pressure
sensors, weighing machines and watches are now in digital. They provide more
accurate and quick reading.

The progress in digital technology has also made life easier. For example, we no
longer have to queue in places such as in banks and bill payment centres. Instead, we
now need only to take a number and wait to be called. New information may also be
displayed on electronic display boards such as those at the airports and LRT stations.
This information may be easily changed as required. Digital electronics systems are
also widely used in hospitals and maritime industries.
















"
EE202 DIGITAL ELECTRONICS CHAPTER 1



1.1 nuM8L8 S?S1LMS


The binary number system is the most important one in digital systems but several
others are also important. The decimal system is important because it is universally
used to represent quantities outside a digital system. This means that there will be
situations where decimal values must be converted to binary values before they are
entered into the digital system. For example, when you punch a decimal number into
your hand calculator (or computer), the circuitry inside the machine converts the
decimal number to a binary value.

Likewise, there will be situations where the binary values at the outputs of a digital
system must be converted to decimal values for presentation to the outside world. For
example, your calculator (or computer) uses binary numbers to calculate answers to a
problem and then converts the answers to a decimal value before displaying them.

In addition to binary and decimal, two other number systems find widespread
applications in digital systems. The octal (base-8) and hexadecimal (base-16) number
systems are both used for the same purpose to provide an efficient means for
representing large binary numbers.

In a digital system, three or four of these number systems may be in use at the same
time, so that an understanding of the system operation requires the ability to convert
from one number system to another. This chapter will show you how to perform these
conversions. This chapter also introduces some of the binary codes that are used to
represent various kinds of information. These binary codes will use 1s and 0s, but in a
way that differs somewhat from that of the binary number system.




1.1.1 uLClMAL nuM8L8 S?S1LM (n
10
)


The numbering system that we are familiar where ten digits are used to represent the
numbers 0,1,2,3,4,5,6,7,8 and 9. Historically, this may be so because man has 10
fingers and therefore simple calculations, adding and subtracting were made by
counting with our own fingers.








EE202 DIGITAL ELECTRONICS CHAPTER 1



1.1.2 8lnA8? nuM8L8 S?S1LM (n
2
)


Decimal system is not suitable in digital electronic circuits because the circuits can
only accept two voltage states. The more appropriate numbering system for digital
electronic circuits is the binary number system. In the binary number system, only
two digits are used, 0 and 1. This system is knows as the base two number system
(N
2
).




1.1.3 CC1AL nuM8L8 S?S1LM (n
8
)


The octal number system is often used in digital computer work. The octal number
system has a base of eight, meaning that it has eight possible digits: 0, 1, 2, 3, 4, 5, 6
and 7. Thus, each digit of an octal number can have any value from 0 to 7. The digit
positions in an octal number have weights as follows:


8
3
8
2
8
1
8
0
8
-1
8
-2
8
-3

Octal point



1.1.4 PLxAuLClMAL nuM8L8 S?S1LM (n
16
)


The hexadecimal number system uses base 16. Thus, it has 16 possible digit symbols.
It uses the digits 0 through 9 plus letters A, B, C, D, E and F as the 16 digits symbols.
Table 1.1.4.1 shows the relationship among hexadecimal, decimal and binary digits.
It is important to remember that hexadecimal digits A through F are equivalent to the
decimal values 10 through 15.


HEXADECIMAL DECIMAL BINARY
0 0 0000
1 1 0001
2 2 0010
3 3 0011
4 4 0100
5 5 0101
6 6 0110
7 7 0111


EE202 DIGITAL ELECTRONICS CHAPTER 1



HEXADECIMAL DECIMAL BINARY
8 8 1000
9 9 1001
A 10 1010
B 11 1011
C 12 1100
D 13 1101
E 14 1110
F 15 1111
Table 1.1.4.1 Hexadecimal, Decimal & Binary





1.2 nuM8L8 S?S1LMS CCnvL8SlCnS

This sub chapter will show you on how to convert Decimal-to-Binary, Binary-to-
Decimal, Decimal-to-Octal, Octal-to-Decimal, Binary-to-Octal, Octal-to-Binary,
Decimal-to-Hexadecimal, Hexadecimal-to-Decimal, Binary-to-Hexadecimal and
Hexadecimal-to-Binary.





1.2.1 uLClMAL 1C 8lnA8? CCnvL8SlCn

There are two ways to convert a decimal whole number to its equivalent binary system
representation. The first method is illustrated as below:

45
10
= 32 + 8 + 4 + 1 = 2
5
+ 0 + 2
3
+ 2
2
+ 0 + 2
0



= 1 0 1 1 0 1
2


Note that a 0 is placed in the 2
1
and 2
4
positions since all positions must be accounted
for. Another example is the following:

76
10
= 64 + 8 + 4 = 2
6
+ 0 + 0 +2
3
+ 2
2
+ 0 + 0


= 1 0 0 1 1 0 0
2


Another method for converting decimal integers uses repeated division by 2. The
conversion, illustrated below for 25
10
, requires repeatedly dividing the decimal

EE202 DIGITAL ELECTRONICS
CHAPTER 1



number 2 and writing down the remainder after each division until a quotient
of 0 is obtained. Note that the binary result is obtained by writing the first
remainder as the
LSB and the last remainder as the MSB. This process, diagrammed in Table
1.2.1.1.


PROCESS QUOTIENT REMAINDER
25 / 2 = 12 1
12 / 2 = 6 0
6 / 2 = 3 0
3 / 2 = 1 1
1 / 2 = 0 1
Table 1.2.1.1 An example process for repeated division for decimal-
to-binary

conversion


25
10
=11001
2


Using N bits, we can represent decimal numbers ranging from 0 to 2
N
1, a
total of 2
N


different numbers.



Please try me!

Convert all these decimal numbers to binary:

" 0.6875

" 237.3125





1.2.2 8lnA8? 1C uLClMAL CCnvL8SlCn

Any binary number can be converted to its decimal equivalent simply by
summing together the weights of the various positions in the binary number
that contain a 1. To illustrate, lets change 11011
2
to its decimal equivalent.

1 1 0 1 1
2


2
4
+ 2
3
+ 0 + 2
1
+ 2
0
= 16 + 8 + 2 + 1


= 27
10



Lets try another example with a greater number of bits:
EE202 DIGITAL ELECTRONICS CHAPTER 1



1 0 1 1 0 1 0 1
2


2
7
+ 0 + 2
5
+ 2
4
+ 0 + 2
2
+ 0 + 2
0
= 181
10


Note that the procedure is to find the weights (i.e. powers of 2) for each bit position
that contains a 1, and then to add them up. Also note that the MSB has a weight of 2
7
even though it is the eighth bit; this is because the LSB is the first bit and has a weight
of 2
0
.


Please try me!

Convert all these binary numbers to decimal:

" 01011001.1101

" 11001011.1100



1.2.3 uLClMAL 1C CC1AL CCnvL8SlCn


A decimal integer can be converted to octal by using the same repeated-division
method that we used in the decimal-to-binary conversion but with a division factor of
8 instead of 2. An example follows in Table 1.2.3.1


PROCESS QUOTIENT REMAINDER
266 / 8 = 33 2
33 / 8 = 4 1
4 / 8 = 0 4
Table 1.2.3.1 An example of repeated division process for decimal-to-octal conversion


266
10
= 412
8


Note that the first remainder becomes the least significant digit (LSD) of the octal
number, and the last remainder becomes the most significant digit (MSD).


Please try me!

Convert all these decimal numbers to octal:

" 1372.1406

" 1000.3242


EE202 DIGITAL ELECTRONICS CHAPTER 1



1.2.4 CC1AL 1C uLClMAL CCnvL8SlCn


An octal number can be converted easily to its decimal equivalent by multiplying each
octal digit by its positional weight. For example:

372
8
= 3 x (8
2
) + 7 x (8
1
) + 2 x (8
0
)


= 3 x 64 + 7 x 8 + 2 x 1


= 250
10


24.6
8
= 2 x (8
1
) + 4 x (8
0
) + 6 x (8
-1
)


= 20.75
10



Please try me!

Convert all these octal numbers to decimal:

" 1251.4

" 1032.2




1.2.3 8lnA8? 1C CC1AL CCnvL8SlCn


The bits of the binary number are grouped into groups of three bits, starting at the
LSB. Then each group is converted to its octal equivalent. To illustrate, consider the
conversion of 100111010
2
to octal.

100 111 010





4 7 2
8



Sometimes the binary number will not have even groups of three bits. For those cases,
we can add one or two 0s to the left of the MSB of the binary number to fill out the
last group. This illustrated below for the binary number 11010110.

011 010 110





3 2 6
8

EE202 DIGITAL ELECTRONICS CHAPTER 1



Note that a 0 was placed to the left of the MSB to produce even groups of three bits.

Using N bits, we can represent decimal numbers ranging from 0 to 8
N
1, a total of 8
N


different numbers.


Please try me!

Convert all these binary numbers to octal:

" 110010111100

" 011010011001



1.2.6 CC1AL 1C 8lnA8? CCnvL8SlCn


Converting each octal digit to its three bit binary equivalent performs the conversion
from octal to binary. The eight possible digits are converted as indicated in Table
1.2.6.1.


OCTAL DIGIT 0 1 2 3 4 5 6 7

BINARY EQUIVALENT

000

001

010

011

100

101

110

111
Table 1.2.6.1 Octal digits and its binary equivalent





Using these conversions, we can convert any octal number to binary by individually
converting each digit. For example, we can convert 472
8
to binary as follows:

4 7 2





100 111 010

Thus, octal 472 is equivalent to binary 100111010
2
. As another example, consider
converting 5431
8
to binary:

EE202 DIGITAL ELECTRONICS CHAPTER 1



5 4 3 1





101 100 011 001


Thus 5431
8
= 101100011001
2



Please try me!

Convert all these octal numbers to binary:

" 140

" 7526




1.2.7 uLClMAL 1C PLxAuLClMAL CCnvL8SlCn

Recall that we did decimal-to-binary conversion using repeated division by 2, and
decimal-to-octal conversion using repeated division by 8. Likewise, using repeated
division by 16 can do decimal-to-hex conversion. The following example contains
two illustrations of this conversion.

(a) Convert 423
10
to hex


Solution:


PROCESS QUOTIENT REMAINDER
423 / 16 = 26 7
26 / 16 = 1 10
1 / 16 = 0 1
423
10
= 1A7
16






(b) Convert 214
10
to hex


Solution:


PROCESS QUOTIENT REMAINDER
214 / 16 = 13 6
EE202 DIGITAL ELECTRONICS CHAPTER 1



PROCESS QUOTIENT REMAINDER
13 / 16 = 0 13
214
10
= D6
16


Note that the remainders division processes from the digits of the hex number. Also
note that any remainders that are greater than 9 are represented by the letters A
through F.


Please try me!

Convert all these decimal numbers to hexadecimal:

" 46579

" 1000




1.2.8 PLxAuLClMAL 1C uLClMAL CCnvL8SlCn


A hex number can be converted to its decimal equivalent by using the fact that each
hex digit position has a weight that is a power of 16. The LSD has a weight of 16
0
=
1; the next higher digit position has a weight of 16
1
= 16 and so on. The conversion

process is demonstrated in the examples below:

356
16
= 3 x 16
2
+ 5 x 16
1
+ 6 x 16
0



= 768 + 80 + 6


= 854
10


2AF
16
= 2 x 16
2
+ 10 x 16
1
+ 15 x 16
0



= 512 + 160 + 15


= 687
10



Note that in the second example, the value 10 was substituted for A and the value for

15 for F in the conversion to decimal.


Please try me!

Convert all these hexadecimal numbers to decimal:

" 1C

" A85
EE202 DIGITAL ELECTRONICS CHAPTER 1



1.2.9 8lnA8? 1C PLxAuLClMAL CCnvL8SlCn

The binary number is grouped into four groups of four bits, and each group is
converted to its equivalent hex digit. Zeros (shown shaded) are added, as needed to
complete a four-bit group.


1110100110
2
= 0011 1010 0110





3 A 6


= 3 A 6
16


Using N bits, we can represent decimal numbers ranging from 0 to 16
N
1, a total of
16
N
different numbers.


Please try me!

Convert all these binary numbers to hexadecimal:

" 1100101001010111

" 111111000101101001




1.2.10 PLxAuLClMAL 1C 8lnA8? CCnvL8SlCn

Each hex digit is converted to its four-bit binary equivalent (Table 1.1.4.1). The
conversion process is illustrated as below:

9F2
16
= 9 F 2





= 1001 1111 0010


= 100111110010
2



Please try me!

Convert all these hexadecimal numbers to binary:

" 10A4

" CF8E
EE202 DIGITAL ELECTRONICS CHAPTER 1



1.3 SuMMA8? Cl CCnvL8SlCnS


i. When converting from binary [or octal or hex] to decimal, use the method of
taking the weighted sum of each digit position.

ii. When converting from decimal to binary [or octal or hex], use the method of
repeatedly dividing by 2 [or 8 or 16] and collecting remainders.

iii. When converting from binary to octal [or hex], group the bits in groups of three

[or four], and convert each group into the correct octal [or hex] digit.


iv. When converting from octal [or hex] to binary, convert each digit into its three-bit

[or four-bit] equivalent.

v. When converting from octal to hex [or vice versa], first convert to binary; then
convert the binary into the desired number system.





1.4 PLxAuLClMAL A8l1PML1lC

Hex numbers are used extensively in machine-language computer programming and in
conjunction with computer memories (i.e., addresses). When working in these areas,
you will encounter situations where hex numbers must be added or subtracted.





1.4.1 PLx Auul1lCn


The following procedure is suggested:


i. Add the two hex digits in decimal, mentally inserting the decimal equivalent
for those digits larger than 9.

ii. If the sum is 15 or less, it can be directly expressed as a hex digit.

iii. If the sum is greater than or equal to 16, subtract 16 and carry a 1 to the next
digit position.


EE202 DIGITAL ELECTRONICS CHAPTER 1

1


Add the hex numbers 58 and 24.
Solution:
58

+ 24

7C



Example 2
Add the hex numbers 58 and 4B.
Solution:
58

+4B
A3


Example 3

Add 3AF to 23C.
Solution:
3AF

+23C

5EB




1.4.2 PLx Su818AC1lCn

The 2s complement of the hex subtrahend will be taken and then added to the minuend
and carry out of the MSD position will be disregarded.

How do we find the 2s complement of a hex number? One way is to convert it to
binary, take the 2s complement of the binary equivalent and then convert it back to
hex. This process is illustrated below.

* Subtrahend - Number that is to be subtracted from a minuend.


* Minuend Number from which the subtrahend is to be subtracted.



73A

# Hex number
0111 0011 1010 # Convert to binary
1000 1100 0110 # Take 2s complement

8C6
# Convert back to hex



There is a quicker procedure: subtract each hex digit from F; then add 1. Lets try this

for the same hex number from the example above.






EE202 DIGITAL ELECTRONICS CHAPTER 1

F F F

- 7 - 3 - A # Subtract each digit from F
8 C 5

+ 1 # Add 1


8


C


6


# Hex equivalent of 2s

complement



Example 1
Subtract 3A5
16
from 592
16
.
Solution:

592

+ C5B

1ED




1.3 8Cu CCuL (8lnA8? CCuLu uLClMAL CCuL)

If each digit of a decimal number is represented by its binary equivalent, the result is a
code called binary-coded-decimal (hereafter abbreviated BCD). Since a decimal digit
can be as large as 9, four bits are required to code each digit (the binary code for 9 is
1001).


To illustrate the BCD code, take a decimal number such as 874. Each digit is changed to
its binary equivalent as follows:

8 7 4 (decimal)





1000 0111 0100 (BCD)


As another example, let us change 943 to its BCD-code- representation:


9 4 3 (decimal)





1001 0100 0011 (BCD)

Once again, each decimal digit is changed to its straight binary equivalent. Note that four
bits are always used for each digit.
EE202 DIGITAL ELECTRONICS CHAPTER 1

The BCD code then represents each digit of the decimal number by a four-bit binary
number. Clearly only the four-bit binary numbers from 0000 through 1001 are used. The
BCD code does not use the numbers 1010, 1011, 1100, 1101, 1110 and 1111. In other
words, only 10 of the 16 possible four-bit binary code groups are used. If any of the
forbidden four-bit numbers ever occurs in a machine using the BCD code, it is usually

an indication that an error has occurred.





1.3.1 CCMA8lSCn Cl 8Cu Anu 8lnA8?

It is important to realize that BCD is not another number system like binary, octal,
decimal and hexadecimal. In fact, it is the decimal system with each digit encoded in its
binary equivalent. It is also important to understand that a BCD number is not the same
as a straight binary number. A straight binary number takes the complete decimal number
and represents it in binary; the BCD code converts each decimal digit to binary
individually. To illustrate, take the number 137 and compare its straight binary and BCD
codes:

137
10
= 10001001
2
(binary)


137
10
= 0001 0011 0111 (BCD)


The BCD code requires 12 bits, while the straight binary code requires only eight bits to
represent 137. BCD requires more bits than straight binary to represent decimal numbers
of more than one digit because BCD does not use all possible four-bit groups.

The main advantage of the BCD code is the relative ease of converting to and from
decimal. Only the four-bit code groups for the decimal digits 0 through 9 needs to be
remembered. This ease of conversion is especially important from a hardware standpoint
because in a digital system, it is the logic circuits that perform the conversions to and
from decimal.





1.6 u11lnC l1 ALL 1CCL1PL8


Table 1.6.1 gives the representation of the decimal numbers 1 through 15 in the binary,

octal and hex number systems and in BCD code.
EE202 DIGITAL ELECTRONICS CHAPTER 1

DECIMAL BINARY OCTAL HEXADECIMAL BCD
0 0 0 0 0000
1 1 1 1 0001
2 10 2 2 0010
3 11 3 3 0011
4 100 4 4 0100
5 101 5 5 0101
6 110 6 6 0110
7 111 7 7 0111
8 1000 10 8 1000
9 1001 11 9 1001
10 1010 12 A 0001 0000
11 1011 13 B 0001 0001
12 1100 14 C 0001 0010
13 1101 15 D 0001 0011
14 1110 16 E 0001 0100
15 1111 17 F 0001 0101
Table 1.6.1 Representation of decimal, binary, octal, hexadecimal and BCD





1.7 ASCll CCuL (AML8lCAn S1AnuA8u CCuL lC8 lnlC8MA1lCn ln1L8CPAnCL)

In addition to numerical data, a computer must be able to handle numerical information.
In other words, a computer should recognize codes that represent letters of the alphabet,
punctuation marks and other special characters as well as numbers. These codes are
called alphanumeric codes. A complete alphanumeric code would include the 26
lowercase letters, 26 uppercase letters, 10 numeric digits, 7 punctuation marks and
anywhere from 20 to 40 other characters such as +, /, #, %, * and so on. We can say that
an alphanumeric code represents all of the various characters and functions that are found
on a computer keyboard.

The most widely used alphanumeric code is the American Standard Code for
Information Interchange (ASCII). The ASCII (pronounced askee) code is a seven-bit
code, and so it has 2
7
= 128 possible code groups. This is more than enough to represent
EE202 DIGITAL ELECTRONICS CHAPTER 1

all of the standard keyboard characters as well as the control functions such as the

{RETURN} and {LINEFEED} functions.

Table 1.7.1 shows a partial listing of the ASCII code. In addition to the binary code
group for each character, the table gives the octal and hexadecimal equivalents.





CHARACTER SEVEN-
BIT ASCII
OCTAL HEX

CHARACTER SEVEN-
BIT ASCII
OCTAL HEX
A 100 101 41 Y 101 131 59
B 100 102 42 Z 101 132 5A
C 100 103 43 0 011 060 30
D 100 104 44 1 011 061 31
E 100 105 45 2 011 062 32
F 100 106 46 3 011 063 33
G 100 107 47 4 011 064 34
H 100 110 48 5 011 065 35
I 100 111 49 6 011 066 36
J 100 112 4A 7 011 067 37
K 100 113 4B 8 011 070 38
L 100 114 4C 9 011 071 39
M 100 115 4D blank 010 040 20
N 100 116 4E . 010 056 2E
O 100 117 4F ( 010 050 28
P 101 120 50 + 010 053 2B
Q 101 121 51 $ 010 044 24
R 101 122 52 * 010 052 2A
S 101 123 53 ) 010 051 29
T 101 124 54 _ 010 055 2D
U 101 125 55 / 010 057 2F
V 101 126 56 , 010 054 2C
W 101 127 57 = 011 075 3D
X 101 130 58 {RETURN} 000 015 0D
{LINEFEED} 000 012 0A
Table 1.7.1 ASCII code (partial)


EE202 DIGITAL ELECTRONICS CHAPTER 1

! '&KI&L M-&/%I,*/


1. Convert 100011011011
2
to its decimal equivalent.

2. What is the weight of the MSB of a 16-bit number?

3. Convert 83
10
to binary using both methods.

4. Convert 729
10
to binary using both methods. Check your answer by converting back to
decimal.

5. How many bits are required to count up to decimal 1 million?

6. Convert 614
8
to decimal.

7. Convert 146
10
to octal, then from octal to binary.

8. Convert 10011101
2
to octal.

9. Write the next three numbers in this octal counting sequence: 624, 625, 626, , ,
.

10. Convert 975
10
to binary by first converting to octal.

11. Convert binary 1010111011 to decimal by first converting to octal.

12. What range of decimal values can be represented by a four-digit octal number?

13. Convert 24CE
16
to decimal.

14. Convert 3117
10
to hex, then from hex to binary.

15. Convert 1001011110110101
2
to hex.

16. Write the next four numbers in this hex counting sequence: E9A, E9B, E9C, E9D, ,
, , .

17. Convert 3527
8
to hex.

18. What range of decimal values can be represented by a four-digit hex number?

19. Represent the decimal value 178 by its straight binary equivalent. Then encode the same
decimal number using BCD.

20. How many bits are required to represent an eight-digit decimal number in BCD?

21. What is an advantage of encoding a decimal number in BCD rather than in straight binary?
What is a disadvantage?

22. Encode the following message in ASCII code using the hex representation: COST = $72.

23. The following padded ASCII-coded message is stored in successive memory locations in a
computer.

01010011 01010100 01001111 01010000

What is the message?