xii Preface circuits except in Chapters 11 and 12. The practical application of digital design will he en- hanced by doing the suggested experiments in Chapter 11 while studying the theory present- ed in the text. Each chapter has a list of refereuces and a set of problems. Answers to selected problems appear iu at the end of the book to aid the student and to help the independent reader. A solu- tions manual is available for the instructor from the publisher. I would like to thauk Charles Kime for iutroducing me to Verilog. My greatest thanks go to Jack Levine for guiding me arid checking the sections, examples, and problem solutions to all Verilog HDL materiaL Thanks go to Tom Robbins for helping me decide to write the third edi- tion and my editor Eric Frauk for his patience throughout the revision. Appreciation goes to Gary Covington and Donna Mitchell for providing the CD-ROM from SynaptiCad. Thanks also to those who reviewed the third edition: Thomas G. Johnson, California State University; Umit Uyar, City University ofNew York; Thomas L. Drake, Clemson University; and Richard Molyet, University of Toledo. Finally, I am grateful to my wife Sandra for encouraging me to pursue this project. M. MORRIS MANa Binary Systems 1-1 DIGITAL SYSTEMS Digital systems have such a prominent role in everyday life that we refer to the present tech- nological period as the digital age. Digital systems are used in communication, business trans- actions, traffic control, space guidance, medical treatment, weather monitoring, the Internet, and many other commercial, industrial, and scientific enterprises. We have digital telephones, dig- ital television, digital versatile discs, digital cameras, and of course, digital computers. The most striking property of the digital computer is its generality. It can follow a sequence of in- structions, called a program, that operates on given data. The user can specify and change the program or the data according to the specific need. Because of this flexibility, general-purpose digital computers can perform a variety of information processing tasks that range over a wide spectrum of applications. One characteristic of digital systems is their ability to manipulate discrete elements of in- formation. Any s'etthat is restricted to a finite number of elements contains discrete infonna- tion. Examples of discrete sets are the 10 decimal digits, the 26 letters of the alphabet, the 52 playing cards, and the 64 squares of a chessboard. Early digital computers were used for nu- meric computations. In this case, the discrete elements used were the digits. From this appli- cation, the term digital computer emerged. Discrete elements of information are represented in a digital system by physical quantities called signals. Electrical siguals such as voltages and currents are the most common. Electronic devices called transistors predominate in the cir- cuitry that implements these signals. The signals in most present-day electronic digital sys- tems use just two discrete values and are therefore said to be binary. A binary digit, called a bit, has two values: 0 and 1. Discrete elements of information are represented with groups of bits called binary codes. For example, the decimal digits 0 through 9 are represented in a dig- ital system with a code of four bits. By p,sing various techniques, groups of bits can be made 1
1. xii Prefacecircuits except in Chapters 11 and 12. The
practical application of digital design will he enhancedby doing
the suggested experiments in Chapter 11 while studying the theory
presentedin the text.Each chapter has a list of refereuces and a
set of problems. Answers to selected problemsappear iu at the end
of the book to aid the student and to help the independent reader.
A solutionsmanual is available for the instructor from the
publisher.I would like to thauk Charles Kime for iutroducing me to
Verilog. My greatest thanks go toJack Levine for guiding me arid
checking the sections, examples, and problem solutions to
allVerilog HDL materiaL Thanks go to Tom Robbins for helping me
decide to write the third editionand my editor Eric Frauk for his
patience throughout the revision. Appreciation goes to
GaryCovington and Donna Mitchell for providing the CD-ROM from
SynaptiCad. Thanks also tothose who reviewed the third edition:
Thomas G. Johnson, California State University; UmitUyar, City
University ofNew York; Thomas L. Drake, Clemson University; and
Richard Molyet,University of Toledo. Finally, I am grateful to my
wife Sandra for encouraging me to pursuethis project.M. MORRIS
MANaBinary Systems1-1 DIGITAL SYSTEMSDigital systems have such a
prominent role in everyday life that we refer to the present
technologicalperiod as the digital age. Digital systems are used in
communication, business transactions,traffic control, space
guidance, medical treatment, weather monitoring, the Internet,
andmany other commercial, industrial, and scientific enterprises.
We have digital telephones, digitaltelevision, digital versatile
discs, digital cameras, and of course, digital computers. Themost
striking property of the digital computer is its generality. It can
follow a sequence of instructions,called a program, that operates
on given data. The user can specify and change theprogram or the
data according to the specific need. Because of this flexibility,
general-purposedigital computers can perform a variety of
information processing tasks that range over a widespectrum of
applications.One characteristic of digital systems is their ability
to manipulate discrete elements of information.Any s'etthat is
restricted to a finite number of elements contains discrete
infonnation.Examples of discrete sets are the 10 decimal digits,
the 26 letters of the alphabet, the 52playing cards, and the 64
squares of a chessboard. Early digital computers were used for
numericcomputations. In this case, the discrete elements used were
the digits. From this application,the term digital computer
emerged. Discrete elements of information are representedin a
digital system by physical quantities called signals. Electrical
siguals such as voltages andcurrents are the most common.
Electronic devices called transistors predominate in the
circuitrythat implements these signals. The signals in most
present-day electronic digital systemsuse just two discrete values
and are therefore said to be binary. A binary digit, called abit,
has two values: 0 and 1. Discrete elements of information are
represented with groups ofbits called binary codes. For example,
the decimal digits 0 through 9 are represented in a digitalsystem
with a code of four bits. By p,sing various techniques, groups of
bits can be made1
2. 2 Chapter 1 Binary Systems Section 1-2 Binary Numbers 3to
represent discrete symbols, which are then used to develop the
system in a digital format.Thus, a digital system is a system that
manipulates discrete elements of information that isrepresented
internally in binary form.Discrete quantities of information either
emerge from the nature of the data being processedor may be
quantized from a continuous process. For example, a payroll
schedule is an inherentlycliscrete process that contains employee
names, social security numbers, weekly salaries,income taxes, and
so on. An employee's paycheck is processed using discrete data
values suchas letters of the alphabet (names), digits (salary), and
special symbols (such as $). On the otherhand, a research scientist
may observe a continuous process, but record only specific
quantitiesin tabular form. The scientist is thus quantizing his
continuous data, making each numberin his table a discrete
quantity. In many cases, the quantization of a process can be
performedautomatically by an analog-to-digital converter.The
general-purpose digital computer is the best-known example of a
digital system. Themajor parts of a computer are a memory unit, a
central processing unit, and input-output units.The memory unit
stores programs as well as input, output, and intermediate data.
The centralprocessing unit perlonns arithmetic and other data
processing operations as specified by the program.The program and
data prepared by a user are transferred into memory by means of
aninput device such as a keyboard~ An output device, such as a
printer, receives the results of thecomputations and the printed
results are presented to the user. A digital computer can
accommodatemany input and output devices. One very useful device is
a communication unit thatprovides interaction with other users
through the Internet. A digital computer is a powerful
instrumentandean penorm not only arithmetic computations, but also
logical operations. In addition,it can be programmed to make
decisions based on internal and external conditions.There are
fundamental reasons why commercial products are made with digital
circuits.Like a digital computer, most digital devices are
programmable. By changing the program ina programmable device, the
same underlying hardware can be' used for many different
applications;Dramatic cost reductions in digital devices have come
about because of the advancesin digital integrated circuit
technology. As the number of transistors that can be put on a
pieceof silicon increases to produce complex functions, the cost
per unit decreases and digital devicescan be bought at an
increasingly reduced price. Equipment built with digital
integratedcircuits can perform at a speed of hundreds of millions
of operations per second. Digital systemscan be made to operate
with extreme reliability by using error-correcting codes. An
exampleof this is the digital versatile disk (DVD) in which digital
information representing video,audio, and other data is recorded
without a loss of a single item. Digital information on a DVDis
recorded in such a way that by examining the code in each digital
sample before it is playedback, any error can be automatically
identified and corrected.A digital system is an interconnection of
digital modules. To understand the operation of eachdigital module,
it is necessary to have a basic knowledge of digital circuits and
their logical function.The first seven chapters of this book
present the basic tools of digital design such as logicgate
structures, combinational and sequential circuits, and programmable
logic devices. Chapter8 introduces digital design at the register
transfer level (RTL). Chapters 9 and 10 deal withasynchronous
sequential circuits and the various integrated digital logic
families. Chapters IIand 12 introduce commercial integrated
circuits and show how they can be connected in thelaboratory to
perform experiments with digital circuits.1-2An important trend in
digital design is the use of hardware description language
(HDL).HDL resembles a programming language and is suitable for
describing digital circuits in textualform. It is used to simulate
a digital system to verify its operation before hardware is
builtin. It is also used in conjunction with logic synthesis tools
to automate the design. HDL descriptionsof digital circuits are
presented throughout the book.As previously stated, digital systems
manipulate discrete quantities of information that arerepresented
in binary form. Operands used for calculations may be expressed in
the binarynumber system. Other discrete elements, including the
decimal digits, are represented in binarycodes. Data processing is
carried out by means of binary logic elements using binary
signals.Quantities are stored in binary storage elements. The
purpose of this chapter is to introduce thevarious binary concepts
as a frame of reference for further study in the succeeding
chapters.BINARY NUMBERSA decimal number such as 7,392 represents a
quantity equal to 7 thousands plus 3 hundreds,plus 9 tens, plus 2
units. The thousands, hundreds, etc. are powers of 10 implied by
the positionof the coefficients. To be more exact, 7,392 should be
written as7 X 103 + 3 X 10' + 9 X 10' + 2 X 100However, the
convention is to write only the coefficients and from their
position deduce thenecessary powers of 10. In general, a number
with a decimal point is represented by a seriesof coefficients as
follows:The aj coefficients are any of the 10 digits (0, I, 2, ...
,9), and the subscript valuejgives theplace value and, hence, the
power of 10 by which the coefficient must be multiplied. This canbe
expressed as10'a, + lO'a, + 103a3 + lO'a, + lO'a, + 100aD + lO-l
a_1 + lO-'a_, + 1O-3a_3The decimal number system is said to be of
base, or radix, 10 because it uses 10 digits andthe coefficients
are multiplied by powers of 10. The binary system is a different
number system.The coefficients of the binary numbers system have
only two possible values: 0 or I. Eachcoefficient aj is multiplied
by 2J For example, the decimal equivalent of the binary
numberIIOlO.11 is 26.75, as shown from the multiplication of the
coefficients by powers of2:I X 24 + I X 23 + 0 X 2' + I X 21 + 0 X
2 + I X T 1 + I X T 2 = 26.75In general, a number expressed in a
base-r system has coefficients multiplied by powers of r:all rll +
all-I rll - 1 + ... + a2 . r 2 + al . r + ao + a~l . r-l + a-2 .
r~2 + ... + a_m r-mThe coefficients aj range in value from ato r -
1. To distinguish between numbers of differentbases, we enclose the
coefficients in parentheses and write a subscript equal to the base
used(except sometimes for decimal numbers, where the content makes
it obvious that it is decimal).An example of a base-5 number
is
3. Chapter 1 Binary Systems Section 1-3 Number Base Conversions
5r-allowable digits. Examples of addition, subtraction, and
multiplication of two binary numbersare as
follows:augend:addend:sum:The sum oftwo binary numbers is
calculated by the same rules as in decimal, except thatfhe digits
of fhe sum in any significant position can be only 0 or 1. Any
carry obtained in a givensignificant position is used by the pair
of digits one significant position higher. The subtractionis
slightly more complicated. The rules are still the same as in
decimal, except that the borrowin a given significant position adds
2 to a minuend digit. (A borrow in the decimal system adds10 to a
minuend digit.) Multiplication is very simple. The multiplier
digits are always 1 or O.Therefore, tbe partial products are equal
either to the multiplicand or to O.1-3 NUMBER BASE
CONVERSIONSproduct:The conversion of a number in base r to decimal
is done by expanding the number in a powerseries and adding an the
terms as shown previously. We now present a general procedure
forthe reverse operation of converting a decimal number to a number
in base r. If the number includesa radix point, it is necessary to
separate the number into an integer part and a fractionpart, since
each part must be converted differently. The conversion of a
decimal integer to anumber in base r is done by dividing the number
and all successive quotients by r and accumulatingfhe remainders.
This procedure is best illustrated by example.Convert decimal 41 to
binary. First, 41 is divided by 2 to give an integer quotient of 20
and aremainder of!. The quotient is again divided by 2 to give a
new quotient and remainder. Thisprocess is continued until the
integer quotient becomes o. The coefficients of the desired
binarynumber are obtained from the remainders as follows:1011X
101101100001011110111multiplicand:multiplier:101101-100111000110minuend:subtrahend:difference:101101+1001111010100IntegerQuotient
Remainder Coefficient41/2 = 20 + ,ao = 1 20/2 = 10 + 0 al = 010/2 =
5 + 0 Q2 = 05/2 = 2 + ,'2 a3 = 12/2 = 1 + 0 a4 = 01/2 = 0 + 12 as =
1Therefore, the answer is (41) 10 = (a,a4a3aZa,aO)2 =
(101001)2(4021.2), = 4 X 53 + 0 X 52 + 2 X 51 + 1 X 5 + 2 X 5-' =
(511.4)10The coefficient values for base 5 can be only 0, 1, 2, 3,
and 4. The octal nnmber system is abase-8 system fhat has eight
digits: 0, 1,2,3,4, 5, 6, 7. An example of an octal number is127.4.
To determine its equivalent decimal value, we expand the number in
a power series witha base of 8:(127.4)8 = 1 X 82 + 2 X 8' + 7 X 8 +
4 X 8-' = (87.5)10Note that the digits 8 and 9 cannot appear in an
octal number.It is customary to borrow the needed r digits for the
coefficients from the decimal systemwhen the base of the number is
less than 10. The letters of the alphabet are used to supplementthe
10 decimal digits when the base of the number is greater than 10.
For example, in the hexadecimal(base 16) number system, the first
ten digits are borrowed from fhe decimal system.The letters A, B,
C, D, E, and F are used for digits 10, 11, 12, 13, 14, and 15,
respectively. Anexample of a hexadecimal number is(B65F)16 = 11 X
163 + 6 X 162 + 5 X 16' + 15 X 16 = (46,687)111As noted before, the
digits in a binary number are called bits. Wheu a bit is equal to
0, it doesnot contribute to the sum during the conversion.
Therefore, the conversion from binary to decimalcan be obtained by
adding the numbers with powers of two corresponding to the bits
thatare equal to 1. For example,(110101)2 = 32 + 16 + 4 + 1 =
(53)10There are four 1'8 in the binary number. The corresponding
decimal number is the sum of thefour powers of two numbers. The
first 24 numbers obtained from 2 to the power of n are listedin
Table 1-1. In computer work, 210 is referred to as K(kilo), 220 as
M(mega), 230 as G(giga),and 240 as T(tera). Thus 4K = 212 = 4096
and 16M, = 224 = 16,777,216. Computer capacityis usually given in
bytes. A byte is equal to eight bits and can accommodate one
keyboardcharacter. A computer hard disk with 4 gigabytes of storage
has a capacity of 4G = 232 bytes(approximately 4 billion
bytes).Arithmetic operations with numbers in base r follow the same
rules as for decimal numbers.When a base other than the familiar
base lOis used, one must be careful to use only theTable 1-1Powers
of Twon 2" n 2" n 2"0 1 8 256 16 65,5361 2 9 512 17 131,0722 4 to
1,024 18 262,1443 8 11 2,048 19 524,2884 16 12 4,096 20 1,048,5765
32 13 8,192 21 2,097,1526 64 14 16,384 22 4,194,3047 128 15 32,768
23 8,388,608
4. Chapter 1 Binary Systems Section 1-4 Octal arid Hexadecimal
Numbers 7The conversion from decimal integers to any base-r system
is similar to the example, exceptthat division is done by r instead
of 2.Convert decimal 153 to octal. The required base r is 8. First,
153 is divided by 8 to give an integerquotient of 19 and a
remainder of I. Then 19 is divided by 8 to give an integer
quotientof 2 and a remainder of 3. Finally, 2 is divided by 8 to
give a quotient of 0 and a remainder of2. This process can be
conveniently manipulated as follows:To convert a decimal fraction
to a number expressed in base r, a similar procedure is
used.Multiplication is by r iustead of 2, and the coefficients
found from the integers may range invalue from 0 to r - 1 instead
of 0 and 1.The answer, to seven significant figures, is obtained
from the integer part of the products(41.6875)10 =
(101001.1011)21-4 OCTAL AND HEXADECIMAL NUMBERSIII 100 000 110h =
(26153.7406)87 4 0 6From Examples 1-2 and 1-4, we have101 0115
3Convert (0.513)10 to octal.( 10 110 0012 6 10.513 X 8 = 4.1040.104
X 8 = 0.8320.832 X 8 = 6.6560.656 X 8 = 5.2480.248 X 8 = 1.9840.984
X 8 = 7.872(0.513) 10 = (0.406517 ... )8The conversion of decimal
numbers with both integer and fraction parts is done by
convertingthe integer and the fraction separately and then
combining the two answers. Using theresults of Examples 1-1 and
1-3, we obtain(153.513)10 = (231.406517)8The conversion from and to
binary, octal, aud hexadecimal plays an important role in
digitalcomputers. Since 23 = 8 and 24 = 16, each octal digit
corresponds to three binary digits andeach hexadecimal digit
corresponds to four binary digits. The fIrst 16 numbers in the
decimal,binary, octal, and hexadecimal number systems are listed in
Table 1-2.The conversion from binary to octal is easily
accomplished by partitioning the binary numberinto groups of three
digits each, starting from the binary point and proceeding to the
leftand to the right. The corresponding octal digit is then
assigned to each group. The followingexample illustrates the
procedure:The arithmetic process can be manipulated more
conveniently as follows:Integer Remainder4120 I10 05 02 II 0o 1
101001 = answer1~ L= (231)8153192oThe conversion of a decimal
fraction to binary is accomplished by a method similar to thatused
for integers. However, multiplication is used instead of division,
and integers are accumulatedinstead of remainders. Again, the
method is best explained by example.Convert (0.6875)10 to binary.
First, 0.6875 is multiplied by 2 to give aninteger and a
fraction.The new fraction is multiplied by 2 to give a new integer
and a new fraction. This process iscontinued until the fraction
becomes 0 or until the number of digits have sufficient
accuracy.The coefficients of the binary number are obtained from
the integers as follows:Integer Fraction Coefficient0.6875 X 2 = 1
+ 0.3750 a_1 = 10.3750 X 2 = 0 + 0.7500 a-2 = 00.7500 X 2 = I +
0.5000 a-3 = 10.5000 X 2 = 1 + 0.0000 a_4 = ITherefore, the answer
is (0.6875)10 = (O.a -1 a _2a -3a -4)z = (0.1011)2
5. 8 Chapter 1 Binary SystemsTable 1-2Numbers with Different
BasesDecimal Binary Odal Hexadecimal(base 10) (base 2) (base 8)
(base 16)00 0000 00 001 0001 01 102 0010 02 203 0011 03 304 0100 04
405 0101 05 506 0110 06 607 0111 07 708 1000 10 809 1001 11 910
1010 12 A11 1011 13 B12 1100 14 C13 1101 15 D14 1110 16 E15 1111 17
FConversion from binary to hexadecimal is similar, except that the
binary number is divided(into groups offour digits:The
corresponding hexadecimal (or octal) digit for each group of binary
digits is easily rememberedafter studying the values listed in
Table 1-2.Conversion from octal or hexadecimal to binary is doneby
reversing the preceding procedure.Each octal digit is converted to
its three-digit binary equivalent. Similarly, each hexadecimaldigit
is converted to its four-digit binary equivalent. This is
illustrated in the following examples:(673.124)8 ~ (110 III 011 001
010 100 ),6 7 3 I 2 4and(306.D h6 = ( 0011 0000 0110 1101 ),3 0 6
DBinary numbers are difficult to work with because they require
three or four times as manydigits as their decimal equivalent. For
example, the binary number Illlllllllll is equivalentto decimal
4095. However, digital computers use binary numbers and it is
sometimes necessaryfor the human operator or user to communicate
directly with the machine by means ofbinary numbers. One scheme
that retains the binary system in the computer, but reduces
thenumber of digits the human must consider, utilizes the
relationship between the binary numbersystem and the octal or
hexadecimal system. By this method, the human thinks in terms
ofoctal or hexadecimal numbers and performs the required conversion
by inspection when directcommunication with the machine is
neCessary. Thus the binary number 1lll1l1llll1 has 12digits and is
expressed in octal as 7777 (four digits) or in hexadecimal as FFF
(three digits).During communication between people (about binary
numbers in the computer), the octal orhexadecimal representation is
more desirable because it can be expressed more compactly witha
third or a quarter of the number of digits required for the
equivalent binary number. Thus, mostcomputer manuals use either
octal or hexadecimal numbers to specify binary quantities.
Thechoice between them is arbitrary, although hexadecimal tends to
win out, since it can representa byte with two digits.1-5 COM Pl
EMEN TSComplements are used in digital computers for simplifying
the subtraction operation and forlogical manipulation. There are
two types of complements for each base-r system: the
radixcomplement and the diminished radix complement. The first is
referred to as the r's complementand the second as the (r - I)'s
complement. When the value of the base r is substitutedin the name,
the two types are referred to as the 2's complement and l's
complement forbinary numbers, and the 10's complement and 9's
complement for decimal numbers.Diminished Radix ComplementGiven a
number N in base r having n digits, the (r - I)'s complement ofN is
defined as(r" - I) - N. For decimal numbers, r = 10 and r - I = 9,
so the 9's complement of N is(10" - I) - N. In this case, 10"
represents a number that consists of a single I followed bynOs. 10"
- I is a number represented by n 9s. For example, if n ~ 4, we have
104 = 10,000and 104- I = 9999. It follows that the 9's complement
of a decimal number is obtained bysubtracting each digit from 9.
Some numerical examples follow:The 9's complement of 546700 is
999999 - 546700 = 453299.The 9's complement of 012398 is 999999 -
012398 = 987601.Forbinarynumbers,r = 2andr -1 = I, sathe I's
complementofN is (2" -I) - N.Again, 2" is represented by a binary
number that consists of a I followed by nOs. 2" - I is abinary
number represented by n I's. For example, if n = 4, we have 24 ~
(10000), and24- I = (llll),. Thus the l's complement of a binary
number is obtained by subtractingeach digit from 1. However, when
subtracting binary digits from 1, we can have eitherI - 0 = I or I
- I = 0, which causes the bit to change from 0 to I or from I to O.
Therefore,the I's complement of a binary number is formed by
changing I's to O's and O's to I 's. The followingare some
numerical examples:Section 1-5 Complements 9The I's complement of
1011000 is 0100111.The I's complement of 0101101 is 1010010.0010),
= (2C6B.F2)162IlllF1011B011061100C(102
6. Chapter 1 Binary Systems Section 1-5 Complements 11The (r -
I)'s complement of octal or hexadecimal numbers is obtained by
subtracting eachdigit from 7 or F (decimal 15), respectively.adix
ComplementThe r's complement of an n-digit number N in base r is
defined as rll - N, for N i: 0 and 0for N = O. Comparing with the
(r - I)'s complement, we note that the r's complement isobtained by
adding I to the (r - I)'s complement since r" - N ~ [(r" - I) - N]
+ 1.Thus, the lO's complement of decimal 2389 is 7610 + I = 7611
and is obtained by adding Ito the 9's-complement value. The 2's
complement of binary 101100 is 010011 + I = 010100and is obtained
by adding I to the I 's-complement value.Since 10" is a number
represented by a I followed by nO's, 10" - N, which is the
10'scomplement of N, can be formed also by leaving all least
significant O's unchanged, subtractingthe first nonzero least
significant digit from 10, and subtracting all higher significant
digitsfrom 9.The lO's complement of 012398 is 987602.The lO's
complement of 246700 is 753300.The lO's complement of the first
number is obtained by snbtracting 8 from 10 in the least
significantposition and subtracting all other digits from 9. The
lO's complement of the second numberis obtained by leaving the two
least significant O's unchanged, subtracting 7 from 10,
andsnbtracting the other three digits from 9.Similarly, the 2's
complement can be formed by leaving all least significant O's and
the firstI unchanged, and replacing I's with O's and O's with I's
in all other higher significant digits.The 2's complement of
1101100 is 0010100.The 2's complement of 0110111 is 1001001.The 2's
complement of the first nnmber is obtained by leaving the two least
significant O's andthe first I unchanged, and then replacing I's
with O's and O's with I's in the other four mostsignificantdigits.
The 2's complement of the second nnmber is obtained by leaving the
leastsignificant I unchanged and complementing all other digits.In
the previous definitions, it was assumed that the numbers did not
have a radix point. If theoriginal nnmber N contains a radix point,
the point should be removed temporarily in orderto form the r's or
(r - I)'s complement. The radix point is then restored to the
complementednumber in the same-relative position. It is also worth
mentioning that the complementof the complement restores the number
to its original value. The r's complement of N isrn- N. The
complement of the complement is Til ~ (rn- N) = N, and is equal to
theoriginal number.~btraction with ComplementsThe direct method of
snbtraction taught in elementary schools uses the borrow concept.
In thismethod, we borrow a 1 from a higher significant position
when the minuend digit is smallerthan the subtrahend digit. The
method works well when people perform subtraction with paperand
pencil. However, when subtraction is implemented with digital
hardware, the method is lessefficient than the method that uses
complements.The subtraction of two n-digit unsigned numbers M - N
in base r can be done as follows:1. Add the minuend, M, to the r's
complement of the subtrahend, N. This performsM + (rn- N) = M - N +
r".2. IfM ;0> N, the sum will produce an end cany, r", which can
be discarded; what is left isthe result M - N.3. IfM < N, the
sum does not produce an end carry and is equal to r" - (N - M),
whichis the r's complement of (N - M). To obtain the answer in a
familiar form, take the r'scomplement of the sum and place a
negative sign in front.The following examples illustrate the
procedure:Using 10's complement, subtract 72532 - 3250.M =
72532lO's complement of N = + 96750Sum = 169282Discard end carry
105 = -100000Answer ~ 69282 Note that M has 5 digits and N has only
4 digits. Both numbers must have the same numberof digits, so we
write N as 03250. Taking the 10's complement ofN produces a 9 in
the mostsignificant position. The occurrence of the end carry
signifies that M 2 N and that the resultis positive.Using 10's
complement, subtract 3250 - 72532.M ~ 03250lO's complement of N ~ +
27468Sum ~ 30718There is no end carry.Therefore, the answer is
-(10's complement of 30718) = -69282 Note that since 3250 <
72532, the result is negative. Since we are dealing with
unsignednumbers, there is really no way to get an unsigned result
for this case. When subtracting withcomplements, the negative
answer is recognized from the absence of the end carry and
thecomplemented result. When working with paper and pencil, we can
change the answer to asigned negative number in order-to put itin a
familiar form.
7. . ~13Section 1-6 Signed Binary NumbersNote that the negative
result is obtained by taking the I's complement of the sum since
this isthe type of complement used. The procedure with end-around
carry is also applicable for subtractingunsigned decimal numbers
with 9's complement.1-6 SIGNED BINARY NUMBERSPositive integers
(including zero) can be represented as unsigned numbers. However,
to representnegative integers, we need a notation for negative
values. In ordinary arithmetic, a negativenumber is indicated by a
minus sign and a positive number by a plus sign. Because ofhardware
limitations, computers must represent everything with binary
digits. It is customaryto represent the sign with a bit placed in
the leftmost position of the number. The conventionis to make the
sign bit 0 for positive and I for negative.It is important to
realize that both signed and unsigned binary numbers consist of a
string ofbits when represented in a computer. The user determines
whether the number is signed or unsigned.If the binary number is
signed, then the leftmost bit represents the sign and the rest
ofthe bits represent the number. If the binary number is assumed to
be unsigned, then the leftmostbit is the most significant bit of
the number. For example, the string of bits 01001 can be
consideredas 9 (unsigned binary) or as +9 (signed binary) because
the leftmost bit is O. The stringof bit' 1100 I represent the
binary equivalent of 25 when considered as an unsigned number oras
-9 when considered as a signed number. This is because the I that
is in the leftmost positiondesignates a negative and the other four
bits represent binary 9. Usually, there is no confusionin
identifying the bits if the type of representation for the number
is known in advance.The representation of the signed numbers in the
last example is referred to as the signedmagnitudeconvention. In
this notation, the number consists of a magnitude and a symbol (+or
-) or a bit (0 or I) indicating the sign. This is the
representation of signed numbers nsed inordinary arithmetic. When
arithmetic operations are implemented in a computer, .it is
moreconvenient to use a different system for representing negative
numbers, referred to as the signedcomplementsystem. In this system,
a negative number is indicated by its complement. Whereasthe
signed-magnitude system negates a number by changing its sign, the
signed-complementsystem negates a number by taking its complement.
Since positive numbers always start witho(plus) in the left-most
position, the complement will always start with aI, indicating a
negativenumber. The signed-complement system can use either the l's
or the 2's complement, butAs an example, consider the number 9
represented in binary with eight bits. +9 is representedwith a sign
bit of 0 in the leftmost position, followed by the binary
equivalent of9, which gives00001001. Note that all eight bits must
have a value and, therefore, Os are inserted followingthe sign bit
up to the first 1. Although there is only one way to represent +9,
there are three different100010011111011011110111the 2's complement
is the most common.ways to represent -9 with eight
bits:signed-magnitude representation:signed-l 's-complement
representation:signed-2's-complement representation:In
signed-magnitude, -9 is obtained from +9 by changing the sign bit
in the leftmost positionfrom 0 to 1. In signed-I's complement, -9
is obtained by complementing all the bits ofChapter 1 Binary
SystemsSubtraction with complements is done with binary numbers in
a similar manner using theprocedure outlined previously,Given the
two binary numbers X = 1010100 and Y = 1000011, perform the
subtraction(a) X - Y and (b) Y - X using 2's complements.(a) X =
1010100Subtraction of unsigned numbers can also be done by means of
the (r - I)'s complement.Remember that the (r - l)'s complement is
one less than the r's complement. Because ofthis, the result of
adding the minuend to the complement of the subtrahend produces a
sum thatis 1 less than the correct difference when an end carry
occurs. Removing the end carry andadding 1 to the sum is referred
to as an end~around carry.~2's complement ofY = + 0111101Sum =
10010001Discard end carry 2' = -10000000Answer: X - Y = 0010001(b)
Y = 1O000112's complement of X = + 0101100Sum = 1101111There is no
end carry.Therefore, the answer is Y - X = -(2's complement of
1101111) = -0010001100001101010111101110X=Y=Repeat Example 1-7
using I's complement.(a) X - Y = 1010100 - 1000011I's complement of
X = +Sum =1010100I's complement of Y = + 0111100Sum =
10010000End-around carry = +__~IAnswer: X - Y = 0010001(b) Y - X =
IQQQQll - 1010100There is no end carry.Therefore, the answer is Y -
X = -(1's complement of 1101110) = -0010001
8. 14 Chapter 1 Binary SystemsTable 1-3Signed Binary
NumbersSigned-2'. Signed-1'. SignedDecimal complement complement
magnitude+7 0111 0111 0111+6 0110 0110 0110+5 0101 0101 0101+4 0100
0100 0100+3 0011 0011 0011+2 0010 0010 0010+1 0001 0001 0001+0 0000
0000 0000-0 1111 1000-1 1111 1110 1001-2 1110 1101 1010-3 1101 1100
1011-4 1100 lOll 1100-5 1011 1010 1101-6 1010 1001 1110-7 1001 1000
1111-8 1000+9, including the sign bit. The signed-2's-complement
representation of -9 is obtained by takingthe 2's complement of the
positive number, including the sign bit.Table 1-3 lists all
possible 4-bit signed binary numbers in 1he three representations.
Theequivalent decimal number is also shown for reference. Note that
the positive numbers in allthree representations are identical and
have 0 in the leftmost position. The signed-2's complementsystem
has only one representation for 0, which is always positive. The
other two systemshave either a positive 0 or a negative 0, which is
something not encountered in ordinary arithmetic.Note that all
negative numbers have a I in the leftmost bit position; this is the
way wedistinguish them from the positive numbers. With fOUf bits,
we can represent 16 binary numbers.In the signed-magnitude and the
1's complement representations, there are eight positivenumbers and
eight negative numbers, including two zeros. In the 2's complement
representation,there are eight positive numbers, including one zero
and eight negative numbers.The signed-magnitude system is used in
ordinary arithmetic, but is awkward when employedin computer
arithmetic because of the separate handling of the sign and the
magnitude.Therefore, the signed-complement is normally used. The
l's complement imposes some difficultiesand is seldom used for
arithmetic operations. It is useful as a logical operation since
thechange of I to 0 or 0 to I is equivalent to a logical complement
operation, as will be shown inthe next chapter. The following
discussion of signed binary arithmetic deals exclusively withthe
signed-2's-complement representation of negative numbers. The same
procedures can beapplied to the signed-I 's-complement system by
including the end-around carry as done withunsigned numbers.Section
1-6 Signed Binary Numbers 15Arithmetic AdditionThe addition of two
numbers in the signed-magnitude system follows the rules of
ordinaryarithmetic. If the signs are the same, we add the two
magnitudes and give the sum the commonsign. If the signs are
different, we subtract the smaller magnitude from the larger and
give theresult the sign of the larger magnitude. For example, (+25)
+ (-37) = -(37 - 25) = -12and is done by subtracting the smaller
magnitude 25 from the larger magnitude 37 and usingthe sign of 37
for the sign of the result. This is a process that requires the
comparison of the signsand the magnitudes and then performing
either addition or subtraction. The same procedure appliesto binary
numbers in signed-magnitude representation. In contrast, the rule
for addingnumbers in the signed-complement system does not require
a comparison or subtraction, butonly addition. The procedure is
very simple and can be stated as follows for binary nnmbers:The
addition of two signed binary numbers with negative numbers
represented in signed2's-complement form is obtained from the
addition of the two numbers, including their sign bits.A carry out
of the sign-bit position is discarded.Numerical examples for
addition follow:+ 6 00000110 - 6 11111010+13 00001101 +13 00001101
- -+19 00010011 + 7 00000111+ 6 00000110 -6 11111010-13 - llllOOl1
-13 llllOOl1 -- 7 11111001 -19 11101101Note that negative numbers
must be initially in 2's complement and thatifthe sum obtainedafter
the addition is negative, it is in 2's-complement form.In each of
the four cases, the operation performed is addition with the sign
bit included.Any carry out of the sign-bit position is discarded,
and negative results are automatically in 2'scomplementform.In
order to obtain a correct answer, we must ensure that the result
has a sufficient numberof bits to accommodate the sum. If we start
with two n-bit numbers and the sum occupiesn + I bits, we say that
an overflow occurs. When one performs the addition with paper and
pencil,an overflow is not a problem, becanse we are not limited by
the width of the page. Wejustadd another 0 to a positive number or
another 1 to a negative number in the most-significantposition to
extend them to n + I bits and then perform the addition. Overflow
is a problem incomputers because the number of bits that hold a
number is finite, and a result that exceeds thefinite value by I
cannot be accommodated.The complement form of representing negative
numbers is unfamiliar to those used to thesigned-magnitude system.
To determine the value of a negative number when in
signed-2'scomplement, it is necessary to convert it to a positive
number to place it in a more familiarform. For example, the signed
binary number 11111001 is negative because the leftmost bit is1.
Its 2's complement is 00000111, which is the binary equivalent of
+7. We therefore recognizethe original negative number to be equal
to -7.
9. 16 Chapter 1 Binary Systems Section 1-7 Binary Codes
17Arithmetic SubtractionSubtraction of two signed binary numbers
when negative numbers are in 2's-complement formis very simple and
can be stated as follows: . .Take the 2's complement of the
snhtrahend (including the sign bit) and add It to the
mmu-end(including the sign bit). A cany out of the sign-bit
position is discarded. . .This procedure occurs because a
subtraction operation can be changed to a~ additIo~ ope~ationif the
sign of the subtrahend is changed. This is demonstrated by the
followmg relatIOnshIp:(A) - (+B) = (A) + (-B);(A) - (-B) = (A) +
(+B).Bnt chauging a positive number to a negative number is easily
done by taking its 2's complement.The reverse is also true because
the complement of a negative number in complement formproduces the
equivalent positive nnmber. Consider the snbtraction of (-6) -
(-:-13) = +7. Inbinary with eight bits, this is written as
(11111010 - 11110011). The subtractIOn IS changedto addition by
taking the 2's complement of the subtrahend (-13) to gIve (+13). In
bmary,this is 11111010 + 00001101 = 100000111. Removing the end
carry, we obtam the correctanswer: 00000111( +7).It is worth noting
that binary numbers in the signed-complement system are added and
subtractedby the same basic addition and subtraction rules as
unsigned numbers. Therefore, computersneed only one common hardware
circnit to haudle both types of arithmetic. The user orprogrammer
must interpret the results of such addition or subtraction
dIfferently, dependmg onwhether it is assumed that the numbers are
signed or unsigned.1-7 BINARY CODESDigital systems use signals that
have two distinct values and circuit elements that have tw~stable
states. There is a direct analogy among binary signals, binary
circuit elements, and bInarydigits. A binary number of n digits,
for example, may be represented by n binary circuitelements, each
having au output signal equivalent to a or I. Digital systems
represent aud manipulatenot only binary numbers, but also many
other discrete elements of information. A~ydiscrete element of
information distinct among a group of quantities can be represented
WItha binary code. The codes must be in binary because computers
can only hold I's aud a's. It mustbe realized that binary codes
merely change the symbols, not the meauing of the elements
ofinformation that they represent. Ifwe inspect the bits of a
computer at random, we will find thatmost of the time they
represent some type of coded information rather than binary
numbers.An n-bit binary code is a group of n bits that assume up to
21ldistinct combinations of 1'sand a's with each combination
representing one element of the set that is being coded. A setof
four 'elements cau be coded with two bits, with each element
assigned one of the followingbit combinations: 00, 01, 10, II. A
set of eight elements requires a 3-bit code aud a set of 16elements
requires a 4-bit code. The bit combination of an n-bit code is
determined from the countin binary from a to 2" ~ 1. Each element
must be assigned a unique binary bit combination audno two elements
can have the same value; otherwise, the code assignment will be
ambiguous.BCD CodeAlthough the minimum number of bits required to
code 2/1 distinct quantities is n, there isno maximum number of
bits that may be used for a binary code. For example, the 10
decimaldigits cau be coded with 10 bits, and each decimal digit cau
be assigned a bit combination ofnine a's and a 1. In this
particular binary code, the digit 6 is assigned the bit
combination0001000000.Although the binary number system is the most
natural system for a computer, most people aremore accustomed to
the decimal system. One way to resolve this difference is to
convert thedecimal numbers to binary, perform all arithmetic
calculations in binary, and then convert thebinary results back to
decimal. This method requires that we store the decimal numbers in
thecomputer so they can be converted to binary. Since the computer
can accept only binary values,we must represent the decimal digits
by means of a code that contains.1 's and O's. It is alsopossible
to perform the arithmetic operations directly with decimal numbers
when they arestored in the computer in coded form.A binary code
will have some unassigned bit combinations if the number of
elements inthe set is not a multiple power of 2. The 10 decimal
digits form such a set. A binary code thatdistinguishes among 10
elements must contain at least four bits, but 6 out of the 16
possiblecombinations remain unassigned. Different binary codes can
be obtained by arranging fourbits in 10 distinct combinations. The
code most commonly used for the decimal digits is thestraight
binary assignment as listed in Table 1-4. This is called binary
coded decimal aud is commonlyreferred to as BCD. Other decimal
codes are possible and a few of them are presentedlater in this
section.Table 1-4 gives the 4-bit code for one decimal digit. A
number with k decimal digits will require4k bits in BCD. Decimal
396 is represented in BCD with 12 bits as 0011 1001 0110,with each
group of 4 bits representing one decimal digit. A decimal number in
BCD is the sameas its equivalent binary number only when the number
is between 0 and 9. A BCD numberTable 1-4Binary Caded Decimal
(BCD)Decimal BCDsymbol digit0 00001 00012 00103 00114 01005 01016
01107 01118 10009 1001i
10. 18 Chapter 1 Binary Systems Section 1-7 Binary Codes
19greater than 10 looks different than its equivalent hinary
number, even though both contain l'sand D's. Moreover, the binary
combinations 1010 through 1111 are not used and have no meaningin
the BCD code. Consider decimal 185 and its corresponding value in
BCD and binary:(185ho = (00011000 OlO1hco = (1011100l)2This
condition occurs when the sum is greater than or equal to 16.
Although the other four bitsare less than 1001, the binary sum
requires a correction because of the carry. Adding 0110, weobtam
the required BCD digit sum 0111 (7) and a BCD carry.The addition of
two n-digit unsigned BCD numbers follows the sarne procedure.
Considerthe addition of 184 + 576 = 760 in BCD:BCD carryThe first,
least significant pair of BCD digits produces a BCD digit sum of
0000 and a carryfor the next palr of dIgIts. The second pair ofBCD
digits plus a previous carry produces a digitsum of 0110 and a
carry for the next pair of digits. The third pair of digits plus a
carry producesa bmary sum of 0111 and does not require a
correction.Decimal Arithmetic1 10001 1000 0100+0101 -- -Ol-ll OllO
--Olll 10000 1010OllO OllO -- --DIll OllO 0000The repr~sen~ation
ofsigned decimal numbers in BCD is similar to the representation of
signednumbers m bmary. We can use either the familiar sign and
magnitude system or the signed-complementsystem. The sign of a
decimal number is usually represented with four bits to conformto
the 4-bit code of the decimal digits. It is customary to designate
a plus with four D's and aminus with the BCD equivalent of 9, which
is 1001.The s~gned-magnitude system is seldom used in computers.
The signed-complement systemcan be e!lher the 9's or the 10's
complement, but the lO's complement is the one most oftenused. To
obtain the lO's complement of a BCD number, we first take the 9's
complement andthen add one to the least significant digit. The 9's
complement is calculated from the subtractionof each digit from
9.The procedures developed for the signed-2's complement system in
the previous sectionapply also to the signed-lO's complement system
for decimal numbers. Addition is done byadding all digits,
including the sign digit, and discarding the end carry. This
assumes that allnegative numbers are in 1O's complement form.
Consider the addition (+375) + (-240) =+135 done in the
signed-complement system.o 375+9 760o 135184+576760Binary sumAdd
6BCD sumThe 9 in the leftmost position of the second number
represents a minus and 9760 is the lO'scomplement of 0240. The two
numbers are added and the end carry is discarded to obtainThe BCD
value has 12 bits, but the equivalent binary nnmber needs only 8
bits. It is obvionsthat a BCD number needs more bits than its
equivalent binary value. However, there is an advantagein the use
of decimal numbers because computer input and output data are
generatedby people that use the decimal system.It is important to
realize that BCD numbers are decimal numbers and not binary
numbers,although they use bits in their representation. The only
difference between a decimal numberand BCD is that decimals are
written with the symbols 0, 1,2, ... , 9 and BCD numbers use
thebinary code 0000, 0001, 0010, ... , 1001. The decimal value is
exactly the same. Decimal 10is represented in BCD with eight bits
as 0001 0000 and decimal 15 as 0001 0101. The correspondingbinary
values are 1010 and 1111 and have only four bits.Consider the
addition of two decimal digits in BCD, together with a possible
carry from a previousless significant pair of digits. Since each
digit does not exceed 9, the sum cannot begreater than 9 + 9 + 1 =
19, with the 1 in the sum being a previous carry. Suppose we addthe
BCD digits as if they were binary numbers. The binary sum will
produce a result in the rangefrom 0 to 19. In binary, this will
befrom 0000 to 10011, but in BCD, it is from 0000 to 1 1001;the
first 1 being a carry and the next four bits being the BCD digit
sum. When the binary sumis equal to or less than 1001 (without a
carry), the corresponding BCD digit is correct. However,when the
binary sum is greater than or equal to 1010, the result is an
invalid BCD digit.The addition of 6 ~ (OllO)2 to the binary sum
converts itlo the correct digit and also producesa carry as
required. This is because the difference between a carry in the
most significant bitposition of the biuary sum and a decimal carry
differ by 16 - 10 ~ 6. Considerthe followiugthree BCD additions:4
0100 4 0100 8 1000+5 +0101 +8 +1000 +9 1001- -- - -- - --9 1001 12
llOO 17 10001+OllO +OllO -- --10010 101llIn each case, the two BCD
digits are added as if they were two binary numbers. If the
biuarysum is greater or equal to 1010, we add 0110 to obtain the
correct BCD digit sum and a carry.In the first example, the sum is
equal to 9 and is the correct BCD digit sum. In the second
example,the binary sum produces an invalid BCD digit. The addition
of 0110 produces the correctBCD digit sum 0010 (2) and a carry. In
the third example, the binary sum produces a carry.BCD
Addition
11. 20 Chapter 1 Binary Systems Section 1-7 Binary Codes
21+135. Of course, the decimal numbers inside the computer must be
in BCD, including the signdigits. The addition is done with BCD
digits as described previously.The subtraction of decimal numbers
either unsigned or in the signed-l O's complement systemis the same
as in the binary case. Take the lO's complement of the subtrahend
and add itto the minuend. Many computers have special hardware to
perform alithmetic calculations directlywith decimal numbers in
BCD. The user of the computer can specify by
programmedinstructionsto perform the arithmetic operation with
decimal numbers dIrectly WIthout havmgto convert them to
binary.Other Decimal CodesBinary codes for decimal digits require a
minimum of four bits per digit. Many different codescau be
formulated by arranging four bits in 10 distinct possible
combinations. The BCD andthree other representative codes are shown
in Table 1-5. Each code uses only 10 bit combinationsout of
possible 16 combinations that can be alTanged with four bits. The
other six unusedcombinations in each case have no meaning and
should be avoided.The BCD and the 2421 codes are examples of
weighted codes. In a weighted code. each bitposition is assigned a
weighting factor in such a way that each digit can be ~valuatedby
addingthe weights of all the I's in the coded combination. The BCD
code has weights of 8, 4, 2, andI, which correspond to the power of
two values of each bit. The bit assignmeut 0110 for example,is
interpreted by the weights to represent decimal 6 because 8 X a + 4
X I + 2 XI + 1 X a = 6. The bit combination 1101 wheu weighted by
the respective digits 2421 givesGray Codethe decimal equivalent of
2 X I + 4 X I + 2 X a + 1 X I ~ 7. Note that some digits canbe
coded in two possible ways in the 2421 code. Decimal 4 can be
assigned to bit combinations0100 or 1010 since both combinations
add up to a total weight offour.The 2421 and the excess-3 codes are
examples of self-complementing codes. Such codeshave the property
that the 9's complement of a decimal number is obtained directly by
changingI's to a's and a's to I's in the code. For example, decimal
395 is represented in the excess3code as 0110 1100 1000. The 9's
complement 604 is represented as 1001 0011 0111, whichis simply
obtained by complementing each bit of the code (as with the I's
complement of binarynumbers).The excess-3 code has been used in
some older computers because of its self-complementingproperty.
This is an unweighted code where each coded combination is obtained
from thecorresponding binary value plus 3. Note that the BCD code
is not self-complementing.The 8, 4, -2. -I code is an example of
assigning both positive and negative weights to a decimalcode. In
this case, the bit combination 0110 is interpreted as a decimal 2
and is calculatedfrom 8 X a + 4 X I + (-2) X I + (-1) X a = 2.The
output data of many physical systems produce quantities that are
continuous. These datamust be converted into digital form before
they are applied to a digital system. Continuous oranalog
information is converted into digital form by means of an
analog-to-digital converter.It is sometimes convenient to use the
Gray code shown in Table 1-6 to represent the digitaldata when it
is converted from analog data. The advantage of the Gray code over
the straightTable 1-5Four Different Binary Codes for the Decimal
Digits Table 1-6Gray CodeDecimal BCDdigit 8421 2421 Excess-3 B
4-2-1 Gray Decimalcode equivalenta 0000 0000 0011 a a a aI 0001
0001 0100 a I I I 0000 a2 0010 0010 0101 a I I a 0001 I3 0011 0011
0110 a 101 0011 24 0100 0100 0111 a 1 a a 0010 35 0101 1011 1000
101 I 0110 46 0110 1100 1001 I a I a 0111 57 0111 1101 1010 100 I
0101 68 1000 1110 1011 100 a 0100 79 1001 1111 1100 I I 1 1 1100
81101 91010 0101 0000 a a a I 1111 10Unused 1011 0110 0001 a a I a
1110 11bit 1100 0111 0010 a a I 1 1010 12combi- 1101 1000 1101 I I
a a 1011 13nations 1110 1001 1110 I 101 1001 141111 1010 1111 I I I
a 1000 15
12. 22 Chapter 1 Binary Systemsbinary number sequence is that
only one bit in the code group changes when going from onenumber to
the next. For example, in going from 7 to 8, the Gray code changes
from 01 00 to1100. Only the first bit changes from 0 to I; the
other three bits remain the same. When comparingthis with binary
numbers, the change from 7 to 8 will be from 0111 to 1000,
whichcauses all four bits to change values.The Gray code is used in
applications where the normal sequence of binary numbers mayproduce
an error or ambiguity during the transition from one number to the
next. If binarynumbers are used, a change from 0111 to 1000 may
produce an intermediate erroneous number1001 if the rightmost bit
takes longer to change in value than the other three bits. The
Graycode eliminates this problem since only one bit changes in
value during any transition betweentwo numbers.A typical
application of the Gray code occurs when analog data are
represented by continuouschange of a shaft position. The shaft is
partitioned into segments, and each segment is assigneda number. If
adjacent segments are made to correspond with the Gray-code
sequence,ambiguity is eliminated when detection is sensed in the
line that separates any two segments.ASCII Character CodeMany
applications of digital computers require the handling of data not
only of numbers, butalso of letters. For instance, an insurance
company with thousands of policy holders will usea computer to
process its files. To represent the names and other pertinent
information, it is necessaryto formulate a binary code for the
letters of the alphabet. In addition, the same binarycode must
represent numerals and special characters (such as $). An
alphanumeric characterset is a set of elements that includes the 10
decimal digits, the 26 letters of the alphabet, and anumber of
special characters. Such a set contains between 36 and 64 elements
if only capitalletters are included, or between 64 and 128 elements
if both. uppercase and lowercase lettersare included. In the first
case, we need a binary code of six bit..., and in the second, we
need abinary code of seven bits.The standard binary code for the
alphanumeric characters is ASCII (American StandardCode for
Information Interchange). It uses seven bits to code 128
characters, as shown inTable 1-7. The seven bits of the code are
designated by bl through b" with b, being the mostsignificantbit.
The letter A, for example, is represented in ASCII as 1000001
(column 100,row 0001). The ASCII code contains 94 graphic
characters that can be printed and 34 nonprintingcharacters used
for various control functions. The graphic characters consist of
the 26uppercase letters (A through Z), the 26 lowercase letters (a
through z), the 10 numerals (0through 9), and 32 special printable
characters such as %, *, and $.The 34 control characters are
designated in the ASCII table with abbreviated names. Theyare
listed again below the table with their functional names. The
control characters are used forrouting data and arranging the
printed text into a prescribed format. There are three types of
controlcharacters: format effectors, information separators, and
communication-control characters.Format effectors are characters
that control the layout of printing. They include the
familiartypewriter controls such as backspace (BS), horizontal
tabulation (HT), and carriage return(CR). Information separators
are used to separate the data into divisions such as paragraphs
andpages. They include characters such as record separator (RS) and
file separator (FS). The communication-control characters are
useful during the transmission of text between remote ter-Section
1-7 Binary Codes 23Table 1-7American Standard Code for Information
Interchange (ASCII),b7~jJ5b.b,b2 b, 000 001 010 011 100 101 110
1110000 NUL DLE SP 0 @ P P0001 SOH DCI I A Q a q0010 STX DC2 2 B R
b r0011 ETX DC3 # 3 C S c s0100 EOT DC4 $ 4 D T d0101 ENQ NAK % 5 E
U e u0110 ACK SYN & 6 F V f v0111 BEL ETB 7 0 W g w1000 BS CAN
8 QL) X h x1001 lIT EM 9 I Y Y1010 LF SUB * J Z j z1011 VT ESC + K
[ k1100 FF FS < LI1101 CR OS M ] m1Il0 SO RS > N II n1111 SI
US / ? 0 0 DELControl charactersNUL Null DLE Data-link escapeSOH
Start of heading DCI Device control 1STX Start of text DC2 Device
control 2ETX End of text DC3 Device control 3EOT End of
transmission DC4 Device control 4ENQ Enquiry NAK Negative
acknowledgeACK Acknowledge SYN Synchronous idleBEL Bell ETB
End-of-transmission blockBS Backspace CAN CancelHT Horizontal tab
EM End of mediumLF Line feed SUB SubstituteVT Vertical tab ESC
EscapeFF Form feed FS File separatorCR Carriage return OS Group
separatorSO Shift out RS Record separatorSI Shift in US Unit
separatorSP Space DEL Deleteminals. Examples of
communication-control characters are STX (start of text) and ETX
(endof text), which are used to frame a text message when
transmitted through telephone wires.ASCII is a 7-bit code, but most
computers manipulate an 8-bit quantity as a single unitcalled a
byte. Therefore, ASCII characters most oftep are stored one per
byte. The extra bit is
13. 24 Chapter 1 Binary Systems Section 1'8 Binary Storage and
Registers 25sometimes used for other purposes, depending on the
application. For example, some printersrecognize 8-bitASCII
characters with the most-significant bit set to O. Additional 128
8-bit characterswith the most-significant bit set to I are used for
other symbols such as the Greek alphabetor italic type
font.Error-Detecting CodeRegistersA register is a group of binary
cells. A register with n cells can store any discrete quantity
ofinformation that contains n bits. The state of a register is an
n-tup1e number of 1's and O's, witheach bit designating the state
of one cell in the register. The content of a register is a
functionof the interpretation given to the information stored in
it. Consider, for example, a 16-bit registerwith the following
content:To detect errors in data communication and processing, an
eighth bit is sometimes added to theASCII character to indicate its
parity. A parity bit is an extra bit included with a message to
makethe total number of 1's either even or odd. Consider the
following two characters and theireven and odd parity:BINARY
STORAGE AND REGISTERSThe binary information in a digital computer
must have a physical existence in some information-storage medium
for storing individual bits. A binary cell is a device that
possesses twostable states and is capable of storing one bit of
information. The inputto the cell receives excitationsignals that
set it to one of the two states. The output of the cell is a
physical quantitythat distinguishes between theCtwo states. The
infonnation stored in a cell is 1 when it is in onestable state and
0 when in the 9ther stable state.1100001111001001A register with 16
cells can be in one of 216 possible states. If one assumes that the
content ofthe register represents a binary integer, then the
register can store any binary number from 0to 216- I. For the
particular example shown, the content of the register is the binary
equivalentof the decimal number 50121. If it is assumed that the
register stores alphanumeric charactersof an eight-bit code, the
content of the register is any two meaningful characters. For
theASCll code with an even parity placed in the eighth
most-significant bit position, the registercontains the two
characters C (left eight bits) and I (right eight bits). On the
other hand, if oneinterprets the content of the register to be four
decimal digits represented by a four-bit code,the content of the
register is a four-digit decimal number. In the excess-3 code, the
registerholds the decimal number 9096. The content of the register
is meaningless in BCD because thebit combination 1100 is not
assigned to any decimal digit. From this example, it is clear that
aregister can store discrete elements of information and that the
same bit configuration may beinterpreted differently for different
types of data.Register TransferA digital system is characterized by
its registers and the components that perform data processing.A
register tranifer operation is a basic operation in digital
systems. It consists.of a transferof binary information from one
set of registers into another set of registers. The transfer maybe
direct from one register to another. or may pass through data
processing circuits to performan operation. Figure 1-1 illustrates
the transfer of the information among registers and
demonstratespictorially the transfer of binary information from a
keyboard into a register in the memoryunit. The input unit is
assumed to have a keyboard, a control circuit, and an input
register.Each time a key is struck, the control enters an
equivalent eight-bit alphanumeric charactercode into the input
register. We shall assume that the code used is the ASCll code with
an oddparitybit. The information from the input register is
transferred into the eight least significantcells of a processor
register. After every transfer, the input register is cleared to
enable the controlto insert a new eight-bit code when the keyboard
is struck again. Each eight-bit charactertransferred to the
processor register is preceded by a shift of the previous character
to the nexteight cells on its left. When a transfer of four
characters is completed, the processor register isfull, and its
contents are transferred into a memory register. The content stored
in the memoryregister shown in Fig. 1-1 came from the transfer of
the characters "J," "0," "H," and "N" afterthe four appropriate
keys were struck.To process discrete quantities of information in
binary form, a computer must be providedwith devices that hold the
data to be processed and circuit elements that manipulate
individualbits of information. The device most commonly used for
holding data is a register.With odd parity1100000101010100With even
parity0100000111010100ASCII A = 1000001ASCII T = 1010100In each
case, we insert an extra bit in the leftmost position of the code
to produce an even numberof I's in the character for even parity or
an odd number of I's in the character for oddparity. In general,
one or the other parity is adopted, with even parity being more
common.The parity bit is helpful in detecting errors during the
transmission of information from onelocation to another. This is
handled by generating an even parity bit in the sending end for
eachcharacter. The 8-bit characters that include parity bits are
transmitted to their destination. Theparity of each character is
then checked in the receiving end. If the parity of the received
characteris not even, it means that at least one bit has changed
value during the transmission. Thismethod detects one, three, or
any odd combination of errors in each character that is
transmitted.An even combination of errors is undetected. Additionar
error detection codes may beneeded to take care of an even
combination of errors.What is done after an error is detected
depends on the particular application. One possibilityis to request
retransmission of the message on the assumption that the errorwas
random andwill not occur again. Thus, if the receiver detects a
parity error, it sends back the ASCll NAK(negative acknowledge)
control character consisting of an even parity eight bits 10010101.
Ifno error is detected, the receiver sends back anACK (acknowledge)
control character, 00000110.The sending end will respond to an NAK
by transmitting the message again nntil the correctparity is
received. If, after a number of attempts, the transmission is still
in error, a message canbe sent to the operator to check for
malfunctions in the transmission path.1-8
14. Binary logic deals with variables that take on two discrete
values and operations that assumelogical meaning. The two values
the variables take may be called by different names (true andfalse,
yes and no, etc.), bnt for our purpose, it is convenient to think
in terms of bits and assignthe values of I and O. The binary logic
introduced in this section is equivalent to an algebra
calledBoolean algebra. The formal presentation of Boolean algebra
is covered in more detail in Chapter2. The purpose of this section
is to introduce Boolean algebra in a heuristic manner and relateit
to digital logic circnits and binary signals.Definition of Binary
LogicBinary logic consists of binary variables and logical
operations. The variables are designated byletters of the alphabet
snch as A, B, C, x, y, z, etc., with each variable having two and
only twodistinct possible values: I and O. There are three basic
logical operations: AND, OR, and NOT.26 Chapter 1 Binary
SystemsMEMORY UNITJ 0 H N I' :1
Memory01001010010011111100100011001110 RegisterPROCESSOR UNITI 8
cells 8 cells IProcessor8 cells 8 cells RegisterINPUT UNIT InputI 8
cells I Registert~IKeyboard I , CONTROLIFIGURE 1-1Transfer of
information with registersManipulation of binary variables is done
by means of digital logic circuits. Figure 1-2 illustratesthe
process of adding two lO-bit binary numbers. The memory unit, which
normally consistsof millions of registers, is shown in the diagram
with only three of its registers. The part of theprocessor unit
shown consists of three registers-RI, R2, and R3-together with
digital logiccircuits that manipulate the bits of RI and R2 and
transfer into R3 a binary number equal totheir arithmetic sum.
Memory registers store information and are incapable of processing
thetwo operands. However, the information stored in memory can be
transferred to processor registers.Results obtained in processor
registers can be transferred back into a memory registerfor storage
until needed again. The diagram shows the contents of two operands
transferred fromtwo memory registers into Rl and R2. The digital
logic circuits produce the sum, which istransferred to register R3.
The contents of R3 can now be transferred back to one of the
memoryregisters.The last two examples demonstrated the
information-flow capabilities of a digital system ina very simple
manner. The registers of the system are the basic elements for
storing and holdingthe binary information. Digital logic circuits
process the binary information stored in theregisters. Digital
logic circuits and registers are covered in Chapters 2 throngh 6.
The memoryunit is explained in Chapter 7. The register transfer
level for describing and designing digitalsystems is covered in
Chapter 8.Section 1-9 Binary LogicMEMORY UNIT.
10000000000SumOperand 1100111000011Ope~d ~IOOOIOOOOIO IL-~ 10 0 0 1
0000101 R11Digital Logiccircuits for ----+- 0 I 0 0 I 0 0 0 I Il
R3binary addition100 III 0 0 0 0 Il R2PROCESSOR UNITFIGURE
1-2Example of binary information processing1-9 BINARY LOGIC27,
j
15. 28 Chapter 1 Binary Systems Section 1-9 Binary Logic 29the
same as those llsed for multiplication and addition. However,
binary logic should not be confusedbinary arithmetic, we have 1 + I
= 10 (read: "one plus one is equal to 2"), whereas in binarybetween
the values that the variables may take and tbe result of the
operation. The truth tablesfor the operations AND and OR with
variables x and yare obtained by listing all possible
valuescombination is then listed in a separate row. The truth
tables for AND, OR, and NOT are listedLogic Gates1. AND: This
operation is represented by a dot or by the absence of an operator.
For example,x y ~ z or xy = z is read "x AND y is equal to z." The
logical operation AND is interpretedto mean that z = I if and only
if x = I and y ~ I; otherwise z = O. (Rememberthat x, y, and z are
binary variables and can be equal either to I or 0, and nothing
else.)2. OR: This operation is represented by a plus sign. For
example, x + y = z is read "xOR y is equal to z," meaning that z ~
I if x = lor if y = lor if both x ~ 1 and y = 1.If both x ~ 0 and y
= 0, then z = O.3. NOT: This operation is represented by a prime
(sometimes by an overbar). For example,x' ~ z (or ex = z) is read
"not x is equal to z," meaning that z is what x is not. In
otherwords, if x = 1, then z = 0; but if x = 0, then z = 1. The NOT
operation is also referredto as the complement operation, since it
changes a 1 to 0 and a 0 to 1.Binary logic resembles binary
arithmetic, and the operations AND and OR have similaritiesto
multiplication and addition, respectively. In fact, the symbols
used for AND and OR arewith binary arithmetic. One should realize
that an arithmetic variable designates a numberthat may consist of
many digits. A logic variable is always eitber 1 or O. For example,
inlogic, we have I + I ~ I (read: "one OR one is equal to one").For
each combination of the values of x and y, there is a value of z
specified by tbe definitionof the logical operation. These
definitions may be listed in a compact form using truth tables.A
truth table is a table of all possible combinations of the
variables sbowing tbe relationthat the variables may have when
combined in pairs. The result of the operation for eachin Table
1-8. These tables clearly demonstrate the definition of the
operations.Logic gates are electronic circuits that operate on one
or more input signals to produce an outputsignal. Electrical
signals such as voltages or currents exist throughout a digital
system ineither of two recognizable values. Voltage-operated
circuits respond to two separate voltage levelsthat represent a
binary variable equal to logic I or logic O. For example, a
particular digitalsystem may define logic 0 as a signal equal to 0
volt and logic I as a signal equal to 4 volts.In practice, each
voltage tevel has an acceptable range as shown in Fig. 1-3. The
input terminalsof digital circuits accept binary signals within the
allowable range and respond at the outputterminals with binary
signals that fall within the specified range. The intermediate
regionbetween the allowed regions is crossed only during state
transition. Any desired informationfor computing or control can be
operated on by passing binary signals through various
combinationsof logic gates with each signal representing a
particular binary variable.The graphic symbols used to designate
the three types of gates are shown in Fig. 1-4. Thegates are blocks
of hardware that produce the equivalent of logic 1 or logic 0
output signals ifinput logic requirements are satisfied. The input
signals x and y in theAND and OR gates mayexist in one offom
possible states: 00, 10, 11, or 01. These input signals are shown
in Fig. 1-5together with the corresponding output signal for each
gate. The timing diagrams illustrate theresponse of each gate to
the four input signal combinations. The horizontal axis of the
timingRangefor logic-lRangefor logic-OVolts431oFIGURE 1-3Example of
binary signalsTransition occursbetween these limits;~ ;~Y
X---[>---X'(a) Two-input AND gate (b) Two-input OR gate (c) NOT
gate or inverterFIGURE 1-4Symbols for digital logic circuitsTable
1-8Truth Tables of Logical OperationsAND OR NOTx y X'y x Y x+y 0 0
0 0 0 0 iott10 1 0 0 1 1 1 01 0 0 1 0 11 I 1 1 1 1
16. 30 Chapter 1 Binary Systems Problems 311
01---",o,-------,o,,---11l yOR:x+y~NOT: x' ~ I 1 1FIGURE
1-5Input-output signals for gatesdiagram represents time and the
vertical axis shows the signal as it changes between the
twopossible voltage levels. The low level represents logic 0 and
the high level represents logic 1.The AND gate responds with a
logic I output signal when both input signals are logic 1. TheOR
gate responds with logic I output signal if any input signal is
logic 1. The NOT gate iscommonly referred to. as an inverter. The
reason for this name is apparent from the signal responsein the
timing diagram, where it is shown that the output signal inverts
the logic senseof the input signal.AND and OR gates may have more
than two inputs. AnAND gate with three inpnts and anOR gate with
four inputs are shown in Fig. 1-6. The three-inputAND gate responds
with logicI outpnt if all three inpnts are logic I. The output
produces logic 0 if any input is logic O. Thefour-input OR gate
responds with logic I if any input is logic I; its output becomes
logic 0 onlywhen all inputs are logic O.List the octal and
hexadecimal numbers from 16 to 32. Using A and B for the last two
digits, listthe numbers from 10 to 26 in base 12.What is the exact
number of bytes in a system that contains (a) 32K byte, (b) 64M
bytes, and(c) 6.4G byte?What is the largest binary number that can
be expressed with 12 bits? What is the equivalent decimaland
hexadecimal?Convert the following numbers with the indicated bases
to decimal: (4310)5' and (198)12'q 1-5 Determine the base of the
numbers in each case for the following operations to be
correct:---"'- (a) 14/2 ~ 5; (b) 54/4 ~ 13, (c) 24 + 17 ~ 40.1-6
The solution to the quadratic equation x2 ~ llx + 22 = 0 is x = 3
and x = 6. What is the base1-91-101-11of the numbers?Express tbe
following numbers in decimal: (10110.0101)', (16.5)16' and
(26.24)g.Convert the following binary numbers to hexadecimal and to
decimal: (a) 1.11010, (b) 1110.10.Explain why the decimal answer in
(b) is 8 times that of (a).Convert the hexadecimal number 68BE to
binary and then from binary convert it to octal.Convert the decimal
number 345 to binary in two ways: (a) convert directly to binary;
(b) convertfirst to hexadecimal, then from hexadecimal to binary.
Which method is faster?Do the following conversion problems:(a)
Convert decimal 34.4375 to binary.(b) Calculate the binary
equivalent of 1/3 out to 8 places. Then convert from binary to
decimal.How close is the result to 1/3?(c) Convert the binary
result in (b) into hexadecimal. Then convert the result to decimal.
Is theanswer the same?1-12 Add and multiply the following numbers
without converting them to decimal.(a) Binary numbers 1011 and
IOJ.(b) Hexadecimal numbers 2E and 34.1-13 Perform tbe following
division in binary: 1011111 + IOJ.1-14 Find the 9's- and the
10's-complement of the following decimal numbers:(a) 98127634 (b)
72049900 (c) 10000000 (d) 00000000.1-15 (a) Find the
16's-complement ofAF3B.(b) Convert AF3B to binary.(c) Find the
2's-complement of the result in (b).(d) Convert the answer in (c)
to hexadecimal and compare with the answer in (a).~ 1-16 Obtain the
l's and 2's complements of the following binary numbers:(a)
11101010 (b) 01111110 (c) 00000001 (d) 10000000 (e)
00000000.1-71-81-17 Perform subtraction on the following unsigned
numbers using the 10's-complement of the subtrahend.Where the
result should be negative, lO's complement it and affix a minus
sign. Verifyyour answers.(a) 7188 - 3049 (b) 150 - 2100 (c) 2997 -
7992 (d) 1321 - 375~ 1-18 Perform subtraction on the following
unsigned binary numbers using the 2's-complement of thesubtrahend.
Where the result should be negative, 2's complement it and affix a
minus sign.(a) 11011 - 11001 (b) 110100 - 10101 (c) 1011 - 110000
(d) 101010 - 1010111-19 The following decimal numbers are shown in
sign-magnitude fonn: +9826 and +801. Convertthem to signed
1O's-complement form and perfOITIl the following operations: (Note
that the sumis + 10627 and requires six digits).(a) (+9826) +
(+801) (b) (+9826) + (-801)(c) (-9826) + (+801) (d) (-9826) +
(-801)1-20 Convert decimal +61 and +27 to binary using the
signed-2's complement representation andenough digits to accomodate
the numbers. Then perform the binary equivalent of (+27) +
(-61),(-27) + (+61) and (-27) + (-61). Convert tbe answers back to
decimal and verify that tbeyare correct.1 ~1f~+B+C+D(b) Four-input
OR gatexAND: x . y~~BC(a) Three-input AND gateFIGURE 1-6Gates with
multiple inputsPROBLEMS1-11-21-4
17. Boolean Algebraand Logic Gates332-1 BAS leD EFIN I T ION
SBoolean algebra, like any other deductive mathematical system, may
be defined with a set ofelements, a set of operators, and a number
of unproved axioms or postulates. A set of elementsis any
collection of objects having a common property. If S is a set, and
x and yare certain objects,then XES denotes that x is a member of
the set, S, and y
18. erties of bistable electlical switching circuits can be
represented by this algebra. For the formaldefinition of Booleau
algebra, we shall employ the postulates formulated by E. V.
Huntingtonin 1904.Boolean algebra is an algebraic structure defined
by a set of elements, B, together with twobinary operators, +and,
provided that the following (Huntington) postulates are
satisfied:1. (a) Closure with respect to the operator +.(b) Closure
with respect to the operator'.2. (a) An identity element with
respect to +, designated by 0: x + 0 = 0 + x = x.(b) An identity
element with respect to " designated by I: x . I = I x ~ x.3. (a)
Commutative with respect to +: x + y ~ y + x.(b) Commutative with
respect to : x . y = y x.4. (a) . is distributive over +: x . (y +
z) = (x' y) + (x' z).(b) + is distributive over': x + (Y' z) = (x +
y) . (x + z).5. For every element x E B, there exists an element Xl
E B (called the complement of x)such that (a) x + x' = I and (b) x
. x' = O.6. There exists at least two elements x, y E B such that x
'" y.Comparing Boolean algebra with arithmetic and ordinary algebra
(the field of real numbers),we note the following differences:1.
Huntington postulates do not include the associative law. However,
this law holds forBoolean algebra and can be derived (for both
operators) from the other postulates.2. The distributive law of +
over', i.e., x + (Y' z) = (x + y) (x + z), is valid forBoolean
algebra, but not for ordinary algebra.3. Boolean algebra does not
have additive or multiplicative inverses; therefore, there areno
subtraction or division operations.4. Postulate 5 defines an
operator called complement that is not available iu ordinary
algebra.5. Ordinary algebra deals with the real numbers, whicb
consitute an infinite set of elements.Boolean algebra deals with
the as yet undefined set of elements, B, but in the
two-valuedBoolean algebra defined next (and of interest in our
subsequent use of this algebra),B is defined as a set with only two
elements, 0 and 1.Boolean algebra resembles ordinary algebra in
some respects. The choice of symbols + and is intentional to
facilitate Boolean algebraic manipulations by persons already
familiar withordinary algebra. Although one can use some knowledge
from ordinary algebra to deal withBoolean algebra, the beginner
must be careful not to substitute the rules of ordinary
algebrawhere they are not applicable.It is important to distinguish
between the elements of the set of an algebraic structure andthe
variables of an algebraic system. For example, the elements of the
field of real numbers arenumbers, whereas variables such as a, b,
c, etc., used in ordinary algebra, are symbols thatstand for real
numbers. Similarly, in Boolean algebra, one defines the elemeuts of
the set B, andvariables such as x, y, and z are merely symbols that
represent the elements. At this point, it isimportant to realize
that in order to have a Boolean algebra, one must show:342-2Chapter
2 Boolean Algebra and Logic Gates3. Commutative law. A binary
operator * on a set S is said to be commutative wheneverx * y = y *
x for all x, yES4. Identity element. A set S is said to have an
identity element with respect to a binary operation* on S if there
exists an element e E S with the propertye*x = x*e = x for every
XESExample: The element 0 is an identity element with respect to
the operation + on the setof integers I = { ... ,-3,-2,-1,0, 1,2,
3, ... }, sincex + 0 = 0 + x = x for any x E IThe set of natural
numbers, N, has no identity element since 0 is excluded from the
set.5. Inverse. A set S having the identity element e with respect
to a binary operator * is saidto have an inverse whenever, for
every XES, there exists an element yES such thatx * y = eExample:
In the set of integers, I, with e = 0, the inverse of an element a
is (-a)since a + (-a) = O.6. Distributive law. If * and are two
binary operators on a set S, * is said to be distributiveover'
wheneverx* (Y' z) = (x*y) (x*z)An example of an algebraic structure
is afield. A field is a set of elements, together with twobinary
operators, each having properties I throngh 5, and both operators
combined to giveproperty 6. The set of real numbers, together with
the binary operators + and " form the fieldof real numbers. The
field of real numbers is the basis for arithmetic and ordinary
algebra. Theoperators and postulates have the following
meanings:The binary operator +defines addition.The additive
identity is O.The additive inverse defines subtraction.The binary
operator' defines multiplication.The multiplicative identity is
1.The multiplicative inverse of a = I/a defines division, i.e., a
1/a ~ 1.The only distributive law applicable is that of . over +:a'
(b + c) = (a' b) + (a' c)AXIOMATIC DEFINITIONOF BOOLEAN ALGEBRAIn
1854 George Boole introduced a systematic treatment of logic and
developed for this purposean algebraic system now called Boolean
algebra. In 1938 C. E. Shannon introduced atwo-valued Boolean
algebra called switching algebra, iU which he demonstrated that the
prop-Section 2-2 Axiomatic Definition of Boolean Algebra 35
19. 36 Chapter 2 Boolean Algebra and Logic Gates1. the elements
of the set B,2. the rules of operation for the two binary
operators, and3. that the set of elements, B, together with the two
operators, satisfies the six Huntingtonpostulates.One can formulate
many Boolean algebras, depending on the choice of elements of
Bandthe mles of operation. In our subsequent work, we deal only
with a two-valuedBoolean algebra,i.e., one with only two elements.
Two-valued Boolean algebra has appl~catlOns III ~et t~eory(the
algebra of classes) and in propositional logic. Our interest here
is wlth the apphcatlOnof Boolean algebra to gate-type
circuits.Two-Valued Boolean AlgebraA two-valued Boolean algebra is
defined on a set of two elements, B = {O, I}, with rules forthe two
binary operators + and, as shown in the following operator tables
(the mle for thecomplement operator is for verification of
postulate 5):Section 2-3 Basic Theorems and Properties of Boolean
Algebra2-3 BAS leT H EO REM SAN D PRO PERTIE SOF BOOLEAN
ALGEBRADuality37x'Y x,z (x . y) + (x . z)0 0 00 0 00 0 00 0 00 0 00
1 11 0 11 1 1x y z y+z x' (y + z)0 0 0 0 00 0 1 I 00 I 0 1 00 1 I 1
01 0 0 0 0I 0 1 I 11 1 0 1 11 1 1 1 1(b) The distributive law of +
over' can be shown to hold true by means of a truth tablesimilar to
the one above.S. From the complement table, it is easily shown
that(a) x + x' ~ I, since 0 + 0' ~ 0 + I = I and I + I' ~ I + 0 =
1.(b) x . x' = 0, since 0 . 0' = O' I = 0 and I . I' = I . 0 .= 0,
which verifies postulate5.6. Postulate 6 is satisfied because the
two-valued Boolean algebra has two distinct elements,I and 0, with
I '" O.We have just established a two-valued Boolean algebra having
a set of two elements, I and0, two binary operators with operation
rules equivalent to the AND and OR operations, and acomplement
operator equivalent to the NOT operator. Thus, Boolean algebra has
been definedin a formal mathematical manner and has been shown to
be equivalent to the binary logic presentedheuristically in Section
1-9. The heuristic presentation is helpful in understauding
theapplication of Boolean algebra to gate-type circuits. The formal
preseutation is necessary fordeveloping the theorems and properties
of the algebraic system. The two-valued Boolean algebradefined in
this section is also called "switching algebra" by engineers. To
emphasize thesimilarities between two-valued Boolean algebra and
other binary systems, this algebra wascalled "binary logic" in
Section 1-9. From here on, we shall drop the adjective
"two-valued"from Boolean algebra in subsequent discussions.The
Huntington postulates have been listed in pairs and designated by
part (a) and part (b). Onepart may be obtained from the other if
the bimuy operators and the identity elements are interchanged.This
important property of Boolean algebra is called the duality
principle. It statesthat every algebraic expression deducible from
the postulates of Boolean algebra remains validif the operators and
identity elements are interchanged. In a two-valued Boolean'
algebra, theidentity elements and the elemeuts of the set, B, are
the same: I and O. The duality principlex y x'Y x Y x+y x x'0 0 0 0
0 0 0 I0 I 0 0 1 1 t 01 0 0 1 0 11 1 1 1 1 1These rules are exactly
the same as the AND, OR, and NOT operations, respectively,
definedin Table 1-8. We must now show that the Huntington
postulates are valid for the set B = {O, I}and the two binary
operators defined before.1. Closure is obvious from the tables
since the result of each operation is either 1 or 0andl,OEB.2. From
the tables, we see that(a) 0 + 0 ~ 0 0 + I = I + 0 = I;(b) I . I =
I I . 0 ~ O' I = O.This establishes the two identity elements, 0
for + and I for ., as defined by postulate 2.3. The com~utativelaws
are obvious from the symmetry of the binary operator tables.4. (a)
Thedistributivelawx'(Y + z) = (xy) +
(x'z)canbeshowntoholdtruefromthe operator tables by formiug a tmth
table of all possible values of x, y, and z Foreach combination, we
derive x . (y + z) and show that the value IS the same as(xy) +
(xz).
20. 38 Chapter 2 Boolean Algebra and Logic GatesSection 2-3
Basic Theorems and Properties of Boolean Algebra 39has many
applications. If the dual of an algebraic expression is desired, we
simply interchangeOR and AND operators and replace I's by O's and
O's by I's.. Note that theorem I (b) is the dual of theorem l(a)
and that each step of the proof in part (b)IS the dual of part (a).
Any dual theorem can be similarly derived from the proof of its
carre.sponding pair.Basic TheoremsTable 2-1 lists six theorems of
Boolean algebra and four of its postulates. The notation is
simplifiedby omitting the binary operator whenever this does not
lead to confusion. The theoremsand postulates listed are the most
basic relationships in Boolean algebra. The theorems, like
thepostulates, are listed in pairs; each relation is the dual of
the one paired with it. The posmlatesare basic axioms of the
algebraic structure and need no proof. The theorems must be
provenfrom the postulates. The proofs of the theorems with one
variable are presented below. At theright is listed the number of
the postulate that justifies each step of the proof.THEOREM 1(a): x
+ x = x.=x+O=xby postulate: 2(b)5(a)4(b)2(b)5(a)THEOREM 3: (x')' =
x. From postulate 5, we have x + x' = I and x . x' = 0, which
definesthe complement ofx. The complement ofx' is x and is also
(x')'. Therefore, since the ComplementThe theorems iuvolving two or
three variables may be proven algebraically from the postulatesand
the theorems that have already been proven. Take, for example, the
absorption theorem.THEOREM 6(a): x + xy = x.by postulate:
2(b)4(a)3(a)2(a)2(b)THEOREM 2(a): x + 1 = 1.x + I = I . (x + I)=(x
+ x')(x + I)= x + x' 1= x + x'= 1THEOREM 2(b): x 0 = 0 by
dUality.IS umque, we have that (x')' = x.x+xy=x'l+xy= x(l + y)= x(y
+ I)~ x Ix V xV x + xV0 0 0 00 1 0 01 0 0 11 1 1 1=xTHEOREM 6(b):
x(x + y) = xby duality.The theorems of Boolean algebra can be shown
to hold true by means of truth tables. In truthtables, both sides
ofthe relation are checked to yield identical results for all
possible combinatIOnsof vanables Involved. The following truth
table verifies the first absorption theorem.IiIIiIby postulate:
2(b)5(a)4(b)5(b)2(a)by posmlate: 2(a)5(b)4(a)5(a)2(b)Cb) x 1 -xCbl
x . x' ~ 0Cb) x x = xCb) x . 0 ~ 0(b) xy = yxCb) x(yz) ~ (xy)zCb) x
+ yz ~ (x + y)(x + z)(b) (xy)' = x' + y'Cb) x(x + y) ~ xTHEOREM
l(b): x x = x.xx=xx+O=xx+xx'(a) x + 0 = xCal x + x' ~ 1Ca) x + x ~
xCa) x + 1 = 1(x')' ~ xCal x + y ~ y + x .Ca) x + (y + z) = (x +y)
+ zCa) x(y + z) ~ xy + xzCa) (x + y)' = x'y'Ca) x + xy ~ xPostulate
2Postulate 5Theorem 1Theorem 2Theorem 3, involutionPostulate 3,
commutativeTheorem 4, associativePostulate 4, distributiveTheorem
5, DeMorganTheorem 6, absorptionx + x = (x + x) 1= (x + x)(x + x')=
x + XXi= x(x + x')= x ITable 21Postulates and Theorems of Boolean
Algebra
21.
.1!I!__]I!!!!"o!!!!!!~!!!I!!!!!!!!!!I!!!!!!!!!!!!!!!!!!!!!I!!!!!!I!I
_40 Chapter 2 Boolean Algebra and Logic GatesThe algebraic proofs
of the associative law and DeMorgan's theorem are long and will not
beshown here. However, their validity is easily shown with truth
tables. For example, the truth tablefor the first DeMorgan's
theorem (x + y)' = x'y' is shown below.Section 2-4 Boolean
Functions 41Table 2-2Truth Tables for F, and F2x y z F, F.0 0 0 0
00 0 1 1 10 1 0 0 00 1 1 0 11 0 0 1 11 0 1 1 11 1 0 1 01 1 1 1 0x--
---y-----) >0----1z ---_-----''---__-1FIGURE 2-1Gate
implementation of F, ~ x + y' ztions. The table shows that the
function is equal to I when x = 1 or when yz = 01. It is equalto 0
otherwise.A Boolean function can be transformed from an algebraic
expression into a circuit diagramcomposed of logic gates. The
logic-circuit diagram for F, is shown in Fig. 2-1. There is an
inverterfor input y to generate the complement. There is anAND gate
for the term y'z and an ORgate that combines the two terms. In
logic-circuit diagrams, the variables of the function aretaken as
the inputs of the circnit and the binary variable FJ is taken as
the output of the circuit.There is only one way that a Boolean
function can be represented in a truth table. However,when the
function is in algebraic form, it can be expressed in a variety of
ways. The particularexpresslOn used to designate the function will
also dictate the interconnection of gatesin the logic circuit
diagram. By manipulating a Boolean expression according to Boolean
algebrarules, it is sometimes possible to obtain a simpler
expression for the same function andthus reduce the number of gates
in the circuit and the number of inputs to the gate. Considerfor
example the following Boolean function:F2 = x'y'Z + x'YZ + xy'The
implementation of this function with logic gates is shown in Fig.
2-2(a). Input variables xand yare complemented with inverters to
obtain x' and y'. The three terms in the expressionare implemented
with three AND gates. The OR gate forms the logical OR of the three
terms.The truth table for F, is listed in Table 2-2. The function
is equal to 1 when xyz = 001 or 011x' y' x'y'1 1 11 0 00 1 00 0 0x
y x+y (x + y)'0 0 0 10 1 1 01 0 1 01 1 1 0Operator PrecedenceThe
operator precedence for evaluating Boolean expressions is (1)
parentheses, (2) NOT, (3)AND, and (4) OR. In other words, the
expression inside the parentheses must be evaluated beforeall other
operations. The next operation that holds precedence is the
complement, then followsthe AND, and finally the OR. As an example,
consider the truth table for DeMorgan'stheorem. The left side of
the expre