chapter 01 - mano

35
: Chapter 1 ,':Olgltal System $ and' Binary Numbers DIGITAL SYSTEMS Digitalsysteins have .such a prominent role in everyday life that we refer tot,pe present tech- nological poriod as the digital age. 'Digital systems are used in business trans..: actions, traffic control. space guidance, m¢ical't1'eIitirient, weather monitoring. the Internet, and many other commercial. industrial. and scientific enterprises. Wihave digitat telephones"dig- ital television. digital vel:satile discs. digital cameras, handheld cOurse, digi- '. tal computers. The most striking prciperty of the digital computer is its generality. It can follow asequence of instrllctions, called a program, that operates on given da,ta.The user can specify andcbange the program or the data according to the specific need..Because of thisfiexibility, digital coniputers can perform a variety of information-processing, tasks that , range over a Wide spectrUm o( applications. . , ' ,', . One characteristic of digital systems is their ability'to represent and manipulate discrete el- ements of information. Any set lhat is restricted to a finite numbei' of elements contains dis- . crete information. Exmq>les of discrete sets are the 10 deeimaldigits, the 26lettets ofthe' alphabet. the 52 playing cards. and the 64 squares of a cheSSboard.' Early digital computers . , were used for numeric computations. In this case. the discrete elements were the digits. From this application,· the term digital computer emerged. Discrete elements of infonnation are rep- resented in a digital system by physical quan#ties·.called signals..Electrical signals such as voltilgesand currents are the most commort. Electronic devices called transistors predominate ' . in the circUitry that implements these. signals. The.signals in most electronic dig- ital systems use just tWQ diScrete values aDd are. therefore said to binary. A binary digit,' called a bit, has two values:.O and 1. Discrete elements of information are repreSented with groups of bits called binary .colks. For example. the decimal digits 0 through 9 are repre,sented in a digital system with a of f()ur bits (e.g., the number 7 is represented by. 0111). . -" 1

Upload: jessie-brian-unabia-revil

Post on 26-Oct-2014

120 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Chapter 01 - Mano

Chapter 1

Olgltal System$ and Binary Numbers

DIGITAL SYSTEMS

Digitalsysteins have such a prominent role in everyday life that we refer totpe present techshynological poriod as the digital age Digital systems are used in ~omm~Jion business trans actions traffic control space guidance mcenticalt1eIitirient weather monitoring the Internet and many other commercial industrial and scientific enterprises Wihave digitat telephonesdigshyital television digital velsatile discs digital cameras handheld devi~sandof cOurse digishy

tal computers The most striking prciperty of the digital computer is its generality It can follow asequence of instrllctions called a program that operates on given dataThe user can specify andcbange the program or the data according to the specific needBecause of thisfiexibility genqi1-lgt~ digital coniputers can perform a variety of information-processing tasks that

range over a Wide spectrUm o(applications One characteristic of digital systems is their abilityto represent and manipulate discrete elshy

ements of information Any set lhat is restricted to a finite numbei of elements contains disshy crete information Exmqgtles of discrete sets are the 10 deeimaldigits the 26lettets ofthe alphabet the 52 playing cards and the 64 squares ofa cheSSboardEarly digital computers

were used for numeric computations In this case the discrete elements were the digits From this applicationmiddotthe term digital computer emerged Discrete elements of infonnation are repshyresented in a digital system by physical quantiesmiddotcalled signals Electrical signals such as voltilgesand currents are the most commort Electronic devices called transistors predominate in the circUitry that implements these signals Thesignals in most present~y electronic digshyital systems use just tWQ diScrete values aDd are therefore said to ~ binary A binary digit called a bit has two valuesO and 1 Discrete elements of information are repreSented with groups of bits called binary colks For example the decimal digits 0 through 9 are represented in a digital system with a ~ode of f()ur bits (eg the number 7 is represented by 0111)

-

1

2 Chapter 1 Drgital Systems and BI~ry Numbers

ThrouJb various techniques groups of bits can ~ made to represent discrete symbols wbicb aretilen u~ to develop the sys~m in a digitAl fonnat Thus a digital system isi systemtbat manipul8lescijacrete ~lerrients of infonnati~~entelaquolWern~Y Inhinary form

Di$cretequantities of information either eilierge frOrri the nature of the data being processed orinau be quampnlized from a continuous process On the one hand a payroll scbedule iun inshyherently discrete process that contains employee names social security numbers weekly salaries income taxes and so on An employees paycheck is processed by means ofdiscrete data values such as letters of the alphfJbet (n_s)~ digits (slilary) and special symbols (such as $) On die other handa research scientist may observe a continuous processbut record only specific quantities in tabUlar fonn Thescientist is thus quantizing continuous data makshying each number iithis or hertaQlea discrete quantity In many cases the quantization ofa process can be performed automatically by an analog~to-digitalconvetter

The general-p~se digital computer is the best-known example of a digital system The major parts ola computer are a memory unit a central processing unit and inputoutput units~ The memory unit stores programs as well as input output andintermediate data Th~ central processing unit performs arithmetic and other data~processingoperations as specified by the program The program and data prepared by a user arefranSferred into memory by means of an input device such as a keyboard An output device such as a printer receives the results of the computations and the printed results are presentedto the user A digital computer canacshycommodate many input and output devices One very uSeful devicemiddot is a oonuiiunication unit that provides interaction with Qther users through the lnternet A digital computer is a powermiddot ful instrument that canperfonn nOt onlyarlthmetic computations but alsological operatiQns In addition it ~an be pro~~ to makedeciyenot1s bllsedon internal and e~temal cOndipons ~ are fbndalDental reasons thatcommereialproducts are made with digital circuits

Like I diSital compUter mostwgibU devi~sare progralnmable By chimging the program in i a programmable device the same underlying hardware can beuSlaquol for many different applishycationsDramatic cost reductions in digital devices have come about because of advances

digital integrated circuit tlaquohnology As the number of fransistorsthat can be put on a piece silicon increasesto produce complex functions the cost per unit decreases and digital devices can bcj b9ught at an increasingly reduced price Equipment built with digital integrated cir~ cuits Clm pCnorm at a speed 6fhun~s ofmillions of operations pet second Digital systems can bem~e to operate with extreme reliabilitybyusingerrorcorrecting codes An ofthis stIlltegy is the digital versatile disk (DVD) bull in which digital in(ormation repJreSentiJilg video audio 8n4 other data is recorded withoQt the loss ofa single itemDigital iru(nnati(Jn

oJiaDVD isrecotded in such a way that by examining the cOCte in each digital sample it is played back any error can be automaticaHy identified and corrected

Adigital ~ystem isanin~rconnection of digitalmoduies T~understand the operation eacb digital module it is necessary to liave a basic knowledgeof digital circuits and cal~ctiQnThe fifstseven chap~rs ofthis book present thebllsictQO~ofdigital design as logic gate strlCtUles Combinational and Seq1iendal circuits and programmable logiC VI

Chapter 8 introduces digital design atthe register ~sfer leel (RTL) Cha~ 9 and 10 vitbasyDchronous sequeriti8t cinlUts and~various integnrted digitallogicfami~ies~_ II and 12mtrOdijce cOlllDlemal integratedClrcuitsandshow how they can be connected labqratory to perform experiments with digital circuits

3 Section 12 BinarymiddotNumbers

A major trend in digital design methodology is the use ofa hardware description language (HDL) to de~ribeand simulate the function8llty ofa digital cinuit AnHDL resembles a proshygramming language and is suitable for describing digital circuits iDtextual fOrinmiddot It is used to simulate a digital system to verify its operation before bardwlUe is built in It is also used in conjunction with logic synthesis tools to automate the design PrQCesSmiddotBecause it is important that students becom~ familiar with an HDL-baseddesign methodology HDLdescriptions of digital circuits arepiesented iliroughdut the book While these examples help illustrate the feashytures ofan HDL theyalso demonstrate the best practices used by industry to exploilHDLs Ignorance of these practices will lead to cute but worthlessHDL models that may simulate a phenomenon but that canno~ be synthesized by design tools or to models that waste silicon area or synthesiZe to hardware that cannot operate correCtly

AB prevjously s~ted digital systems Qlanipulate discrete qllantities of information that are represented in binary form Operands used for calcU11tions may bJ eltpressed in the binary number system Other discrete elements including the decimal digits are represented in binary codes Digital circuits also referred to as logic circUits proces~ data by means of binary logic elements (logic gates)using binary signals Quantities are stored il1 binary (two-valued) stor- age elements (t1i~t1ops) The purpOse ofthis chapter islo introduce the various binary con~ cepts as a frame ofrcferenceforfurther study in the succeeding chapters

-

A decimal number such as 7392 represents a quantity equal to 7 thousaadsplu8 3 bunltlryens plUl 9 tens plus 2 units The thousands bundred$ etc are powers of Hlirnplied by the posi tion Ofthe coefficients in the number To be moreeltact 1392 is ashtmhai1d notation for what should Dewrinen as

7 x 10f+ 3 x middotmiddot1Q2 + 9 X 101 + 2 x 1O

However tqe convention is to write only the coefficients and fromdJeitpoSltiori deduce the bullnecessary powers 000 In general a number with a decimal point is repres~nted by a series of coefficients

a504a3a2afaO a_I a-20-3

The coe(ficients ajareanyofthe 10 digt~ (012 ~ 9)andthe$ubscript valuej gives the place value and-hence the power of 10 by which the coefficient m~t be multiplied Th~ ttte preceding decimal number cltn be expressed as

lo5a5 + 104a4 + 103a3 + 102~2 + 10Iai + 10deg00 + lO-la~1 + 1O2a~2 + 1O-3a_3

The decimal nQmber systeirt is~aidto be of basf -or radix 1Qbecause it uses 1 0 digits and ttiecOefficients are multiplied by powers of 10 The binarysystemis a differentoumber sysshytem The coefficients ofthe binary number systemh~veonltw~ possible values 0 middotand 1 Each coefficient aiismultipli~d by2i and ~e results are adQedto ~tain tbcdecimalequivshy

alent of the number The radix pUint (~gbull the decinwpoitlt when lOistherlWix) distinguishes positive powers of10 frofl negative powers of 10 For ~ple the ltkclmlil equivalent of the

-- - - - - - -

4 Ch~pter 1 Digital Systems andBlnary Numbers

binary number 1101011 is 2675 as shown from the multiplication ofthe coefficients by powshyersoH

1 X24+1 XZ3 +0 x22 + 1 X 21 + 0 X2deg +1 xri + 1 X r 2 = 2675~ In general a number expressed in ~ base-r systeIri has coefficients m~ltiplied by powers of r

anrn + an-l 71-1 + +a22 + alr +06 + a-I r-1

+ a_~r-2 + + q_mr-m

The coeffici~nts a j range ip value from 0 to 1 To distinguish between numbers of differshymiddot ent baseswe enclose the coefficients in parentheses and Vrite asubscripteqOal to the base used (exceptsometime~ fot decimal nwnlers where the content makes it obvious that the base is decimal) An example ofabaseS numlgteris

(40212)s ~ 4Xs3 -I- 0 XS2+ 2 51 + IX 5deg + 2 X 5-1 == 5114ho

The cOefficient values for base 5 can be only 0 I 2 3 and 4 The octal mllnber system is a base-8 system that has eight digi~ 0 1234 5 6 1~ An example of an octal number is 1274 To determine its equivalent decimal value we expand the nlim6er in apower series witba base of8

(1274)8 = 1 X 82 + 2x 81 + 7X SO+4 x g-l==(S75)lO

Note that the digits 8 and 9 cannot appearin an oCtal number Itis customary to borrow the needed digits forthe coefficients from tlle decimal system

when the base of thenmnber i~ less than lO The letters ofthe alphabet reusedto supplement the 10 decimal digits when ~ base of the number is ~than 10 For example inthe

middot hexadecimal(base-16) number systemthe fIrst 10 digits are borrowed fro1ll the decimaJ sysshytem ~ letters A BCD~E and F are used for thedigits 10 n 12 13bull 14 and 15 respec~ tively An exampICf ofa hexadecimar number is

(B65Fh6 = 11 X 163 + 6gtX 162 + 5X 161 -+ 15 X 16deg =(~~687ho

As noted before the digits in lJ binary number are called bits When a bit is equal to 0 it does not contribute to the sum during the conversion Therefore the conversion from binary to decshymiddot imal can be obtained by addingonly the numbers With powersofctwo cotreSpOnding to the bits

that are equal to lForexample

(1l0101h = 32+ 16 +4+ 1 = 53)10

There are jour ls in the binwy number The corre~pondil1g decimal number is the sum of the four powers of two Thefirst 24 numbersobtaiJted from 2 to tJl(~ power of n are listed in bull Table 11 In computerwork 210 is referred to as K (kilo) 220 as M (mega) 230 asG (giga) and 240 as T (tera)Thus 4K = 212 4096 and 16M 224 = 16777216 Computer cashy~City is us1ial1y given inbyte$ A byte is equal to eight biis arid call ~onuriodal (ie represhysent the code of) onekeyboard character A computer hard disk with four gigabytesof storage

has a capacity of 4G = 232 brtes (approximately 4 billion bytes)

Section 13 ffumb~r-BaSetonver5iotls S

Table 11 Powers of Two

~ n 1 n Z n Z

0 1 8 middotmiddot256 16 65536 1 2 middot9 512 17 131072 2 4 10 1024 18 262144 3 amp 11 2048 f9 524288 4 16 12 4096 20 1048516

5 32 13 8192 21 2097152 6 64 14 1(i3amp4 22 4194304 7 128 15 32768 23 8388608

Arithmetic operations with numbers in base followtht same rules as for decimal nun1- hers When a base othef than the fariilliar base 10 is used one must becarefuho use only the -allowable digits~amples of~di~on subtraction and multipliCation oftwo binary numshybers are asfoUows

augend 101101 nlinuend 101101 multiplicand 1011

addend +100111 subtrahend -tOOtH multiplier XIOI sum 1010100 difference 000110 1011

0000 1011

product HOli

The sum oftwo binaiy numbers is calculated bY the sam~ rules as in decimal except that the digits of the sum ifl any sigiuficaOt position can be oDly 0 or 1 Any carry obtained in agiven significant position is uSed by the pair of digits one significantplt)sition higher Subtraction is slightly more complicated Tho rules are still the sam~ lismiddot ip declmalexcept that the bonow in a given signifieantposition adds 2 toa minuend digit (A bonoW in thedeeimaI syste~ adds 10 to a minUend digit) Multiplication is simpIefhe mo1iplier digits are 8lWaYs lor 0 thereshyfore the Partial produCts are eq~ either to the multiplicand Or la O

Theco~vefsio~ ofan~~r in ~a~e ~decimaI is40nebYexPamnngth~ntunber in a power series and adding all the terixlsasshown previOU$ly We nowptesel1u generij procedure for

the reverse operation of conyertirigadecimalnuil1ber~ anum1gtel in hasedfthe number inshycludes a radix point it is necessary to separate tbenumber~toan inte~partand a fraction part since each part mus~be converte4 diffqeptlyThe conversion ofadecimalinteger to a num- berin basO risdont by tlividingthe humber SAd all Successiv~q~nts by ~d8CCUllUlal- ing therem~ This procedure is best illustrated by example

6 Chapter 1 DigitatSy$tems and BInary Numbers

111411

Convert deciIIla14 r to binary First 41 is divided by 2 to live an integer quotient of 20 and a remainder of i Then thequoiientisagam divided by 2 to give anewquotient and remainder Theproeess is ~ntinued untilth~ integer quotient becomes O The Cf)eJJicients of the desired binary number are obtained fJOm the remainders as follows

Ioteger Quotient Remainder Coeflldent

4112= 20 + ah= 1 2012 10 + 0 at= 0

1012 = 5 + 0 a2= 0

512 = 2 + 1 a3 = 11 Z2 1 0+ G4=O

I112= 0 + 2 as =1 lt

Therefore the aDsWeris(41 )u)= (llsa4~3f12alaoh =(IOlOOlh The arithmetic proCess can be manipUlated moreconvemently as follOws

Integer 41

20

10

5 2 1

o

Relnamder

1

o o 1

o J~

1 101001 ==answer

Con~ersi~n from decimalintegeJS to lQ1ybase-r Sstem i~ similar totljis example except that division is done by r iil$teadof2

1I1t4191I Convert decimall5lto oCtal The required baSe r is aFirst 153 is divi~ by 8 tQl1ve anin- tegerquotient of 19 and a remainder of lThen 19 is divided by 8 to give an ~tegerqlotient

of 2 anli a remainder of 3 tFiny 2 is divided by 8to give aquotientof 0 and a remainder of 2 lbisproeess can be conveniently manipulatecfas follows

153 19 J

i 3 o 2= (23J)s

7 Section13middot Number-Base Conversions

lhe(OllVelSiOllQCdecimalfrmtonto binary js accompllshedby a ~od similar to tbai uscd for ~~veri multiplication is used instead of division and integers instead of

rem~ are acc~aQd Agafu~ the method is best explajned by example

bull Co~vert (06875hotobmaryFirst 06875 i~ multiplied by2 to give an integer and ajraction nen the new fraction is multiplied by 2 to give a new integer and a newfraction The process is continued until the fraction ~om~ 0 or until the nUJ1lber of digits have sufficient accuracy necoefficients oftbebinary nUlllberare ~btaipedfrolIl-~~ integers asfQUows

lnteger Fraction middotCoemclent gt~fn5 Jlt~~ i + 03750 a-I = 1

()37SO f(2 0 + 07500 g-2= 0

07500X2= 1 + 05000 D-3 - 1-

0-5000 X 2 == I + 00000 a~=l

J

) -

Thereforethe at)Swer is (O6875ho= (OD-lazQ-3D-4h= 010l1hshyTo convert adtcimal fractl9D to a number expressed in base 1 a-similar procedure isused HQwever multiPlication i~ by 1 instead all and the coefficlentsfound from the integers may

range iti value from 0 to r- 1 lI)stead of 0 and 1 bull bull bull - - -_ t lt~ 1

bull

O513X 8 = 4104

0104 X 8 = 0832 0832 X8 6656

0656 X 8 == 5248

0248 X 8 = 1984

0984 x 8= 7872

The an~wer to seven significant figures is obtained from the integer part onhe products

(OsP)IO= (0406517)8

middot8 Chapter 1 Digital Systems iilnd Binary Numbers

Ibo oonversion ofdecimalnumbers withbotMnteger and ftattionparts is done by con- vertingthe integer and the fraction separately and ihencombinihgthe two answers Using the re$Ults ofExamples 11 and l~ weobtain

(416875h~ (lOI001l011h

From Examples 12 and 14e have

(1535130 (2314tl6517)s

14 OCTAL AND HEXADECIMAL NUMBERS

The conversion frOm and to binary octal and bexadecimal plays an important role in digital computers Since 23 =8 and 24 = 16 each octal digit corresponds to thref binary digits and bull each hexadecimal digit corresponds to foUr binary digits The first 16 numbers in the decimal binary oct8r andhex~ecimalnumber systems are listed in Table 1-2

The comersion fm~ binary tooctal is easilyacltooiplishedby partitio~ng the binary num ber into groups oftbree digits each starting ti()n1 the binary plmt and proceeding to the left

I and to the right ~correspo~ octal digit is then assigned to each group The following example illustrates the proeedure ~

(10 110 001 101 011 11~ 100 000 lloh = (261537406)8 2 6 1 ~ 3 7 4 0 6

T_lel2 Numbers with Different-Baus

DecImal IY Octal Hexadecimal middot(base 10) (base 2) (b) (16)

i

00 0000 00 p 01 0001 01 1 02 0010 02 2 03 0011 03 3 04 0100 04 4 0 0101 OS 5 06 0110 06 6 07 0111 07 7

08 1000 10 8 09 1001 11 9 10 1010 12 A 11 1011 13 B 12 1100 14 C 13 1101 IS D 14 1110 16 bull

Ej

IS 1111 11 F r i

9 section 1S Complements

Conversion from binary to heudeciInal is similar except thatthe binary nutriber is divided into groups ofourdigits

(10 1100 0110 1011 1111 0010h = (2C6BJ2) 16

2 C 6 B P 2

The comsponding heX~ima1(o~ octal)~digit fOr each group of binary digits is easily reshymembeled from the values listed in Table 12

Conversion from octal or hexadeciInal to Jlinary is dOne by reversing the preceding proceshy(luremiddot Each octal digit is converted to its tbi-ee-digit binary equivalent Similarlyeach hexashydecimal digit is convertedioits four~digitbinaryequivalent1he procedure is illustrated in the following examples

(673124)8= (110 6

III 011 7 3

001

010 2

l00h 4

and

(306Dh6 = (OOlf 0000030shy

110 6

~101h D

Binary numbers are difficUlt to work with because they require three or fout times as many digits as their decimal equivaltmts Por exaniple the binary number 111111111111middotis equivalent to decimal409S Howeverdigital computers use biIUuy11UIhbers and itis soIIJet4nes necessary for the human operator or user to oonununicatedirectly With the machine by means of such num bers One scheme that retainsthebinary~ystem in the cotnputer but reduceS the number of digshyits the human must cOnsider utilizes the relationslripbetyeen the binary Ilumber system and the ~ or hexadeciinal system By this method the Ql1DaIlthinksin tenns ofQCtal ornexadecimal nurnbers and performs the required conversion by inspection when direct communication with the machine is necessary Thus thebinary number 111111111111 has 12 digits ~d isexpressed iIi octal ~ 7777 (4 digits) or in hexadecimal as FFF (3digits) During communication between people(about binary numbers in the coJlllQter)the octal or hexadecimal representation is more desirable because it can be expressed more compactly with a third or a quarter of the number of digits reqUired for the eqwvalent binary number Thusmpstcomputer manuals use either octal laquohexadecimal numbers to specify binaryqwintiti~ The choice between diem is arbitrary although hexadecimal tends to win out since it can represent a byte with two digits

PlEM ENTS

Complements are used in digital cOmputers to simplifydle subtraction operation and for logshyical manipulation Simplifying operations leads to simpler less expensive circuil$ to implement the operations There are two types of complements for each baSe-r system the radix comshyplement andthe diminished raclix cOtllplement Themiddotflrst is referred to as the rts complement and the second as the (r - middot1)scomplement When the value of the base r is substituted~ the name the twotypesare refefted to as the 2s complement and 1 scomplement fot binary numshy~rs and the lOscompl~ent and 9s complement fqrdecimal numbers

10 Chapt~rl Digital Systems and Binary Numbers

D~I~llhed Radix Complame~middot Gi~en a number N in base r haYing n digits the (r - 1)scomplement~f N is defined as

(rll - 1) ~NFotdecimainumbersr -= Wandr -1 9sothe9scomplementofNis (10 - 1) - N IIi this c~ 10 represents a number that consists of a single 1 followed by nOs 10 - lisartumberrepresentedbyn9sFOrexampleifn 4wehavel04 = 10000 and 104 - 1 = 9999 It follows that the9s complement ofa decimaJnumber is obtained by subtracting each digit from 9 Here are some nwnericalexamples

The 9s complement of 54670(Ms929999~ 546700 453299 bull - I

The 9scothplement of012398is999999~0l2398 =987601

For binary pumbers r =2 and r - l~ 1 sothe 1s complementofNis(Z - 1) - N Again 211 is represented by a binaty number thatconsistsofa 1followed by Ii0s 211 - 1 is abinary number represented by ~1s~FOr example if 11= 4 we have z4 = (10000)zand 24 - 1 = (1111h Thus the ls complement of a binary number is obtained by sUbtractiDg

each dig~t from 1 However when subtracting binary digits from 1 we can have either I -0= lor1 - 1 = 0 which causestbe bit to change from Oto 1 0( from 1 to 0 respec- tively Theretore the ls complement of a binary number isfonnedby changing 1s to Osand Osto 1s The f9llowillg are somenumqical ex~esI

~

The ls Complement of 1011000 isotOOiu

The 1scompieme~t oHlIOUOI is 10 tOOlO

The (r-l) s compleme~ ofoctal or b~xadechnalnumbers i~6btained by subtracting eaeh digit from 70rF (diicimallS) respectively~

Radl~ C~mplement

The s complement of an n~digit number N in baserisdefinedasrmiddot Nfot N i 0 and as ofor N = O~ Comparing with the (r- l)s ~entwe note that ~rs complement is obtained by adding Ito the (r - l)scomplement smcer - N= HA-- 1) - N] L lhus the lOscomplementof deein1al2389 is 76lO +1 = 7611 and is otltamed by adding 1 to the 9scomplernent value The 2s oomplementofbinary 1011oois 010011 1 =010100 and isobtained by adding 1 to the ls-complement value

Since 10 is a number represented by a 1 followed by n0s1011 N Whicb is the10S com~

plementof N can be fonn~d also by leaving allieasl sigtrlficani Os Unchanged the first nonurO least significant digit from 10 and SUbr8Cting all higher significant

from9 ThUs

the 10s complement of 012398js987602

and

11 Sectlon middot15middot Complements

The 10s complement ofthefustnumber isobtaineltibysublriiCtingSfrom lOin the least sig~ nificant position and subtracting all other digits from 9~ The 10s complement of the second number is obtained by leaving the to least significant Os unchanged subtracting 7 from 10 and subtracting the other three digits from 9

Similarly the 2s complement ~be fonned by leaving 1ll11east significant Os and tbe first 1 unchanged and replacing I swith Os and Os with ls in allother hi~r signifIcJUlt digits For example

the 2s cORlplement of 1101100 is 0010100

and

the 2scomplement ofOllOllHs 1001001 _ - r

The +s complement pf therrrst nJUDber i~ obt4iriedby I~vingthetwo least significant Os and the first 1 unchanged andmiddotlQen replacing ls with Os and Oswith 1~ in the other four most sigmiddot nificant digits The 2s lXgtmplement qf the second number is obtained byleaving the least sigshynificantmiddotl unchanged and (fOmplementing all other digits

In the previous definitions it was assum~dtMt the D~bers did not have a radix pomt1f the original number Noontains a radix point the point should be removed temporarily in order to form the s or(r 1)s complement The radix point is then restored to the c9ll1plementshyednumber in the same relative PositionIlis abo wOrth mentioning thatfhecontplement oftbe complement restoresthe number to its original v41ue To see this rel~tionsbipnOtethat the ts complement of N is n - N so that themiddot complement oft1e complement is n - (n - N) == N and is ltlqual to the original number

Mr8Ctiton wltl1 Complementsmiddot

1le direct metb()jiofsubtraCtion taught in elexnentaty schpOls uses the bottow concept In this QlCth9dwebortowa I from a middothigher significant position when the minuend digit is smaller than the subtrahend digit The tDethod wor~wen when peOple perfonnsubtraction with paper andpeooillIowever when subtlaction is implemented withdigi1al bardw8le the method is less e~citnt than the method that u~s compl~m~ts

The subtraction of two n-digitunSigneq numbers M N in base can be done as fonows I

1 Add the minuend M to the scompleme~t of thesubtramphend N Mathematically M+ (n N) = M N +

2 IfM ~ N ttie sum wiUproduce an end cury 11 which caD be discarded what is left is the resultM N

3 If M lt N the sum does not produce ~tlend carry JUld iseijUattor (N~ Ji) which is the s complement of (N - M) To obtain the answer in a familiar form take the s complement of the sum aruI place a negative sign in frorit

12 Chapter 1 Digital Syst-ems and Binary N~mbers

The following examples illustrate the procedure

plPi1I VsinglOs complement subtract 72532 - ~250

M = 72532

lOs complement of N + 96750 Sum= 169282

Discard end caIry lOS = -100000 Answer = 69282

Note that M bas fiv~ digits andN has only fourdigitsBoth numbers mtast have the same numshyber of digits sowe wrlteN as 03250 Taking the lOscomp~ementofNptOducesa9 in the most significant PositionThe occurrence of the end carry signifies that M ~ N 8ndtlult ~ result is therefore positive

Ulling 10s complement subtract 3250 - 72532 - ~ ~

M = 03250 JOscornplementof N =+27468

Sum= ~0718

There is no end carry Theref()re-theanswer is--(10amp complementof30718) == -69282 Note thatsince 3250 lt n532~the result is negative Becauwe are dealing with WUiigned

numbers there is really no way to get BnunSigned result for this case When subtracting complements we reoogilize the negltive answer from the~sence of the end carry and complemented result When workingwith paper and pencil we c8nchlnp the aDswer

signed negative number in oider to putH inafamiliar form Subtraction with complements is done with binary numbers in a similar manner uing

procedure outlined previously

EXAMPLE 17

Given the two binary numbersX = 1010100 and Y =1000011 performtbe $UbiDctiG (8) X - Y arid (b) Y - Xby using 2scomptem~ts -

f

- -

Section 15Complements 13

(a) x = 1010100

2s complement ofY= + -0111101

Sum = middot 10010001 Discard end carry 27 = 10000000

Answ~ X- Y = 0010001

(b) Y == 1000011 2sco~lement of X = + 0101100

Sum= 1101111

There is nQmiddotend carry Therefore the answer is Y ~X= -(2sq)mplement of 1101111) = -0010001 Subtractionof unsigned D1lJllbers ~ also bed()neby means of the (r - 1)s complement Remember that the(r- l)s complement is one lesstharithers complement BeCause of

ibis the result of adding the minue~ to tJte coQlplement of the subtiah~ndPtOductS itsum that is one less than the correct 4ifference when an end carrY oCcurs Removing the end carry and adding 1 to the sum is referred to asan end-around carry

Repeat Example 17 but this time using rs complement

(8) X y = 1010100 - 1000011middot

X= 1010100

rs complementafY= + olfnoo Som = 10010000

End-arOundmiddot~ =- ~ ~ Answermiddot X Y= middot0010001

(b) Y - X = 1000011 - 1010100

Y = 1000011

1s complement ofX = +0101011

Sum = 1101110

There is no end carry TherefOre the answer is y - X = -(1s complement of 1101110) = -0010001

bull Note that the negative resultis ob~ by taltingtbe 1 scomplemeilt of theJWltsince this is the type ofcoDiplementused The procedwewithendaroundoanyis aIs(gt Iijlpliclbleto subshytracting Unsigned deciImdnumQers with 9seomPlement

14 Chapter 1 Digital Systemsand BinayNumbers

16 SIGNED BINARYNUMBER$ ~

Positiveintegers (including zero) CaBbe ep~~ 11$ unstPecl numbers However to repshyresent negative integers we need a notation for negative srn ordinary arithmetic a negshyative number is indicated by a mulUs signmdapOsitiv~Pwtlt)e~ by aplus sign Because of lJardware limitations computers mlstrepresenlev~With~ digitsIt is customary to represent the sign witb a bit placed intheleftmotp6sitiolwfthe number The convention is tltl make the sign bit 0 for positive and 1 for negative

Itis important to realize that botp siped and unsignedtDnary 11UJDbers consist of a strfug of bits when represented in a com~ TQeuser detem1inesWbether the number is signed or unsigned If the binary number is signed then the lefuriostbitreple$ellts thtsign aud the rest of the bits represent the number Ifthebinaryllu~beiis~ tObe unsigned then the left most bit is the most significant bit of the l)uMber Fdre~the~~f bits 01001 can be consideredas 9 (unsigned binary) or as +9 (Sighedbitia1j) ~USJtheteftmostbit is O The

string ofbits 11001 represents the binary ~~v~ento~ ~w~nc~idered as an unsigned number and the binary equivalent of 9whenconsidered1l si~riumPer This is because the Ithal isintbe leftmost positiondesignatesampC nega6ye_~QtherfourJ)its represent bishynary 9 usually tlere is no cotifusionin identifying thebits~the~Qfrepresentation for the number is known in advance ~

The representation of the signed numbers in the lastexainple is referred to as the signed magnitutk coDvention In this ~otati()nthenurnber C4mSiampesOCa mQ~~andil~ymbolH

or -) or a bit (0 or 1) indicating the sign This is the representation ampr~~used in ordinary arithmetic When arithmeti~ operatioBslllieimplerneJltcldin~cOQlPuter hii more convenient to use a different systemrefetred t(gt as the si~cqmptement system~ for repre- senting negative numbers In thissystlm a neg8tielliun~r isjhdic~ted by its cornplc~mc~nt Whereas the signed-magnitude system negates a nlllllher by cbanging its sign me signed-comshyplement system negatesanwnber bytakin$ its~OinPleltleitiSinoepositife numbers always start witbO(plusin tte leftmost pOsition thecompktllint wiilalwaysstart with a 1 indicating a negative number The siped-complemelt system can use olthertbe 1s Or the 2s but the 2s complement is the mos~comtliOfi

As an exampleconsider the number9re~~ed in binary with eight bits + 9 Is sented with a sign bit of Oin the leftri1ostpOsition oIIOv~by the binary (equivalent of 9 which gives ()()()olOOl Note thai all eigbtbits must haYampa v~therefore O~s are inserted folshylowing the sign bitllp to the first 1 Although ~ is only 01K way to tepresent +9 there three different ways to represent 9 with eight ~its

s~gned~magnituderepresentation 10001001

sigried-l s-complement represe~on~ 11110110

signed-2 s-complemerit representatim 1ttltllU

In signedmagnituamp -9 isobwned from +9 by changing the sign bitmtbe leftmost ~iti(ln tromO to L In sigl1ed~ lroomplement 9isobtaidedtf~~tiog all the bits of includinj the sign bit Thesigned-2~sco~re~Qf-9 is obtampDedby ihe 2s complement oftbepOsitivenumberincludingtbesijnbIt

Sectlont6 SIgned8lnary NumberS is

Table 13 Slgtlfd Biliary Humbm

+7 +6

+5 +4 +3 +2 +l +0 0 -I

-2 -3

4 -5 -6 -1 -8

Olll 0110

0101 ( 0100

001l 0010 0001 0000

IIll 1110

nOI noo Ion 1010

1001 1000

OIll Oito eHOl OHIO OOU 0010 0001 0000 1111 1110middot dOl 1100 Ion

lOti 1001 1000

0111 OUO 0101

0100 0011 0010 0001 0000 1000 1001 1010 IOU 1100

1101 1110

lUI

Table 13 lists all possible four-bitsignedbinaryaumbers in the three representations The equivalent decimal number Is also shown for refelenoeNote that the positive n~ in all three representations are identicaland have 0 inthelefmostpcsiticm The signed2sshycompl~mentsystemhaironly onemiddotrepresentation for 0 which is always po$itive The other tw()systetns- mlve either a positive 0 or a negative 0 sometbingnoteDcounteredin ordinary arithmetic Note that all negative numbenhave alin the leftmost bitpositi~ that is the way we distinguish them from the positivenumbers With fout bits we can repreSent 16 binary numbers In the signed-magnitude aDd thelscomplement repre$eDtatipns there are eight positive numbers and eight negative numbers inciUdingtwo zeros In the2s-complement representation there are eight positive numbers includi0a one zerQ and eight negative numberS

The siped-m_gnitude system is used in ordiIlary arithmetic but is awkward when emshyployed in computer arithmetie becauIe of the ~parate bandIinJ bfthesipand the magnitude Therefore the signed-compiement systeni is normallyused The ls ~t imposes some difficulties and is seldom USedJor arithmetic openitiOns It is U$eful aSa lo~ operation since the change of 1 to Obrmiddot() to 1 is equivalent to a logical complement Operation as will be shown in the next c~The discussion~f sigiled binary ariduneti~ that fol10ws deals exshyclusively with the signe4-2soomplt_nt~tatJonQfnegadveilUlilbers hsame proshy

cedurescan beappJied to the sigMdrs-comPlemeD~Iysby incIudiOI tbe~arotmdcarry as is done with unsigned numbers

J6 Chapt~r 1 OlgltalSystlf(ns and Binary Numbels

Arithmetic Addition

The addition of two numbers in the signed-magnitudelYs_foUowsthe rules ofordinaiy arithshymetiC Ifthesi~s arethesam~we addthetwOtt~gni1U~~d ~vetbe sum the CCmmon sign Iftbe signs are diffe~nt we subtract tllcsmaUermagnitude frOtnlthe larF and give the differshyehtethe signof the larger magnitude For example (+25) +( - 37) = ~ (37 - 25) = -12 and is done by subtracung the smaller magnitude 25 from the larger magnitude 37and a~nding the sign of 37 tGtbe result Ibis is a process that requires a corripanson of the signs and magnitudes and then performing eithr additi()n or subtraction The same procedure applieato binary numbers in sigped-magnitude representation~Incontrast the rule for adding numbers in the signed-corppleme~ sy~tem does not require a comparison or su~ traction but only addjtion The procedure is very simple andcanbe stated as follows for binary numbers The 8ddltion oftwo signed binary numberS with negative numbers tepresented in signed- 2sComprement fonn is obtaiIled from theadditlooofthe two numbers includingtheii sign bits

AcentiirrY out oftbe sign-bitposition is diScacded NumerIcal e~aihpledotai1dition follow

+ 6 00000110 - 6 11UI0tO I

+13 00001101

+13 00001101 +19 00010011 + J 0Q900111 + 6 00000110 6 11111010 ~13 11110011 -1~l 11110011 7 illl1001 -19 11101101

I bull bull ~

Note that negative numbers musthil iriitially in 2seompkmentform and that if the swn ~ ~afterthladdit40nis negativeins in2s~p~t fOl1Jl - In each of thefoDrcasestlteoporationperfol1JlC(lis additionwitb the sign bit iilcluded Any catTY o~of~~-bit~onisdisc~ and negative resultsareButomaticallyin 2sshyromplementfoon

In order to obtain acOrrect answer we mustensQre that the result has a sufficient of bits to accommodate the swnlfwestartwith t~on-bltnumbers and tbeswn occupies n + 1bits we say tblltan overflow occurs~Wheri one perfotmStbc ad(JitiOJl with nllllIPTJllVIl

pencil aq overflow is not a preblem because we arcr noflimitecLbythewidth of the page jUst addanothcentr 0 to apositive number or another 1 toa negative number in the mOst cant positi()n to extend thenwnber to n+ 1 bitSand theQ perform addition Overflow is

problem in computers beqiusetbe number ofbi~~ bolla ~befis finite and a result ex~ tI1efinite val~e hy lcatmotbe accommodated

The compJement form of representiQg negativetlQUlbers is unfamiliar to those usedto signed-magnitude system To itetermine th~ value of II negatienumber insiped-2s COlIlpJe

mentit0is~ to CODVerttbe numbcr to apositie ntirit_ ~ place itiDa more formPor ~plethesig~binary number qUl00~ lii~egativebecausothe leftmost

t 1182s c0J8plemen~js~UlwhUhi$~ binaryeqqivalen of +7Wcmiddottherefore nize the Ori~nal ~atiy-eQumber to be equ~ lo-7 1

Sectlonl7 Bh1ary Codes 17

ArIthmetic SubtractIOn

Subtraction of two signed binafy numbers whe~negative numbersare in2s-complement form is simple and can be stilted as follows

Take the 2s complement of the5ubtraltend (including the sign bit) and add it to the minuend (including the sign bit) A cany oU1of thesignbit position is discarded

This prOCedure is adopted because a subtraction operation can be changed to an addition operation if the sign of the subtrahend is changed as is demonstrated by the following relationship

(plusmnA) ~ (-tB) = (plusmnA) + (-B) (plusmnA) - (-B) =plusmnA) + (+B)

But changing a positivetwober toa negative n~ber is eaampily done by taking the 2s compleshy mentof the pQsitive number The reverse is also tiUe~use theCOmPle~n~ of a negative numshyber in complement form produces the equivalent positive number To see this consider the sJlbtr~ction ( 76) -- (13) = +7 In binaIy_ with eight bits this ()peiationis written as (11111010 11110011) The subtracti~ri ischmlged ~ addition by taking the 2s complement ofthe subtrahend (-13) giving (+13) In binaly tbis~ 11 niOlO+ 00001101 = lOOOOOU1 Removing the end~ we obtain the ootrect answer ()()()()() III (+7)

Itisworth noting that binary DUmbersinthe signed-complement system are added and subshy tracted by the same basic addition and suPtraction rules as unsigned numbers Therefore comshyputersneed omy one common hardware circuit tobandle bothtypcs ofaritbtnetic The user or programmer ~ust interpret the reswtIi of $l1ch addition or subtraction differently depending on whether itisassumedtha~the numbe~ are signed ltr tinsigned

j

BINARY CODES

Digitalsystems use signalsthat have two distinct values1Uld circuit elements that havetwostashyble states There is a direct analogy anrong binary iignals binary circuitelements and binary digits A binary number ofndigitsfor example may be represented by n binary circuit eleshyments each baving an output sig~alequivalen1to Oor I Digital systems represent (Uld mashynipUlate not omy binary numbers but alsO many other diScrete elements of information Any discrete element of informatioIidlat is dis1iilct among agroup of quantities can be represented witha binary code (Le a pattern of Os and fmiddots) The codes must be in binary because in todays techIiology omy circuits that represent and manipulate patterns of 0s and ls can be manufactured economically foru~ in computers However it mtistbe realizCd that binary codes merely change the symbols not the meaning ofthe ele~nts of infonbationthat they repshyresent IT we inspect the bits of a computer at random we will find that mostofthe time they represent some tYPe of coded information rath~ than binlUY numbers

AIln-bit binary code is a groopofn hits that assumes up to 211 distinct cOmbinations of ls ~d Os with eacn combination representing one elementof tnt set that is being coded A set

of four elements clab becoded with two lilS with each ~lementassignedoneof thefoUowing bit oombinationsOOO I 10 J 1 A set of eight elements requiies a three-bit code 00 a set of

18 Chapter 1 Digital Systems and Binary Numbers

J6 elements requires a fourmiddotbit code The bit combination of ann~bit code is determined the count in binuy from 0 to 21t - t Each element must be assigned a unique binuy bit binationand no two elemerits cm havetbtsamevalueothenvisethe code assignment be ambigUous

Although the minimum nqrnber of 1lits required to code 21t distiItct quantities is nthere nomaximwn numbe( of bit that may he used for a binuy code For example the 10 digits can be coded with 10 bits and each decimal digit can be assigned a bit combination nine OSmid a 1 In this pamcularbinarycode the digit6 is assigned the bit )UllIUlauuu0001000000

BCDcode

Although the binary number systemis die ~ost natural system for a computer most people more accustomed to the d~imal system One way to resolve this difference is to convert

inlal nUmbers to binary perform all arithmetic calculations in binary and then convert the nary results back to decimal This metbodrequites that we store decimal numbers in

cOinputer so that they canbec6b~rted to binary Since the compllter Can accept only valueswe must represent the decimal digits by means ofa code that contains ls and Os also pOsSible lopedorm the arithmetic operlltiorisd1rectly on decimal numbers when they stored in the comput~ in cod~ct form

A binarycodewill have some unasSigned bit com~inatiqns ifthe num~rofelements in set is not amultiple power of 2 The 10decimai digits form such asel A biruuy code that tinguishes among 10 elements must coiltain at least four bits but 6otitofthe 16 possible binations remain unassigned Different binary code$ can bemiddotoNained by arranging four into 10 distinct combin~tions TheicodeIllcfflt oommonly used fdr the decimal digits is straight binary assf~ntlisted in Table 14 This scheil)eis called bittary~coded decimal

is commoolyreferred to as BCQ OtherdecimalcodesaIlfpossible and a few of them are sentedlaterinthis section

Table 14 BinarymiddotCoded Oeclmql (BCO)

Decimal BCD SnlboiDIgIt

o 0000 1 0001 2 0010

3 0011 4 middot0100 5 0101 6 0110 7 0111 8 1000 9 1001

Sectionmiddot 17 BInary COdes 19

Table 14 givesthe four-bit code for one decimal digit A number with k decimal digits will require 4k bits in BCD Decimal 396 is represented in BCD with 12 bits as 0011 10010110 with each group of 4 bits representing one decimal digit A decimalmiddotnumber in BCD is the

- same as itS equiyalent binary number only when the number is between 0 and 9 A BCD numshyber greater than lOJpoks different from its equivalentbinary number even though both con tainls and Os Moreover the binary Combinations 1010 thrpugh 1111 are not used arid have no meaning in BCD Consider decimal 18SlUld its corresponding value inBCD and bUtary

(185ho = (0001100001Ol)BCD = (l0111001h

The BCD value has 12 bits to encode the characters of the decimal value but the equivalent binary number needs only 8 bits It is obvious thatthe representation of a BCp number needs more bits than its equivalent binary value However there is an advantage in the use ofdecishymal numbers because compUterinput and output data are generated by people who use the decshyimal system

It is important to realize that BCD numbers are deCimal numbers and not binary numbers although they use bits in tbeir representation The only difference between a decimal number and BCD is that decimals are written with the symbOls 0 1 2 9 and BCD numbers use tbebinarycode 00000001 001O~ bull 1001The decimal value is exaCtly the same Dec~mal 10 is represented in BCD witheight b~ts as 00010000 and decitna1J5as 0001 01Of1lte corshyresponding binaryvalues are 1010 and 1111 and have only four bits

Consider the addition of two decimal digits in BCD together with a po~ible carry from a pre- vious less significant pair ofdigitsSince each digit does not exceed 9 the sum cannot be bull greater than 9 + 9 + 1 = 19 with the 1 being a previous carrySllppose we add the BCD dig-

its as if they were binary numbers Then the binary sumvill produce It result in the range from degto 19 In bin8ry thistange wil[be from 0000 to 10011 butin BCD it is frOm 0000 to

I 1001 with the first (ie leftmost) 1 bemg a carry and the next fo~ bits being the BCD sum When tPe binary sum is equalto or less than 1001 (withaut 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 (0110h to the binary Sum cOnverts it to the correct digit and also produces a catTy as required This is because a carry in themost significant bitposishytion of the binary sum and a deCimal carry differ by 16 10 = 6 Consider the following three BCD additions

4 0100 4 0100 8 1000

+S +0101 +8 +1000 +9 1001 9 1001 12 1100 17 10001

+0110 +0110----

10010 10111

In each case the two BCD digits are added as if they were two binary numbers If the binary sum is greater than or equal to 1010 we add 0110 to obtain the correct BCD sum and a carry In the flIst example the sum is equal to 9 and is the correct BCD sum In the second example

20 Chapter 1 Digital Systems and BInary Numbers

the binary sum produces an iJlv~ BCD digit The addition of0110 produces the cortect BCD sum 0010 (ie the number 2) and acanyInthetbirdexample the binalY SUDlproduces acany This condition occurs wben the $W)) is greater than or equal to 16Altbough the other fout are less than 1091 the binary 9Ulll requires acOnectionbecause of die carry Adding 0110 obtain thetequiled BCD sum 0111 (ie the numblaquo 7) and 8 BCD CiUT

The additionoftwondigit unsipedBCD numbers follows the same procedure COIlSioll the addition of 184 + 576 1= 76() in BCD

BCD 1 I 0001 10000100 184

+6101 ~

0111--- 0110 +576

lJinarysum 0111 10000 1010 Add6 ono 0110

BCDsun 0111 0110 0000 7(1)

The flfSt l~ sigDiticant pili- of BCD digits produces aBCDdigi~SllDlof 0000 and a for the next pair of digits the second parr or BCD digits plus a ~Vi0U8 cany produces a sum of 0110 and a carry for the next patr()fdigits The third pair of digits plus acarry proltIUC~ a binary s~ of 0111 and does not require a correction

Decimal Arithmetic The represeiltation of signed decimal numbers in BCD is simiiarto the tepresentation of numbers in binaryWe can useeitheI the familiar signed-magnitude system at the SllZllOO-COI1I

plemelit system The sign of a decimal number is tJSually represented with four bits to to thefour-bit code ofthe decimal digits Itis customary to designate 8 plus With four Os 8 minus with the llCDequivalent oi9 whlcq is 1001 The sigiled~magnitudesystem is seldom used in com~tersThe signed-complerDem ~~ either the 9s octhe 10s complement put the lOscomplement is the one most useP To obtain the lOs complement of aBCD numberwe first take the 9s complement then add 1 to the least significant digit The 9s Complement is calculated from the subtracloo of each digit from 9

The prltXeduresdevelope4 for the signed-2s-complement system in the ~vious also apply to the signed-IOs-complement system for decimal mimberS Addition is done summing all digits including the sign digit and discafding the end carry This operatiQ assumes that all negative numbers are in 10s-complement form COOsider the (+375) + (-240) == + 135 done inthe signed-complement system

o 375

+9 760middot

o 135

lhe 9in the leftmost pOsition of the second n~ber tepresents a minllS and 9760 is the complement o( 0240 The two numbers are added and tbe end carry is discarded to +13SOfcourse the decimal ntmlbers insi~ tile computer includingthe sign digits in BCD The addition isdone with BCDOigits as described previously

Sectionl 7 Binary Codes 21

The suQtr8ction of decimalliUJ1lbets either unsigned or in thesi~-~Oscomplement systetn is the sameu in the binary case Taketbe 10s ootnplementof the subtrahend and add i~ to themin~nd ManyooDlputerslULvespeciaJ hardware to perform arithmeticcalculations directly withdecilnal oumbers in 8tDThe~u$etofthecoBlPuter can specify programliled Wtnlctionsto JOdonn the aDtiuJletiP oPmwoowithdeQmal n1UQ~ ~ywithout having to convell them to binary

Binafy codes for decimal digits requirea minimum of four bits per digit Many different codes can be formulated by~gjng four bits into IQ distinct combinations BP) and three other representative codes are shown in Table L5 Each code uses only 10 out ofa pOssible middot16 bit combinations that can be arranged with four bits The other six Unused cOmbinations have no meaning amt should be avoided BCD and the 2421 code are examplesofweigbted codes In a weigbtedcodeeach bit position

juBsigned a weighting f~in~awaythat eaehdigitcanbe ev~by 8dding the wei~ oran the lsin thecoded combination The BCD code has weights of8 42 and I which cotteshy

spondiothe powe1Of-two valuesofeaCh bitTbebitasSignmeatOll0 for example is interpreted by the weights to represent dedma16beCause 8 X 0 +4xt +2 Xl +IX 0 6Thebit combination 1101 when weighted by the ~ve digits 2421 gives themiddotdeCimal equivalent of 2 X I +4 gtlt I + 2 KO + 1 X 1 = 7 Note that some digits cantle coded in lw9 possib)e

ways in the 2421Q)(feFOr inke decimal 4 can be asSigned to bitCombinadon 0100 or 1010 since botbcOmbinatibns add upto a totalweight of4

middot1$ Fou Dlf(et Blnqry Code$ for thtJledmol DIgits

~ IICD DIgIt sal MZt Exeet) 8 4 -~1

0 1

000() middotmiddotmiddot0000 001)1 0001

oem 0100

0000 0111

2 0010 0010 0101 0110 3 0011 OQU 0110 0101

4 0100 0100 0111 oroo 5 0101 lOll 1000 1011 6 OlIO middot1100 1001 1010 7 middot0111 1101 1010 J001 8 1000 IUOmiddot 1011 1000 9 1001 11U 1100 1111

1010 oloi 0000 0001 Uaused IOU 0110 middotOOOl 0010 bit 1100 0111 0010 0011 combishynations

nOl 1110

lOW 1001

HOI 1110

1100 1101

1111 IOU) 1111 1110

22 ChaptfrliDfgltalSystemsaod Btoary Numbers

I1te 2421 rind the

e~l3~es are exampks Of self-complementing codes Such codes have~propertyjbatthe9s~plement ofa deCimal nfunberigobtairted directly by chang-

ing 1$ to O~$ finO tYSCfb1 sie~bycomple~mmgeaCh bit in the pattem)For example decshyimat3~Sis re~ fu tbeexcess3code as 01101100 1000 The 9s compl~ntof 604 isrepRse~l00liOOllelliwbich isobiainc(himply by complementing each bit of the

code (as with the 1 s coinpl~ofbin~rillDlbers)middot Theexcess~3code has been used in some oldel coritputers because of its selfcpmplement~

ing property Excess-3 is an unweighted code inwhich each codedcombinationis obtained-fJQm the corresPonQing bin3ryvalueplus 3 Note that the BCD code is1~ self-complementing TheS 4 ~~ Icode isan example of assigning both positive and negative weights to ~ decimalcodeInthis case the bit combiDation 0110isin~reted as oecimal2 and is calcu-

latedfrom8XO+4X 1 + (2) X 1 + (1XO=2 ~

Cra Code _ _ J

l1te output data QfmaJlfpbYsicaimiddot $)ShmlS are quantities that are continuous These data bemiddottonverted~digiWforuitJefore they art applied toaliigital system Contfuuous or ~nisCOIl~middotUitodigitalfonn bymeans of an rumlog~digitalConverter It is times ~~ent tousethe Gray code slown inTable 16torepresehtdigiuU data that have oon~ fMn8D8l08 dasaTheadvantage of th( Gray cOOeover thesllaigbt binary nIl11l1hPt~

~lt~thatoWY~ hit in the codegroup changeSin going from one number to the For examplcentbullin-goingfrom 1 to 8dleGray code cblngesfrom 0100 to 1100Only the fust changesfromOto l~the odter~ I)its mnaintbesame By contrast With binary numbers change from 7 to 8wrube from 0111 to lOOOwhich causes allfciur bits to change valUes

TabielAi GtPyCode

01 Decl COde Equivalent

~ 0000 0001 0011 OOlG 011Q Olll OlO 0100 1100 11m 1111 1110 lOlQ 1011

lOOt i

1000

o 1 ~ 3

4 5 6 7 8 9

10 11

12 13 14 15

SectIOnl7 BlnarYCod~s 23

The Gray code is used in applications in which the normal sequenceOrbiruuy rium~may produce an error orambiguitymiddot during themiddot transitionfrom ODeDWDber to the next If binary numbersareusec1 acbange forexaJIlple nom 0111 to 1000 may produce anintermediateershyroneous number 1001 if the value ofthe rigbtmost bit takes longer to -change than domiddotthe valshyues of the other three bits The Graycode elimb1ates this problem since only one bit changes its valve dUrlng aily transition be~een two numbers I

Atypical appli-cation ofmiddotthe Gray code is the representation of analog data by a Continu ous change in the angUlar position of a shaft The sQaftmiddot is partitioned into segments ana each segment is assigned a number If adJacent segments are made to correspond with the Qray-Codesequence ambiguity is eliminated between the angle of thesbaft and the value encoded by the sensor

Character Code

Many applications of digital computers require the handling not only ofnumberS but also of other characterS or symbols such as the letters of the alphabet For mstancean insurance comshypany with thousands of policyholders will use a computeX to process its files To represent the names and other pertinent information it is necessary to fonnulate bull binary code for the letshyters ofthe alphabet In additiQt1 the same binary qode must represent numerals and special Characters (such as $) An a1phanumeric character setis a set ofeiements that inclUdes the 10 decimal digits the 26leuersofthealp1iabe and a nutnbeof special~S~ a set conshytains between 36~d 64 elements ifonIy capital letters areincltided or between 64 and 128 e1eJDents ifboth uppercasemiddot and lowercllle etters are inclUded In the first case we need a bi- nary code ofsix bits and in the second we need a binary cooeO(seVM bits

The standaM binary code for the alphanumeric char8cters is the American Stahdard Code for Information InterCbange (A~n) which uses seven bitS to code 128 characters asshoWn in Table 17 The seven bitsof the code are desipted by b~through h With h the mostsigshynificant bit ~e leUer A for example is represented inASCn as l(l()()()Ol (column l00~tOw 0001) The Ascn ()()de also contains 94 graphic characters that can be printed and 34 nonshyprinting characters used for variQUS control functions The graphic characters consist of the 26 uppercase letters (A through Z) the 26 lowercase letters (a through z) the 10 numerals (0 through 9) and 32 special printable characters suchaS andS

The 34 control characters are designated in the ASCTItable With abbreviated nalne8 They are listed again below the table with their functional names The control characters are used fQr routing data and arranging the printed text into a prescribed format~ There are three types of control characters format effectors information separatOrs andcommumc~on-COnlrpl char~ IlCters Format effectors are characters that control the layout ofprinting They inciude the fashymiliar word pr6cessorand typewriter controlssucb 8$ bac~pace (BS) horizontal tabulation (HT) and carriage return (CR) Information separators are used to separatetbe data into divi~ sions such as paragraphs and pages Theyinclude characters such as ~ordseparator (RS)and file separator (FS)The cODlIDunication-control characters are uSefulduriDgthe transmission of text between remote tenninals EXllll1plesof conlmunicatiOn(ODtiol~ are STX (start oftext)-and ETX (end of text) whicb are used toframe a text mesaagetnQlSlnitted through telephone wires

24 Chap~er 1 Diglt8l Systems and Binary Numbers

rblel7 Amerkcm5tandard Code for Information (nterclHlnge(ASCII)

b~jbzb 000 001 010 on 100 101 no 111

0000 NUL )jLP SP () p P 0001 SOH OC1 1 A Q a q

R0010 STX OC2 2 B b r 0011 ETX DC3 3 C S Ii S

0100 EDT 0C4 $ 4 D~ T d t 0101 ENQ NAK 5 E iU e u OUO ACK SYN amp 6 F V f v 0111 BEL ETB 7 0 W g w 1000 B8 CAN ( S H K h x 1001 HT EM ) 9 I Y Y 1010 LF SU~ 1 Z j z lOll VT ESC + 1lt r k UOO FF PS lt L I I 1101 Cit OS == - M 1 m 1110 SO R~ N 1 n shy

-0PIt st US f 1 0 0 DEL

r- Control characten

NUL NlI]l DlE Data-inkescape SOH Start of hea~ng DC1 Device cOntroll STX Start of text DC2 DevIce io~1lOi2 ETX End (Jftext i DC3 Device corUlri1 3 OOT End oftraIlsmission ~4 DeVicecoQtrol4

ENQ ampqwry NAK Negativeackilowledge ACK

Acknowledge SVN Sync~nous idle

Btl Bell ETB End-of-tmnsnussionblOck sS Backspace CAN CanCel HT Horizontal tab EM End of mediUrlt LF Lintifeed SUB Substitute VT Vertical tab ESC escape FF form feed FS File separator CR Carriigeretum GS Group separator SO shift Ollt RS Reoord sepuator SI Shlftin US Unit separator SF S~e DEL Delete

ASCII is a seven-bit codebutrnostcompUters manipulate anejght-bit quantity asa unit called a byte Therefore ASCII characters most often are stored ~e per byte The

I biti~sometimesused forotlef purposes depending ontheapplicatio~lFor example printetS recognize eightmiddotbit AScn chaiacterS with themost sigoificaot bit ~twO An atkJlitlo

Section 18 Binary Storage and Registers 2S

128 eight-bit characters with the most significant bit set tol are used for other symbols such as the Greek alpbabet or italic tyIe font

Error-Dtectlng Code

To detect errors in data communication and processing aneigbth bit is sometimes added to the ASCll cbaracter to indicate its Panty Aparitybit is an extra hit included with a message to make the total num~ of ls either even or odd Consider the fo119wing two cbaracters and their even andodd parity

With even parity With odd parity Ascn A = 1000061 01000001 11000001 ASCI( T == 101deg100 11010100 01010100

1

- Ineacb casewe insert an extra bit in the leftmost position of the code to produce an even number of 1 s intQe cbaraeter for even parity or an odd number of 1 s in the character for odd parity In generlll one or tbe oth~r parity i~ adopted with even parity being more common

The parity biqsbelpful in detecting errors during the transmission ofinformation from one location to another nisfuJictiOD is bandIed by generating an even parity bit at the sending end for ~h character The eight-bit characters that include parity bits are transmitted to their desshytination The parity ofeachebaracter is thetichecked at the receiving~nd If the parity of the received cbaracter is Dot even then at1east on~bit has changed value dUring the trmlsmission This method detects one three or any odd combination of errors in each character tb8t is transshymitted An even combination oferrors however goes undetected and additioDaterror detic- shytion codes may be needed to take care of that possibility

What is done after an errQlis detected depends on the partieu~ application One possishybilityis to request retransrois~ion of the message on the assump~on that tbeenigtr was ranshyd()m andwill not occur again Thus if thereeeiverdetects a parityerrorit sends bai~ the ASCII NAK (negative acknowledge) control cnaracter consisting ofail even-parity eight bits lOOlOl01H no error is detectedthe ~iversends back anACK (aCkno~ledge) conshytrol character namely 0000011 O The sending end will respond middotto an NAK by tranSmitting the message again until the correct panty is received Ifmiddot after a number of attempts the transmission is still in error a message can be sent to the Operatai to check for malfunctions in the transmission path

BINARY STORAGE ANORECiISTEIlS

The binary infonnation inadigitalcomputermust have a physical e~stencein some medium for storing individual bits A binary cell is a device that possesses two stable sttes and is cashypable of storing pne bit (0 or 1) oflnfotlllation The input to tbe cell receives exciJation sigshynals that set it to one of the two states The output of the cell isa pbysicalquantity that distinguishes between the two states The irtformationstored in Ii cell is 1when the cell is in one stable state and degwhen the Cell is in the other stable state

26middot Chapter 1 Digital Systems and BtnaryNumbers

Registers

A register is a group of binary cells A register with n cells can store any discrete quantity of middot information thatcontains n bits The state ofa registeris an n-tuple ofls middotand Os with each bit designating the state of one cell in the register The C()ntent ofaregister is a function of the int~rpretation given to tbeinformation stored in it Consider fQf ex~ple a 16-bitregister with the following binary content

11 00001111001001

middot Aregjs~ with 16 cells can be in one of 216 possible statesIf one asstimesthat the content cif the register represents a binaryinteger then the register can store any binarydumber from Oto 216 - 1 For the patticularexample shown the content ofthe register is the binary equivshyalent(lftbe decimal number 50121 If one assumes instead that the register stores alpbanushy

middot meric characters of an eight-bit cooe then the content of the register is any two meaningful characters For tht ASCII code with anevenplirityplaced in the eighth most significant bit position the register contains thetwo charactersC (the lefunosteightbits) and I (the rigbt~ most eight bits) If however one in~rprets the content of the register to be four decimal dig- its represented by a four-bitcode tnenthe content of the register is a four-digit decimal number In theexcess-3 code the register holqs the decimal nutriber 9096 The content of the registe~is meaningless in BCD becau~e the bit combinatiOn ltob is 110t assfgned to any decshyimal digit From this example it is clear that a register can store discrete elements of inforshymation and that the same bit configuration Inay beinterpreted dlffe(ently for different types of data

tmiddotmiddotReglsterTrail Adigitalsystenlis characteriZed by its registers and the components thatpetfolin data proshy~ssingIIl digital sy~tems a rcentgister tra1lsfer operation is abasi operation that consists of

middot a transftr of hiJWy hUormation from one ~t of registers into ano$er set of registers transfer may be dir~ctfr9m one regist~r toanlt)ther or may pass througb datamiddotprocessing circuits to petformaD operation Figure L 1 illustratel the transfer of iidOrnuttion among regshyisters anddemonstratespictorlallY [the tr8ll~~ ofbinaryinformation from akeyboard a register in the memQryullit Thehlputunit~s assumed to have a keyboard1 control cuit and aninput register Each time a key is strock the control circuit enters an ImnV$_

lent eight-bit alphanumeric character coqe into the input register We shall assume that code used is the ASCII code with an odd-parity bit The information from the input regisshyter is transferred into the eight-least significant cells Qf a proeessOr register After transfer theinpui register is cleared to enable the control to insert a new eight-bit when the keyboard is struck again Each eight-bit character transferred to the pro1c4ess(raquo register is preceded by a shift of the previous character to the next eight cens on its left~

middot a transfer -of four characters is completed the processor registeris full and its contents transferred into a memory register The content stored in die memOry register shown in Figl came from the transfer of the characters J 0 H an~ N aftet the four ap)lroJ)riatt keys were struck

Section 18 Binary Storage and Registers 27

FIGURE 11 Transfer of information among registers

To process discrete quantities of infoiniatiori in binary form a computer m~st be promiddot vided with devices that hold the (lata to be processed and with circuit elements that manipmiddot ulate individual bits of irifonnation The device most commonly used for holding data is a register Binary variables~ manipulated by means of digital logic circuits Figure 12 il~ luslrates the process of adding two l()bit binary iUlmbers Themeniory unit which no[shy

mally consists of millions of registers is shown with only three ofits registers Thepait of the processor unit showncoDsistsmiddotofthree registers-RI R2 and R3~getherwith digital logic circuits that manipulate the bits of RI and R2 and transfer into R3 a binary number equal to their arithmetic sum Memory registers store information and are incapable of pr0shy

cessing the two operands However th~ information stored in meDij)iybanbetransferred to ~ processor registers and the resUlts obtainedin processor tegisters can be transferred back into ame~ry register for storage Untill)ecded again The diagram ~wsthe90ntents of two

operands transferred from twoJDemoryregisters into RI imd R2 The digital logic circuits produce the sum which is transfened to register R3 The contents of R3 can now be 1riUlsshyferredback to one of thetnemory registers

The last two examples demonstrated the infonncion-flow capabilitieSofa digital system in a simple manner Themiddot registets of the ~ystem are the basic ele~ents for Noring and holding the binary information~igitallogic circuits process the binary ihfonaation stored in the

28 Chapter 1 DigIt bullbull Systems and Binary Numbers

Sum

FIGURE 12 Eumple of blnarylnfonn~t1on processing

registers Digitallogiccirctiits and registers are covered InChQpteB 2 throQgh 6 The metlilOlY unit is ~xPIained ill 9aptet 7 Th~ descriptton of register opetJtions at the register level and the design of digital systems are covexed in Chapter 8

19 BINARY LOGIC

Binary logic deals with variables th~ take on two discrete valueund withoperations that sumelogicalmeaning~ The two val~s the variableussume may be called~ydifferent (true andalse yel and no etc) but for ourp1llpQSe it is cpqVenienttotbink in terms of and assign the values llUld O The binary logic intr0ducedin this section is equivalent to algebra oalledBoolean algebra The fannal presentation ofBoolean algebra is covered in detail in Chapter 2 The purpose ofthis seCtion is to introduce Boo algebra ina matmerandlate it to digitallogiccircuits andmiddotbinarYsignalsmiddot

Section 19 Sinary logic 29 ~

Itkltn of IInary logic

Binarylogic consists of binary v~les and a set of logica1middotoperatiQDS The variables are desigshy ~by lettell of thCalplWlet~such asA B C x yz etc with eaCh variable baving two and oniy

two distinct posSible valueS 1and O There are three basic logical operations AND ORand NOT

1 AN]) This ~peration is represented by adotorby the absence ~f an oPerator For example x bull y =z or xy = zis~ x ANDy is equalto z~ThelogicaloperationAND is interpreted to mean that z == 1 ifand only ift~ land y = 1 otherwise z = O (Reme~r that x y andzare binary v8riablesand canmiddotbe equal either to 1 or Omiddotand nothing eise)middot

2 OR This operation IS represented by a plus sign For example x + y =z is read x OR y is equal to z meaning that z 1 if x = iorif y = lorifbothx= 1 and y = 1 If bqth X - 0 andY Omeo z= O

3bull NOT This operation is repf6sented by a prime (sometimes by an overbar) For ~xample x =Z (or~ =z) is read notdsequalto 1 meiming that z iswkatx isnot In other

words ifx = 1 then z == 0 but if x == 0 tnenz = L TheNOT operationisals(1 reshyferred tolls the complement operation since it changes ~ 1 toOand a O to 1

bull bull lt Binary logic resembles binary arithmetic and themiddot9peratioos ANDahd OR have similarishy

ties to multiplication and addition respectively In fac~ the symbols used for AND and OR are the same as those used for multiplication and addition However binary lOgic should not be conshyfused withbinaryarithIrietic One should realize thatan arithmetic variable designates a numshyber that may consist of many digits A logicmiddot variable is always either 1 or O For example in binary arithmetic we have I +1 =10(read~one plus ()fie is equal to 2) whereas in binary logicwe have 1 + 1 1 (read one OR onds equal to one)

For each combination of the values oix and y bullthere isa value of ~ $pecifiedby the definishytion of the logical operation D~linitiops of logical~perations maybe listed in a compacHorm called truth tables A truth table is atable of anpbssible combinations ofthe variables $howshying the relation between the values that the variables may take and the resultof the operation The truth tables for th~ operations ANDand OR with variables x and y are obtained by lis~ng

all possible values that the variables may have when combined in pairs bull For each combination the resUlt of die operation 18 theillistedin a separate row The truth tables for ANDORand

NOT are given in Table La These tables clearly demonstrate the definitionf the operatibns

Table 18 Truth TcibJts of Logical Operations

AND OR NOT

x y xmiddoty x y x+y

0 0 0 0 0 0 1 0 0 1

10

1 0 d 1 0 1 I 1 1 1 1 1

bull~lt~m

30 Chapter 1

Logk Gates

Digital Systems and Binary Numbers

Logic gates are electronic cirellit that operate on ~

variable

or mpre mput tignals to produce an output signal Electrical signals sUch as voltages orrutrents exist as analog signals having values over a given taDgebull saYOt03 V but in a digital system are interpreted to be either of two recognizable values 0 or 1 Voltage~opetated logic Circuits respond to two separate voltshyage levels that represent a binary varjable equal to logic I bt logic O For example a partic- ular digital system may define 10gicOas a signal equal to 0 volts lind logic 1 asa signal equal to 3 volts In practice each voltage levelhiS an acceptable rangeas shown in Fig 13

The input te~nals of digital cikuits accePt binary signals within the allowable range and respond at the output terininals with binary signals that fall within the specified range The intermediate region between the aJl()wed regions is crossed only during aState transition Any desired information for computing or control can be operated tm by passing binary signals through variQUS combinatioDsof logic gates with each signal represebting a particular binary

The graphic symbols used to deSignate themiddotthree types of gates are Mown in Fig 14 The

gates are blocks of hardware that prooocc tbeequivalent of1ogic~1 orlogic() output signals

Volts

- FGURl13

x

y

Exampleof binary slgnaJs

Signal ratlge for logieO

(a)~omiddotinput AND gate

FIGURE 14 SymbOls for digital logic circuits

(c)NOT gate or invert~

Problems 31

x-lU 1 11 P 0

y 0 0 11 1 ~

ANDxy 0 0 rTl 00

ORX+Y~ NOT x 11 0 0 I 1 1

FIGURE 15 Input-output 5Igals for gates

FIGURE 1

A B C

Gates WIth mlltlple JnpUU

A B C lJ

~

if inPllt logic ~ts are satisfied Theinput signals xaDd y intheNDaadQR gates may exist in ~ oHow-possible states 00 10 11 or 01 Il1ese ibpu~ampignals_ shown inFig lStoshygetber with the corresponding output signal foreach PfCThI~tiaiug~iDustrate the reshysponse ofeaclt gate to the four input signal~The~llisofthetiminadiagram represents time and the vertical axis sbo~~~~ it cbapg~botwcen~possible voltshy

age levels The low level represents logic O tJte high level l1lteAND _ responds With a logic ~ ~tput sipl wh~ both input ~~)e 1middot1~ lIieOR S-~with a logic 1 outpUt signal ifanylnput sigrudis lOgic 1 TheNOTgateis~~ to BUll invedet The reason for~nameis~t froJn the signalmsponae inmiddottbe timitt8 diagramwhicbsbows that theoUtputsignal inverts the logic sense of tbeiDpUtsigll8l

AND and OR gates may bavei)lQte tbantwQinputs M AND8_~itti ~input$andan OR gate with foU) inputs are shown in Fig 16 The three-inPllt AND gate responds With logic 1 output if all tbreeinputs arelogic 11jleoutputproduces lOgic Oifanymput is logic O-The

four-input OR gate responds withlogic 1 ifany input is logic 1 its clu1ptltllCCoines logic oonly when all inputs are logic O

Answers to prvblems marked with middotappearaHbe ClOd ofthe ~

11 lJltthe octal and beXadecimalliurilbers trom16ui 32UdngA B1l1ld C forthebst~ digits Usttbe numbers from 8 to 28 in base13 bull

I

12t What is the exact D1Jllbcr of bytes in a system that contains lta) 32Kbytoe (b)64M ~and (e) 640 byte$ middot7 t

32 Chapter 1 Digital Systemsand Binary Numbers

13 Convert the following nu~bers with the indicated bases to decimal (a) (4310)s (b) (198hz (c) (735)8 (d) (525)6

14 Whllt is the largest binary number that can be expressed with 14 bits WhlIt are the equivaleDt ~~ iinal and hexadecimal numbei-s

--

15 Detemrine the base of thl1 numbers in each case for the following operatio~ to be correct (a) 142 = 5 (b) 5414 = 13 (C) 24+ 17 == 40

16 The solution$to the q~cequation xl - Ux +22 oare l1 3 arid x =6 What is the base of the numbers

17 Convertthehexadecimal ntmIher 68BE to bitiary and then convert it ~mbinary to octal

18 I Convert the decirpal number 431 to binary in tWo ways (a) Convertd~y to binary (b) conshyvert first to hexadecinla1 and then from ~decimalwbinary Which method is faster

19 amppress the following nqrnbersin decinud (a) IQ11O0101)z (b) (l65his (c)(2624)8 (d) (FAFA) 16

(e) (10101010)2

110 Convert the following binary numbers tobexadeoimal and todecitnal (a) UOOlO (b) 110010 Explain why the deCimal answer in (b)is 4 times that in (a)

111 Perform the followingdiviskmin binary 11 Ion + l()t

112 Add IlniImultiply tfle following numberswiihout converting them to decimal (a) Binary nuniberilOll aiIdlOh (b) He~uumbers 2E aDd 34

1~)( Do thefoHowing con~ersionproblems (a) CorivertCiecimal2731S to binary (b) CakUlate the binary eqUivalent (f 213 outto eight pl~Then Convert from binary to

imalHowgJose istbe result to 2131 (c) Convert the binary resukin (b) into hexad~ lb~oonvert ~result to decimal Is answer tbesame

114 Obtain the is 8nd 2s complementsofthe foUowing binaryDumbcentrs (aj l)()()(J()OO (b) OOOOOOOO (c) 11011010 (d)01l10110 (e) 10000101 (0 11111111

115 Find the 9s and the 10s complement of the following detimal numbers (a) 52734630 (b) 63325600 (c) 25000009 (d) 00000000

116 (a) Find the 16s complement of B2FA (b) Convert B2FA to binary (c) Find the 2scomplement ofthe resultin (b) (d) Convert the answer in (c)to hex~malandco~ with ihe an~wer in (a)

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 2: Chapter 01 - Mano

2 Chapter 1 Drgital Systems and BI~ry Numbers

ThrouJb various techniques groups of bits can ~ made to represent discrete symbols wbicb aretilen u~ to develop the sys~m in a digitAl fonnat Thus a digital system isi systemtbat manipul8lescijacrete ~lerrients of infonnati~~entelaquolWern~Y Inhinary form

Di$cretequantities of information either eilierge frOrri the nature of the data being processed orinau be quampnlized from a continuous process On the one hand a payroll scbedule iun inshyherently discrete process that contains employee names social security numbers weekly salaries income taxes and so on An employees paycheck is processed by means ofdiscrete data values such as letters of the alphfJbet (n_s)~ digits (slilary) and special symbols (such as $) On die other handa research scientist may observe a continuous processbut record only specific quantities in tabUlar fonn Thescientist is thus quantizing continuous data makshying each number iithis or hertaQlea discrete quantity In many cases the quantization ofa process can be performed automatically by an analog~to-digitalconvetter

The general-p~se digital computer is the best-known example of a digital system The major parts ola computer are a memory unit a central processing unit and inputoutput units~ The memory unit stores programs as well as input output andintermediate data Th~ central processing unit performs arithmetic and other data~processingoperations as specified by the program The program and data prepared by a user arefranSferred into memory by means of an input device such as a keyboard An output device such as a printer receives the results of the computations and the printed results are presentedto the user A digital computer canacshycommodate many input and output devices One very uSeful devicemiddot is a oonuiiunication unit that provides interaction with Qther users through the lnternet A digital computer is a powermiddot ful instrument that canperfonn nOt onlyarlthmetic computations but alsological operatiQns In addition it ~an be pro~~ to makedeciyenot1s bllsedon internal and e~temal cOndipons ~ are fbndalDental reasons thatcommereialproducts are made with digital circuits

Like I diSital compUter mostwgibU devi~sare progralnmable By chimging the program in i a programmable device the same underlying hardware can beuSlaquol for many different applishycationsDramatic cost reductions in digital devices have come about because of advances

digital integrated circuit tlaquohnology As the number of fransistorsthat can be put on a piece silicon increasesto produce complex functions the cost per unit decreases and digital devices can bcj b9ught at an increasingly reduced price Equipment built with digital integrated cir~ cuits Clm pCnorm at a speed 6fhun~s ofmillions of operations pet second Digital systems can bem~e to operate with extreme reliabilitybyusingerrorcorrecting codes An ofthis stIlltegy is the digital versatile disk (DVD) bull in which digital in(ormation repJreSentiJilg video audio 8n4 other data is recorded withoQt the loss ofa single itemDigital iru(nnati(Jn

oJiaDVD isrecotded in such a way that by examining the cOCte in each digital sample it is played back any error can be automaticaHy identified and corrected

Adigital ~ystem isanin~rconnection of digitalmoduies T~understand the operation eacb digital module it is necessary to liave a basic knowledgeof digital circuits and cal~ctiQnThe fifstseven chap~rs ofthis book present thebllsictQO~ofdigital design as logic gate strlCtUles Combinational and Seq1iendal circuits and programmable logiC VI

Chapter 8 introduces digital design atthe register ~sfer leel (RTL) Cha~ 9 and 10 vitbasyDchronous sequeriti8t cinlUts and~various integnrted digitallogicfami~ies~_ II and 12mtrOdijce cOlllDlemal integratedClrcuitsandshow how they can be connected labqratory to perform experiments with digital circuits

3 Section 12 BinarymiddotNumbers

A major trend in digital design methodology is the use ofa hardware description language (HDL) to de~ribeand simulate the function8llty ofa digital cinuit AnHDL resembles a proshygramming language and is suitable for describing digital circuits iDtextual fOrinmiddot It is used to simulate a digital system to verify its operation before bardwlUe is built in It is also used in conjunction with logic synthesis tools to automate the design PrQCesSmiddotBecause it is important that students becom~ familiar with an HDL-baseddesign methodology HDLdescriptions of digital circuits arepiesented iliroughdut the book While these examples help illustrate the feashytures ofan HDL theyalso demonstrate the best practices used by industry to exploilHDLs Ignorance of these practices will lead to cute but worthlessHDL models that may simulate a phenomenon but that canno~ be synthesized by design tools or to models that waste silicon area or synthesiZe to hardware that cannot operate correCtly

AB prevjously s~ted digital systems Qlanipulate discrete qllantities of information that are represented in binary form Operands used for calcU11tions may bJ eltpressed in the binary number system Other discrete elements including the decimal digits are represented in binary codes Digital circuits also referred to as logic circUits proces~ data by means of binary logic elements (logic gates)using binary signals Quantities are stored il1 binary (two-valued) stor- age elements (t1i~t1ops) The purpOse ofthis chapter islo introduce the various binary con~ cepts as a frame ofrcferenceforfurther study in the succeeding chapters

-

A decimal number such as 7392 represents a quantity equal to 7 thousaadsplu8 3 bunltlryens plUl 9 tens plus 2 units The thousands bundred$ etc are powers of Hlirnplied by the posi tion Ofthe coefficients in the number To be moreeltact 1392 is ashtmhai1d notation for what should Dewrinen as

7 x 10f+ 3 x middotmiddot1Q2 + 9 X 101 + 2 x 1O

However tqe convention is to write only the coefficients and fromdJeitpoSltiori deduce the bullnecessary powers 000 In general a number with a decimal point is repres~nted by a series of coefficients

a504a3a2afaO a_I a-20-3

The coe(ficients ajareanyofthe 10 digt~ (012 ~ 9)andthe$ubscript valuej gives the place value and-hence the power of 10 by which the coefficient m~t be multiplied Th~ ttte preceding decimal number cltn be expressed as

lo5a5 + 104a4 + 103a3 + 102~2 + 10Iai + 10deg00 + lO-la~1 + 1O2a~2 + 1O-3a_3

The decimal nQmber systeirt is~aidto be of basf -or radix 1Qbecause it uses 1 0 digits and ttiecOefficients are multiplied by powers of 10 The binarysystemis a differentoumber sysshytem The coefficients ofthe binary number systemh~veonltw~ possible values 0 middotand 1 Each coefficient aiismultipli~d by2i and ~e results are adQedto ~tain tbcdecimalequivshy

alent of the number The radix pUint (~gbull the decinwpoitlt when lOistherlWix) distinguishes positive powers of10 frofl negative powers of 10 For ~ple the ltkclmlil equivalent of the

-- - - - - - -

4 Ch~pter 1 Digital Systems andBlnary Numbers

binary number 1101011 is 2675 as shown from the multiplication ofthe coefficients by powshyersoH

1 X24+1 XZ3 +0 x22 + 1 X 21 + 0 X2deg +1 xri + 1 X r 2 = 2675~ In general a number expressed in ~ base-r systeIri has coefficients m~ltiplied by powers of r

anrn + an-l 71-1 + +a22 + alr +06 + a-I r-1

+ a_~r-2 + + q_mr-m

The coeffici~nts a j range ip value from 0 to 1 To distinguish between numbers of differshymiddot ent baseswe enclose the coefficients in parentheses and Vrite asubscripteqOal to the base used (exceptsometime~ fot decimal nwnlers where the content makes it obvious that the base is decimal) An example ofabaseS numlgteris

(40212)s ~ 4Xs3 -I- 0 XS2+ 2 51 + IX 5deg + 2 X 5-1 == 5114ho

The cOefficient values for base 5 can be only 0 I 2 3 and 4 The octal mllnber system is a base-8 system that has eight digi~ 0 1234 5 6 1~ An example of an octal number is 1274 To determine its equivalent decimal value we expand the nlim6er in apower series witba base of8

(1274)8 = 1 X 82 + 2x 81 + 7X SO+4 x g-l==(S75)lO

Note that the digits 8 and 9 cannot appearin an oCtal number Itis customary to borrow the needed digits forthe coefficients from tlle decimal system

when the base of thenmnber i~ less than lO The letters ofthe alphabet reusedto supplement the 10 decimal digits when ~ base of the number is ~than 10 For example inthe

middot hexadecimal(base-16) number systemthe fIrst 10 digits are borrowed fro1ll the decimaJ sysshytem ~ letters A BCD~E and F are used for thedigits 10 n 12 13bull 14 and 15 respec~ tively An exampICf ofa hexadecimar number is

(B65Fh6 = 11 X 163 + 6gtX 162 + 5X 161 -+ 15 X 16deg =(~~687ho

As noted before the digits in lJ binary number are called bits When a bit is equal to 0 it does not contribute to the sum during the conversion Therefore the conversion from binary to decshymiddot imal can be obtained by addingonly the numbers With powersofctwo cotreSpOnding to the bits

that are equal to lForexample

(1l0101h = 32+ 16 +4+ 1 = 53)10

There are jour ls in the binwy number The corre~pondil1g decimal number is the sum of the four powers of two Thefirst 24 numbersobtaiJted from 2 to tJl(~ power of n are listed in bull Table 11 In computerwork 210 is referred to as K (kilo) 220 as M (mega) 230 asG (giga) and 240 as T (tera)Thus 4K = 212 4096 and 16M 224 = 16777216 Computer cashy~City is us1ial1y given inbyte$ A byte is equal to eight biis arid call ~onuriodal (ie represhysent the code of) onekeyboard character A computer hard disk with four gigabytesof storage

has a capacity of 4G = 232 brtes (approximately 4 billion bytes)

Section 13 ffumb~r-BaSetonver5iotls S

Table 11 Powers of Two

~ n 1 n Z n Z

0 1 8 middotmiddot256 16 65536 1 2 middot9 512 17 131072 2 4 10 1024 18 262144 3 amp 11 2048 f9 524288 4 16 12 4096 20 1048516

5 32 13 8192 21 2097152 6 64 14 1(i3amp4 22 4194304 7 128 15 32768 23 8388608

Arithmetic operations with numbers in base followtht same rules as for decimal nun1- hers When a base othef than the fariilliar base 10 is used one must becarefuho use only the -allowable digits~amples of~di~on subtraction and multipliCation oftwo binary numshybers are asfoUows

augend 101101 nlinuend 101101 multiplicand 1011

addend +100111 subtrahend -tOOtH multiplier XIOI sum 1010100 difference 000110 1011

0000 1011

product HOli

The sum oftwo binaiy numbers is calculated bY the sam~ rules as in decimal except that the digits of the sum ifl any sigiuficaOt position can be oDly 0 or 1 Any carry obtained in agiven significant position is uSed by the pair of digits one significantplt)sition higher Subtraction is slightly more complicated Tho rules are still the sam~ lismiddot ip declmalexcept that the bonow in a given signifieantposition adds 2 toa minuend digit (A bonoW in thedeeimaI syste~ adds 10 to a minUend digit) Multiplication is simpIefhe mo1iplier digits are 8lWaYs lor 0 thereshyfore the Partial produCts are eq~ either to the multiplicand Or la O

Theco~vefsio~ ofan~~r in ~a~e ~decimaI is40nebYexPamnngth~ntunber in a power series and adding all the terixlsasshown previOU$ly We nowptesel1u generij procedure for

the reverse operation of conyertirigadecimalnuil1ber~ anum1gtel in hasedfthe number inshycludes a radix point it is necessary to separate tbenumber~toan inte~partand a fraction part since each part mus~be converte4 diffqeptlyThe conversion ofadecimalinteger to a num- berin basO risdont by tlividingthe humber SAd all Successiv~q~nts by ~d8CCUllUlal- ing therem~ This procedure is best illustrated by example

6 Chapter 1 DigitatSy$tems and BInary Numbers

111411

Convert deciIIla14 r to binary First 41 is divided by 2 to live an integer quotient of 20 and a remainder of i Then thequoiientisagam divided by 2 to give anewquotient and remainder Theproeess is ~ntinued untilth~ integer quotient becomes O The Cf)eJJicients of the desired binary number are obtained fJOm the remainders as follows

Ioteger Quotient Remainder Coeflldent

4112= 20 + ah= 1 2012 10 + 0 at= 0

1012 = 5 + 0 a2= 0

512 = 2 + 1 a3 = 11 Z2 1 0+ G4=O

I112= 0 + 2 as =1 lt

Therefore the aDsWeris(41 )u)= (llsa4~3f12alaoh =(IOlOOlh The arithmetic proCess can be manipUlated moreconvemently as follOws

Integer 41

20

10

5 2 1

o

Relnamder

1

o o 1

o J~

1 101001 ==answer

Con~ersi~n from decimalintegeJS to lQ1ybase-r Sstem i~ similar totljis example except that division is done by r iil$teadof2

1I1t4191I Convert decimall5lto oCtal The required baSe r is aFirst 153 is divi~ by 8 tQl1ve anin- tegerquotient of 19 and a remainder of lThen 19 is divided by 8 to give an ~tegerqlotient

of 2 anli a remainder of 3 tFiny 2 is divided by 8to give aquotientof 0 and a remainder of 2 lbisproeess can be conveniently manipulatecfas follows

153 19 J

i 3 o 2= (23J)s

7 Section13middot Number-Base Conversions

lhe(OllVelSiOllQCdecimalfrmtonto binary js accompllshedby a ~od similar to tbai uscd for ~~veri multiplication is used instead of division and integers instead of

rem~ are acc~aQd Agafu~ the method is best explajned by example

bull Co~vert (06875hotobmaryFirst 06875 i~ multiplied by2 to give an integer and ajraction nen the new fraction is multiplied by 2 to give a new integer and a newfraction The process is continued until the fraction ~om~ 0 or until the nUJ1lber of digits have sufficient accuracy necoefficients oftbebinary nUlllberare ~btaipedfrolIl-~~ integers asfQUows

lnteger Fraction middotCoemclent gt~fn5 Jlt~~ i + 03750 a-I = 1

()37SO f(2 0 + 07500 g-2= 0

07500X2= 1 + 05000 D-3 - 1-

0-5000 X 2 == I + 00000 a~=l

J

) -

Thereforethe at)Swer is (O6875ho= (OD-lazQ-3D-4h= 010l1hshyTo convert adtcimal fractl9D to a number expressed in base 1 a-similar procedure isused HQwever multiPlication i~ by 1 instead all and the coefficlentsfound from the integers may

range iti value from 0 to r- 1 lI)stead of 0 and 1 bull bull bull - - -_ t lt~ 1

bull

O513X 8 = 4104

0104 X 8 = 0832 0832 X8 6656

0656 X 8 == 5248

0248 X 8 = 1984

0984 x 8= 7872

The an~wer to seven significant figures is obtained from the integer part onhe products

(OsP)IO= (0406517)8

middot8 Chapter 1 Digital Systems iilnd Binary Numbers

Ibo oonversion ofdecimalnumbers withbotMnteger and ftattionparts is done by con- vertingthe integer and the fraction separately and ihencombinihgthe two answers Using the re$Ults ofExamples 11 and l~ weobtain

(416875h~ (lOI001l011h

From Examples 12 and 14e have

(1535130 (2314tl6517)s

14 OCTAL AND HEXADECIMAL NUMBERS

The conversion frOm and to binary octal and bexadecimal plays an important role in digital computers Since 23 =8 and 24 = 16 each octal digit corresponds to thref binary digits and bull each hexadecimal digit corresponds to foUr binary digits The first 16 numbers in the decimal binary oct8r andhex~ecimalnumber systems are listed in Table 1-2

The comersion fm~ binary tooctal is easilyacltooiplishedby partitio~ng the binary num ber into groups oftbree digits each starting ti()n1 the binary plmt and proceeding to the left

I and to the right ~correspo~ octal digit is then assigned to each group The following example illustrates the proeedure ~

(10 110 001 101 011 11~ 100 000 lloh = (261537406)8 2 6 1 ~ 3 7 4 0 6

T_lel2 Numbers with Different-Baus

DecImal IY Octal Hexadecimal middot(base 10) (base 2) (b) (16)

i

00 0000 00 p 01 0001 01 1 02 0010 02 2 03 0011 03 3 04 0100 04 4 0 0101 OS 5 06 0110 06 6 07 0111 07 7

08 1000 10 8 09 1001 11 9 10 1010 12 A 11 1011 13 B 12 1100 14 C 13 1101 IS D 14 1110 16 bull

Ej

IS 1111 11 F r i

9 section 1S Complements

Conversion from binary to heudeciInal is similar except thatthe binary nutriber is divided into groups ofourdigits

(10 1100 0110 1011 1111 0010h = (2C6BJ2) 16

2 C 6 B P 2

The comsponding heX~ima1(o~ octal)~digit fOr each group of binary digits is easily reshymembeled from the values listed in Table 12

Conversion from octal or hexadeciInal to Jlinary is dOne by reversing the preceding proceshy(luremiddot Each octal digit is converted to its tbi-ee-digit binary equivalent Similarlyeach hexashydecimal digit is convertedioits four~digitbinaryequivalent1he procedure is illustrated in the following examples

(673124)8= (110 6

III 011 7 3

001

010 2

l00h 4

and

(306Dh6 = (OOlf 0000030shy

110 6

~101h D

Binary numbers are difficUlt to work with because they require three or fout times as many digits as their decimal equivaltmts Por exaniple the binary number 111111111111middotis equivalent to decimal409S Howeverdigital computers use biIUuy11UIhbers and itis soIIJet4nes necessary for the human operator or user to oonununicatedirectly With the machine by means of such num bers One scheme that retainsthebinary~ystem in the cotnputer but reduceS the number of digshyits the human must cOnsider utilizes the relationslripbetyeen the binary Ilumber system and the ~ or hexadeciinal system By this method the Ql1DaIlthinksin tenns ofQCtal ornexadecimal nurnbers and performs the required conversion by inspection when direct communication with the machine is necessary Thus thebinary number 111111111111 has 12 digits ~d isexpressed iIi octal ~ 7777 (4 digits) or in hexadecimal as FFF (3digits) During communication between people(about binary numbers in the coJlllQter)the octal or hexadecimal representation is more desirable because it can be expressed more compactly with a third or a quarter of the number of digits reqUired for the eqwvalent binary number Thusmpstcomputer manuals use either octal laquohexadecimal numbers to specify binaryqwintiti~ The choice between diem is arbitrary although hexadecimal tends to win out since it can represent a byte with two digits

PlEM ENTS

Complements are used in digital cOmputers to simplifydle subtraction operation and for logshyical manipulation Simplifying operations leads to simpler less expensive circuil$ to implement the operations There are two types of complements for each baSe-r system the radix comshyplement andthe diminished raclix cOtllplement Themiddotflrst is referred to as the rts complement and the second as the (r - middot1)scomplement When the value of the base r is substituted~ the name the twotypesare refefted to as the 2s complement and 1 scomplement fot binary numshy~rs and the lOscompl~ent and 9s complement fqrdecimal numbers

10 Chapt~rl Digital Systems and Binary Numbers

D~I~llhed Radix Complame~middot Gi~en a number N in base r haYing n digits the (r - 1)scomplement~f N is defined as

(rll - 1) ~NFotdecimainumbersr -= Wandr -1 9sothe9scomplementofNis (10 - 1) - N IIi this c~ 10 represents a number that consists of a single 1 followed by nOs 10 - lisartumberrepresentedbyn9sFOrexampleifn 4wehavel04 = 10000 and 104 - 1 = 9999 It follows that the9s complement ofa decimaJnumber is obtained by subtracting each digit from 9 Here are some nwnericalexamples

The 9s complement of 54670(Ms929999~ 546700 453299 bull - I

The 9scothplement of012398is999999~0l2398 =987601

For binary pumbers r =2 and r - l~ 1 sothe 1s complementofNis(Z - 1) - N Again 211 is represented by a binaty number thatconsistsofa 1followed by Ii0s 211 - 1 is abinary number represented by ~1s~FOr example if 11= 4 we have z4 = (10000)zand 24 - 1 = (1111h Thus the ls complement of a binary number is obtained by sUbtractiDg

each dig~t from 1 However when subtracting binary digits from 1 we can have either I -0= lor1 - 1 = 0 which causestbe bit to change from Oto 1 0( from 1 to 0 respec- tively Theretore the ls complement of a binary number isfonnedby changing 1s to Osand Osto 1s The f9llowillg are somenumqical ex~esI

~

The ls Complement of 1011000 isotOOiu

The 1scompieme~t oHlIOUOI is 10 tOOlO

The (r-l) s compleme~ ofoctal or b~xadechnalnumbers i~6btained by subtracting eaeh digit from 70rF (diicimallS) respectively~

Radl~ C~mplement

The s complement of an n~digit number N in baserisdefinedasrmiddot Nfot N i 0 and as ofor N = O~ Comparing with the (r- l)s ~entwe note that ~rs complement is obtained by adding Ito the (r - l)scomplement smcer - N= HA-- 1) - N] L lhus the lOscomplementof deein1al2389 is 76lO +1 = 7611 and is otltamed by adding 1 to the 9scomplernent value The 2s oomplementofbinary 1011oois 010011 1 =010100 and isobtained by adding 1 to the ls-complement value

Since 10 is a number represented by a 1 followed by n0s1011 N Whicb is the10S com~

plementof N can be fonn~d also by leaving allieasl sigtrlficani Os Unchanged the first nonurO least significant digit from 10 and SUbr8Cting all higher significant

from9 ThUs

the 10s complement of 012398js987602

and

11 Sectlon middot15middot Complements

The 10s complement ofthefustnumber isobtaineltibysublriiCtingSfrom lOin the least sig~ nificant position and subtracting all other digits from 9~ The 10s complement of the second number is obtained by leaving the to least significant Os unchanged subtracting 7 from 10 and subtracting the other three digits from 9

Similarly the 2s complement ~be fonned by leaving 1ll11east significant Os and tbe first 1 unchanged and replacing I swith Os and Os with ls in allother hi~r signifIcJUlt digits For example

the 2s cORlplement of 1101100 is 0010100

and

the 2scomplement ofOllOllHs 1001001 _ - r

The +s complement pf therrrst nJUDber i~ obt4iriedby I~vingthetwo least significant Os and the first 1 unchanged andmiddotlQen replacing ls with Os and Oswith 1~ in the other four most sigmiddot nificant digits The 2s lXgtmplement qf the second number is obtained byleaving the least sigshynificantmiddotl unchanged and (fOmplementing all other digits

In the previous definitions it was assum~dtMt the D~bers did not have a radix pomt1f the original number Noontains a radix point the point should be removed temporarily in order to form the s or(r 1)s complement The radix point is then restored to the c9ll1plementshyednumber in the same relative PositionIlis abo wOrth mentioning thatfhecontplement oftbe complement restoresthe number to its original v41ue To see this rel~tionsbipnOtethat the ts complement of N is n - N so that themiddot complement oft1e complement is n - (n - N) == N and is ltlqual to the original number

Mr8Ctiton wltl1 Complementsmiddot

1le direct metb()jiofsubtraCtion taught in elexnentaty schpOls uses the bottow concept In this QlCth9dwebortowa I from a middothigher significant position when the minuend digit is smaller than the subtrahend digit The tDethod wor~wen when peOple perfonnsubtraction with paper andpeooillIowever when subtlaction is implemented withdigi1al bardw8le the method is less e~citnt than the method that u~s compl~m~ts

The subtraction of two n-digitunSigneq numbers M N in base can be done as fonows I

1 Add the minuend M to the scompleme~t of thesubtramphend N Mathematically M+ (n N) = M N +

2 IfM ~ N ttie sum wiUproduce an end cury 11 which caD be discarded what is left is the resultM N

3 If M lt N the sum does not produce ~tlend carry JUld iseijUattor (N~ Ji) which is the s complement of (N - M) To obtain the answer in a familiar form take the s complement of the sum aruI place a negative sign in frorit

12 Chapter 1 Digital Syst-ems and Binary N~mbers

The following examples illustrate the procedure

plPi1I VsinglOs complement subtract 72532 - ~250

M = 72532

lOs complement of N + 96750 Sum= 169282

Discard end caIry lOS = -100000 Answer = 69282

Note that M bas fiv~ digits andN has only fourdigitsBoth numbers mtast have the same numshyber of digits sowe wrlteN as 03250 Taking the lOscomp~ementofNptOducesa9 in the most significant PositionThe occurrence of the end carry signifies that M ~ N 8ndtlult ~ result is therefore positive

Ulling 10s complement subtract 3250 - 72532 - ~ ~

M = 03250 JOscornplementof N =+27468

Sum= ~0718

There is no end carry Theref()re-theanswer is--(10amp complementof30718) == -69282 Note thatsince 3250 lt n532~the result is negative Becauwe are dealing with WUiigned

numbers there is really no way to get BnunSigned result for this case When subtracting complements we reoogilize the negltive answer from the~sence of the end carry and complemented result When workingwith paper and pencil we c8nchlnp the aDswer

signed negative number in oider to putH inafamiliar form Subtraction with complements is done with binary numbers in a similar manner uing

procedure outlined previously

EXAMPLE 17

Given the two binary numbersX = 1010100 and Y =1000011 performtbe $UbiDctiG (8) X - Y arid (b) Y - Xby using 2scomptem~ts -

f

- -

Section 15Complements 13

(a) x = 1010100

2s complement ofY= + -0111101

Sum = middot 10010001 Discard end carry 27 = 10000000

Answ~ X- Y = 0010001

(b) Y == 1000011 2sco~lement of X = + 0101100

Sum= 1101111

There is nQmiddotend carry Therefore the answer is Y ~X= -(2sq)mplement of 1101111) = -0010001 Subtractionof unsigned D1lJllbers ~ also bed()neby means of the (r - 1)s complement Remember that the(r- l)s complement is one lesstharithers complement BeCause of

ibis the result of adding the minue~ to tJte coQlplement of the subtiah~ndPtOductS itsum that is one less than the correct 4ifference when an end carrY oCcurs Removing the end carry and adding 1 to the sum is referred to asan end-around carry

Repeat Example 17 but this time using rs complement

(8) X y = 1010100 - 1000011middot

X= 1010100

rs complementafY= + olfnoo Som = 10010000

End-arOundmiddot~ =- ~ ~ Answermiddot X Y= middot0010001

(b) Y - X = 1000011 - 1010100

Y = 1000011

1s complement ofX = +0101011

Sum = 1101110

There is no end carry TherefOre the answer is y - X = -(1s complement of 1101110) = -0010001

bull Note that the negative resultis ob~ by taltingtbe 1 scomplemeilt of theJWltsince this is the type ofcoDiplementused The procedwewithendaroundoanyis aIs(gt Iijlpliclbleto subshytracting Unsigned deciImdnumQers with 9seomPlement

14 Chapter 1 Digital Systemsand BinayNumbers

16 SIGNED BINARYNUMBER$ ~

Positiveintegers (including zero) CaBbe ep~~ 11$ unstPecl numbers However to repshyresent negative integers we need a notation for negative srn ordinary arithmetic a negshyative number is indicated by a mulUs signmdapOsitiv~Pwtlt)e~ by aplus sign Because of lJardware limitations computers mlstrepresenlev~With~ digitsIt is customary to represent the sign witb a bit placed intheleftmotp6sitiolwfthe number The convention is tltl make the sign bit 0 for positive and 1 for negative

Itis important to realize that botp siped and unsignedtDnary 11UJDbers consist of a strfug of bits when represented in a com~ TQeuser detem1inesWbether the number is signed or unsigned If the binary number is signed then the lefuriostbitreple$ellts thtsign aud the rest of the bits represent the number Ifthebinaryllu~beiis~ tObe unsigned then the left most bit is the most significant bit of the l)uMber Fdre~the~~f bits 01001 can be consideredas 9 (unsigned binary) or as +9 (Sighedbitia1j) ~USJtheteftmostbit is O The

string ofbits 11001 represents the binary ~~v~ento~ ~w~nc~idered as an unsigned number and the binary equivalent of 9whenconsidered1l si~riumPer This is because the Ithal isintbe leftmost positiondesignatesampC nega6ye_~QtherfourJ)its represent bishynary 9 usually tlere is no cotifusionin identifying thebits~the~Qfrepresentation for the number is known in advance ~

The representation of the signed numbers in the lastexainple is referred to as the signed magnitutk coDvention In this ~otati()nthenurnber C4mSiampesOCa mQ~~andil~ymbolH

or -) or a bit (0 or 1) indicating the sign This is the representation ampr~~used in ordinary arithmetic When arithmeti~ operatioBslllieimplerneJltcldin~cOQlPuter hii more convenient to use a different systemrefetred t(gt as the si~cqmptement system~ for repre- senting negative numbers In thissystlm a neg8tielliun~r isjhdic~ted by its cornplc~mc~nt Whereas the signed-magnitude system negates a nlllllher by cbanging its sign me signed-comshyplement system negatesanwnber bytakin$ its~OinPleltleitiSinoepositife numbers always start witbO(plusin tte leftmost pOsition thecompktllint wiilalwaysstart with a 1 indicating a negative number The siped-complemelt system can use olthertbe 1s Or the 2s but the 2s complement is the mos~comtliOfi

As an exampleconsider the number9re~~ed in binary with eight bits + 9 Is sented with a sign bit of Oin the leftri1ostpOsition oIIOv~by the binary (equivalent of 9 which gives ()()()olOOl Note thai all eigbtbits must haYampa v~therefore O~s are inserted folshylowing the sign bitllp to the first 1 Although ~ is only 01K way to tepresent +9 there three different ways to represent 9 with eight ~its

s~gned~magnituderepresentation 10001001

sigried-l s-complement represe~on~ 11110110

signed-2 s-complemerit representatim 1ttltllU

In signedmagnituamp -9 isobwned from +9 by changing the sign bitmtbe leftmost ~iti(ln tromO to L In sigl1ed~ lroomplement 9isobtaidedtf~~tiog all the bits of includinj the sign bit Thesigned-2~sco~re~Qf-9 is obtampDedby ihe 2s complement oftbepOsitivenumberincludingtbesijnbIt

Sectlont6 SIgned8lnary NumberS is

Table 13 Slgtlfd Biliary Humbm

+7 +6

+5 +4 +3 +2 +l +0 0 -I

-2 -3

4 -5 -6 -1 -8

Olll 0110

0101 ( 0100

001l 0010 0001 0000

IIll 1110

nOI noo Ion 1010

1001 1000

OIll Oito eHOl OHIO OOU 0010 0001 0000 1111 1110middot dOl 1100 Ion

lOti 1001 1000

0111 OUO 0101

0100 0011 0010 0001 0000 1000 1001 1010 IOU 1100

1101 1110

lUI

Table 13 lists all possible four-bitsignedbinaryaumbers in the three representations The equivalent decimal number Is also shown for refelenoeNote that the positive n~ in all three representations are identicaland have 0 inthelefmostpcsiticm The signed2sshycompl~mentsystemhaironly onemiddotrepresentation for 0 which is always po$itive The other tw()systetns- mlve either a positive 0 or a negative 0 sometbingnoteDcounteredin ordinary arithmetic Note that all negative numbenhave alin the leftmost bitpositi~ that is the way we distinguish them from the positivenumbers With fout bits we can repreSent 16 binary numbers In the signed-magnitude aDd thelscomplement repre$eDtatipns there are eight positive numbers and eight negative numbers inciUdingtwo zeros In the2s-complement representation there are eight positive numbers includi0a one zerQ and eight negative numberS

The siped-m_gnitude system is used in ordiIlary arithmetic but is awkward when emshyployed in computer arithmetie becauIe of the ~parate bandIinJ bfthesipand the magnitude Therefore the signed-compiement systeni is normallyused The ls ~t imposes some difficulties and is seldom USedJor arithmetic openitiOns It is U$eful aSa lo~ operation since the change of 1 to Obrmiddot() to 1 is equivalent to a logical complement Operation as will be shown in the next c~The discussion~f sigiled binary ariduneti~ that fol10ws deals exshyclusively with the signe4-2soomplt_nt~tatJonQfnegadveilUlilbers hsame proshy

cedurescan beappJied to the sigMdrs-comPlemeD~Iysby incIudiOI tbe~arotmdcarry as is done with unsigned numbers

J6 Chapt~r 1 OlgltalSystlf(ns and Binary Numbels

Arithmetic Addition

The addition of two numbers in the signed-magnitudelYs_foUowsthe rules ofordinaiy arithshymetiC Ifthesi~s arethesam~we addthetwOtt~gni1U~~d ~vetbe sum the CCmmon sign Iftbe signs are diffe~nt we subtract tllcsmaUermagnitude frOtnlthe larF and give the differshyehtethe signof the larger magnitude For example (+25) +( - 37) = ~ (37 - 25) = -12 and is done by subtracung the smaller magnitude 25 from the larger magnitude 37and a~nding the sign of 37 tGtbe result Ibis is a process that requires a corripanson of the signs and magnitudes and then performing eithr additi()n or subtraction The same procedure applieato binary numbers in sigped-magnitude representation~Incontrast the rule for adding numbers in the signed-corppleme~ sy~tem does not require a comparison or su~ traction but only addjtion The procedure is very simple andcanbe stated as follows for binary numbers The 8ddltion oftwo signed binary numberS with negative numbers tepresented in signed- 2sComprement fonn is obtaiIled from theadditlooofthe two numbers includingtheii sign bits

AcentiirrY out oftbe sign-bitposition is diScacded NumerIcal e~aihpledotai1dition follow

+ 6 00000110 - 6 11UI0tO I

+13 00001101

+13 00001101 +19 00010011 + J 0Q900111 + 6 00000110 6 11111010 ~13 11110011 -1~l 11110011 7 illl1001 -19 11101101

I bull bull ~

Note that negative numbers musthil iriitially in 2seompkmentform and that if the swn ~ ~afterthladdit40nis negativeins in2s~p~t fOl1Jl - In each of thefoDrcasestlteoporationperfol1JlC(lis additionwitb the sign bit iilcluded Any catTY o~of~~-bit~onisdisc~ and negative resultsareButomaticallyin 2sshyromplementfoon

In order to obtain acOrrect answer we mustensQre that the result has a sufficient of bits to accommodate the swnlfwestartwith t~on-bltnumbers and tbeswn occupies n + 1bits we say tblltan overflow occurs~Wheri one perfotmStbc ad(JitiOJl with nllllIPTJllVIl

pencil aq overflow is not a preblem because we arcr noflimitecLbythewidth of the page jUst addanothcentr 0 to apositive number or another 1 toa negative number in the mOst cant positi()n to extend thenwnber to n+ 1 bitSand theQ perform addition Overflow is

problem in computers beqiusetbe number ofbi~~ bolla ~befis finite and a result ex~ tI1efinite val~e hy lcatmotbe accommodated

The compJement form of representiQg negativetlQUlbers is unfamiliar to those usedto signed-magnitude system To itetermine th~ value of II negatienumber insiped-2s COlIlpJe

mentit0is~ to CODVerttbe numbcr to apositie ntirit_ ~ place itiDa more formPor ~plethesig~binary number qUl00~ lii~egativebecausothe leftmost

t 1182s c0J8plemen~js~UlwhUhi$~ binaryeqqivalen of +7Wcmiddottherefore nize the Ori~nal ~atiy-eQumber to be equ~ lo-7 1

Sectlonl7 Bh1ary Codes 17

ArIthmetic SubtractIOn

Subtraction of two signed binafy numbers whe~negative numbersare in2s-complement form is simple and can be stilted as follows

Take the 2s complement of the5ubtraltend (including the sign bit) and add it to the minuend (including the sign bit) A cany oU1of thesignbit position is discarded

This prOCedure is adopted because a subtraction operation can be changed to an addition operation if the sign of the subtrahend is changed as is demonstrated by the following relationship

(plusmnA) ~ (-tB) = (plusmnA) + (-B) (plusmnA) - (-B) =plusmnA) + (+B)

But changing a positivetwober toa negative n~ber is eaampily done by taking the 2s compleshy mentof the pQsitive number The reverse is also tiUe~use theCOmPle~n~ of a negative numshyber in complement form produces the equivalent positive number To see this consider the sJlbtr~ction ( 76) -- (13) = +7 In binaIy_ with eight bits this ()peiationis written as (11111010 11110011) The subtracti~ri ischmlged ~ addition by taking the 2s complement ofthe subtrahend (-13) giving (+13) In binaly tbis~ 11 niOlO+ 00001101 = lOOOOOU1 Removing the end~ we obtain the ootrect answer ()()()()() III (+7)

Itisworth noting that binary DUmbersinthe signed-complement system are added and subshy tracted by the same basic addition and suPtraction rules as unsigned numbers Therefore comshyputersneed omy one common hardware circuit tobandle bothtypcs ofaritbtnetic The user or programmer ~ust interpret the reswtIi of $l1ch addition or subtraction differently depending on whether itisassumedtha~the numbe~ are signed ltr tinsigned

j

BINARY CODES

Digitalsystems use signalsthat have two distinct values1Uld circuit elements that havetwostashyble states There is a direct analogy anrong binary iignals binary circuitelements and binary digits A binary number ofndigitsfor example may be represented by n binary circuit eleshyments each baving an output sig~alequivalen1to Oor I Digital systems represent (Uld mashynipUlate not omy binary numbers but alsO many other diScrete elements of information Any discrete element of informatioIidlat is dis1iilct among agroup of quantities can be represented witha binary code (Le a pattern of Os and fmiddots) The codes must be in binary because in todays techIiology omy circuits that represent and manipulate patterns of 0s and ls can be manufactured economically foru~ in computers However it mtistbe realizCd that binary codes merely change the symbols not the meaning ofthe ele~nts of infonbationthat they repshyresent IT we inspect the bits of a computer at random we will find that mostofthe time they represent some tYPe of coded information rath~ than binlUY numbers

AIln-bit binary code is a groopofn hits that assumes up to 211 distinct cOmbinations of ls ~d Os with eacn combination representing one elementof tnt set that is being coded A set

of four elements clab becoded with two lilS with each ~lementassignedoneof thefoUowing bit oombinationsOOO I 10 J 1 A set of eight elements requiies a three-bit code 00 a set of

18 Chapter 1 Digital Systems and Binary Numbers

J6 elements requires a fourmiddotbit code The bit combination of ann~bit code is determined the count in binuy from 0 to 21t - t Each element must be assigned a unique binuy bit binationand no two elemerits cm havetbtsamevalueothenvisethe code assignment be ambigUous

Although the minimum nqrnber of 1lits required to code 21t distiItct quantities is nthere nomaximwn numbe( of bit that may he used for a binuy code For example the 10 digits can be coded with 10 bits and each decimal digit can be assigned a bit combination nine OSmid a 1 In this pamcularbinarycode the digit6 is assigned the bit )UllIUlauuu0001000000

BCDcode

Although the binary number systemis die ~ost natural system for a computer most people more accustomed to the d~imal system One way to resolve this difference is to convert

inlal nUmbers to binary perform all arithmetic calculations in binary and then convert the nary results back to decimal This metbodrequites that we store decimal numbers in

cOinputer so that they canbec6b~rted to binary Since the compllter Can accept only valueswe must represent the decimal digits by means ofa code that contains ls and Os also pOsSible lopedorm the arithmetic operlltiorisd1rectly on decimal numbers when they stored in the comput~ in cod~ct form

A binarycodewill have some unasSigned bit com~inatiqns ifthe num~rofelements in set is not amultiple power of 2 The 10decimai digits form such asel A biruuy code that tinguishes among 10 elements must coiltain at least four bits but 6otitofthe 16 possible binations remain unassigned Different binary code$ can bemiddotoNained by arranging four into 10 distinct combin~tions TheicodeIllcfflt oommonly used fdr the decimal digits is straight binary assf~ntlisted in Table 14 This scheil)eis called bittary~coded decimal

is commoolyreferred to as BCQ OtherdecimalcodesaIlfpossible and a few of them are sentedlaterinthis section

Table 14 BinarymiddotCoded Oeclmql (BCO)

Decimal BCD SnlboiDIgIt

o 0000 1 0001 2 0010

3 0011 4 middot0100 5 0101 6 0110 7 0111 8 1000 9 1001

Sectionmiddot 17 BInary COdes 19

Table 14 givesthe four-bit code for one decimal digit A number with k decimal digits will require 4k bits in BCD Decimal 396 is represented in BCD with 12 bits as 0011 10010110 with each group of 4 bits representing one decimal digit A decimalmiddotnumber in BCD is the

- same as itS equiyalent binary number only when the number is between 0 and 9 A BCD numshyber greater than lOJpoks different from its equivalentbinary number even though both con tainls and Os Moreover the binary Combinations 1010 thrpugh 1111 are not used arid have no meaning in BCD Consider decimal 18SlUld its corresponding value inBCD and bUtary

(185ho = (0001100001Ol)BCD = (l0111001h

The BCD value has 12 bits to encode the characters of the decimal value but the equivalent binary number needs only 8 bits It is obvious thatthe representation of a BCp number needs more bits than its equivalent binary value However there is an advantage in the use ofdecishymal numbers because compUterinput and output data are generated by people who use the decshyimal system

It is important to realize that BCD numbers are deCimal numbers and not binary numbers although they use bits in tbeir representation The only difference between a decimal number and BCD is that decimals are written with the symbOls 0 1 2 9 and BCD numbers use tbebinarycode 00000001 001O~ bull 1001The decimal value is exaCtly the same Dec~mal 10 is represented in BCD witheight b~ts as 00010000 and decitna1J5as 0001 01Of1lte corshyresponding binaryvalues are 1010 and 1111 and have only four bits

Consider the addition of two decimal digits in BCD together with a po~ible carry from a pre- vious less significant pair ofdigitsSince each digit does not exceed 9 the sum cannot be bull greater than 9 + 9 + 1 = 19 with the 1 being a previous carrySllppose we add the BCD dig-

its as if they were binary numbers Then the binary sumvill produce It result in the range from degto 19 In bin8ry thistange wil[be from 0000 to 10011 butin BCD it is frOm 0000 to

I 1001 with the first (ie leftmost) 1 bemg a carry and the next fo~ bits being the BCD sum When tPe binary sum is equalto or less than 1001 (withaut 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 (0110h to the binary Sum cOnverts it to the correct digit and also produces a catTy as required This is because a carry in themost significant bitposishytion of the binary sum and a deCimal carry differ by 16 10 = 6 Consider the following three BCD additions

4 0100 4 0100 8 1000

+S +0101 +8 +1000 +9 1001 9 1001 12 1100 17 10001

+0110 +0110----

10010 10111

In each case the two BCD digits are added as if they were two binary numbers If the binary sum is greater than or equal to 1010 we add 0110 to obtain the correct BCD sum and a carry In the flIst example the sum is equal to 9 and is the correct BCD sum In the second example

20 Chapter 1 Digital Systems and BInary Numbers

the binary sum produces an iJlv~ BCD digit The addition of0110 produces the cortect BCD sum 0010 (ie the number 2) and acanyInthetbirdexample the binalY SUDlproduces acany This condition occurs wben the $W)) is greater than or equal to 16Altbough the other fout are less than 1091 the binary 9Ulll requires acOnectionbecause of die carry Adding 0110 obtain thetequiled BCD sum 0111 (ie the numblaquo 7) and 8 BCD CiUT

The additionoftwondigit unsipedBCD numbers follows the same procedure COIlSioll the addition of 184 + 576 1= 76() in BCD

BCD 1 I 0001 10000100 184

+6101 ~

0111--- 0110 +576

lJinarysum 0111 10000 1010 Add6 ono 0110

BCDsun 0111 0110 0000 7(1)

The flfSt l~ sigDiticant pili- of BCD digits produces aBCDdigi~SllDlof 0000 and a for the next pair of digits the second parr or BCD digits plus a ~Vi0U8 cany produces a sum of 0110 and a carry for the next patr()fdigits The third pair of digits plus acarry proltIUC~ a binary s~ of 0111 and does not require a correction

Decimal Arithmetic The represeiltation of signed decimal numbers in BCD is simiiarto the tepresentation of numbers in binaryWe can useeitheI the familiar signed-magnitude system at the SllZllOO-COI1I

plemelit system The sign of a decimal number is tJSually represented with four bits to to thefour-bit code ofthe decimal digits Itis customary to designate 8 plus With four Os 8 minus with the llCDequivalent oi9 whlcq is 1001 The sigiled~magnitudesystem is seldom used in com~tersThe signed-complerDem ~~ either the 9s octhe 10s complement put the lOscomplement is the one most useP To obtain the lOs complement of aBCD numberwe first take the 9s complement then add 1 to the least significant digit The 9s Complement is calculated from the subtracloo of each digit from 9

The prltXeduresdevelope4 for the signed-2s-complement system in the ~vious also apply to the signed-IOs-complement system for decimal mimberS Addition is done summing all digits including the sign digit and discafding the end carry This operatiQ assumes that all negative numbers are in 10s-complement form COOsider the (+375) + (-240) == + 135 done inthe signed-complement system

o 375

+9 760middot

o 135

lhe 9in the leftmost pOsition of the second n~ber tepresents a minllS and 9760 is the complement o( 0240 The two numbers are added and tbe end carry is discarded to +13SOfcourse the decimal ntmlbers insi~ tile computer includingthe sign digits in BCD The addition isdone with BCDOigits as described previously

Sectionl 7 Binary Codes 21

The suQtr8ction of decimalliUJ1lbets either unsigned or in thesi~-~Oscomplement systetn is the sameu in the binary case Taketbe 10s ootnplementof the subtrahend and add i~ to themin~nd ManyooDlputerslULvespeciaJ hardware to perform arithmeticcalculations directly withdecilnal oumbers in 8tDThe~u$etofthecoBlPuter can specify programliled Wtnlctionsto JOdonn the aDtiuJletiP oPmwoowithdeQmal n1UQ~ ~ywithout having to convell them to binary

Binafy codes for decimal digits requirea minimum of four bits per digit Many different codes can be formulated by~gjng four bits into IQ distinct combinations BP) and three other representative codes are shown in Table L5 Each code uses only 10 out ofa pOssible middot16 bit combinations that can be arranged with four bits The other six Unused cOmbinations have no meaning amt should be avoided BCD and the 2421 code are examplesofweigbted codes In a weigbtedcodeeach bit position

juBsigned a weighting f~in~awaythat eaehdigitcanbe ev~by 8dding the wei~ oran the lsin thecoded combination The BCD code has weights of8 42 and I which cotteshy

spondiothe powe1Of-two valuesofeaCh bitTbebitasSignmeatOll0 for example is interpreted by the weights to represent dedma16beCause 8 X 0 +4xt +2 Xl +IX 0 6Thebit combination 1101 when weighted by the ~ve digits 2421 gives themiddotdeCimal equivalent of 2 X I +4 gtlt I + 2 KO + 1 X 1 = 7 Note that some digits cantle coded in lw9 possib)e

ways in the 2421Q)(feFOr inke decimal 4 can be asSigned to bitCombinadon 0100 or 1010 since botbcOmbinatibns add upto a totalweight of4

middot1$ Fou Dlf(et Blnqry Code$ for thtJledmol DIgits

~ IICD DIgIt sal MZt Exeet) 8 4 -~1

0 1

000() middotmiddotmiddot0000 001)1 0001

oem 0100

0000 0111

2 0010 0010 0101 0110 3 0011 OQU 0110 0101

4 0100 0100 0111 oroo 5 0101 lOll 1000 1011 6 OlIO middot1100 1001 1010 7 middot0111 1101 1010 J001 8 1000 IUOmiddot 1011 1000 9 1001 11U 1100 1111

1010 oloi 0000 0001 Uaused IOU 0110 middotOOOl 0010 bit 1100 0111 0010 0011 combishynations

nOl 1110

lOW 1001

HOI 1110

1100 1101

1111 IOU) 1111 1110

22 ChaptfrliDfgltalSystemsaod Btoary Numbers

I1te 2421 rind the

e~l3~es are exampks Of self-complementing codes Such codes have~propertyjbatthe9s~plement ofa deCimal nfunberigobtairted directly by chang-

ing 1$ to O~$ finO tYSCfb1 sie~bycomple~mmgeaCh bit in the pattem)For example decshyimat3~Sis re~ fu tbeexcess3code as 01101100 1000 The 9s compl~ntof 604 isrepRse~l00liOOllelliwbich isobiainc(himply by complementing each bit of the

code (as with the 1 s coinpl~ofbin~rillDlbers)middot Theexcess~3code has been used in some oldel coritputers because of its selfcpmplement~

ing property Excess-3 is an unweighted code inwhich each codedcombinationis obtained-fJQm the corresPonQing bin3ryvalueplus 3 Note that the BCD code is1~ self-complementing TheS 4 ~~ Icode isan example of assigning both positive and negative weights to ~ decimalcodeInthis case the bit combiDation 0110isin~reted as oecimal2 and is calcu-

latedfrom8XO+4X 1 + (2) X 1 + (1XO=2 ~

Cra Code _ _ J

l1te output data QfmaJlfpbYsicaimiddot $)ShmlS are quantities that are continuous These data bemiddottonverted~digiWforuitJefore they art applied toaliigital system Contfuuous or ~nisCOIl~middotUitodigitalfonn bymeans of an rumlog~digitalConverter It is times ~~ent tousethe Gray code slown inTable 16torepresehtdigiuU data that have oon~ fMn8D8l08 dasaTheadvantage of th( Gray cOOeover thesllaigbt binary nIl11l1hPt~

~lt~thatoWY~ hit in the codegroup changeSin going from one number to the For examplcentbullin-goingfrom 1 to 8dleGray code cblngesfrom 0100 to 1100Only the fust changesfromOto l~the odter~ I)its mnaintbesame By contrast With binary numbers change from 7 to 8wrube from 0111 to lOOOwhich causes allfciur bits to change valUes

TabielAi GtPyCode

01 Decl COde Equivalent

~ 0000 0001 0011 OOlG 011Q Olll OlO 0100 1100 11m 1111 1110 lOlQ 1011

lOOt i

1000

o 1 ~ 3

4 5 6 7 8 9

10 11

12 13 14 15

SectIOnl7 BlnarYCod~s 23

The Gray code is used in applications in which the normal sequenceOrbiruuy rium~may produce an error orambiguitymiddot during themiddot transitionfrom ODeDWDber to the next If binary numbersareusec1 acbange forexaJIlple nom 0111 to 1000 may produce anintermediateershyroneous number 1001 if the value ofthe rigbtmost bit takes longer to -change than domiddotthe valshyues of the other three bits The Graycode elimb1ates this problem since only one bit changes its valve dUrlng aily transition be~een two numbers I

Atypical appli-cation ofmiddotthe Gray code is the representation of analog data by a Continu ous change in the angUlar position of a shaft The sQaftmiddot is partitioned into segments ana each segment is assigned a number If adJacent segments are made to correspond with the Qray-Codesequence ambiguity is eliminated between the angle of thesbaft and the value encoded by the sensor

Character Code

Many applications of digital computers require the handling not only ofnumberS but also of other characterS or symbols such as the letters of the alphabet For mstancean insurance comshypany with thousands of policyholders will use a computeX to process its files To represent the names and other pertinent information it is necessary to fonnulate bull binary code for the letshyters ofthe alphabet In additiQt1 the same binary qode must represent numerals and special Characters (such as $) An a1phanumeric character setis a set ofeiements that inclUdes the 10 decimal digits the 26leuersofthealp1iabe and a nutnbeof special~S~ a set conshytains between 36~d 64 elements ifonIy capital letters areincltided or between 64 and 128 e1eJDents ifboth uppercasemiddot and lowercllle etters are inclUded In the first case we need a bi- nary code ofsix bits and in the second we need a binary cooeO(seVM bits

The standaM binary code for the alphanumeric char8cters is the American Stahdard Code for Information InterCbange (A~n) which uses seven bitS to code 128 characters asshoWn in Table 17 The seven bitsof the code are desipted by b~through h With h the mostsigshynificant bit ~e leUer A for example is represented inASCn as l(l()()()Ol (column l00~tOw 0001) The Ascn ()()de also contains 94 graphic characters that can be printed and 34 nonshyprinting characters used for variQUS control functions The graphic characters consist of the 26 uppercase letters (A through Z) the 26 lowercase letters (a through z) the 10 numerals (0 through 9) and 32 special printable characters suchaS andS

The 34 control characters are designated in the ASCTItable With abbreviated nalne8 They are listed again below the table with their functional names The control characters are used fQr routing data and arranging the printed text into a prescribed format~ There are three types of control characters format effectors information separatOrs andcommumc~on-COnlrpl char~ IlCters Format effectors are characters that control the layout ofprinting They inciude the fashymiliar word pr6cessorand typewriter controlssucb 8$ bac~pace (BS) horizontal tabulation (HT) and carriage return (CR) Information separators are used to separatetbe data into divi~ sions such as paragraphs and pages Theyinclude characters such as ~ordseparator (RS)and file separator (FS)The cODlIDunication-control characters are uSefulduriDgthe transmission of text between remote tenninals EXllll1plesof conlmunicatiOn(ODtiol~ are STX (start oftext)-and ETX (end of text) whicb are used toframe a text mesaagetnQlSlnitted through telephone wires

24 Chap~er 1 Diglt8l Systems and Binary Numbers

rblel7 Amerkcm5tandard Code for Information (nterclHlnge(ASCII)

b~jbzb 000 001 010 on 100 101 no 111

0000 NUL )jLP SP () p P 0001 SOH OC1 1 A Q a q

R0010 STX OC2 2 B b r 0011 ETX DC3 3 C S Ii S

0100 EDT 0C4 $ 4 D~ T d t 0101 ENQ NAK 5 E iU e u OUO ACK SYN amp 6 F V f v 0111 BEL ETB 7 0 W g w 1000 B8 CAN ( S H K h x 1001 HT EM ) 9 I Y Y 1010 LF SU~ 1 Z j z lOll VT ESC + 1lt r k UOO FF PS lt L I I 1101 Cit OS == - M 1 m 1110 SO R~ N 1 n shy

-0PIt st US f 1 0 0 DEL

r- Control characten

NUL NlI]l DlE Data-inkescape SOH Start of hea~ng DC1 Device cOntroll STX Start of text DC2 DevIce io~1lOi2 ETX End (Jftext i DC3 Device corUlri1 3 OOT End oftraIlsmission ~4 DeVicecoQtrol4

ENQ ampqwry NAK Negativeackilowledge ACK

Acknowledge SVN Sync~nous idle

Btl Bell ETB End-of-tmnsnussionblOck sS Backspace CAN CanCel HT Horizontal tab EM End of mediUrlt LF Lintifeed SUB Substitute VT Vertical tab ESC escape FF form feed FS File separator CR Carriigeretum GS Group separator SO shift Ollt RS Reoord sepuator SI Shlftin US Unit separator SF S~e DEL Delete

ASCII is a seven-bit codebutrnostcompUters manipulate anejght-bit quantity asa unit called a byte Therefore ASCII characters most often are stored ~e per byte The

I biti~sometimesused forotlef purposes depending ontheapplicatio~lFor example printetS recognize eightmiddotbit AScn chaiacterS with themost sigoificaot bit ~twO An atkJlitlo

Section 18 Binary Storage and Registers 2S

128 eight-bit characters with the most significant bit set tol are used for other symbols such as the Greek alpbabet or italic tyIe font

Error-Dtectlng Code

To detect errors in data communication and processing aneigbth bit is sometimes added to the ASCll cbaracter to indicate its Panty Aparitybit is an extra hit included with a message to make the total num~ of ls either even or odd Consider the fo119wing two cbaracters and their even andodd parity

With even parity With odd parity Ascn A = 1000061 01000001 11000001 ASCI( T == 101deg100 11010100 01010100

1

- Ineacb casewe insert an extra bit in the leftmost position of the code to produce an even number of 1 s intQe cbaraeter for even parity or an odd number of 1 s in the character for odd parity In generlll one or tbe oth~r parity i~ adopted with even parity being more common

The parity biqsbelpful in detecting errors during the transmission ofinformation from one location to another nisfuJictiOD is bandIed by generating an even parity bit at the sending end for ~h character The eight-bit characters that include parity bits are transmitted to their desshytination The parity ofeachebaracter is thetichecked at the receiving~nd If the parity of the received cbaracter is Dot even then at1east on~bit has changed value dUring the trmlsmission This method detects one three or any odd combination of errors in each character tb8t is transshymitted An even combination oferrors however goes undetected and additioDaterror detic- shytion codes may be needed to take care of that possibility

What is done after an errQlis detected depends on the partieu~ application One possishybilityis to request retransrois~ion of the message on the assump~on that tbeenigtr was ranshyd()m andwill not occur again Thus if thereeeiverdetects a parityerrorit sends bai~ the ASCII NAK (negative acknowledge) control cnaracter consisting ofail even-parity eight bits lOOlOl01H no error is detectedthe ~iversends back anACK (aCkno~ledge) conshytrol character namely 0000011 O The sending end will respond middotto an NAK by tranSmitting the message again until the correct panty is received Ifmiddot after a number of attempts the transmission is still in error a message can be sent to the Operatai to check for malfunctions in the transmission path

BINARY STORAGE ANORECiISTEIlS

The binary infonnation inadigitalcomputermust have a physical e~stencein some medium for storing individual bits A binary cell is a device that possesses two stable sttes and is cashypable of storing pne bit (0 or 1) oflnfotlllation The input to tbe cell receives exciJation sigshynals that set it to one of the two states The output of the cell isa pbysicalquantity that distinguishes between the two states The irtformationstored in Ii cell is 1when the cell is in one stable state and degwhen the Cell is in the other stable state

26middot Chapter 1 Digital Systems and BtnaryNumbers

Registers

A register is a group of binary cells A register with n cells can store any discrete quantity of middot information thatcontains n bits The state ofa registeris an n-tuple ofls middotand Os with each bit designating the state of one cell in the register The C()ntent ofaregister is a function of the int~rpretation given to tbeinformation stored in it Consider fQf ex~ple a 16-bitregister with the following binary content

11 00001111001001

middot Aregjs~ with 16 cells can be in one of 216 possible statesIf one asstimesthat the content cif the register represents a binaryinteger then the register can store any binarydumber from Oto 216 - 1 For the patticularexample shown the content ofthe register is the binary equivshyalent(lftbe decimal number 50121 If one assumes instead that the register stores alpbanushy

middot meric characters of an eight-bit cooe then the content of the register is any two meaningful characters For tht ASCII code with anevenplirityplaced in the eighth most significant bit position the register contains thetwo charactersC (the lefunosteightbits) and I (the rigbt~ most eight bits) If however one in~rprets the content of the register to be four decimal dig- its represented by a four-bitcode tnenthe content of the register is a four-digit decimal number In theexcess-3 code the register holqs the decimal nutriber 9096 The content of the registe~is meaningless in BCD becau~e the bit combinatiOn ltob is 110t assfgned to any decshyimal digit From this example it is clear that a register can store discrete elements of inforshymation and that the same bit configuration Inay beinterpreted dlffe(ently for different types of data

tmiddotmiddotReglsterTrail Adigitalsystenlis characteriZed by its registers and the components thatpetfolin data proshy~ssingIIl digital sy~tems a rcentgister tra1lsfer operation is abasi operation that consists of

middot a transftr of hiJWy hUormation from one ~t of registers into ano$er set of registers transfer may be dir~ctfr9m one regist~r toanlt)ther or may pass througb datamiddotprocessing circuits to petformaD operation Figure L 1 illustratel the transfer of iidOrnuttion among regshyisters anddemonstratespictorlallY [the tr8ll~~ ofbinaryinformation from akeyboard a register in the memQryullit Thehlputunit~s assumed to have a keyboard1 control cuit and aninput register Each time a key is strock the control circuit enters an ImnV$_

lent eight-bit alphanumeric character coqe into the input register We shall assume that code used is the ASCII code with an odd-parity bit The information from the input regisshyter is transferred into the eight-least significant cells Qf a proeessOr register After transfer theinpui register is cleared to enable the control to insert a new eight-bit when the keyboard is struck again Each eight-bit character transferred to the pro1c4ess(raquo register is preceded by a shift of the previous character to the next eight cens on its left~

middot a transfer -of four characters is completed the processor registeris full and its contents transferred into a memory register The content stored in die memOry register shown in Figl came from the transfer of the characters J 0 H an~ N aftet the four ap)lroJ)riatt keys were struck

Section 18 Binary Storage and Registers 27

FIGURE 11 Transfer of information among registers

To process discrete quantities of infoiniatiori in binary form a computer m~st be promiddot vided with devices that hold the (lata to be processed and with circuit elements that manipmiddot ulate individual bits of irifonnation The device most commonly used for holding data is a register Binary variables~ manipulated by means of digital logic circuits Figure 12 il~ luslrates the process of adding two l()bit binary iUlmbers Themeniory unit which no[shy

mally consists of millions of registers is shown with only three ofits registers Thepait of the processor unit showncoDsistsmiddotofthree registers-RI R2 and R3~getherwith digital logic circuits that manipulate the bits of RI and R2 and transfer into R3 a binary number equal to their arithmetic sum Memory registers store information and are incapable of pr0shy

cessing the two operands However th~ information stored in meDij)iybanbetransferred to ~ processor registers and the resUlts obtainedin processor tegisters can be transferred back into ame~ry register for storage Untill)ecded again The diagram ~wsthe90ntents of two

operands transferred from twoJDemoryregisters into RI imd R2 The digital logic circuits produce the sum which is transfened to register R3 The contents of R3 can now be 1riUlsshyferredback to one of thetnemory registers

The last two examples demonstrated the infonncion-flow capabilitieSofa digital system in a simple manner Themiddot registets of the ~ystem are the basic ele~ents for Noring and holding the binary information~igitallogic circuits process the binary ihfonaation stored in the

28 Chapter 1 DigIt bullbull Systems and Binary Numbers

Sum

FIGURE 12 Eumple of blnarylnfonn~t1on processing

registers Digitallogiccirctiits and registers are covered InChQpteB 2 throQgh 6 The metlilOlY unit is ~xPIained ill 9aptet 7 Th~ descriptton of register opetJtions at the register level and the design of digital systems are covexed in Chapter 8

19 BINARY LOGIC

Binary logic deals with variables th~ take on two discrete valueund withoperations that sumelogicalmeaning~ The two val~s the variableussume may be called~ydifferent (true andalse yel and no etc) but for ourp1llpQSe it is cpqVenienttotbink in terms of and assign the values llUld O The binary logic intr0ducedin this section is equivalent to algebra oalledBoolean algebra The fannal presentation ofBoolean algebra is covered in detail in Chapter 2 The purpose ofthis seCtion is to introduce Boo algebra ina matmerandlate it to digitallogiccircuits andmiddotbinarYsignalsmiddot

Section 19 Sinary logic 29 ~

Itkltn of IInary logic

Binarylogic consists of binary v~les and a set of logica1middotoperatiQDS The variables are desigshy ~by lettell of thCalplWlet~such asA B C x yz etc with eaCh variable baving two and oniy

two distinct posSible valueS 1and O There are three basic logical operations AND ORand NOT

1 AN]) This ~peration is represented by adotorby the absence ~f an oPerator For example x bull y =z or xy = zis~ x ANDy is equalto z~ThelogicaloperationAND is interpreted to mean that z == 1 ifand only ift~ land y = 1 otherwise z = O (Reme~r that x y andzare binary v8riablesand canmiddotbe equal either to 1 or Omiddotand nothing eise)middot

2 OR This operation IS represented by a plus sign For example x + y =z is read x OR y is equal to z meaning that z 1 if x = iorif y = lorifbothx= 1 and y = 1 If bqth X - 0 andY Omeo z= O

3bull NOT This operation is repf6sented by a prime (sometimes by an overbar) For ~xample x =Z (or~ =z) is read notdsequalto 1 meiming that z iswkatx isnot In other

words ifx = 1 then z == 0 but if x == 0 tnenz = L TheNOT operationisals(1 reshyferred tolls the complement operation since it changes ~ 1 toOand a O to 1

bull bull lt Binary logic resembles binary arithmetic and themiddot9peratioos ANDahd OR have similarishy

ties to multiplication and addition respectively In fac~ the symbols used for AND and OR are the same as those used for multiplication and addition However binary lOgic should not be conshyfused withbinaryarithIrietic One should realize thatan arithmetic variable designates a numshyber that may consist of many digits A logicmiddot variable is always either 1 or O For example in binary arithmetic we have I +1 =10(read~one plus ()fie is equal to 2) whereas in binary logicwe have 1 + 1 1 (read one OR onds equal to one)

For each combination of the values oix and y bullthere isa value of ~ $pecifiedby the definishytion of the logical operation D~linitiops of logical~perations maybe listed in a compacHorm called truth tables A truth table is atable of anpbssible combinations ofthe variables $howshying the relation between the values that the variables may take and the resultof the operation The truth tables for th~ operations ANDand OR with variables x and y are obtained by lis~ng

all possible values that the variables may have when combined in pairs bull For each combination the resUlt of die operation 18 theillistedin a separate row The truth tables for ANDORand

NOT are given in Table La These tables clearly demonstrate the definitionf the operatibns

Table 18 Truth TcibJts of Logical Operations

AND OR NOT

x y xmiddoty x y x+y

0 0 0 0 0 0 1 0 0 1

10

1 0 d 1 0 1 I 1 1 1 1 1

bull~lt~m

30 Chapter 1

Logk Gates

Digital Systems and Binary Numbers

Logic gates are electronic cirellit that operate on ~

variable

or mpre mput tignals to produce an output signal Electrical signals sUch as voltages orrutrents exist as analog signals having values over a given taDgebull saYOt03 V but in a digital system are interpreted to be either of two recognizable values 0 or 1 Voltage~opetated logic Circuits respond to two separate voltshyage levels that represent a binary varjable equal to logic I bt logic O For example a partic- ular digital system may define 10gicOas a signal equal to 0 volts lind logic 1 asa signal equal to 3 volts In practice each voltage levelhiS an acceptable rangeas shown in Fig 13

The input te~nals of digital cikuits accePt binary signals within the allowable range and respond at the output terininals with binary signals that fall within the specified range The intermediate region between the aJl()wed regions is crossed only during aState transition Any desired information for computing or control can be operated tm by passing binary signals through variQUS combinatioDsof logic gates with each signal represebting a particular binary

The graphic symbols used to deSignate themiddotthree types of gates are Mown in Fig 14 The

gates are blocks of hardware that prooocc tbeequivalent of1ogic~1 orlogic() output signals

Volts

- FGURl13

x

y

Exampleof binary slgnaJs

Signal ratlge for logieO

(a)~omiddotinput AND gate

FIGURE 14 SymbOls for digital logic circuits

(c)NOT gate or invert~

Problems 31

x-lU 1 11 P 0

y 0 0 11 1 ~

ANDxy 0 0 rTl 00

ORX+Y~ NOT x 11 0 0 I 1 1

FIGURE 15 Input-output 5Igals for gates

FIGURE 1

A B C

Gates WIth mlltlple JnpUU

A B C lJ

~

if inPllt logic ~ts are satisfied Theinput signals xaDd y intheNDaadQR gates may exist in ~ oHow-possible states 00 10 11 or 01 Il1ese ibpu~ampignals_ shown inFig lStoshygetber with the corresponding output signal foreach PfCThI~tiaiug~iDustrate the reshysponse ofeaclt gate to the four input signal~The~llisofthetiminadiagram represents time and the vertical axis sbo~~~~ it cbapg~botwcen~possible voltshy

age levels The low level represents logic O tJte high level l1lteAND _ responds With a logic ~ ~tput sipl wh~ both input ~~)e 1middot1~ lIieOR S-~with a logic 1 outpUt signal ifanylnput sigrudis lOgic 1 TheNOTgateis~~ to BUll invedet The reason for~nameis~t froJn the signalmsponae inmiddottbe timitt8 diagramwhicbsbows that theoUtputsignal inverts the logic sense of tbeiDpUtsigll8l

AND and OR gates may bavei)lQte tbantwQinputs M AND8_~itti ~input$andan OR gate with foU) inputs are shown in Fig 16 The three-inPllt AND gate responds With logic 1 output if all tbreeinputs arelogic 11jleoutputproduces lOgic Oifanymput is logic O-The

four-input OR gate responds withlogic 1 ifany input is logic 1 its clu1ptltllCCoines logic oonly when all inputs are logic O

Answers to prvblems marked with middotappearaHbe ClOd ofthe ~

11 lJltthe octal and beXadecimalliurilbers trom16ui 32UdngA B1l1ld C forthebst~ digits Usttbe numbers from 8 to 28 in base13 bull

I

12t What is the exact D1Jllbcr of bytes in a system that contains lta) 32Kbytoe (b)64M ~and (e) 640 byte$ middot7 t

32 Chapter 1 Digital Systemsand Binary Numbers

13 Convert the following nu~bers with the indicated bases to decimal (a) (4310)s (b) (198hz (c) (735)8 (d) (525)6

14 Whllt is the largest binary number that can be expressed with 14 bits WhlIt are the equivaleDt ~~ iinal and hexadecimal numbei-s

--

15 Detemrine the base of thl1 numbers in each case for the following operatio~ to be correct (a) 142 = 5 (b) 5414 = 13 (C) 24+ 17 == 40

16 The solution$to the q~cequation xl - Ux +22 oare l1 3 arid x =6 What is the base of the numbers

17 Convertthehexadecimal ntmIher 68BE to bitiary and then convert it ~mbinary to octal

18 I Convert the decirpal number 431 to binary in tWo ways (a) Convertd~y to binary (b) conshyvert first to hexadecinla1 and then from ~decimalwbinary Which method is faster

19 amppress the following nqrnbersin decinud (a) IQ11O0101)z (b) (l65his (c)(2624)8 (d) (FAFA) 16

(e) (10101010)2

110 Convert the following binary numbers tobexadeoimal and todecitnal (a) UOOlO (b) 110010 Explain why the deCimal answer in (b)is 4 times that in (a)

111 Perform the followingdiviskmin binary 11 Ion + l()t

112 Add IlniImultiply tfle following numberswiihout converting them to decimal (a) Binary nuniberilOll aiIdlOh (b) He~uumbers 2E aDd 34

1~)( Do thefoHowing con~ersionproblems (a) CorivertCiecimal2731S to binary (b) CakUlate the binary eqUivalent (f 213 outto eight pl~Then Convert from binary to

imalHowgJose istbe result to 2131 (c) Convert the binary resukin (b) into hexad~ lb~oonvert ~result to decimal Is answer tbesame

114 Obtain the is 8nd 2s complementsofthe foUowing binaryDumbcentrs (aj l)()()(J()OO (b) OOOOOOOO (c) 11011010 (d)01l10110 (e) 10000101 (0 11111111

115 Find the 9s and the 10s complement of the following detimal numbers (a) 52734630 (b) 63325600 (c) 25000009 (d) 00000000

116 (a) Find the 16s complement of B2FA (b) Convert B2FA to binary (c) Find the 2scomplement ofthe resultin (b) (d) Convert the answer in (c)to hex~malandco~ with ihe an~wer in (a)

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 3: Chapter 01 - Mano

3 Section 12 BinarymiddotNumbers

A major trend in digital design methodology is the use ofa hardware description language (HDL) to de~ribeand simulate the function8llty ofa digital cinuit AnHDL resembles a proshygramming language and is suitable for describing digital circuits iDtextual fOrinmiddot It is used to simulate a digital system to verify its operation before bardwlUe is built in It is also used in conjunction with logic synthesis tools to automate the design PrQCesSmiddotBecause it is important that students becom~ familiar with an HDL-baseddesign methodology HDLdescriptions of digital circuits arepiesented iliroughdut the book While these examples help illustrate the feashytures ofan HDL theyalso demonstrate the best practices used by industry to exploilHDLs Ignorance of these practices will lead to cute but worthlessHDL models that may simulate a phenomenon but that canno~ be synthesized by design tools or to models that waste silicon area or synthesiZe to hardware that cannot operate correCtly

AB prevjously s~ted digital systems Qlanipulate discrete qllantities of information that are represented in binary form Operands used for calcU11tions may bJ eltpressed in the binary number system Other discrete elements including the decimal digits are represented in binary codes Digital circuits also referred to as logic circUits proces~ data by means of binary logic elements (logic gates)using binary signals Quantities are stored il1 binary (two-valued) stor- age elements (t1i~t1ops) The purpOse ofthis chapter islo introduce the various binary con~ cepts as a frame ofrcferenceforfurther study in the succeeding chapters

-

A decimal number such as 7392 represents a quantity equal to 7 thousaadsplu8 3 bunltlryens plUl 9 tens plus 2 units The thousands bundred$ etc are powers of Hlirnplied by the posi tion Ofthe coefficients in the number To be moreeltact 1392 is ashtmhai1d notation for what should Dewrinen as

7 x 10f+ 3 x middotmiddot1Q2 + 9 X 101 + 2 x 1O

However tqe convention is to write only the coefficients and fromdJeitpoSltiori deduce the bullnecessary powers 000 In general a number with a decimal point is repres~nted by a series of coefficients

a504a3a2afaO a_I a-20-3

The coe(ficients ajareanyofthe 10 digt~ (012 ~ 9)andthe$ubscript valuej gives the place value and-hence the power of 10 by which the coefficient m~t be multiplied Th~ ttte preceding decimal number cltn be expressed as

lo5a5 + 104a4 + 103a3 + 102~2 + 10Iai + 10deg00 + lO-la~1 + 1O2a~2 + 1O-3a_3

The decimal nQmber systeirt is~aidto be of basf -or radix 1Qbecause it uses 1 0 digits and ttiecOefficients are multiplied by powers of 10 The binarysystemis a differentoumber sysshytem The coefficients ofthe binary number systemh~veonltw~ possible values 0 middotand 1 Each coefficient aiismultipli~d by2i and ~e results are adQedto ~tain tbcdecimalequivshy

alent of the number The radix pUint (~gbull the decinwpoitlt when lOistherlWix) distinguishes positive powers of10 frofl negative powers of 10 For ~ple the ltkclmlil equivalent of the

-- - - - - - -

4 Ch~pter 1 Digital Systems andBlnary Numbers

binary number 1101011 is 2675 as shown from the multiplication ofthe coefficients by powshyersoH

1 X24+1 XZ3 +0 x22 + 1 X 21 + 0 X2deg +1 xri + 1 X r 2 = 2675~ In general a number expressed in ~ base-r systeIri has coefficients m~ltiplied by powers of r

anrn + an-l 71-1 + +a22 + alr +06 + a-I r-1

+ a_~r-2 + + q_mr-m

The coeffici~nts a j range ip value from 0 to 1 To distinguish between numbers of differshymiddot ent baseswe enclose the coefficients in parentheses and Vrite asubscripteqOal to the base used (exceptsometime~ fot decimal nwnlers where the content makes it obvious that the base is decimal) An example ofabaseS numlgteris

(40212)s ~ 4Xs3 -I- 0 XS2+ 2 51 + IX 5deg + 2 X 5-1 == 5114ho

The cOefficient values for base 5 can be only 0 I 2 3 and 4 The octal mllnber system is a base-8 system that has eight digi~ 0 1234 5 6 1~ An example of an octal number is 1274 To determine its equivalent decimal value we expand the nlim6er in apower series witba base of8

(1274)8 = 1 X 82 + 2x 81 + 7X SO+4 x g-l==(S75)lO

Note that the digits 8 and 9 cannot appearin an oCtal number Itis customary to borrow the needed digits forthe coefficients from tlle decimal system

when the base of thenmnber i~ less than lO The letters ofthe alphabet reusedto supplement the 10 decimal digits when ~ base of the number is ~than 10 For example inthe

middot hexadecimal(base-16) number systemthe fIrst 10 digits are borrowed fro1ll the decimaJ sysshytem ~ letters A BCD~E and F are used for thedigits 10 n 12 13bull 14 and 15 respec~ tively An exampICf ofa hexadecimar number is

(B65Fh6 = 11 X 163 + 6gtX 162 + 5X 161 -+ 15 X 16deg =(~~687ho

As noted before the digits in lJ binary number are called bits When a bit is equal to 0 it does not contribute to the sum during the conversion Therefore the conversion from binary to decshymiddot imal can be obtained by addingonly the numbers With powersofctwo cotreSpOnding to the bits

that are equal to lForexample

(1l0101h = 32+ 16 +4+ 1 = 53)10

There are jour ls in the binwy number The corre~pondil1g decimal number is the sum of the four powers of two Thefirst 24 numbersobtaiJted from 2 to tJl(~ power of n are listed in bull Table 11 In computerwork 210 is referred to as K (kilo) 220 as M (mega) 230 asG (giga) and 240 as T (tera)Thus 4K = 212 4096 and 16M 224 = 16777216 Computer cashy~City is us1ial1y given inbyte$ A byte is equal to eight biis arid call ~onuriodal (ie represhysent the code of) onekeyboard character A computer hard disk with four gigabytesof storage

has a capacity of 4G = 232 brtes (approximately 4 billion bytes)

Section 13 ffumb~r-BaSetonver5iotls S

Table 11 Powers of Two

~ n 1 n Z n Z

0 1 8 middotmiddot256 16 65536 1 2 middot9 512 17 131072 2 4 10 1024 18 262144 3 amp 11 2048 f9 524288 4 16 12 4096 20 1048516

5 32 13 8192 21 2097152 6 64 14 1(i3amp4 22 4194304 7 128 15 32768 23 8388608

Arithmetic operations with numbers in base followtht same rules as for decimal nun1- hers When a base othef than the fariilliar base 10 is used one must becarefuho use only the -allowable digits~amples of~di~on subtraction and multipliCation oftwo binary numshybers are asfoUows

augend 101101 nlinuend 101101 multiplicand 1011

addend +100111 subtrahend -tOOtH multiplier XIOI sum 1010100 difference 000110 1011

0000 1011

product HOli

The sum oftwo binaiy numbers is calculated bY the sam~ rules as in decimal except that the digits of the sum ifl any sigiuficaOt position can be oDly 0 or 1 Any carry obtained in agiven significant position is uSed by the pair of digits one significantplt)sition higher Subtraction is slightly more complicated Tho rules are still the sam~ lismiddot ip declmalexcept that the bonow in a given signifieantposition adds 2 toa minuend digit (A bonoW in thedeeimaI syste~ adds 10 to a minUend digit) Multiplication is simpIefhe mo1iplier digits are 8lWaYs lor 0 thereshyfore the Partial produCts are eq~ either to the multiplicand Or la O

Theco~vefsio~ ofan~~r in ~a~e ~decimaI is40nebYexPamnngth~ntunber in a power series and adding all the terixlsasshown previOU$ly We nowptesel1u generij procedure for

the reverse operation of conyertirigadecimalnuil1ber~ anum1gtel in hasedfthe number inshycludes a radix point it is necessary to separate tbenumber~toan inte~partand a fraction part since each part mus~be converte4 diffqeptlyThe conversion ofadecimalinteger to a num- berin basO risdont by tlividingthe humber SAd all Successiv~q~nts by ~d8CCUllUlal- ing therem~ This procedure is best illustrated by example

6 Chapter 1 DigitatSy$tems and BInary Numbers

111411

Convert deciIIla14 r to binary First 41 is divided by 2 to live an integer quotient of 20 and a remainder of i Then thequoiientisagam divided by 2 to give anewquotient and remainder Theproeess is ~ntinued untilth~ integer quotient becomes O The Cf)eJJicients of the desired binary number are obtained fJOm the remainders as follows

Ioteger Quotient Remainder Coeflldent

4112= 20 + ah= 1 2012 10 + 0 at= 0

1012 = 5 + 0 a2= 0

512 = 2 + 1 a3 = 11 Z2 1 0+ G4=O

I112= 0 + 2 as =1 lt

Therefore the aDsWeris(41 )u)= (llsa4~3f12alaoh =(IOlOOlh The arithmetic proCess can be manipUlated moreconvemently as follOws

Integer 41

20

10

5 2 1

o

Relnamder

1

o o 1

o J~

1 101001 ==answer

Con~ersi~n from decimalintegeJS to lQ1ybase-r Sstem i~ similar totljis example except that division is done by r iil$teadof2

1I1t4191I Convert decimall5lto oCtal The required baSe r is aFirst 153 is divi~ by 8 tQl1ve anin- tegerquotient of 19 and a remainder of lThen 19 is divided by 8 to give an ~tegerqlotient

of 2 anli a remainder of 3 tFiny 2 is divided by 8to give aquotientof 0 and a remainder of 2 lbisproeess can be conveniently manipulatecfas follows

153 19 J

i 3 o 2= (23J)s

7 Section13middot Number-Base Conversions

lhe(OllVelSiOllQCdecimalfrmtonto binary js accompllshedby a ~od similar to tbai uscd for ~~veri multiplication is used instead of division and integers instead of

rem~ are acc~aQd Agafu~ the method is best explajned by example

bull Co~vert (06875hotobmaryFirst 06875 i~ multiplied by2 to give an integer and ajraction nen the new fraction is multiplied by 2 to give a new integer and a newfraction The process is continued until the fraction ~om~ 0 or until the nUJ1lber of digits have sufficient accuracy necoefficients oftbebinary nUlllberare ~btaipedfrolIl-~~ integers asfQUows

lnteger Fraction middotCoemclent gt~fn5 Jlt~~ i + 03750 a-I = 1

()37SO f(2 0 + 07500 g-2= 0

07500X2= 1 + 05000 D-3 - 1-

0-5000 X 2 == I + 00000 a~=l

J

) -

Thereforethe at)Swer is (O6875ho= (OD-lazQ-3D-4h= 010l1hshyTo convert adtcimal fractl9D to a number expressed in base 1 a-similar procedure isused HQwever multiPlication i~ by 1 instead all and the coefficlentsfound from the integers may

range iti value from 0 to r- 1 lI)stead of 0 and 1 bull bull bull - - -_ t lt~ 1

bull

O513X 8 = 4104

0104 X 8 = 0832 0832 X8 6656

0656 X 8 == 5248

0248 X 8 = 1984

0984 x 8= 7872

The an~wer to seven significant figures is obtained from the integer part onhe products

(OsP)IO= (0406517)8

middot8 Chapter 1 Digital Systems iilnd Binary Numbers

Ibo oonversion ofdecimalnumbers withbotMnteger and ftattionparts is done by con- vertingthe integer and the fraction separately and ihencombinihgthe two answers Using the re$Ults ofExamples 11 and l~ weobtain

(416875h~ (lOI001l011h

From Examples 12 and 14e have

(1535130 (2314tl6517)s

14 OCTAL AND HEXADECIMAL NUMBERS

The conversion frOm and to binary octal and bexadecimal plays an important role in digital computers Since 23 =8 and 24 = 16 each octal digit corresponds to thref binary digits and bull each hexadecimal digit corresponds to foUr binary digits The first 16 numbers in the decimal binary oct8r andhex~ecimalnumber systems are listed in Table 1-2

The comersion fm~ binary tooctal is easilyacltooiplishedby partitio~ng the binary num ber into groups oftbree digits each starting ti()n1 the binary plmt and proceeding to the left

I and to the right ~correspo~ octal digit is then assigned to each group The following example illustrates the proeedure ~

(10 110 001 101 011 11~ 100 000 lloh = (261537406)8 2 6 1 ~ 3 7 4 0 6

T_lel2 Numbers with Different-Baus

DecImal IY Octal Hexadecimal middot(base 10) (base 2) (b) (16)

i

00 0000 00 p 01 0001 01 1 02 0010 02 2 03 0011 03 3 04 0100 04 4 0 0101 OS 5 06 0110 06 6 07 0111 07 7

08 1000 10 8 09 1001 11 9 10 1010 12 A 11 1011 13 B 12 1100 14 C 13 1101 IS D 14 1110 16 bull

Ej

IS 1111 11 F r i

9 section 1S Complements

Conversion from binary to heudeciInal is similar except thatthe binary nutriber is divided into groups ofourdigits

(10 1100 0110 1011 1111 0010h = (2C6BJ2) 16

2 C 6 B P 2

The comsponding heX~ima1(o~ octal)~digit fOr each group of binary digits is easily reshymembeled from the values listed in Table 12

Conversion from octal or hexadeciInal to Jlinary is dOne by reversing the preceding proceshy(luremiddot Each octal digit is converted to its tbi-ee-digit binary equivalent Similarlyeach hexashydecimal digit is convertedioits four~digitbinaryequivalent1he procedure is illustrated in the following examples

(673124)8= (110 6

III 011 7 3

001

010 2

l00h 4

and

(306Dh6 = (OOlf 0000030shy

110 6

~101h D

Binary numbers are difficUlt to work with because they require three or fout times as many digits as their decimal equivaltmts Por exaniple the binary number 111111111111middotis equivalent to decimal409S Howeverdigital computers use biIUuy11UIhbers and itis soIIJet4nes necessary for the human operator or user to oonununicatedirectly With the machine by means of such num bers One scheme that retainsthebinary~ystem in the cotnputer but reduceS the number of digshyits the human must cOnsider utilizes the relationslripbetyeen the binary Ilumber system and the ~ or hexadeciinal system By this method the Ql1DaIlthinksin tenns ofQCtal ornexadecimal nurnbers and performs the required conversion by inspection when direct communication with the machine is necessary Thus thebinary number 111111111111 has 12 digits ~d isexpressed iIi octal ~ 7777 (4 digits) or in hexadecimal as FFF (3digits) During communication between people(about binary numbers in the coJlllQter)the octal or hexadecimal representation is more desirable because it can be expressed more compactly with a third or a quarter of the number of digits reqUired for the eqwvalent binary number Thusmpstcomputer manuals use either octal laquohexadecimal numbers to specify binaryqwintiti~ The choice between diem is arbitrary although hexadecimal tends to win out since it can represent a byte with two digits

PlEM ENTS

Complements are used in digital cOmputers to simplifydle subtraction operation and for logshyical manipulation Simplifying operations leads to simpler less expensive circuil$ to implement the operations There are two types of complements for each baSe-r system the radix comshyplement andthe diminished raclix cOtllplement Themiddotflrst is referred to as the rts complement and the second as the (r - middot1)scomplement When the value of the base r is substituted~ the name the twotypesare refefted to as the 2s complement and 1 scomplement fot binary numshy~rs and the lOscompl~ent and 9s complement fqrdecimal numbers

10 Chapt~rl Digital Systems and Binary Numbers

D~I~llhed Radix Complame~middot Gi~en a number N in base r haYing n digits the (r - 1)scomplement~f N is defined as

(rll - 1) ~NFotdecimainumbersr -= Wandr -1 9sothe9scomplementofNis (10 - 1) - N IIi this c~ 10 represents a number that consists of a single 1 followed by nOs 10 - lisartumberrepresentedbyn9sFOrexampleifn 4wehavel04 = 10000 and 104 - 1 = 9999 It follows that the9s complement ofa decimaJnumber is obtained by subtracting each digit from 9 Here are some nwnericalexamples

The 9s complement of 54670(Ms929999~ 546700 453299 bull - I

The 9scothplement of012398is999999~0l2398 =987601

For binary pumbers r =2 and r - l~ 1 sothe 1s complementofNis(Z - 1) - N Again 211 is represented by a binaty number thatconsistsofa 1followed by Ii0s 211 - 1 is abinary number represented by ~1s~FOr example if 11= 4 we have z4 = (10000)zand 24 - 1 = (1111h Thus the ls complement of a binary number is obtained by sUbtractiDg

each dig~t from 1 However when subtracting binary digits from 1 we can have either I -0= lor1 - 1 = 0 which causestbe bit to change from Oto 1 0( from 1 to 0 respec- tively Theretore the ls complement of a binary number isfonnedby changing 1s to Osand Osto 1s The f9llowillg are somenumqical ex~esI

~

The ls Complement of 1011000 isotOOiu

The 1scompieme~t oHlIOUOI is 10 tOOlO

The (r-l) s compleme~ ofoctal or b~xadechnalnumbers i~6btained by subtracting eaeh digit from 70rF (diicimallS) respectively~

Radl~ C~mplement

The s complement of an n~digit number N in baserisdefinedasrmiddot Nfot N i 0 and as ofor N = O~ Comparing with the (r- l)s ~entwe note that ~rs complement is obtained by adding Ito the (r - l)scomplement smcer - N= HA-- 1) - N] L lhus the lOscomplementof deein1al2389 is 76lO +1 = 7611 and is otltamed by adding 1 to the 9scomplernent value The 2s oomplementofbinary 1011oois 010011 1 =010100 and isobtained by adding 1 to the ls-complement value

Since 10 is a number represented by a 1 followed by n0s1011 N Whicb is the10S com~

plementof N can be fonn~d also by leaving allieasl sigtrlficani Os Unchanged the first nonurO least significant digit from 10 and SUbr8Cting all higher significant

from9 ThUs

the 10s complement of 012398js987602

and

11 Sectlon middot15middot Complements

The 10s complement ofthefustnumber isobtaineltibysublriiCtingSfrom lOin the least sig~ nificant position and subtracting all other digits from 9~ The 10s complement of the second number is obtained by leaving the to least significant Os unchanged subtracting 7 from 10 and subtracting the other three digits from 9

Similarly the 2s complement ~be fonned by leaving 1ll11east significant Os and tbe first 1 unchanged and replacing I swith Os and Os with ls in allother hi~r signifIcJUlt digits For example

the 2s cORlplement of 1101100 is 0010100

and

the 2scomplement ofOllOllHs 1001001 _ - r

The +s complement pf therrrst nJUDber i~ obt4iriedby I~vingthetwo least significant Os and the first 1 unchanged andmiddotlQen replacing ls with Os and Oswith 1~ in the other four most sigmiddot nificant digits The 2s lXgtmplement qf the second number is obtained byleaving the least sigshynificantmiddotl unchanged and (fOmplementing all other digits

In the previous definitions it was assum~dtMt the D~bers did not have a radix pomt1f the original number Noontains a radix point the point should be removed temporarily in order to form the s or(r 1)s complement The radix point is then restored to the c9ll1plementshyednumber in the same relative PositionIlis abo wOrth mentioning thatfhecontplement oftbe complement restoresthe number to its original v41ue To see this rel~tionsbipnOtethat the ts complement of N is n - N so that themiddot complement oft1e complement is n - (n - N) == N and is ltlqual to the original number

Mr8Ctiton wltl1 Complementsmiddot

1le direct metb()jiofsubtraCtion taught in elexnentaty schpOls uses the bottow concept In this QlCth9dwebortowa I from a middothigher significant position when the minuend digit is smaller than the subtrahend digit The tDethod wor~wen when peOple perfonnsubtraction with paper andpeooillIowever when subtlaction is implemented withdigi1al bardw8le the method is less e~citnt than the method that u~s compl~m~ts

The subtraction of two n-digitunSigneq numbers M N in base can be done as fonows I

1 Add the minuend M to the scompleme~t of thesubtramphend N Mathematically M+ (n N) = M N +

2 IfM ~ N ttie sum wiUproduce an end cury 11 which caD be discarded what is left is the resultM N

3 If M lt N the sum does not produce ~tlend carry JUld iseijUattor (N~ Ji) which is the s complement of (N - M) To obtain the answer in a familiar form take the s complement of the sum aruI place a negative sign in frorit

12 Chapter 1 Digital Syst-ems and Binary N~mbers

The following examples illustrate the procedure

plPi1I VsinglOs complement subtract 72532 - ~250

M = 72532

lOs complement of N + 96750 Sum= 169282

Discard end caIry lOS = -100000 Answer = 69282

Note that M bas fiv~ digits andN has only fourdigitsBoth numbers mtast have the same numshyber of digits sowe wrlteN as 03250 Taking the lOscomp~ementofNptOducesa9 in the most significant PositionThe occurrence of the end carry signifies that M ~ N 8ndtlult ~ result is therefore positive

Ulling 10s complement subtract 3250 - 72532 - ~ ~

M = 03250 JOscornplementof N =+27468

Sum= ~0718

There is no end carry Theref()re-theanswer is--(10amp complementof30718) == -69282 Note thatsince 3250 lt n532~the result is negative Becauwe are dealing with WUiigned

numbers there is really no way to get BnunSigned result for this case When subtracting complements we reoogilize the negltive answer from the~sence of the end carry and complemented result When workingwith paper and pencil we c8nchlnp the aDswer

signed negative number in oider to putH inafamiliar form Subtraction with complements is done with binary numbers in a similar manner uing

procedure outlined previously

EXAMPLE 17

Given the two binary numbersX = 1010100 and Y =1000011 performtbe $UbiDctiG (8) X - Y arid (b) Y - Xby using 2scomptem~ts -

f

- -

Section 15Complements 13

(a) x = 1010100

2s complement ofY= + -0111101

Sum = middot 10010001 Discard end carry 27 = 10000000

Answ~ X- Y = 0010001

(b) Y == 1000011 2sco~lement of X = + 0101100

Sum= 1101111

There is nQmiddotend carry Therefore the answer is Y ~X= -(2sq)mplement of 1101111) = -0010001 Subtractionof unsigned D1lJllbers ~ also bed()neby means of the (r - 1)s complement Remember that the(r- l)s complement is one lesstharithers complement BeCause of

ibis the result of adding the minue~ to tJte coQlplement of the subtiah~ndPtOductS itsum that is one less than the correct 4ifference when an end carrY oCcurs Removing the end carry and adding 1 to the sum is referred to asan end-around carry

Repeat Example 17 but this time using rs complement

(8) X y = 1010100 - 1000011middot

X= 1010100

rs complementafY= + olfnoo Som = 10010000

End-arOundmiddot~ =- ~ ~ Answermiddot X Y= middot0010001

(b) Y - X = 1000011 - 1010100

Y = 1000011

1s complement ofX = +0101011

Sum = 1101110

There is no end carry TherefOre the answer is y - X = -(1s complement of 1101110) = -0010001

bull Note that the negative resultis ob~ by taltingtbe 1 scomplemeilt of theJWltsince this is the type ofcoDiplementused The procedwewithendaroundoanyis aIs(gt Iijlpliclbleto subshytracting Unsigned deciImdnumQers with 9seomPlement

14 Chapter 1 Digital Systemsand BinayNumbers

16 SIGNED BINARYNUMBER$ ~

Positiveintegers (including zero) CaBbe ep~~ 11$ unstPecl numbers However to repshyresent negative integers we need a notation for negative srn ordinary arithmetic a negshyative number is indicated by a mulUs signmdapOsitiv~Pwtlt)e~ by aplus sign Because of lJardware limitations computers mlstrepresenlev~With~ digitsIt is customary to represent the sign witb a bit placed intheleftmotp6sitiolwfthe number The convention is tltl make the sign bit 0 for positive and 1 for negative

Itis important to realize that botp siped and unsignedtDnary 11UJDbers consist of a strfug of bits when represented in a com~ TQeuser detem1inesWbether the number is signed or unsigned If the binary number is signed then the lefuriostbitreple$ellts thtsign aud the rest of the bits represent the number Ifthebinaryllu~beiis~ tObe unsigned then the left most bit is the most significant bit of the l)uMber Fdre~the~~f bits 01001 can be consideredas 9 (unsigned binary) or as +9 (Sighedbitia1j) ~USJtheteftmostbit is O The

string ofbits 11001 represents the binary ~~v~ento~ ~w~nc~idered as an unsigned number and the binary equivalent of 9whenconsidered1l si~riumPer This is because the Ithal isintbe leftmost positiondesignatesampC nega6ye_~QtherfourJ)its represent bishynary 9 usually tlere is no cotifusionin identifying thebits~the~Qfrepresentation for the number is known in advance ~

The representation of the signed numbers in the lastexainple is referred to as the signed magnitutk coDvention In this ~otati()nthenurnber C4mSiampesOCa mQ~~andil~ymbolH

or -) or a bit (0 or 1) indicating the sign This is the representation ampr~~used in ordinary arithmetic When arithmeti~ operatioBslllieimplerneJltcldin~cOQlPuter hii more convenient to use a different systemrefetred t(gt as the si~cqmptement system~ for repre- senting negative numbers In thissystlm a neg8tielliun~r isjhdic~ted by its cornplc~mc~nt Whereas the signed-magnitude system negates a nlllllher by cbanging its sign me signed-comshyplement system negatesanwnber bytakin$ its~OinPleltleitiSinoepositife numbers always start witbO(plusin tte leftmost pOsition thecompktllint wiilalwaysstart with a 1 indicating a negative number The siped-complemelt system can use olthertbe 1s Or the 2s but the 2s complement is the mos~comtliOfi

As an exampleconsider the number9re~~ed in binary with eight bits + 9 Is sented with a sign bit of Oin the leftri1ostpOsition oIIOv~by the binary (equivalent of 9 which gives ()()()olOOl Note thai all eigbtbits must haYampa v~therefore O~s are inserted folshylowing the sign bitllp to the first 1 Although ~ is only 01K way to tepresent +9 there three different ways to represent 9 with eight ~its

s~gned~magnituderepresentation 10001001

sigried-l s-complement represe~on~ 11110110

signed-2 s-complemerit representatim 1ttltllU

In signedmagnituamp -9 isobwned from +9 by changing the sign bitmtbe leftmost ~iti(ln tromO to L In sigl1ed~ lroomplement 9isobtaidedtf~~tiog all the bits of includinj the sign bit Thesigned-2~sco~re~Qf-9 is obtampDedby ihe 2s complement oftbepOsitivenumberincludingtbesijnbIt

Sectlont6 SIgned8lnary NumberS is

Table 13 Slgtlfd Biliary Humbm

+7 +6

+5 +4 +3 +2 +l +0 0 -I

-2 -3

4 -5 -6 -1 -8

Olll 0110

0101 ( 0100

001l 0010 0001 0000

IIll 1110

nOI noo Ion 1010

1001 1000

OIll Oito eHOl OHIO OOU 0010 0001 0000 1111 1110middot dOl 1100 Ion

lOti 1001 1000

0111 OUO 0101

0100 0011 0010 0001 0000 1000 1001 1010 IOU 1100

1101 1110

lUI

Table 13 lists all possible four-bitsignedbinaryaumbers in the three representations The equivalent decimal number Is also shown for refelenoeNote that the positive n~ in all three representations are identicaland have 0 inthelefmostpcsiticm The signed2sshycompl~mentsystemhaironly onemiddotrepresentation for 0 which is always po$itive The other tw()systetns- mlve either a positive 0 or a negative 0 sometbingnoteDcounteredin ordinary arithmetic Note that all negative numbenhave alin the leftmost bitpositi~ that is the way we distinguish them from the positivenumbers With fout bits we can repreSent 16 binary numbers In the signed-magnitude aDd thelscomplement repre$eDtatipns there are eight positive numbers and eight negative numbers inciUdingtwo zeros In the2s-complement representation there are eight positive numbers includi0a one zerQ and eight negative numberS

The siped-m_gnitude system is used in ordiIlary arithmetic but is awkward when emshyployed in computer arithmetie becauIe of the ~parate bandIinJ bfthesipand the magnitude Therefore the signed-compiement systeni is normallyused The ls ~t imposes some difficulties and is seldom USedJor arithmetic openitiOns It is U$eful aSa lo~ operation since the change of 1 to Obrmiddot() to 1 is equivalent to a logical complement Operation as will be shown in the next c~The discussion~f sigiled binary ariduneti~ that fol10ws deals exshyclusively with the signe4-2soomplt_nt~tatJonQfnegadveilUlilbers hsame proshy

cedurescan beappJied to the sigMdrs-comPlemeD~Iysby incIudiOI tbe~arotmdcarry as is done with unsigned numbers

J6 Chapt~r 1 OlgltalSystlf(ns and Binary Numbels

Arithmetic Addition

The addition of two numbers in the signed-magnitudelYs_foUowsthe rules ofordinaiy arithshymetiC Ifthesi~s arethesam~we addthetwOtt~gni1U~~d ~vetbe sum the CCmmon sign Iftbe signs are diffe~nt we subtract tllcsmaUermagnitude frOtnlthe larF and give the differshyehtethe signof the larger magnitude For example (+25) +( - 37) = ~ (37 - 25) = -12 and is done by subtracung the smaller magnitude 25 from the larger magnitude 37and a~nding the sign of 37 tGtbe result Ibis is a process that requires a corripanson of the signs and magnitudes and then performing eithr additi()n or subtraction The same procedure applieato binary numbers in sigped-magnitude representation~Incontrast the rule for adding numbers in the signed-corppleme~ sy~tem does not require a comparison or su~ traction but only addjtion The procedure is very simple andcanbe stated as follows for binary numbers The 8ddltion oftwo signed binary numberS with negative numbers tepresented in signed- 2sComprement fonn is obtaiIled from theadditlooofthe two numbers includingtheii sign bits

AcentiirrY out oftbe sign-bitposition is diScacded NumerIcal e~aihpledotai1dition follow

+ 6 00000110 - 6 11UI0tO I

+13 00001101

+13 00001101 +19 00010011 + J 0Q900111 + 6 00000110 6 11111010 ~13 11110011 -1~l 11110011 7 illl1001 -19 11101101

I bull bull ~

Note that negative numbers musthil iriitially in 2seompkmentform and that if the swn ~ ~afterthladdit40nis negativeins in2s~p~t fOl1Jl - In each of thefoDrcasestlteoporationperfol1JlC(lis additionwitb the sign bit iilcluded Any catTY o~of~~-bit~onisdisc~ and negative resultsareButomaticallyin 2sshyromplementfoon

In order to obtain acOrrect answer we mustensQre that the result has a sufficient of bits to accommodate the swnlfwestartwith t~on-bltnumbers and tbeswn occupies n + 1bits we say tblltan overflow occurs~Wheri one perfotmStbc ad(JitiOJl with nllllIPTJllVIl

pencil aq overflow is not a preblem because we arcr noflimitecLbythewidth of the page jUst addanothcentr 0 to apositive number or another 1 toa negative number in the mOst cant positi()n to extend thenwnber to n+ 1 bitSand theQ perform addition Overflow is

problem in computers beqiusetbe number ofbi~~ bolla ~befis finite and a result ex~ tI1efinite val~e hy lcatmotbe accommodated

The compJement form of representiQg negativetlQUlbers is unfamiliar to those usedto signed-magnitude system To itetermine th~ value of II negatienumber insiped-2s COlIlpJe

mentit0is~ to CODVerttbe numbcr to apositie ntirit_ ~ place itiDa more formPor ~plethesig~binary number qUl00~ lii~egativebecausothe leftmost

t 1182s c0J8plemen~js~UlwhUhi$~ binaryeqqivalen of +7Wcmiddottherefore nize the Ori~nal ~atiy-eQumber to be equ~ lo-7 1

Sectlonl7 Bh1ary Codes 17

ArIthmetic SubtractIOn

Subtraction of two signed binafy numbers whe~negative numbersare in2s-complement form is simple and can be stilted as follows

Take the 2s complement of the5ubtraltend (including the sign bit) and add it to the minuend (including the sign bit) A cany oU1of thesignbit position is discarded

This prOCedure is adopted because a subtraction operation can be changed to an addition operation if the sign of the subtrahend is changed as is demonstrated by the following relationship

(plusmnA) ~ (-tB) = (plusmnA) + (-B) (plusmnA) - (-B) =plusmnA) + (+B)

But changing a positivetwober toa negative n~ber is eaampily done by taking the 2s compleshy mentof the pQsitive number The reverse is also tiUe~use theCOmPle~n~ of a negative numshyber in complement form produces the equivalent positive number To see this consider the sJlbtr~ction ( 76) -- (13) = +7 In binaIy_ with eight bits this ()peiationis written as (11111010 11110011) The subtracti~ri ischmlged ~ addition by taking the 2s complement ofthe subtrahend (-13) giving (+13) In binaly tbis~ 11 niOlO+ 00001101 = lOOOOOU1 Removing the end~ we obtain the ootrect answer ()()()()() III (+7)

Itisworth noting that binary DUmbersinthe signed-complement system are added and subshy tracted by the same basic addition and suPtraction rules as unsigned numbers Therefore comshyputersneed omy one common hardware circuit tobandle bothtypcs ofaritbtnetic The user or programmer ~ust interpret the reswtIi of $l1ch addition or subtraction differently depending on whether itisassumedtha~the numbe~ are signed ltr tinsigned

j

BINARY CODES

Digitalsystems use signalsthat have two distinct values1Uld circuit elements that havetwostashyble states There is a direct analogy anrong binary iignals binary circuitelements and binary digits A binary number ofndigitsfor example may be represented by n binary circuit eleshyments each baving an output sig~alequivalen1to Oor I Digital systems represent (Uld mashynipUlate not omy binary numbers but alsO many other diScrete elements of information Any discrete element of informatioIidlat is dis1iilct among agroup of quantities can be represented witha binary code (Le a pattern of Os and fmiddots) The codes must be in binary because in todays techIiology omy circuits that represent and manipulate patterns of 0s and ls can be manufactured economically foru~ in computers However it mtistbe realizCd that binary codes merely change the symbols not the meaning ofthe ele~nts of infonbationthat they repshyresent IT we inspect the bits of a computer at random we will find that mostofthe time they represent some tYPe of coded information rath~ than binlUY numbers

AIln-bit binary code is a groopofn hits that assumes up to 211 distinct cOmbinations of ls ~d Os with eacn combination representing one elementof tnt set that is being coded A set

of four elements clab becoded with two lilS with each ~lementassignedoneof thefoUowing bit oombinationsOOO I 10 J 1 A set of eight elements requiies a three-bit code 00 a set of

18 Chapter 1 Digital Systems and Binary Numbers

J6 elements requires a fourmiddotbit code The bit combination of ann~bit code is determined the count in binuy from 0 to 21t - t Each element must be assigned a unique binuy bit binationand no two elemerits cm havetbtsamevalueothenvisethe code assignment be ambigUous

Although the minimum nqrnber of 1lits required to code 21t distiItct quantities is nthere nomaximwn numbe( of bit that may he used for a binuy code For example the 10 digits can be coded with 10 bits and each decimal digit can be assigned a bit combination nine OSmid a 1 In this pamcularbinarycode the digit6 is assigned the bit )UllIUlauuu0001000000

BCDcode

Although the binary number systemis die ~ost natural system for a computer most people more accustomed to the d~imal system One way to resolve this difference is to convert

inlal nUmbers to binary perform all arithmetic calculations in binary and then convert the nary results back to decimal This metbodrequites that we store decimal numbers in

cOinputer so that they canbec6b~rted to binary Since the compllter Can accept only valueswe must represent the decimal digits by means ofa code that contains ls and Os also pOsSible lopedorm the arithmetic operlltiorisd1rectly on decimal numbers when they stored in the comput~ in cod~ct form

A binarycodewill have some unasSigned bit com~inatiqns ifthe num~rofelements in set is not amultiple power of 2 The 10decimai digits form such asel A biruuy code that tinguishes among 10 elements must coiltain at least four bits but 6otitofthe 16 possible binations remain unassigned Different binary code$ can bemiddotoNained by arranging four into 10 distinct combin~tions TheicodeIllcfflt oommonly used fdr the decimal digits is straight binary assf~ntlisted in Table 14 This scheil)eis called bittary~coded decimal

is commoolyreferred to as BCQ OtherdecimalcodesaIlfpossible and a few of them are sentedlaterinthis section

Table 14 BinarymiddotCoded Oeclmql (BCO)

Decimal BCD SnlboiDIgIt

o 0000 1 0001 2 0010

3 0011 4 middot0100 5 0101 6 0110 7 0111 8 1000 9 1001

Sectionmiddot 17 BInary COdes 19

Table 14 givesthe four-bit code for one decimal digit A number with k decimal digits will require 4k bits in BCD Decimal 396 is represented in BCD with 12 bits as 0011 10010110 with each group of 4 bits representing one decimal digit A decimalmiddotnumber in BCD is the

- same as itS equiyalent binary number only when the number is between 0 and 9 A BCD numshyber greater than lOJpoks different from its equivalentbinary number even though both con tainls and Os Moreover the binary Combinations 1010 thrpugh 1111 are not used arid have no meaning in BCD Consider decimal 18SlUld its corresponding value inBCD and bUtary

(185ho = (0001100001Ol)BCD = (l0111001h

The BCD value has 12 bits to encode the characters of the decimal value but the equivalent binary number needs only 8 bits It is obvious thatthe representation of a BCp number needs more bits than its equivalent binary value However there is an advantage in the use ofdecishymal numbers because compUterinput and output data are generated by people who use the decshyimal system

It is important to realize that BCD numbers are deCimal numbers and not binary numbers although they use bits in tbeir representation The only difference between a decimal number and BCD is that decimals are written with the symbOls 0 1 2 9 and BCD numbers use tbebinarycode 00000001 001O~ bull 1001The decimal value is exaCtly the same Dec~mal 10 is represented in BCD witheight b~ts as 00010000 and decitna1J5as 0001 01Of1lte corshyresponding binaryvalues are 1010 and 1111 and have only four bits

Consider the addition of two decimal digits in BCD together with a po~ible carry from a pre- vious less significant pair ofdigitsSince each digit does not exceed 9 the sum cannot be bull greater than 9 + 9 + 1 = 19 with the 1 being a previous carrySllppose we add the BCD dig-

its as if they were binary numbers Then the binary sumvill produce It result in the range from degto 19 In bin8ry thistange wil[be from 0000 to 10011 butin BCD it is frOm 0000 to

I 1001 with the first (ie leftmost) 1 bemg a carry and the next fo~ bits being the BCD sum When tPe binary sum is equalto or less than 1001 (withaut 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 (0110h to the binary Sum cOnverts it to the correct digit and also produces a catTy as required This is because a carry in themost significant bitposishytion of the binary sum and a deCimal carry differ by 16 10 = 6 Consider the following three BCD additions

4 0100 4 0100 8 1000

+S +0101 +8 +1000 +9 1001 9 1001 12 1100 17 10001

+0110 +0110----

10010 10111

In each case the two BCD digits are added as if they were two binary numbers If the binary sum is greater than or equal to 1010 we add 0110 to obtain the correct BCD sum and a carry In the flIst example the sum is equal to 9 and is the correct BCD sum In the second example

20 Chapter 1 Digital Systems and BInary Numbers

the binary sum produces an iJlv~ BCD digit The addition of0110 produces the cortect BCD sum 0010 (ie the number 2) and acanyInthetbirdexample the binalY SUDlproduces acany This condition occurs wben the $W)) is greater than or equal to 16Altbough the other fout are less than 1091 the binary 9Ulll requires acOnectionbecause of die carry Adding 0110 obtain thetequiled BCD sum 0111 (ie the numblaquo 7) and 8 BCD CiUT

The additionoftwondigit unsipedBCD numbers follows the same procedure COIlSioll the addition of 184 + 576 1= 76() in BCD

BCD 1 I 0001 10000100 184

+6101 ~

0111--- 0110 +576

lJinarysum 0111 10000 1010 Add6 ono 0110

BCDsun 0111 0110 0000 7(1)

The flfSt l~ sigDiticant pili- of BCD digits produces aBCDdigi~SllDlof 0000 and a for the next pair of digits the second parr or BCD digits plus a ~Vi0U8 cany produces a sum of 0110 and a carry for the next patr()fdigits The third pair of digits plus acarry proltIUC~ a binary s~ of 0111 and does not require a correction

Decimal Arithmetic The represeiltation of signed decimal numbers in BCD is simiiarto the tepresentation of numbers in binaryWe can useeitheI the familiar signed-magnitude system at the SllZllOO-COI1I

plemelit system The sign of a decimal number is tJSually represented with four bits to to thefour-bit code ofthe decimal digits Itis customary to designate 8 plus With four Os 8 minus with the llCDequivalent oi9 whlcq is 1001 The sigiled~magnitudesystem is seldom used in com~tersThe signed-complerDem ~~ either the 9s octhe 10s complement put the lOscomplement is the one most useP To obtain the lOs complement of aBCD numberwe first take the 9s complement then add 1 to the least significant digit The 9s Complement is calculated from the subtracloo of each digit from 9

The prltXeduresdevelope4 for the signed-2s-complement system in the ~vious also apply to the signed-IOs-complement system for decimal mimberS Addition is done summing all digits including the sign digit and discafding the end carry This operatiQ assumes that all negative numbers are in 10s-complement form COOsider the (+375) + (-240) == + 135 done inthe signed-complement system

o 375

+9 760middot

o 135

lhe 9in the leftmost pOsition of the second n~ber tepresents a minllS and 9760 is the complement o( 0240 The two numbers are added and tbe end carry is discarded to +13SOfcourse the decimal ntmlbers insi~ tile computer includingthe sign digits in BCD The addition isdone with BCDOigits as described previously

Sectionl 7 Binary Codes 21

The suQtr8ction of decimalliUJ1lbets either unsigned or in thesi~-~Oscomplement systetn is the sameu in the binary case Taketbe 10s ootnplementof the subtrahend and add i~ to themin~nd ManyooDlputerslULvespeciaJ hardware to perform arithmeticcalculations directly withdecilnal oumbers in 8tDThe~u$etofthecoBlPuter can specify programliled Wtnlctionsto JOdonn the aDtiuJletiP oPmwoowithdeQmal n1UQ~ ~ywithout having to convell them to binary

Binafy codes for decimal digits requirea minimum of four bits per digit Many different codes can be formulated by~gjng four bits into IQ distinct combinations BP) and three other representative codes are shown in Table L5 Each code uses only 10 out ofa pOssible middot16 bit combinations that can be arranged with four bits The other six Unused cOmbinations have no meaning amt should be avoided BCD and the 2421 code are examplesofweigbted codes In a weigbtedcodeeach bit position

juBsigned a weighting f~in~awaythat eaehdigitcanbe ev~by 8dding the wei~ oran the lsin thecoded combination The BCD code has weights of8 42 and I which cotteshy

spondiothe powe1Of-two valuesofeaCh bitTbebitasSignmeatOll0 for example is interpreted by the weights to represent dedma16beCause 8 X 0 +4xt +2 Xl +IX 0 6Thebit combination 1101 when weighted by the ~ve digits 2421 gives themiddotdeCimal equivalent of 2 X I +4 gtlt I + 2 KO + 1 X 1 = 7 Note that some digits cantle coded in lw9 possib)e

ways in the 2421Q)(feFOr inke decimal 4 can be asSigned to bitCombinadon 0100 or 1010 since botbcOmbinatibns add upto a totalweight of4

middot1$ Fou Dlf(et Blnqry Code$ for thtJledmol DIgits

~ IICD DIgIt sal MZt Exeet) 8 4 -~1

0 1

000() middotmiddotmiddot0000 001)1 0001

oem 0100

0000 0111

2 0010 0010 0101 0110 3 0011 OQU 0110 0101

4 0100 0100 0111 oroo 5 0101 lOll 1000 1011 6 OlIO middot1100 1001 1010 7 middot0111 1101 1010 J001 8 1000 IUOmiddot 1011 1000 9 1001 11U 1100 1111

1010 oloi 0000 0001 Uaused IOU 0110 middotOOOl 0010 bit 1100 0111 0010 0011 combishynations

nOl 1110

lOW 1001

HOI 1110

1100 1101

1111 IOU) 1111 1110

22 ChaptfrliDfgltalSystemsaod Btoary Numbers

I1te 2421 rind the

e~l3~es are exampks Of self-complementing codes Such codes have~propertyjbatthe9s~plement ofa deCimal nfunberigobtairted directly by chang-

ing 1$ to O~$ finO tYSCfb1 sie~bycomple~mmgeaCh bit in the pattem)For example decshyimat3~Sis re~ fu tbeexcess3code as 01101100 1000 The 9s compl~ntof 604 isrepRse~l00liOOllelliwbich isobiainc(himply by complementing each bit of the

code (as with the 1 s coinpl~ofbin~rillDlbers)middot Theexcess~3code has been used in some oldel coritputers because of its selfcpmplement~

ing property Excess-3 is an unweighted code inwhich each codedcombinationis obtained-fJQm the corresPonQing bin3ryvalueplus 3 Note that the BCD code is1~ self-complementing TheS 4 ~~ Icode isan example of assigning both positive and negative weights to ~ decimalcodeInthis case the bit combiDation 0110isin~reted as oecimal2 and is calcu-

latedfrom8XO+4X 1 + (2) X 1 + (1XO=2 ~

Cra Code _ _ J

l1te output data QfmaJlfpbYsicaimiddot $)ShmlS are quantities that are continuous These data bemiddottonverted~digiWforuitJefore they art applied toaliigital system Contfuuous or ~nisCOIl~middotUitodigitalfonn bymeans of an rumlog~digitalConverter It is times ~~ent tousethe Gray code slown inTable 16torepresehtdigiuU data that have oon~ fMn8D8l08 dasaTheadvantage of th( Gray cOOeover thesllaigbt binary nIl11l1hPt~

~lt~thatoWY~ hit in the codegroup changeSin going from one number to the For examplcentbullin-goingfrom 1 to 8dleGray code cblngesfrom 0100 to 1100Only the fust changesfromOto l~the odter~ I)its mnaintbesame By contrast With binary numbers change from 7 to 8wrube from 0111 to lOOOwhich causes allfciur bits to change valUes

TabielAi GtPyCode

01 Decl COde Equivalent

~ 0000 0001 0011 OOlG 011Q Olll OlO 0100 1100 11m 1111 1110 lOlQ 1011

lOOt i

1000

o 1 ~ 3

4 5 6 7 8 9

10 11

12 13 14 15

SectIOnl7 BlnarYCod~s 23

The Gray code is used in applications in which the normal sequenceOrbiruuy rium~may produce an error orambiguitymiddot during themiddot transitionfrom ODeDWDber to the next If binary numbersareusec1 acbange forexaJIlple nom 0111 to 1000 may produce anintermediateershyroneous number 1001 if the value ofthe rigbtmost bit takes longer to -change than domiddotthe valshyues of the other three bits The Graycode elimb1ates this problem since only one bit changes its valve dUrlng aily transition be~een two numbers I

Atypical appli-cation ofmiddotthe Gray code is the representation of analog data by a Continu ous change in the angUlar position of a shaft The sQaftmiddot is partitioned into segments ana each segment is assigned a number If adJacent segments are made to correspond with the Qray-Codesequence ambiguity is eliminated between the angle of thesbaft and the value encoded by the sensor

Character Code

Many applications of digital computers require the handling not only ofnumberS but also of other characterS or symbols such as the letters of the alphabet For mstancean insurance comshypany with thousands of policyholders will use a computeX to process its files To represent the names and other pertinent information it is necessary to fonnulate bull binary code for the letshyters ofthe alphabet In additiQt1 the same binary qode must represent numerals and special Characters (such as $) An a1phanumeric character setis a set ofeiements that inclUdes the 10 decimal digits the 26leuersofthealp1iabe and a nutnbeof special~S~ a set conshytains between 36~d 64 elements ifonIy capital letters areincltided or between 64 and 128 e1eJDents ifboth uppercasemiddot and lowercllle etters are inclUded In the first case we need a bi- nary code ofsix bits and in the second we need a binary cooeO(seVM bits

The standaM binary code for the alphanumeric char8cters is the American Stahdard Code for Information InterCbange (A~n) which uses seven bitS to code 128 characters asshoWn in Table 17 The seven bitsof the code are desipted by b~through h With h the mostsigshynificant bit ~e leUer A for example is represented inASCn as l(l()()()Ol (column l00~tOw 0001) The Ascn ()()de also contains 94 graphic characters that can be printed and 34 nonshyprinting characters used for variQUS control functions The graphic characters consist of the 26 uppercase letters (A through Z) the 26 lowercase letters (a through z) the 10 numerals (0 through 9) and 32 special printable characters suchaS andS

The 34 control characters are designated in the ASCTItable With abbreviated nalne8 They are listed again below the table with their functional names The control characters are used fQr routing data and arranging the printed text into a prescribed format~ There are three types of control characters format effectors information separatOrs andcommumc~on-COnlrpl char~ IlCters Format effectors are characters that control the layout ofprinting They inciude the fashymiliar word pr6cessorand typewriter controlssucb 8$ bac~pace (BS) horizontal tabulation (HT) and carriage return (CR) Information separators are used to separatetbe data into divi~ sions such as paragraphs and pages Theyinclude characters such as ~ordseparator (RS)and file separator (FS)The cODlIDunication-control characters are uSefulduriDgthe transmission of text between remote tenninals EXllll1plesof conlmunicatiOn(ODtiol~ are STX (start oftext)-and ETX (end of text) whicb are used toframe a text mesaagetnQlSlnitted through telephone wires

24 Chap~er 1 Diglt8l Systems and Binary Numbers

rblel7 Amerkcm5tandard Code for Information (nterclHlnge(ASCII)

b~jbzb 000 001 010 on 100 101 no 111

0000 NUL )jLP SP () p P 0001 SOH OC1 1 A Q a q

R0010 STX OC2 2 B b r 0011 ETX DC3 3 C S Ii S

0100 EDT 0C4 $ 4 D~ T d t 0101 ENQ NAK 5 E iU e u OUO ACK SYN amp 6 F V f v 0111 BEL ETB 7 0 W g w 1000 B8 CAN ( S H K h x 1001 HT EM ) 9 I Y Y 1010 LF SU~ 1 Z j z lOll VT ESC + 1lt r k UOO FF PS lt L I I 1101 Cit OS == - M 1 m 1110 SO R~ N 1 n shy

-0PIt st US f 1 0 0 DEL

r- Control characten

NUL NlI]l DlE Data-inkescape SOH Start of hea~ng DC1 Device cOntroll STX Start of text DC2 DevIce io~1lOi2 ETX End (Jftext i DC3 Device corUlri1 3 OOT End oftraIlsmission ~4 DeVicecoQtrol4

ENQ ampqwry NAK Negativeackilowledge ACK

Acknowledge SVN Sync~nous idle

Btl Bell ETB End-of-tmnsnussionblOck sS Backspace CAN CanCel HT Horizontal tab EM End of mediUrlt LF Lintifeed SUB Substitute VT Vertical tab ESC escape FF form feed FS File separator CR Carriigeretum GS Group separator SO shift Ollt RS Reoord sepuator SI Shlftin US Unit separator SF S~e DEL Delete

ASCII is a seven-bit codebutrnostcompUters manipulate anejght-bit quantity asa unit called a byte Therefore ASCII characters most often are stored ~e per byte The

I biti~sometimesused forotlef purposes depending ontheapplicatio~lFor example printetS recognize eightmiddotbit AScn chaiacterS with themost sigoificaot bit ~twO An atkJlitlo

Section 18 Binary Storage and Registers 2S

128 eight-bit characters with the most significant bit set tol are used for other symbols such as the Greek alpbabet or italic tyIe font

Error-Dtectlng Code

To detect errors in data communication and processing aneigbth bit is sometimes added to the ASCll cbaracter to indicate its Panty Aparitybit is an extra hit included with a message to make the total num~ of ls either even or odd Consider the fo119wing two cbaracters and their even andodd parity

With even parity With odd parity Ascn A = 1000061 01000001 11000001 ASCI( T == 101deg100 11010100 01010100

1

- Ineacb casewe insert an extra bit in the leftmost position of the code to produce an even number of 1 s intQe cbaraeter for even parity or an odd number of 1 s in the character for odd parity In generlll one or tbe oth~r parity i~ adopted with even parity being more common

The parity biqsbelpful in detecting errors during the transmission ofinformation from one location to another nisfuJictiOD is bandIed by generating an even parity bit at the sending end for ~h character The eight-bit characters that include parity bits are transmitted to their desshytination The parity ofeachebaracter is thetichecked at the receiving~nd If the parity of the received cbaracter is Dot even then at1east on~bit has changed value dUring the trmlsmission This method detects one three or any odd combination of errors in each character tb8t is transshymitted An even combination oferrors however goes undetected and additioDaterror detic- shytion codes may be needed to take care of that possibility

What is done after an errQlis detected depends on the partieu~ application One possishybilityis to request retransrois~ion of the message on the assump~on that tbeenigtr was ranshyd()m andwill not occur again Thus if thereeeiverdetects a parityerrorit sends bai~ the ASCII NAK (negative acknowledge) control cnaracter consisting ofail even-parity eight bits lOOlOl01H no error is detectedthe ~iversends back anACK (aCkno~ledge) conshytrol character namely 0000011 O The sending end will respond middotto an NAK by tranSmitting the message again until the correct panty is received Ifmiddot after a number of attempts the transmission is still in error a message can be sent to the Operatai to check for malfunctions in the transmission path

BINARY STORAGE ANORECiISTEIlS

The binary infonnation inadigitalcomputermust have a physical e~stencein some medium for storing individual bits A binary cell is a device that possesses two stable sttes and is cashypable of storing pne bit (0 or 1) oflnfotlllation The input to tbe cell receives exciJation sigshynals that set it to one of the two states The output of the cell isa pbysicalquantity that distinguishes between the two states The irtformationstored in Ii cell is 1when the cell is in one stable state and degwhen the Cell is in the other stable state

26middot Chapter 1 Digital Systems and BtnaryNumbers

Registers

A register is a group of binary cells A register with n cells can store any discrete quantity of middot information thatcontains n bits The state ofa registeris an n-tuple ofls middotand Os with each bit designating the state of one cell in the register The C()ntent ofaregister is a function of the int~rpretation given to tbeinformation stored in it Consider fQf ex~ple a 16-bitregister with the following binary content

11 00001111001001

middot Aregjs~ with 16 cells can be in one of 216 possible statesIf one asstimesthat the content cif the register represents a binaryinteger then the register can store any binarydumber from Oto 216 - 1 For the patticularexample shown the content ofthe register is the binary equivshyalent(lftbe decimal number 50121 If one assumes instead that the register stores alpbanushy

middot meric characters of an eight-bit cooe then the content of the register is any two meaningful characters For tht ASCII code with anevenplirityplaced in the eighth most significant bit position the register contains thetwo charactersC (the lefunosteightbits) and I (the rigbt~ most eight bits) If however one in~rprets the content of the register to be four decimal dig- its represented by a four-bitcode tnenthe content of the register is a four-digit decimal number In theexcess-3 code the register holqs the decimal nutriber 9096 The content of the registe~is meaningless in BCD becau~e the bit combinatiOn ltob is 110t assfgned to any decshyimal digit From this example it is clear that a register can store discrete elements of inforshymation and that the same bit configuration Inay beinterpreted dlffe(ently for different types of data

tmiddotmiddotReglsterTrail Adigitalsystenlis characteriZed by its registers and the components thatpetfolin data proshy~ssingIIl digital sy~tems a rcentgister tra1lsfer operation is abasi operation that consists of

middot a transftr of hiJWy hUormation from one ~t of registers into ano$er set of registers transfer may be dir~ctfr9m one regist~r toanlt)ther or may pass througb datamiddotprocessing circuits to petformaD operation Figure L 1 illustratel the transfer of iidOrnuttion among regshyisters anddemonstratespictorlallY [the tr8ll~~ ofbinaryinformation from akeyboard a register in the memQryullit Thehlputunit~s assumed to have a keyboard1 control cuit and aninput register Each time a key is strock the control circuit enters an ImnV$_

lent eight-bit alphanumeric character coqe into the input register We shall assume that code used is the ASCII code with an odd-parity bit The information from the input regisshyter is transferred into the eight-least significant cells Qf a proeessOr register After transfer theinpui register is cleared to enable the control to insert a new eight-bit when the keyboard is struck again Each eight-bit character transferred to the pro1c4ess(raquo register is preceded by a shift of the previous character to the next eight cens on its left~

middot a transfer -of four characters is completed the processor registeris full and its contents transferred into a memory register The content stored in die memOry register shown in Figl came from the transfer of the characters J 0 H an~ N aftet the four ap)lroJ)riatt keys were struck

Section 18 Binary Storage and Registers 27

FIGURE 11 Transfer of information among registers

To process discrete quantities of infoiniatiori in binary form a computer m~st be promiddot vided with devices that hold the (lata to be processed and with circuit elements that manipmiddot ulate individual bits of irifonnation The device most commonly used for holding data is a register Binary variables~ manipulated by means of digital logic circuits Figure 12 il~ luslrates the process of adding two l()bit binary iUlmbers Themeniory unit which no[shy

mally consists of millions of registers is shown with only three ofits registers Thepait of the processor unit showncoDsistsmiddotofthree registers-RI R2 and R3~getherwith digital logic circuits that manipulate the bits of RI and R2 and transfer into R3 a binary number equal to their arithmetic sum Memory registers store information and are incapable of pr0shy

cessing the two operands However th~ information stored in meDij)iybanbetransferred to ~ processor registers and the resUlts obtainedin processor tegisters can be transferred back into ame~ry register for storage Untill)ecded again The diagram ~wsthe90ntents of two

operands transferred from twoJDemoryregisters into RI imd R2 The digital logic circuits produce the sum which is transfened to register R3 The contents of R3 can now be 1riUlsshyferredback to one of thetnemory registers

The last two examples demonstrated the infonncion-flow capabilitieSofa digital system in a simple manner Themiddot registets of the ~ystem are the basic ele~ents for Noring and holding the binary information~igitallogic circuits process the binary ihfonaation stored in the

28 Chapter 1 DigIt bullbull Systems and Binary Numbers

Sum

FIGURE 12 Eumple of blnarylnfonn~t1on processing

registers Digitallogiccirctiits and registers are covered InChQpteB 2 throQgh 6 The metlilOlY unit is ~xPIained ill 9aptet 7 Th~ descriptton of register opetJtions at the register level and the design of digital systems are covexed in Chapter 8

19 BINARY LOGIC

Binary logic deals with variables th~ take on two discrete valueund withoperations that sumelogicalmeaning~ The two val~s the variableussume may be called~ydifferent (true andalse yel and no etc) but for ourp1llpQSe it is cpqVenienttotbink in terms of and assign the values llUld O The binary logic intr0ducedin this section is equivalent to algebra oalledBoolean algebra The fannal presentation ofBoolean algebra is covered in detail in Chapter 2 The purpose ofthis seCtion is to introduce Boo algebra ina matmerandlate it to digitallogiccircuits andmiddotbinarYsignalsmiddot

Section 19 Sinary logic 29 ~

Itkltn of IInary logic

Binarylogic consists of binary v~les and a set of logica1middotoperatiQDS The variables are desigshy ~by lettell of thCalplWlet~such asA B C x yz etc with eaCh variable baving two and oniy

two distinct posSible valueS 1and O There are three basic logical operations AND ORand NOT

1 AN]) This ~peration is represented by adotorby the absence ~f an oPerator For example x bull y =z or xy = zis~ x ANDy is equalto z~ThelogicaloperationAND is interpreted to mean that z == 1 ifand only ift~ land y = 1 otherwise z = O (Reme~r that x y andzare binary v8riablesand canmiddotbe equal either to 1 or Omiddotand nothing eise)middot

2 OR This operation IS represented by a plus sign For example x + y =z is read x OR y is equal to z meaning that z 1 if x = iorif y = lorifbothx= 1 and y = 1 If bqth X - 0 andY Omeo z= O

3bull NOT This operation is repf6sented by a prime (sometimes by an overbar) For ~xample x =Z (or~ =z) is read notdsequalto 1 meiming that z iswkatx isnot In other

words ifx = 1 then z == 0 but if x == 0 tnenz = L TheNOT operationisals(1 reshyferred tolls the complement operation since it changes ~ 1 toOand a O to 1

bull bull lt Binary logic resembles binary arithmetic and themiddot9peratioos ANDahd OR have similarishy

ties to multiplication and addition respectively In fac~ the symbols used for AND and OR are the same as those used for multiplication and addition However binary lOgic should not be conshyfused withbinaryarithIrietic One should realize thatan arithmetic variable designates a numshyber that may consist of many digits A logicmiddot variable is always either 1 or O For example in binary arithmetic we have I +1 =10(read~one plus ()fie is equal to 2) whereas in binary logicwe have 1 + 1 1 (read one OR onds equal to one)

For each combination of the values oix and y bullthere isa value of ~ $pecifiedby the definishytion of the logical operation D~linitiops of logical~perations maybe listed in a compacHorm called truth tables A truth table is atable of anpbssible combinations ofthe variables $howshying the relation between the values that the variables may take and the resultof the operation The truth tables for th~ operations ANDand OR with variables x and y are obtained by lis~ng

all possible values that the variables may have when combined in pairs bull For each combination the resUlt of die operation 18 theillistedin a separate row The truth tables for ANDORand

NOT are given in Table La These tables clearly demonstrate the definitionf the operatibns

Table 18 Truth TcibJts of Logical Operations

AND OR NOT

x y xmiddoty x y x+y

0 0 0 0 0 0 1 0 0 1

10

1 0 d 1 0 1 I 1 1 1 1 1

bull~lt~m

30 Chapter 1

Logk Gates

Digital Systems and Binary Numbers

Logic gates are electronic cirellit that operate on ~

variable

or mpre mput tignals to produce an output signal Electrical signals sUch as voltages orrutrents exist as analog signals having values over a given taDgebull saYOt03 V but in a digital system are interpreted to be either of two recognizable values 0 or 1 Voltage~opetated logic Circuits respond to two separate voltshyage levels that represent a binary varjable equal to logic I bt logic O For example a partic- ular digital system may define 10gicOas a signal equal to 0 volts lind logic 1 asa signal equal to 3 volts In practice each voltage levelhiS an acceptable rangeas shown in Fig 13

The input te~nals of digital cikuits accePt binary signals within the allowable range and respond at the output terininals with binary signals that fall within the specified range The intermediate region between the aJl()wed regions is crossed only during aState transition Any desired information for computing or control can be operated tm by passing binary signals through variQUS combinatioDsof logic gates with each signal represebting a particular binary

The graphic symbols used to deSignate themiddotthree types of gates are Mown in Fig 14 The

gates are blocks of hardware that prooocc tbeequivalent of1ogic~1 orlogic() output signals

Volts

- FGURl13

x

y

Exampleof binary slgnaJs

Signal ratlge for logieO

(a)~omiddotinput AND gate

FIGURE 14 SymbOls for digital logic circuits

(c)NOT gate or invert~

Problems 31

x-lU 1 11 P 0

y 0 0 11 1 ~

ANDxy 0 0 rTl 00

ORX+Y~ NOT x 11 0 0 I 1 1

FIGURE 15 Input-output 5Igals for gates

FIGURE 1

A B C

Gates WIth mlltlple JnpUU

A B C lJ

~

if inPllt logic ~ts are satisfied Theinput signals xaDd y intheNDaadQR gates may exist in ~ oHow-possible states 00 10 11 or 01 Il1ese ibpu~ampignals_ shown inFig lStoshygetber with the corresponding output signal foreach PfCThI~tiaiug~iDustrate the reshysponse ofeaclt gate to the four input signal~The~llisofthetiminadiagram represents time and the vertical axis sbo~~~~ it cbapg~botwcen~possible voltshy

age levels The low level represents logic O tJte high level l1lteAND _ responds With a logic ~ ~tput sipl wh~ both input ~~)e 1middot1~ lIieOR S-~with a logic 1 outpUt signal ifanylnput sigrudis lOgic 1 TheNOTgateis~~ to BUll invedet The reason for~nameis~t froJn the signalmsponae inmiddottbe timitt8 diagramwhicbsbows that theoUtputsignal inverts the logic sense of tbeiDpUtsigll8l

AND and OR gates may bavei)lQte tbantwQinputs M AND8_~itti ~input$andan OR gate with foU) inputs are shown in Fig 16 The three-inPllt AND gate responds With logic 1 output if all tbreeinputs arelogic 11jleoutputproduces lOgic Oifanymput is logic O-The

four-input OR gate responds withlogic 1 ifany input is logic 1 its clu1ptltllCCoines logic oonly when all inputs are logic O

Answers to prvblems marked with middotappearaHbe ClOd ofthe ~

11 lJltthe octal and beXadecimalliurilbers trom16ui 32UdngA B1l1ld C forthebst~ digits Usttbe numbers from 8 to 28 in base13 bull

I

12t What is the exact D1Jllbcr of bytes in a system that contains lta) 32Kbytoe (b)64M ~and (e) 640 byte$ middot7 t

32 Chapter 1 Digital Systemsand Binary Numbers

13 Convert the following nu~bers with the indicated bases to decimal (a) (4310)s (b) (198hz (c) (735)8 (d) (525)6

14 Whllt is the largest binary number that can be expressed with 14 bits WhlIt are the equivaleDt ~~ iinal and hexadecimal numbei-s

--

15 Detemrine the base of thl1 numbers in each case for the following operatio~ to be correct (a) 142 = 5 (b) 5414 = 13 (C) 24+ 17 == 40

16 The solution$to the q~cequation xl - Ux +22 oare l1 3 arid x =6 What is the base of the numbers

17 Convertthehexadecimal ntmIher 68BE to bitiary and then convert it ~mbinary to octal

18 I Convert the decirpal number 431 to binary in tWo ways (a) Convertd~y to binary (b) conshyvert first to hexadecinla1 and then from ~decimalwbinary Which method is faster

19 amppress the following nqrnbersin decinud (a) IQ11O0101)z (b) (l65his (c)(2624)8 (d) (FAFA) 16

(e) (10101010)2

110 Convert the following binary numbers tobexadeoimal and todecitnal (a) UOOlO (b) 110010 Explain why the deCimal answer in (b)is 4 times that in (a)

111 Perform the followingdiviskmin binary 11 Ion + l()t

112 Add IlniImultiply tfle following numberswiihout converting them to decimal (a) Binary nuniberilOll aiIdlOh (b) He~uumbers 2E aDd 34

1~)( Do thefoHowing con~ersionproblems (a) CorivertCiecimal2731S to binary (b) CakUlate the binary eqUivalent (f 213 outto eight pl~Then Convert from binary to

imalHowgJose istbe result to 2131 (c) Convert the binary resukin (b) into hexad~ lb~oonvert ~result to decimal Is answer tbesame

114 Obtain the is 8nd 2s complementsofthe foUowing binaryDumbcentrs (aj l)()()(J()OO (b) OOOOOOOO (c) 11011010 (d)01l10110 (e) 10000101 (0 11111111

115 Find the 9s and the 10s complement of the following detimal numbers (a) 52734630 (b) 63325600 (c) 25000009 (d) 00000000

116 (a) Find the 16s complement of B2FA (b) Convert B2FA to binary (c) Find the 2scomplement ofthe resultin (b) (d) Convert the answer in (c)to hex~malandco~ with ihe an~wer in (a)

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 4: Chapter 01 - Mano

4 Ch~pter 1 Digital Systems andBlnary Numbers

binary number 1101011 is 2675 as shown from the multiplication ofthe coefficients by powshyersoH

1 X24+1 XZ3 +0 x22 + 1 X 21 + 0 X2deg +1 xri + 1 X r 2 = 2675~ In general a number expressed in ~ base-r systeIri has coefficients m~ltiplied by powers of r

anrn + an-l 71-1 + +a22 + alr +06 + a-I r-1

+ a_~r-2 + + q_mr-m

The coeffici~nts a j range ip value from 0 to 1 To distinguish between numbers of differshymiddot ent baseswe enclose the coefficients in parentheses and Vrite asubscripteqOal to the base used (exceptsometime~ fot decimal nwnlers where the content makes it obvious that the base is decimal) An example ofabaseS numlgteris

(40212)s ~ 4Xs3 -I- 0 XS2+ 2 51 + IX 5deg + 2 X 5-1 == 5114ho

The cOefficient values for base 5 can be only 0 I 2 3 and 4 The octal mllnber system is a base-8 system that has eight digi~ 0 1234 5 6 1~ An example of an octal number is 1274 To determine its equivalent decimal value we expand the nlim6er in apower series witba base of8

(1274)8 = 1 X 82 + 2x 81 + 7X SO+4 x g-l==(S75)lO

Note that the digits 8 and 9 cannot appearin an oCtal number Itis customary to borrow the needed digits forthe coefficients from tlle decimal system

when the base of thenmnber i~ less than lO The letters ofthe alphabet reusedto supplement the 10 decimal digits when ~ base of the number is ~than 10 For example inthe

middot hexadecimal(base-16) number systemthe fIrst 10 digits are borrowed fro1ll the decimaJ sysshytem ~ letters A BCD~E and F are used for thedigits 10 n 12 13bull 14 and 15 respec~ tively An exampICf ofa hexadecimar number is

(B65Fh6 = 11 X 163 + 6gtX 162 + 5X 161 -+ 15 X 16deg =(~~687ho

As noted before the digits in lJ binary number are called bits When a bit is equal to 0 it does not contribute to the sum during the conversion Therefore the conversion from binary to decshymiddot imal can be obtained by addingonly the numbers With powersofctwo cotreSpOnding to the bits

that are equal to lForexample

(1l0101h = 32+ 16 +4+ 1 = 53)10

There are jour ls in the binwy number The corre~pondil1g decimal number is the sum of the four powers of two Thefirst 24 numbersobtaiJted from 2 to tJl(~ power of n are listed in bull Table 11 In computerwork 210 is referred to as K (kilo) 220 as M (mega) 230 asG (giga) and 240 as T (tera)Thus 4K = 212 4096 and 16M 224 = 16777216 Computer cashy~City is us1ial1y given inbyte$ A byte is equal to eight biis arid call ~onuriodal (ie represhysent the code of) onekeyboard character A computer hard disk with four gigabytesof storage

has a capacity of 4G = 232 brtes (approximately 4 billion bytes)

Section 13 ffumb~r-BaSetonver5iotls S

Table 11 Powers of Two

~ n 1 n Z n Z

0 1 8 middotmiddot256 16 65536 1 2 middot9 512 17 131072 2 4 10 1024 18 262144 3 amp 11 2048 f9 524288 4 16 12 4096 20 1048516

5 32 13 8192 21 2097152 6 64 14 1(i3amp4 22 4194304 7 128 15 32768 23 8388608

Arithmetic operations with numbers in base followtht same rules as for decimal nun1- hers When a base othef than the fariilliar base 10 is used one must becarefuho use only the -allowable digits~amples of~di~on subtraction and multipliCation oftwo binary numshybers are asfoUows

augend 101101 nlinuend 101101 multiplicand 1011

addend +100111 subtrahend -tOOtH multiplier XIOI sum 1010100 difference 000110 1011

0000 1011

product HOli

The sum oftwo binaiy numbers is calculated bY the sam~ rules as in decimal except that the digits of the sum ifl any sigiuficaOt position can be oDly 0 or 1 Any carry obtained in agiven significant position is uSed by the pair of digits one significantplt)sition higher Subtraction is slightly more complicated Tho rules are still the sam~ lismiddot ip declmalexcept that the bonow in a given signifieantposition adds 2 toa minuend digit (A bonoW in thedeeimaI syste~ adds 10 to a minUend digit) Multiplication is simpIefhe mo1iplier digits are 8lWaYs lor 0 thereshyfore the Partial produCts are eq~ either to the multiplicand Or la O

Theco~vefsio~ ofan~~r in ~a~e ~decimaI is40nebYexPamnngth~ntunber in a power series and adding all the terixlsasshown previOU$ly We nowptesel1u generij procedure for

the reverse operation of conyertirigadecimalnuil1ber~ anum1gtel in hasedfthe number inshycludes a radix point it is necessary to separate tbenumber~toan inte~partand a fraction part since each part mus~be converte4 diffqeptlyThe conversion ofadecimalinteger to a num- berin basO risdont by tlividingthe humber SAd all Successiv~q~nts by ~d8CCUllUlal- ing therem~ This procedure is best illustrated by example

6 Chapter 1 DigitatSy$tems and BInary Numbers

111411

Convert deciIIla14 r to binary First 41 is divided by 2 to live an integer quotient of 20 and a remainder of i Then thequoiientisagam divided by 2 to give anewquotient and remainder Theproeess is ~ntinued untilth~ integer quotient becomes O The Cf)eJJicients of the desired binary number are obtained fJOm the remainders as follows

Ioteger Quotient Remainder Coeflldent

4112= 20 + ah= 1 2012 10 + 0 at= 0

1012 = 5 + 0 a2= 0

512 = 2 + 1 a3 = 11 Z2 1 0+ G4=O

I112= 0 + 2 as =1 lt

Therefore the aDsWeris(41 )u)= (llsa4~3f12alaoh =(IOlOOlh The arithmetic proCess can be manipUlated moreconvemently as follOws

Integer 41

20

10

5 2 1

o

Relnamder

1

o o 1

o J~

1 101001 ==answer

Con~ersi~n from decimalintegeJS to lQ1ybase-r Sstem i~ similar totljis example except that division is done by r iil$teadof2

1I1t4191I Convert decimall5lto oCtal The required baSe r is aFirst 153 is divi~ by 8 tQl1ve anin- tegerquotient of 19 and a remainder of lThen 19 is divided by 8 to give an ~tegerqlotient

of 2 anli a remainder of 3 tFiny 2 is divided by 8to give aquotientof 0 and a remainder of 2 lbisproeess can be conveniently manipulatecfas follows

153 19 J

i 3 o 2= (23J)s

7 Section13middot Number-Base Conversions

lhe(OllVelSiOllQCdecimalfrmtonto binary js accompllshedby a ~od similar to tbai uscd for ~~veri multiplication is used instead of division and integers instead of

rem~ are acc~aQd Agafu~ the method is best explajned by example

bull Co~vert (06875hotobmaryFirst 06875 i~ multiplied by2 to give an integer and ajraction nen the new fraction is multiplied by 2 to give a new integer and a newfraction The process is continued until the fraction ~om~ 0 or until the nUJ1lber of digits have sufficient accuracy necoefficients oftbebinary nUlllberare ~btaipedfrolIl-~~ integers asfQUows

lnteger Fraction middotCoemclent gt~fn5 Jlt~~ i + 03750 a-I = 1

()37SO f(2 0 + 07500 g-2= 0

07500X2= 1 + 05000 D-3 - 1-

0-5000 X 2 == I + 00000 a~=l

J

) -

Thereforethe at)Swer is (O6875ho= (OD-lazQ-3D-4h= 010l1hshyTo convert adtcimal fractl9D to a number expressed in base 1 a-similar procedure isused HQwever multiPlication i~ by 1 instead all and the coefficlentsfound from the integers may

range iti value from 0 to r- 1 lI)stead of 0 and 1 bull bull bull - - -_ t lt~ 1

bull

O513X 8 = 4104

0104 X 8 = 0832 0832 X8 6656

0656 X 8 == 5248

0248 X 8 = 1984

0984 x 8= 7872

The an~wer to seven significant figures is obtained from the integer part onhe products

(OsP)IO= (0406517)8

middot8 Chapter 1 Digital Systems iilnd Binary Numbers

Ibo oonversion ofdecimalnumbers withbotMnteger and ftattionparts is done by con- vertingthe integer and the fraction separately and ihencombinihgthe two answers Using the re$Ults ofExamples 11 and l~ weobtain

(416875h~ (lOI001l011h

From Examples 12 and 14e have

(1535130 (2314tl6517)s

14 OCTAL AND HEXADECIMAL NUMBERS

The conversion frOm and to binary octal and bexadecimal plays an important role in digital computers Since 23 =8 and 24 = 16 each octal digit corresponds to thref binary digits and bull each hexadecimal digit corresponds to foUr binary digits The first 16 numbers in the decimal binary oct8r andhex~ecimalnumber systems are listed in Table 1-2

The comersion fm~ binary tooctal is easilyacltooiplishedby partitio~ng the binary num ber into groups oftbree digits each starting ti()n1 the binary plmt and proceeding to the left

I and to the right ~correspo~ octal digit is then assigned to each group The following example illustrates the proeedure ~

(10 110 001 101 011 11~ 100 000 lloh = (261537406)8 2 6 1 ~ 3 7 4 0 6

T_lel2 Numbers with Different-Baus

DecImal IY Octal Hexadecimal middot(base 10) (base 2) (b) (16)

i

00 0000 00 p 01 0001 01 1 02 0010 02 2 03 0011 03 3 04 0100 04 4 0 0101 OS 5 06 0110 06 6 07 0111 07 7

08 1000 10 8 09 1001 11 9 10 1010 12 A 11 1011 13 B 12 1100 14 C 13 1101 IS D 14 1110 16 bull

Ej

IS 1111 11 F r i

9 section 1S Complements

Conversion from binary to heudeciInal is similar except thatthe binary nutriber is divided into groups ofourdigits

(10 1100 0110 1011 1111 0010h = (2C6BJ2) 16

2 C 6 B P 2

The comsponding heX~ima1(o~ octal)~digit fOr each group of binary digits is easily reshymembeled from the values listed in Table 12

Conversion from octal or hexadeciInal to Jlinary is dOne by reversing the preceding proceshy(luremiddot Each octal digit is converted to its tbi-ee-digit binary equivalent Similarlyeach hexashydecimal digit is convertedioits four~digitbinaryequivalent1he procedure is illustrated in the following examples

(673124)8= (110 6

III 011 7 3

001

010 2

l00h 4

and

(306Dh6 = (OOlf 0000030shy

110 6

~101h D

Binary numbers are difficUlt to work with because they require three or fout times as many digits as their decimal equivaltmts Por exaniple the binary number 111111111111middotis equivalent to decimal409S Howeverdigital computers use biIUuy11UIhbers and itis soIIJet4nes necessary for the human operator or user to oonununicatedirectly With the machine by means of such num bers One scheme that retainsthebinary~ystem in the cotnputer but reduceS the number of digshyits the human must cOnsider utilizes the relationslripbetyeen the binary Ilumber system and the ~ or hexadeciinal system By this method the Ql1DaIlthinksin tenns ofQCtal ornexadecimal nurnbers and performs the required conversion by inspection when direct communication with the machine is necessary Thus thebinary number 111111111111 has 12 digits ~d isexpressed iIi octal ~ 7777 (4 digits) or in hexadecimal as FFF (3digits) During communication between people(about binary numbers in the coJlllQter)the octal or hexadecimal representation is more desirable because it can be expressed more compactly with a third or a quarter of the number of digits reqUired for the eqwvalent binary number Thusmpstcomputer manuals use either octal laquohexadecimal numbers to specify binaryqwintiti~ The choice between diem is arbitrary although hexadecimal tends to win out since it can represent a byte with two digits

PlEM ENTS

Complements are used in digital cOmputers to simplifydle subtraction operation and for logshyical manipulation Simplifying operations leads to simpler less expensive circuil$ to implement the operations There are two types of complements for each baSe-r system the radix comshyplement andthe diminished raclix cOtllplement Themiddotflrst is referred to as the rts complement and the second as the (r - middot1)scomplement When the value of the base r is substituted~ the name the twotypesare refefted to as the 2s complement and 1 scomplement fot binary numshy~rs and the lOscompl~ent and 9s complement fqrdecimal numbers

10 Chapt~rl Digital Systems and Binary Numbers

D~I~llhed Radix Complame~middot Gi~en a number N in base r haYing n digits the (r - 1)scomplement~f N is defined as

(rll - 1) ~NFotdecimainumbersr -= Wandr -1 9sothe9scomplementofNis (10 - 1) - N IIi this c~ 10 represents a number that consists of a single 1 followed by nOs 10 - lisartumberrepresentedbyn9sFOrexampleifn 4wehavel04 = 10000 and 104 - 1 = 9999 It follows that the9s complement ofa decimaJnumber is obtained by subtracting each digit from 9 Here are some nwnericalexamples

The 9s complement of 54670(Ms929999~ 546700 453299 bull - I

The 9scothplement of012398is999999~0l2398 =987601

For binary pumbers r =2 and r - l~ 1 sothe 1s complementofNis(Z - 1) - N Again 211 is represented by a binaty number thatconsistsofa 1followed by Ii0s 211 - 1 is abinary number represented by ~1s~FOr example if 11= 4 we have z4 = (10000)zand 24 - 1 = (1111h Thus the ls complement of a binary number is obtained by sUbtractiDg

each dig~t from 1 However when subtracting binary digits from 1 we can have either I -0= lor1 - 1 = 0 which causestbe bit to change from Oto 1 0( from 1 to 0 respec- tively Theretore the ls complement of a binary number isfonnedby changing 1s to Osand Osto 1s The f9llowillg are somenumqical ex~esI

~

The ls Complement of 1011000 isotOOiu

The 1scompieme~t oHlIOUOI is 10 tOOlO

The (r-l) s compleme~ ofoctal or b~xadechnalnumbers i~6btained by subtracting eaeh digit from 70rF (diicimallS) respectively~

Radl~ C~mplement

The s complement of an n~digit number N in baserisdefinedasrmiddot Nfot N i 0 and as ofor N = O~ Comparing with the (r- l)s ~entwe note that ~rs complement is obtained by adding Ito the (r - l)scomplement smcer - N= HA-- 1) - N] L lhus the lOscomplementof deein1al2389 is 76lO +1 = 7611 and is otltamed by adding 1 to the 9scomplernent value The 2s oomplementofbinary 1011oois 010011 1 =010100 and isobtained by adding 1 to the ls-complement value

Since 10 is a number represented by a 1 followed by n0s1011 N Whicb is the10S com~

plementof N can be fonn~d also by leaving allieasl sigtrlficani Os Unchanged the first nonurO least significant digit from 10 and SUbr8Cting all higher significant

from9 ThUs

the 10s complement of 012398js987602

and

11 Sectlon middot15middot Complements

The 10s complement ofthefustnumber isobtaineltibysublriiCtingSfrom lOin the least sig~ nificant position and subtracting all other digits from 9~ The 10s complement of the second number is obtained by leaving the to least significant Os unchanged subtracting 7 from 10 and subtracting the other three digits from 9

Similarly the 2s complement ~be fonned by leaving 1ll11east significant Os and tbe first 1 unchanged and replacing I swith Os and Os with ls in allother hi~r signifIcJUlt digits For example

the 2s cORlplement of 1101100 is 0010100

and

the 2scomplement ofOllOllHs 1001001 _ - r

The +s complement pf therrrst nJUDber i~ obt4iriedby I~vingthetwo least significant Os and the first 1 unchanged andmiddotlQen replacing ls with Os and Oswith 1~ in the other four most sigmiddot nificant digits The 2s lXgtmplement qf the second number is obtained byleaving the least sigshynificantmiddotl unchanged and (fOmplementing all other digits

In the previous definitions it was assum~dtMt the D~bers did not have a radix pomt1f the original number Noontains a radix point the point should be removed temporarily in order to form the s or(r 1)s complement The radix point is then restored to the c9ll1plementshyednumber in the same relative PositionIlis abo wOrth mentioning thatfhecontplement oftbe complement restoresthe number to its original v41ue To see this rel~tionsbipnOtethat the ts complement of N is n - N so that themiddot complement oft1e complement is n - (n - N) == N and is ltlqual to the original number

Mr8Ctiton wltl1 Complementsmiddot

1le direct metb()jiofsubtraCtion taught in elexnentaty schpOls uses the bottow concept In this QlCth9dwebortowa I from a middothigher significant position when the minuend digit is smaller than the subtrahend digit The tDethod wor~wen when peOple perfonnsubtraction with paper andpeooillIowever when subtlaction is implemented withdigi1al bardw8le the method is less e~citnt than the method that u~s compl~m~ts

The subtraction of two n-digitunSigneq numbers M N in base can be done as fonows I

1 Add the minuend M to the scompleme~t of thesubtramphend N Mathematically M+ (n N) = M N +

2 IfM ~ N ttie sum wiUproduce an end cury 11 which caD be discarded what is left is the resultM N

3 If M lt N the sum does not produce ~tlend carry JUld iseijUattor (N~ Ji) which is the s complement of (N - M) To obtain the answer in a familiar form take the s complement of the sum aruI place a negative sign in frorit

12 Chapter 1 Digital Syst-ems and Binary N~mbers

The following examples illustrate the procedure

plPi1I VsinglOs complement subtract 72532 - ~250

M = 72532

lOs complement of N + 96750 Sum= 169282

Discard end caIry lOS = -100000 Answer = 69282

Note that M bas fiv~ digits andN has only fourdigitsBoth numbers mtast have the same numshyber of digits sowe wrlteN as 03250 Taking the lOscomp~ementofNptOducesa9 in the most significant PositionThe occurrence of the end carry signifies that M ~ N 8ndtlult ~ result is therefore positive

Ulling 10s complement subtract 3250 - 72532 - ~ ~

M = 03250 JOscornplementof N =+27468

Sum= ~0718

There is no end carry Theref()re-theanswer is--(10amp complementof30718) == -69282 Note thatsince 3250 lt n532~the result is negative Becauwe are dealing with WUiigned

numbers there is really no way to get BnunSigned result for this case When subtracting complements we reoogilize the negltive answer from the~sence of the end carry and complemented result When workingwith paper and pencil we c8nchlnp the aDswer

signed negative number in oider to putH inafamiliar form Subtraction with complements is done with binary numbers in a similar manner uing

procedure outlined previously

EXAMPLE 17

Given the two binary numbersX = 1010100 and Y =1000011 performtbe $UbiDctiG (8) X - Y arid (b) Y - Xby using 2scomptem~ts -

f

- -

Section 15Complements 13

(a) x = 1010100

2s complement ofY= + -0111101

Sum = middot 10010001 Discard end carry 27 = 10000000

Answ~ X- Y = 0010001

(b) Y == 1000011 2sco~lement of X = + 0101100

Sum= 1101111

There is nQmiddotend carry Therefore the answer is Y ~X= -(2sq)mplement of 1101111) = -0010001 Subtractionof unsigned D1lJllbers ~ also bed()neby means of the (r - 1)s complement Remember that the(r- l)s complement is one lesstharithers complement BeCause of

ibis the result of adding the minue~ to tJte coQlplement of the subtiah~ndPtOductS itsum that is one less than the correct 4ifference when an end carrY oCcurs Removing the end carry and adding 1 to the sum is referred to asan end-around carry

Repeat Example 17 but this time using rs complement

(8) X y = 1010100 - 1000011middot

X= 1010100

rs complementafY= + olfnoo Som = 10010000

End-arOundmiddot~ =- ~ ~ Answermiddot X Y= middot0010001

(b) Y - X = 1000011 - 1010100

Y = 1000011

1s complement ofX = +0101011

Sum = 1101110

There is no end carry TherefOre the answer is y - X = -(1s complement of 1101110) = -0010001

bull Note that the negative resultis ob~ by taltingtbe 1 scomplemeilt of theJWltsince this is the type ofcoDiplementused The procedwewithendaroundoanyis aIs(gt Iijlpliclbleto subshytracting Unsigned deciImdnumQers with 9seomPlement

14 Chapter 1 Digital Systemsand BinayNumbers

16 SIGNED BINARYNUMBER$ ~

Positiveintegers (including zero) CaBbe ep~~ 11$ unstPecl numbers However to repshyresent negative integers we need a notation for negative srn ordinary arithmetic a negshyative number is indicated by a mulUs signmdapOsitiv~Pwtlt)e~ by aplus sign Because of lJardware limitations computers mlstrepresenlev~With~ digitsIt is customary to represent the sign witb a bit placed intheleftmotp6sitiolwfthe number The convention is tltl make the sign bit 0 for positive and 1 for negative

Itis important to realize that botp siped and unsignedtDnary 11UJDbers consist of a strfug of bits when represented in a com~ TQeuser detem1inesWbether the number is signed or unsigned If the binary number is signed then the lefuriostbitreple$ellts thtsign aud the rest of the bits represent the number Ifthebinaryllu~beiis~ tObe unsigned then the left most bit is the most significant bit of the l)uMber Fdre~the~~f bits 01001 can be consideredas 9 (unsigned binary) or as +9 (Sighedbitia1j) ~USJtheteftmostbit is O The

string ofbits 11001 represents the binary ~~v~ento~ ~w~nc~idered as an unsigned number and the binary equivalent of 9whenconsidered1l si~riumPer This is because the Ithal isintbe leftmost positiondesignatesampC nega6ye_~QtherfourJ)its represent bishynary 9 usually tlere is no cotifusionin identifying thebits~the~Qfrepresentation for the number is known in advance ~

The representation of the signed numbers in the lastexainple is referred to as the signed magnitutk coDvention In this ~otati()nthenurnber C4mSiampesOCa mQ~~andil~ymbolH

or -) or a bit (0 or 1) indicating the sign This is the representation ampr~~used in ordinary arithmetic When arithmeti~ operatioBslllieimplerneJltcldin~cOQlPuter hii more convenient to use a different systemrefetred t(gt as the si~cqmptement system~ for repre- senting negative numbers In thissystlm a neg8tielliun~r isjhdic~ted by its cornplc~mc~nt Whereas the signed-magnitude system negates a nlllllher by cbanging its sign me signed-comshyplement system negatesanwnber bytakin$ its~OinPleltleitiSinoepositife numbers always start witbO(plusin tte leftmost pOsition thecompktllint wiilalwaysstart with a 1 indicating a negative number The siped-complemelt system can use olthertbe 1s Or the 2s but the 2s complement is the mos~comtliOfi

As an exampleconsider the number9re~~ed in binary with eight bits + 9 Is sented with a sign bit of Oin the leftri1ostpOsition oIIOv~by the binary (equivalent of 9 which gives ()()()olOOl Note thai all eigbtbits must haYampa v~therefore O~s are inserted folshylowing the sign bitllp to the first 1 Although ~ is only 01K way to tepresent +9 there three different ways to represent 9 with eight ~its

s~gned~magnituderepresentation 10001001

sigried-l s-complement represe~on~ 11110110

signed-2 s-complemerit representatim 1ttltllU

In signedmagnituamp -9 isobwned from +9 by changing the sign bitmtbe leftmost ~iti(ln tromO to L In sigl1ed~ lroomplement 9isobtaidedtf~~tiog all the bits of includinj the sign bit Thesigned-2~sco~re~Qf-9 is obtampDedby ihe 2s complement oftbepOsitivenumberincludingtbesijnbIt

Sectlont6 SIgned8lnary NumberS is

Table 13 Slgtlfd Biliary Humbm

+7 +6

+5 +4 +3 +2 +l +0 0 -I

-2 -3

4 -5 -6 -1 -8

Olll 0110

0101 ( 0100

001l 0010 0001 0000

IIll 1110

nOI noo Ion 1010

1001 1000

OIll Oito eHOl OHIO OOU 0010 0001 0000 1111 1110middot dOl 1100 Ion

lOti 1001 1000

0111 OUO 0101

0100 0011 0010 0001 0000 1000 1001 1010 IOU 1100

1101 1110

lUI

Table 13 lists all possible four-bitsignedbinaryaumbers in the three representations The equivalent decimal number Is also shown for refelenoeNote that the positive n~ in all three representations are identicaland have 0 inthelefmostpcsiticm The signed2sshycompl~mentsystemhaironly onemiddotrepresentation for 0 which is always po$itive The other tw()systetns- mlve either a positive 0 or a negative 0 sometbingnoteDcounteredin ordinary arithmetic Note that all negative numbenhave alin the leftmost bitpositi~ that is the way we distinguish them from the positivenumbers With fout bits we can repreSent 16 binary numbers In the signed-magnitude aDd thelscomplement repre$eDtatipns there are eight positive numbers and eight negative numbers inciUdingtwo zeros In the2s-complement representation there are eight positive numbers includi0a one zerQ and eight negative numberS

The siped-m_gnitude system is used in ordiIlary arithmetic but is awkward when emshyployed in computer arithmetie becauIe of the ~parate bandIinJ bfthesipand the magnitude Therefore the signed-compiement systeni is normallyused The ls ~t imposes some difficulties and is seldom USedJor arithmetic openitiOns It is U$eful aSa lo~ operation since the change of 1 to Obrmiddot() to 1 is equivalent to a logical complement Operation as will be shown in the next c~The discussion~f sigiled binary ariduneti~ that fol10ws deals exshyclusively with the signe4-2soomplt_nt~tatJonQfnegadveilUlilbers hsame proshy

cedurescan beappJied to the sigMdrs-comPlemeD~Iysby incIudiOI tbe~arotmdcarry as is done with unsigned numbers

J6 Chapt~r 1 OlgltalSystlf(ns and Binary Numbels

Arithmetic Addition

The addition of two numbers in the signed-magnitudelYs_foUowsthe rules ofordinaiy arithshymetiC Ifthesi~s arethesam~we addthetwOtt~gni1U~~d ~vetbe sum the CCmmon sign Iftbe signs are diffe~nt we subtract tllcsmaUermagnitude frOtnlthe larF and give the differshyehtethe signof the larger magnitude For example (+25) +( - 37) = ~ (37 - 25) = -12 and is done by subtracung the smaller magnitude 25 from the larger magnitude 37and a~nding the sign of 37 tGtbe result Ibis is a process that requires a corripanson of the signs and magnitudes and then performing eithr additi()n or subtraction The same procedure applieato binary numbers in sigped-magnitude representation~Incontrast the rule for adding numbers in the signed-corppleme~ sy~tem does not require a comparison or su~ traction but only addjtion The procedure is very simple andcanbe stated as follows for binary numbers The 8ddltion oftwo signed binary numberS with negative numbers tepresented in signed- 2sComprement fonn is obtaiIled from theadditlooofthe two numbers includingtheii sign bits

AcentiirrY out oftbe sign-bitposition is diScacded NumerIcal e~aihpledotai1dition follow

+ 6 00000110 - 6 11UI0tO I

+13 00001101

+13 00001101 +19 00010011 + J 0Q900111 + 6 00000110 6 11111010 ~13 11110011 -1~l 11110011 7 illl1001 -19 11101101

I bull bull ~

Note that negative numbers musthil iriitially in 2seompkmentform and that if the swn ~ ~afterthladdit40nis negativeins in2s~p~t fOl1Jl - In each of thefoDrcasestlteoporationperfol1JlC(lis additionwitb the sign bit iilcluded Any catTY o~of~~-bit~onisdisc~ and negative resultsareButomaticallyin 2sshyromplementfoon

In order to obtain acOrrect answer we mustensQre that the result has a sufficient of bits to accommodate the swnlfwestartwith t~on-bltnumbers and tbeswn occupies n + 1bits we say tblltan overflow occurs~Wheri one perfotmStbc ad(JitiOJl with nllllIPTJllVIl

pencil aq overflow is not a preblem because we arcr noflimitecLbythewidth of the page jUst addanothcentr 0 to apositive number or another 1 toa negative number in the mOst cant positi()n to extend thenwnber to n+ 1 bitSand theQ perform addition Overflow is

problem in computers beqiusetbe number ofbi~~ bolla ~befis finite and a result ex~ tI1efinite val~e hy lcatmotbe accommodated

The compJement form of representiQg negativetlQUlbers is unfamiliar to those usedto signed-magnitude system To itetermine th~ value of II negatienumber insiped-2s COlIlpJe

mentit0is~ to CODVerttbe numbcr to apositie ntirit_ ~ place itiDa more formPor ~plethesig~binary number qUl00~ lii~egativebecausothe leftmost

t 1182s c0J8plemen~js~UlwhUhi$~ binaryeqqivalen of +7Wcmiddottherefore nize the Ori~nal ~atiy-eQumber to be equ~ lo-7 1

Sectlonl7 Bh1ary Codes 17

ArIthmetic SubtractIOn

Subtraction of two signed binafy numbers whe~negative numbersare in2s-complement form is simple and can be stilted as follows

Take the 2s complement of the5ubtraltend (including the sign bit) and add it to the minuend (including the sign bit) A cany oU1of thesignbit position is discarded

This prOCedure is adopted because a subtraction operation can be changed to an addition operation if the sign of the subtrahend is changed as is demonstrated by the following relationship

(plusmnA) ~ (-tB) = (plusmnA) + (-B) (plusmnA) - (-B) =plusmnA) + (+B)

But changing a positivetwober toa negative n~ber is eaampily done by taking the 2s compleshy mentof the pQsitive number The reverse is also tiUe~use theCOmPle~n~ of a negative numshyber in complement form produces the equivalent positive number To see this consider the sJlbtr~ction ( 76) -- (13) = +7 In binaIy_ with eight bits this ()peiationis written as (11111010 11110011) The subtracti~ri ischmlged ~ addition by taking the 2s complement ofthe subtrahend (-13) giving (+13) In binaly tbis~ 11 niOlO+ 00001101 = lOOOOOU1 Removing the end~ we obtain the ootrect answer ()()()()() III (+7)

Itisworth noting that binary DUmbersinthe signed-complement system are added and subshy tracted by the same basic addition and suPtraction rules as unsigned numbers Therefore comshyputersneed omy one common hardware circuit tobandle bothtypcs ofaritbtnetic The user or programmer ~ust interpret the reswtIi of $l1ch addition or subtraction differently depending on whether itisassumedtha~the numbe~ are signed ltr tinsigned

j

BINARY CODES

Digitalsystems use signalsthat have two distinct values1Uld circuit elements that havetwostashyble states There is a direct analogy anrong binary iignals binary circuitelements and binary digits A binary number ofndigitsfor example may be represented by n binary circuit eleshyments each baving an output sig~alequivalen1to Oor I Digital systems represent (Uld mashynipUlate not omy binary numbers but alsO many other diScrete elements of information Any discrete element of informatioIidlat is dis1iilct among agroup of quantities can be represented witha binary code (Le a pattern of Os and fmiddots) The codes must be in binary because in todays techIiology omy circuits that represent and manipulate patterns of 0s and ls can be manufactured economically foru~ in computers However it mtistbe realizCd that binary codes merely change the symbols not the meaning ofthe ele~nts of infonbationthat they repshyresent IT we inspect the bits of a computer at random we will find that mostofthe time they represent some tYPe of coded information rath~ than binlUY numbers

AIln-bit binary code is a groopofn hits that assumes up to 211 distinct cOmbinations of ls ~d Os with eacn combination representing one elementof tnt set that is being coded A set

of four elements clab becoded with two lilS with each ~lementassignedoneof thefoUowing bit oombinationsOOO I 10 J 1 A set of eight elements requiies a three-bit code 00 a set of

18 Chapter 1 Digital Systems and Binary Numbers

J6 elements requires a fourmiddotbit code The bit combination of ann~bit code is determined the count in binuy from 0 to 21t - t Each element must be assigned a unique binuy bit binationand no two elemerits cm havetbtsamevalueothenvisethe code assignment be ambigUous

Although the minimum nqrnber of 1lits required to code 21t distiItct quantities is nthere nomaximwn numbe( of bit that may he used for a binuy code For example the 10 digits can be coded with 10 bits and each decimal digit can be assigned a bit combination nine OSmid a 1 In this pamcularbinarycode the digit6 is assigned the bit )UllIUlauuu0001000000

BCDcode

Although the binary number systemis die ~ost natural system for a computer most people more accustomed to the d~imal system One way to resolve this difference is to convert

inlal nUmbers to binary perform all arithmetic calculations in binary and then convert the nary results back to decimal This metbodrequites that we store decimal numbers in

cOinputer so that they canbec6b~rted to binary Since the compllter Can accept only valueswe must represent the decimal digits by means ofa code that contains ls and Os also pOsSible lopedorm the arithmetic operlltiorisd1rectly on decimal numbers when they stored in the comput~ in cod~ct form

A binarycodewill have some unasSigned bit com~inatiqns ifthe num~rofelements in set is not amultiple power of 2 The 10decimai digits form such asel A biruuy code that tinguishes among 10 elements must coiltain at least four bits but 6otitofthe 16 possible binations remain unassigned Different binary code$ can bemiddotoNained by arranging four into 10 distinct combin~tions TheicodeIllcfflt oommonly used fdr the decimal digits is straight binary assf~ntlisted in Table 14 This scheil)eis called bittary~coded decimal

is commoolyreferred to as BCQ OtherdecimalcodesaIlfpossible and a few of them are sentedlaterinthis section

Table 14 BinarymiddotCoded Oeclmql (BCO)

Decimal BCD SnlboiDIgIt

o 0000 1 0001 2 0010

3 0011 4 middot0100 5 0101 6 0110 7 0111 8 1000 9 1001

Sectionmiddot 17 BInary COdes 19

Table 14 givesthe four-bit code for one decimal digit A number with k decimal digits will require 4k bits in BCD Decimal 396 is represented in BCD with 12 bits as 0011 10010110 with each group of 4 bits representing one decimal digit A decimalmiddotnumber in BCD is the

- same as itS equiyalent binary number only when the number is between 0 and 9 A BCD numshyber greater than lOJpoks different from its equivalentbinary number even though both con tainls and Os Moreover the binary Combinations 1010 thrpugh 1111 are not used arid have no meaning in BCD Consider decimal 18SlUld its corresponding value inBCD and bUtary

(185ho = (0001100001Ol)BCD = (l0111001h

The BCD value has 12 bits to encode the characters of the decimal value but the equivalent binary number needs only 8 bits It is obvious thatthe representation of a BCp number needs more bits than its equivalent binary value However there is an advantage in the use ofdecishymal numbers because compUterinput and output data are generated by people who use the decshyimal system

It is important to realize that BCD numbers are deCimal numbers and not binary numbers although they use bits in tbeir representation The only difference between a decimal number and BCD is that decimals are written with the symbOls 0 1 2 9 and BCD numbers use tbebinarycode 00000001 001O~ bull 1001The decimal value is exaCtly the same Dec~mal 10 is represented in BCD witheight b~ts as 00010000 and decitna1J5as 0001 01Of1lte corshyresponding binaryvalues are 1010 and 1111 and have only four bits

Consider the addition of two decimal digits in BCD together with a po~ible carry from a pre- vious less significant pair ofdigitsSince each digit does not exceed 9 the sum cannot be bull greater than 9 + 9 + 1 = 19 with the 1 being a previous carrySllppose we add the BCD dig-

its as if they were binary numbers Then the binary sumvill produce It result in the range from degto 19 In bin8ry thistange wil[be from 0000 to 10011 butin BCD it is frOm 0000 to

I 1001 with the first (ie leftmost) 1 bemg a carry and the next fo~ bits being the BCD sum When tPe binary sum is equalto or less than 1001 (withaut 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 (0110h to the binary Sum cOnverts it to the correct digit and also produces a catTy as required This is because a carry in themost significant bitposishytion of the binary sum and a deCimal carry differ by 16 10 = 6 Consider the following three BCD additions

4 0100 4 0100 8 1000

+S +0101 +8 +1000 +9 1001 9 1001 12 1100 17 10001

+0110 +0110----

10010 10111

In each case the two BCD digits are added as if they were two binary numbers If the binary sum is greater than or equal to 1010 we add 0110 to obtain the correct BCD sum and a carry In the flIst example the sum is equal to 9 and is the correct BCD sum In the second example

20 Chapter 1 Digital Systems and BInary Numbers

the binary sum produces an iJlv~ BCD digit The addition of0110 produces the cortect BCD sum 0010 (ie the number 2) and acanyInthetbirdexample the binalY SUDlproduces acany This condition occurs wben the $W)) is greater than or equal to 16Altbough the other fout are less than 1091 the binary 9Ulll requires acOnectionbecause of die carry Adding 0110 obtain thetequiled BCD sum 0111 (ie the numblaquo 7) and 8 BCD CiUT

The additionoftwondigit unsipedBCD numbers follows the same procedure COIlSioll the addition of 184 + 576 1= 76() in BCD

BCD 1 I 0001 10000100 184

+6101 ~

0111--- 0110 +576

lJinarysum 0111 10000 1010 Add6 ono 0110

BCDsun 0111 0110 0000 7(1)

The flfSt l~ sigDiticant pili- of BCD digits produces aBCDdigi~SllDlof 0000 and a for the next pair of digits the second parr or BCD digits plus a ~Vi0U8 cany produces a sum of 0110 and a carry for the next patr()fdigits The third pair of digits plus acarry proltIUC~ a binary s~ of 0111 and does not require a correction

Decimal Arithmetic The represeiltation of signed decimal numbers in BCD is simiiarto the tepresentation of numbers in binaryWe can useeitheI the familiar signed-magnitude system at the SllZllOO-COI1I

plemelit system The sign of a decimal number is tJSually represented with four bits to to thefour-bit code ofthe decimal digits Itis customary to designate 8 plus With four Os 8 minus with the llCDequivalent oi9 whlcq is 1001 The sigiled~magnitudesystem is seldom used in com~tersThe signed-complerDem ~~ either the 9s octhe 10s complement put the lOscomplement is the one most useP To obtain the lOs complement of aBCD numberwe first take the 9s complement then add 1 to the least significant digit The 9s Complement is calculated from the subtracloo of each digit from 9

The prltXeduresdevelope4 for the signed-2s-complement system in the ~vious also apply to the signed-IOs-complement system for decimal mimberS Addition is done summing all digits including the sign digit and discafding the end carry This operatiQ assumes that all negative numbers are in 10s-complement form COOsider the (+375) + (-240) == + 135 done inthe signed-complement system

o 375

+9 760middot

o 135

lhe 9in the leftmost pOsition of the second n~ber tepresents a minllS and 9760 is the complement o( 0240 The two numbers are added and tbe end carry is discarded to +13SOfcourse the decimal ntmlbers insi~ tile computer includingthe sign digits in BCD The addition isdone with BCDOigits as described previously

Sectionl 7 Binary Codes 21

The suQtr8ction of decimalliUJ1lbets either unsigned or in thesi~-~Oscomplement systetn is the sameu in the binary case Taketbe 10s ootnplementof the subtrahend and add i~ to themin~nd ManyooDlputerslULvespeciaJ hardware to perform arithmeticcalculations directly withdecilnal oumbers in 8tDThe~u$etofthecoBlPuter can specify programliled Wtnlctionsto JOdonn the aDtiuJletiP oPmwoowithdeQmal n1UQ~ ~ywithout having to convell them to binary

Binafy codes for decimal digits requirea minimum of four bits per digit Many different codes can be formulated by~gjng four bits into IQ distinct combinations BP) and three other representative codes are shown in Table L5 Each code uses only 10 out ofa pOssible middot16 bit combinations that can be arranged with four bits The other six Unused cOmbinations have no meaning amt should be avoided BCD and the 2421 code are examplesofweigbted codes In a weigbtedcodeeach bit position

juBsigned a weighting f~in~awaythat eaehdigitcanbe ev~by 8dding the wei~ oran the lsin thecoded combination The BCD code has weights of8 42 and I which cotteshy

spondiothe powe1Of-two valuesofeaCh bitTbebitasSignmeatOll0 for example is interpreted by the weights to represent dedma16beCause 8 X 0 +4xt +2 Xl +IX 0 6Thebit combination 1101 when weighted by the ~ve digits 2421 gives themiddotdeCimal equivalent of 2 X I +4 gtlt I + 2 KO + 1 X 1 = 7 Note that some digits cantle coded in lw9 possib)e

ways in the 2421Q)(feFOr inke decimal 4 can be asSigned to bitCombinadon 0100 or 1010 since botbcOmbinatibns add upto a totalweight of4

middot1$ Fou Dlf(et Blnqry Code$ for thtJledmol DIgits

~ IICD DIgIt sal MZt Exeet) 8 4 -~1

0 1

000() middotmiddotmiddot0000 001)1 0001

oem 0100

0000 0111

2 0010 0010 0101 0110 3 0011 OQU 0110 0101

4 0100 0100 0111 oroo 5 0101 lOll 1000 1011 6 OlIO middot1100 1001 1010 7 middot0111 1101 1010 J001 8 1000 IUOmiddot 1011 1000 9 1001 11U 1100 1111

1010 oloi 0000 0001 Uaused IOU 0110 middotOOOl 0010 bit 1100 0111 0010 0011 combishynations

nOl 1110

lOW 1001

HOI 1110

1100 1101

1111 IOU) 1111 1110

22 ChaptfrliDfgltalSystemsaod Btoary Numbers

I1te 2421 rind the

e~l3~es are exampks Of self-complementing codes Such codes have~propertyjbatthe9s~plement ofa deCimal nfunberigobtairted directly by chang-

ing 1$ to O~$ finO tYSCfb1 sie~bycomple~mmgeaCh bit in the pattem)For example decshyimat3~Sis re~ fu tbeexcess3code as 01101100 1000 The 9s compl~ntof 604 isrepRse~l00liOOllelliwbich isobiainc(himply by complementing each bit of the

code (as with the 1 s coinpl~ofbin~rillDlbers)middot Theexcess~3code has been used in some oldel coritputers because of its selfcpmplement~

ing property Excess-3 is an unweighted code inwhich each codedcombinationis obtained-fJQm the corresPonQing bin3ryvalueplus 3 Note that the BCD code is1~ self-complementing TheS 4 ~~ Icode isan example of assigning both positive and negative weights to ~ decimalcodeInthis case the bit combiDation 0110isin~reted as oecimal2 and is calcu-

latedfrom8XO+4X 1 + (2) X 1 + (1XO=2 ~

Cra Code _ _ J

l1te output data QfmaJlfpbYsicaimiddot $)ShmlS are quantities that are continuous These data bemiddottonverted~digiWforuitJefore they art applied toaliigital system Contfuuous or ~nisCOIl~middotUitodigitalfonn bymeans of an rumlog~digitalConverter It is times ~~ent tousethe Gray code slown inTable 16torepresehtdigiuU data that have oon~ fMn8D8l08 dasaTheadvantage of th( Gray cOOeover thesllaigbt binary nIl11l1hPt~

~lt~thatoWY~ hit in the codegroup changeSin going from one number to the For examplcentbullin-goingfrom 1 to 8dleGray code cblngesfrom 0100 to 1100Only the fust changesfromOto l~the odter~ I)its mnaintbesame By contrast With binary numbers change from 7 to 8wrube from 0111 to lOOOwhich causes allfciur bits to change valUes

TabielAi GtPyCode

01 Decl COde Equivalent

~ 0000 0001 0011 OOlG 011Q Olll OlO 0100 1100 11m 1111 1110 lOlQ 1011

lOOt i

1000

o 1 ~ 3

4 5 6 7 8 9

10 11

12 13 14 15

SectIOnl7 BlnarYCod~s 23

The Gray code is used in applications in which the normal sequenceOrbiruuy rium~may produce an error orambiguitymiddot during themiddot transitionfrom ODeDWDber to the next If binary numbersareusec1 acbange forexaJIlple nom 0111 to 1000 may produce anintermediateershyroneous number 1001 if the value ofthe rigbtmost bit takes longer to -change than domiddotthe valshyues of the other three bits The Graycode elimb1ates this problem since only one bit changes its valve dUrlng aily transition be~een two numbers I

Atypical appli-cation ofmiddotthe Gray code is the representation of analog data by a Continu ous change in the angUlar position of a shaft The sQaftmiddot is partitioned into segments ana each segment is assigned a number If adJacent segments are made to correspond with the Qray-Codesequence ambiguity is eliminated between the angle of thesbaft and the value encoded by the sensor

Character Code

Many applications of digital computers require the handling not only ofnumberS but also of other characterS or symbols such as the letters of the alphabet For mstancean insurance comshypany with thousands of policyholders will use a computeX to process its files To represent the names and other pertinent information it is necessary to fonnulate bull binary code for the letshyters ofthe alphabet In additiQt1 the same binary qode must represent numerals and special Characters (such as $) An a1phanumeric character setis a set ofeiements that inclUdes the 10 decimal digits the 26leuersofthealp1iabe and a nutnbeof special~S~ a set conshytains between 36~d 64 elements ifonIy capital letters areincltided or between 64 and 128 e1eJDents ifboth uppercasemiddot and lowercllle etters are inclUded In the first case we need a bi- nary code ofsix bits and in the second we need a binary cooeO(seVM bits

The standaM binary code for the alphanumeric char8cters is the American Stahdard Code for Information InterCbange (A~n) which uses seven bitS to code 128 characters asshoWn in Table 17 The seven bitsof the code are desipted by b~through h With h the mostsigshynificant bit ~e leUer A for example is represented inASCn as l(l()()()Ol (column l00~tOw 0001) The Ascn ()()de also contains 94 graphic characters that can be printed and 34 nonshyprinting characters used for variQUS control functions The graphic characters consist of the 26 uppercase letters (A through Z) the 26 lowercase letters (a through z) the 10 numerals (0 through 9) and 32 special printable characters suchaS andS

The 34 control characters are designated in the ASCTItable With abbreviated nalne8 They are listed again below the table with their functional names The control characters are used fQr routing data and arranging the printed text into a prescribed format~ There are three types of control characters format effectors information separatOrs andcommumc~on-COnlrpl char~ IlCters Format effectors are characters that control the layout ofprinting They inciude the fashymiliar word pr6cessorand typewriter controlssucb 8$ bac~pace (BS) horizontal tabulation (HT) and carriage return (CR) Information separators are used to separatetbe data into divi~ sions such as paragraphs and pages Theyinclude characters such as ~ordseparator (RS)and file separator (FS)The cODlIDunication-control characters are uSefulduriDgthe transmission of text between remote tenninals EXllll1plesof conlmunicatiOn(ODtiol~ are STX (start oftext)-and ETX (end of text) whicb are used toframe a text mesaagetnQlSlnitted through telephone wires

24 Chap~er 1 Diglt8l Systems and Binary Numbers

rblel7 Amerkcm5tandard Code for Information (nterclHlnge(ASCII)

b~jbzb 000 001 010 on 100 101 no 111

0000 NUL )jLP SP () p P 0001 SOH OC1 1 A Q a q

R0010 STX OC2 2 B b r 0011 ETX DC3 3 C S Ii S

0100 EDT 0C4 $ 4 D~ T d t 0101 ENQ NAK 5 E iU e u OUO ACK SYN amp 6 F V f v 0111 BEL ETB 7 0 W g w 1000 B8 CAN ( S H K h x 1001 HT EM ) 9 I Y Y 1010 LF SU~ 1 Z j z lOll VT ESC + 1lt r k UOO FF PS lt L I I 1101 Cit OS == - M 1 m 1110 SO R~ N 1 n shy

-0PIt st US f 1 0 0 DEL

r- Control characten

NUL NlI]l DlE Data-inkescape SOH Start of hea~ng DC1 Device cOntroll STX Start of text DC2 DevIce io~1lOi2 ETX End (Jftext i DC3 Device corUlri1 3 OOT End oftraIlsmission ~4 DeVicecoQtrol4

ENQ ampqwry NAK Negativeackilowledge ACK

Acknowledge SVN Sync~nous idle

Btl Bell ETB End-of-tmnsnussionblOck sS Backspace CAN CanCel HT Horizontal tab EM End of mediUrlt LF Lintifeed SUB Substitute VT Vertical tab ESC escape FF form feed FS File separator CR Carriigeretum GS Group separator SO shift Ollt RS Reoord sepuator SI Shlftin US Unit separator SF S~e DEL Delete

ASCII is a seven-bit codebutrnostcompUters manipulate anejght-bit quantity asa unit called a byte Therefore ASCII characters most often are stored ~e per byte The

I biti~sometimesused forotlef purposes depending ontheapplicatio~lFor example printetS recognize eightmiddotbit AScn chaiacterS with themost sigoificaot bit ~twO An atkJlitlo

Section 18 Binary Storage and Registers 2S

128 eight-bit characters with the most significant bit set tol are used for other symbols such as the Greek alpbabet or italic tyIe font

Error-Dtectlng Code

To detect errors in data communication and processing aneigbth bit is sometimes added to the ASCll cbaracter to indicate its Panty Aparitybit is an extra hit included with a message to make the total num~ of ls either even or odd Consider the fo119wing two cbaracters and their even andodd parity

With even parity With odd parity Ascn A = 1000061 01000001 11000001 ASCI( T == 101deg100 11010100 01010100

1

- Ineacb casewe insert an extra bit in the leftmost position of the code to produce an even number of 1 s intQe cbaraeter for even parity or an odd number of 1 s in the character for odd parity In generlll one or tbe oth~r parity i~ adopted with even parity being more common

The parity biqsbelpful in detecting errors during the transmission ofinformation from one location to another nisfuJictiOD is bandIed by generating an even parity bit at the sending end for ~h character The eight-bit characters that include parity bits are transmitted to their desshytination The parity ofeachebaracter is thetichecked at the receiving~nd If the parity of the received cbaracter is Dot even then at1east on~bit has changed value dUring the trmlsmission This method detects one three or any odd combination of errors in each character tb8t is transshymitted An even combination oferrors however goes undetected and additioDaterror detic- shytion codes may be needed to take care of that possibility

What is done after an errQlis detected depends on the partieu~ application One possishybilityis to request retransrois~ion of the message on the assump~on that tbeenigtr was ranshyd()m andwill not occur again Thus if thereeeiverdetects a parityerrorit sends bai~ the ASCII NAK (negative acknowledge) control cnaracter consisting ofail even-parity eight bits lOOlOl01H no error is detectedthe ~iversends back anACK (aCkno~ledge) conshytrol character namely 0000011 O The sending end will respond middotto an NAK by tranSmitting the message again until the correct panty is received Ifmiddot after a number of attempts the transmission is still in error a message can be sent to the Operatai to check for malfunctions in the transmission path

BINARY STORAGE ANORECiISTEIlS

The binary infonnation inadigitalcomputermust have a physical e~stencein some medium for storing individual bits A binary cell is a device that possesses two stable sttes and is cashypable of storing pne bit (0 or 1) oflnfotlllation The input to tbe cell receives exciJation sigshynals that set it to one of the two states The output of the cell isa pbysicalquantity that distinguishes between the two states The irtformationstored in Ii cell is 1when the cell is in one stable state and degwhen the Cell is in the other stable state

26middot Chapter 1 Digital Systems and BtnaryNumbers

Registers

A register is a group of binary cells A register with n cells can store any discrete quantity of middot information thatcontains n bits The state ofa registeris an n-tuple ofls middotand Os with each bit designating the state of one cell in the register The C()ntent ofaregister is a function of the int~rpretation given to tbeinformation stored in it Consider fQf ex~ple a 16-bitregister with the following binary content

11 00001111001001

middot Aregjs~ with 16 cells can be in one of 216 possible statesIf one asstimesthat the content cif the register represents a binaryinteger then the register can store any binarydumber from Oto 216 - 1 For the patticularexample shown the content ofthe register is the binary equivshyalent(lftbe decimal number 50121 If one assumes instead that the register stores alpbanushy

middot meric characters of an eight-bit cooe then the content of the register is any two meaningful characters For tht ASCII code with anevenplirityplaced in the eighth most significant bit position the register contains thetwo charactersC (the lefunosteightbits) and I (the rigbt~ most eight bits) If however one in~rprets the content of the register to be four decimal dig- its represented by a four-bitcode tnenthe content of the register is a four-digit decimal number In theexcess-3 code the register holqs the decimal nutriber 9096 The content of the registe~is meaningless in BCD becau~e the bit combinatiOn ltob is 110t assfgned to any decshyimal digit From this example it is clear that a register can store discrete elements of inforshymation and that the same bit configuration Inay beinterpreted dlffe(ently for different types of data

tmiddotmiddotReglsterTrail Adigitalsystenlis characteriZed by its registers and the components thatpetfolin data proshy~ssingIIl digital sy~tems a rcentgister tra1lsfer operation is abasi operation that consists of

middot a transftr of hiJWy hUormation from one ~t of registers into ano$er set of registers transfer may be dir~ctfr9m one regist~r toanlt)ther or may pass througb datamiddotprocessing circuits to petformaD operation Figure L 1 illustratel the transfer of iidOrnuttion among regshyisters anddemonstratespictorlallY [the tr8ll~~ ofbinaryinformation from akeyboard a register in the memQryullit Thehlputunit~s assumed to have a keyboard1 control cuit and aninput register Each time a key is strock the control circuit enters an ImnV$_

lent eight-bit alphanumeric character coqe into the input register We shall assume that code used is the ASCII code with an odd-parity bit The information from the input regisshyter is transferred into the eight-least significant cells Qf a proeessOr register After transfer theinpui register is cleared to enable the control to insert a new eight-bit when the keyboard is struck again Each eight-bit character transferred to the pro1c4ess(raquo register is preceded by a shift of the previous character to the next eight cens on its left~

middot a transfer -of four characters is completed the processor registeris full and its contents transferred into a memory register The content stored in die memOry register shown in Figl came from the transfer of the characters J 0 H an~ N aftet the four ap)lroJ)riatt keys were struck

Section 18 Binary Storage and Registers 27

FIGURE 11 Transfer of information among registers

To process discrete quantities of infoiniatiori in binary form a computer m~st be promiddot vided with devices that hold the (lata to be processed and with circuit elements that manipmiddot ulate individual bits of irifonnation The device most commonly used for holding data is a register Binary variables~ manipulated by means of digital logic circuits Figure 12 il~ luslrates the process of adding two l()bit binary iUlmbers Themeniory unit which no[shy

mally consists of millions of registers is shown with only three ofits registers Thepait of the processor unit showncoDsistsmiddotofthree registers-RI R2 and R3~getherwith digital logic circuits that manipulate the bits of RI and R2 and transfer into R3 a binary number equal to their arithmetic sum Memory registers store information and are incapable of pr0shy

cessing the two operands However th~ information stored in meDij)iybanbetransferred to ~ processor registers and the resUlts obtainedin processor tegisters can be transferred back into ame~ry register for storage Untill)ecded again The diagram ~wsthe90ntents of two

operands transferred from twoJDemoryregisters into RI imd R2 The digital logic circuits produce the sum which is transfened to register R3 The contents of R3 can now be 1riUlsshyferredback to one of thetnemory registers

The last two examples demonstrated the infonncion-flow capabilitieSofa digital system in a simple manner Themiddot registets of the ~ystem are the basic ele~ents for Noring and holding the binary information~igitallogic circuits process the binary ihfonaation stored in the

28 Chapter 1 DigIt bullbull Systems and Binary Numbers

Sum

FIGURE 12 Eumple of blnarylnfonn~t1on processing

registers Digitallogiccirctiits and registers are covered InChQpteB 2 throQgh 6 The metlilOlY unit is ~xPIained ill 9aptet 7 Th~ descriptton of register opetJtions at the register level and the design of digital systems are covexed in Chapter 8

19 BINARY LOGIC

Binary logic deals with variables th~ take on two discrete valueund withoperations that sumelogicalmeaning~ The two val~s the variableussume may be called~ydifferent (true andalse yel and no etc) but for ourp1llpQSe it is cpqVenienttotbink in terms of and assign the values llUld O The binary logic intr0ducedin this section is equivalent to algebra oalledBoolean algebra The fannal presentation ofBoolean algebra is covered in detail in Chapter 2 The purpose ofthis seCtion is to introduce Boo algebra ina matmerandlate it to digitallogiccircuits andmiddotbinarYsignalsmiddot

Section 19 Sinary logic 29 ~

Itkltn of IInary logic

Binarylogic consists of binary v~les and a set of logica1middotoperatiQDS The variables are desigshy ~by lettell of thCalplWlet~such asA B C x yz etc with eaCh variable baving two and oniy

two distinct posSible valueS 1and O There are three basic logical operations AND ORand NOT

1 AN]) This ~peration is represented by adotorby the absence ~f an oPerator For example x bull y =z or xy = zis~ x ANDy is equalto z~ThelogicaloperationAND is interpreted to mean that z == 1 ifand only ift~ land y = 1 otherwise z = O (Reme~r that x y andzare binary v8riablesand canmiddotbe equal either to 1 or Omiddotand nothing eise)middot

2 OR This operation IS represented by a plus sign For example x + y =z is read x OR y is equal to z meaning that z 1 if x = iorif y = lorifbothx= 1 and y = 1 If bqth X - 0 andY Omeo z= O

3bull NOT This operation is repf6sented by a prime (sometimes by an overbar) For ~xample x =Z (or~ =z) is read notdsequalto 1 meiming that z iswkatx isnot In other

words ifx = 1 then z == 0 but if x == 0 tnenz = L TheNOT operationisals(1 reshyferred tolls the complement operation since it changes ~ 1 toOand a O to 1

bull bull lt Binary logic resembles binary arithmetic and themiddot9peratioos ANDahd OR have similarishy

ties to multiplication and addition respectively In fac~ the symbols used for AND and OR are the same as those used for multiplication and addition However binary lOgic should not be conshyfused withbinaryarithIrietic One should realize thatan arithmetic variable designates a numshyber that may consist of many digits A logicmiddot variable is always either 1 or O For example in binary arithmetic we have I +1 =10(read~one plus ()fie is equal to 2) whereas in binary logicwe have 1 + 1 1 (read one OR onds equal to one)

For each combination of the values oix and y bullthere isa value of ~ $pecifiedby the definishytion of the logical operation D~linitiops of logical~perations maybe listed in a compacHorm called truth tables A truth table is atable of anpbssible combinations ofthe variables $howshying the relation between the values that the variables may take and the resultof the operation The truth tables for th~ operations ANDand OR with variables x and y are obtained by lis~ng

all possible values that the variables may have when combined in pairs bull For each combination the resUlt of die operation 18 theillistedin a separate row The truth tables for ANDORand

NOT are given in Table La These tables clearly demonstrate the definitionf the operatibns

Table 18 Truth TcibJts of Logical Operations

AND OR NOT

x y xmiddoty x y x+y

0 0 0 0 0 0 1 0 0 1

10

1 0 d 1 0 1 I 1 1 1 1 1

bull~lt~m

30 Chapter 1

Logk Gates

Digital Systems and Binary Numbers

Logic gates are electronic cirellit that operate on ~

variable

or mpre mput tignals to produce an output signal Electrical signals sUch as voltages orrutrents exist as analog signals having values over a given taDgebull saYOt03 V but in a digital system are interpreted to be either of two recognizable values 0 or 1 Voltage~opetated logic Circuits respond to two separate voltshyage levels that represent a binary varjable equal to logic I bt logic O For example a partic- ular digital system may define 10gicOas a signal equal to 0 volts lind logic 1 asa signal equal to 3 volts In practice each voltage levelhiS an acceptable rangeas shown in Fig 13

The input te~nals of digital cikuits accePt binary signals within the allowable range and respond at the output terininals with binary signals that fall within the specified range The intermediate region between the aJl()wed regions is crossed only during aState transition Any desired information for computing or control can be operated tm by passing binary signals through variQUS combinatioDsof logic gates with each signal represebting a particular binary

The graphic symbols used to deSignate themiddotthree types of gates are Mown in Fig 14 The

gates are blocks of hardware that prooocc tbeequivalent of1ogic~1 orlogic() output signals

Volts

- FGURl13

x

y

Exampleof binary slgnaJs

Signal ratlge for logieO

(a)~omiddotinput AND gate

FIGURE 14 SymbOls for digital logic circuits

(c)NOT gate or invert~

Problems 31

x-lU 1 11 P 0

y 0 0 11 1 ~

ANDxy 0 0 rTl 00

ORX+Y~ NOT x 11 0 0 I 1 1

FIGURE 15 Input-output 5Igals for gates

FIGURE 1

A B C

Gates WIth mlltlple JnpUU

A B C lJ

~

if inPllt logic ~ts are satisfied Theinput signals xaDd y intheNDaadQR gates may exist in ~ oHow-possible states 00 10 11 or 01 Il1ese ibpu~ampignals_ shown inFig lStoshygetber with the corresponding output signal foreach PfCThI~tiaiug~iDustrate the reshysponse ofeaclt gate to the four input signal~The~llisofthetiminadiagram represents time and the vertical axis sbo~~~~ it cbapg~botwcen~possible voltshy

age levels The low level represents logic O tJte high level l1lteAND _ responds With a logic ~ ~tput sipl wh~ both input ~~)e 1middot1~ lIieOR S-~with a logic 1 outpUt signal ifanylnput sigrudis lOgic 1 TheNOTgateis~~ to BUll invedet The reason for~nameis~t froJn the signalmsponae inmiddottbe timitt8 diagramwhicbsbows that theoUtputsignal inverts the logic sense of tbeiDpUtsigll8l

AND and OR gates may bavei)lQte tbantwQinputs M AND8_~itti ~input$andan OR gate with foU) inputs are shown in Fig 16 The three-inPllt AND gate responds With logic 1 output if all tbreeinputs arelogic 11jleoutputproduces lOgic Oifanymput is logic O-The

four-input OR gate responds withlogic 1 ifany input is logic 1 its clu1ptltllCCoines logic oonly when all inputs are logic O

Answers to prvblems marked with middotappearaHbe ClOd ofthe ~

11 lJltthe octal and beXadecimalliurilbers trom16ui 32UdngA B1l1ld C forthebst~ digits Usttbe numbers from 8 to 28 in base13 bull

I

12t What is the exact D1Jllbcr of bytes in a system that contains lta) 32Kbytoe (b)64M ~and (e) 640 byte$ middot7 t

32 Chapter 1 Digital Systemsand Binary Numbers

13 Convert the following nu~bers with the indicated bases to decimal (a) (4310)s (b) (198hz (c) (735)8 (d) (525)6

14 Whllt is the largest binary number that can be expressed with 14 bits WhlIt are the equivaleDt ~~ iinal and hexadecimal numbei-s

--

15 Detemrine the base of thl1 numbers in each case for the following operatio~ to be correct (a) 142 = 5 (b) 5414 = 13 (C) 24+ 17 == 40

16 The solution$to the q~cequation xl - Ux +22 oare l1 3 arid x =6 What is the base of the numbers

17 Convertthehexadecimal ntmIher 68BE to bitiary and then convert it ~mbinary to octal

18 I Convert the decirpal number 431 to binary in tWo ways (a) Convertd~y to binary (b) conshyvert first to hexadecinla1 and then from ~decimalwbinary Which method is faster

19 amppress the following nqrnbersin decinud (a) IQ11O0101)z (b) (l65his (c)(2624)8 (d) (FAFA) 16

(e) (10101010)2

110 Convert the following binary numbers tobexadeoimal and todecitnal (a) UOOlO (b) 110010 Explain why the deCimal answer in (b)is 4 times that in (a)

111 Perform the followingdiviskmin binary 11 Ion + l()t

112 Add IlniImultiply tfle following numberswiihout converting them to decimal (a) Binary nuniberilOll aiIdlOh (b) He~uumbers 2E aDd 34

1~)( Do thefoHowing con~ersionproblems (a) CorivertCiecimal2731S to binary (b) CakUlate the binary eqUivalent (f 213 outto eight pl~Then Convert from binary to

imalHowgJose istbe result to 2131 (c) Convert the binary resukin (b) into hexad~ lb~oonvert ~result to decimal Is answer tbesame

114 Obtain the is 8nd 2s complementsofthe foUowing binaryDumbcentrs (aj l)()()(J()OO (b) OOOOOOOO (c) 11011010 (d)01l10110 (e) 10000101 (0 11111111

115 Find the 9s and the 10s complement of the following detimal numbers (a) 52734630 (b) 63325600 (c) 25000009 (d) 00000000

116 (a) Find the 16s complement of B2FA (b) Convert B2FA to binary (c) Find the 2scomplement ofthe resultin (b) (d) Convert the answer in (c)to hex~malandco~ with ihe an~wer in (a)

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 5: Chapter 01 - Mano

Section 13 ffumb~r-BaSetonver5iotls S

Table 11 Powers of Two

~ n 1 n Z n Z

0 1 8 middotmiddot256 16 65536 1 2 middot9 512 17 131072 2 4 10 1024 18 262144 3 amp 11 2048 f9 524288 4 16 12 4096 20 1048516

5 32 13 8192 21 2097152 6 64 14 1(i3amp4 22 4194304 7 128 15 32768 23 8388608

Arithmetic operations with numbers in base followtht same rules as for decimal nun1- hers When a base othef than the fariilliar base 10 is used one must becarefuho use only the -allowable digits~amples of~di~on subtraction and multipliCation oftwo binary numshybers are asfoUows

augend 101101 nlinuend 101101 multiplicand 1011

addend +100111 subtrahend -tOOtH multiplier XIOI sum 1010100 difference 000110 1011

0000 1011

product HOli

The sum oftwo binaiy numbers is calculated bY the sam~ rules as in decimal except that the digits of the sum ifl any sigiuficaOt position can be oDly 0 or 1 Any carry obtained in agiven significant position is uSed by the pair of digits one significantplt)sition higher Subtraction is slightly more complicated Tho rules are still the sam~ lismiddot ip declmalexcept that the bonow in a given signifieantposition adds 2 toa minuend digit (A bonoW in thedeeimaI syste~ adds 10 to a minUend digit) Multiplication is simpIefhe mo1iplier digits are 8lWaYs lor 0 thereshyfore the Partial produCts are eq~ either to the multiplicand Or la O

Theco~vefsio~ ofan~~r in ~a~e ~decimaI is40nebYexPamnngth~ntunber in a power series and adding all the terixlsasshown previOU$ly We nowptesel1u generij procedure for

the reverse operation of conyertirigadecimalnuil1ber~ anum1gtel in hasedfthe number inshycludes a radix point it is necessary to separate tbenumber~toan inte~partand a fraction part since each part mus~be converte4 diffqeptlyThe conversion ofadecimalinteger to a num- berin basO risdont by tlividingthe humber SAd all Successiv~q~nts by ~d8CCUllUlal- ing therem~ This procedure is best illustrated by example

6 Chapter 1 DigitatSy$tems and BInary Numbers

111411

Convert deciIIla14 r to binary First 41 is divided by 2 to live an integer quotient of 20 and a remainder of i Then thequoiientisagam divided by 2 to give anewquotient and remainder Theproeess is ~ntinued untilth~ integer quotient becomes O The Cf)eJJicients of the desired binary number are obtained fJOm the remainders as follows

Ioteger Quotient Remainder Coeflldent

4112= 20 + ah= 1 2012 10 + 0 at= 0

1012 = 5 + 0 a2= 0

512 = 2 + 1 a3 = 11 Z2 1 0+ G4=O

I112= 0 + 2 as =1 lt

Therefore the aDsWeris(41 )u)= (llsa4~3f12alaoh =(IOlOOlh The arithmetic proCess can be manipUlated moreconvemently as follOws

Integer 41

20

10

5 2 1

o

Relnamder

1

o o 1

o J~

1 101001 ==answer

Con~ersi~n from decimalintegeJS to lQ1ybase-r Sstem i~ similar totljis example except that division is done by r iil$teadof2

1I1t4191I Convert decimall5lto oCtal The required baSe r is aFirst 153 is divi~ by 8 tQl1ve anin- tegerquotient of 19 and a remainder of lThen 19 is divided by 8 to give an ~tegerqlotient

of 2 anli a remainder of 3 tFiny 2 is divided by 8to give aquotientof 0 and a remainder of 2 lbisproeess can be conveniently manipulatecfas follows

153 19 J

i 3 o 2= (23J)s

7 Section13middot Number-Base Conversions

lhe(OllVelSiOllQCdecimalfrmtonto binary js accompllshedby a ~od similar to tbai uscd for ~~veri multiplication is used instead of division and integers instead of

rem~ are acc~aQd Agafu~ the method is best explajned by example

bull Co~vert (06875hotobmaryFirst 06875 i~ multiplied by2 to give an integer and ajraction nen the new fraction is multiplied by 2 to give a new integer and a newfraction The process is continued until the fraction ~om~ 0 or until the nUJ1lber of digits have sufficient accuracy necoefficients oftbebinary nUlllberare ~btaipedfrolIl-~~ integers asfQUows

lnteger Fraction middotCoemclent gt~fn5 Jlt~~ i + 03750 a-I = 1

()37SO f(2 0 + 07500 g-2= 0

07500X2= 1 + 05000 D-3 - 1-

0-5000 X 2 == I + 00000 a~=l

J

) -

Thereforethe at)Swer is (O6875ho= (OD-lazQ-3D-4h= 010l1hshyTo convert adtcimal fractl9D to a number expressed in base 1 a-similar procedure isused HQwever multiPlication i~ by 1 instead all and the coefficlentsfound from the integers may

range iti value from 0 to r- 1 lI)stead of 0 and 1 bull bull bull - - -_ t lt~ 1

bull

O513X 8 = 4104

0104 X 8 = 0832 0832 X8 6656

0656 X 8 == 5248

0248 X 8 = 1984

0984 x 8= 7872

The an~wer to seven significant figures is obtained from the integer part onhe products

(OsP)IO= (0406517)8

middot8 Chapter 1 Digital Systems iilnd Binary Numbers

Ibo oonversion ofdecimalnumbers withbotMnteger and ftattionparts is done by con- vertingthe integer and the fraction separately and ihencombinihgthe two answers Using the re$Ults ofExamples 11 and l~ weobtain

(416875h~ (lOI001l011h

From Examples 12 and 14e have

(1535130 (2314tl6517)s

14 OCTAL AND HEXADECIMAL NUMBERS

The conversion frOm and to binary octal and bexadecimal plays an important role in digital computers Since 23 =8 and 24 = 16 each octal digit corresponds to thref binary digits and bull each hexadecimal digit corresponds to foUr binary digits The first 16 numbers in the decimal binary oct8r andhex~ecimalnumber systems are listed in Table 1-2

The comersion fm~ binary tooctal is easilyacltooiplishedby partitio~ng the binary num ber into groups oftbree digits each starting ti()n1 the binary plmt and proceeding to the left

I and to the right ~correspo~ octal digit is then assigned to each group The following example illustrates the proeedure ~

(10 110 001 101 011 11~ 100 000 lloh = (261537406)8 2 6 1 ~ 3 7 4 0 6

T_lel2 Numbers with Different-Baus

DecImal IY Octal Hexadecimal middot(base 10) (base 2) (b) (16)

i

00 0000 00 p 01 0001 01 1 02 0010 02 2 03 0011 03 3 04 0100 04 4 0 0101 OS 5 06 0110 06 6 07 0111 07 7

08 1000 10 8 09 1001 11 9 10 1010 12 A 11 1011 13 B 12 1100 14 C 13 1101 IS D 14 1110 16 bull

Ej

IS 1111 11 F r i

9 section 1S Complements

Conversion from binary to heudeciInal is similar except thatthe binary nutriber is divided into groups ofourdigits

(10 1100 0110 1011 1111 0010h = (2C6BJ2) 16

2 C 6 B P 2

The comsponding heX~ima1(o~ octal)~digit fOr each group of binary digits is easily reshymembeled from the values listed in Table 12

Conversion from octal or hexadeciInal to Jlinary is dOne by reversing the preceding proceshy(luremiddot Each octal digit is converted to its tbi-ee-digit binary equivalent Similarlyeach hexashydecimal digit is convertedioits four~digitbinaryequivalent1he procedure is illustrated in the following examples

(673124)8= (110 6

III 011 7 3

001

010 2

l00h 4

and

(306Dh6 = (OOlf 0000030shy

110 6

~101h D

Binary numbers are difficUlt to work with because they require three or fout times as many digits as their decimal equivaltmts Por exaniple the binary number 111111111111middotis equivalent to decimal409S Howeverdigital computers use biIUuy11UIhbers and itis soIIJet4nes necessary for the human operator or user to oonununicatedirectly With the machine by means of such num bers One scheme that retainsthebinary~ystem in the cotnputer but reduceS the number of digshyits the human must cOnsider utilizes the relationslripbetyeen the binary Ilumber system and the ~ or hexadeciinal system By this method the Ql1DaIlthinksin tenns ofQCtal ornexadecimal nurnbers and performs the required conversion by inspection when direct communication with the machine is necessary Thus thebinary number 111111111111 has 12 digits ~d isexpressed iIi octal ~ 7777 (4 digits) or in hexadecimal as FFF (3digits) During communication between people(about binary numbers in the coJlllQter)the octal or hexadecimal representation is more desirable because it can be expressed more compactly with a third or a quarter of the number of digits reqUired for the eqwvalent binary number Thusmpstcomputer manuals use either octal laquohexadecimal numbers to specify binaryqwintiti~ The choice between diem is arbitrary although hexadecimal tends to win out since it can represent a byte with two digits

PlEM ENTS

Complements are used in digital cOmputers to simplifydle subtraction operation and for logshyical manipulation Simplifying operations leads to simpler less expensive circuil$ to implement the operations There are two types of complements for each baSe-r system the radix comshyplement andthe diminished raclix cOtllplement Themiddotflrst is referred to as the rts complement and the second as the (r - middot1)scomplement When the value of the base r is substituted~ the name the twotypesare refefted to as the 2s complement and 1 scomplement fot binary numshy~rs and the lOscompl~ent and 9s complement fqrdecimal numbers

10 Chapt~rl Digital Systems and Binary Numbers

D~I~llhed Radix Complame~middot Gi~en a number N in base r haYing n digits the (r - 1)scomplement~f N is defined as

(rll - 1) ~NFotdecimainumbersr -= Wandr -1 9sothe9scomplementofNis (10 - 1) - N IIi this c~ 10 represents a number that consists of a single 1 followed by nOs 10 - lisartumberrepresentedbyn9sFOrexampleifn 4wehavel04 = 10000 and 104 - 1 = 9999 It follows that the9s complement ofa decimaJnumber is obtained by subtracting each digit from 9 Here are some nwnericalexamples

The 9s complement of 54670(Ms929999~ 546700 453299 bull - I

The 9scothplement of012398is999999~0l2398 =987601

For binary pumbers r =2 and r - l~ 1 sothe 1s complementofNis(Z - 1) - N Again 211 is represented by a binaty number thatconsistsofa 1followed by Ii0s 211 - 1 is abinary number represented by ~1s~FOr example if 11= 4 we have z4 = (10000)zand 24 - 1 = (1111h Thus the ls complement of a binary number is obtained by sUbtractiDg

each dig~t from 1 However when subtracting binary digits from 1 we can have either I -0= lor1 - 1 = 0 which causestbe bit to change from Oto 1 0( from 1 to 0 respec- tively Theretore the ls complement of a binary number isfonnedby changing 1s to Osand Osto 1s The f9llowillg are somenumqical ex~esI

~

The ls Complement of 1011000 isotOOiu

The 1scompieme~t oHlIOUOI is 10 tOOlO

The (r-l) s compleme~ ofoctal or b~xadechnalnumbers i~6btained by subtracting eaeh digit from 70rF (diicimallS) respectively~

Radl~ C~mplement

The s complement of an n~digit number N in baserisdefinedasrmiddot Nfot N i 0 and as ofor N = O~ Comparing with the (r- l)s ~entwe note that ~rs complement is obtained by adding Ito the (r - l)scomplement smcer - N= HA-- 1) - N] L lhus the lOscomplementof deein1al2389 is 76lO +1 = 7611 and is otltamed by adding 1 to the 9scomplernent value The 2s oomplementofbinary 1011oois 010011 1 =010100 and isobtained by adding 1 to the ls-complement value

Since 10 is a number represented by a 1 followed by n0s1011 N Whicb is the10S com~

plementof N can be fonn~d also by leaving allieasl sigtrlficani Os Unchanged the first nonurO least significant digit from 10 and SUbr8Cting all higher significant

from9 ThUs

the 10s complement of 012398js987602

and

11 Sectlon middot15middot Complements

The 10s complement ofthefustnumber isobtaineltibysublriiCtingSfrom lOin the least sig~ nificant position and subtracting all other digits from 9~ The 10s complement of the second number is obtained by leaving the to least significant Os unchanged subtracting 7 from 10 and subtracting the other three digits from 9

Similarly the 2s complement ~be fonned by leaving 1ll11east significant Os and tbe first 1 unchanged and replacing I swith Os and Os with ls in allother hi~r signifIcJUlt digits For example

the 2s cORlplement of 1101100 is 0010100

and

the 2scomplement ofOllOllHs 1001001 _ - r

The +s complement pf therrrst nJUDber i~ obt4iriedby I~vingthetwo least significant Os and the first 1 unchanged andmiddotlQen replacing ls with Os and Oswith 1~ in the other four most sigmiddot nificant digits The 2s lXgtmplement qf the second number is obtained byleaving the least sigshynificantmiddotl unchanged and (fOmplementing all other digits

In the previous definitions it was assum~dtMt the D~bers did not have a radix pomt1f the original number Noontains a radix point the point should be removed temporarily in order to form the s or(r 1)s complement The radix point is then restored to the c9ll1plementshyednumber in the same relative PositionIlis abo wOrth mentioning thatfhecontplement oftbe complement restoresthe number to its original v41ue To see this rel~tionsbipnOtethat the ts complement of N is n - N so that themiddot complement oft1e complement is n - (n - N) == N and is ltlqual to the original number

Mr8Ctiton wltl1 Complementsmiddot

1le direct metb()jiofsubtraCtion taught in elexnentaty schpOls uses the bottow concept In this QlCth9dwebortowa I from a middothigher significant position when the minuend digit is smaller than the subtrahend digit The tDethod wor~wen when peOple perfonnsubtraction with paper andpeooillIowever when subtlaction is implemented withdigi1al bardw8le the method is less e~citnt than the method that u~s compl~m~ts

The subtraction of two n-digitunSigneq numbers M N in base can be done as fonows I

1 Add the minuend M to the scompleme~t of thesubtramphend N Mathematically M+ (n N) = M N +

2 IfM ~ N ttie sum wiUproduce an end cury 11 which caD be discarded what is left is the resultM N

3 If M lt N the sum does not produce ~tlend carry JUld iseijUattor (N~ Ji) which is the s complement of (N - M) To obtain the answer in a familiar form take the s complement of the sum aruI place a negative sign in frorit

12 Chapter 1 Digital Syst-ems and Binary N~mbers

The following examples illustrate the procedure

plPi1I VsinglOs complement subtract 72532 - ~250

M = 72532

lOs complement of N + 96750 Sum= 169282

Discard end caIry lOS = -100000 Answer = 69282

Note that M bas fiv~ digits andN has only fourdigitsBoth numbers mtast have the same numshyber of digits sowe wrlteN as 03250 Taking the lOscomp~ementofNptOducesa9 in the most significant PositionThe occurrence of the end carry signifies that M ~ N 8ndtlult ~ result is therefore positive

Ulling 10s complement subtract 3250 - 72532 - ~ ~

M = 03250 JOscornplementof N =+27468

Sum= ~0718

There is no end carry Theref()re-theanswer is--(10amp complementof30718) == -69282 Note thatsince 3250 lt n532~the result is negative Becauwe are dealing with WUiigned

numbers there is really no way to get BnunSigned result for this case When subtracting complements we reoogilize the negltive answer from the~sence of the end carry and complemented result When workingwith paper and pencil we c8nchlnp the aDswer

signed negative number in oider to putH inafamiliar form Subtraction with complements is done with binary numbers in a similar manner uing

procedure outlined previously

EXAMPLE 17

Given the two binary numbersX = 1010100 and Y =1000011 performtbe $UbiDctiG (8) X - Y arid (b) Y - Xby using 2scomptem~ts -

f

- -

Section 15Complements 13

(a) x = 1010100

2s complement ofY= + -0111101

Sum = middot 10010001 Discard end carry 27 = 10000000

Answ~ X- Y = 0010001

(b) Y == 1000011 2sco~lement of X = + 0101100

Sum= 1101111

There is nQmiddotend carry Therefore the answer is Y ~X= -(2sq)mplement of 1101111) = -0010001 Subtractionof unsigned D1lJllbers ~ also bed()neby means of the (r - 1)s complement Remember that the(r- l)s complement is one lesstharithers complement BeCause of

ibis the result of adding the minue~ to tJte coQlplement of the subtiah~ndPtOductS itsum that is one less than the correct 4ifference when an end carrY oCcurs Removing the end carry and adding 1 to the sum is referred to asan end-around carry

Repeat Example 17 but this time using rs complement

(8) X y = 1010100 - 1000011middot

X= 1010100

rs complementafY= + olfnoo Som = 10010000

End-arOundmiddot~ =- ~ ~ Answermiddot X Y= middot0010001

(b) Y - X = 1000011 - 1010100

Y = 1000011

1s complement ofX = +0101011

Sum = 1101110

There is no end carry TherefOre the answer is y - X = -(1s complement of 1101110) = -0010001

bull Note that the negative resultis ob~ by taltingtbe 1 scomplemeilt of theJWltsince this is the type ofcoDiplementused The procedwewithendaroundoanyis aIs(gt Iijlpliclbleto subshytracting Unsigned deciImdnumQers with 9seomPlement

14 Chapter 1 Digital Systemsand BinayNumbers

16 SIGNED BINARYNUMBER$ ~

Positiveintegers (including zero) CaBbe ep~~ 11$ unstPecl numbers However to repshyresent negative integers we need a notation for negative srn ordinary arithmetic a negshyative number is indicated by a mulUs signmdapOsitiv~Pwtlt)e~ by aplus sign Because of lJardware limitations computers mlstrepresenlev~With~ digitsIt is customary to represent the sign witb a bit placed intheleftmotp6sitiolwfthe number The convention is tltl make the sign bit 0 for positive and 1 for negative

Itis important to realize that botp siped and unsignedtDnary 11UJDbers consist of a strfug of bits when represented in a com~ TQeuser detem1inesWbether the number is signed or unsigned If the binary number is signed then the lefuriostbitreple$ellts thtsign aud the rest of the bits represent the number Ifthebinaryllu~beiis~ tObe unsigned then the left most bit is the most significant bit of the l)uMber Fdre~the~~f bits 01001 can be consideredas 9 (unsigned binary) or as +9 (Sighedbitia1j) ~USJtheteftmostbit is O The

string ofbits 11001 represents the binary ~~v~ento~ ~w~nc~idered as an unsigned number and the binary equivalent of 9whenconsidered1l si~riumPer This is because the Ithal isintbe leftmost positiondesignatesampC nega6ye_~QtherfourJ)its represent bishynary 9 usually tlere is no cotifusionin identifying thebits~the~Qfrepresentation for the number is known in advance ~

The representation of the signed numbers in the lastexainple is referred to as the signed magnitutk coDvention In this ~otati()nthenurnber C4mSiampesOCa mQ~~andil~ymbolH

or -) or a bit (0 or 1) indicating the sign This is the representation ampr~~used in ordinary arithmetic When arithmeti~ operatioBslllieimplerneJltcldin~cOQlPuter hii more convenient to use a different systemrefetred t(gt as the si~cqmptement system~ for repre- senting negative numbers In thissystlm a neg8tielliun~r isjhdic~ted by its cornplc~mc~nt Whereas the signed-magnitude system negates a nlllllher by cbanging its sign me signed-comshyplement system negatesanwnber bytakin$ its~OinPleltleitiSinoepositife numbers always start witbO(plusin tte leftmost pOsition thecompktllint wiilalwaysstart with a 1 indicating a negative number The siped-complemelt system can use olthertbe 1s Or the 2s but the 2s complement is the mos~comtliOfi

As an exampleconsider the number9re~~ed in binary with eight bits + 9 Is sented with a sign bit of Oin the leftri1ostpOsition oIIOv~by the binary (equivalent of 9 which gives ()()()olOOl Note thai all eigbtbits must haYampa v~therefore O~s are inserted folshylowing the sign bitllp to the first 1 Although ~ is only 01K way to tepresent +9 there three different ways to represent 9 with eight ~its

s~gned~magnituderepresentation 10001001

sigried-l s-complement represe~on~ 11110110

signed-2 s-complemerit representatim 1ttltllU

In signedmagnituamp -9 isobwned from +9 by changing the sign bitmtbe leftmost ~iti(ln tromO to L In sigl1ed~ lroomplement 9isobtaidedtf~~tiog all the bits of includinj the sign bit Thesigned-2~sco~re~Qf-9 is obtampDedby ihe 2s complement oftbepOsitivenumberincludingtbesijnbIt

Sectlont6 SIgned8lnary NumberS is

Table 13 Slgtlfd Biliary Humbm

+7 +6

+5 +4 +3 +2 +l +0 0 -I

-2 -3

4 -5 -6 -1 -8

Olll 0110

0101 ( 0100

001l 0010 0001 0000

IIll 1110

nOI noo Ion 1010

1001 1000

OIll Oito eHOl OHIO OOU 0010 0001 0000 1111 1110middot dOl 1100 Ion

lOti 1001 1000

0111 OUO 0101

0100 0011 0010 0001 0000 1000 1001 1010 IOU 1100

1101 1110

lUI

Table 13 lists all possible four-bitsignedbinaryaumbers in the three representations The equivalent decimal number Is also shown for refelenoeNote that the positive n~ in all three representations are identicaland have 0 inthelefmostpcsiticm The signed2sshycompl~mentsystemhaironly onemiddotrepresentation for 0 which is always po$itive The other tw()systetns- mlve either a positive 0 or a negative 0 sometbingnoteDcounteredin ordinary arithmetic Note that all negative numbenhave alin the leftmost bitpositi~ that is the way we distinguish them from the positivenumbers With fout bits we can repreSent 16 binary numbers In the signed-magnitude aDd thelscomplement repre$eDtatipns there are eight positive numbers and eight negative numbers inciUdingtwo zeros In the2s-complement representation there are eight positive numbers includi0a one zerQ and eight negative numberS

The siped-m_gnitude system is used in ordiIlary arithmetic but is awkward when emshyployed in computer arithmetie becauIe of the ~parate bandIinJ bfthesipand the magnitude Therefore the signed-compiement systeni is normallyused The ls ~t imposes some difficulties and is seldom USedJor arithmetic openitiOns It is U$eful aSa lo~ operation since the change of 1 to Obrmiddot() to 1 is equivalent to a logical complement Operation as will be shown in the next c~The discussion~f sigiled binary ariduneti~ that fol10ws deals exshyclusively with the signe4-2soomplt_nt~tatJonQfnegadveilUlilbers hsame proshy

cedurescan beappJied to the sigMdrs-comPlemeD~Iysby incIudiOI tbe~arotmdcarry as is done with unsigned numbers

J6 Chapt~r 1 OlgltalSystlf(ns and Binary Numbels

Arithmetic Addition

The addition of two numbers in the signed-magnitudelYs_foUowsthe rules ofordinaiy arithshymetiC Ifthesi~s arethesam~we addthetwOtt~gni1U~~d ~vetbe sum the CCmmon sign Iftbe signs are diffe~nt we subtract tllcsmaUermagnitude frOtnlthe larF and give the differshyehtethe signof the larger magnitude For example (+25) +( - 37) = ~ (37 - 25) = -12 and is done by subtracung the smaller magnitude 25 from the larger magnitude 37and a~nding the sign of 37 tGtbe result Ibis is a process that requires a corripanson of the signs and magnitudes and then performing eithr additi()n or subtraction The same procedure applieato binary numbers in sigped-magnitude representation~Incontrast the rule for adding numbers in the signed-corppleme~ sy~tem does not require a comparison or su~ traction but only addjtion The procedure is very simple andcanbe stated as follows for binary numbers The 8ddltion oftwo signed binary numberS with negative numbers tepresented in signed- 2sComprement fonn is obtaiIled from theadditlooofthe two numbers includingtheii sign bits

AcentiirrY out oftbe sign-bitposition is diScacded NumerIcal e~aihpledotai1dition follow

+ 6 00000110 - 6 11UI0tO I

+13 00001101

+13 00001101 +19 00010011 + J 0Q900111 + 6 00000110 6 11111010 ~13 11110011 -1~l 11110011 7 illl1001 -19 11101101

I bull bull ~

Note that negative numbers musthil iriitially in 2seompkmentform and that if the swn ~ ~afterthladdit40nis negativeins in2s~p~t fOl1Jl - In each of thefoDrcasestlteoporationperfol1JlC(lis additionwitb the sign bit iilcluded Any catTY o~of~~-bit~onisdisc~ and negative resultsareButomaticallyin 2sshyromplementfoon

In order to obtain acOrrect answer we mustensQre that the result has a sufficient of bits to accommodate the swnlfwestartwith t~on-bltnumbers and tbeswn occupies n + 1bits we say tblltan overflow occurs~Wheri one perfotmStbc ad(JitiOJl with nllllIPTJllVIl

pencil aq overflow is not a preblem because we arcr noflimitecLbythewidth of the page jUst addanothcentr 0 to apositive number or another 1 toa negative number in the mOst cant positi()n to extend thenwnber to n+ 1 bitSand theQ perform addition Overflow is

problem in computers beqiusetbe number ofbi~~ bolla ~befis finite and a result ex~ tI1efinite val~e hy lcatmotbe accommodated

The compJement form of representiQg negativetlQUlbers is unfamiliar to those usedto signed-magnitude system To itetermine th~ value of II negatienumber insiped-2s COlIlpJe

mentit0is~ to CODVerttbe numbcr to apositie ntirit_ ~ place itiDa more formPor ~plethesig~binary number qUl00~ lii~egativebecausothe leftmost

t 1182s c0J8plemen~js~UlwhUhi$~ binaryeqqivalen of +7Wcmiddottherefore nize the Ori~nal ~atiy-eQumber to be equ~ lo-7 1

Sectlonl7 Bh1ary Codes 17

ArIthmetic SubtractIOn

Subtraction of two signed binafy numbers whe~negative numbersare in2s-complement form is simple and can be stilted as follows

Take the 2s complement of the5ubtraltend (including the sign bit) and add it to the minuend (including the sign bit) A cany oU1of thesignbit position is discarded

This prOCedure is adopted because a subtraction operation can be changed to an addition operation if the sign of the subtrahend is changed as is demonstrated by the following relationship

(plusmnA) ~ (-tB) = (plusmnA) + (-B) (plusmnA) - (-B) =plusmnA) + (+B)

But changing a positivetwober toa negative n~ber is eaampily done by taking the 2s compleshy mentof the pQsitive number The reverse is also tiUe~use theCOmPle~n~ of a negative numshyber in complement form produces the equivalent positive number To see this consider the sJlbtr~ction ( 76) -- (13) = +7 In binaIy_ with eight bits this ()peiationis written as (11111010 11110011) The subtracti~ri ischmlged ~ addition by taking the 2s complement ofthe subtrahend (-13) giving (+13) In binaly tbis~ 11 niOlO+ 00001101 = lOOOOOU1 Removing the end~ we obtain the ootrect answer ()()()()() III (+7)

Itisworth noting that binary DUmbersinthe signed-complement system are added and subshy tracted by the same basic addition and suPtraction rules as unsigned numbers Therefore comshyputersneed omy one common hardware circuit tobandle bothtypcs ofaritbtnetic The user or programmer ~ust interpret the reswtIi of $l1ch addition or subtraction differently depending on whether itisassumedtha~the numbe~ are signed ltr tinsigned

j

BINARY CODES

Digitalsystems use signalsthat have two distinct values1Uld circuit elements that havetwostashyble states There is a direct analogy anrong binary iignals binary circuitelements and binary digits A binary number ofndigitsfor example may be represented by n binary circuit eleshyments each baving an output sig~alequivalen1to Oor I Digital systems represent (Uld mashynipUlate not omy binary numbers but alsO many other diScrete elements of information Any discrete element of informatioIidlat is dis1iilct among agroup of quantities can be represented witha binary code (Le a pattern of Os and fmiddots) The codes must be in binary because in todays techIiology omy circuits that represent and manipulate patterns of 0s and ls can be manufactured economically foru~ in computers However it mtistbe realizCd that binary codes merely change the symbols not the meaning ofthe ele~nts of infonbationthat they repshyresent IT we inspect the bits of a computer at random we will find that mostofthe time they represent some tYPe of coded information rath~ than binlUY numbers

AIln-bit binary code is a groopofn hits that assumes up to 211 distinct cOmbinations of ls ~d Os with eacn combination representing one elementof tnt set that is being coded A set

of four elements clab becoded with two lilS with each ~lementassignedoneof thefoUowing bit oombinationsOOO I 10 J 1 A set of eight elements requiies a three-bit code 00 a set of

18 Chapter 1 Digital Systems and Binary Numbers

J6 elements requires a fourmiddotbit code The bit combination of ann~bit code is determined the count in binuy from 0 to 21t - t Each element must be assigned a unique binuy bit binationand no two elemerits cm havetbtsamevalueothenvisethe code assignment be ambigUous

Although the minimum nqrnber of 1lits required to code 21t distiItct quantities is nthere nomaximwn numbe( of bit that may he used for a binuy code For example the 10 digits can be coded with 10 bits and each decimal digit can be assigned a bit combination nine OSmid a 1 In this pamcularbinarycode the digit6 is assigned the bit )UllIUlauuu0001000000

BCDcode

Although the binary number systemis die ~ost natural system for a computer most people more accustomed to the d~imal system One way to resolve this difference is to convert

inlal nUmbers to binary perform all arithmetic calculations in binary and then convert the nary results back to decimal This metbodrequites that we store decimal numbers in

cOinputer so that they canbec6b~rted to binary Since the compllter Can accept only valueswe must represent the decimal digits by means ofa code that contains ls and Os also pOsSible lopedorm the arithmetic operlltiorisd1rectly on decimal numbers when they stored in the comput~ in cod~ct form

A binarycodewill have some unasSigned bit com~inatiqns ifthe num~rofelements in set is not amultiple power of 2 The 10decimai digits form such asel A biruuy code that tinguishes among 10 elements must coiltain at least four bits but 6otitofthe 16 possible binations remain unassigned Different binary code$ can bemiddotoNained by arranging four into 10 distinct combin~tions TheicodeIllcfflt oommonly used fdr the decimal digits is straight binary assf~ntlisted in Table 14 This scheil)eis called bittary~coded decimal

is commoolyreferred to as BCQ OtherdecimalcodesaIlfpossible and a few of them are sentedlaterinthis section

Table 14 BinarymiddotCoded Oeclmql (BCO)

Decimal BCD SnlboiDIgIt

o 0000 1 0001 2 0010

3 0011 4 middot0100 5 0101 6 0110 7 0111 8 1000 9 1001

Sectionmiddot 17 BInary COdes 19

Table 14 givesthe four-bit code for one decimal digit A number with k decimal digits will require 4k bits in BCD Decimal 396 is represented in BCD with 12 bits as 0011 10010110 with each group of 4 bits representing one decimal digit A decimalmiddotnumber in BCD is the

- same as itS equiyalent binary number only when the number is between 0 and 9 A BCD numshyber greater than lOJpoks different from its equivalentbinary number even though both con tainls and Os Moreover the binary Combinations 1010 thrpugh 1111 are not used arid have no meaning in BCD Consider decimal 18SlUld its corresponding value inBCD and bUtary

(185ho = (0001100001Ol)BCD = (l0111001h

The BCD value has 12 bits to encode the characters of the decimal value but the equivalent binary number needs only 8 bits It is obvious thatthe representation of a BCp number needs more bits than its equivalent binary value However there is an advantage in the use ofdecishymal numbers because compUterinput and output data are generated by people who use the decshyimal system

It is important to realize that BCD numbers are deCimal numbers and not binary numbers although they use bits in tbeir representation The only difference between a decimal number and BCD is that decimals are written with the symbOls 0 1 2 9 and BCD numbers use tbebinarycode 00000001 001O~ bull 1001The decimal value is exaCtly the same Dec~mal 10 is represented in BCD witheight b~ts as 00010000 and decitna1J5as 0001 01Of1lte corshyresponding binaryvalues are 1010 and 1111 and have only four bits

Consider the addition of two decimal digits in BCD together with a po~ible carry from a pre- vious less significant pair ofdigitsSince each digit does not exceed 9 the sum cannot be bull greater than 9 + 9 + 1 = 19 with the 1 being a previous carrySllppose we add the BCD dig-

its as if they were binary numbers Then the binary sumvill produce It result in the range from degto 19 In bin8ry thistange wil[be from 0000 to 10011 butin BCD it is frOm 0000 to

I 1001 with the first (ie leftmost) 1 bemg a carry and the next fo~ bits being the BCD sum When tPe binary sum is equalto or less than 1001 (withaut 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 (0110h to the binary Sum cOnverts it to the correct digit and also produces a catTy as required This is because a carry in themost significant bitposishytion of the binary sum and a deCimal carry differ by 16 10 = 6 Consider the following three BCD additions

4 0100 4 0100 8 1000

+S +0101 +8 +1000 +9 1001 9 1001 12 1100 17 10001

+0110 +0110----

10010 10111

In each case the two BCD digits are added as if they were two binary numbers If the binary sum is greater than or equal to 1010 we add 0110 to obtain the correct BCD sum and a carry In the flIst example the sum is equal to 9 and is the correct BCD sum In the second example

20 Chapter 1 Digital Systems and BInary Numbers

the binary sum produces an iJlv~ BCD digit The addition of0110 produces the cortect BCD sum 0010 (ie the number 2) and acanyInthetbirdexample the binalY SUDlproduces acany This condition occurs wben the $W)) is greater than or equal to 16Altbough the other fout are less than 1091 the binary 9Ulll requires acOnectionbecause of die carry Adding 0110 obtain thetequiled BCD sum 0111 (ie the numblaquo 7) and 8 BCD CiUT

The additionoftwondigit unsipedBCD numbers follows the same procedure COIlSioll the addition of 184 + 576 1= 76() in BCD

BCD 1 I 0001 10000100 184

+6101 ~

0111--- 0110 +576

lJinarysum 0111 10000 1010 Add6 ono 0110

BCDsun 0111 0110 0000 7(1)

The flfSt l~ sigDiticant pili- of BCD digits produces aBCDdigi~SllDlof 0000 and a for the next pair of digits the second parr or BCD digits plus a ~Vi0U8 cany produces a sum of 0110 and a carry for the next patr()fdigits The third pair of digits plus acarry proltIUC~ a binary s~ of 0111 and does not require a correction

Decimal Arithmetic The represeiltation of signed decimal numbers in BCD is simiiarto the tepresentation of numbers in binaryWe can useeitheI the familiar signed-magnitude system at the SllZllOO-COI1I

plemelit system The sign of a decimal number is tJSually represented with four bits to to thefour-bit code ofthe decimal digits Itis customary to designate 8 plus With four Os 8 minus with the llCDequivalent oi9 whlcq is 1001 The sigiled~magnitudesystem is seldom used in com~tersThe signed-complerDem ~~ either the 9s octhe 10s complement put the lOscomplement is the one most useP To obtain the lOs complement of aBCD numberwe first take the 9s complement then add 1 to the least significant digit The 9s Complement is calculated from the subtracloo of each digit from 9

The prltXeduresdevelope4 for the signed-2s-complement system in the ~vious also apply to the signed-IOs-complement system for decimal mimberS Addition is done summing all digits including the sign digit and discafding the end carry This operatiQ assumes that all negative numbers are in 10s-complement form COOsider the (+375) + (-240) == + 135 done inthe signed-complement system

o 375

+9 760middot

o 135

lhe 9in the leftmost pOsition of the second n~ber tepresents a minllS and 9760 is the complement o( 0240 The two numbers are added and tbe end carry is discarded to +13SOfcourse the decimal ntmlbers insi~ tile computer includingthe sign digits in BCD The addition isdone with BCDOigits as described previously

Sectionl 7 Binary Codes 21

The suQtr8ction of decimalliUJ1lbets either unsigned or in thesi~-~Oscomplement systetn is the sameu in the binary case Taketbe 10s ootnplementof the subtrahend and add i~ to themin~nd ManyooDlputerslULvespeciaJ hardware to perform arithmeticcalculations directly withdecilnal oumbers in 8tDThe~u$etofthecoBlPuter can specify programliled Wtnlctionsto JOdonn the aDtiuJletiP oPmwoowithdeQmal n1UQ~ ~ywithout having to convell them to binary

Binafy codes for decimal digits requirea minimum of four bits per digit Many different codes can be formulated by~gjng four bits into IQ distinct combinations BP) and three other representative codes are shown in Table L5 Each code uses only 10 out ofa pOssible middot16 bit combinations that can be arranged with four bits The other six Unused cOmbinations have no meaning amt should be avoided BCD and the 2421 code are examplesofweigbted codes In a weigbtedcodeeach bit position

juBsigned a weighting f~in~awaythat eaehdigitcanbe ev~by 8dding the wei~ oran the lsin thecoded combination The BCD code has weights of8 42 and I which cotteshy

spondiothe powe1Of-two valuesofeaCh bitTbebitasSignmeatOll0 for example is interpreted by the weights to represent dedma16beCause 8 X 0 +4xt +2 Xl +IX 0 6Thebit combination 1101 when weighted by the ~ve digits 2421 gives themiddotdeCimal equivalent of 2 X I +4 gtlt I + 2 KO + 1 X 1 = 7 Note that some digits cantle coded in lw9 possib)e

ways in the 2421Q)(feFOr inke decimal 4 can be asSigned to bitCombinadon 0100 or 1010 since botbcOmbinatibns add upto a totalweight of4

middot1$ Fou Dlf(et Blnqry Code$ for thtJledmol DIgits

~ IICD DIgIt sal MZt Exeet) 8 4 -~1

0 1

000() middotmiddotmiddot0000 001)1 0001

oem 0100

0000 0111

2 0010 0010 0101 0110 3 0011 OQU 0110 0101

4 0100 0100 0111 oroo 5 0101 lOll 1000 1011 6 OlIO middot1100 1001 1010 7 middot0111 1101 1010 J001 8 1000 IUOmiddot 1011 1000 9 1001 11U 1100 1111

1010 oloi 0000 0001 Uaused IOU 0110 middotOOOl 0010 bit 1100 0111 0010 0011 combishynations

nOl 1110

lOW 1001

HOI 1110

1100 1101

1111 IOU) 1111 1110

22 ChaptfrliDfgltalSystemsaod Btoary Numbers

I1te 2421 rind the

e~l3~es are exampks Of self-complementing codes Such codes have~propertyjbatthe9s~plement ofa deCimal nfunberigobtairted directly by chang-

ing 1$ to O~$ finO tYSCfb1 sie~bycomple~mmgeaCh bit in the pattem)For example decshyimat3~Sis re~ fu tbeexcess3code as 01101100 1000 The 9s compl~ntof 604 isrepRse~l00liOOllelliwbich isobiainc(himply by complementing each bit of the

code (as with the 1 s coinpl~ofbin~rillDlbers)middot Theexcess~3code has been used in some oldel coritputers because of its selfcpmplement~

ing property Excess-3 is an unweighted code inwhich each codedcombinationis obtained-fJQm the corresPonQing bin3ryvalueplus 3 Note that the BCD code is1~ self-complementing TheS 4 ~~ Icode isan example of assigning both positive and negative weights to ~ decimalcodeInthis case the bit combiDation 0110isin~reted as oecimal2 and is calcu-

latedfrom8XO+4X 1 + (2) X 1 + (1XO=2 ~

Cra Code _ _ J

l1te output data QfmaJlfpbYsicaimiddot $)ShmlS are quantities that are continuous These data bemiddottonverted~digiWforuitJefore they art applied toaliigital system Contfuuous or ~nisCOIl~middotUitodigitalfonn bymeans of an rumlog~digitalConverter It is times ~~ent tousethe Gray code slown inTable 16torepresehtdigiuU data that have oon~ fMn8D8l08 dasaTheadvantage of th( Gray cOOeover thesllaigbt binary nIl11l1hPt~

~lt~thatoWY~ hit in the codegroup changeSin going from one number to the For examplcentbullin-goingfrom 1 to 8dleGray code cblngesfrom 0100 to 1100Only the fust changesfromOto l~the odter~ I)its mnaintbesame By contrast With binary numbers change from 7 to 8wrube from 0111 to lOOOwhich causes allfciur bits to change valUes

TabielAi GtPyCode

01 Decl COde Equivalent

~ 0000 0001 0011 OOlG 011Q Olll OlO 0100 1100 11m 1111 1110 lOlQ 1011

lOOt i

1000

o 1 ~ 3

4 5 6 7 8 9

10 11

12 13 14 15

SectIOnl7 BlnarYCod~s 23

The Gray code is used in applications in which the normal sequenceOrbiruuy rium~may produce an error orambiguitymiddot during themiddot transitionfrom ODeDWDber to the next If binary numbersareusec1 acbange forexaJIlple nom 0111 to 1000 may produce anintermediateershyroneous number 1001 if the value ofthe rigbtmost bit takes longer to -change than domiddotthe valshyues of the other three bits The Graycode elimb1ates this problem since only one bit changes its valve dUrlng aily transition be~een two numbers I

Atypical appli-cation ofmiddotthe Gray code is the representation of analog data by a Continu ous change in the angUlar position of a shaft The sQaftmiddot is partitioned into segments ana each segment is assigned a number If adJacent segments are made to correspond with the Qray-Codesequence ambiguity is eliminated between the angle of thesbaft and the value encoded by the sensor

Character Code

Many applications of digital computers require the handling not only ofnumberS but also of other characterS or symbols such as the letters of the alphabet For mstancean insurance comshypany with thousands of policyholders will use a computeX to process its files To represent the names and other pertinent information it is necessary to fonnulate bull binary code for the letshyters ofthe alphabet In additiQt1 the same binary qode must represent numerals and special Characters (such as $) An a1phanumeric character setis a set ofeiements that inclUdes the 10 decimal digits the 26leuersofthealp1iabe and a nutnbeof special~S~ a set conshytains between 36~d 64 elements ifonIy capital letters areincltided or between 64 and 128 e1eJDents ifboth uppercasemiddot and lowercllle etters are inclUded In the first case we need a bi- nary code ofsix bits and in the second we need a binary cooeO(seVM bits

The standaM binary code for the alphanumeric char8cters is the American Stahdard Code for Information InterCbange (A~n) which uses seven bitS to code 128 characters asshoWn in Table 17 The seven bitsof the code are desipted by b~through h With h the mostsigshynificant bit ~e leUer A for example is represented inASCn as l(l()()()Ol (column l00~tOw 0001) The Ascn ()()de also contains 94 graphic characters that can be printed and 34 nonshyprinting characters used for variQUS control functions The graphic characters consist of the 26 uppercase letters (A through Z) the 26 lowercase letters (a through z) the 10 numerals (0 through 9) and 32 special printable characters suchaS andS

The 34 control characters are designated in the ASCTItable With abbreviated nalne8 They are listed again below the table with their functional names The control characters are used fQr routing data and arranging the printed text into a prescribed format~ There are three types of control characters format effectors information separatOrs andcommumc~on-COnlrpl char~ IlCters Format effectors are characters that control the layout ofprinting They inciude the fashymiliar word pr6cessorand typewriter controlssucb 8$ bac~pace (BS) horizontal tabulation (HT) and carriage return (CR) Information separators are used to separatetbe data into divi~ sions such as paragraphs and pages Theyinclude characters such as ~ordseparator (RS)and file separator (FS)The cODlIDunication-control characters are uSefulduriDgthe transmission of text between remote tenninals EXllll1plesof conlmunicatiOn(ODtiol~ are STX (start oftext)-and ETX (end of text) whicb are used toframe a text mesaagetnQlSlnitted through telephone wires

24 Chap~er 1 Diglt8l Systems and Binary Numbers

rblel7 Amerkcm5tandard Code for Information (nterclHlnge(ASCII)

b~jbzb 000 001 010 on 100 101 no 111

0000 NUL )jLP SP () p P 0001 SOH OC1 1 A Q a q

R0010 STX OC2 2 B b r 0011 ETX DC3 3 C S Ii S

0100 EDT 0C4 $ 4 D~ T d t 0101 ENQ NAK 5 E iU e u OUO ACK SYN amp 6 F V f v 0111 BEL ETB 7 0 W g w 1000 B8 CAN ( S H K h x 1001 HT EM ) 9 I Y Y 1010 LF SU~ 1 Z j z lOll VT ESC + 1lt r k UOO FF PS lt L I I 1101 Cit OS == - M 1 m 1110 SO R~ N 1 n shy

-0PIt st US f 1 0 0 DEL

r- Control characten

NUL NlI]l DlE Data-inkescape SOH Start of hea~ng DC1 Device cOntroll STX Start of text DC2 DevIce io~1lOi2 ETX End (Jftext i DC3 Device corUlri1 3 OOT End oftraIlsmission ~4 DeVicecoQtrol4

ENQ ampqwry NAK Negativeackilowledge ACK

Acknowledge SVN Sync~nous idle

Btl Bell ETB End-of-tmnsnussionblOck sS Backspace CAN CanCel HT Horizontal tab EM End of mediUrlt LF Lintifeed SUB Substitute VT Vertical tab ESC escape FF form feed FS File separator CR Carriigeretum GS Group separator SO shift Ollt RS Reoord sepuator SI Shlftin US Unit separator SF S~e DEL Delete

ASCII is a seven-bit codebutrnostcompUters manipulate anejght-bit quantity asa unit called a byte Therefore ASCII characters most often are stored ~e per byte The

I biti~sometimesused forotlef purposes depending ontheapplicatio~lFor example printetS recognize eightmiddotbit AScn chaiacterS with themost sigoificaot bit ~twO An atkJlitlo

Section 18 Binary Storage and Registers 2S

128 eight-bit characters with the most significant bit set tol are used for other symbols such as the Greek alpbabet or italic tyIe font

Error-Dtectlng Code

To detect errors in data communication and processing aneigbth bit is sometimes added to the ASCll cbaracter to indicate its Panty Aparitybit is an extra hit included with a message to make the total num~ of ls either even or odd Consider the fo119wing two cbaracters and their even andodd parity

With even parity With odd parity Ascn A = 1000061 01000001 11000001 ASCI( T == 101deg100 11010100 01010100

1

- Ineacb casewe insert an extra bit in the leftmost position of the code to produce an even number of 1 s intQe cbaraeter for even parity or an odd number of 1 s in the character for odd parity In generlll one or tbe oth~r parity i~ adopted with even parity being more common

The parity biqsbelpful in detecting errors during the transmission ofinformation from one location to another nisfuJictiOD is bandIed by generating an even parity bit at the sending end for ~h character The eight-bit characters that include parity bits are transmitted to their desshytination The parity ofeachebaracter is thetichecked at the receiving~nd If the parity of the received cbaracter is Dot even then at1east on~bit has changed value dUring the trmlsmission This method detects one three or any odd combination of errors in each character tb8t is transshymitted An even combination oferrors however goes undetected and additioDaterror detic- shytion codes may be needed to take care of that possibility

What is done after an errQlis detected depends on the partieu~ application One possishybilityis to request retransrois~ion of the message on the assump~on that tbeenigtr was ranshyd()m andwill not occur again Thus if thereeeiverdetects a parityerrorit sends bai~ the ASCII NAK (negative acknowledge) control cnaracter consisting ofail even-parity eight bits lOOlOl01H no error is detectedthe ~iversends back anACK (aCkno~ledge) conshytrol character namely 0000011 O The sending end will respond middotto an NAK by tranSmitting the message again until the correct panty is received Ifmiddot after a number of attempts the transmission is still in error a message can be sent to the Operatai to check for malfunctions in the transmission path

BINARY STORAGE ANORECiISTEIlS

The binary infonnation inadigitalcomputermust have a physical e~stencein some medium for storing individual bits A binary cell is a device that possesses two stable sttes and is cashypable of storing pne bit (0 or 1) oflnfotlllation The input to tbe cell receives exciJation sigshynals that set it to one of the two states The output of the cell isa pbysicalquantity that distinguishes between the two states The irtformationstored in Ii cell is 1when the cell is in one stable state and degwhen the Cell is in the other stable state

26middot Chapter 1 Digital Systems and BtnaryNumbers

Registers

A register is a group of binary cells A register with n cells can store any discrete quantity of middot information thatcontains n bits The state ofa registeris an n-tuple ofls middotand Os with each bit designating the state of one cell in the register The C()ntent ofaregister is a function of the int~rpretation given to tbeinformation stored in it Consider fQf ex~ple a 16-bitregister with the following binary content

11 00001111001001

middot Aregjs~ with 16 cells can be in one of 216 possible statesIf one asstimesthat the content cif the register represents a binaryinteger then the register can store any binarydumber from Oto 216 - 1 For the patticularexample shown the content ofthe register is the binary equivshyalent(lftbe decimal number 50121 If one assumes instead that the register stores alpbanushy

middot meric characters of an eight-bit cooe then the content of the register is any two meaningful characters For tht ASCII code with anevenplirityplaced in the eighth most significant bit position the register contains thetwo charactersC (the lefunosteightbits) and I (the rigbt~ most eight bits) If however one in~rprets the content of the register to be four decimal dig- its represented by a four-bitcode tnenthe content of the register is a four-digit decimal number In theexcess-3 code the register holqs the decimal nutriber 9096 The content of the registe~is meaningless in BCD becau~e the bit combinatiOn ltob is 110t assfgned to any decshyimal digit From this example it is clear that a register can store discrete elements of inforshymation and that the same bit configuration Inay beinterpreted dlffe(ently for different types of data

tmiddotmiddotReglsterTrail Adigitalsystenlis characteriZed by its registers and the components thatpetfolin data proshy~ssingIIl digital sy~tems a rcentgister tra1lsfer operation is abasi operation that consists of

middot a transftr of hiJWy hUormation from one ~t of registers into ano$er set of registers transfer may be dir~ctfr9m one regist~r toanlt)ther or may pass througb datamiddotprocessing circuits to petformaD operation Figure L 1 illustratel the transfer of iidOrnuttion among regshyisters anddemonstratespictorlallY [the tr8ll~~ ofbinaryinformation from akeyboard a register in the memQryullit Thehlputunit~s assumed to have a keyboard1 control cuit and aninput register Each time a key is strock the control circuit enters an ImnV$_

lent eight-bit alphanumeric character coqe into the input register We shall assume that code used is the ASCII code with an odd-parity bit The information from the input regisshyter is transferred into the eight-least significant cells Qf a proeessOr register After transfer theinpui register is cleared to enable the control to insert a new eight-bit when the keyboard is struck again Each eight-bit character transferred to the pro1c4ess(raquo register is preceded by a shift of the previous character to the next eight cens on its left~

middot a transfer -of four characters is completed the processor registeris full and its contents transferred into a memory register The content stored in die memOry register shown in Figl came from the transfer of the characters J 0 H an~ N aftet the four ap)lroJ)riatt keys were struck

Section 18 Binary Storage and Registers 27

FIGURE 11 Transfer of information among registers

To process discrete quantities of infoiniatiori in binary form a computer m~st be promiddot vided with devices that hold the (lata to be processed and with circuit elements that manipmiddot ulate individual bits of irifonnation The device most commonly used for holding data is a register Binary variables~ manipulated by means of digital logic circuits Figure 12 il~ luslrates the process of adding two l()bit binary iUlmbers Themeniory unit which no[shy

mally consists of millions of registers is shown with only three ofits registers Thepait of the processor unit showncoDsistsmiddotofthree registers-RI R2 and R3~getherwith digital logic circuits that manipulate the bits of RI and R2 and transfer into R3 a binary number equal to their arithmetic sum Memory registers store information and are incapable of pr0shy

cessing the two operands However th~ information stored in meDij)iybanbetransferred to ~ processor registers and the resUlts obtainedin processor tegisters can be transferred back into ame~ry register for storage Untill)ecded again The diagram ~wsthe90ntents of two

operands transferred from twoJDemoryregisters into RI imd R2 The digital logic circuits produce the sum which is transfened to register R3 The contents of R3 can now be 1riUlsshyferredback to one of thetnemory registers

The last two examples demonstrated the infonncion-flow capabilitieSofa digital system in a simple manner Themiddot registets of the ~ystem are the basic ele~ents for Noring and holding the binary information~igitallogic circuits process the binary ihfonaation stored in the

28 Chapter 1 DigIt bullbull Systems and Binary Numbers

Sum

FIGURE 12 Eumple of blnarylnfonn~t1on processing

registers Digitallogiccirctiits and registers are covered InChQpteB 2 throQgh 6 The metlilOlY unit is ~xPIained ill 9aptet 7 Th~ descriptton of register opetJtions at the register level and the design of digital systems are covexed in Chapter 8

19 BINARY LOGIC

Binary logic deals with variables th~ take on two discrete valueund withoperations that sumelogicalmeaning~ The two val~s the variableussume may be called~ydifferent (true andalse yel and no etc) but for ourp1llpQSe it is cpqVenienttotbink in terms of and assign the values llUld O The binary logic intr0ducedin this section is equivalent to algebra oalledBoolean algebra The fannal presentation ofBoolean algebra is covered in detail in Chapter 2 The purpose ofthis seCtion is to introduce Boo algebra ina matmerandlate it to digitallogiccircuits andmiddotbinarYsignalsmiddot

Section 19 Sinary logic 29 ~

Itkltn of IInary logic

Binarylogic consists of binary v~les and a set of logica1middotoperatiQDS The variables are desigshy ~by lettell of thCalplWlet~such asA B C x yz etc with eaCh variable baving two and oniy

two distinct posSible valueS 1and O There are three basic logical operations AND ORand NOT

1 AN]) This ~peration is represented by adotorby the absence ~f an oPerator For example x bull y =z or xy = zis~ x ANDy is equalto z~ThelogicaloperationAND is interpreted to mean that z == 1 ifand only ift~ land y = 1 otherwise z = O (Reme~r that x y andzare binary v8riablesand canmiddotbe equal either to 1 or Omiddotand nothing eise)middot

2 OR This operation IS represented by a plus sign For example x + y =z is read x OR y is equal to z meaning that z 1 if x = iorif y = lorifbothx= 1 and y = 1 If bqth X - 0 andY Omeo z= O

3bull NOT This operation is repf6sented by a prime (sometimes by an overbar) For ~xample x =Z (or~ =z) is read notdsequalto 1 meiming that z iswkatx isnot In other

words ifx = 1 then z == 0 but if x == 0 tnenz = L TheNOT operationisals(1 reshyferred tolls the complement operation since it changes ~ 1 toOand a O to 1

bull bull lt Binary logic resembles binary arithmetic and themiddot9peratioos ANDahd OR have similarishy

ties to multiplication and addition respectively In fac~ the symbols used for AND and OR are the same as those used for multiplication and addition However binary lOgic should not be conshyfused withbinaryarithIrietic One should realize thatan arithmetic variable designates a numshyber that may consist of many digits A logicmiddot variable is always either 1 or O For example in binary arithmetic we have I +1 =10(read~one plus ()fie is equal to 2) whereas in binary logicwe have 1 + 1 1 (read one OR onds equal to one)

For each combination of the values oix and y bullthere isa value of ~ $pecifiedby the definishytion of the logical operation D~linitiops of logical~perations maybe listed in a compacHorm called truth tables A truth table is atable of anpbssible combinations ofthe variables $howshying the relation between the values that the variables may take and the resultof the operation The truth tables for th~ operations ANDand OR with variables x and y are obtained by lis~ng

all possible values that the variables may have when combined in pairs bull For each combination the resUlt of die operation 18 theillistedin a separate row The truth tables for ANDORand

NOT are given in Table La These tables clearly demonstrate the definitionf the operatibns

Table 18 Truth TcibJts of Logical Operations

AND OR NOT

x y xmiddoty x y x+y

0 0 0 0 0 0 1 0 0 1

10

1 0 d 1 0 1 I 1 1 1 1 1

bull~lt~m

30 Chapter 1

Logk Gates

Digital Systems and Binary Numbers

Logic gates are electronic cirellit that operate on ~

variable

or mpre mput tignals to produce an output signal Electrical signals sUch as voltages orrutrents exist as analog signals having values over a given taDgebull saYOt03 V but in a digital system are interpreted to be either of two recognizable values 0 or 1 Voltage~opetated logic Circuits respond to two separate voltshyage levels that represent a binary varjable equal to logic I bt logic O For example a partic- ular digital system may define 10gicOas a signal equal to 0 volts lind logic 1 asa signal equal to 3 volts In practice each voltage levelhiS an acceptable rangeas shown in Fig 13

The input te~nals of digital cikuits accePt binary signals within the allowable range and respond at the output terininals with binary signals that fall within the specified range The intermediate region between the aJl()wed regions is crossed only during aState transition Any desired information for computing or control can be operated tm by passing binary signals through variQUS combinatioDsof logic gates with each signal represebting a particular binary

The graphic symbols used to deSignate themiddotthree types of gates are Mown in Fig 14 The

gates are blocks of hardware that prooocc tbeequivalent of1ogic~1 orlogic() output signals

Volts

- FGURl13

x

y

Exampleof binary slgnaJs

Signal ratlge for logieO

(a)~omiddotinput AND gate

FIGURE 14 SymbOls for digital logic circuits

(c)NOT gate or invert~

Problems 31

x-lU 1 11 P 0

y 0 0 11 1 ~

ANDxy 0 0 rTl 00

ORX+Y~ NOT x 11 0 0 I 1 1

FIGURE 15 Input-output 5Igals for gates

FIGURE 1

A B C

Gates WIth mlltlple JnpUU

A B C lJ

~

if inPllt logic ~ts are satisfied Theinput signals xaDd y intheNDaadQR gates may exist in ~ oHow-possible states 00 10 11 or 01 Il1ese ibpu~ampignals_ shown inFig lStoshygetber with the corresponding output signal foreach PfCThI~tiaiug~iDustrate the reshysponse ofeaclt gate to the four input signal~The~llisofthetiminadiagram represents time and the vertical axis sbo~~~~ it cbapg~botwcen~possible voltshy

age levels The low level represents logic O tJte high level l1lteAND _ responds With a logic ~ ~tput sipl wh~ both input ~~)e 1middot1~ lIieOR S-~with a logic 1 outpUt signal ifanylnput sigrudis lOgic 1 TheNOTgateis~~ to BUll invedet The reason for~nameis~t froJn the signalmsponae inmiddottbe timitt8 diagramwhicbsbows that theoUtputsignal inverts the logic sense of tbeiDpUtsigll8l

AND and OR gates may bavei)lQte tbantwQinputs M AND8_~itti ~input$andan OR gate with foU) inputs are shown in Fig 16 The three-inPllt AND gate responds With logic 1 output if all tbreeinputs arelogic 11jleoutputproduces lOgic Oifanymput is logic O-The

four-input OR gate responds withlogic 1 ifany input is logic 1 its clu1ptltllCCoines logic oonly when all inputs are logic O

Answers to prvblems marked with middotappearaHbe ClOd ofthe ~

11 lJltthe octal and beXadecimalliurilbers trom16ui 32UdngA B1l1ld C forthebst~ digits Usttbe numbers from 8 to 28 in base13 bull

I

12t What is the exact D1Jllbcr of bytes in a system that contains lta) 32Kbytoe (b)64M ~and (e) 640 byte$ middot7 t

32 Chapter 1 Digital Systemsand Binary Numbers

13 Convert the following nu~bers with the indicated bases to decimal (a) (4310)s (b) (198hz (c) (735)8 (d) (525)6

14 Whllt is the largest binary number that can be expressed with 14 bits WhlIt are the equivaleDt ~~ iinal and hexadecimal numbei-s

--

15 Detemrine the base of thl1 numbers in each case for the following operatio~ to be correct (a) 142 = 5 (b) 5414 = 13 (C) 24+ 17 == 40

16 The solution$to the q~cequation xl - Ux +22 oare l1 3 arid x =6 What is the base of the numbers

17 Convertthehexadecimal ntmIher 68BE to bitiary and then convert it ~mbinary to octal

18 I Convert the decirpal number 431 to binary in tWo ways (a) Convertd~y to binary (b) conshyvert first to hexadecinla1 and then from ~decimalwbinary Which method is faster

19 amppress the following nqrnbersin decinud (a) IQ11O0101)z (b) (l65his (c)(2624)8 (d) (FAFA) 16

(e) (10101010)2

110 Convert the following binary numbers tobexadeoimal and todecitnal (a) UOOlO (b) 110010 Explain why the deCimal answer in (b)is 4 times that in (a)

111 Perform the followingdiviskmin binary 11 Ion + l()t

112 Add IlniImultiply tfle following numberswiihout converting them to decimal (a) Binary nuniberilOll aiIdlOh (b) He~uumbers 2E aDd 34

1~)( Do thefoHowing con~ersionproblems (a) CorivertCiecimal2731S to binary (b) CakUlate the binary eqUivalent (f 213 outto eight pl~Then Convert from binary to

imalHowgJose istbe result to 2131 (c) Convert the binary resukin (b) into hexad~ lb~oonvert ~result to decimal Is answer tbesame

114 Obtain the is 8nd 2s complementsofthe foUowing binaryDumbcentrs (aj l)()()(J()OO (b) OOOOOOOO (c) 11011010 (d)01l10110 (e) 10000101 (0 11111111

115 Find the 9s and the 10s complement of the following detimal numbers (a) 52734630 (b) 63325600 (c) 25000009 (d) 00000000

116 (a) Find the 16s complement of B2FA (b) Convert B2FA to binary (c) Find the 2scomplement ofthe resultin (b) (d) Convert the answer in (c)to hex~malandco~ with ihe an~wer in (a)

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 6: Chapter 01 - Mano

6 Chapter 1 DigitatSy$tems and BInary Numbers

111411

Convert deciIIla14 r to binary First 41 is divided by 2 to live an integer quotient of 20 and a remainder of i Then thequoiientisagam divided by 2 to give anewquotient and remainder Theproeess is ~ntinued untilth~ integer quotient becomes O The Cf)eJJicients of the desired binary number are obtained fJOm the remainders as follows

Ioteger Quotient Remainder Coeflldent

4112= 20 + ah= 1 2012 10 + 0 at= 0

1012 = 5 + 0 a2= 0

512 = 2 + 1 a3 = 11 Z2 1 0+ G4=O

I112= 0 + 2 as =1 lt

Therefore the aDsWeris(41 )u)= (llsa4~3f12alaoh =(IOlOOlh The arithmetic proCess can be manipUlated moreconvemently as follOws

Integer 41

20

10

5 2 1

o

Relnamder

1

o o 1

o J~

1 101001 ==answer

Con~ersi~n from decimalintegeJS to lQ1ybase-r Sstem i~ similar totljis example except that division is done by r iil$teadof2

1I1t4191I Convert decimall5lto oCtal The required baSe r is aFirst 153 is divi~ by 8 tQl1ve anin- tegerquotient of 19 and a remainder of lThen 19 is divided by 8 to give an ~tegerqlotient

of 2 anli a remainder of 3 tFiny 2 is divided by 8to give aquotientof 0 and a remainder of 2 lbisproeess can be conveniently manipulatecfas follows

153 19 J

i 3 o 2= (23J)s

7 Section13middot Number-Base Conversions

lhe(OllVelSiOllQCdecimalfrmtonto binary js accompllshedby a ~od similar to tbai uscd for ~~veri multiplication is used instead of division and integers instead of

rem~ are acc~aQd Agafu~ the method is best explajned by example

bull Co~vert (06875hotobmaryFirst 06875 i~ multiplied by2 to give an integer and ajraction nen the new fraction is multiplied by 2 to give a new integer and a newfraction The process is continued until the fraction ~om~ 0 or until the nUJ1lber of digits have sufficient accuracy necoefficients oftbebinary nUlllberare ~btaipedfrolIl-~~ integers asfQUows

lnteger Fraction middotCoemclent gt~fn5 Jlt~~ i + 03750 a-I = 1

()37SO f(2 0 + 07500 g-2= 0

07500X2= 1 + 05000 D-3 - 1-

0-5000 X 2 == I + 00000 a~=l

J

) -

Thereforethe at)Swer is (O6875ho= (OD-lazQ-3D-4h= 010l1hshyTo convert adtcimal fractl9D to a number expressed in base 1 a-similar procedure isused HQwever multiPlication i~ by 1 instead all and the coefficlentsfound from the integers may

range iti value from 0 to r- 1 lI)stead of 0 and 1 bull bull bull - - -_ t lt~ 1

bull

O513X 8 = 4104

0104 X 8 = 0832 0832 X8 6656

0656 X 8 == 5248

0248 X 8 = 1984

0984 x 8= 7872

The an~wer to seven significant figures is obtained from the integer part onhe products

(OsP)IO= (0406517)8

middot8 Chapter 1 Digital Systems iilnd Binary Numbers

Ibo oonversion ofdecimalnumbers withbotMnteger and ftattionparts is done by con- vertingthe integer and the fraction separately and ihencombinihgthe two answers Using the re$Ults ofExamples 11 and l~ weobtain

(416875h~ (lOI001l011h

From Examples 12 and 14e have

(1535130 (2314tl6517)s

14 OCTAL AND HEXADECIMAL NUMBERS

The conversion frOm and to binary octal and bexadecimal plays an important role in digital computers Since 23 =8 and 24 = 16 each octal digit corresponds to thref binary digits and bull each hexadecimal digit corresponds to foUr binary digits The first 16 numbers in the decimal binary oct8r andhex~ecimalnumber systems are listed in Table 1-2

The comersion fm~ binary tooctal is easilyacltooiplishedby partitio~ng the binary num ber into groups oftbree digits each starting ti()n1 the binary plmt and proceeding to the left

I and to the right ~correspo~ octal digit is then assigned to each group The following example illustrates the proeedure ~

(10 110 001 101 011 11~ 100 000 lloh = (261537406)8 2 6 1 ~ 3 7 4 0 6

T_lel2 Numbers with Different-Baus

DecImal IY Octal Hexadecimal middot(base 10) (base 2) (b) (16)

i

00 0000 00 p 01 0001 01 1 02 0010 02 2 03 0011 03 3 04 0100 04 4 0 0101 OS 5 06 0110 06 6 07 0111 07 7

08 1000 10 8 09 1001 11 9 10 1010 12 A 11 1011 13 B 12 1100 14 C 13 1101 IS D 14 1110 16 bull

Ej

IS 1111 11 F r i

9 section 1S Complements

Conversion from binary to heudeciInal is similar except thatthe binary nutriber is divided into groups ofourdigits

(10 1100 0110 1011 1111 0010h = (2C6BJ2) 16

2 C 6 B P 2

The comsponding heX~ima1(o~ octal)~digit fOr each group of binary digits is easily reshymembeled from the values listed in Table 12

Conversion from octal or hexadeciInal to Jlinary is dOne by reversing the preceding proceshy(luremiddot Each octal digit is converted to its tbi-ee-digit binary equivalent Similarlyeach hexashydecimal digit is convertedioits four~digitbinaryequivalent1he procedure is illustrated in the following examples

(673124)8= (110 6

III 011 7 3

001

010 2

l00h 4

and

(306Dh6 = (OOlf 0000030shy

110 6

~101h D

Binary numbers are difficUlt to work with because they require three or fout times as many digits as their decimal equivaltmts Por exaniple the binary number 111111111111middotis equivalent to decimal409S Howeverdigital computers use biIUuy11UIhbers and itis soIIJet4nes necessary for the human operator or user to oonununicatedirectly With the machine by means of such num bers One scheme that retainsthebinary~ystem in the cotnputer but reduceS the number of digshyits the human must cOnsider utilizes the relationslripbetyeen the binary Ilumber system and the ~ or hexadeciinal system By this method the Ql1DaIlthinksin tenns ofQCtal ornexadecimal nurnbers and performs the required conversion by inspection when direct communication with the machine is necessary Thus thebinary number 111111111111 has 12 digits ~d isexpressed iIi octal ~ 7777 (4 digits) or in hexadecimal as FFF (3digits) During communication between people(about binary numbers in the coJlllQter)the octal or hexadecimal representation is more desirable because it can be expressed more compactly with a third or a quarter of the number of digits reqUired for the eqwvalent binary number Thusmpstcomputer manuals use either octal laquohexadecimal numbers to specify binaryqwintiti~ The choice between diem is arbitrary although hexadecimal tends to win out since it can represent a byte with two digits

PlEM ENTS

Complements are used in digital cOmputers to simplifydle subtraction operation and for logshyical manipulation Simplifying operations leads to simpler less expensive circuil$ to implement the operations There are two types of complements for each baSe-r system the radix comshyplement andthe diminished raclix cOtllplement Themiddotflrst is referred to as the rts complement and the second as the (r - middot1)scomplement When the value of the base r is substituted~ the name the twotypesare refefted to as the 2s complement and 1 scomplement fot binary numshy~rs and the lOscompl~ent and 9s complement fqrdecimal numbers

10 Chapt~rl Digital Systems and Binary Numbers

D~I~llhed Radix Complame~middot Gi~en a number N in base r haYing n digits the (r - 1)scomplement~f N is defined as

(rll - 1) ~NFotdecimainumbersr -= Wandr -1 9sothe9scomplementofNis (10 - 1) - N IIi this c~ 10 represents a number that consists of a single 1 followed by nOs 10 - lisartumberrepresentedbyn9sFOrexampleifn 4wehavel04 = 10000 and 104 - 1 = 9999 It follows that the9s complement ofa decimaJnumber is obtained by subtracting each digit from 9 Here are some nwnericalexamples

The 9s complement of 54670(Ms929999~ 546700 453299 bull - I

The 9scothplement of012398is999999~0l2398 =987601

For binary pumbers r =2 and r - l~ 1 sothe 1s complementofNis(Z - 1) - N Again 211 is represented by a binaty number thatconsistsofa 1followed by Ii0s 211 - 1 is abinary number represented by ~1s~FOr example if 11= 4 we have z4 = (10000)zand 24 - 1 = (1111h Thus the ls complement of a binary number is obtained by sUbtractiDg

each dig~t from 1 However when subtracting binary digits from 1 we can have either I -0= lor1 - 1 = 0 which causestbe bit to change from Oto 1 0( from 1 to 0 respec- tively Theretore the ls complement of a binary number isfonnedby changing 1s to Osand Osto 1s The f9llowillg are somenumqical ex~esI

~

The ls Complement of 1011000 isotOOiu

The 1scompieme~t oHlIOUOI is 10 tOOlO

The (r-l) s compleme~ ofoctal or b~xadechnalnumbers i~6btained by subtracting eaeh digit from 70rF (diicimallS) respectively~

Radl~ C~mplement

The s complement of an n~digit number N in baserisdefinedasrmiddot Nfot N i 0 and as ofor N = O~ Comparing with the (r- l)s ~entwe note that ~rs complement is obtained by adding Ito the (r - l)scomplement smcer - N= HA-- 1) - N] L lhus the lOscomplementof deein1al2389 is 76lO +1 = 7611 and is otltamed by adding 1 to the 9scomplernent value The 2s oomplementofbinary 1011oois 010011 1 =010100 and isobtained by adding 1 to the ls-complement value

Since 10 is a number represented by a 1 followed by n0s1011 N Whicb is the10S com~

plementof N can be fonn~d also by leaving allieasl sigtrlficani Os Unchanged the first nonurO least significant digit from 10 and SUbr8Cting all higher significant

from9 ThUs

the 10s complement of 012398js987602

and

11 Sectlon middot15middot Complements

The 10s complement ofthefustnumber isobtaineltibysublriiCtingSfrom lOin the least sig~ nificant position and subtracting all other digits from 9~ The 10s complement of the second number is obtained by leaving the to least significant Os unchanged subtracting 7 from 10 and subtracting the other three digits from 9

Similarly the 2s complement ~be fonned by leaving 1ll11east significant Os and tbe first 1 unchanged and replacing I swith Os and Os with ls in allother hi~r signifIcJUlt digits For example

the 2s cORlplement of 1101100 is 0010100

and

the 2scomplement ofOllOllHs 1001001 _ - r

The +s complement pf therrrst nJUDber i~ obt4iriedby I~vingthetwo least significant Os and the first 1 unchanged andmiddotlQen replacing ls with Os and Oswith 1~ in the other four most sigmiddot nificant digits The 2s lXgtmplement qf the second number is obtained byleaving the least sigshynificantmiddotl unchanged and (fOmplementing all other digits

In the previous definitions it was assum~dtMt the D~bers did not have a radix pomt1f the original number Noontains a radix point the point should be removed temporarily in order to form the s or(r 1)s complement The radix point is then restored to the c9ll1plementshyednumber in the same relative PositionIlis abo wOrth mentioning thatfhecontplement oftbe complement restoresthe number to its original v41ue To see this rel~tionsbipnOtethat the ts complement of N is n - N so that themiddot complement oft1e complement is n - (n - N) == N and is ltlqual to the original number

Mr8Ctiton wltl1 Complementsmiddot

1le direct metb()jiofsubtraCtion taught in elexnentaty schpOls uses the bottow concept In this QlCth9dwebortowa I from a middothigher significant position when the minuend digit is smaller than the subtrahend digit The tDethod wor~wen when peOple perfonnsubtraction with paper andpeooillIowever when subtlaction is implemented withdigi1al bardw8le the method is less e~citnt than the method that u~s compl~m~ts

The subtraction of two n-digitunSigneq numbers M N in base can be done as fonows I

1 Add the minuend M to the scompleme~t of thesubtramphend N Mathematically M+ (n N) = M N +

2 IfM ~ N ttie sum wiUproduce an end cury 11 which caD be discarded what is left is the resultM N

3 If M lt N the sum does not produce ~tlend carry JUld iseijUattor (N~ Ji) which is the s complement of (N - M) To obtain the answer in a familiar form take the s complement of the sum aruI place a negative sign in frorit

12 Chapter 1 Digital Syst-ems and Binary N~mbers

The following examples illustrate the procedure

plPi1I VsinglOs complement subtract 72532 - ~250

M = 72532

lOs complement of N + 96750 Sum= 169282

Discard end caIry lOS = -100000 Answer = 69282

Note that M bas fiv~ digits andN has only fourdigitsBoth numbers mtast have the same numshyber of digits sowe wrlteN as 03250 Taking the lOscomp~ementofNptOducesa9 in the most significant PositionThe occurrence of the end carry signifies that M ~ N 8ndtlult ~ result is therefore positive

Ulling 10s complement subtract 3250 - 72532 - ~ ~

M = 03250 JOscornplementof N =+27468

Sum= ~0718

There is no end carry Theref()re-theanswer is--(10amp complementof30718) == -69282 Note thatsince 3250 lt n532~the result is negative Becauwe are dealing with WUiigned

numbers there is really no way to get BnunSigned result for this case When subtracting complements we reoogilize the negltive answer from the~sence of the end carry and complemented result When workingwith paper and pencil we c8nchlnp the aDswer

signed negative number in oider to putH inafamiliar form Subtraction with complements is done with binary numbers in a similar manner uing

procedure outlined previously

EXAMPLE 17

Given the two binary numbersX = 1010100 and Y =1000011 performtbe $UbiDctiG (8) X - Y arid (b) Y - Xby using 2scomptem~ts -

f

- -

Section 15Complements 13

(a) x = 1010100

2s complement ofY= + -0111101

Sum = middot 10010001 Discard end carry 27 = 10000000

Answ~ X- Y = 0010001

(b) Y == 1000011 2sco~lement of X = + 0101100

Sum= 1101111

There is nQmiddotend carry Therefore the answer is Y ~X= -(2sq)mplement of 1101111) = -0010001 Subtractionof unsigned D1lJllbers ~ also bed()neby means of the (r - 1)s complement Remember that the(r- l)s complement is one lesstharithers complement BeCause of

ibis the result of adding the minue~ to tJte coQlplement of the subtiah~ndPtOductS itsum that is one less than the correct 4ifference when an end carrY oCcurs Removing the end carry and adding 1 to the sum is referred to asan end-around carry

Repeat Example 17 but this time using rs complement

(8) X y = 1010100 - 1000011middot

X= 1010100

rs complementafY= + olfnoo Som = 10010000

End-arOundmiddot~ =- ~ ~ Answermiddot X Y= middot0010001

(b) Y - X = 1000011 - 1010100

Y = 1000011

1s complement ofX = +0101011

Sum = 1101110

There is no end carry TherefOre the answer is y - X = -(1s complement of 1101110) = -0010001

bull Note that the negative resultis ob~ by taltingtbe 1 scomplemeilt of theJWltsince this is the type ofcoDiplementused The procedwewithendaroundoanyis aIs(gt Iijlpliclbleto subshytracting Unsigned deciImdnumQers with 9seomPlement

14 Chapter 1 Digital Systemsand BinayNumbers

16 SIGNED BINARYNUMBER$ ~

Positiveintegers (including zero) CaBbe ep~~ 11$ unstPecl numbers However to repshyresent negative integers we need a notation for negative srn ordinary arithmetic a negshyative number is indicated by a mulUs signmdapOsitiv~Pwtlt)e~ by aplus sign Because of lJardware limitations computers mlstrepresenlev~With~ digitsIt is customary to represent the sign witb a bit placed intheleftmotp6sitiolwfthe number The convention is tltl make the sign bit 0 for positive and 1 for negative

Itis important to realize that botp siped and unsignedtDnary 11UJDbers consist of a strfug of bits when represented in a com~ TQeuser detem1inesWbether the number is signed or unsigned If the binary number is signed then the lefuriostbitreple$ellts thtsign aud the rest of the bits represent the number Ifthebinaryllu~beiis~ tObe unsigned then the left most bit is the most significant bit of the l)uMber Fdre~the~~f bits 01001 can be consideredas 9 (unsigned binary) or as +9 (Sighedbitia1j) ~USJtheteftmostbit is O The

string ofbits 11001 represents the binary ~~v~ento~ ~w~nc~idered as an unsigned number and the binary equivalent of 9whenconsidered1l si~riumPer This is because the Ithal isintbe leftmost positiondesignatesampC nega6ye_~QtherfourJ)its represent bishynary 9 usually tlere is no cotifusionin identifying thebits~the~Qfrepresentation for the number is known in advance ~

The representation of the signed numbers in the lastexainple is referred to as the signed magnitutk coDvention In this ~otati()nthenurnber C4mSiampesOCa mQ~~andil~ymbolH

or -) or a bit (0 or 1) indicating the sign This is the representation ampr~~used in ordinary arithmetic When arithmeti~ operatioBslllieimplerneJltcldin~cOQlPuter hii more convenient to use a different systemrefetred t(gt as the si~cqmptement system~ for repre- senting negative numbers In thissystlm a neg8tielliun~r isjhdic~ted by its cornplc~mc~nt Whereas the signed-magnitude system negates a nlllllher by cbanging its sign me signed-comshyplement system negatesanwnber bytakin$ its~OinPleltleitiSinoepositife numbers always start witbO(plusin tte leftmost pOsition thecompktllint wiilalwaysstart with a 1 indicating a negative number The siped-complemelt system can use olthertbe 1s Or the 2s but the 2s complement is the mos~comtliOfi

As an exampleconsider the number9re~~ed in binary with eight bits + 9 Is sented with a sign bit of Oin the leftri1ostpOsition oIIOv~by the binary (equivalent of 9 which gives ()()()olOOl Note thai all eigbtbits must haYampa v~therefore O~s are inserted folshylowing the sign bitllp to the first 1 Although ~ is only 01K way to tepresent +9 there three different ways to represent 9 with eight ~its

s~gned~magnituderepresentation 10001001

sigried-l s-complement represe~on~ 11110110

signed-2 s-complemerit representatim 1ttltllU

In signedmagnituamp -9 isobwned from +9 by changing the sign bitmtbe leftmost ~iti(ln tromO to L In sigl1ed~ lroomplement 9isobtaidedtf~~tiog all the bits of includinj the sign bit Thesigned-2~sco~re~Qf-9 is obtampDedby ihe 2s complement oftbepOsitivenumberincludingtbesijnbIt

Sectlont6 SIgned8lnary NumberS is

Table 13 Slgtlfd Biliary Humbm

+7 +6

+5 +4 +3 +2 +l +0 0 -I

-2 -3

4 -5 -6 -1 -8

Olll 0110

0101 ( 0100

001l 0010 0001 0000

IIll 1110

nOI noo Ion 1010

1001 1000

OIll Oito eHOl OHIO OOU 0010 0001 0000 1111 1110middot dOl 1100 Ion

lOti 1001 1000

0111 OUO 0101

0100 0011 0010 0001 0000 1000 1001 1010 IOU 1100

1101 1110

lUI

Table 13 lists all possible four-bitsignedbinaryaumbers in the three representations The equivalent decimal number Is also shown for refelenoeNote that the positive n~ in all three representations are identicaland have 0 inthelefmostpcsiticm The signed2sshycompl~mentsystemhaironly onemiddotrepresentation for 0 which is always po$itive The other tw()systetns- mlve either a positive 0 or a negative 0 sometbingnoteDcounteredin ordinary arithmetic Note that all negative numbenhave alin the leftmost bitpositi~ that is the way we distinguish them from the positivenumbers With fout bits we can repreSent 16 binary numbers In the signed-magnitude aDd thelscomplement repre$eDtatipns there are eight positive numbers and eight negative numbers inciUdingtwo zeros In the2s-complement representation there are eight positive numbers includi0a one zerQ and eight negative numberS

The siped-m_gnitude system is used in ordiIlary arithmetic but is awkward when emshyployed in computer arithmetie becauIe of the ~parate bandIinJ bfthesipand the magnitude Therefore the signed-compiement systeni is normallyused The ls ~t imposes some difficulties and is seldom USedJor arithmetic openitiOns It is U$eful aSa lo~ operation since the change of 1 to Obrmiddot() to 1 is equivalent to a logical complement Operation as will be shown in the next c~The discussion~f sigiled binary ariduneti~ that fol10ws deals exshyclusively with the signe4-2soomplt_nt~tatJonQfnegadveilUlilbers hsame proshy

cedurescan beappJied to the sigMdrs-comPlemeD~Iysby incIudiOI tbe~arotmdcarry as is done with unsigned numbers

J6 Chapt~r 1 OlgltalSystlf(ns and Binary Numbels

Arithmetic Addition

The addition of two numbers in the signed-magnitudelYs_foUowsthe rules ofordinaiy arithshymetiC Ifthesi~s arethesam~we addthetwOtt~gni1U~~d ~vetbe sum the CCmmon sign Iftbe signs are diffe~nt we subtract tllcsmaUermagnitude frOtnlthe larF and give the differshyehtethe signof the larger magnitude For example (+25) +( - 37) = ~ (37 - 25) = -12 and is done by subtracung the smaller magnitude 25 from the larger magnitude 37and a~nding the sign of 37 tGtbe result Ibis is a process that requires a corripanson of the signs and magnitudes and then performing eithr additi()n or subtraction The same procedure applieato binary numbers in sigped-magnitude representation~Incontrast the rule for adding numbers in the signed-corppleme~ sy~tem does not require a comparison or su~ traction but only addjtion The procedure is very simple andcanbe stated as follows for binary numbers The 8ddltion oftwo signed binary numberS with negative numbers tepresented in signed- 2sComprement fonn is obtaiIled from theadditlooofthe two numbers includingtheii sign bits

AcentiirrY out oftbe sign-bitposition is diScacded NumerIcal e~aihpledotai1dition follow

+ 6 00000110 - 6 11UI0tO I

+13 00001101

+13 00001101 +19 00010011 + J 0Q900111 + 6 00000110 6 11111010 ~13 11110011 -1~l 11110011 7 illl1001 -19 11101101

I bull bull ~

Note that negative numbers musthil iriitially in 2seompkmentform and that if the swn ~ ~afterthladdit40nis negativeins in2s~p~t fOl1Jl - In each of thefoDrcasestlteoporationperfol1JlC(lis additionwitb the sign bit iilcluded Any catTY o~of~~-bit~onisdisc~ and negative resultsareButomaticallyin 2sshyromplementfoon

In order to obtain acOrrect answer we mustensQre that the result has a sufficient of bits to accommodate the swnlfwestartwith t~on-bltnumbers and tbeswn occupies n + 1bits we say tblltan overflow occurs~Wheri one perfotmStbc ad(JitiOJl with nllllIPTJllVIl

pencil aq overflow is not a preblem because we arcr noflimitecLbythewidth of the page jUst addanothcentr 0 to apositive number or another 1 toa negative number in the mOst cant positi()n to extend thenwnber to n+ 1 bitSand theQ perform addition Overflow is

problem in computers beqiusetbe number ofbi~~ bolla ~befis finite and a result ex~ tI1efinite val~e hy lcatmotbe accommodated

The compJement form of representiQg negativetlQUlbers is unfamiliar to those usedto signed-magnitude system To itetermine th~ value of II negatienumber insiped-2s COlIlpJe

mentit0is~ to CODVerttbe numbcr to apositie ntirit_ ~ place itiDa more formPor ~plethesig~binary number qUl00~ lii~egativebecausothe leftmost

t 1182s c0J8plemen~js~UlwhUhi$~ binaryeqqivalen of +7Wcmiddottherefore nize the Ori~nal ~atiy-eQumber to be equ~ lo-7 1

Sectlonl7 Bh1ary Codes 17

ArIthmetic SubtractIOn

Subtraction of two signed binafy numbers whe~negative numbersare in2s-complement form is simple and can be stilted as follows

Take the 2s complement of the5ubtraltend (including the sign bit) and add it to the minuend (including the sign bit) A cany oU1of thesignbit position is discarded

This prOCedure is adopted because a subtraction operation can be changed to an addition operation if the sign of the subtrahend is changed as is demonstrated by the following relationship

(plusmnA) ~ (-tB) = (plusmnA) + (-B) (plusmnA) - (-B) =plusmnA) + (+B)

But changing a positivetwober toa negative n~ber is eaampily done by taking the 2s compleshy mentof the pQsitive number The reverse is also tiUe~use theCOmPle~n~ of a negative numshyber in complement form produces the equivalent positive number To see this consider the sJlbtr~ction ( 76) -- (13) = +7 In binaIy_ with eight bits this ()peiationis written as (11111010 11110011) The subtracti~ri ischmlged ~ addition by taking the 2s complement ofthe subtrahend (-13) giving (+13) In binaly tbis~ 11 niOlO+ 00001101 = lOOOOOU1 Removing the end~ we obtain the ootrect answer ()()()()() III (+7)

Itisworth noting that binary DUmbersinthe signed-complement system are added and subshy tracted by the same basic addition and suPtraction rules as unsigned numbers Therefore comshyputersneed omy one common hardware circuit tobandle bothtypcs ofaritbtnetic The user or programmer ~ust interpret the reswtIi of $l1ch addition or subtraction differently depending on whether itisassumedtha~the numbe~ are signed ltr tinsigned

j

BINARY CODES

Digitalsystems use signalsthat have two distinct values1Uld circuit elements that havetwostashyble states There is a direct analogy anrong binary iignals binary circuitelements and binary digits A binary number ofndigitsfor example may be represented by n binary circuit eleshyments each baving an output sig~alequivalen1to Oor I Digital systems represent (Uld mashynipUlate not omy binary numbers but alsO many other diScrete elements of information Any discrete element of informatioIidlat is dis1iilct among agroup of quantities can be represented witha binary code (Le a pattern of Os and fmiddots) The codes must be in binary because in todays techIiology omy circuits that represent and manipulate patterns of 0s and ls can be manufactured economically foru~ in computers However it mtistbe realizCd that binary codes merely change the symbols not the meaning ofthe ele~nts of infonbationthat they repshyresent IT we inspect the bits of a computer at random we will find that mostofthe time they represent some tYPe of coded information rath~ than binlUY numbers

AIln-bit binary code is a groopofn hits that assumes up to 211 distinct cOmbinations of ls ~d Os with eacn combination representing one elementof tnt set that is being coded A set

of four elements clab becoded with two lilS with each ~lementassignedoneof thefoUowing bit oombinationsOOO I 10 J 1 A set of eight elements requiies a three-bit code 00 a set of

18 Chapter 1 Digital Systems and Binary Numbers

J6 elements requires a fourmiddotbit code The bit combination of ann~bit code is determined the count in binuy from 0 to 21t - t Each element must be assigned a unique binuy bit binationand no two elemerits cm havetbtsamevalueothenvisethe code assignment be ambigUous

Although the minimum nqrnber of 1lits required to code 21t distiItct quantities is nthere nomaximwn numbe( of bit that may he used for a binuy code For example the 10 digits can be coded with 10 bits and each decimal digit can be assigned a bit combination nine OSmid a 1 In this pamcularbinarycode the digit6 is assigned the bit )UllIUlauuu0001000000

BCDcode

Although the binary number systemis die ~ost natural system for a computer most people more accustomed to the d~imal system One way to resolve this difference is to convert

inlal nUmbers to binary perform all arithmetic calculations in binary and then convert the nary results back to decimal This metbodrequites that we store decimal numbers in

cOinputer so that they canbec6b~rted to binary Since the compllter Can accept only valueswe must represent the decimal digits by means ofa code that contains ls and Os also pOsSible lopedorm the arithmetic operlltiorisd1rectly on decimal numbers when they stored in the comput~ in cod~ct form

A binarycodewill have some unasSigned bit com~inatiqns ifthe num~rofelements in set is not amultiple power of 2 The 10decimai digits form such asel A biruuy code that tinguishes among 10 elements must coiltain at least four bits but 6otitofthe 16 possible binations remain unassigned Different binary code$ can bemiddotoNained by arranging four into 10 distinct combin~tions TheicodeIllcfflt oommonly used fdr the decimal digits is straight binary assf~ntlisted in Table 14 This scheil)eis called bittary~coded decimal

is commoolyreferred to as BCQ OtherdecimalcodesaIlfpossible and a few of them are sentedlaterinthis section

Table 14 BinarymiddotCoded Oeclmql (BCO)

Decimal BCD SnlboiDIgIt

o 0000 1 0001 2 0010

3 0011 4 middot0100 5 0101 6 0110 7 0111 8 1000 9 1001

Sectionmiddot 17 BInary COdes 19

Table 14 givesthe four-bit code for one decimal digit A number with k decimal digits will require 4k bits in BCD Decimal 396 is represented in BCD with 12 bits as 0011 10010110 with each group of 4 bits representing one decimal digit A decimalmiddotnumber in BCD is the

- same as itS equiyalent binary number only when the number is between 0 and 9 A BCD numshyber greater than lOJpoks different from its equivalentbinary number even though both con tainls and Os Moreover the binary Combinations 1010 thrpugh 1111 are not used arid have no meaning in BCD Consider decimal 18SlUld its corresponding value inBCD and bUtary

(185ho = (0001100001Ol)BCD = (l0111001h

The BCD value has 12 bits to encode the characters of the decimal value but the equivalent binary number needs only 8 bits It is obvious thatthe representation of a BCp number needs more bits than its equivalent binary value However there is an advantage in the use ofdecishymal numbers because compUterinput and output data are generated by people who use the decshyimal system

It is important to realize that BCD numbers are deCimal numbers and not binary numbers although they use bits in tbeir representation The only difference between a decimal number and BCD is that decimals are written with the symbOls 0 1 2 9 and BCD numbers use tbebinarycode 00000001 001O~ bull 1001The decimal value is exaCtly the same Dec~mal 10 is represented in BCD witheight b~ts as 00010000 and decitna1J5as 0001 01Of1lte corshyresponding binaryvalues are 1010 and 1111 and have only four bits

Consider the addition of two decimal digits in BCD together with a po~ible carry from a pre- vious less significant pair ofdigitsSince each digit does not exceed 9 the sum cannot be bull greater than 9 + 9 + 1 = 19 with the 1 being a previous carrySllppose we add the BCD dig-

its as if they were binary numbers Then the binary sumvill produce It result in the range from degto 19 In bin8ry thistange wil[be from 0000 to 10011 butin BCD it is frOm 0000 to

I 1001 with the first (ie leftmost) 1 bemg a carry and the next fo~ bits being the BCD sum When tPe binary sum is equalto or less than 1001 (withaut 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 (0110h to the binary Sum cOnverts it to the correct digit and also produces a catTy as required This is because a carry in themost significant bitposishytion of the binary sum and a deCimal carry differ by 16 10 = 6 Consider the following three BCD additions

4 0100 4 0100 8 1000

+S +0101 +8 +1000 +9 1001 9 1001 12 1100 17 10001

+0110 +0110----

10010 10111

In each case the two BCD digits are added as if they were two binary numbers If the binary sum is greater than or equal to 1010 we add 0110 to obtain the correct BCD sum and a carry In the flIst example the sum is equal to 9 and is the correct BCD sum In the second example

20 Chapter 1 Digital Systems and BInary Numbers

the binary sum produces an iJlv~ BCD digit The addition of0110 produces the cortect BCD sum 0010 (ie the number 2) and acanyInthetbirdexample the binalY SUDlproduces acany This condition occurs wben the $W)) is greater than or equal to 16Altbough the other fout are less than 1091 the binary 9Ulll requires acOnectionbecause of die carry Adding 0110 obtain thetequiled BCD sum 0111 (ie the numblaquo 7) and 8 BCD CiUT

The additionoftwondigit unsipedBCD numbers follows the same procedure COIlSioll the addition of 184 + 576 1= 76() in BCD

BCD 1 I 0001 10000100 184

+6101 ~

0111--- 0110 +576

lJinarysum 0111 10000 1010 Add6 ono 0110

BCDsun 0111 0110 0000 7(1)

The flfSt l~ sigDiticant pili- of BCD digits produces aBCDdigi~SllDlof 0000 and a for the next pair of digits the second parr or BCD digits plus a ~Vi0U8 cany produces a sum of 0110 and a carry for the next patr()fdigits The third pair of digits plus acarry proltIUC~ a binary s~ of 0111 and does not require a correction

Decimal Arithmetic The represeiltation of signed decimal numbers in BCD is simiiarto the tepresentation of numbers in binaryWe can useeitheI the familiar signed-magnitude system at the SllZllOO-COI1I

plemelit system The sign of a decimal number is tJSually represented with four bits to to thefour-bit code ofthe decimal digits Itis customary to designate 8 plus With four Os 8 minus with the llCDequivalent oi9 whlcq is 1001 The sigiled~magnitudesystem is seldom used in com~tersThe signed-complerDem ~~ either the 9s octhe 10s complement put the lOscomplement is the one most useP To obtain the lOs complement of aBCD numberwe first take the 9s complement then add 1 to the least significant digit The 9s Complement is calculated from the subtracloo of each digit from 9

The prltXeduresdevelope4 for the signed-2s-complement system in the ~vious also apply to the signed-IOs-complement system for decimal mimberS Addition is done summing all digits including the sign digit and discafding the end carry This operatiQ assumes that all negative numbers are in 10s-complement form COOsider the (+375) + (-240) == + 135 done inthe signed-complement system

o 375

+9 760middot

o 135

lhe 9in the leftmost pOsition of the second n~ber tepresents a minllS and 9760 is the complement o( 0240 The two numbers are added and tbe end carry is discarded to +13SOfcourse the decimal ntmlbers insi~ tile computer includingthe sign digits in BCD The addition isdone with BCDOigits as described previously

Sectionl 7 Binary Codes 21

The suQtr8ction of decimalliUJ1lbets either unsigned or in thesi~-~Oscomplement systetn is the sameu in the binary case Taketbe 10s ootnplementof the subtrahend and add i~ to themin~nd ManyooDlputerslULvespeciaJ hardware to perform arithmeticcalculations directly withdecilnal oumbers in 8tDThe~u$etofthecoBlPuter can specify programliled Wtnlctionsto JOdonn the aDtiuJletiP oPmwoowithdeQmal n1UQ~ ~ywithout having to convell them to binary

Binafy codes for decimal digits requirea minimum of four bits per digit Many different codes can be formulated by~gjng four bits into IQ distinct combinations BP) and three other representative codes are shown in Table L5 Each code uses only 10 out ofa pOssible middot16 bit combinations that can be arranged with four bits The other six Unused cOmbinations have no meaning amt should be avoided BCD and the 2421 code are examplesofweigbted codes In a weigbtedcodeeach bit position

juBsigned a weighting f~in~awaythat eaehdigitcanbe ev~by 8dding the wei~ oran the lsin thecoded combination The BCD code has weights of8 42 and I which cotteshy

spondiothe powe1Of-two valuesofeaCh bitTbebitasSignmeatOll0 for example is interpreted by the weights to represent dedma16beCause 8 X 0 +4xt +2 Xl +IX 0 6Thebit combination 1101 when weighted by the ~ve digits 2421 gives themiddotdeCimal equivalent of 2 X I +4 gtlt I + 2 KO + 1 X 1 = 7 Note that some digits cantle coded in lw9 possib)e

ways in the 2421Q)(feFOr inke decimal 4 can be asSigned to bitCombinadon 0100 or 1010 since botbcOmbinatibns add upto a totalweight of4

middot1$ Fou Dlf(et Blnqry Code$ for thtJledmol DIgits

~ IICD DIgIt sal MZt Exeet) 8 4 -~1

0 1

000() middotmiddotmiddot0000 001)1 0001

oem 0100

0000 0111

2 0010 0010 0101 0110 3 0011 OQU 0110 0101

4 0100 0100 0111 oroo 5 0101 lOll 1000 1011 6 OlIO middot1100 1001 1010 7 middot0111 1101 1010 J001 8 1000 IUOmiddot 1011 1000 9 1001 11U 1100 1111

1010 oloi 0000 0001 Uaused IOU 0110 middotOOOl 0010 bit 1100 0111 0010 0011 combishynations

nOl 1110

lOW 1001

HOI 1110

1100 1101

1111 IOU) 1111 1110

22 ChaptfrliDfgltalSystemsaod Btoary Numbers

I1te 2421 rind the

e~l3~es are exampks Of self-complementing codes Such codes have~propertyjbatthe9s~plement ofa deCimal nfunberigobtairted directly by chang-

ing 1$ to O~$ finO tYSCfb1 sie~bycomple~mmgeaCh bit in the pattem)For example decshyimat3~Sis re~ fu tbeexcess3code as 01101100 1000 The 9s compl~ntof 604 isrepRse~l00liOOllelliwbich isobiainc(himply by complementing each bit of the

code (as with the 1 s coinpl~ofbin~rillDlbers)middot Theexcess~3code has been used in some oldel coritputers because of its selfcpmplement~

ing property Excess-3 is an unweighted code inwhich each codedcombinationis obtained-fJQm the corresPonQing bin3ryvalueplus 3 Note that the BCD code is1~ self-complementing TheS 4 ~~ Icode isan example of assigning both positive and negative weights to ~ decimalcodeInthis case the bit combiDation 0110isin~reted as oecimal2 and is calcu-

latedfrom8XO+4X 1 + (2) X 1 + (1XO=2 ~

Cra Code _ _ J

l1te output data QfmaJlfpbYsicaimiddot $)ShmlS are quantities that are continuous These data bemiddottonverted~digiWforuitJefore they art applied toaliigital system Contfuuous or ~nisCOIl~middotUitodigitalfonn bymeans of an rumlog~digitalConverter It is times ~~ent tousethe Gray code slown inTable 16torepresehtdigiuU data that have oon~ fMn8D8l08 dasaTheadvantage of th( Gray cOOeover thesllaigbt binary nIl11l1hPt~

~lt~thatoWY~ hit in the codegroup changeSin going from one number to the For examplcentbullin-goingfrom 1 to 8dleGray code cblngesfrom 0100 to 1100Only the fust changesfromOto l~the odter~ I)its mnaintbesame By contrast With binary numbers change from 7 to 8wrube from 0111 to lOOOwhich causes allfciur bits to change valUes

TabielAi GtPyCode

01 Decl COde Equivalent

~ 0000 0001 0011 OOlG 011Q Olll OlO 0100 1100 11m 1111 1110 lOlQ 1011

lOOt i

1000

o 1 ~ 3

4 5 6 7 8 9

10 11

12 13 14 15

SectIOnl7 BlnarYCod~s 23

The Gray code is used in applications in which the normal sequenceOrbiruuy rium~may produce an error orambiguitymiddot during themiddot transitionfrom ODeDWDber to the next If binary numbersareusec1 acbange forexaJIlple nom 0111 to 1000 may produce anintermediateershyroneous number 1001 if the value ofthe rigbtmost bit takes longer to -change than domiddotthe valshyues of the other three bits The Graycode elimb1ates this problem since only one bit changes its valve dUrlng aily transition be~een two numbers I

Atypical appli-cation ofmiddotthe Gray code is the representation of analog data by a Continu ous change in the angUlar position of a shaft The sQaftmiddot is partitioned into segments ana each segment is assigned a number If adJacent segments are made to correspond with the Qray-Codesequence ambiguity is eliminated between the angle of thesbaft and the value encoded by the sensor

Character Code

Many applications of digital computers require the handling not only ofnumberS but also of other characterS or symbols such as the letters of the alphabet For mstancean insurance comshypany with thousands of policyholders will use a computeX to process its files To represent the names and other pertinent information it is necessary to fonnulate bull binary code for the letshyters ofthe alphabet In additiQt1 the same binary qode must represent numerals and special Characters (such as $) An a1phanumeric character setis a set ofeiements that inclUdes the 10 decimal digits the 26leuersofthealp1iabe and a nutnbeof special~S~ a set conshytains between 36~d 64 elements ifonIy capital letters areincltided or between 64 and 128 e1eJDents ifboth uppercasemiddot and lowercllle etters are inclUded In the first case we need a bi- nary code ofsix bits and in the second we need a binary cooeO(seVM bits

The standaM binary code for the alphanumeric char8cters is the American Stahdard Code for Information InterCbange (A~n) which uses seven bitS to code 128 characters asshoWn in Table 17 The seven bitsof the code are desipted by b~through h With h the mostsigshynificant bit ~e leUer A for example is represented inASCn as l(l()()()Ol (column l00~tOw 0001) The Ascn ()()de also contains 94 graphic characters that can be printed and 34 nonshyprinting characters used for variQUS control functions The graphic characters consist of the 26 uppercase letters (A through Z) the 26 lowercase letters (a through z) the 10 numerals (0 through 9) and 32 special printable characters suchaS andS

The 34 control characters are designated in the ASCTItable With abbreviated nalne8 They are listed again below the table with their functional names The control characters are used fQr routing data and arranging the printed text into a prescribed format~ There are three types of control characters format effectors information separatOrs andcommumc~on-COnlrpl char~ IlCters Format effectors are characters that control the layout ofprinting They inciude the fashymiliar word pr6cessorand typewriter controlssucb 8$ bac~pace (BS) horizontal tabulation (HT) and carriage return (CR) Information separators are used to separatetbe data into divi~ sions such as paragraphs and pages Theyinclude characters such as ~ordseparator (RS)and file separator (FS)The cODlIDunication-control characters are uSefulduriDgthe transmission of text between remote tenninals EXllll1plesof conlmunicatiOn(ODtiol~ are STX (start oftext)-and ETX (end of text) whicb are used toframe a text mesaagetnQlSlnitted through telephone wires

24 Chap~er 1 Diglt8l Systems and Binary Numbers

rblel7 Amerkcm5tandard Code for Information (nterclHlnge(ASCII)

b~jbzb 000 001 010 on 100 101 no 111

0000 NUL )jLP SP () p P 0001 SOH OC1 1 A Q a q

R0010 STX OC2 2 B b r 0011 ETX DC3 3 C S Ii S

0100 EDT 0C4 $ 4 D~ T d t 0101 ENQ NAK 5 E iU e u OUO ACK SYN amp 6 F V f v 0111 BEL ETB 7 0 W g w 1000 B8 CAN ( S H K h x 1001 HT EM ) 9 I Y Y 1010 LF SU~ 1 Z j z lOll VT ESC + 1lt r k UOO FF PS lt L I I 1101 Cit OS == - M 1 m 1110 SO R~ N 1 n shy

-0PIt st US f 1 0 0 DEL

r- Control characten

NUL NlI]l DlE Data-inkescape SOH Start of hea~ng DC1 Device cOntroll STX Start of text DC2 DevIce io~1lOi2 ETX End (Jftext i DC3 Device corUlri1 3 OOT End oftraIlsmission ~4 DeVicecoQtrol4

ENQ ampqwry NAK Negativeackilowledge ACK

Acknowledge SVN Sync~nous idle

Btl Bell ETB End-of-tmnsnussionblOck sS Backspace CAN CanCel HT Horizontal tab EM End of mediUrlt LF Lintifeed SUB Substitute VT Vertical tab ESC escape FF form feed FS File separator CR Carriigeretum GS Group separator SO shift Ollt RS Reoord sepuator SI Shlftin US Unit separator SF S~e DEL Delete

ASCII is a seven-bit codebutrnostcompUters manipulate anejght-bit quantity asa unit called a byte Therefore ASCII characters most often are stored ~e per byte The

I biti~sometimesused forotlef purposes depending ontheapplicatio~lFor example printetS recognize eightmiddotbit AScn chaiacterS with themost sigoificaot bit ~twO An atkJlitlo

Section 18 Binary Storage and Registers 2S

128 eight-bit characters with the most significant bit set tol are used for other symbols such as the Greek alpbabet or italic tyIe font

Error-Dtectlng Code

To detect errors in data communication and processing aneigbth bit is sometimes added to the ASCll cbaracter to indicate its Panty Aparitybit is an extra hit included with a message to make the total num~ of ls either even or odd Consider the fo119wing two cbaracters and their even andodd parity

With even parity With odd parity Ascn A = 1000061 01000001 11000001 ASCI( T == 101deg100 11010100 01010100

1

- Ineacb casewe insert an extra bit in the leftmost position of the code to produce an even number of 1 s intQe cbaraeter for even parity or an odd number of 1 s in the character for odd parity In generlll one or tbe oth~r parity i~ adopted with even parity being more common

The parity biqsbelpful in detecting errors during the transmission ofinformation from one location to another nisfuJictiOD is bandIed by generating an even parity bit at the sending end for ~h character The eight-bit characters that include parity bits are transmitted to their desshytination The parity ofeachebaracter is thetichecked at the receiving~nd If the parity of the received cbaracter is Dot even then at1east on~bit has changed value dUring the trmlsmission This method detects one three or any odd combination of errors in each character tb8t is transshymitted An even combination oferrors however goes undetected and additioDaterror detic- shytion codes may be needed to take care of that possibility

What is done after an errQlis detected depends on the partieu~ application One possishybilityis to request retransrois~ion of the message on the assump~on that tbeenigtr was ranshyd()m andwill not occur again Thus if thereeeiverdetects a parityerrorit sends bai~ the ASCII NAK (negative acknowledge) control cnaracter consisting ofail even-parity eight bits lOOlOl01H no error is detectedthe ~iversends back anACK (aCkno~ledge) conshytrol character namely 0000011 O The sending end will respond middotto an NAK by tranSmitting the message again until the correct panty is received Ifmiddot after a number of attempts the transmission is still in error a message can be sent to the Operatai to check for malfunctions in the transmission path

BINARY STORAGE ANORECiISTEIlS

The binary infonnation inadigitalcomputermust have a physical e~stencein some medium for storing individual bits A binary cell is a device that possesses two stable sttes and is cashypable of storing pne bit (0 or 1) oflnfotlllation The input to tbe cell receives exciJation sigshynals that set it to one of the two states The output of the cell isa pbysicalquantity that distinguishes between the two states The irtformationstored in Ii cell is 1when the cell is in one stable state and degwhen the Cell is in the other stable state

26middot Chapter 1 Digital Systems and BtnaryNumbers

Registers

A register is a group of binary cells A register with n cells can store any discrete quantity of middot information thatcontains n bits The state ofa registeris an n-tuple ofls middotand Os with each bit designating the state of one cell in the register The C()ntent ofaregister is a function of the int~rpretation given to tbeinformation stored in it Consider fQf ex~ple a 16-bitregister with the following binary content

11 00001111001001

middot Aregjs~ with 16 cells can be in one of 216 possible statesIf one asstimesthat the content cif the register represents a binaryinteger then the register can store any binarydumber from Oto 216 - 1 For the patticularexample shown the content ofthe register is the binary equivshyalent(lftbe decimal number 50121 If one assumes instead that the register stores alpbanushy

middot meric characters of an eight-bit cooe then the content of the register is any two meaningful characters For tht ASCII code with anevenplirityplaced in the eighth most significant bit position the register contains thetwo charactersC (the lefunosteightbits) and I (the rigbt~ most eight bits) If however one in~rprets the content of the register to be four decimal dig- its represented by a four-bitcode tnenthe content of the register is a four-digit decimal number In theexcess-3 code the register holqs the decimal nutriber 9096 The content of the registe~is meaningless in BCD becau~e the bit combinatiOn ltob is 110t assfgned to any decshyimal digit From this example it is clear that a register can store discrete elements of inforshymation and that the same bit configuration Inay beinterpreted dlffe(ently for different types of data

tmiddotmiddotReglsterTrail Adigitalsystenlis characteriZed by its registers and the components thatpetfolin data proshy~ssingIIl digital sy~tems a rcentgister tra1lsfer operation is abasi operation that consists of

middot a transftr of hiJWy hUormation from one ~t of registers into ano$er set of registers transfer may be dir~ctfr9m one regist~r toanlt)ther or may pass througb datamiddotprocessing circuits to petformaD operation Figure L 1 illustratel the transfer of iidOrnuttion among regshyisters anddemonstratespictorlallY [the tr8ll~~ ofbinaryinformation from akeyboard a register in the memQryullit Thehlputunit~s assumed to have a keyboard1 control cuit and aninput register Each time a key is strock the control circuit enters an ImnV$_

lent eight-bit alphanumeric character coqe into the input register We shall assume that code used is the ASCII code with an odd-parity bit The information from the input regisshyter is transferred into the eight-least significant cells Qf a proeessOr register After transfer theinpui register is cleared to enable the control to insert a new eight-bit when the keyboard is struck again Each eight-bit character transferred to the pro1c4ess(raquo register is preceded by a shift of the previous character to the next eight cens on its left~

middot a transfer -of four characters is completed the processor registeris full and its contents transferred into a memory register The content stored in die memOry register shown in Figl came from the transfer of the characters J 0 H an~ N aftet the four ap)lroJ)riatt keys were struck

Section 18 Binary Storage and Registers 27

FIGURE 11 Transfer of information among registers

To process discrete quantities of infoiniatiori in binary form a computer m~st be promiddot vided with devices that hold the (lata to be processed and with circuit elements that manipmiddot ulate individual bits of irifonnation The device most commonly used for holding data is a register Binary variables~ manipulated by means of digital logic circuits Figure 12 il~ luslrates the process of adding two l()bit binary iUlmbers Themeniory unit which no[shy

mally consists of millions of registers is shown with only three ofits registers Thepait of the processor unit showncoDsistsmiddotofthree registers-RI R2 and R3~getherwith digital logic circuits that manipulate the bits of RI and R2 and transfer into R3 a binary number equal to their arithmetic sum Memory registers store information and are incapable of pr0shy

cessing the two operands However th~ information stored in meDij)iybanbetransferred to ~ processor registers and the resUlts obtainedin processor tegisters can be transferred back into ame~ry register for storage Untill)ecded again The diagram ~wsthe90ntents of two

operands transferred from twoJDemoryregisters into RI imd R2 The digital logic circuits produce the sum which is transfened to register R3 The contents of R3 can now be 1riUlsshyferredback to one of thetnemory registers

The last two examples demonstrated the infonncion-flow capabilitieSofa digital system in a simple manner Themiddot registets of the ~ystem are the basic ele~ents for Noring and holding the binary information~igitallogic circuits process the binary ihfonaation stored in the

28 Chapter 1 DigIt bullbull Systems and Binary Numbers

Sum

FIGURE 12 Eumple of blnarylnfonn~t1on processing

registers Digitallogiccirctiits and registers are covered InChQpteB 2 throQgh 6 The metlilOlY unit is ~xPIained ill 9aptet 7 Th~ descriptton of register opetJtions at the register level and the design of digital systems are covexed in Chapter 8

19 BINARY LOGIC

Binary logic deals with variables th~ take on two discrete valueund withoperations that sumelogicalmeaning~ The two val~s the variableussume may be called~ydifferent (true andalse yel and no etc) but for ourp1llpQSe it is cpqVenienttotbink in terms of and assign the values llUld O The binary logic intr0ducedin this section is equivalent to algebra oalledBoolean algebra The fannal presentation ofBoolean algebra is covered in detail in Chapter 2 The purpose ofthis seCtion is to introduce Boo algebra ina matmerandlate it to digitallogiccircuits andmiddotbinarYsignalsmiddot

Section 19 Sinary logic 29 ~

Itkltn of IInary logic

Binarylogic consists of binary v~les and a set of logica1middotoperatiQDS The variables are desigshy ~by lettell of thCalplWlet~such asA B C x yz etc with eaCh variable baving two and oniy

two distinct posSible valueS 1and O There are three basic logical operations AND ORand NOT

1 AN]) This ~peration is represented by adotorby the absence ~f an oPerator For example x bull y =z or xy = zis~ x ANDy is equalto z~ThelogicaloperationAND is interpreted to mean that z == 1 ifand only ift~ land y = 1 otherwise z = O (Reme~r that x y andzare binary v8riablesand canmiddotbe equal either to 1 or Omiddotand nothing eise)middot

2 OR This operation IS represented by a plus sign For example x + y =z is read x OR y is equal to z meaning that z 1 if x = iorif y = lorifbothx= 1 and y = 1 If bqth X - 0 andY Omeo z= O

3bull NOT This operation is repf6sented by a prime (sometimes by an overbar) For ~xample x =Z (or~ =z) is read notdsequalto 1 meiming that z iswkatx isnot In other

words ifx = 1 then z == 0 but if x == 0 tnenz = L TheNOT operationisals(1 reshyferred tolls the complement operation since it changes ~ 1 toOand a O to 1

bull bull lt Binary logic resembles binary arithmetic and themiddot9peratioos ANDahd OR have similarishy

ties to multiplication and addition respectively In fac~ the symbols used for AND and OR are the same as those used for multiplication and addition However binary lOgic should not be conshyfused withbinaryarithIrietic One should realize thatan arithmetic variable designates a numshyber that may consist of many digits A logicmiddot variable is always either 1 or O For example in binary arithmetic we have I +1 =10(read~one plus ()fie is equal to 2) whereas in binary logicwe have 1 + 1 1 (read one OR onds equal to one)

For each combination of the values oix and y bullthere isa value of ~ $pecifiedby the definishytion of the logical operation D~linitiops of logical~perations maybe listed in a compacHorm called truth tables A truth table is atable of anpbssible combinations ofthe variables $howshying the relation between the values that the variables may take and the resultof the operation The truth tables for th~ operations ANDand OR with variables x and y are obtained by lis~ng

all possible values that the variables may have when combined in pairs bull For each combination the resUlt of die operation 18 theillistedin a separate row The truth tables for ANDORand

NOT are given in Table La These tables clearly demonstrate the definitionf the operatibns

Table 18 Truth TcibJts of Logical Operations

AND OR NOT

x y xmiddoty x y x+y

0 0 0 0 0 0 1 0 0 1

10

1 0 d 1 0 1 I 1 1 1 1 1

bull~lt~m

30 Chapter 1

Logk Gates

Digital Systems and Binary Numbers

Logic gates are electronic cirellit that operate on ~

variable

or mpre mput tignals to produce an output signal Electrical signals sUch as voltages orrutrents exist as analog signals having values over a given taDgebull saYOt03 V but in a digital system are interpreted to be either of two recognizable values 0 or 1 Voltage~opetated logic Circuits respond to two separate voltshyage levels that represent a binary varjable equal to logic I bt logic O For example a partic- ular digital system may define 10gicOas a signal equal to 0 volts lind logic 1 asa signal equal to 3 volts In practice each voltage levelhiS an acceptable rangeas shown in Fig 13

The input te~nals of digital cikuits accePt binary signals within the allowable range and respond at the output terininals with binary signals that fall within the specified range The intermediate region between the aJl()wed regions is crossed only during aState transition Any desired information for computing or control can be operated tm by passing binary signals through variQUS combinatioDsof logic gates with each signal represebting a particular binary

The graphic symbols used to deSignate themiddotthree types of gates are Mown in Fig 14 The

gates are blocks of hardware that prooocc tbeequivalent of1ogic~1 orlogic() output signals

Volts

- FGURl13

x

y

Exampleof binary slgnaJs

Signal ratlge for logieO

(a)~omiddotinput AND gate

FIGURE 14 SymbOls for digital logic circuits

(c)NOT gate or invert~

Problems 31

x-lU 1 11 P 0

y 0 0 11 1 ~

ANDxy 0 0 rTl 00

ORX+Y~ NOT x 11 0 0 I 1 1

FIGURE 15 Input-output 5Igals for gates

FIGURE 1

A B C

Gates WIth mlltlple JnpUU

A B C lJ

~

if inPllt logic ~ts are satisfied Theinput signals xaDd y intheNDaadQR gates may exist in ~ oHow-possible states 00 10 11 or 01 Il1ese ibpu~ampignals_ shown inFig lStoshygetber with the corresponding output signal foreach PfCThI~tiaiug~iDustrate the reshysponse ofeaclt gate to the four input signal~The~llisofthetiminadiagram represents time and the vertical axis sbo~~~~ it cbapg~botwcen~possible voltshy

age levels The low level represents logic O tJte high level l1lteAND _ responds With a logic ~ ~tput sipl wh~ both input ~~)e 1middot1~ lIieOR S-~with a logic 1 outpUt signal ifanylnput sigrudis lOgic 1 TheNOTgateis~~ to BUll invedet The reason for~nameis~t froJn the signalmsponae inmiddottbe timitt8 diagramwhicbsbows that theoUtputsignal inverts the logic sense of tbeiDpUtsigll8l

AND and OR gates may bavei)lQte tbantwQinputs M AND8_~itti ~input$andan OR gate with foU) inputs are shown in Fig 16 The three-inPllt AND gate responds With logic 1 output if all tbreeinputs arelogic 11jleoutputproduces lOgic Oifanymput is logic O-The

four-input OR gate responds withlogic 1 ifany input is logic 1 its clu1ptltllCCoines logic oonly when all inputs are logic O

Answers to prvblems marked with middotappearaHbe ClOd ofthe ~

11 lJltthe octal and beXadecimalliurilbers trom16ui 32UdngA B1l1ld C forthebst~ digits Usttbe numbers from 8 to 28 in base13 bull

I

12t What is the exact D1Jllbcr of bytes in a system that contains lta) 32Kbytoe (b)64M ~and (e) 640 byte$ middot7 t

32 Chapter 1 Digital Systemsand Binary Numbers

13 Convert the following nu~bers with the indicated bases to decimal (a) (4310)s (b) (198hz (c) (735)8 (d) (525)6

14 Whllt is the largest binary number that can be expressed with 14 bits WhlIt are the equivaleDt ~~ iinal and hexadecimal numbei-s

--

15 Detemrine the base of thl1 numbers in each case for the following operatio~ to be correct (a) 142 = 5 (b) 5414 = 13 (C) 24+ 17 == 40

16 The solution$to the q~cequation xl - Ux +22 oare l1 3 arid x =6 What is the base of the numbers

17 Convertthehexadecimal ntmIher 68BE to bitiary and then convert it ~mbinary to octal

18 I Convert the decirpal number 431 to binary in tWo ways (a) Convertd~y to binary (b) conshyvert first to hexadecinla1 and then from ~decimalwbinary Which method is faster

19 amppress the following nqrnbersin decinud (a) IQ11O0101)z (b) (l65his (c)(2624)8 (d) (FAFA) 16

(e) (10101010)2

110 Convert the following binary numbers tobexadeoimal and todecitnal (a) UOOlO (b) 110010 Explain why the deCimal answer in (b)is 4 times that in (a)

111 Perform the followingdiviskmin binary 11 Ion + l()t

112 Add IlniImultiply tfle following numberswiihout converting them to decimal (a) Binary nuniberilOll aiIdlOh (b) He~uumbers 2E aDd 34

1~)( Do thefoHowing con~ersionproblems (a) CorivertCiecimal2731S to binary (b) CakUlate the binary eqUivalent (f 213 outto eight pl~Then Convert from binary to

imalHowgJose istbe result to 2131 (c) Convert the binary resukin (b) into hexad~ lb~oonvert ~result to decimal Is answer tbesame

114 Obtain the is 8nd 2s complementsofthe foUowing binaryDumbcentrs (aj l)()()(J()OO (b) OOOOOOOO (c) 11011010 (d)01l10110 (e) 10000101 (0 11111111

115 Find the 9s and the 10s complement of the following detimal numbers (a) 52734630 (b) 63325600 (c) 25000009 (d) 00000000

116 (a) Find the 16s complement of B2FA (b) Convert B2FA to binary (c) Find the 2scomplement ofthe resultin (b) (d) Convert the answer in (c)to hex~malandco~ with ihe an~wer in (a)

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 7: Chapter 01 - Mano

7 Section13middot Number-Base Conversions

lhe(OllVelSiOllQCdecimalfrmtonto binary js accompllshedby a ~od similar to tbai uscd for ~~veri multiplication is used instead of division and integers instead of

rem~ are acc~aQd Agafu~ the method is best explajned by example

bull Co~vert (06875hotobmaryFirst 06875 i~ multiplied by2 to give an integer and ajraction nen the new fraction is multiplied by 2 to give a new integer and a newfraction The process is continued until the fraction ~om~ 0 or until the nUJ1lber of digits have sufficient accuracy necoefficients oftbebinary nUlllberare ~btaipedfrolIl-~~ integers asfQUows

lnteger Fraction middotCoemclent gt~fn5 Jlt~~ i + 03750 a-I = 1

()37SO f(2 0 + 07500 g-2= 0

07500X2= 1 + 05000 D-3 - 1-

0-5000 X 2 == I + 00000 a~=l

J

) -

Thereforethe at)Swer is (O6875ho= (OD-lazQ-3D-4h= 010l1hshyTo convert adtcimal fractl9D to a number expressed in base 1 a-similar procedure isused HQwever multiPlication i~ by 1 instead all and the coefficlentsfound from the integers may

range iti value from 0 to r- 1 lI)stead of 0 and 1 bull bull bull - - -_ t lt~ 1

bull

O513X 8 = 4104

0104 X 8 = 0832 0832 X8 6656

0656 X 8 == 5248

0248 X 8 = 1984

0984 x 8= 7872

The an~wer to seven significant figures is obtained from the integer part onhe products

(OsP)IO= (0406517)8

middot8 Chapter 1 Digital Systems iilnd Binary Numbers

Ibo oonversion ofdecimalnumbers withbotMnteger and ftattionparts is done by con- vertingthe integer and the fraction separately and ihencombinihgthe two answers Using the re$Ults ofExamples 11 and l~ weobtain

(416875h~ (lOI001l011h

From Examples 12 and 14e have

(1535130 (2314tl6517)s

14 OCTAL AND HEXADECIMAL NUMBERS

The conversion frOm and to binary octal and bexadecimal plays an important role in digital computers Since 23 =8 and 24 = 16 each octal digit corresponds to thref binary digits and bull each hexadecimal digit corresponds to foUr binary digits The first 16 numbers in the decimal binary oct8r andhex~ecimalnumber systems are listed in Table 1-2

The comersion fm~ binary tooctal is easilyacltooiplishedby partitio~ng the binary num ber into groups oftbree digits each starting ti()n1 the binary plmt and proceeding to the left

I and to the right ~correspo~ octal digit is then assigned to each group The following example illustrates the proeedure ~

(10 110 001 101 011 11~ 100 000 lloh = (261537406)8 2 6 1 ~ 3 7 4 0 6

T_lel2 Numbers with Different-Baus

DecImal IY Octal Hexadecimal middot(base 10) (base 2) (b) (16)

i

00 0000 00 p 01 0001 01 1 02 0010 02 2 03 0011 03 3 04 0100 04 4 0 0101 OS 5 06 0110 06 6 07 0111 07 7

08 1000 10 8 09 1001 11 9 10 1010 12 A 11 1011 13 B 12 1100 14 C 13 1101 IS D 14 1110 16 bull

Ej

IS 1111 11 F r i

9 section 1S Complements

Conversion from binary to heudeciInal is similar except thatthe binary nutriber is divided into groups ofourdigits

(10 1100 0110 1011 1111 0010h = (2C6BJ2) 16

2 C 6 B P 2

The comsponding heX~ima1(o~ octal)~digit fOr each group of binary digits is easily reshymembeled from the values listed in Table 12

Conversion from octal or hexadeciInal to Jlinary is dOne by reversing the preceding proceshy(luremiddot Each octal digit is converted to its tbi-ee-digit binary equivalent Similarlyeach hexashydecimal digit is convertedioits four~digitbinaryequivalent1he procedure is illustrated in the following examples

(673124)8= (110 6

III 011 7 3

001

010 2

l00h 4

and

(306Dh6 = (OOlf 0000030shy

110 6

~101h D

Binary numbers are difficUlt to work with because they require three or fout times as many digits as their decimal equivaltmts Por exaniple the binary number 111111111111middotis equivalent to decimal409S Howeverdigital computers use biIUuy11UIhbers and itis soIIJet4nes necessary for the human operator or user to oonununicatedirectly With the machine by means of such num bers One scheme that retainsthebinary~ystem in the cotnputer but reduceS the number of digshyits the human must cOnsider utilizes the relationslripbetyeen the binary Ilumber system and the ~ or hexadeciinal system By this method the Ql1DaIlthinksin tenns ofQCtal ornexadecimal nurnbers and performs the required conversion by inspection when direct communication with the machine is necessary Thus thebinary number 111111111111 has 12 digits ~d isexpressed iIi octal ~ 7777 (4 digits) or in hexadecimal as FFF (3digits) During communication between people(about binary numbers in the coJlllQter)the octal or hexadecimal representation is more desirable because it can be expressed more compactly with a third or a quarter of the number of digits reqUired for the eqwvalent binary number Thusmpstcomputer manuals use either octal laquohexadecimal numbers to specify binaryqwintiti~ The choice between diem is arbitrary although hexadecimal tends to win out since it can represent a byte with two digits

PlEM ENTS

Complements are used in digital cOmputers to simplifydle subtraction operation and for logshyical manipulation Simplifying operations leads to simpler less expensive circuil$ to implement the operations There are two types of complements for each baSe-r system the radix comshyplement andthe diminished raclix cOtllplement Themiddotflrst is referred to as the rts complement and the second as the (r - middot1)scomplement When the value of the base r is substituted~ the name the twotypesare refefted to as the 2s complement and 1 scomplement fot binary numshy~rs and the lOscompl~ent and 9s complement fqrdecimal numbers

10 Chapt~rl Digital Systems and Binary Numbers

D~I~llhed Radix Complame~middot Gi~en a number N in base r haYing n digits the (r - 1)scomplement~f N is defined as

(rll - 1) ~NFotdecimainumbersr -= Wandr -1 9sothe9scomplementofNis (10 - 1) - N IIi this c~ 10 represents a number that consists of a single 1 followed by nOs 10 - lisartumberrepresentedbyn9sFOrexampleifn 4wehavel04 = 10000 and 104 - 1 = 9999 It follows that the9s complement ofa decimaJnumber is obtained by subtracting each digit from 9 Here are some nwnericalexamples

The 9s complement of 54670(Ms929999~ 546700 453299 bull - I

The 9scothplement of012398is999999~0l2398 =987601

For binary pumbers r =2 and r - l~ 1 sothe 1s complementofNis(Z - 1) - N Again 211 is represented by a binaty number thatconsistsofa 1followed by Ii0s 211 - 1 is abinary number represented by ~1s~FOr example if 11= 4 we have z4 = (10000)zand 24 - 1 = (1111h Thus the ls complement of a binary number is obtained by sUbtractiDg

each dig~t from 1 However when subtracting binary digits from 1 we can have either I -0= lor1 - 1 = 0 which causestbe bit to change from Oto 1 0( from 1 to 0 respec- tively Theretore the ls complement of a binary number isfonnedby changing 1s to Osand Osto 1s The f9llowillg are somenumqical ex~esI

~

The ls Complement of 1011000 isotOOiu

The 1scompieme~t oHlIOUOI is 10 tOOlO

The (r-l) s compleme~ ofoctal or b~xadechnalnumbers i~6btained by subtracting eaeh digit from 70rF (diicimallS) respectively~

Radl~ C~mplement

The s complement of an n~digit number N in baserisdefinedasrmiddot Nfot N i 0 and as ofor N = O~ Comparing with the (r- l)s ~entwe note that ~rs complement is obtained by adding Ito the (r - l)scomplement smcer - N= HA-- 1) - N] L lhus the lOscomplementof deein1al2389 is 76lO +1 = 7611 and is otltamed by adding 1 to the 9scomplernent value The 2s oomplementofbinary 1011oois 010011 1 =010100 and isobtained by adding 1 to the ls-complement value

Since 10 is a number represented by a 1 followed by n0s1011 N Whicb is the10S com~

plementof N can be fonn~d also by leaving allieasl sigtrlficani Os Unchanged the first nonurO least significant digit from 10 and SUbr8Cting all higher significant

from9 ThUs

the 10s complement of 012398js987602

and

11 Sectlon middot15middot Complements

The 10s complement ofthefustnumber isobtaineltibysublriiCtingSfrom lOin the least sig~ nificant position and subtracting all other digits from 9~ The 10s complement of the second number is obtained by leaving the to least significant Os unchanged subtracting 7 from 10 and subtracting the other three digits from 9

Similarly the 2s complement ~be fonned by leaving 1ll11east significant Os and tbe first 1 unchanged and replacing I swith Os and Os with ls in allother hi~r signifIcJUlt digits For example

the 2s cORlplement of 1101100 is 0010100

and

the 2scomplement ofOllOllHs 1001001 _ - r

The +s complement pf therrrst nJUDber i~ obt4iriedby I~vingthetwo least significant Os and the first 1 unchanged andmiddotlQen replacing ls with Os and Oswith 1~ in the other four most sigmiddot nificant digits The 2s lXgtmplement qf the second number is obtained byleaving the least sigshynificantmiddotl unchanged and (fOmplementing all other digits

In the previous definitions it was assum~dtMt the D~bers did not have a radix pomt1f the original number Noontains a radix point the point should be removed temporarily in order to form the s or(r 1)s complement The radix point is then restored to the c9ll1plementshyednumber in the same relative PositionIlis abo wOrth mentioning thatfhecontplement oftbe complement restoresthe number to its original v41ue To see this rel~tionsbipnOtethat the ts complement of N is n - N so that themiddot complement oft1e complement is n - (n - N) == N and is ltlqual to the original number

Mr8Ctiton wltl1 Complementsmiddot

1le direct metb()jiofsubtraCtion taught in elexnentaty schpOls uses the bottow concept In this QlCth9dwebortowa I from a middothigher significant position when the minuend digit is smaller than the subtrahend digit The tDethod wor~wen when peOple perfonnsubtraction with paper andpeooillIowever when subtlaction is implemented withdigi1al bardw8le the method is less e~citnt than the method that u~s compl~m~ts

The subtraction of two n-digitunSigneq numbers M N in base can be done as fonows I

1 Add the minuend M to the scompleme~t of thesubtramphend N Mathematically M+ (n N) = M N +

2 IfM ~ N ttie sum wiUproduce an end cury 11 which caD be discarded what is left is the resultM N

3 If M lt N the sum does not produce ~tlend carry JUld iseijUattor (N~ Ji) which is the s complement of (N - M) To obtain the answer in a familiar form take the s complement of the sum aruI place a negative sign in frorit

12 Chapter 1 Digital Syst-ems and Binary N~mbers

The following examples illustrate the procedure

plPi1I VsinglOs complement subtract 72532 - ~250

M = 72532

lOs complement of N + 96750 Sum= 169282

Discard end caIry lOS = -100000 Answer = 69282

Note that M bas fiv~ digits andN has only fourdigitsBoth numbers mtast have the same numshyber of digits sowe wrlteN as 03250 Taking the lOscomp~ementofNptOducesa9 in the most significant PositionThe occurrence of the end carry signifies that M ~ N 8ndtlult ~ result is therefore positive

Ulling 10s complement subtract 3250 - 72532 - ~ ~

M = 03250 JOscornplementof N =+27468

Sum= ~0718

There is no end carry Theref()re-theanswer is--(10amp complementof30718) == -69282 Note thatsince 3250 lt n532~the result is negative Becauwe are dealing with WUiigned

numbers there is really no way to get BnunSigned result for this case When subtracting complements we reoogilize the negltive answer from the~sence of the end carry and complemented result When workingwith paper and pencil we c8nchlnp the aDswer

signed negative number in oider to putH inafamiliar form Subtraction with complements is done with binary numbers in a similar manner uing

procedure outlined previously

EXAMPLE 17

Given the two binary numbersX = 1010100 and Y =1000011 performtbe $UbiDctiG (8) X - Y arid (b) Y - Xby using 2scomptem~ts -

f

- -

Section 15Complements 13

(a) x = 1010100

2s complement ofY= + -0111101

Sum = middot 10010001 Discard end carry 27 = 10000000

Answ~ X- Y = 0010001

(b) Y == 1000011 2sco~lement of X = + 0101100

Sum= 1101111

There is nQmiddotend carry Therefore the answer is Y ~X= -(2sq)mplement of 1101111) = -0010001 Subtractionof unsigned D1lJllbers ~ also bed()neby means of the (r - 1)s complement Remember that the(r- l)s complement is one lesstharithers complement BeCause of

ibis the result of adding the minue~ to tJte coQlplement of the subtiah~ndPtOductS itsum that is one less than the correct 4ifference when an end carrY oCcurs Removing the end carry and adding 1 to the sum is referred to asan end-around carry

Repeat Example 17 but this time using rs complement

(8) X y = 1010100 - 1000011middot

X= 1010100

rs complementafY= + olfnoo Som = 10010000

End-arOundmiddot~ =- ~ ~ Answermiddot X Y= middot0010001

(b) Y - X = 1000011 - 1010100

Y = 1000011

1s complement ofX = +0101011

Sum = 1101110

There is no end carry TherefOre the answer is y - X = -(1s complement of 1101110) = -0010001

bull Note that the negative resultis ob~ by taltingtbe 1 scomplemeilt of theJWltsince this is the type ofcoDiplementused The procedwewithendaroundoanyis aIs(gt Iijlpliclbleto subshytracting Unsigned deciImdnumQers with 9seomPlement

14 Chapter 1 Digital Systemsand BinayNumbers

16 SIGNED BINARYNUMBER$ ~

Positiveintegers (including zero) CaBbe ep~~ 11$ unstPecl numbers However to repshyresent negative integers we need a notation for negative srn ordinary arithmetic a negshyative number is indicated by a mulUs signmdapOsitiv~Pwtlt)e~ by aplus sign Because of lJardware limitations computers mlstrepresenlev~With~ digitsIt is customary to represent the sign witb a bit placed intheleftmotp6sitiolwfthe number The convention is tltl make the sign bit 0 for positive and 1 for negative

Itis important to realize that botp siped and unsignedtDnary 11UJDbers consist of a strfug of bits when represented in a com~ TQeuser detem1inesWbether the number is signed or unsigned If the binary number is signed then the lefuriostbitreple$ellts thtsign aud the rest of the bits represent the number Ifthebinaryllu~beiis~ tObe unsigned then the left most bit is the most significant bit of the l)uMber Fdre~the~~f bits 01001 can be consideredas 9 (unsigned binary) or as +9 (Sighedbitia1j) ~USJtheteftmostbit is O The

string ofbits 11001 represents the binary ~~v~ento~ ~w~nc~idered as an unsigned number and the binary equivalent of 9whenconsidered1l si~riumPer This is because the Ithal isintbe leftmost positiondesignatesampC nega6ye_~QtherfourJ)its represent bishynary 9 usually tlere is no cotifusionin identifying thebits~the~Qfrepresentation for the number is known in advance ~

The representation of the signed numbers in the lastexainple is referred to as the signed magnitutk coDvention In this ~otati()nthenurnber C4mSiampesOCa mQ~~andil~ymbolH

or -) or a bit (0 or 1) indicating the sign This is the representation ampr~~used in ordinary arithmetic When arithmeti~ operatioBslllieimplerneJltcldin~cOQlPuter hii more convenient to use a different systemrefetred t(gt as the si~cqmptement system~ for repre- senting negative numbers In thissystlm a neg8tielliun~r isjhdic~ted by its cornplc~mc~nt Whereas the signed-magnitude system negates a nlllllher by cbanging its sign me signed-comshyplement system negatesanwnber bytakin$ its~OinPleltleitiSinoepositife numbers always start witbO(plusin tte leftmost pOsition thecompktllint wiilalwaysstart with a 1 indicating a negative number The siped-complemelt system can use olthertbe 1s Or the 2s but the 2s complement is the mos~comtliOfi

As an exampleconsider the number9re~~ed in binary with eight bits + 9 Is sented with a sign bit of Oin the leftri1ostpOsition oIIOv~by the binary (equivalent of 9 which gives ()()()olOOl Note thai all eigbtbits must haYampa v~therefore O~s are inserted folshylowing the sign bitllp to the first 1 Although ~ is only 01K way to tepresent +9 there three different ways to represent 9 with eight ~its

s~gned~magnituderepresentation 10001001

sigried-l s-complement represe~on~ 11110110

signed-2 s-complemerit representatim 1ttltllU

In signedmagnituamp -9 isobwned from +9 by changing the sign bitmtbe leftmost ~iti(ln tromO to L In sigl1ed~ lroomplement 9isobtaidedtf~~tiog all the bits of includinj the sign bit Thesigned-2~sco~re~Qf-9 is obtampDedby ihe 2s complement oftbepOsitivenumberincludingtbesijnbIt

Sectlont6 SIgned8lnary NumberS is

Table 13 Slgtlfd Biliary Humbm

+7 +6

+5 +4 +3 +2 +l +0 0 -I

-2 -3

4 -5 -6 -1 -8

Olll 0110

0101 ( 0100

001l 0010 0001 0000

IIll 1110

nOI noo Ion 1010

1001 1000

OIll Oito eHOl OHIO OOU 0010 0001 0000 1111 1110middot dOl 1100 Ion

lOti 1001 1000

0111 OUO 0101

0100 0011 0010 0001 0000 1000 1001 1010 IOU 1100

1101 1110

lUI

Table 13 lists all possible four-bitsignedbinaryaumbers in the three representations The equivalent decimal number Is also shown for refelenoeNote that the positive n~ in all three representations are identicaland have 0 inthelefmostpcsiticm The signed2sshycompl~mentsystemhaironly onemiddotrepresentation for 0 which is always po$itive The other tw()systetns- mlve either a positive 0 or a negative 0 sometbingnoteDcounteredin ordinary arithmetic Note that all negative numbenhave alin the leftmost bitpositi~ that is the way we distinguish them from the positivenumbers With fout bits we can repreSent 16 binary numbers In the signed-magnitude aDd thelscomplement repre$eDtatipns there are eight positive numbers and eight negative numbers inciUdingtwo zeros In the2s-complement representation there are eight positive numbers includi0a one zerQ and eight negative numberS

The siped-m_gnitude system is used in ordiIlary arithmetic but is awkward when emshyployed in computer arithmetie becauIe of the ~parate bandIinJ bfthesipand the magnitude Therefore the signed-compiement systeni is normallyused The ls ~t imposes some difficulties and is seldom USedJor arithmetic openitiOns It is U$eful aSa lo~ operation since the change of 1 to Obrmiddot() to 1 is equivalent to a logical complement Operation as will be shown in the next c~The discussion~f sigiled binary ariduneti~ that fol10ws deals exshyclusively with the signe4-2soomplt_nt~tatJonQfnegadveilUlilbers hsame proshy

cedurescan beappJied to the sigMdrs-comPlemeD~Iysby incIudiOI tbe~arotmdcarry as is done with unsigned numbers

J6 Chapt~r 1 OlgltalSystlf(ns and Binary Numbels

Arithmetic Addition

The addition of two numbers in the signed-magnitudelYs_foUowsthe rules ofordinaiy arithshymetiC Ifthesi~s arethesam~we addthetwOtt~gni1U~~d ~vetbe sum the CCmmon sign Iftbe signs are diffe~nt we subtract tllcsmaUermagnitude frOtnlthe larF and give the differshyehtethe signof the larger magnitude For example (+25) +( - 37) = ~ (37 - 25) = -12 and is done by subtracung the smaller magnitude 25 from the larger magnitude 37and a~nding the sign of 37 tGtbe result Ibis is a process that requires a corripanson of the signs and magnitudes and then performing eithr additi()n or subtraction The same procedure applieato binary numbers in sigped-magnitude representation~Incontrast the rule for adding numbers in the signed-corppleme~ sy~tem does not require a comparison or su~ traction but only addjtion The procedure is very simple andcanbe stated as follows for binary numbers The 8ddltion oftwo signed binary numberS with negative numbers tepresented in signed- 2sComprement fonn is obtaiIled from theadditlooofthe two numbers includingtheii sign bits

AcentiirrY out oftbe sign-bitposition is diScacded NumerIcal e~aihpledotai1dition follow

+ 6 00000110 - 6 11UI0tO I

+13 00001101

+13 00001101 +19 00010011 + J 0Q900111 + 6 00000110 6 11111010 ~13 11110011 -1~l 11110011 7 illl1001 -19 11101101

I bull bull ~

Note that negative numbers musthil iriitially in 2seompkmentform and that if the swn ~ ~afterthladdit40nis negativeins in2s~p~t fOl1Jl - In each of thefoDrcasestlteoporationperfol1JlC(lis additionwitb the sign bit iilcluded Any catTY o~of~~-bit~onisdisc~ and negative resultsareButomaticallyin 2sshyromplementfoon

In order to obtain acOrrect answer we mustensQre that the result has a sufficient of bits to accommodate the swnlfwestartwith t~on-bltnumbers and tbeswn occupies n + 1bits we say tblltan overflow occurs~Wheri one perfotmStbc ad(JitiOJl with nllllIPTJllVIl

pencil aq overflow is not a preblem because we arcr noflimitecLbythewidth of the page jUst addanothcentr 0 to apositive number or another 1 toa negative number in the mOst cant positi()n to extend thenwnber to n+ 1 bitSand theQ perform addition Overflow is

problem in computers beqiusetbe number ofbi~~ bolla ~befis finite and a result ex~ tI1efinite val~e hy lcatmotbe accommodated

The compJement form of representiQg negativetlQUlbers is unfamiliar to those usedto signed-magnitude system To itetermine th~ value of II negatienumber insiped-2s COlIlpJe

mentit0is~ to CODVerttbe numbcr to apositie ntirit_ ~ place itiDa more formPor ~plethesig~binary number qUl00~ lii~egativebecausothe leftmost

t 1182s c0J8plemen~js~UlwhUhi$~ binaryeqqivalen of +7Wcmiddottherefore nize the Ori~nal ~atiy-eQumber to be equ~ lo-7 1

Sectlonl7 Bh1ary Codes 17

ArIthmetic SubtractIOn

Subtraction of two signed binafy numbers whe~negative numbersare in2s-complement form is simple and can be stilted as follows

Take the 2s complement of the5ubtraltend (including the sign bit) and add it to the minuend (including the sign bit) A cany oU1of thesignbit position is discarded

This prOCedure is adopted because a subtraction operation can be changed to an addition operation if the sign of the subtrahend is changed as is demonstrated by the following relationship

(plusmnA) ~ (-tB) = (plusmnA) + (-B) (plusmnA) - (-B) =plusmnA) + (+B)

But changing a positivetwober toa negative n~ber is eaampily done by taking the 2s compleshy mentof the pQsitive number The reverse is also tiUe~use theCOmPle~n~ of a negative numshyber in complement form produces the equivalent positive number To see this consider the sJlbtr~ction ( 76) -- (13) = +7 In binaIy_ with eight bits this ()peiationis written as (11111010 11110011) The subtracti~ri ischmlged ~ addition by taking the 2s complement ofthe subtrahend (-13) giving (+13) In binaly tbis~ 11 niOlO+ 00001101 = lOOOOOU1 Removing the end~ we obtain the ootrect answer ()()()()() III (+7)

Itisworth noting that binary DUmbersinthe signed-complement system are added and subshy tracted by the same basic addition and suPtraction rules as unsigned numbers Therefore comshyputersneed omy one common hardware circuit tobandle bothtypcs ofaritbtnetic The user or programmer ~ust interpret the reswtIi of $l1ch addition or subtraction differently depending on whether itisassumedtha~the numbe~ are signed ltr tinsigned

j

BINARY CODES

Digitalsystems use signalsthat have two distinct values1Uld circuit elements that havetwostashyble states There is a direct analogy anrong binary iignals binary circuitelements and binary digits A binary number ofndigitsfor example may be represented by n binary circuit eleshyments each baving an output sig~alequivalen1to Oor I Digital systems represent (Uld mashynipUlate not omy binary numbers but alsO many other diScrete elements of information Any discrete element of informatioIidlat is dis1iilct among agroup of quantities can be represented witha binary code (Le a pattern of Os and fmiddots) The codes must be in binary because in todays techIiology omy circuits that represent and manipulate patterns of 0s and ls can be manufactured economically foru~ in computers However it mtistbe realizCd that binary codes merely change the symbols not the meaning ofthe ele~nts of infonbationthat they repshyresent IT we inspect the bits of a computer at random we will find that mostofthe time they represent some tYPe of coded information rath~ than binlUY numbers

AIln-bit binary code is a groopofn hits that assumes up to 211 distinct cOmbinations of ls ~d Os with eacn combination representing one elementof tnt set that is being coded A set

of four elements clab becoded with two lilS with each ~lementassignedoneof thefoUowing bit oombinationsOOO I 10 J 1 A set of eight elements requiies a three-bit code 00 a set of

18 Chapter 1 Digital Systems and Binary Numbers

J6 elements requires a fourmiddotbit code The bit combination of ann~bit code is determined the count in binuy from 0 to 21t - t Each element must be assigned a unique binuy bit binationand no two elemerits cm havetbtsamevalueothenvisethe code assignment be ambigUous

Although the minimum nqrnber of 1lits required to code 21t distiItct quantities is nthere nomaximwn numbe( of bit that may he used for a binuy code For example the 10 digits can be coded with 10 bits and each decimal digit can be assigned a bit combination nine OSmid a 1 In this pamcularbinarycode the digit6 is assigned the bit )UllIUlauuu0001000000

BCDcode

Although the binary number systemis die ~ost natural system for a computer most people more accustomed to the d~imal system One way to resolve this difference is to convert

inlal nUmbers to binary perform all arithmetic calculations in binary and then convert the nary results back to decimal This metbodrequites that we store decimal numbers in

cOinputer so that they canbec6b~rted to binary Since the compllter Can accept only valueswe must represent the decimal digits by means ofa code that contains ls and Os also pOsSible lopedorm the arithmetic operlltiorisd1rectly on decimal numbers when they stored in the comput~ in cod~ct form

A binarycodewill have some unasSigned bit com~inatiqns ifthe num~rofelements in set is not amultiple power of 2 The 10decimai digits form such asel A biruuy code that tinguishes among 10 elements must coiltain at least four bits but 6otitofthe 16 possible binations remain unassigned Different binary code$ can bemiddotoNained by arranging four into 10 distinct combin~tions TheicodeIllcfflt oommonly used fdr the decimal digits is straight binary assf~ntlisted in Table 14 This scheil)eis called bittary~coded decimal

is commoolyreferred to as BCQ OtherdecimalcodesaIlfpossible and a few of them are sentedlaterinthis section

Table 14 BinarymiddotCoded Oeclmql (BCO)

Decimal BCD SnlboiDIgIt

o 0000 1 0001 2 0010

3 0011 4 middot0100 5 0101 6 0110 7 0111 8 1000 9 1001

Sectionmiddot 17 BInary COdes 19

Table 14 givesthe four-bit code for one decimal digit A number with k decimal digits will require 4k bits in BCD Decimal 396 is represented in BCD with 12 bits as 0011 10010110 with each group of 4 bits representing one decimal digit A decimalmiddotnumber in BCD is the

- same as itS equiyalent binary number only when the number is between 0 and 9 A BCD numshyber greater than lOJpoks different from its equivalentbinary number even though both con tainls and Os Moreover the binary Combinations 1010 thrpugh 1111 are not used arid have no meaning in BCD Consider decimal 18SlUld its corresponding value inBCD and bUtary

(185ho = (0001100001Ol)BCD = (l0111001h

The BCD value has 12 bits to encode the characters of the decimal value but the equivalent binary number needs only 8 bits It is obvious thatthe representation of a BCp number needs more bits than its equivalent binary value However there is an advantage in the use ofdecishymal numbers because compUterinput and output data are generated by people who use the decshyimal system

It is important to realize that BCD numbers are deCimal numbers and not binary numbers although they use bits in tbeir representation The only difference between a decimal number and BCD is that decimals are written with the symbOls 0 1 2 9 and BCD numbers use tbebinarycode 00000001 001O~ bull 1001The decimal value is exaCtly the same Dec~mal 10 is represented in BCD witheight b~ts as 00010000 and decitna1J5as 0001 01Of1lte corshyresponding binaryvalues are 1010 and 1111 and have only four bits

Consider the addition of two decimal digits in BCD together with a po~ible carry from a pre- vious less significant pair ofdigitsSince each digit does not exceed 9 the sum cannot be bull greater than 9 + 9 + 1 = 19 with the 1 being a previous carrySllppose we add the BCD dig-

its as if they were binary numbers Then the binary sumvill produce It result in the range from degto 19 In bin8ry thistange wil[be from 0000 to 10011 butin BCD it is frOm 0000 to

I 1001 with the first (ie leftmost) 1 bemg a carry and the next fo~ bits being the BCD sum When tPe binary sum is equalto or less than 1001 (withaut 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 (0110h to the binary Sum cOnverts it to the correct digit and also produces a catTy as required This is because a carry in themost significant bitposishytion of the binary sum and a deCimal carry differ by 16 10 = 6 Consider the following three BCD additions

4 0100 4 0100 8 1000

+S +0101 +8 +1000 +9 1001 9 1001 12 1100 17 10001

+0110 +0110----

10010 10111

In each case the two BCD digits are added as if they were two binary numbers If the binary sum is greater than or equal to 1010 we add 0110 to obtain the correct BCD sum and a carry In the flIst example the sum is equal to 9 and is the correct BCD sum In the second example

20 Chapter 1 Digital Systems and BInary Numbers

the binary sum produces an iJlv~ BCD digit The addition of0110 produces the cortect BCD sum 0010 (ie the number 2) and acanyInthetbirdexample the binalY SUDlproduces acany This condition occurs wben the $W)) is greater than or equal to 16Altbough the other fout are less than 1091 the binary 9Ulll requires acOnectionbecause of die carry Adding 0110 obtain thetequiled BCD sum 0111 (ie the numblaquo 7) and 8 BCD CiUT

The additionoftwondigit unsipedBCD numbers follows the same procedure COIlSioll the addition of 184 + 576 1= 76() in BCD

BCD 1 I 0001 10000100 184

+6101 ~

0111--- 0110 +576

lJinarysum 0111 10000 1010 Add6 ono 0110

BCDsun 0111 0110 0000 7(1)

The flfSt l~ sigDiticant pili- of BCD digits produces aBCDdigi~SllDlof 0000 and a for the next pair of digits the second parr or BCD digits plus a ~Vi0U8 cany produces a sum of 0110 and a carry for the next patr()fdigits The third pair of digits plus acarry proltIUC~ a binary s~ of 0111 and does not require a correction

Decimal Arithmetic The represeiltation of signed decimal numbers in BCD is simiiarto the tepresentation of numbers in binaryWe can useeitheI the familiar signed-magnitude system at the SllZllOO-COI1I

plemelit system The sign of a decimal number is tJSually represented with four bits to to thefour-bit code ofthe decimal digits Itis customary to designate 8 plus With four Os 8 minus with the llCDequivalent oi9 whlcq is 1001 The sigiled~magnitudesystem is seldom used in com~tersThe signed-complerDem ~~ either the 9s octhe 10s complement put the lOscomplement is the one most useP To obtain the lOs complement of aBCD numberwe first take the 9s complement then add 1 to the least significant digit The 9s Complement is calculated from the subtracloo of each digit from 9

The prltXeduresdevelope4 for the signed-2s-complement system in the ~vious also apply to the signed-IOs-complement system for decimal mimberS Addition is done summing all digits including the sign digit and discafding the end carry This operatiQ assumes that all negative numbers are in 10s-complement form COOsider the (+375) + (-240) == + 135 done inthe signed-complement system

o 375

+9 760middot

o 135

lhe 9in the leftmost pOsition of the second n~ber tepresents a minllS and 9760 is the complement o( 0240 The two numbers are added and tbe end carry is discarded to +13SOfcourse the decimal ntmlbers insi~ tile computer includingthe sign digits in BCD The addition isdone with BCDOigits as described previously

Sectionl 7 Binary Codes 21

The suQtr8ction of decimalliUJ1lbets either unsigned or in thesi~-~Oscomplement systetn is the sameu in the binary case Taketbe 10s ootnplementof the subtrahend and add i~ to themin~nd ManyooDlputerslULvespeciaJ hardware to perform arithmeticcalculations directly withdecilnal oumbers in 8tDThe~u$etofthecoBlPuter can specify programliled Wtnlctionsto JOdonn the aDtiuJletiP oPmwoowithdeQmal n1UQ~ ~ywithout having to convell them to binary

Binafy codes for decimal digits requirea minimum of four bits per digit Many different codes can be formulated by~gjng four bits into IQ distinct combinations BP) and three other representative codes are shown in Table L5 Each code uses only 10 out ofa pOssible middot16 bit combinations that can be arranged with four bits The other six Unused cOmbinations have no meaning amt should be avoided BCD and the 2421 code are examplesofweigbted codes In a weigbtedcodeeach bit position

juBsigned a weighting f~in~awaythat eaehdigitcanbe ev~by 8dding the wei~ oran the lsin thecoded combination The BCD code has weights of8 42 and I which cotteshy

spondiothe powe1Of-two valuesofeaCh bitTbebitasSignmeatOll0 for example is interpreted by the weights to represent dedma16beCause 8 X 0 +4xt +2 Xl +IX 0 6Thebit combination 1101 when weighted by the ~ve digits 2421 gives themiddotdeCimal equivalent of 2 X I +4 gtlt I + 2 KO + 1 X 1 = 7 Note that some digits cantle coded in lw9 possib)e

ways in the 2421Q)(feFOr inke decimal 4 can be asSigned to bitCombinadon 0100 or 1010 since botbcOmbinatibns add upto a totalweight of4

middot1$ Fou Dlf(et Blnqry Code$ for thtJledmol DIgits

~ IICD DIgIt sal MZt Exeet) 8 4 -~1

0 1

000() middotmiddotmiddot0000 001)1 0001

oem 0100

0000 0111

2 0010 0010 0101 0110 3 0011 OQU 0110 0101

4 0100 0100 0111 oroo 5 0101 lOll 1000 1011 6 OlIO middot1100 1001 1010 7 middot0111 1101 1010 J001 8 1000 IUOmiddot 1011 1000 9 1001 11U 1100 1111

1010 oloi 0000 0001 Uaused IOU 0110 middotOOOl 0010 bit 1100 0111 0010 0011 combishynations

nOl 1110

lOW 1001

HOI 1110

1100 1101

1111 IOU) 1111 1110

22 ChaptfrliDfgltalSystemsaod Btoary Numbers

I1te 2421 rind the

e~l3~es are exampks Of self-complementing codes Such codes have~propertyjbatthe9s~plement ofa deCimal nfunberigobtairted directly by chang-

ing 1$ to O~$ finO tYSCfb1 sie~bycomple~mmgeaCh bit in the pattem)For example decshyimat3~Sis re~ fu tbeexcess3code as 01101100 1000 The 9s compl~ntof 604 isrepRse~l00liOOllelliwbich isobiainc(himply by complementing each bit of the

code (as with the 1 s coinpl~ofbin~rillDlbers)middot Theexcess~3code has been used in some oldel coritputers because of its selfcpmplement~

ing property Excess-3 is an unweighted code inwhich each codedcombinationis obtained-fJQm the corresPonQing bin3ryvalueplus 3 Note that the BCD code is1~ self-complementing TheS 4 ~~ Icode isan example of assigning both positive and negative weights to ~ decimalcodeInthis case the bit combiDation 0110isin~reted as oecimal2 and is calcu-

latedfrom8XO+4X 1 + (2) X 1 + (1XO=2 ~

Cra Code _ _ J

l1te output data QfmaJlfpbYsicaimiddot $)ShmlS are quantities that are continuous These data bemiddottonverted~digiWforuitJefore they art applied toaliigital system Contfuuous or ~nisCOIl~middotUitodigitalfonn bymeans of an rumlog~digitalConverter It is times ~~ent tousethe Gray code slown inTable 16torepresehtdigiuU data that have oon~ fMn8D8l08 dasaTheadvantage of th( Gray cOOeover thesllaigbt binary nIl11l1hPt~

~lt~thatoWY~ hit in the codegroup changeSin going from one number to the For examplcentbullin-goingfrom 1 to 8dleGray code cblngesfrom 0100 to 1100Only the fust changesfromOto l~the odter~ I)its mnaintbesame By contrast With binary numbers change from 7 to 8wrube from 0111 to lOOOwhich causes allfciur bits to change valUes

TabielAi GtPyCode

01 Decl COde Equivalent

~ 0000 0001 0011 OOlG 011Q Olll OlO 0100 1100 11m 1111 1110 lOlQ 1011

lOOt i

1000

o 1 ~ 3

4 5 6 7 8 9

10 11

12 13 14 15

SectIOnl7 BlnarYCod~s 23

The Gray code is used in applications in which the normal sequenceOrbiruuy rium~may produce an error orambiguitymiddot during themiddot transitionfrom ODeDWDber to the next If binary numbersareusec1 acbange forexaJIlple nom 0111 to 1000 may produce anintermediateershyroneous number 1001 if the value ofthe rigbtmost bit takes longer to -change than domiddotthe valshyues of the other three bits The Graycode elimb1ates this problem since only one bit changes its valve dUrlng aily transition be~een two numbers I

Atypical appli-cation ofmiddotthe Gray code is the representation of analog data by a Continu ous change in the angUlar position of a shaft The sQaftmiddot is partitioned into segments ana each segment is assigned a number If adJacent segments are made to correspond with the Qray-Codesequence ambiguity is eliminated between the angle of thesbaft and the value encoded by the sensor

Character Code

Many applications of digital computers require the handling not only ofnumberS but also of other characterS or symbols such as the letters of the alphabet For mstancean insurance comshypany with thousands of policyholders will use a computeX to process its files To represent the names and other pertinent information it is necessary to fonnulate bull binary code for the letshyters ofthe alphabet In additiQt1 the same binary qode must represent numerals and special Characters (such as $) An a1phanumeric character setis a set ofeiements that inclUdes the 10 decimal digits the 26leuersofthealp1iabe and a nutnbeof special~S~ a set conshytains between 36~d 64 elements ifonIy capital letters areincltided or between 64 and 128 e1eJDents ifboth uppercasemiddot and lowercllle etters are inclUded In the first case we need a bi- nary code ofsix bits and in the second we need a binary cooeO(seVM bits

The standaM binary code for the alphanumeric char8cters is the American Stahdard Code for Information InterCbange (A~n) which uses seven bitS to code 128 characters asshoWn in Table 17 The seven bitsof the code are desipted by b~through h With h the mostsigshynificant bit ~e leUer A for example is represented inASCn as l(l()()()Ol (column l00~tOw 0001) The Ascn ()()de also contains 94 graphic characters that can be printed and 34 nonshyprinting characters used for variQUS control functions The graphic characters consist of the 26 uppercase letters (A through Z) the 26 lowercase letters (a through z) the 10 numerals (0 through 9) and 32 special printable characters suchaS andS

The 34 control characters are designated in the ASCTItable With abbreviated nalne8 They are listed again below the table with their functional names The control characters are used fQr routing data and arranging the printed text into a prescribed format~ There are three types of control characters format effectors information separatOrs andcommumc~on-COnlrpl char~ IlCters Format effectors are characters that control the layout ofprinting They inciude the fashymiliar word pr6cessorand typewriter controlssucb 8$ bac~pace (BS) horizontal tabulation (HT) and carriage return (CR) Information separators are used to separatetbe data into divi~ sions such as paragraphs and pages Theyinclude characters such as ~ordseparator (RS)and file separator (FS)The cODlIDunication-control characters are uSefulduriDgthe transmission of text between remote tenninals EXllll1plesof conlmunicatiOn(ODtiol~ are STX (start oftext)-and ETX (end of text) whicb are used toframe a text mesaagetnQlSlnitted through telephone wires

24 Chap~er 1 Diglt8l Systems and Binary Numbers

rblel7 Amerkcm5tandard Code for Information (nterclHlnge(ASCII)

b~jbzb 000 001 010 on 100 101 no 111

0000 NUL )jLP SP () p P 0001 SOH OC1 1 A Q a q

R0010 STX OC2 2 B b r 0011 ETX DC3 3 C S Ii S

0100 EDT 0C4 $ 4 D~ T d t 0101 ENQ NAK 5 E iU e u OUO ACK SYN amp 6 F V f v 0111 BEL ETB 7 0 W g w 1000 B8 CAN ( S H K h x 1001 HT EM ) 9 I Y Y 1010 LF SU~ 1 Z j z lOll VT ESC + 1lt r k UOO FF PS lt L I I 1101 Cit OS == - M 1 m 1110 SO R~ N 1 n shy

-0PIt st US f 1 0 0 DEL

r- Control characten

NUL NlI]l DlE Data-inkescape SOH Start of hea~ng DC1 Device cOntroll STX Start of text DC2 DevIce io~1lOi2 ETX End (Jftext i DC3 Device corUlri1 3 OOT End oftraIlsmission ~4 DeVicecoQtrol4

ENQ ampqwry NAK Negativeackilowledge ACK

Acknowledge SVN Sync~nous idle

Btl Bell ETB End-of-tmnsnussionblOck sS Backspace CAN CanCel HT Horizontal tab EM End of mediUrlt LF Lintifeed SUB Substitute VT Vertical tab ESC escape FF form feed FS File separator CR Carriigeretum GS Group separator SO shift Ollt RS Reoord sepuator SI Shlftin US Unit separator SF S~e DEL Delete

ASCII is a seven-bit codebutrnostcompUters manipulate anejght-bit quantity asa unit called a byte Therefore ASCII characters most often are stored ~e per byte The

I biti~sometimesused forotlef purposes depending ontheapplicatio~lFor example printetS recognize eightmiddotbit AScn chaiacterS with themost sigoificaot bit ~twO An atkJlitlo

Section 18 Binary Storage and Registers 2S

128 eight-bit characters with the most significant bit set tol are used for other symbols such as the Greek alpbabet or italic tyIe font

Error-Dtectlng Code

To detect errors in data communication and processing aneigbth bit is sometimes added to the ASCll cbaracter to indicate its Panty Aparitybit is an extra hit included with a message to make the total num~ of ls either even or odd Consider the fo119wing two cbaracters and their even andodd parity

With even parity With odd parity Ascn A = 1000061 01000001 11000001 ASCI( T == 101deg100 11010100 01010100

1

- Ineacb casewe insert an extra bit in the leftmost position of the code to produce an even number of 1 s intQe cbaraeter for even parity or an odd number of 1 s in the character for odd parity In generlll one or tbe oth~r parity i~ adopted with even parity being more common

The parity biqsbelpful in detecting errors during the transmission ofinformation from one location to another nisfuJictiOD is bandIed by generating an even parity bit at the sending end for ~h character The eight-bit characters that include parity bits are transmitted to their desshytination The parity ofeachebaracter is thetichecked at the receiving~nd If the parity of the received cbaracter is Dot even then at1east on~bit has changed value dUring the trmlsmission This method detects one three or any odd combination of errors in each character tb8t is transshymitted An even combination oferrors however goes undetected and additioDaterror detic- shytion codes may be needed to take care of that possibility

What is done after an errQlis detected depends on the partieu~ application One possishybilityis to request retransrois~ion of the message on the assump~on that tbeenigtr was ranshyd()m andwill not occur again Thus if thereeeiverdetects a parityerrorit sends bai~ the ASCII NAK (negative acknowledge) control cnaracter consisting ofail even-parity eight bits lOOlOl01H no error is detectedthe ~iversends back anACK (aCkno~ledge) conshytrol character namely 0000011 O The sending end will respond middotto an NAK by tranSmitting the message again until the correct panty is received Ifmiddot after a number of attempts the transmission is still in error a message can be sent to the Operatai to check for malfunctions in the transmission path

BINARY STORAGE ANORECiISTEIlS

The binary infonnation inadigitalcomputermust have a physical e~stencein some medium for storing individual bits A binary cell is a device that possesses two stable sttes and is cashypable of storing pne bit (0 or 1) oflnfotlllation The input to tbe cell receives exciJation sigshynals that set it to one of the two states The output of the cell isa pbysicalquantity that distinguishes between the two states The irtformationstored in Ii cell is 1when the cell is in one stable state and degwhen the Cell is in the other stable state

26middot Chapter 1 Digital Systems and BtnaryNumbers

Registers

A register is a group of binary cells A register with n cells can store any discrete quantity of middot information thatcontains n bits The state ofa registeris an n-tuple ofls middotand Os with each bit designating the state of one cell in the register The C()ntent ofaregister is a function of the int~rpretation given to tbeinformation stored in it Consider fQf ex~ple a 16-bitregister with the following binary content

11 00001111001001

middot Aregjs~ with 16 cells can be in one of 216 possible statesIf one asstimesthat the content cif the register represents a binaryinteger then the register can store any binarydumber from Oto 216 - 1 For the patticularexample shown the content ofthe register is the binary equivshyalent(lftbe decimal number 50121 If one assumes instead that the register stores alpbanushy

middot meric characters of an eight-bit cooe then the content of the register is any two meaningful characters For tht ASCII code with anevenplirityplaced in the eighth most significant bit position the register contains thetwo charactersC (the lefunosteightbits) and I (the rigbt~ most eight bits) If however one in~rprets the content of the register to be four decimal dig- its represented by a four-bitcode tnenthe content of the register is a four-digit decimal number In theexcess-3 code the register holqs the decimal nutriber 9096 The content of the registe~is meaningless in BCD becau~e the bit combinatiOn ltob is 110t assfgned to any decshyimal digit From this example it is clear that a register can store discrete elements of inforshymation and that the same bit configuration Inay beinterpreted dlffe(ently for different types of data

tmiddotmiddotReglsterTrail Adigitalsystenlis characteriZed by its registers and the components thatpetfolin data proshy~ssingIIl digital sy~tems a rcentgister tra1lsfer operation is abasi operation that consists of

middot a transftr of hiJWy hUormation from one ~t of registers into ano$er set of registers transfer may be dir~ctfr9m one regist~r toanlt)ther or may pass througb datamiddotprocessing circuits to petformaD operation Figure L 1 illustratel the transfer of iidOrnuttion among regshyisters anddemonstratespictorlallY [the tr8ll~~ ofbinaryinformation from akeyboard a register in the memQryullit Thehlputunit~s assumed to have a keyboard1 control cuit and aninput register Each time a key is strock the control circuit enters an ImnV$_

lent eight-bit alphanumeric character coqe into the input register We shall assume that code used is the ASCII code with an odd-parity bit The information from the input regisshyter is transferred into the eight-least significant cells Qf a proeessOr register After transfer theinpui register is cleared to enable the control to insert a new eight-bit when the keyboard is struck again Each eight-bit character transferred to the pro1c4ess(raquo register is preceded by a shift of the previous character to the next eight cens on its left~

middot a transfer -of four characters is completed the processor registeris full and its contents transferred into a memory register The content stored in die memOry register shown in Figl came from the transfer of the characters J 0 H an~ N aftet the four ap)lroJ)riatt keys were struck

Section 18 Binary Storage and Registers 27

FIGURE 11 Transfer of information among registers

To process discrete quantities of infoiniatiori in binary form a computer m~st be promiddot vided with devices that hold the (lata to be processed and with circuit elements that manipmiddot ulate individual bits of irifonnation The device most commonly used for holding data is a register Binary variables~ manipulated by means of digital logic circuits Figure 12 il~ luslrates the process of adding two l()bit binary iUlmbers Themeniory unit which no[shy

mally consists of millions of registers is shown with only three ofits registers Thepait of the processor unit showncoDsistsmiddotofthree registers-RI R2 and R3~getherwith digital logic circuits that manipulate the bits of RI and R2 and transfer into R3 a binary number equal to their arithmetic sum Memory registers store information and are incapable of pr0shy

cessing the two operands However th~ information stored in meDij)iybanbetransferred to ~ processor registers and the resUlts obtainedin processor tegisters can be transferred back into ame~ry register for storage Untill)ecded again The diagram ~wsthe90ntents of two

operands transferred from twoJDemoryregisters into RI imd R2 The digital logic circuits produce the sum which is transfened to register R3 The contents of R3 can now be 1riUlsshyferredback to one of thetnemory registers

The last two examples demonstrated the infonncion-flow capabilitieSofa digital system in a simple manner Themiddot registets of the ~ystem are the basic ele~ents for Noring and holding the binary information~igitallogic circuits process the binary ihfonaation stored in the

28 Chapter 1 DigIt bullbull Systems and Binary Numbers

Sum

FIGURE 12 Eumple of blnarylnfonn~t1on processing

registers Digitallogiccirctiits and registers are covered InChQpteB 2 throQgh 6 The metlilOlY unit is ~xPIained ill 9aptet 7 Th~ descriptton of register opetJtions at the register level and the design of digital systems are covexed in Chapter 8

19 BINARY LOGIC

Binary logic deals with variables th~ take on two discrete valueund withoperations that sumelogicalmeaning~ The two val~s the variableussume may be called~ydifferent (true andalse yel and no etc) but for ourp1llpQSe it is cpqVenienttotbink in terms of and assign the values llUld O The binary logic intr0ducedin this section is equivalent to algebra oalledBoolean algebra The fannal presentation ofBoolean algebra is covered in detail in Chapter 2 The purpose ofthis seCtion is to introduce Boo algebra ina matmerandlate it to digitallogiccircuits andmiddotbinarYsignalsmiddot

Section 19 Sinary logic 29 ~

Itkltn of IInary logic

Binarylogic consists of binary v~les and a set of logica1middotoperatiQDS The variables are desigshy ~by lettell of thCalplWlet~such asA B C x yz etc with eaCh variable baving two and oniy

two distinct posSible valueS 1and O There are three basic logical operations AND ORand NOT

1 AN]) This ~peration is represented by adotorby the absence ~f an oPerator For example x bull y =z or xy = zis~ x ANDy is equalto z~ThelogicaloperationAND is interpreted to mean that z == 1 ifand only ift~ land y = 1 otherwise z = O (Reme~r that x y andzare binary v8riablesand canmiddotbe equal either to 1 or Omiddotand nothing eise)middot

2 OR This operation IS represented by a plus sign For example x + y =z is read x OR y is equal to z meaning that z 1 if x = iorif y = lorifbothx= 1 and y = 1 If bqth X - 0 andY Omeo z= O

3bull NOT This operation is repf6sented by a prime (sometimes by an overbar) For ~xample x =Z (or~ =z) is read notdsequalto 1 meiming that z iswkatx isnot In other

words ifx = 1 then z == 0 but if x == 0 tnenz = L TheNOT operationisals(1 reshyferred tolls the complement operation since it changes ~ 1 toOand a O to 1

bull bull lt Binary logic resembles binary arithmetic and themiddot9peratioos ANDahd OR have similarishy

ties to multiplication and addition respectively In fac~ the symbols used for AND and OR are the same as those used for multiplication and addition However binary lOgic should not be conshyfused withbinaryarithIrietic One should realize thatan arithmetic variable designates a numshyber that may consist of many digits A logicmiddot variable is always either 1 or O For example in binary arithmetic we have I +1 =10(read~one plus ()fie is equal to 2) whereas in binary logicwe have 1 + 1 1 (read one OR onds equal to one)

For each combination of the values oix and y bullthere isa value of ~ $pecifiedby the definishytion of the logical operation D~linitiops of logical~perations maybe listed in a compacHorm called truth tables A truth table is atable of anpbssible combinations ofthe variables $howshying the relation between the values that the variables may take and the resultof the operation The truth tables for th~ operations ANDand OR with variables x and y are obtained by lis~ng

all possible values that the variables may have when combined in pairs bull For each combination the resUlt of die operation 18 theillistedin a separate row The truth tables for ANDORand

NOT are given in Table La These tables clearly demonstrate the definitionf the operatibns

Table 18 Truth TcibJts of Logical Operations

AND OR NOT

x y xmiddoty x y x+y

0 0 0 0 0 0 1 0 0 1

10

1 0 d 1 0 1 I 1 1 1 1 1

bull~lt~m

30 Chapter 1

Logk Gates

Digital Systems and Binary Numbers

Logic gates are electronic cirellit that operate on ~

variable

or mpre mput tignals to produce an output signal Electrical signals sUch as voltages orrutrents exist as analog signals having values over a given taDgebull saYOt03 V but in a digital system are interpreted to be either of two recognizable values 0 or 1 Voltage~opetated logic Circuits respond to two separate voltshyage levels that represent a binary varjable equal to logic I bt logic O For example a partic- ular digital system may define 10gicOas a signal equal to 0 volts lind logic 1 asa signal equal to 3 volts In practice each voltage levelhiS an acceptable rangeas shown in Fig 13

The input te~nals of digital cikuits accePt binary signals within the allowable range and respond at the output terininals with binary signals that fall within the specified range The intermediate region between the aJl()wed regions is crossed only during aState transition Any desired information for computing or control can be operated tm by passing binary signals through variQUS combinatioDsof logic gates with each signal represebting a particular binary

The graphic symbols used to deSignate themiddotthree types of gates are Mown in Fig 14 The

gates are blocks of hardware that prooocc tbeequivalent of1ogic~1 orlogic() output signals

Volts

- FGURl13

x

y

Exampleof binary slgnaJs

Signal ratlge for logieO

(a)~omiddotinput AND gate

FIGURE 14 SymbOls for digital logic circuits

(c)NOT gate or invert~

Problems 31

x-lU 1 11 P 0

y 0 0 11 1 ~

ANDxy 0 0 rTl 00

ORX+Y~ NOT x 11 0 0 I 1 1

FIGURE 15 Input-output 5Igals for gates

FIGURE 1

A B C

Gates WIth mlltlple JnpUU

A B C lJ

~

if inPllt logic ~ts are satisfied Theinput signals xaDd y intheNDaadQR gates may exist in ~ oHow-possible states 00 10 11 or 01 Il1ese ibpu~ampignals_ shown inFig lStoshygetber with the corresponding output signal foreach PfCThI~tiaiug~iDustrate the reshysponse ofeaclt gate to the four input signal~The~llisofthetiminadiagram represents time and the vertical axis sbo~~~~ it cbapg~botwcen~possible voltshy

age levels The low level represents logic O tJte high level l1lteAND _ responds With a logic ~ ~tput sipl wh~ both input ~~)e 1middot1~ lIieOR S-~with a logic 1 outpUt signal ifanylnput sigrudis lOgic 1 TheNOTgateis~~ to BUll invedet The reason for~nameis~t froJn the signalmsponae inmiddottbe timitt8 diagramwhicbsbows that theoUtputsignal inverts the logic sense of tbeiDpUtsigll8l

AND and OR gates may bavei)lQte tbantwQinputs M AND8_~itti ~input$andan OR gate with foU) inputs are shown in Fig 16 The three-inPllt AND gate responds With logic 1 output if all tbreeinputs arelogic 11jleoutputproduces lOgic Oifanymput is logic O-The

four-input OR gate responds withlogic 1 ifany input is logic 1 its clu1ptltllCCoines logic oonly when all inputs are logic O

Answers to prvblems marked with middotappearaHbe ClOd ofthe ~

11 lJltthe octal and beXadecimalliurilbers trom16ui 32UdngA B1l1ld C forthebst~ digits Usttbe numbers from 8 to 28 in base13 bull

I

12t What is the exact D1Jllbcr of bytes in a system that contains lta) 32Kbytoe (b)64M ~and (e) 640 byte$ middot7 t

32 Chapter 1 Digital Systemsand Binary Numbers

13 Convert the following nu~bers with the indicated bases to decimal (a) (4310)s (b) (198hz (c) (735)8 (d) (525)6

14 Whllt is the largest binary number that can be expressed with 14 bits WhlIt are the equivaleDt ~~ iinal and hexadecimal numbei-s

--

15 Detemrine the base of thl1 numbers in each case for the following operatio~ to be correct (a) 142 = 5 (b) 5414 = 13 (C) 24+ 17 == 40

16 The solution$to the q~cequation xl - Ux +22 oare l1 3 arid x =6 What is the base of the numbers

17 Convertthehexadecimal ntmIher 68BE to bitiary and then convert it ~mbinary to octal

18 I Convert the decirpal number 431 to binary in tWo ways (a) Convertd~y to binary (b) conshyvert first to hexadecinla1 and then from ~decimalwbinary Which method is faster

19 amppress the following nqrnbersin decinud (a) IQ11O0101)z (b) (l65his (c)(2624)8 (d) (FAFA) 16

(e) (10101010)2

110 Convert the following binary numbers tobexadeoimal and todecitnal (a) UOOlO (b) 110010 Explain why the deCimal answer in (b)is 4 times that in (a)

111 Perform the followingdiviskmin binary 11 Ion + l()t

112 Add IlniImultiply tfle following numberswiihout converting them to decimal (a) Binary nuniberilOll aiIdlOh (b) He~uumbers 2E aDd 34

1~)( Do thefoHowing con~ersionproblems (a) CorivertCiecimal2731S to binary (b) CakUlate the binary eqUivalent (f 213 outto eight pl~Then Convert from binary to

imalHowgJose istbe result to 2131 (c) Convert the binary resukin (b) into hexad~ lb~oonvert ~result to decimal Is answer tbesame

114 Obtain the is 8nd 2s complementsofthe foUowing binaryDumbcentrs (aj l)()()(J()OO (b) OOOOOOOO (c) 11011010 (d)01l10110 (e) 10000101 (0 11111111

115 Find the 9s and the 10s complement of the following detimal numbers (a) 52734630 (b) 63325600 (c) 25000009 (d) 00000000

116 (a) Find the 16s complement of B2FA (b) Convert B2FA to binary (c) Find the 2scomplement ofthe resultin (b) (d) Convert the answer in (c)to hex~malandco~ with ihe an~wer in (a)

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 8: Chapter 01 - Mano

middot8 Chapter 1 Digital Systems iilnd Binary Numbers

Ibo oonversion ofdecimalnumbers withbotMnteger and ftattionparts is done by con- vertingthe integer and the fraction separately and ihencombinihgthe two answers Using the re$Ults ofExamples 11 and l~ weobtain

(416875h~ (lOI001l011h

From Examples 12 and 14e have

(1535130 (2314tl6517)s

14 OCTAL AND HEXADECIMAL NUMBERS

The conversion frOm and to binary octal and bexadecimal plays an important role in digital computers Since 23 =8 and 24 = 16 each octal digit corresponds to thref binary digits and bull each hexadecimal digit corresponds to foUr binary digits The first 16 numbers in the decimal binary oct8r andhex~ecimalnumber systems are listed in Table 1-2

The comersion fm~ binary tooctal is easilyacltooiplishedby partitio~ng the binary num ber into groups oftbree digits each starting ti()n1 the binary plmt and proceeding to the left

I and to the right ~correspo~ octal digit is then assigned to each group The following example illustrates the proeedure ~

(10 110 001 101 011 11~ 100 000 lloh = (261537406)8 2 6 1 ~ 3 7 4 0 6

T_lel2 Numbers with Different-Baus

DecImal IY Octal Hexadecimal middot(base 10) (base 2) (b) (16)

i

00 0000 00 p 01 0001 01 1 02 0010 02 2 03 0011 03 3 04 0100 04 4 0 0101 OS 5 06 0110 06 6 07 0111 07 7

08 1000 10 8 09 1001 11 9 10 1010 12 A 11 1011 13 B 12 1100 14 C 13 1101 IS D 14 1110 16 bull

Ej

IS 1111 11 F r i

9 section 1S Complements

Conversion from binary to heudeciInal is similar except thatthe binary nutriber is divided into groups ofourdigits

(10 1100 0110 1011 1111 0010h = (2C6BJ2) 16

2 C 6 B P 2

The comsponding heX~ima1(o~ octal)~digit fOr each group of binary digits is easily reshymembeled from the values listed in Table 12

Conversion from octal or hexadeciInal to Jlinary is dOne by reversing the preceding proceshy(luremiddot Each octal digit is converted to its tbi-ee-digit binary equivalent Similarlyeach hexashydecimal digit is convertedioits four~digitbinaryequivalent1he procedure is illustrated in the following examples

(673124)8= (110 6

III 011 7 3

001

010 2

l00h 4

and

(306Dh6 = (OOlf 0000030shy

110 6

~101h D

Binary numbers are difficUlt to work with because they require three or fout times as many digits as their decimal equivaltmts Por exaniple the binary number 111111111111middotis equivalent to decimal409S Howeverdigital computers use biIUuy11UIhbers and itis soIIJet4nes necessary for the human operator or user to oonununicatedirectly With the machine by means of such num bers One scheme that retainsthebinary~ystem in the cotnputer but reduceS the number of digshyits the human must cOnsider utilizes the relationslripbetyeen the binary Ilumber system and the ~ or hexadeciinal system By this method the Ql1DaIlthinksin tenns ofQCtal ornexadecimal nurnbers and performs the required conversion by inspection when direct communication with the machine is necessary Thus thebinary number 111111111111 has 12 digits ~d isexpressed iIi octal ~ 7777 (4 digits) or in hexadecimal as FFF (3digits) During communication between people(about binary numbers in the coJlllQter)the octal or hexadecimal representation is more desirable because it can be expressed more compactly with a third or a quarter of the number of digits reqUired for the eqwvalent binary number Thusmpstcomputer manuals use either octal laquohexadecimal numbers to specify binaryqwintiti~ The choice between diem is arbitrary although hexadecimal tends to win out since it can represent a byte with two digits

PlEM ENTS

Complements are used in digital cOmputers to simplifydle subtraction operation and for logshyical manipulation Simplifying operations leads to simpler less expensive circuil$ to implement the operations There are two types of complements for each baSe-r system the radix comshyplement andthe diminished raclix cOtllplement Themiddotflrst is referred to as the rts complement and the second as the (r - middot1)scomplement When the value of the base r is substituted~ the name the twotypesare refefted to as the 2s complement and 1 scomplement fot binary numshy~rs and the lOscompl~ent and 9s complement fqrdecimal numbers

10 Chapt~rl Digital Systems and Binary Numbers

D~I~llhed Radix Complame~middot Gi~en a number N in base r haYing n digits the (r - 1)scomplement~f N is defined as

(rll - 1) ~NFotdecimainumbersr -= Wandr -1 9sothe9scomplementofNis (10 - 1) - N IIi this c~ 10 represents a number that consists of a single 1 followed by nOs 10 - lisartumberrepresentedbyn9sFOrexampleifn 4wehavel04 = 10000 and 104 - 1 = 9999 It follows that the9s complement ofa decimaJnumber is obtained by subtracting each digit from 9 Here are some nwnericalexamples

The 9s complement of 54670(Ms929999~ 546700 453299 bull - I

The 9scothplement of012398is999999~0l2398 =987601

For binary pumbers r =2 and r - l~ 1 sothe 1s complementofNis(Z - 1) - N Again 211 is represented by a binaty number thatconsistsofa 1followed by Ii0s 211 - 1 is abinary number represented by ~1s~FOr example if 11= 4 we have z4 = (10000)zand 24 - 1 = (1111h Thus the ls complement of a binary number is obtained by sUbtractiDg

each dig~t from 1 However when subtracting binary digits from 1 we can have either I -0= lor1 - 1 = 0 which causestbe bit to change from Oto 1 0( from 1 to 0 respec- tively Theretore the ls complement of a binary number isfonnedby changing 1s to Osand Osto 1s The f9llowillg are somenumqical ex~esI

~

The ls Complement of 1011000 isotOOiu

The 1scompieme~t oHlIOUOI is 10 tOOlO

The (r-l) s compleme~ ofoctal or b~xadechnalnumbers i~6btained by subtracting eaeh digit from 70rF (diicimallS) respectively~

Radl~ C~mplement

The s complement of an n~digit number N in baserisdefinedasrmiddot Nfot N i 0 and as ofor N = O~ Comparing with the (r- l)s ~entwe note that ~rs complement is obtained by adding Ito the (r - l)scomplement smcer - N= HA-- 1) - N] L lhus the lOscomplementof deein1al2389 is 76lO +1 = 7611 and is otltamed by adding 1 to the 9scomplernent value The 2s oomplementofbinary 1011oois 010011 1 =010100 and isobtained by adding 1 to the ls-complement value

Since 10 is a number represented by a 1 followed by n0s1011 N Whicb is the10S com~

plementof N can be fonn~d also by leaving allieasl sigtrlficani Os Unchanged the first nonurO least significant digit from 10 and SUbr8Cting all higher significant

from9 ThUs

the 10s complement of 012398js987602

and

11 Sectlon middot15middot Complements

The 10s complement ofthefustnumber isobtaineltibysublriiCtingSfrom lOin the least sig~ nificant position and subtracting all other digits from 9~ The 10s complement of the second number is obtained by leaving the to least significant Os unchanged subtracting 7 from 10 and subtracting the other three digits from 9

Similarly the 2s complement ~be fonned by leaving 1ll11east significant Os and tbe first 1 unchanged and replacing I swith Os and Os with ls in allother hi~r signifIcJUlt digits For example

the 2s cORlplement of 1101100 is 0010100

and

the 2scomplement ofOllOllHs 1001001 _ - r

The +s complement pf therrrst nJUDber i~ obt4iriedby I~vingthetwo least significant Os and the first 1 unchanged andmiddotlQen replacing ls with Os and Oswith 1~ in the other four most sigmiddot nificant digits The 2s lXgtmplement qf the second number is obtained byleaving the least sigshynificantmiddotl unchanged and (fOmplementing all other digits

In the previous definitions it was assum~dtMt the D~bers did not have a radix pomt1f the original number Noontains a radix point the point should be removed temporarily in order to form the s or(r 1)s complement The radix point is then restored to the c9ll1plementshyednumber in the same relative PositionIlis abo wOrth mentioning thatfhecontplement oftbe complement restoresthe number to its original v41ue To see this rel~tionsbipnOtethat the ts complement of N is n - N so that themiddot complement oft1e complement is n - (n - N) == N and is ltlqual to the original number

Mr8Ctiton wltl1 Complementsmiddot

1le direct metb()jiofsubtraCtion taught in elexnentaty schpOls uses the bottow concept In this QlCth9dwebortowa I from a middothigher significant position when the minuend digit is smaller than the subtrahend digit The tDethod wor~wen when peOple perfonnsubtraction with paper andpeooillIowever when subtlaction is implemented withdigi1al bardw8le the method is less e~citnt than the method that u~s compl~m~ts

The subtraction of two n-digitunSigneq numbers M N in base can be done as fonows I

1 Add the minuend M to the scompleme~t of thesubtramphend N Mathematically M+ (n N) = M N +

2 IfM ~ N ttie sum wiUproduce an end cury 11 which caD be discarded what is left is the resultM N

3 If M lt N the sum does not produce ~tlend carry JUld iseijUattor (N~ Ji) which is the s complement of (N - M) To obtain the answer in a familiar form take the s complement of the sum aruI place a negative sign in frorit

12 Chapter 1 Digital Syst-ems and Binary N~mbers

The following examples illustrate the procedure

plPi1I VsinglOs complement subtract 72532 - ~250

M = 72532

lOs complement of N + 96750 Sum= 169282

Discard end caIry lOS = -100000 Answer = 69282

Note that M bas fiv~ digits andN has only fourdigitsBoth numbers mtast have the same numshyber of digits sowe wrlteN as 03250 Taking the lOscomp~ementofNptOducesa9 in the most significant PositionThe occurrence of the end carry signifies that M ~ N 8ndtlult ~ result is therefore positive

Ulling 10s complement subtract 3250 - 72532 - ~ ~

M = 03250 JOscornplementof N =+27468

Sum= ~0718

There is no end carry Theref()re-theanswer is--(10amp complementof30718) == -69282 Note thatsince 3250 lt n532~the result is negative Becauwe are dealing with WUiigned

numbers there is really no way to get BnunSigned result for this case When subtracting complements we reoogilize the negltive answer from the~sence of the end carry and complemented result When workingwith paper and pencil we c8nchlnp the aDswer

signed negative number in oider to putH inafamiliar form Subtraction with complements is done with binary numbers in a similar manner uing

procedure outlined previously

EXAMPLE 17

Given the two binary numbersX = 1010100 and Y =1000011 performtbe $UbiDctiG (8) X - Y arid (b) Y - Xby using 2scomptem~ts -

f

- -

Section 15Complements 13

(a) x = 1010100

2s complement ofY= + -0111101

Sum = middot 10010001 Discard end carry 27 = 10000000

Answ~ X- Y = 0010001

(b) Y == 1000011 2sco~lement of X = + 0101100

Sum= 1101111

There is nQmiddotend carry Therefore the answer is Y ~X= -(2sq)mplement of 1101111) = -0010001 Subtractionof unsigned D1lJllbers ~ also bed()neby means of the (r - 1)s complement Remember that the(r- l)s complement is one lesstharithers complement BeCause of

ibis the result of adding the minue~ to tJte coQlplement of the subtiah~ndPtOductS itsum that is one less than the correct 4ifference when an end carrY oCcurs Removing the end carry and adding 1 to the sum is referred to asan end-around carry

Repeat Example 17 but this time using rs complement

(8) X y = 1010100 - 1000011middot

X= 1010100

rs complementafY= + olfnoo Som = 10010000

End-arOundmiddot~ =- ~ ~ Answermiddot X Y= middot0010001

(b) Y - X = 1000011 - 1010100

Y = 1000011

1s complement ofX = +0101011

Sum = 1101110

There is no end carry TherefOre the answer is y - X = -(1s complement of 1101110) = -0010001

bull Note that the negative resultis ob~ by taltingtbe 1 scomplemeilt of theJWltsince this is the type ofcoDiplementused The procedwewithendaroundoanyis aIs(gt Iijlpliclbleto subshytracting Unsigned deciImdnumQers with 9seomPlement

14 Chapter 1 Digital Systemsand BinayNumbers

16 SIGNED BINARYNUMBER$ ~

Positiveintegers (including zero) CaBbe ep~~ 11$ unstPecl numbers However to repshyresent negative integers we need a notation for negative srn ordinary arithmetic a negshyative number is indicated by a mulUs signmdapOsitiv~Pwtlt)e~ by aplus sign Because of lJardware limitations computers mlstrepresenlev~With~ digitsIt is customary to represent the sign witb a bit placed intheleftmotp6sitiolwfthe number The convention is tltl make the sign bit 0 for positive and 1 for negative

Itis important to realize that botp siped and unsignedtDnary 11UJDbers consist of a strfug of bits when represented in a com~ TQeuser detem1inesWbether the number is signed or unsigned If the binary number is signed then the lefuriostbitreple$ellts thtsign aud the rest of the bits represent the number Ifthebinaryllu~beiis~ tObe unsigned then the left most bit is the most significant bit of the l)uMber Fdre~the~~f bits 01001 can be consideredas 9 (unsigned binary) or as +9 (Sighedbitia1j) ~USJtheteftmostbit is O The

string ofbits 11001 represents the binary ~~v~ento~ ~w~nc~idered as an unsigned number and the binary equivalent of 9whenconsidered1l si~riumPer This is because the Ithal isintbe leftmost positiondesignatesampC nega6ye_~QtherfourJ)its represent bishynary 9 usually tlere is no cotifusionin identifying thebits~the~Qfrepresentation for the number is known in advance ~

The representation of the signed numbers in the lastexainple is referred to as the signed magnitutk coDvention In this ~otati()nthenurnber C4mSiampesOCa mQ~~andil~ymbolH

or -) or a bit (0 or 1) indicating the sign This is the representation ampr~~used in ordinary arithmetic When arithmeti~ operatioBslllieimplerneJltcldin~cOQlPuter hii more convenient to use a different systemrefetred t(gt as the si~cqmptement system~ for repre- senting negative numbers In thissystlm a neg8tielliun~r isjhdic~ted by its cornplc~mc~nt Whereas the signed-magnitude system negates a nlllllher by cbanging its sign me signed-comshyplement system negatesanwnber bytakin$ its~OinPleltleitiSinoepositife numbers always start witbO(plusin tte leftmost pOsition thecompktllint wiilalwaysstart with a 1 indicating a negative number The siped-complemelt system can use olthertbe 1s Or the 2s but the 2s complement is the mos~comtliOfi

As an exampleconsider the number9re~~ed in binary with eight bits + 9 Is sented with a sign bit of Oin the leftri1ostpOsition oIIOv~by the binary (equivalent of 9 which gives ()()()olOOl Note thai all eigbtbits must haYampa v~therefore O~s are inserted folshylowing the sign bitllp to the first 1 Although ~ is only 01K way to tepresent +9 there three different ways to represent 9 with eight ~its

s~gned~magnituderepresentation 10001001

sigried-l s-complement represe~on~ 11110110

signed-2 s-complemerit representatim 1ttltllU

In signedmagnituamp -9 isobwned from +9 by changing the sign bitmtbe leftmost ~iti(ln tromO to L In sigl1ed~ lroomplement 9isobtaidedtf~~tiog all the bits of includinj the sign bit Thesigned-2~sco~re~Qf-9 is obtampDedby ihe 2s complement oftbepOsitivenumberincludingtbesijnbIt

Sectlont6 SIgned8lnary NumberS is

Table 13 Slgtlfd Biliary Humbm

+7 +6

+5 +4 +3 +2 +l +0 0 -I

-2 -3

4 -5 -6 -1 -8

Olll 0110

0101 ( 0100

001l 0010 0001 0000

IIll 1110

nOI noo Ion 1010

1001 1000

OIll Oito eHOl OHIO OOU 0010 0001 0000 1111 1110middot dOl 1100 Ion

lOti 1001 1000

0111 OUO 0101

0100 0011 0010 0001 0000 1000 1001 1010 IOU 1100

1101 1110

lUI

Table 13 lists all possible four-bitsignedbinaryaumbers in the three representations The equivalent decimal number Is also shown for refelenoeNote that the positive n~ in all three representations are identicaland have 0 inthelefmostpcsiticm The signed2sshycompl~mentsystemhaironly onemiddotrepresentation for 0 which is always po$itive The other tw()systetns- mlve either a positive 0 or a negative 0 sometbingnoteDcounteredin ordinary arithmetic Note that all negative numbenhave alin the leftmost bitpositi~ that is the way we distinguish them from the positivenumbers With fout bits we can repreSent 16 binary numbers In the signed-magnitude aDd thelscomplement repre$eDtatipns there are eight positive numbers and eight negative numbers inciUdingtwo zeros In the2s-complement representation there are eight positive numbers includi0a one zerQ and eight negative numberS

The siped-m_gnitude system is used in ordiIlary arithmetic but is awkward when emshyployed in computer arithmetie becauIe of the ~parate bandIinJ bfthesipand the magnitude Therefore the signed-compiement systeni is normallyused The ls ~t imposes some difficulties and is seldom USedJor arithmetic openitiOns It is U$eful aSa lo~ operation since the change of 1 to Obrmiddot() to 1 is equivalent to a logical complement Operation as will be shown in the next c~The discussion~f sigiled binary ariduneti~ that fol10ws deals exshyclusively with the signe4-2soomplt_nt~tatJonQfnegadveilUlilbers hsame proshy

cedurescan beappJied to the sigMdrs-comPlemeD~Iysby incIudiOI tbe~arotmdcarry as is done with unsigned numbers

J6 Chapt~r 1 OlgltalSystlf(ns and Binary Numbels

Arithmetic Addition

The addition of two numbers in the signed-magnitudelYs_foUowsthe rules ofordinaiy arithshymetiC Ifthesi~s arethesam~we addthetwOtt~gni1U~~d ~vetbe sum the CCmmon sign Iftbe signs are diffe~nt we subtract tllcsmaUermagnitude frOtnlthe larF and give the differshyehtethe signof the larger magnitude For example (+25) +( - 37) = ~ (37 - 25) = -12 and is done by subtracung the smaller magnitude 25 from the larger magnitude 37and a~nding the sign of 37 tGtbe result Ibis is a process that requires a corripanson of the signs and magnitudes and then performing eithr additi()n or subtraction The same procedure applieato binary numbers in sigped-magnitude representation~Incontrast the rule for adding numbers in the signed-corppleme~ sy~tem does not require a comparison or su~ traction but only addjtion The procedure is very simple andcanbe stated as follows for binary numbers The 8ddltion oftwo signed binary numberS with negative numbers tepresented in signed- 2sComprement fonn is obtaiIled from theadditlooofthe two numbers includingtheii sign bits

AcentiirrY out oftbe sign-bitposition is diScacded NumerIcal e~aihpledotai1dition follow

+ 6 00000110 - 6 11UI0tO I

+13 00001101

+13 00001101 +19 00010011 + J 0Q900111 + 6 00000110 6 11111010 ~13 11110011 -1~l 11110011 7 illl1001 -19 11101101

I bull bull ~

Note that negative numbers musthil iriitially in 2seompkmentform and that if the swn ~ ~afterthladdit40nis negativeins in2s~p~t fOl1Jl - In each of thefoDrcasestlteoporationperfol1JlC(lis additionwitb the sign bit iilcluded Any catTY o~of~~-bit~onisdisc~ and negative resultsareButomaticallyin 2sshyromplementfoon

In order to obtain acOrrect answer we mustensQre that the result has a sufficient of bits to accommodate the swnlfwestartwith t~on-bltnumbers and tbeswn occupies n + 1bits we say tblltan overflow occurs~Wheri one perfotmStbc ad(JitiOJl with nllllIPTJllVIl

pencil aq overflow is not a preblem because we arcr noflimitecLbythewidth of the page jUst addanothcentr 0 to apositive number or another 1 toa negative number in the mOst cant positi()n to extend thenwnber to n+ 1 bitSand theQ perform addition Overflow is

problem in computers beqiusetbe number ofbi~~ bolla ~befis finite and a result ex~ tI1efinite val~e hy lcatmotbe accommodated

The compJement form of representiQg negativetlQUlbers is unfamiliar to those usedto signed-magnitude system To itetermine th~ value of II negatienumber insiped-2s COlIlpJe

mentit0is~ to CODVerttbe numbcr to apositie ntirit_ ~ place itiDa more formPor ~plethesig~binary number qUl00~ lii~egativebecausothe leftmost

t 1182s c0J8plemen~js~UlwhUhi$~ binaryeqqivalen of +7Wcmiddottherefore nize the Ori~nal ~atiy-eQumber to be equ~ lo-7 1

Sectlonl7 Bh1ary Codes 17

ArIthmetic SubtractIOn

Subtraction of two signed binafy numbers whe~negative numbersare in2s-complement form is simple and can be stilted as follows

Take the 2s complement of the5ubtraltend (including the sign bit) and add it to the minuend (including the sign bit) A cany oU1of thesignbit position is discarded

This prOCedure is adopted because a subtraction operation can be changed to an addition operation if the sign of the subtrahend is changed as is demonstrated by the following relationship

(plusmnA) ~ (-tB) = (plusmnA) + (-B) (plusmnA) - (-B) =plusmnA) + (+B)

But changing a positivetwober toa negative n~ber is eaampily done by taking the 2s compleshy mentof the pQsitive number The reverse is also tiUe~use theCOmPle~n~ of a negative numshyber in complement form produces the equivalent positive number To see this consider the sJlbtr~ction ( 76) -- (13) = +7 In binaIy_ with eight bits this ()peiationis written as (11111010 11110011) The subtracti~ri ischmlged ~ addition by taking the 2s complement ofthe subtrahend (-13) giving (+13) In binaly tbis~ 11 niOlO+ 00001101 = lOOOOOU1 Removing the end~ we obtain the ootrect answer ()()()()() III (+7)

Itisworth noting that binary DUmbersinthe signed-complement system are added and subshy tracted by the same basic addition and suPtraction rules as unsigned numbers Therefore comshyputersneed omy one common hardware circuit tobandle bothtypcs ofaritbtnetic The user or programmer ~ust interpret the reswtIi of $l1ch addition or subtraction differently depending on whether itisassumedtha~the numbe~ are signed ltr tinsigned

j

BINARY CODES

Digitalsystems use signalsthat have two distinct values1Uld circuit elements that havetwostashyble states There is a direct analogy anrong binary iignals binary circuitelements and binary digits A binary number ofndigitsfor example may be represented by n binary circuit eleshyments each baving an output sig~alequivalen1to Oor I Digital systems represent (Uld mashynipUlate not omy binary numbers but alsO many other diScrete elements of information Any discrete element of informatioIidlat is dis1iilct among agroup of quantities can be represented witha binary code (Le a pattern of Os and fmiddots) The codes must be in binary because in todays techIiology omy circuits that represent and manipulate patterns of 0s and ls can be manufactured economically foru~ in computers However it mtistbe realizCd that binary codes merely change the symbols not the meaning ofthe ele~nts of infonbationthat they repshyresent IT we inspect the bits of a computer at random we will find that mostofthe time they represent some tYPe of coded information rath~ than binlUY numbers

AIln-bit binary code is a groopofn hits that assumes up to 211 distinct cOmbinations of ls ~d Os with eacn combination representing one elementof tnt set that is being coded A set

of four elements clab becoded with two lilS with each ~lementassignedoneof thefoUowing bit oombinationsOOO I 10 J 1 A set of eight elements requiies a three-bit code 00 a set of

18 Chapter 1 Digital Systems and Binary Numbers

J6 elements requires a fourmiddotbit code The bit combination of ann~bit code is determined the count in binuy from 0 to 21t - t Each element must be assigned a unique binuy bit binationand no two elemerits cm havetbtsamevalueothenvisethe code assignment be ambigUous

Although the minimum nqrnber of 1lits required to code 21t distiItct quantities is nthere nomaximwn numbe( of bit that may he used for a binuy code For example the 10 digits can be coded with 10 bits and each decimal digit can be assigned a bit combination nine OSmid a 1 In this pamcularbinarycode the digit6 is assigned the bit )UllIUlauuu0001000000

BCDcode

Although the binary number systemis die ~ost natural system for a computer most people more accustomed to the d~imal system One way to resolve this difference is to convert

inlal nUmbers to binary perform all arithmetic calculations in binary and then convert the nary results back to decimal This metbodrequites that we store decimal numbers in

cOinputer so that they canbec6b~rted to binary Since the compllter Can accept only valueswe must represent the decimal digits by means ofa code that contains ls and Os also pOsSible lopedorm the arithmetic operlltiorisd1rectly on decimal numbers when they stored in the comput~ in cod~ct form

A binarycodewill have some unasSigned bit com~inatiqns ifthe num~rofelements in set is not amultiple power of 2 The 10decimai digits form such asel A biruuy code that tinguishes among 10 elements must coiltain at least four bits but 6otitofthe 16 possible binations remain unassigned Different binary code$ can bemiddotoNained by arranging four into 10 distinct combin~tions TheicodeIllcfflt oommonly used fdr the decimal digits is straight binary assf~ntlisted in Table 14 This scheil)eis called bittary~coded decimal

is commoolyreferred to as BCQ OtherdecimalcodesaIlfpossible and a few of them are sentedlaterinthis section

Table 14 BinarymiddotCoded Oeclmql (BCO)

Decimal BCD SnlboiDIgIt

o 0000 1 0001 2 0010

3 0011 4 middot0100 5 0101 6 0110 7 0111 8 1000 9 1001

Sectionmiddot 17 BInary COdes 19

Table 14 givesthe four-bit code for one decimal digit A number with k decimal digits will require 4k bits in BCD Decimal 396 is represented in BCD with 12 bits as 0011 10010110 with each group of 4 bits representing one decimal digit A decimalmiddotnumber in BCD is the

- same as itS equiyalent binary number only when the number is between 0 and 9 A BCD numshyber greater than lOJpoks different from its equivalentbinary number even though both con tainls and Os Moreover the binary Combinations 1010 thrpugh 1111 are not used arid have no meaning in BCD Consider decimal 18SlUld its corresponding value inBCD and bUtary

(185ho = (0001100001Ol)BCD = (l0111001h

The BCD value has 12 bits to encode the characters of the decimal value but the equivalent binary number needs only 8 bits It is obvious thatthe representation of a BCp number needs more bits than its equivalent binary value However there is an advantage in the use ofdecishymal numbers because compUterinput and output data are generated by people who use the decshyimal system

It is important to realize that BCD numbers are deCimal numbers and not binary numbers although they use bits in tbeir representation The only difference between a decimal number and BCD is that decimals are written with the symbOls 0 1 2 9 and BCD numbers use tbebinarycode 00000001 001O~ bull 1001The decimal value is exaCtly the same Dec~mal 10 is represented in BCD witheight b~ts as 00010000 and decitna1J5as 0001 01Of1lte corshyresponding binaryvalues are 1010 and 1111 and have only four bits

Consider the addition of two decimal digits in BCD together with a po~ible carry from a pre- vious less significant pair ofdigitsSince each digit does not exceed 9 the sum cannot be bull greater than 9 + 9 + 1 = 19 with the 1 being a previous carrySllppose we add the BCD dig-

its as if they were binary numbers Then the binary sumvill produce It result in the range from degto 19 In bin8ry thistange wil[be from 0000 to 10011 butin BCD it is frOm 0000 to

I 1001 with the first (ie leftmost) 1 bemg a carry and the next fo~ bits being the BCD sum When tPe binary sum is equalto or less than 1001 (withaut 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 (0110h to the binary Sum cOnverts it to the correct digit and also produces a catTy as required This is because a carry in themost significant bitposishytion of the binary sum and a deCimal carry differ by 16 10 = 6 Consider the following three BCD additions

4 0100 4 0100 8 1000

+S +0101 +8 +1000 +9 1001 9 1001 12 1100 17 10001

+0110 +0110----

10010 10111

In each case the two BCD digits are added as if they were two binary numbers If the binary sum is greater than or equal to 1010 we add 0110 to obtain the correct BCD sum and a carry In the flIst example the sum is equal to 9 and is the correct BCD sum In the second example

20 Chapter 1 Digital Systems and BInary Numbers

the binary sum produces an iJlv~ BCD digit The addition of0110 produces the cortect BCD sum 0010 (ie the number 2) and acanyInthetbirdexample the binalY SUDlproduces acany This condition occurs wben the $W)) is greater than or equal to 16Altbough the other fout are less than 1091 the binary 9Ulll requires acOnectionbecause of die carry Adding 0110 obtain thetequiled BCD sum 0111 (ie the numblaquo 7) and 8 BCD CiUT

The additionoftwondigit unsipedBCD numbers follows the same procedure COIlSioll the addition of 184 + 576 1= 76() in BCD

BCD 1 I 0001 10000100 184

+6101 ~

0111--- 0110 +576

lJinarysum 0111 10000 1010 Add6 ono 0110

BCDsun 0111 0110 0000 7(1)

The flfSt l~ sigDiticant pili- of BCD digits produces aBCDdigi~SllDlof 0000 and a for the next pair of digits the second parr or BCD digits plus a ~Vi0U8 cany produces a sum of 0110 and a carry for the next patr()fdigits The third pair of digits plus acarry proltIUC~ a binary s~ of 0111 and does not require a correction

Decimal Arithmetic The represeiltation of signed decimal numbers in BCD is simiiarto the tepresentation of numbers in binaryWe can useeitheI the familiar signed-magnitude system at the SllZllOO-COI1I

plemelit system The sign of a decimal number is tJSually represented with four bits to to thefour-bit code ofthe decimal digits Itis customary to designate 8 plus With four Os 8 minus with the llCDequivalent oi9 whlcq is 1001 The sigiled~magnitudesystem is seldom used in com~tersThe signed-complerDem ~~ either the 9s octhe 10s complement put the lOscomplement is the one most useP To obtain the lOs complement of aBCD numberwe first take the 9s complement then add 1 to the least significant digit The 9s Complement is calculated from the subtracloo of each digit from 9

The prltXeduresdevelope4 for the signed-2s-complement system in the ~vious also apply to the signed-IOs-complement system for decimal mimberS Addition is done summing all digits including the sign digit and discafding the end carry This operatiQ assumes that all negative numbers are in 10s-complement form COOsider the (+375) + (-240) == + 135 done inthe signed-complement system

o 375

+9 760middot

o 135

lhe 9in the leftmost pOsition of the second n~ber tepresents a minllS and 9760 is the complement o( 0240 The two numbers are added and tbe end carry is discarded to +13SOfcourse the decimal ntmlbers insi~ tile computer includingthe sign digits in BCD The addition isdone with BCDOigits as described previously

Sectionl 7 Binary Codes 21

The suQtr8ction of decimalliUJ1lbets either unsigned or in thesi~-~Oscomplement systetn is the sameu in the binary case Taketbe 10s ootnplementof the subtrahend and add i~ to themin~nd ManyooDlputerslULvespeciaJ hardware to perform arithmeticcalculations directly withdecilnal oumbers in 8tDThe~u$etofthecoBlPuter can specify programliled Wtnlctionsto JOdonn the aDtiuJletiP oPmwoowithdeQmal n1UQ~ ~ywithout having to convell them to binary

Binafy codes for decimal digits requirea minimum of four bits per digit Many different codes can be formulated by~gjng four bits into IQ distinct combinations BP) and three other representative codes are shown in Table L5 Each code uses only 10 out ofa pOssible middot16 bit combinations that can be arranged with four bits The other six Unused cOmbinations have no meaning amt should be avoided BCD and the 2421 code are examplesofweigbted codes In a weigbtedcodeeach bit position

juBsigned a weighting f~in~awaythat eaehdigitcanbe ev~by 8dding the wei~ oran the lsin thecoded combination The BCD code has weights of8 42 and I which cotteshy

spondiothe powe1Of-two valuesofeaCh bitTbebitasSignmeatOll0 for example is interpreted by the weights to represent dedma16beCause 8 X 0 +4xt +2 Xl +IX 0 6Thebit combination 1101 when weighted by the ~ve digits 2421 gives themiddotdeCimal equivalent of 2 X I +4 gtlt I + 2 KO + 1 X 1 = 7 Note that some digits cantle coded in lw9 possib)e

ways in the 2421Q)(feFOr inke decimal 4 can be asSigned to bitCombinadon 0100 or 1010 since botbcOmbinatibns add upto a totalweight of4

middot1$ Fou Dlf(et Blnqry Code$ for thtJledmol DIgits

~ IICD DIgIt sal MZt Exeet) 8 4 -~1

0 1

000() middotmiddotmiddot0000 001)1 0001

oem 0100

0000 0111

2 0010 0010 0101 0110 3 0011 OQU 0110 0101

4 0100 0100 0111 oroo 5 0101 lOll 1000 1011 6 OlIO middot1100 1001 1010 7 middot0111 1101 1010 J001 8 1000 IUOmiddot 1011 1000 9 1001 11U 1100 1111

1010 oloi 0000 0001 Uaused IOU 0110 middotOOOl 0010 bit 1100 0111 0010 0011 combishynations

nOl 1110

lOW 1001

HOI 1110

1100 1101

1111 IOU) 1111 1110

22 ChaptfrliDfgltalSystemsaod Btoary Numbers

I1te 2421 rind the

e~l3~es are exampks Of self-complementing codes Such codes have~propertyjbatthe9s~plement ofa deCimal nfunberigobtairted directly by chang-

ing 1$ to O~$ finO tYSCfb1 sie~bycomple~mmgeaCh bit in the pattem)For example decshyimat3~Sis re~ fu tbeexcess3code as 01101100 1000 The 9s compl~ntof 604 isrepRse~l00liOOllelliwbich isobiainc(himply by complementing each bit of the

code (as with the 1 s coinpl~ofbin~rillDlbers)middot Theexcess~3code has been used in some oldel coritputers because of its selfcpmplement~

ing property Excess-3 is an unweighted code inwhich each codedcombinationis obtained-fJQm the corresPonQing bin3ryvalueplus 3 Note that the BCD code is1~ self-complementing TheS 4 ~~ Icode isan example of assigning both positive and negative weights to ~ decimalcodeInthis case the bit combiDation 0110isin~reted as oecimal2 and is calcu-

latedfrom8XO+4X 1 + (2) X 1 + (1XO=2 ~

Cra Code _ _ J

l1te output data QfmaJlfpbYsicaimiddot $)ShmlS are quantities that are continuous These data bemiddottonverted~digiWforuitJefore they art applied toaliigital system Contfuuous or ~nisCOIl~middotUitodigitalfonn bymeans of an rumlog~digitalConverter It is times ~~ent tousethe Gray code slown inTable 16torepresehtdigiuU data that have oon~ fMn8D8l08 dasaTheadvantage of th( Gray cOOeover thesllaigbt binary nIl11l1hPt~

~lt~thatoWY~ hit in the codegroup changeSin going from one number to the For examplcentbullin-goingfrom 1 to 8dleGray code cblngesfrom 0100 to 1100Only the fust changesfromOto l~the odter~ I)its mnaintbesame By contrast With binary numbers change from 7 to 8wrube from 0111 to lOOOwhich causes allfciur bits to change valUes

TabielAi GtPyCode

01 Decl COde Equivalent

~ 0000 0001 0011 OOlG 011Q Olll OlO 0100 1100 11m 1111 1110 lOlQ 1011

lOOt i

1000

o 1 ~ 3

4 5 6 7 8 9

10 11

12 13 14 15

SectIOnl7 BlnarYCod~s 23

The Gray code is used in applications in which the normal sequenceOrbiruuy rium~may produce an error orambiguitymiddot during themiddot transitionfrom ODeDWDber to the next If binary numbersareusec1 acbange forexaJIlple nom 0111 to 1000 may produce anintermediateershyroneous number 1001 if the value ofthe rigbtmost bit takes longer to -change than domiddotthe valshyues of the other three bits The Graycode elimb1ates this problem since only one bit changes its valve dUrlng aily transition be~een two numbers I

Atypical appli-cation ofmiddotthe Gray code is the representation of analog data by a Continu ous change in the angUlar position of a shaft The sQaftmiddot is partitioned into segments ana each segment is assigned a number If adJacent segments are made to correspond with the Qray-Codesequence ambiguity is eliminated between the angle of thesbaft and the value encoded by the sensor

Character Code

Many applications of digital computers require the handling not only ofnumberS but also of other characterS or symbols such as the letters of the alphabet For mstancean insurance comshypany with thousands of policyholders will use a computeX to process its files To represent the names and other pertinent information it is necessary to fonnulate bull binary code for the letshyters ofthe alphabet In additiQt1 the same binary qode must represent numerals and special Characters (such as $) An a1phanumeric character setis a set ofeiements that inclUdes the 10 decimal digits the 26leuersofthealp1iabe and a nutnbeof special~S~ a set conshytains between 36~d 64 elements ifonIy capital letters areincltided or between 64 and 128 e1eJDents ifboth uppercasemiddot and lowercllle etters are inclUded In the first case we need a bi- nary code ofsix bits and in the second we need a binary cooeO(seVM bits

The standaM binary code for the alphanumeric char8cters is the American Stahdard Code for Information InterCbange (A~n) which uses seven bitS to code 128 characters asshoWn in Table 17 The seven bitsof the code are desipted by b~through h With h the mostsigshynificant bit ~e leUer A for example is represented inASCn as l(l()()()Ol (column l00~tOw 0001) The Ascn ()()de also contains 94 graphic characters that can be printed and 34 nonshyprinting characters used for variQUS control functions The graphic characters consist of the 26 uppercase letters (A through Z) the 26 lowercase letters (a through z) the 10 numerals (0 through 9) and 32 special printable characters suchaS andS

The 34 control characters are designated in the ASCTItable With abbreviated nalne8 They are listed again below the table with their functional names The control characters are used fQr routing data and arranging the printed text into a prescribed format~ There are three types of control characters format effectors information separatOrs andcommumc~on-COnlrpl char~ IlCters Format effectors are characters that control the layout ofprinting They inciude the fashymiliar word pr6cessorand typewriter controlssucb 8$ bac~pace (BS) horizontal tabulation (HT) and carriage return (CR) Information separators are used to separatetbe data into divi~ sions such as paragraphs and pages Theyinclude characters such as ~ordseparator (RS)and file separator (FS)The cODlIDunication-control characters are uSefulduriDgthe transmission of text between remote tenninals EXllll1plesof conlmunicatiOn(ODtiol~ are STX (start oftext)-and ETX (end of text) whicb are used toframe a text mesaagetnQlSlnitted through telephone wires

24 Chap~er 1 Diglt8l Systems and Binary Numbers

rblel7 Amerkcm5tandard Code for Information (nterclHlnge(ASCII)

b~jbzb 000 001 010 on 100 101 no 111

0000 NUL )jLP SP () p P 0001 SOH OC1 1 A Q a q

R0010 STX OC2 2 B b r 0011 ETX DC3 3 C S Ii S

0100 EDT 0C4 $ 4 D~ T d t 0101 ENQ NAK 5 E iU e u OUO ACK SYN amp 6 F V f v 0111 BEL ETB 7 0 W g w 1000 B8 CAN ( S H K h x 1001 HT EM ) 9 I Y Y 1010 LF SU~ 1 Z j z lOll VT ESC + 1lt r k UOO FF PS lt L I I 1101 Cit OS == - M 1 m 1110 SO R~ N 1 n shy

-0PIt st US f 1 0 0 DEL

r- Control characten

NUL NlI]l DlE Data-inkescape SOH Start of hea~ng DC1 Device cOntroll STX Start of text DC2 DevIce io~1lOi2 ETX End (Jftext i DC3 Device corUlri1 3 OOT End oftraIlsmission ~4 DeVicecoQtrol4

ENQ ampqwry NAK Negativeackilowledge ACK

Acknowledge SVN Sync~nous idle

Btl Bell ETB End-of-tmnsnussionblOck sS Backspace CAN CanCel HT Horizontal tab EM End of mediUrlt LF Lintifeed SUB Substitute VT Vertical tab ESC escape FF form feed FS File separator CR Carriigeretum GS Group separator SO shift Ollt RS Reoord sepuator SI Shlftin US Unit separator SF S~e DEL Delete

ASCII is a seven-bit codebutrnostcompUters manipulate anejght-bit quantity asa unit called a byte Therefore ASCII characters most often are stored ~e per byte The

I biti~sometimesused forotlef purposes depending ontheapplicatio~lFor example printetS recognize eightmiddotbit AScn chaiacterS with themost sigoificaot bit ~twO An atkJlitlo

Section 18 Binary Storage and Registers 2S

128 eight-bit characters with the most significant bit set tol are used for other symbols such as the Greek alpbabet or italic tyIe font

Error-Dtectlng Code

To detect errors in data communication and processing aneigbth bit is sometimes added to the ASCll cbaracter to indicate its Panty Aparitybit is an extra hit included with a message to make the total num~ of ls either even or odd Consider the fo119wing two cbaracters and their even andodd parity

With even parity With odd parity Ascn A = 1000061 01000001 11000001 ASCI( T == 101deg100 11010100 01010100

1

- Ineacb casewe insert an extra bit in the leftmost position of the code to produce an even number of 1 s intQe cbaraeter for even parity or an odd number of 1 s in the character for odd parity In generlll one or tbe oth~r parity i~ adopted with even parity being more common

The parity biqsbelpful in detecting errors during the transmission ofinformation from one location to another nisfuJictiOD is bandIed by generating an even parity bit at the sending end for ~h character The eight-bit characters that include parity bits are transmitted to their desshytination The parity ofeachebaracter is thetichecked at the receiving~nd If the parity of the received cbaracter is Dot even then at1east on~bit has changed value dUring the trmlsmission This method detects one three or any odd combination of errors in each character tb8t is transshymitted An even combination oferrors however goes undetected and additioDaterror detic- shytion codes may be needed to take care of that possibility

What is done after an errQlis detected depends on the partieu~ application One possishybilityis to request retransrois~ion of the message on the assump~on that tbeenigtr was ranshyd()m andwill not occur again Thus if thereeeiverdetects a parityerrorit sends bai~ the ASCII NAK (negative acknowledge) control cnaracter consisting ofail even-parity eight bits lOOlOl01H no error is detectedthe ~iversends back anACK (aCkno~ledge) conshytrol character namely 0000011 O The sending end will respond middotto an NAK by tranSmitting the message again until the correct panty is received Ifmiddot after a number of attempts the transmission is still in error a message can be sent to the Operatai to check for malfunctions in the transmission path

BINARY STORAGE ANORECiISTEIlS

The binary infonnation inadigitalcomputermust have a physical e~stencein some medium for storing individual bits A binary cell is a device that possesses two stable sttes and is cashypable of storing pne bit (0 or 1) oflnfotlllation The input to tbe cell receives exciJation sigshynals that set it to one of the two states The output of the cell isa pbysicalquantity that distinguishes between the two states The irtformationstored in Ii cell is 1when the cell is in one stable state and degwhen the Cell is in the other stable state

26middot Chapter 1 Digital Systems and BtnaryNumbers

Registers

A register is a group of binary cells A register with n cells can store any discrete quantity of middot information thatcontains n bits The state ofa registeris an n-tuple ofls middotand Os with each bit designating the state of one cell in the register The C()ntent ofaregister is a function of the int~rpretation given to tbeinformation stored in it Consider fQf ex~ple a 16-bitregister with the following binary content

11 00001111001001

middot Aregjs~ with 16 cells can be in one of 216 possible statesIf one asstimesthat the content cif the register represents a binaryinteger then the register can store any binarydumber from Oto 216 - 1 For the patticularexample shown the content ofthe register is the binary equivshyalent(lftbe decimal number 50121 If one assumes instead that the register stores alpbanushy

middot meric characters of an eight-bit cooe then the content of the register is any two meaningful characters For tht ASCII code with anevenplirityplaced in the eighth most significant bit position the register contains thetwo charactersC (the lefunosteightbits) and I (the rigbt~ most eight bits) If however one in~rprets the content of the register to be four decimal dig- its represented by a four-bitcode tnenthe content of the register is a four-digit decimal number In theexcess-3 code the register holqs the decimal nutriber 9096 The content of the registe~is meaningless in BCD becau~e the bit combinatiOn ltob is 110t assfgned to any decshyimal digit From this example it is clear that a register can store discrete elements of inforshymation and that the same bit configuration Inay beinterpreted dlffe(ently for different types of data

tmiddotmiddotReglsterTrail Adigitalsystenlis characteriZed by its registers and the components thatpetfolin data proshy~ssingIIl digital sy~tems a rcentgister tra1lsfer operation is abasi operation that consists of

middot a transftr of hiJWy hUormation from one ~t of registers into ano$er set of registers transfer may be dir~ctfr9m one regist~r toanlt)ther or may pass througb datamiddotprocessing circuits to petformaD operation Figure L 1 illustratel the transfer of iidOrnuttion among regshyisters anddemonstratespictorlallY [the tr8ll~~ ofbinaryinformation from akeyboard a register in the memQryullit Thehlputunit~s assumed to have a keyboard1 control cuit and aninput register Each time a key is strock the control circuit enters an ImnV$_

lent eight-bit alphanumeric character coqe into the input register We shall assume that code used is the ASCII code with an odd-parity bit The information from the input regisshyter is transferred into the eight-least significant cells Qf a proeessOr register After transfer theinpui register is cleared to enable the control to insert a new eight-bit when the keyboard is struck again Each eight-bit character transferred to the pro1c4ess(raquo register is preceded by a shift of the previous character to the next eight cens on its left~

middot a transfer -of four characters is completed the processor registeris full and its contents transferred into a memory register The content stored in die memOry register shown in Figl came from the transfer of the characters J 0 H an~ N aftet the four ap)lroJ)riatt keys were struck

Section 18 Binary Storage and Registers 27

FIGURE 11 Transfer of information among registers

To process discrete quantities of infoiniatiori in binary form a computer m~st be promiddot vided with devices that hold the (lata to be processed and with circuit elements that manipmiddot ulate individual bits of irifonnation The device most commonly used for holding data is a register Binary variables~ manipulated by means of digital logic circuits Figure 12 il~ luslrates the process of adding two l()bit binary iUlmbers Themeniory unit which no[shy

mally consists of millions of registers is shown with only three ofits registers Thepait of the processor unit showncoDsistsmiddotofthree registers-RI R2 and R3~getherwith digital logic circuits that manipulate the bits of RI and R2 and transfer into R3 a binary number equal to their arithmetic sum Memory registers store information and are incapable of pr0shy

cessing the two operands However th~ information stored in meDij)iybanbetransferred to ~ processor registers and the resUlts obtainedin processor tegisters can be transferred back into ame~ry register for storage Untill)ecded again The diagram ~wsthe90ntents of two

operands transferred from twoJDemoryregisters into RI imd R2 The digital logic circuits produce the sum which is transfened to register R3 The contents of R3 can now be 1riUlsshyferredback to one of thetnemory registers

The last two examples demonstrated the infonncion-flow capabilitieSofa digital system in a simple manner Themiddot registets of the ~ystem are the basic ele~ents for Noring and holding the binary information~igitallogic circuits process the binary ihfonaation stored in the

28 Chapter 1 DigIt bullbull Systems and Binary Numbers

Sum

FIGURE 12 Eumple of blnarylnfonn~t1on processing

registers Digitallogiccirctiits and registers are covered InChQpteB 2 throQgh 6 The metlilOlY unit is ~xPIained ill 9aptet 7 Th~ descriptton of register opetJtions at the register level and the design of digital systems are covexed in Chapter 8

19 BINARY LOGIC

Binary logic deals with variables th~ take on two discrete valueund withoperations that sumelogicalmeaning~ The two val~s the variableussume may be called~ydifferent (true andalse yel and no etc) but for ourp1llpQSe it is cpqVenienttotbink in terms of and assign the values llUld O The binary logic intr0ducedin this section is equivalent to algebra oalledBoolean algebra The fannal presentation ofBoolean algebra is covered in detail in Chapter 2 The purpose ofthis seCtion is to introduce Boo algebra ina matmerandlate it to digitallogiccircuits andmiddotbinarYsignalsmiddot

Section 19 Sinary logic 29 ~

Itkltn of IInary logic

Binarylogic consists of binary v~les and a set of logica1middotoperatiQDS The variables are desigshy ~by lettell of thCalplWlet~such asA B C x yz etc with eaCh variable baving two and oniy

two distinct posSible valueS 1and O There are three basic logical operations AND ORand NOT

1 AN]) This ~peration is represented by adotorby the absence ~f an oPerator For example x bull y =z or xy = zis~ x ANDy is equalto z~ThelogicaloperationAND is interpreted to mean that z == 1 ifand only ift~ land y = 1 otherwise z = O (Reme~r that x y andzare binary v8riablesand canmiddotbe equal either to 1 or Omiddotand nothing eise)middot

2 OR This operation IS represented by a plus sign For example x + y =z is read x OR y is equal to z meaning that z 1 if x = iorif y = lorifbothx= 1 and y = 1 If bqth X - 0 andY Omeo z= O

3bull NOT This operation is repf6sented by a prime (sometimes by an overbar) For ~xample x =Z (or~ =z) is read notdsequalto 1 meiming that z iswkatx isnot In other

words ifx = 1 then z == 0 but if x == 0 tnenz = L TheNOT operationisals(1 reshyferred tolls the complement operation since it changes ~ 1 toOand a O to 1

bull bull lt Binary logic resembles binary arithmetic and themiddot9peratioos ANDahd OR have similarishy

ties to multiplication and addition respectively In fac~ the symbols used for AND and OR are the same as those used for multiplication and addition However binary lOgic should not be conshyfused withbinaryarithIrietic One should realize thatan arithmetic variable designates a numshyber that may consist of many digits A logicmiddot variable is always either 1 or O For example in binary arithmetic we have I +1 =10(read~one plus ()fie is equal to 2) whereas in binary logicwe have 1 + 1 1 (read one OR onds equal to one)

For each combination of the values oix and y bullthere isa value of ~ $pecifiedby the definishytion of the logical operation D~linitiops of logical~perations maybe listed in a compacHorm called truth tables A truth table is atable of anpbssible combinations ofthe variables $howshying the relation between the values that the variables may take and the resultof the operation The truth tables for th~ operations ANDand OR with variables x and y are obtained by lis~ng

all possible values that the variables may have when combined in pairs bull For each combination the resUlt of die operation 18 theillistedin a separate row The truth tables for ANDORand

NOT are given in Table La These tables clearly demonstrate the definitionf the operatibns

Table 18 Truth TcibJts of Logical Operations

AND OR NOT

x y xmiddoty x y x+y

0 0 0 0 0 0 1 0 0 1

10

1 0 d 1 0 1 I 1 1 1 1 1

bull~lt~m

30 Chapter 1

Logk Gates

Digital Systems and Binary Numbers

Logic gates are electronic cirellit that operate on ~

variable

or mpre mput tignals to produce an output signal Electrical signals sUch as voltages orrutrents exist as analog signals having values over a given taDgebull saYOt03 V but in a digital system are interpreted to be either of two recognizable values 0 or 1 Voltage~opetated logic Circuits respond to two separate voltshyage levels that represent a binary varjable equal to logic I bt logic O For example a partic- ular digital system may define 10gicOas a signal equal to 0 volts lind logic 1 asa signal equal to 3 volts In practice each voltage levelhiS an acceptable rangeas shown in Fig 13

The input te~nals of digital cikuits accePt binary signals within the allowable range and respond at the output terininals with binary signals that fall within the specified range The intermediate region between the aJl()wed regions is crossed only during aState transition Any desired information for computing or control can be operated tm by passing binary signals through variQUS combinatioDsof logic gates with each signal represebting a particular binary

The graphic symbols used to deSignate themiddotthree types of gates are Mown in Fig 14 The

gates are blocks of hardware that prooocc tbeequivalent of1ogic~1 orlogic() output signals

Volts

- FGURl13

x

y

Exampleof binary slgnaJs

Signal ratlge for logieO

(a)~omiddotinput AND gate

FIGURE 14 SymbOls for digital logic circuits

(c)NOT gate or invert~

Problems 31

x-lU 1 11 P 0

y 0 0 11 1 ~

ANDxy 0 0 rTl 00

ORX+Y~ NOT x 11 0 0 I 1 1

FIGURE 15 Input-output 5Igals for gates

FIGURE 1

A B C

Gates WIth mlltlple JnpUU

A B C lJ

~

if inPllt logic ~ts are satisfied Theinput signals xaDd y intheNDaadQR gates may exist in ~ oHow-possible states 00 10 11 or 01 Il1ese ibpu~ampignals_ shown inFig lStoshygetber with the corresponding output signal foreach PfCThI~tiaiug~iDustrate the reshysponse ofeaclt gate to the four input signal~The~llisofthetiminadiagram represents time and the vertical axis sbo~~~~ it cbapg~botwcen~possible voltshy

age levels The low level represents logic O tJte high level l1lteAND _ responds With a logic ~ ~tput sipl wh~ both input ~~)e 1middot1~ lIieOR S-~with a logic 1 outpUt signal ifanylnput sigrudis lOgic 1 TheNOTgateis~~ to BUll invedet The reason for~nameis~t froJn the signalmsponae inmiddottbe timitt8 diagramwhicbsbows that theoUtputsignal inverts the logic sense of tbeiDpUtsigll8l

AND and OR gates may bavei)lQte tbantwQinputs M AND8_~itti ~input$andan OR gate with foU) inputs are shown in Fig 16 The three-inPllt AND gate responds With logic 1 output if all tbreeinputs arelogic 11jleoutputproduces lOgic Oifanymput is logic O-The

four-input OR gate responds withlogic 1 ifany input is logic 1 its clu1ptltllCCoines logic oonly when all inputs are logic O

Answers to prvblems marked with middotappearaHbe ClOd ofthe ~

11 lJltthe octal and beXadecimalliurilbers trom16ui 32UdngA B1l1ld C forthebst~ digits Usttbe numbers from 8 to 28 in base13 bull

I

12t What is the exact D1Jllbcr of bytes in a system that contains lta) 32Kbytoe (b)64M ~and (e) 640 byte$ middot7 t

32 Chapter 1 Digital Systemsand Binary Numbers

13 Convert the following nu~bers with the indicated bases to decimal (a) (4310)s (b) (198hz (c) (735)8 (d) (525)6

14 Whllt is the largest binary number that can be expressed with 14 bits WhlIt are the equivaleDt ~~ iinal and hexadecimal numbei-s

--

15 Detemrine the base of thl1 numbers in each case for the following operatio~ to be correct (a) 142 = 5 (b) 5414 = 13 (C) 24+ 17 == 40

16 The solution$to the q~cequation xl - Ux +22 oare l1 3 arid x =6 What is the base of the numbers

17 Convertthehexadecimal ntmIher 68BE to bitiary and then convert it ~mbinary to octal

18 I Convert the decirpal number 431 to binary in tWo ways (a) Convertd~y to binary (b) conshyvert first to hexadecinla1 and then from ~decimalwbinary Which method is faster

19 amppress the following nqrnbersin decinud (a) IQ11O0101)z (b) (l65his (c)(2624)8 (d) (FAFA) 16

(e) (10101010)2

110 Convert the following binary numbers tobexadeoimal and todecitnal (a) UOOlO (b) 110010 Explain why the deCimal answer in (b)is 4 times that in (a)

111 Perform the followingdiviskmin binary 11 Ion + l()t

112 Add IlniImultiply tfle following numberswiihout converting them to decimal (a) Binary nuniberilOll aiIdlOh (b) He~uumbers 2E aDd 34

1~)( Do thefoHowing con~ersionproblems (a) CorivertCiecimal2731S to binary (b) CakUlate the binary eqUivalent (f 213 outto eight pl~Then Convert from binary to

imalHowgJose istbe result to 2131 (c) Convert the binary resukin (b) into hexad~ lb~oonvert ~result to decimal Is answer tbesame

114 Obtain the is 8nd 2s complementsofthe foUowing binaryDumbcentrs (aj l)()()(J()OO (b) OOOOOOOO (c) 11011010 (d)01l10110 (e) 10000101 (0 11111111

115 Find the 9s and the 10s complement of the following detimal numbers (a) 52734630 (b) 63325600 (c) 25000009 (d) 00000000

116 (a) Find the 16s complement of B2FA (b) Convert B2FA to binary (c) Find the 2scomplement ofthe resultin (b) (d) Convert the answer in (c)to hex~malandco~ with ihe an~wer in (a)

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 9: Chapter 01 - Mano

9 section 1S Complements

Conversion from binary to heudeciInal is similar except thatthe binary nutriber is divided into groups ofourdigits

(10 1100 0110 1011 1111 0010h = (2C6BJ2) 16

2 C 6 B P 2

The comsponding heX~ima1(o~ octal)~digit fOr each group of binary digits is easily reshymembeled from the values listed in Table 12

Conversion from octal or hexadeciInal to Jlinary is dOne by reversing the preceding proceshy(luremiddot Each octal digit is converted to its tbi-ee-digit binary equivalent Similarlyeach hexashydecimal digit is convertedioits four~digitbinaryequivalent1he procedure is illustrated in the following examples

(673124)8= (110 6

III 011 7 3

001

010 2

l00h 4

and

(306Dh6 = (OOlf 0000030shy

110 6

~101h D

Binary numbers are difficUlt to work with because they require three or fout times as many digits as their decimal equivaltmts Por exaniple the binary number 111111111111middotis equivalent to decimal409S Howeverdigital computers use biIUuy11UIhbers and itis soIIJet4nes necessary for the human operator or user to oonununicatedirectly With the machine by means of such num bers One scheme that retainsthebinary~ystem in the cotnputer but reduceS the number of digshyits the human must cOnsider utilizes the relationslripbetyeen the binary Ilumber system and the ~ or hexadeciinal system By this method the Ql1DaIlthinksin tenns ofQCtal ornexadecimal nurnbers and performs the required conversion by inspection when direct communication with the machine is necessary Thus thebinary number 111111111111 has 12 digits ~d isexpressed iIi octal ~ 7777 (4 digits) or in hexadecimal as FFF (3digits) During communication between people(about binary numbers in the coJlllQter)the octal or hexadecimal representation is more desirable because it can be expressed more compactly with a third or a quarter of the number of digits reqUired for the eqwvalent binary number Thusmpstcomputer manuals use either octal laquohexadecimal numbers to specify binaryqwintiti~ The choice between diem is arbitrary although hexadecimal tends to win out since it can represent a byte with two digits

PlEM ENTS

Complements are used in digital cOmputers to simplifydle subtraction operation and for logshyical manipulation Simplifying operations leads to simpler less expensive circuil$ to implement the operations There are two types of complements for each baSe-r system the radix comshyplement andthe diminished raclix cOtllplement Themiddotflrst is referred to as the rts complement and the second as the (r - middot1)scomplement When the value of the base r is substituted~ the name the twotypesare refefted to as the 2s complement and 1 scomplement fot binary numshy~rs and the lOscompl~ent and 9s complement fqrdecimal numbers

10 Chapt~rl Digital Systems and Binary Numbers

D~I~llhed Radix Complame~middot Gi~en a number N in base r haYing n digits the (r - 1)scomplement~f N is defined as

(rll - 1) ~NFotdecimainumbersr -= Wandr -1 9sothe9scomplementofNis (10 - 1) - N IIi this c~ 10 represents a number that consists of a single 1 followed by nOs 10 - lisartumberrepresentedbyn9sFOrexampleifn 4wehavel04 = 10000 and 104 - 1 = 9999 It follows that the9s complement ofa decimaJnumber is obtained by subtracting each digit from 9 Here are some nwnericalexamples

The 9s complement of 54670(Ms929999~ 546700 453299 bull - I

The 9scothplement of012398is999999~0l2398 =987601

For binary pumbers r =2 and r - l~ 1 sothe 1s complementofNis(Z - 1) - N Again 211 is represented by a binaty number thatconsistsofa 1followed by Ii0s 211 - 1 is abinary number represented by ~1s~FOr example if 11= 4 we have z4 = (10000)zand 24 - 1 = (1111h Thus the ls complement of a binary number is obtained by sUbtractiDg

each dig~t from 1 However when subtracting binary digits from 1 we can have either I -0= lor1 - 1 = 0 which causestbe bit to change from Oto 1 0( from 1 to 0 respec- tively Theretore the ls complement of a binary number isfonnedby changing 1s to Osand Osto 1s The f9llowillg are somenumqical ex~esI

~

The ls Complement of 1011000 isotOOiu

The 1scompieme~t oHlIOUOI is 10 tOOlO

The (r-l) s compleme~ ofoctal or b~xadechnalnumbers i~6btained by subtracting eaeh digit from 70rF (diicimallS) respectively~

Radl~ C~mplement

The s complement of an n~digit number N in baserisdefinedasrmiddot Nfot N i 0 and as ofor N = O~ Comparing with the (r- l)s ~entwe note that ~rs complement is obtained by adding Ito the (r - l)scomplement smcer - N= HA-- 1) - N] L lhus the lOscomplementof deein1al2389 is 76lO +1 = 7611 and is otltamed by adding 1 to the 9scomplernent value The 2s oomplementofbinary 1011oois 010011 1 =010100 and isobtained by adding 1 to the ls-complement value

Since 10 is a number represented by a 1 followed by n0s1011 N Whicb is the10S com~

plementof N can be fonn~d also by leaving allieasl sigtrlficani Os Unchanged the first nonurO least significant digit from 10 and SUbr8Cting all higher significant

from9 ThUs

the 10s complement of 012398js987602

and

11 Sectlon middot15middot Complements

The 10s complement ofthefustnumber isobtaineltibysublriiCtingSfrom lOin the least sig~ nificant position and subtracting all other digits from 9~ The 10s complement of the second number is obtained by leaving the to least significant Os unchanged subtracting 7 from 10 and subtracting the other three digits from 9

Similarly the 2s complement ~be fonned by leaving 1ll11east significant Os and tbe first 1 unchanged and replacing I swith Os and Os with ls in allother hi~r signifIcJUlt digits For example

the 2s cORlplement of 1101100 is 0010100

and

the 2scomplement ofOllOllHs 1001001 _ - r

The +s complement pf therrrst nJUDber i~ obt4iriedby I~vingthetwo least significant Os and the first 1 unchanged andmiddotlQen replacing ls with Os and Oswith 1~ in the other four most sigmiddot nificant digits The 2s lXgtmplement qf the second number is obtained byleaving the least sigshynificantmiddotl unchanged and (fOmplementing all other digits

In the previous definitions it was assum~dtMt the D~bers did not have a radix pomt1f the original number Noontains a radix point the point should be removed temporarily in order to form the s or(r 1)s complement The radix point is then restored to the c9ll1plementshyednumber in the same relative PositionIlis abo wOrth mentioning thatfhecontplement oftbe complement restoresthe number to its original v41ue To see this rel~tionsbipnOtethat the ts complement of N is n - N so that themiddot complement oft1e complement is n - (n - N) == N and is ltlqual to the original number

Mr8Ctiton wltl1 Complementsmiddot

1le direct metb()jiofsubtraCtion taught in elexnentaty schpOls uses the bottow concept In this QlCth9dwebortowa I from a middothigher significant position when the minuend digit is smaller than the subtrahend digit The tDethod wor~wen when peOple perfonnsubtraction with paper andpeooillIowever when subtlaction is implemented withdigi1al bardw8le the method is less e~citnt than the method that u~s compl~m~ts

The subtraction of two n-digitunSigneq numbers M N in base can be done as fonows I

1 Add the minuend M to the scompleme~t of thesubtramphend N Mathematically M+ (n N) = M N +

2 IfM ~ N ttie sum wiUproduce an end cury 11 which caD be discarded what is left is the resultM N

3 If M lt N the sum does not produce ~tlend carry JUld iseijUattor (N~ Ji) which is the s complement of (N - M) To obtain the answer in a familiar form take the s complement of the sum aruI place a negative sign in frorit

12 Chapter 1 Digital Syst-ems and Binary N~mbers

The following examples illustrate the procedure

plPi1I VsinglOs complement subtract 72532 - ~250

M = 72532

lOs complement of N + 96750 Sum= 169282

Discard end caIry lOS = -100000 Answer = 69282

Note that M bas fiv~ digits andN has only fourdigitsBoth numbers mtast have the same numshyber of digits sowe wrlteN as 03250 Taking the lOscomp~ementofNptOducesa9 in the most significant PositionThe occurrence of the end carry signifies that M ~ N 8ndtlult ~ result is therefore positive

Ulling 10s complement subtract 3250 - 72532 - ~ ~

M = 03250 JOscornplementof N =+27468

Sum= ~0718

There is no end carry Theref()re-theanswer is--(10amp complementof30718) == -69282 Note thatsince 3250 lt n532~the result is negative Becauwe are dealing with WUiigned

numbers there is really no way to get BnunSigned result for this case When subtracting complements we reoogilize the negltive answer from the~sence of the end carry and complemented result When workingwith paper and pencil we c8nchlnp the aDswer

signed negative number in oider to putH inafamiliar form Subtraction with complements is done with binary numbers in a similar manner uing

procedure outlined previously

EXAMPLE 17

Given the two binary numbersX = 1010100 and Y =1000011 performtbe $UbiDctiG (8) X - Y arid (b) Y - Xby using 2scomptem~ts -

f

- -

Section 15Complements 13

(a) x = 1010100

2s complement ofY= + -0111101

Sum = middot 10010001 Discard end carry 27 = 10000000

Answ~ X- Y = 0010001

(b) Y == 1000011 2sco~lement of X = + 0101100

Sum= 1101111

There is nQmiddotend carry Therefore the answer is Y ~X= -(2sq)mplement of 1101111) = -0010001 Subtractionof unsigned D1lJllbers ~ also bed()neby means of the (r - 1)s complement Remember that the(r- l)s complement is one lesstharithers complement BeCause of

ibis the result of adding the minue~ to tJte coQlplement of the subtiah~ndPtOductS itsum that is one less than the correct 4ifference when an end carrY oCcurs Removing the end carry and adding 1 to the sum is referred to asan end-around carry

Repeat Example 17 but this time using rs complement

(8) X y = 1010100 - 1000011middot

X= 1010100

rs complementafY= + olfnoo Som = 10010000

End-arOundmiddot~ =- ~ ~ Answermiddot X Y= middot0010001

(b) Y - X = 1000011 - 1010100

Y = 1000011

1s complement ofX = +0101011

Sum = 1101110

There is no end carry TherefOre the answer is y - X = -(1s complement of 1101110) = -0010001

bull Note that the negative resultis ob~ by taltingtbe 1 scomplemeilt of theJWltsince this is the type ofcoDiplementused The procedwewithendaroundoanyis aIs(gt Iijlpliclbleto subshytracting Unsigned deciImdnumQers with 9seomPlement

14 Chapter 1 Digital Systemsand BinayNumbers

16 SIGNED BINARYNUMBER$ ~

Positiveintegers (including zero) CaBbe ep~~ 11$ unstPecl numbers However to repshyresent negative integers we need a notation for negative srn ordinary arithmetic a negshyative number is indicated by a mulUs signmdapOsitiv~Pwtlt)e~ by aplus sign Because of lJardware limitations computers mlstrepresenlev~With~ digitsIt is customary to represent the sign witb a bit placed intheleftmotp6sitiolwfthe number The convention is tltl make the sign bit 0 for positive and 1 for negative

Itis important to realize that botp siped and unsignedtDnary 11UJDbers consist of a strfug of bits when represented in a com~ TQeuser detem1inesWbether the number is signed or unsigned If the binary number is signed then the lefuriostbitreple$ellts thtsign aud the rest of the bits represent the number Ifthebinaryllu~beiis~ tObe unsigned then the left most bit is the most significant bit of the l)uMber Fdre~the~~f bits 01001 can be consideredas 9 (unsigned binary) or as +9 (Sighedbitia1j) ~USJtheteftmostbit is O The

string ofbits 11001 represents the binary ~~v~ento~ ~w~nc~idered as an unsigned number and the binary equivalent of 9whenconsidered1l si~riumPer This is because the Ithal isintbe leftmost positiondesignatesampC nega6ye_~QtherfourJ)its represent bishynary 9 usually tlere is no cotifusionin identifying thebits~the~Qfrepresentation for the number is known in advance ~

The representation of the signed numbers in the lastexainple is referred to as the signed magnitutk coDvention In this ~otati()nthenurnber C4mSiampesOCa mQ~~andil~ymbolH

or -) or a bit (0 or 1) indicating the sign This is the representation ampr~~used in ordinary arithmetic When arithmeti~ operatioBslllieimplerneJltcldin~cOQlPuter hii more convenient to use a different systemrefetred t(gt as the si~cqmptement system~ for repre- senting negative numbers In thissystlm a neg8tielliun~r isjhdic~ted by its cornplc~mc~nt Whereas the signed-magnitude system negates a nlllllher by cbanging its sign me signed-comshyplement system negatesanwnber bytakin$ its~OinPleltleitiSinoepositife numbers always start witbO(plusin tte leftmost pOsition thecompktllint wiilalwaysstart with a 1 indicating a negative number The siped-complemelt system can use olthertbe 1s Or the 2s but the 2s complement is the mos~comtliOfi

As an exampleconsider the number9re~~ed in binary with eight bits + 9 Is sented with a sign bit of Oin the leftri1ostpOsition oIIOv~by the binary (equivalent of 9 which gives ()()()olOOl Note thai all eigbtbits must haYampa v~therefore O~s are inserted folshylowing the sign bitllp to the first 1 Although ~ is only 01K way to tepresent +9 there three different ways to represent 9 with eight ~its

s~gned~magnituderepresentation 10001001

sigried-l s-complement represe~on~ 11110110

signed-2 s-complemerit representatim 1ttltllU

In signedmagnituamp -9 isobwned from +9 by changing the sign bitmtbe leftmost ~iti(ln tromO to L In sigl1ed~ lroomplement 9isobtaidedtf~~tiog all the bits of includinj the sign bit Thesigned-2~sco~re~Qf-9 is obtampDedby ihe 2s complement oftbepOsitivenumberincludingtbesijnbIt

Sectlont6 SIgned8lnary NumberS is

Table 13 Slgtlfd Biliary Humbm

+7 +6

+5 +4 +3 +2 +l +0 0 -I

-2 -3

4 -5 -6 -1 -8

Olll 0110

0101 ( 0100

001l 0010 0001 0000

IIll 1110

nOI noo Ion 1010

1001 1000

OIll Oito eHOl OHIO OOU 0010 0001 0000 1111 1110middot dOl 1100 Ion

lOti 1001 1000

0111 OUO 0101

0100 0011 0010 0001 0000 1000 1001 1010 IOU 1100

1101 1110

lUI

Table 13 lists all possible four-bitsignedbinaryaumbers in the three representations The equivalent decimal number Is also shown for refelenoeNote that the positive n~ in all three representations are identicaland have 0 inthelefmostpcsiticm The signed2sshycompl~mentsystemhaironly onemiddotrepresentation for 0 which is always po$itive The other tw()systetns- mlve either a positive 0 or a negative 0 sometbingnoteDcounteredin ordinary arithmetic Note that all negative numbenhave alin the leftmost bitpositi~ that is the way we distinguish them from the positivenumbers With fout bits we can repreSent 16 binary numbers In the signed-magnitude aDd thelscomplement repre$eDtatipns there are eight positive numbers and eight negative numbers inciUdingtwo zeros In the2s-complement representation there are eight positive numbers includi0a one zerQ and eight negative numberS

The siped-m_gnitude system is used in ordiIlary arithmetic but is awkward when emshyployed in computer arithmetie becauIe of the ~parate bandIinJ bfthesipand the magnitude Therefore the signed-compiement systeni is normallyused The ls ~t imposes some difficulties and is seldom USedJor arithmetic openitiOns It is U$eful aSa lo~ operation since the change of 1 to Obrmiddot() to 1 is equivalent to a logical complement Operation as will be shown in the next c~The discussion~f sigiled binary ariduneti~ that fol10ws deals exshyclusively with the signe4-2soomplt_nt~tatJonQfnegadveilUlilbers hsame proshy

cedurescan beappJied to the sigMdrs-comPlemeD~Iysby incIudiOI tbe~arotmdcarry as is done with unsigned numbers

J6 Chapt~r 1 OlgltalSystlf(ns and Binary Numbels

Arithmetic Addition

The addition of two numbers in the signed-magnitudelYs_foUowsthe rules ofordinaiy arithshymetiC Ifthesi~s arethesam~we addthetwOtt~gni1U~~d ~vetbe sum the CCmmon sign Iftbe signs are diffe~nt we subtract tllcsmaUermagnitude frOtnlthe larF and give the differshyehtethe signof the larger magnitude For example (+25) +( - 37) = ~ (37 - 25) = -12 and is done by subtracung the smaller magnitude 25 from the larger magnitude 37and a~nding the sign of 37 tGtbe result Ibis is a process that requires a corripanson of the signs and magnitudes and then performing eithr additi()n or subtraction The same procedure applieato binary numbers in sigped-magnitude representation~Incontrast the rule for adding numbers in the signed-corppleme~ sy~tem does not require a comparison or su~ traction but only addjtion The procedure is very simple andcanbe stated as follows for binary numbers The 8ddltion oftwo signed binary numberS with negative numbers tepresented in signed- 2sComprement fonn is obtaiIled from theadditlooofthe two numbers includingtheii sign bits

AcentiirrY out oftbe sign-bitposition is diScacded NumerIcal e~aihpledotai1dition follow

+ 6 00000110 - 6 11UI0tO I

+13 00001101

+13 00001101 +19 00010011 + J 0Q900111 + 6 00000110 6 11111010 ~13 11110011 -1~l 11110011 7 illl1001 -19 11101101

I bull bull ~

Note that negative numbers musthil iriitially in 2seompkmentform and that if the swn ~ ~afterthladdit40nis negativeins in2s~p~t fOl1Jl - In each of thefoDrcasestlteoporationperfol1JlC(lis additionwitb the sign bit iilcluded Any catTY o~of~~-bit~onisdisc~ and negative resultsareButomaticallyin 2sshyromplementfoon

In order to obtain acOrrect answer we mustensQre that the result has a sufficient of bits to accommodate the swnlfwestartwith t~on-bltnumbers and tbeswn occupies n + 1bits we say tblltan overflow occurs~Wheri one perfotmStbc ad(JitiOJl with nllllIPTJllVIl

pencil aq overflow is not a preblem because we arcr noflimitecLbythewidth of the page jUst addanothcentr 0 to apositive number or another 1 toa negative number in the mOst cant positi()n to extend thenwnber to n+ 1 bitSand theQ perform addition Overflow is

problem in computers beqiusetbe number ofbi~~ bolla ~befis finite and a result ex~ tI1efinite val~e hy lcatmotbe accommodated

The compJement form of representiQg negativetlQUlbers is unfamiliar to those usedto signed-magnitude system To itetermine th~ value of II negatienumber insiped-2s COlIlpJe

mentit0is~ to CODVerttbe numbcr to apositie ntirit_ ~ place itiDa more formPor ~plethesig~binary number qUl00~ lii~egativebecausothe leftmost

t 1182s c0J8plemen~js~UlwhUhi$~ binaryeqqivalen of +7Wcmiddottherefore nize the Ori~nal ~atiy-eQumber to be equ~ lo-7 1

Sectlonl7 Bh1ary Codes 17

ArIthmetic SubtractIOn

Subtraction of two signed binafy numbers whe~negative numbersare in2s-complement form is simple and can be stilted as follows

Take the 2s complement of the5ubtraltend (including the sign bit) and add it to the minuend (including the sign bit) A cany oU1of thesignbit position is discarded

This prOCedure is adopted because a subtraction operation can be changed to an addition operation if the sign of the subtrahend is changed as is demonstrated by the following relationship

(plusmnA) ~ (-tB) = (plusmnA) + (-B) (plusmnA) - (-B) =plusmnA) + (+B)

But changing a positivetwober toa negative n~ber is eaampily done by taking the 2s compleshy mentof the pQsitive number The reverse is also tiUe~use theCOmPle~n~ of a negative numshyber in complement form produces the equivalent positive number To see this consider the sJlbtr~ction ( 76) -- (13) = +7 In binaIy_ with eight bits this ()peiationis written as (11111010 11110011) The subtracti~ri ischmlged ~ addition by taking the 2s complement ofthe subtrahend (-13) giving (+13) In binaly tbis~ 11 niOlO+ 00001101 = lOOOOOU1 Removing the end~ we obtain the ootrect answer ()()()()() III (+7)

Itisworth noting that binary DUmbersinthe signed-complement system are added and subshy tracted by the same basic addition and suPtraction rules as unsigned numbers Therefore comshyputersneed omy one common hardware circuit tobandle bothtypcs ofaritbtnetic The user or programmer ~ust interpret the reswtIi of $l1ch addition or subtraction differently depending on whether itisassumedtha~the numbe~ are signed ltr tinsigned

j

BINARY CODES

Digitalsystems use signalsthat have two distinct values1Uld circuit elements that havetwostashyble states There is a direct analogy anrong binary iignals binary circuitelements and binary digits A binary number ofndigitsfor example may be represented by n binary circuit eleshyments each baving an output sig~alequivalen1to Oor I Digital systems represent (Uld mashynipUlate not omy binary numbers but alsO many other diScrete elements of information Any discrete element of informatioIidlat is dis1iilct among agroup of quantities can be represented witha binary code (Le a pattern of Os and fmiddots) The codes must be in binary because in todays techIiology omy circuits that represent and manipulate patterns of 0s and ls can be manufactured economically foru~ in computers However it mtistbe realizCd that binary codes merely change the symbols not the meaning ofthe ele~nts of infonbationthat they repshyresent IT we inspect the bits of a computer at random we will find that mostofthe time they represent some tYPe of coded information rath~ than binlUY numbers

AIln-bit binary code is a groopofn hits that assumes up to 211 distinct cOmbinations of ls ~d Os with eacn combination representing one elementof tnt set that is being coded A set

of four elements clab becoded with two lilS with each ~lementassignedoneof thefoUowing bit oombinationsOOO I 10 J 1 A set of eight elements requiies a three-bit code 00 a set of

18 Chapter 1 Digital Systems and Binary Numbers

J6 elements requires a fourmiddotbit code The bit combination of ann~bit code is determined the count in binuy from 0 to 21t - t Each element must be assigned a unique binuy bit binationand no two elemerits cm havetbtsamevalueothenvisethe code assignment be ambigUous

Although the minimum nqrnber of 1lits required to code 21t distiItct quantities is nthere nomaximwn numbe( of bit that may he used for a binuy code For example the 10 digits can be coded with 10 bits and each decimal digit can be assigned a bit combination nine OSmid a 1 In this pamcularbinarycode the digit6 is assigned the bit )UllIUlauuu0001000000

BCDcode

Although the binary number systemis die ~ost natural system for a computer most people more accustomed to the d~imal system One way to resolve this difference is to convert

inlal nUmbers to binary perform all arithmetic calculations in binary and then convert the nary results back to decimal This metbodrequites that we store decimal numbers in

cOinputer so that they canbec6b~rted to binary Since the compllter Can accept only valueswe must represent the decimal digits by means ofa code that contains ls and Os also pOsSible lopedorm the arithmetic operlltiorisd1rectly on decimal numbers when they stored in the comput~ in cod~ct form

A binarycodewill have some unasSigned bit com~inatiqns ifthe num~rofelements in set is not amultiple power of 2 The 10decimai digits form such asel A biruuy code that tinguishes among 10 elements must coiltain at least four bits but 6otitofthe 16 possible binations remain unassigned Different binary code$ can bemiddotoNained by arranging four into 10 distinct combin~tions TheicodeIllcfflt oommonly used fdr the decimal digits is straight binary assf~ntlisted in Table 14 This scheil)eis called bittary~coded decimal

is commoolyreferred to as BCQ OtherdecimalcodesaIlfpossible and a few of them are sentedlaterinthis section

Table 14 BinarymiddotCoded Oeclmql (BCO)

Decimal BCD SnlboiDIgIt

o 0000 1 0001 2 0010

3 0011 4 middot0100 5 0101 6 0110 7 0111 8 1000 9 1001

Sectionmiddot 17 BInary COdes 19

Table 14 givesthe four-bit code for one decimal digit A number with k decimal digits will require 4k bits in BCD Decimal 396 is represented in BCD with 12 bits as 0011 10010110 with each group of 4 bits representing one decimal digit A decimalmiddotnumber in BCD is the

- same as itS equiyalent binary number only when the number is between 0 and 9 A BCD numshyber greater than lOJpoks different from its equivalentbinary number even though both con tainls and Os Moreover the binary Combinations 1010 thrpugh 1111 are not used arid have no meaning in BCD Consider decimal 18SlUld its corresponding value inBCD and bUtary

(185ho = (0001100001Ol)BCD = (l0111001h

The BCD value has 12 bits to encode the characters of the decimal value but the equivalent binary number needs only 8 bits It is obvious thatthe representation of a BCp number needs more bits than its equivalent binary value However there is an advantage in the use ofdecishymal numbers because compUterinput and output data are generated by people who use the decshyimal system

It is important to realize that BCD numbers are deCimal numbers and not binary numbers although they use bits in tbeir representation The only difference between a decimal number and BCD is that decimals are written with the symbOls 0 1 2 9 and BCD numbers use tbebinarycode 00000001 001O~ bull 1001The decimal value is exaCtly the same Dec~mal 10 is represented in BCD witheight b~ts as 00010000 and decitna1J5as 0001 01Of1lte corshyresponding binaryvalues are 1010 and 1111 and have only four bits

Consider the addition of two decimal digits in BCD together with a po~ible carry from a pre- vious less significant pair ofdigitsSince each digit does not exceed 9 the sum cannot be bull greater than 9 + 9 + 1 = 19 with the 1 being a previous carrySllppose we add the BCD dig-

its as if they were binary numbers Then the binary sumvill produce It result in the range from degto 19 In bin8ry thistange wil[be from 0000 to 10011 butin BCD it is frOm 0000 to

I 1001 with the first (ie leftmost) 1 bemg a carry and the next fo~ bits being the BCD sum When tPe binary sum is equalto or less than 1001 (withaut 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 (0110h to the binary Sum cOnverts it to the correct digit and also produces a catTy as required This is because a carry in themost significant bitposishytion of the binary sum and a deCimal carry differ by 16 10 = 6 Consider the following three BCD additions

4 0100 4 0100 8 1000

+S +0101 +8 +1000 +9 1001 9 1001 12 1100 17 10001

+0110 +0110----

10010 10111

In each case the two BCD digits are added as if they were two binary numbers If the binary sum is greater than or equal to 1010 we add 0110 to obtain the correct BCD sum and a carry In the flIst example the sum is equal to 9 and is the correct BCD sum In the second example

20 Chapter 1 Digital Systems and BInary Numbers

the binary sum produces an iJlv~ BCD digit The addition of0110 produces the cortect BCD sum 0010 (ie the number 2) and acanyInthetbirdexample the binalY SUDlproduces acany This condition occurs wben the $W)) is greater than or equal to 16Altbough the other fout are less than 1091 the binary 9Ulll requires acOnectionbecause of die carry Adding 0110 obtain thetequiled BCD sum 0111 (ie the numblaquo 7) and 8 BCD CiUT

The additionoftwondigit unsipedBCD numbers follows the same procedure COIlSioll the addition of 184 + 576 1= 76() in BCD

BCD 1 I 0001 10000100 184

+6101 ~

0111--- 0110 +576

lJinarysum 0111 10000 1010 Add6 ono 0110

BCDsun 0111 0110 0000 7(1)

The flfSt l~ sigDiticant pili- of BCD digits produces aBCDdigi~SllDlof 0000 and a for the next pair of digits the second parr or BCD digits plus a ~Vi0U8 cany produces a sum of 0110 and a carry for the next patr()fdigits The third pair of digits plus acarry proltIUC~ a binary s~ of 0111 and does not require a correction

Decimal Arithmetic The represeiltation of signed decimal numbers in BCD is simiiarto the tepresentation of numbers in binaryWe can useeitheI the familiar signed-magnitude system at the SllZllOO-COI1I

plemelit system The sign of a decimal number is tJSually represented with four bits to to thefour-bit code ofthe decimal digits Itis customary to designate 8 plus With four Os 8 minus with the llCDequivalent oi9 whlcq is 1001 The sigiled~magnitudesystem is seldom used in com~tersThe signed-complerDem ~~ either the 9s octhe 10s complement put the lOscomplement is the one most useP To obtain the lOs complement of aBCD numberwe first take the 9s complement then add 1 to the least significant digit The 9s Complement is calculated from the subtracloo of each digit from 9

The prltXeduresdevelope4 for the signed-2s-complement system in the ~vious also apply to the signed-IOs-complement system for decimal mimberS Addition is done summing all digits including the sign digit and discafding the end carry This operatiQ assumes that all negative numbers are in 10s-complement form COOsider the (+375) + (-240) == + 135 done inthe signed-complement system

o 375

+9 760middot

o 135

lhe 9in the leftmost pOsition of the second n~ber tepresents a minllS and 9760 is the complement o( 0240 The two numbers are added and tbe end carry is discarded to +13SOfcourse the decimal ntmlbers insi~ tile computer includingthe sign digits in BCD The addition isdone with BCDOigits as described previously

Sectionl 7 Binary Codes 21

The suQtr8ction of decimalliUJ1lbets either unsigned or in thesi~-~Oscomplement systetn is the sameu in the binary case Taketbe 10s ootnplementof the subtrahend and add i~ to themin~nd ManyooDlputerslULvespeciaJ hardware to perform arithmeticcalculations directly withdecilnal oumbers in 8tDThe~u$etofthecoBlPuter can specify programliled Wtnlctionsto JOdonn the aDtiuJletiP oPmwoowithdeQmal n1UQ~ ~ywithout having to convell them to binary

Binafy codes for decimal digits requirea minimum of four bits per digit Many different codes can be formulated by~gjng four bits into IQ distinct combinations BP) and three other representative codes are shown in Table L5 Each code uses only 10 out ofa pOssible middot16 bit combinations that can be arranged with four bits The other six Unused cOmbinations have no meaning amt should be avoided BCD and the 2421 code are examplesofweigbted codes In a weigbtedcodeeach bit position

juBsigned a weighting f~in~awaythat eaehdigitcanbe ev~by 8dding the wei~ oran the lsin thecoded combination The BCD code has weights of8 42 and I which cotteshy

spondiothe powe1Of-two valuesofeaCh bitTbebitasSignmeatOll0 for example is interpreted by the weights to represent dedma16beCause 8 X 0 +4xt +2 Xl +IX 0 6Thebit combination 1101 when weighted by the ~ve digits 2421 gives themiddotdeCimal equivalent of 2 X I +4 gtlt I + 2 KO + 1 X 1 = 7 Note that some digits cantle coded in lw9 possib)e

ways in the 2421Q)(feFOr inke decimal 4 can be asSigned to bitCombinadon 0100 or 1010 since botbcOmbinatibns add upto a totalweight of4

middot1$ Fou Dlf(et Blnqry Code$ for thtJledmol DIgits

~ IICD DIgIt sal MZt Exeet) 8 4 -~1

0 1

000() middotmiddotmiddot0000 001)1 0001

oem 0100

0000 0111

2 0010 0010 0101 0110 3 0011 OQU 0110 0101

4 0100 0100 0111 oroo 5 0101 lOll 1000 1011 6 OlIO middot1100 1001 1010 7 middot0111 1101 1010 J001 8 1000 IUOmiddot 1011 1000 9 1001 11U 1100 1111

1010 oloi 0000 0001 Uaused IOU 0110 middotOOOl 0010 bit 1100 0111 0010 0011 combishynations

nOl 1110

lOW 1001

HOI 1110

1100 1101

1111 IOU) 1111 1110

22 ChaptfrliDfgltalSystemsaod Btoary Numbers

I1te 2421 rind the

e~l3~es are exampks Of self-complementing codes Such codes have~propertyjbatthe9s~plement ofa deCimal nfunberigobtairted directly by chang-

ing 1$ to O~$ finO tYSCfb1 sie~bycomple~mmgeaCh bit in the pattem)For example decshyimat3~Sis re~ fu tbeexcess3code as 01101100 1000 The 9s compl~ntof 604 isrepRse~l00liOOllelliwbich isobiainc(himply by complementing each bit of the

code (as with the 1 s coinpl~ofbin~rillDlbers)middot Theexcess~3code has been used in some oldel coritputers because of its selfcpmplement~

ing property Excess-3 is an unweighted code inwhich each codedcombinationis obtained-fJQm the corresPonQing bin3ryvalueplus 3 Note that the BCD code is1~ self-complementing TheS 4 ~~ Icode isan example of assigning both positive and negative weights to ~ decimalcodeInthis case the bit combiDation 0110isin~reted as oecimal2 and is calcu-

latedfrom8XO+4X 1 + (2) X 1 + (1XO=2 ~

Cra Code _ _ J

l1te output data QfmaJlfpbYsicaimiddot $)ShmlS are quantities that are continuous These data bemiddottonverted~digiWforuitJefore they art applied toaliigital system Contfuuous or ~nisCOIl~middotUitodigitalfonn bymeans of an rumlog~digitalConverter It is times ~~ent tousethe Gray code slown inTable 16torepresehtdigiuU data that have oon~ fMn8D8l08 dasaTheadvantage of th( Gray cOOeover thesllaigbt binary nIl11l1hPt~

~lt~thatoWY~ hit in the codegroup changeSin going from one number to the For examplcentbullin-goingfrom 1 to 8dleGray code cblngesfrom 0100 to 1100Only the fust changesfromOto l~the odter~ I)its mnaintbesame By contrast With binary numbers change from 7 to 8wrube from 0111 to lOOOwhich causes allfciur bits to change valUes

TabielAi GtPyCode

01 Decl COde Equivalent

~ 0000 0001 0011 OOlG 011Q Olll OlO 0100 1100 11m 1111 1110 lOlQ 1011

lOOt i

1000

o 1 ~ 3

4 5 6 7 8 9

10 11

12 13 14 15

SectIOnl7 BlnarYCod~s 23

The Gray code is used in applications in which the normal sequenceOrbiruuy rium~may produce an error orambiguitymiddot during themiddot transitionfrom ODeDWDber to the next If binary numbersareusec1 acbange forexaJIlple nom 0111 to 1000 may produce anintermediateershyroneous number 1001 if the value ofthe rigbtmost bit takes longer to -change than domiddotthe valshyues of the other three bits The Graycode elimb1ates this problem since only one bit changes its valve dUrlng aily transition be~een two numbers I

Atypical appli-cation ofmiddotthe Gray code is the representation of analog data by a Continu ous change in the angUlar position of a shaft The sQaftmiddot is partitioned into segments ana each segment is assigned a number If adJacent segments are made to correspond with the Qray-Codesequence ambiguity is eliminated between the angle of thesbaft and the value encoded by the sensor

Character Code

Many applications of digital computers require the handling not only ofnumberS but also of other characterS or symbols such as the letters of the alphabet For mstancean insurance comshypany with thousands of policyholders will use a computeX to process its files To represent the names and other pertinent information it is necessary to fonnulate bull binary code for the letshyters ofthe alphabet In additiQt1 the same binary qode must represent numerals and special Characters (such as $) An a1phanumeric character setis a set ofeiements that inclUdes the 10 decimal digits the 26leuersofthealp1iabe and a nutnbeof special~S~ a set conshytains between 36~d 64 elements ifonIy capital letters areincltided or between 64 and 128 e1eJDents ifboth uppercasemiddot and lowercllle etters are inclUded In the first case we need a bi- nary code ofsix bits and in the second we need a binary cooeO(seVM bits

The standaM binary code for the alphanumeric char8cters is the American Stahdard Code for Information InterCbange (A~n) which uses seven bitS to code 128 characters asshoWn in Table 17 The seven bitsof the code are desipted by b~through h With h the mostsigshynificant bit ~e leUer A for example is represented inASCn as l(l()()()Ol (column l00~tOw 0001) The Ascn ()()de also contains 94 graphic characters that can be printed and 34 nonshyprinting characters used for variQUS control functions The graphic characters consist of the 26 uppercase letters (A through Z) the 26 lowercase letters (a through z) the 10 numerals (0 through 9) and 32 special printable characters suchaS andS

The 34 control characters are designated in the ASCTItable With abbreviated nalne8 They are listed again below the table with their functional names The control characters are used fQr routing data and arranging the printed text into a prescribed format~ There are three types of control characters format effectors information separatOrs andcommumc~on-COnlrpl char~ IlCters Format effectors are characters that control the layout ofprinting They inciude the fashymiliar word pr6cessorand typewriter controlssucb 8$ bac~pace (BS) horizontal tabulation (HT) and carriage return (CR) Information separators are used to separatetbe data into divi~ sions such as paragraphs and pages Theyinclude characters such as ~ordseparator (RS)and file separator (FS)The cODlIDunication-control characters are uSefulduriDgthe transmission of text between remote tenninals EXllll1plesof conlmunicatiOn(ODtiol~ are STX (start oftext)-and ETX (end of text) whicb are used toframe a text mesaagetnQlSlnitted through telephone wires

24 Chap~er 1 Diglt8l Systems and Binary Numbers

rblel7 Amerkcm5tandard Code for Information (nterclHlnge(ASCII)

b~jbzb 000 001 010 on 100 101 no 111

0000 NUL )jLP SP () p P 0001 SOH OC1 1 A Q a q

R0010 STX OC2 2 B b r 0011 ETX DC3 3 C S Ii S

0100 EDT 0C4 $ 4 D~ T d t 0101 ENQ NAK 5 E iU e u OUO ACK SYN amp 6 F V f v 0111 BEL ETB 7 0 W g w 1000 B8 CAN ( S H K h x 1001 HT EM ) 9 I Y Y 1010 LF SU~ 1 Z j z lOll VT ESC + 1lt r k UOO FF PS lt L I I 1101 Cit OS == - M 1 m 1110 SO R~ N 1 n shy

-0PIt st US f 1 0 0 DEL

r- Control characten

NUL NlI]l DlE Data-inkescape SOH Start of hea~ng DC1 Device cOntroll STX Start of text DC2 DevIce io~1lOi2 ETX End (Jftext i DC3 Device corUlri1 3 OOT End oftraIlsmission ~4 DeVicecoQtrol4

ENQ ampqwry NAK Negativeackilowledge ACK

Acknowledge SVN Sync~nous idle

Btl Bell ETB End-of-tmnsnussionblOck sS Backspace CAN CanCel HT Horizontal tab EM End of mediUrlt LF Lintifeed SUB Substitute VT Vertical tab ESC escape FF form feed FS File separator CR Carriigeretum GS Group separator SO shift Ollt RS Reoord sepuator SI Shlftin US Unit separator SF S~e DEL Delete

ASCII is a seven-bit codebutrnostcompUters manipulate anejght-bit quantity asa unit called a byte Therefore ASCII characters most often are stored ~e per byte The

I biti~sometimesused forotlef purposes depending ontheapplicatio~lFor example printetS recognize eightmiddotbit AScn chaiacterS with themost sigoificaot bit ~twO An atkJlitlo

Section 18 Binary Storage and Registers 2S

128 eight-bit characters with the most significant bit set tol are used for other symbols such as the Greek alpbabet or italic tyIe font

Error-Dtectlng Code

To detect errors in data communication and processing aneigbth bit is sometimes added to the ASCll cbaracter to indicate its Panty Aparitybit is an extra hit included with a message to make the total num~ of ls either even or odd Consider the fo119wing two cbaracters and their even andodd parity

With even parity With odd parity Ascn A = 1000061 01000001 11000001 ASCI( T == 101deg100 11010100 01010100

1

- Ineacb casewe insert an extra bit in the leftmost position of the code to produce an even number of 1 s intQe cbaraeter for even parity or an odd number of 1 s in the character for odd parity In generlll one or tbe oth~r parity i~ adopted with even parity being more common

The parity biqsbelpful in detecting errors during the transmission ofinformation from one location to another nisfuJictiOD is bandIed by generating an even parity bit at the sending end for ~h character The eight-bit characters that include parity bits are transmitted to their desshytination The parity ofeachebaracter is thetichecked at the receiving~nd If the parity of the received cbaracter is Dot even then at1east on~bit has changed value dUring the trmlsmission This method detects one three or any odd combination of errors in each character tb8t is transshymitted An even combination oferrors however goes undetected and additioDaterror detic- shytion codes may be needed to take care of that possibility

What is done after an errQlis detected depends on the partieu~ application One possishybilityis to request retransrois~ion of the message on the assump~on that tbeenigtr was ranshyd()m andwill not occur again Thus if thereeeiverdetects a parityerrorit sends bai~ the ASCII NAK (negative acknowledge) control cnaracter consisting ofail even-parity eight bits lOOlOl01H no error is detectedthe ~iversends back anACK (aCkno~ledge) conshytrol character namely 0000011 O The sending end will respond middotto an NAK by tranSmitting the message again until the correct panty is received Ifmiddot after a number of attempts the transmission is still in error a message can be sent to the Operatai to check for malfunctions in the transmission path

BINARY STORAGE ANORECiISTEIlS

The binary infonnation inadigitalcomputermust have a physical e~stencein some medium for storing individual bits A binary cell is a device that possesses two stable sttes and is cashypable of storing pne bit (0 or 1) oflnfotlllation The input to tbe cell receives exciJation sigshynals that set it to one of the two states The output of the cell isa pbysicalquantity that distinguishes between the two states The irtformationstored in Ii cell is 1when the cell is in one stable state and degwhen the Cell is in the other stable state

26middot Chapter 1 Digital Systems and BtnaryNumbers

Registers

A register is a group of binary cells A register with n cells can store any discrete quantity of middot information thatcontains n bits The state ofa registeris an n-tuple ofls middotand Os with each bit designating the state of one cell in the register The C()ntent ofaregister is a function of the int~rpretation given to tbeinformation stored in it Consider fQf ex~ple a 16-bitregister with the following binary content

11 00001111001001

middot Aregjs~ with 16 cells can be in one of 216 possible statesIf one asstimesthat the content cif the register represents a binaryinteger then the register can store any binarydumber from Oto 216 - 1 For the patticularexample shown the content ofthe register is the binary equivshyalent(lftbe decimal number 50121 If one assumes instead that the register stores alpbanushy

middot meric characters of an eight-bit cooe then the content of the register is any two meaningful characters For tht ASCII code with anevenplirityplaced in the eighth most significant bit position the register contains thetwo charactersC (the lefunosteightbits) and I (the rigbt~ most eight bits) If however one in~rprets the content of the register to be four decimal dig- its represented by a four-bitcode tnenthe content of the register is a four-digit decimal number In theexcess-3 code the register holqs the decimal nutriber 9096 The content of the registe~is meaningless in BCD becau~e the bit combinatiOn ltob is 110t assfgned to any decshyimal digit From this example it is clear that a register can store discrete elements of inforshymation and that the same bit configuration Inay beinterpreted dlffe(ently for different types of data

tmiddotmiddotReglsterTrail Adigitalsystenlis characteriZed by its registers and the components thatpetfolin data proshy~ssingIIl digital sy~tems a rcentgister tra1lsfer operation is abasi operation that consists of

middot a transftr of hiJWy hUormation from one ~t of registers into ano$er set of registers transfer may be dir~ctfr9m one regist~r toanlt)ther or may pass througb datamiddotprocessing circuits to petformaD operation Figure L 1 illustratel the transfer of iidOrnuttion among regshyisters anddemonstratespictorlallY [the tr8ll~~ ofbinaryinformation from akeyboard a register in the memQryullit Thehlputunit~s assumed to have a keyboard1 control cuit and aninput register Each time a key is strock the control circuit enters an ImnV$_

lent eight-bit alphanumeric character coqe into the input register We shall assume that code used is the ASCII code with an odd-parity bit The information from the input regisshyter is transferred into the eight-least significant cells Qf a proeessOr register After transfer theinpui register is cleared to enable the control to insert a new eight-bit when the keyboard is struck again Each eight-bit character transferred to the pro1c4ess(raquo register is preceded by a shift of the previous character to the next eight cens on its left~

middot a transfer -of four characters is completed the processor registeris full and its contents transferred into a memory register The content stored in die memOry register shown in Figl came from the transfer of the characters J 0 H an~ N aftet the four ap)lroJ)riatt keys were struck

Section 18 Binary Storage and Registers 27

FIGURE 11 Transfer of information among registers

To process discrete quantities of infoiniatiori in binary form a computer m~st be promiddot vided with devices that hold the (lata to be processed and with circuit elements that manipmiddot ulate individual bits of irifonnation The device most commonly used for holding data is a register Binary variables~ manipulated by means of digital logic circuits Figure 12 il~ luslrates the process of adding two l()bit binary iUlmbers Themeniory unit which no[shy

mally consists of millions of registers is shown with only three ofits registers Thepait of the processor unit showncoDsistsmiddotofthree registers-RI R2 and R3~getherwith digital logic circuits that manipulate the bits of RI and R2 and transfer into R3 a binary number equal to their arithmetic sum Memory registers store information and are incapable of pr0shy

cessing the two operands However th~ information stored in meDij)iybanbetransferred to ~ processor registers and the resUlts obtainedin processor tegisters can be transferred back into ame~ry register for storage Untill)ecded again The diagram ~wsthe90ntents of two

operands transferred from twoJDemoryregisters into RI imd R2 The digital logic circuits produce the sum which is transfened to register R3 The contents of R3 can now be 1riUlsshyferredback to one of thetnemory registers

The last two examples demonstrated the infonncion-flow capabilitieSofa digital system in a simple manner Themiddot registets of the ~ystem are the basic ele~ents for Noring and holding the binary information~igitallogic circuits process the binary ihfonaation stored in the

28 Chapter 1 DigIt bullbull Systems and Binary Numbers

Sum

FIGURE 12 Eumple of blnarylnfonn~t1on processing

registers Digitallogiccirctiits and registers are covered InChQpteB 2 throQgh 6 The metlilOlY unit is ~xPIained ill 9aptet 7 Th~ descriptton of register opetJtions at the register level and the design of digital systems are covexed in Chapter 8

19 BINARY LOGIC

Binary logic deals with variables th~ take on two discrete valueund withoperations that sumelogicalmeaning~ The two val~s the variableussume may be called~ydifferent (true andalse yel and no etc) but for ourp1llpQSe it is cpqVenienttotbink in terms of and assign the values llUld O The binary logic intr0ducedin this section is equivalent to algebra oalledBoolean algebra The fannal presentation ofBoolean algebra is covered in detail in Chapter 2 The purpose ofthis seCtion is to introduce Boo algebra ina matmerandlate it to digitallogiccircuits andmiddotbinarYsignalsmiddot

Section 19 Sinary logic 29 ~

Itkltn of IInary logic

Binarylogic consists of binary v~les and a set of logica1middotoperatiQDS The variables are desigshy ~by lettell of thCalplWlet~such asA B C x yz etc with eaCh variable baving two and oniy

two distinct posSible valueS 1and O There are three basic logical operations AND ORand NOT

1 AN]) This ~peration is represented by adotorby the absence ~f an oPerator For example x bull y =z or xy = zis~ x ANDy is equalto z~ThelogicaloperationAND is interpreted to mean that z == 1 ifand only ift~ land y = 1 otherwise z = O (Reme~r that x y andzare binary v8riablesand canmiddotbe equal either to 1 or Omiddotand nothing eise)middot

2 OR This operation IS represented by a plus sign For example x + y =z is read x OR y is equal to z meaning that z 1 if x = iorif y = lorifbothx= 1 and y = 1 If bqth X - 0 andY Omeo z= O

3bull NOT This operation is repf6sented by a prime (sometimes by an overbar) For ~xample x =Z (or~ =z) is read notdsequalto 1 meiming that z iswkatx isnot In other

words ifx = 1 then z == 0 but if x == 0 tnenz = L TheNOT operationisals(1 reshyferred tolls the complement operation since it changes ~ 1 toOand a O to 1

bull bull lt Binary logic resembles binary arithmetic and themiddot9peratioos ANDahd OR have similarishy

ties to multiplication and addition respectively In fac~ the symbols used for AND and OR are the same as those used for multiplication and addition However binary lOgic should not be conshyfused withbinaryarithIrietic One should realize thatan arithmetic variable designates a numshyber that may consist of many digits A logicmiddot variable is always either 1 or O For example in binary arithmetic we have I +1 =10(read~one plus ()fie is equal to 2) whereas in binary logicwe have 1 + 1 1 (read one OR onds equal to one)

For each combination of the values oix and y bullthere isa value of ~ $pecifiedby the definishytion of the logical operation D~linitiops of logical~perations maybe listed in a compacHorm called truth tables A truth table is atable of anpbssible combinations ofthe variables $howshying the relation between the values that the variables may take and the resultof the operation The truth tables for th~ operations ANDand OR with variables x and y are obtained by lis~ng

all possible values that the variables may have when combined in pairs bull For each combination the resUlt of die operation 18 theillistedin a separate row The truth tables for ANDORand

NOT are given in Table La These tables clearly demonstrate the definitionf the operatibns

Table 18 Truth TcibJts of Logical Operations

AND OR NOT

x y xmiddoty x y x+y

0 0 0 0 0 0 1 0 0 1

10

1 0 d 1 0 1 I 1 1 1 1 1

bull~lt~m

30 Chapter 1

Logk Gates

Digital Systems and Binary Numbers

Logic gates are electronic cirellit that operate on ~

variable

or mpre mput tignals to produce an output signal Electrical signals sUch as voltages orrutrents exist as analog signals having values over a given taDgebull saYOt03 V but in a digital system are interpreted to be either of two recognizable values 0 or 1 Voltage~opetated logic Circuits respond to two separate voltshyage levels that represent a binary varjable equal to logic I bt logic O For example a partic- ular digital system may define 10gicOas a signal equal to 0 volts lind logic 1 asa signal equal to 3 volts In practice each voltage levelhiS an acceptable rangeas shown in Fig 13

The input te~nals of digital cikuits accePt binary signals within the allowable range and respond at the output terininals with binary signals that fall within the specified range The intermediate region between the aJl()wed regions is crossed only during aState transition Any desired information for computing or control can be operated tm by passing binary signals through variQUS combinatioDsof logic gates with each signal represebting a particular binary

The graphic symbols used to deSignate themiddotthree types of gates are Mown in Fig 14 The

gates are blocks of hardware that prooocc tbeequivalent of1ogic~1 orlogic() output signals

Volts

- FGURl13

x

y

Exampleof binary slgnaJs

Signal ratlge for logieO

(a)~omiddotinput AND gate

FIGURE 14 SymbOls for digital logic circuits

(c)NOT gate or invert~

Problems 31

x-lU 1 11 P 0

y 0 0 11 1 ~

ANDxy 0 0 rTl 00

ORX+Y~ NOT x 11 0 0 I 1 1

FIGURE 15 Input-output 5Igals for gates

FIGURE 1

A B C

Gates WIth mlltlple JnpUU

A B C lJ

~

if inPllt logic ~ts are satisfied Theinput signals xaDd y intheNDaadQR gates may exist in ~ oHow-possible states 00 10 11 or 01 Il1ese ibpu~ampignals_ shown inFig lStoshygetber with the corresponding output signal foreach PfCThI~tiaiug~iDustrate the reshysponse ofeaclt gate to the four input signal~The~llisofthetiminadiagram represents time and the vertical axis sbo~~~~ it cbapg~botwcen~possible voltshy

age levels The low level represents logic O tJte high level l1lteAND _ responds With a logic ~ ~tput sipl wh~ both input ~~)e 1middot1~ lIieOR S-~with a logic 1 outpUt signal ifanylnput sigrudis lOgic 1 TheNOTgateis~~ to BUll invedet The reason for~nameis~t froJn the signalmsponae inmiddottbe timitt8 diagramwhicbsbows that theoUtputsignal inverts the logic sense of tbeiDpUtsigll8l

AND and OR gates may bavei)lQte tbantwQinputs M AND8_~itti ~input$andan OR gate with foU) inputs are shown in Fig 16 The three-inPllt AND gate responds With logic 1 output if all tbreeinputs arelogic 11jleoutputproduces lOgic Oifanymput is logic O-The

four-input OR gate responds withlogic 1 ifany input is logic 1 its clu1ptltllCCoines logic oonly when all inputs are logic O

Answers to prvblems marked with middotappearaHbe ClOd ofthe ~

11 lJltthe octal and beXadecimalliurilbers trom16ui 32UdngA B1l1ld C forthebst~ digits Usttbe numbers from 8 to 28 in base13 bull

I

12t What is the exact D1Jllbcr of bytes in a system that contains lta) 32Kbytoe (b)64M ~and (e) 640 byte$ middot7 t

32 Chapter 1 Digital Systemsand Binary Numbers

13 Convert the following nu~bers with the indicated bases to decimal (a) (4310)s (b) (198hz (c) (735)8 (d) (525)6

14 Whllt is the largest binary number that can be expressed with 14 bits WhlIt are the equivaleDt ~~ iinal and hexadecimal numbei-s

--

15 Detemrine the base of thl1 numbers in each case for the following operatio~ to be correct (a) 142 = 5 (b) 5414 = 13 (C) 24+ 17 == 40

16 The solution$to the q~cequation xl - Ux +22 oare l1 3 arid x =6 What is the base of the numbers

17 Convertthehexadecimal ntmIher 68BE to bitiary and then convert it ~mbinary to octal

18 I Convert the decirpal number 431 to binary in tWo ways (a) Convertd~y to binary (b) conshyvert first to hexadecinla1 and then from ~decimalwbinary Which method is faster

19 amppress the following nqrnbersin decinud (a) IQ11O0101)z (b) (l65his (c)(2624)8 (d) (FAFA) 16

(e) (10101010)2

110 Convert the following binary numbers tobexadeoimal and todecitnal (a) UOOlO (b) 110010 Explain why the deCimal answer in (b)is 4 times that in (a)

111 Perform the followingdiviskmin binary 11 Ion + l()t

112 Add IlniImultiply tfle following numberswiihout converting them to decimal (a) Binary nuniberilOll aiIdlOh (b) He~uumbers 2E aDd 34

1~)( Do thefoHowing con~ersionproblems (a) CorivertCiecimal2731S to binary (b) CakUlate the binary eqUivalent (f 213 outto eight pl~Then Convert from binary to

imalHowgJose istbe result to 2131 (c) Convert the binary resukin (b) into hexad~ lb~oonvert ~result to decimal Is answer tbesame

114 Obtain the is 8nd 2s complementsofthe foUowing binaryDumbcentrs (aj l)()()(J()OO (b) OOOOOOOO (c) 11011010 (d)01l10110 (e) 10000101 (0 11111111

115 Find the 9s and the 10s complement of the following detimal numbers (a) 52734630 (b) 63325600 (c) 25000009 (d) 00000000

116 (a) Find the 16s complement of B2FA (b) Convert B2FA to binary (c) Find the 2scomplement ofthe resultin (b) (d) Convert the answer in (c)to hex~malandco~ with ihe an~wer in (a)

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 10: Chapter 01 - Mano

10 Chapt~rl Digital Systems and Binary Numbers

D~I~llhed Radix Complame~middot Gi~en a number N in base r haYing n digits the (r - 1)scomplement~f N is defined as

(rll - 1) ~NFotdecimainumbersr -= Wandr -1 9sothe9scomplementofNis (10 - 1) - N IIi this c~ 10 represents a number that consists of a single 1 followed by nOs 10 - lisartumberrepresentedbyn9sFOrexampleifn 4wehavel04 = 10000 and 104 - 1 = 9999 It follows that the9s complement ofa decimaJnumber is obtained by subtracting each digit from 9 Here are some nwnericalexamples

The 9s complement of 54670(Ms929999~ 546700 453299 bull - I

The 9scothplement of012398is999999~0l2398 =987601

For binary pumbers r =2 and r - l~ 1 sothe 1s complementofNis(Z - 1) - N Again 211 is represented by a binaty number thatconsistsofa 1followed by Ii0s 211 - 1 is abinary number represented by ~1s~FOr example if 11= 4 we have z4 = (10000)zand 24 - 1 = (1111h Thus the ls complement of a binary number is obtained by sUbtractiDg

each dig~t from 1 However when subtracting binary digits from 1 we can have either I -0= lor1 - 1 = 0 which causestbe bit to change from Oto 1 0( from 1 to 0 respec- tively Theretore the ls complement of a binary number isfonnedby changing 1s to Osand Osto 1s The f9llowillg are somenumqical ex~esI

~

The ls Complement of 1011000 isotOOiu

The 1scompieme~t oHlIOUOI is 10 tOOlO

The (r-l) s compleme~ ofoctal or b~xadechnalnumbers i~6btained by subtracting eaeh digit from 70rF (diicimallS) respectively~

Radl~ C~mplement

The s complement of an n~digit number N in baserisdefinedasrmiddot Nfot N i 0 and as ofor N = O~ Comparing with the (r- l)s ~entwe note that ~rs complement is obtained by adding Ito the (r - l)scomplement smcer - N= HA-- 1) - N] L lhus the lOscomplementof deein1al2389 is 76lO +1 = 7611 and is otltamed by adding 1 to the 9scomplernent value The 2s oomplementofbinary 1011oois 010011 1 =010100 and isobtained by adding 1 to the ls-complement value

Since 10 is a number represented by a 1 followed by n0s1011 N Whicb is the10S com~

plementof N can be fonn~d also by leaving allieasl sigtrlficani Os Unchanged the first nonurO least significant digit from 10 and SUbr8Cting all higher significant

from9 ThUs

the 10s complement of 012398js987602

and

11 Sectlon middot15middot Complements

The 10s complement ofthefustnumber isobtaineltibysublriiCtingSfrom lOin the least sig~ nificant position and subtracting all other digits from 9~ The 10s complement of the second number is obtained by leaving the to least significant Os unchanged subtracting 7 from 10 and subtracting the other three digits from 9

Similarly the 2s complement ~be fonned by leaving 1ll11east significant Os and tbe first 1 unchanged and replacing I swith Os and Os with ls in allother hi~r signifIcJUlt digits For example

the 2s cORlplement of 1101100 is 0010100

and

the 2scomplement ofOllOllHs 1001001 _ - r

The +s complement pf therrrst nJUDber i~ obt4iriedby I~vingthetwo least significant Os and the first 1 unchanged andmiddotlQen replacing ls with Os and Oswith 1~ in the other four most sigmiddot nificant digits The 2s lXgtmplement qf the second number is obtained byleaving the least sigshynificantmiddotl unchanged and (fOmplementing all other digits

In the previous definitions it was assum~dtMt the D~bers did not have a radix pomt1f the original number Noontains a radix point the point should be removed temporarily in order to form the s or(r 1)s complement The radix point is then restored to the c9ll1plementshyednumber in the same relative PositionIlis abo wOrth mentioning thatfhecontplement oftbe complement restoresthe number to its original v41ue To see this rel~tionsbipnOtethat the ts complement of N is n - N so that themiddot complement oft1e complement is n - (n - N) == N and is ltlqual to the original number

Mr8Ctiton wltl1 Complementsmiddot

1le direct metb()jiofsubtraCtion taught in elexnentaty schpOls uses the bottow concept In this QlCth9dwebortowa I from a middothigher significant position when the minuend digit is smaller than the subtrahend digit The tDethod wor~wen when peOple perfonnsubtraction with paper andpeooillIowever when subtlaction is implemented withdigi1al bardw8le the method is less e~citnt than the method that u~s compl~m~ts

The subtraction of two n-digitunSigneq numbers M N in base can be done as fonows I

1 Add the minuend M to the scompleme~t of thesubtramphend N Mathematically M+ (n N) = M N +

2 IfM ~ N ttie sum wiUproduce an end cury 11 which caD be discarded what is left is the resultM N

3 If M lt N the sum does not produce ~tlend carry JUld iseijUattor (N~ Ji) which is the s complement of (N - M) To obtain the answer in a familiar form take the s complement of the sum aruI place a negative sign in frorit

12 Chapter 1 Digital Syst-ems and Binary N~mbers

The following examples illustrate the procedure

plPi1I VsinglOs complement subtract 72532 - ~250

M = 72532

lOs complement of N + 96750 Sum= 169282

Discard end caIry lOS = -100000 Answer = 69282

Note that M bas fiv~ digits andN has only fourdigitsBoth numbers mtast have the same numshyber of digits sowe wrlteN as 03250 Taking the lOscomp~ementofNptOducesa9 in the most significant PositionThe occurrence of the end carry signifies that M ~ N 8ndtlult ~ result is therefore positive

Ulling 10s complement subtract 3250 - 72532 - ~ ~

M = 03250 JOscornplementof N =+27468

Sum= ~0718

There is no end carry Theref()re-theanswer is--(10amp complementof30718) == -69282 Note thatsince 3250 lt n532~the result is negative Becauwe are dealing with WUiigned

numbers there is really no way to get BnunSigned result for this case When subtracting complements we reoogilize the negltive answer from the~sence of the end carry and complemented result When workingwith paper and pencil we c8nchlnp the aDswer

signed negative number in oider to putH inafamiliar form Subtraction with complements is done with binary numbers in a similar manner uing

procedure outlined previously

EXAMPLE 17

Given the two binary numbersX = 1010100 and Y =1000011 performtbe $UbiDctiG (8) X - Y arid (b) Y - Xby using 2scomptem~ts -

f

- -

Section 15Complements 13

(a) x = 1010100

2s complement ofY= + -0111101

Sum = middot 10010001 Discard end carry 27 = 10000000

Answ~ X- Y = 0010001

(b) Y == 1000011 2sco~lement of X = + 0101100

Sum= 1101111

There is nQmiddotend carry Therefore the answer is Y ~X= -(2sq)mplement of 1101111) = -0010001 Subtractionof unsigned D1lJllbers ~ also bed()neby means of the (r - 1)s complement Remember that the(r- l)s complement is one lesstharithers complement BeCause of

ibis the result of adding the minue~ to tJte coQlplement of the subtiah~ndPtOductS itsum that is one less than the correct 4ifference when an end carrY oCcurs Removing the end carry and adding 1 to the sum is referred to asan end-around carry

Repeat Example 17 but this time using rs complement

(8) X y = 1010100 - 1000011middot

X= 1010100

rs complementafY= + olfnoo Som = 10010000

End-arOundmiddot~ =- ~ ~ Answermiddot X Y= middot0010001

(b) Y - X = 1000011 - 1010100

Y = 1000011

1s complement ofX = +0101011

Sum = 1101110

There is no end carry TherefOre the answer is y - X = -(1s complement of 1101110) = -0010001

bull Note that the negative resultis ob~ by taltingtbe 1 scomplemeilt of theJWltsince this is the type ofcoDiplementused The procedwewithendaroundoanyis aIs(gt Iijlpliclbleto subshytracting Unsigned deciImdnumQers with 9seomPlement

14 Chapter 1 Digital Systemsand BinayNumbers

16 SIGNED BINARYNUMBER$ ~

Positiveintegers (including zero) CaBbe ep~~ 11$ unstPecl numbers However to repshyresent negative integers we need a notation for negative srn ordinary arithmetic a negshyative number is indicated by a mulUs signmdapOsitiv~Pwtlt)e~ by aplus sign Because of lJardware limitations computers mlstrepresenlev~With~ digitsIt is customary to represent the sign witb a bit placed intheleftmotp6sitiolwfthe number The convention is tltl make the sign bit 0 for positive and 1 for negative

Itis important to realize that botp siped and unsignedtDnary 11UJDbers consist of a strfug of bits when represented in a com~ TQeuser detem1inesWbether the number is signed or unsigned If the binary number is signed then the lefuriostbitreple$ellts thtsign aud the rest of the bits represent the number Ifthebinaryllu~beiis~ tObe unsigned then the left most bit is the most significant bit of the l)uMber Fdre~the~~f bits 01001 can be consideredas 9 (unsigned binary) or as +9 (Sighedbitia1j) ~USJtheteftmostbit is O The

string ofbits 11001 represents the binary ~~v~ento~ ~w~nc~idered as an unsigned number and the binary equivalent of 9whenconsidered1l si~riumPer This is because the Ithal isintbe leftmost positiondesignatesampC nega6ye_~QtherfourJ)its represent bishynary 9 usually tlere is no cotifusionin identifying thebits~the~Qfrepresentation for the number is known in advance ~

The representation of the signed numbers in the lastexainple is referred to as the signed magnitutk coDvention In this ~otati()nthenurnber C4mSiampesOCa mQ~~andil~ymbolH

or -) or a bit (0 or 1) indicating the sign This is the representation ampr~~used in ordinary arithmetic When arithmeti~ operatioBslllieimplerneJltcldin~cOQlPuter hii more convenient to use a different systemrefetred t(gt as the si~cqmptement system~ for repre- senting negative numbers In thissystlm a neg8tielliun~r isjhdic~ted by its cornplc~mc~nt Whereas the signed-magnitude system negates a nlllllher by cbanging its sign me signed-comshyplement system negatesanwnber bytakin$ its~OinPleltleitiSinoepositife numbers always start witbO(plusin tte leftmost pOsition thecompktllint wiilalwaysstart with a 1 indicating a negative number The siped-complemelt system can use olthertbe 1s Or the 2s but the 2s complement is the mos~comtliOfi

As an exampleconsider the number9re~~ed in binary with eight bits + 9 Is sented with a sign bit of Oin the leftri1ostpOsition oIIOv~by the binary (equivalent of 9 which gives ()()()olOOl Note thai all eigbtbits must haYampa v~therefore O~s are inserted folshylowing the sign bitllp to the first 1 Although ~ is only 01K way to tepresent +9 there three different ways to represent 9 with eight ~its

s~gned~magnituderepresentation 10001001

sigried-l s-complement represe~on~ 11110110

signed-2 s-complemerit representatim 1ttltllU

In signedmagnituamp -9 isobwned from +9 by changing the sign bitmtbe leftmost ~iti(ln tromO to L In sigl1ed~ lroomplement 9isobtaidedtf~~tiog all the bits of includinj the sign bit Thesigned-2~sco~re~Qf-9 is obtampDedby ihe 2s complement oftbepOsitivenumberincludingtbesijnbIt

Sectlont6 SIgned8lnary NumberS is

Table 13 Slgtlfd Biliary Humbm

+7 +6

+5 +4 +3 +2 +l +0 0 -I

-2 -3

4 -5 -6 -1 -8

Olll 0110

0101 ( 0100

001l 0010 0001 0000

IIll 1110

nOI noo Ion 1010

1001 1000

OIll Oito eHOl OHIO OOU 0010 0001 0000 1111 1110middot dOl 1100 Ion

lOti 1001 1000

0111 OUO 0101

0100 0011 0010 0001 0000 1000 1001 1010 IOU 1100

1101 1110

lUI

Table 13 lists all possible four-bitsignedbinaryaumbers in the three representations The equivalent decimal number Is also shown for refelenoeNote that the positive n~ in all three representations are identicaland have 0 inthelefmostpcsiticm The signed2sshycompl~mentsystemhaironly onemiddotrepresentation for 0 which is always po$itive The other tw()systetns- mlve either a positive 0 or a negative 0 sometbingnoteDcounteredin ordinary arithmetic Note that all negative numbenhave alin the leftmost bitpositi~ that is the way we distinguish them from the positivenumbers With fout bits we can repreSent 16 binary numbers In the signed-magnitude aDd thelscomplement repre$eDtatipns there are eight positive numbers and eight negative numbers inciUdingtwo zeros In the2s-complement representation there are eight positive numbers includi0a one zerQ and eight negative numberS

The siped-m_gnitude system is used in ordiIlary arithmetic but is awkward when emshyployed in computer arithmetie becauIe of the ~parate bandIinJ bfthesipand the magnitude Therefore the signed-compiement systeni is normallyused The ls ~t imposes some difficulties and is seldom USedJor arithmetic openitiOns It is U$eful aSa lo~ operation since the change of 1 to Obrmiddot() to 1 is equivalent to a logical complement Operation as will be shown in the next c~The discussion~f sigiled binary ariduneti~ that fol10ws deals exshyclusively with the signe4-2soomplt_nt~tatJonQfnegadveilUlilbers hsame proshy

cedurescan beappJied to the sigMdrs-comPlemeD~Iysby incIudiOI tbe~arotmdcarry as is done with unsigned numbers

J6 Chapt~r 1 OlgltalSystlf(ns and Binary Numbels

Arithmetic Addition

The addition of two numbers in the signed-magnitudelYs_foUowsthe rules ofordinaiy arithshymetiC Ifthesi~s arethesam~we addthetwOtt~gni1U~~d ~vetbe sum the CCmmon sign Iftbe signs are diffe~nt we subtract tllcsmaUermagnitude frOtnlthe larF and give the differshyehtethe signof the larger magnitude For example (+25) +( - 37) = ~ (37 - 25) = -12 and is done by subtracung the smaller magnitude 25 from the larger magnitude 37and a~nding the sign of 37 tGtbe result Ibis is a process that requires a corripanson of the signs and magnitudes and then performing eithr additi()n or subtraction The same procedure applieato binary numbers in sigped-magnitude representation~Incontrast the rule for adding numbers in the signed-corppleme~ sy~tem does not require a comparison or su~ traction but only addjtion The procedure is very simple andcanbe stated as follows for binary numbers The 8ddltion oftwo signed binary numberS with negative numbers tepresented in signed- 2sComprement fonn is obtaiIled from theadditlooofthe two numbers includingtheii sign bits

AcentiirrY out oftbe sign-bitposition is diScacded NumerIcal e~aihpledotai1dition follow

+ 6 00000110 - 6 11UI0tO I

+13 00001101

+13 00001101 +19 00010011 + J 0Q900111 + 6 00000110 6 11111010 ~13 11110011 -1~l 11110011 7 illl1001 -19 11101101

I bull bull ~

Note that negative numbers musthil iriitially in 2seompkmentform and that if the swn ~ ~afterthladdit40nis negativeins in2s~p~t fOl1Jl - In each of thefoDrcasestlteoporationperfol1JlC(lis additionwitb the sign bit iilcluded Any catTY o~of~~-bit~onisdisc~ and negative resultsareButomaticallyin 2sshyromplementfoon

In order to obtain acOrrect answer we mustensQre that the result has a sufficient of bits to accommodate the swnlfwestartwith t~on-bltnumbers and tbeswn occupies n + 1bits we say tblltan overflow occurs~Wheri one perfotmStbc ad(JitiOJl with nllllIPTJllVIl

pencil aq overflow is not a preblem because we arcr noflimitecLbythewidth of the page jUst addanothcentr 0 to apositive number or another 1 toa negative number in the mOst cant positi()n to extend thenwnber to n+ 1 bitSand theQ perform addition Overflow is

problem in computers beqiusetbe number ofbi~~ bolla ~befis finite and a result ex~ tI1efinite val~e hy lcatmotbe accommodated

The compJement form of representiQg negativetlQUlbers is unfamiliar to those usedto signed-magnitude system To itetermine th~ value of II negatienumber insiped-2s COlIlpJe

mentit0is~ to CODVerttbe numbcr to apositie ntirit_ ~ place itiDa more formPor ~plethesig~binary number qUl00~ lii~egativebecausothe leftmost

t 1182s c0J8plemen~js~UlwhUhi$~ binaryeqqivalen of +7Wcmiddottherefore nize the Ori~nal ~atiy-eQumber to be equ~ lo-7 1

Sectlonl7 Bh1ary Codes 17

ArIthmetic SubtractIOn

Subtraction of two signed binafy numbers whe~negative numbersare in2s-complement form is simple and can be stilted as follows

Take the 2s complement of the5ubtraltend (including the sign bit) and add it to the minuend (including the sign bit) A cany oU1of thesignbit position is discarded

This prOCedure is adopted because a subtraction operation can be changed to an addition operation if the sign of the subtrahend is changed as is demonstrated by the following relationship

(plusmnA) ~ (-tB) = (plusmnA) + (-B) (plusmnA) - (-B) =plusmnA) + (+B)

But changing a positivetwober toa negative n~ber is eaampily done by taking the 2s compleshy mentof the pQsitive number The reverse is also tiUe~use theCOmPle~n~ of a negative numshyber in complement form produces the equivalent positive number To see this consider the sJlbtr~ction ( 76) -- (13) = +7 In binaIy_ with eight bits this ()peiationis written as (11111010 11110011) The subtracti~ri ischmlged ~ addition by taking the 2s complement ofthe subtrahend (-13) giving (+13) In binaly tbis~ 11 niOlO+ 00001101 = lOOOOOU1 Removing the end~ we obtain the ootrect answer ()()()()() III (+7)

Itisworth noting that binary DUmbersinthe signed-complement system are added and subshy tracted by the same basic addition and suPtraction rules as unsigned numbers Therefore comshyputersneed omy one common hardware circuit tobandle bothtypcs ofaritbtnetic The user or programmer ~ust interpret the reswtIi of $l1ch addition or subtraction differently depending on whether itisassumedtha~the numbe~ are signed ltr tinsigned

j

BINARY CODES

Digitalsystems use signalsthat have two distinct values1Uld circuit elements that havetwostashyble states There is a direct analogy anrong binary iignals binary circuitelements and binary digits A binary number ofndigitsfor example may be represented by n binary circuit eleshyments each baving an output sig~alequivalen1to Oor I Digital systems represent (Uld mashynipUlate not omy binary numbers but alsO many other diScrete elements of information Any discrete element of informatioIidlat is dis1iilct among agroup of quantities can be represented witha binary code (Le a pattern of Os and fmiddots) The codes must be in binary because in todays techIiology omy circuits that represent and manipulate patterns of 0s and ls can be manufactured economically foru~ in computers However it mtistbe realizCd that binary codes merely change the symbols not the meaning ofthe ele~nts of infonbationthat they repshyresent IT we inspect the bits of a computer at random we will find that mostofthe time they represent some tYPe of coded information rath~ than binlUY numbers

AIln-bit binary code is a groopofn hits that assumes up to 211 distinct cOmbinations of ls ~d Os with eacn combination representing one elementof tnt set that is being coded A set

of four elements clab becoded with two lilS with each ~lementassignedoneof thefoUowing bit oombinationsOOO I 10 J 1 A set of eight elements requiies a three-bit code 00 a set of

18 Chapter 1 Digital Systems and Binary Numbers

J6 elements requires a fourmiddotbit code The bit combination of ann~bit code is determined the count in binuy from 0 to 21t - t Each element must be assigned a unique binuy bit binationand no two elemerits cm havetbtsamevalueothenvisethe code assignment be ambigUous

Although the minimum nqrnber of 1lits required to code 21t distiItct quantities is nthere nomaximwn numbe( of bit that may he used for a binuy code For example the 10 digits can be coded with 10 bits and each decimal digit can be assigned a bit combination nine OSmid a 1 In this pamcularbinarycode the digit6 is assigned the bit )UllIUlauuu0001000000

BCDcode

Although the binary number systemis die ~ost natural system for a computer most people more accustomed to the d~imal system One way to resolve this difference is to convert

inlal nUmbers to binary perform all arithmetic calculations in binary and then convert the nary results back to decimal This metbodrequites that we store decimal numbers in

cOinputer so that they canbec6b~rted to binary Since the compllter Can accept only valueswe must represent the decimal digits by means ofa code that contains ls and Os also pOsSible lopedorm the arithmetic operlltiorisd1rectly on decimal numbers when they stored in the comput~ in cod~ct form

A binarycodewill have some unasSigned bit com~inatiqns ifthe num~rofelements in set is not amultiple power of 2 The 10decimai digits form such asel A biruuy code that tinguishes among 10 elements must coiltain at least four bits but 6otitofthe 16 possible binations remain unassigned Different binary code$ can bemiddotoNained by arranging four into 10 distinct combin~tions TheicodeIllcfflt oommonly used fdr the decimal digits is straight binary assf~ntlisted in Table 14 This scheil)eis called bittary~coded decimal

is commoolyreferred to as BCQ OtherdecimalcodesaIlfpossible and a few of them are sentedlaterinthis section

Table 14 BinarymiddotCoded Oeclmql (BCO)

Decimal BCD SnlboiDIgIt

o 0000 1 0001 2 0010

3 0011 4 middot0100 5 0101 6 0110 7 0111 8 1000 9 1001

Sectionmiddot 17 BInary COdes 19

Table 14 givesthe four-bit code for one decimal digit A number with k decimal digits will require 4k bits in BCD Decimal 396 is represented in BCD with 12 bits as 0011 10010110 with each group of 4 bits representing one decimal digit A decimalmiddotnumber in BCD is the

- same as itS equiyalent binary number only when the number is between 0 and 9 A BCD numshyber greater than lOJpoks different from its equivalentbinary number even though both con tainls and Os Moreover the binary Combinations 1010 thrpugh 1111 are not used arid have no meaning in BCD Consider decimal 18SlUld its corresponding value inBCD and bUtary

(185ho = (0001100001Ol)BCD = (l0111001h

The BCD value has 12 bits to encode the characters of the decimal value but the equivalent binary number needs only 8 bits It is obvious thatthe representation of a BCp number needs more bits than its equivalent binary value However there is an advantage in the use ofdecishymal numbers because compUterinput and output data are generated by people who use the decshyimal system

It is important to realize that BCD numbers are deCimal numbers and not binary numbers although they use bits in tbeir representation The only difference between a decimal number and BCD is that decimals are written with the symbOls 0 1 2 9 and BCD numbers use tbebinarycode 00000001 001O~ bull 1001The decimal value is exaCtly the same Dec~mal 10 is represented in BCD witheight b~ts as 00010000 and decitna1J5as 0001 01Of1lte corshyresponding binaryvalues are 1010 and 1111 and have only four bits

Consider the addition of two decimal digits in BCD together with a po~ible carry from a pre- vious less significant pair ofdigitsSince each digit does not exceed 9 the sum cannot be bull greater than 9 + 9 + 1 = 19 with the 1 being a previous carrySllppose we add the BCD dig-

its as if they were binary numbers Then the binary sumvill produce It result in the range from degto 19 In bin8ry thistange wil[be from 0000 to 10011 butin BCD it is frOm 0000 to

I 1001 with the first (ie leftmost) 1 bemg a carry and the next fo~ bits being the BCD sum When tPe binary sum is equalto or less than 1001 (withaut 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 (0110h to the binary Sum cOnverts it to the correct digit and also produces a catTy as required This is because a carry in themost significant bitposishytion of the binary sum and a deCimal carry differ by 16 10 = 6 Consider the following three BCD additions

4 0100 4 0100 8 1000

+S +0101 +8 +1000 +9 1001 9 1001 12 1100 17 10001

+0110 +0110----

10010 10111

In each case the two BCD digits are added as if they were two binary numbers If the binary sum is greater than or equal to 1010 we add 0110 to obtain the correct BCD sum and a carry In the flIst example the sum is equal to 9 and is the correct BCD sum In the second example

20 Chapter 1 Digital Systems and BInary Numbers

the binary sum produces an iJlv~ BCD digit The addition of0110 produces the cortect BCD sum 0010 (ie the number 2) and acanyInthetbirdexample the binalY SUDlproduces acany This condition occurs wben the $W)) is greater than or equal to 16Altbough the other fout are less than 1091 the binary 9Ulll requires acOnectionbecause of die carry Adding 0110 obtain thetequiled BCD sum 0111 (ie the numblaquo 7) and 8 BCD CiUT

The additionoftwondigit unsipedBCD numbers follows the same procedure COIlSioll the addition of 184 + 576 1= 76() in BCD

BCD 1 I 0001 10000100 184

+6101 ~

0111--- 0110 +576

lJinarysum 0111 10000 1010 Add6 ono 0110

BCDsun 0111 0110 0000 7(1)

The flfSt l~ sigDiticant pili- of BCD digits produces aBCDdigi~SllDlof 0000 and a for the next pair of digits the second parr or BCD digits plus a ~Vi0U8 cany produces a sum of 0110 and a carry for the next patr()fdigits The third pair of digits plus acarry proltIUC~ a binary s~ of 0111 and does not require a correction

Decimal Arithmetic The represeiltation of signed decimal numbers in BCD is simiiarto the tepresentation of numbers in binaryWe can useeitheI the familiar signed-magnitude system at the SllZllOO-COI1I

plemelit system The sign of a decimal number is tJSually represented with four bits to to thefour-bit code ofthe decimal digits Itis customary to designate 8 plus With four Os 8 minus with the llCDequivalent oi9 whlcq is 1001 The sigiled~magnitudesystem is seldom used in com~tersThe signed-complerDem ~~ either the 9s octhe 10s complement put the lOscomplement is the one most useP To obtain the lOs complement of aBCD numberwe first take the 9s complement then add 1 to the least significant digit The 9s Complement is calculated from the subtracloo of each digit from 9

The prltXeduresdevelope4 for the signed-2s-complement system in the ~vious also apply to the signed-IOs-complement system for decimal mimberS Addition is done summing all digits including the sign digit and discafding the end carry This operatiQ assumes that all negative numbers are in 10s-complement form COOsider the (+375) + (-240) == + 135 done inthe signed-complement system

o 375

+9 760middot

o 135

lhe 9in the leftmost pOsition of the second n~ber tepresents a minllS and 9760 is the complement o( 0240 The two numbers are added and tbe end carry is discarded to +13SOfcourse the decimal ntmlbers insi~ tile computer includingthe sign digits in BCD The addition isdone with BCDOigits as described previously

Sectionl 7 Binary Codes 21

The suQtr8ction of decimalliUJ1lbets either unsigned or in thesi~-~Oscomplement systetn is the sameu in the binary case Taketbe 10s ootnplementof the subtrahend and add i~ to themin~nd ManyooDlputerslULvespeciaJ hardware to perform arithmeticcalculations directly withdecilnal oumbers in 8tDThe~u$etofthecoBlPuter can specify programliled Wtnlctionsto JOdonn the aDtiuJletiP oPmwoowithdeQmal n1UQ~ ~ywithout having to convell them to binary

Binafy codes for decimal digits requirea minimum of four bits per digit Many different codes can be formulated by~gjng four bits into IQ distinct combinations BP) and three other representative codes are shown in Table L5 Each code uses only 10 out ofa pOssible middot16 bit combinations that can be arranged with four bits The other six Unused cOmbinations have no meaning amt should be avoided BCD and the 2421 code are examplesofweigbted codes In a weigbtedcodeeach bit position

juBsigned a weighting f~in~awaythat eaehdigitcanbe ev~by 8dding the wei~ oran the lsin thecoded combination The BCD code has weights of8 42 and I which cotteshy

spondiothe powe1Of-two valuesofeaCh bitTbebitasSignmeatOll0 for example is interpreted by the weights to represent dedma16beCause 8 X 0 +4xt +2 Xl +IX 0 6Thebit combination 1101 when weighted by the ~ve digits 2421 gives themiddotdeCimal equivalent of 2 X I +4 gtlt I + 2 KO + 1 X 1 = 7 Note that some digits cantle coded in lw9 possib)e

ways in the 2421Q)(feFOr inke decimal 4 can be asSigned to bitCombinadon 0100 or 1010 since botbcOmbinatibns add upto a totalweight of4

middot1$ Fou Dlf(et Blnqry Code$ for thtJledmol DIgits

~ IICD DIgIt sal MZt Exeet) 8 4 -~1

0 1

000() middotmiddotmiddot0000 001)1 0001

oem 0100

0000 0111

2 0010 0010 0101 0110 3 0011 OQU 0110 0101

4 0100 0100 0111 oroo 5 0101 lOll 1000 1011 6 OlIO middot1100 1001 1010 7 middot0111 1101 1010 J001 8 1000 IUOmiddot 1011 1000 9 1001 11U 1100 1111

1010 oloi 0000 0001 Uaused IOU 0110 middotOOOl 0010 bit 1100 0111 0010 0011 combishynations

nOl 1110

lOW 1001

HOI 1110

1100 1101

1111 IOU) 1111 1110

22 ChaptfrliDfgltalSystemsaod Btoary Numbers

I1te 2421 rind the

e~l3~es are exampks Of self-complementing codes Such codes have~propertyjbatthe9s~plement ofa deCimal nfunberigobtairted directly by chang-

ing 1$ to O~$ finO tYSCfb1 sie~bycomple~mmgeaCh bit in the pattem)For example decshyimat3~Sis re~ fu tbeexcess3code as 01101100 1000 The 9s compl~ntof 604 isrepRse~l00liOOllelliwbich isobiainc(himply by complementing each bit of the

code (as with the 1 s coinpl~ofbin~rillDlbers)middot Theexcess~3code has been used in some oldel coritputers because of its selfcpmplement~

ing property Excess-3 is an unweighted code inwhich each codedcombinationis obtained-fJQm the corresPonQing bin3ryvalueplus 3 Note that the BCD code is1~ self-complementing TheS 4 ~~ Icode isan example of assigning both positive and negative weights to ~ decimalcodeInthis case the bit combiDation 0110isin~reted as oecimal2 and is calcu-

latedfrom8XO+4X 1 + (2) X 1 + (1XO=2 ~

Cra Code _ _ J

l1te output data QfmaJlfpbYsicaimiddot $)ShmlS are quantities that are continuous These data bemiddottonverted~digiWforuitJefore they art applied toaliigital system Contfuuous or ~nisCOIl~middotUitodigitalfonn bymeans of an rumlog~digitalConverter It is times ~~ent tousethe Gray code slown inTable 16torepresehtdigiuU data that have oon~ fMn8D8l08 dasaTheadvantage of th( Gray cOOeover thesllaigbt binary nIl11l1hPt~

~lt~thatoWY~ hit in the codegroup changeSin going from one number to the For examplcentbullin-goingfrom 1 to 8dleGray code cblngesfrom 0100 to 1100Only the fust changesfromOto l~the odter~ I)its mnaintbesame By contrast With binary numbers change from 7 to 8wrube from 0111 to lOOOwhich causes allfciur bits to change valUes

TabielAi GtPyCode

01 Decl COde Equivalent

~ 0000 0001 0011 OOlG 011Q Olll OlO 0100 1100 11m 1111 1110 lOlQ 1011

lOOt i

1000

o 1 ~ 3

4 5 6 7 8 9

10 11

12 13 14 15

SectIOnl7 BlnarYCod~s 23

The Gray code is used in applications in which the normal sequenceOrbiruuy rium~may produce an error orambiguitymiddot during themiddot transitionfrom ODeDWDber to the next If binary numbersareusec1 acbange forexaJIlple nom 0111 to 1000 may produce anintermediateershyroneous number 1001 if the value ofthe rigbtmost bit takes longer to -change than domiddotthe valshyues of the other three bits The Graycode elimb1ates this problem since only one bit changes its valve dUrlng aily transition be~een two numbers I

Atypical appli-cation ofmiddotthe Gray code is the representation of analog data by a Continu ous change in the angUlar position of a shaft The sQaftmiddot is partitioned into segments ana each segment is assigned a number If adJacent segments are made to correspond with the Qray-Codesequence ambiguity is eliminated between the angle of thesbaft and the value encoded by the sensor

Character Code

Many applications of digital computers require the handling not only ofnumberS but also of other characterS or symbols such as the letters of the alphabet For mstancean insurance comshypany with thousands of policyholders will use a computeX to process its files To represent the names and other pertinent information it is necessary to fonnulate bull binary code for the letshyters ofthe alphabet In additiQt1 the same binary qode must represent numerals and special Characters (such as $) An a1phanumeric character setis a set ofeiements that inclUdes the 10 decimal digits the 26leuersofthealp1iabe and a nutnbeof special~S~ a set conshytains between 36~d 64 elements ifonIy capital letters areincltided or between 64 and 128 e1eJDents ifboth uppercasemiddot and lowercllle etters are inclUded In the first case we need a bi- nary code ofsix bits and in the second we need a binary cooeO(seVM bits

The standaM binary code for the alphanumeric char8cters is the American Stahdard Code for Information InterCbange (A~n) which uses seven bitS to code 128 characters asshoWn in Table 17 The seven bitsof the code are desipted by b~through h With h the mostsigshynificant bit ~e leUer A for example is represented inASCn as l(l()()()Ol (column l00~tOw 0001) The Ascn ()()de also contains 94 graphic characters that can be printed and 34 nonshyprinting characters used for variQUS control functions The graphic characters consist of the 26 uppercase letters (A through Z) the 26 lowercase letters (a through z) the 10 numerals (0 through 9) and 32 special printable characters suchaS andS

The 34 control characters are designated in the ASCTItable With abbreviated nalne8 They are listed again below the table with their functional names The control characters are used fQr routing data and arranging the printed text into a prescribed format~ There are three types of control characters format effectors information separatOrs andcommumc~on-COnlrpl char~ IlCters Format effectors are characters that control the layout ofprinting They inciude the fashymiliar word pr6cessorand typewriter controlssucb 8$ bac~pace (BS) horizontal tabulation (HT) and carriage return (CR) Information separators are used to separatetbe data into divi~ sions such as paragraphs and pages Theyinclude characters such as ~ordseparator (RS)and file separator (FS)The cODlIDunication-control characters are uSefulduriDgthe transmission of text between remote tenninals EXllll1plesof conlmunicatiOn(ODtiol~ are STX (start oftext)-and ETX (end of text) whicb are used toframe a text mesaagetnQlSlnitted through telephone wires

24 Chap~er 1 Diglt8l Systems and Binary Numbers

rblel7 Amerkcm5tandard Code for Information (nterclHlnge(ASCII)

b~jbzb 000 001 010 on 100 101 no 111

0000 NUL )jLP SP () p P 0001 SOH OC1 1 A Q a q

R0010 STX OC2 2 B b r 0011 ETX DC3 3 C S Ii S

0100 EDT 0C4 $ 4 D~ T d t 0101 ENQ NAK 5 E iU e u OUO ACK SYN amp 6 F V f v 0111 BEL ETB 7 0 W g w 1000 B8 CAN ( S H K h x 1001 HT EM ) 9 I Y Y 1010 LF SU~ 1 Z j z lOll VT ESC + 1lt r k UOO FF PS lt L I I 1101 Cit OS == - M 1 m 1110 SO R~ N 1 n shy

-0PIt st US f 1 0 0 DEL

r- Control characten

NUL NlI]l DlE Data-inkescape SOH Start of hea~ng DC1 Device cOntroll STX Start of text DC2 DevIce io~1lOi2 ETX End (Jftext i DC3 Device corUlri1 3 OOT End oftraIlsmission ~4 DeVicecoQtrol4

ENQ ampqwry NAK Negativeackilowledge ACK

Acknowledge SVN Sync~nous idle

Btl Bell ETB End-of-tmnsnussionblOck sS Backspace CAN CanCel HT Horizontal tab EM End of mediUrlt LF Lintifeed SUB Substitute VT Vertical tab ESC escape FF form feed FS File separator CR Carriigeretum GS Group separator SO shift Ollt RS Reoord sepuator SI Shlftin US Unit separator SF S~e DEL Delete

ASCII is a seven-bit codebutrnostcompUters manipulate anejght-bit quantity asa unit called a byte Therefore ASCII characters most often are stored ~e per byte The

I biti~sometimesused forotlef purposes depending ontheapplicatio~lFor example printetS recognize eightmiddotbit AScn chaiacterS with themost sigoificaot bit ~twO An atkJlitlo

Section 18 Binary Storage and Registers 2S

128 eight-bit characters with the most significant bit set tol are used for other symbols such as the Greek alpbabet or italic tyIe font

Error-Dtectlng Code

To detect errors in data communication and processing aneigbth bit is sometimes added to the ASCll cbaracter to indicate its Panty Aparitybit is an extra hit included with a message to make the total num~ of ls either even or odd Consider the fo119wing two cbaracters and their even andodd parity

With even parity With odd parity Ascn A = 1000061 01000001 11000001 ASCI( T == 101deg100 11010100 01010100

1

- Ineacb casewe insert an extra bit in the leftmost position of the code to produce an even number of 1 s intQe cbaraeter for even parity or an odd number of 1 s in the character for odd parity In generlll one or tbe oth~r parity i~ adopted with even parity being more common

The parity biqsbelpful in detecting errors during the transmission ofinformation from one location to another nisfuJictiOD is bandIed by generating an even parity bit at the sending end for ~h character The eight-bit characters that include parity bits are transmitted to their desshytination The parity ofeachebaracter is thetichecked at the receiving~nd If the parity of the received cbaracter is Dot even then at1east on~bit has changed value dUring the trmlsmission This method detects one three or any odd combination of errors in each character tb8t is transshymitted An even combination oferrors however goes undetected and additioDaterror detic- shytion codes may be needed to take care of that possibility

What is done after an errQlis detected depends on the partieu~ application One possishybilityis to request retransrois~ion of the message on the assump~on that tbeenigtr was ranshyd()m andwill not occur again Thus if thereeeiverdetects a parityerrorit sends bai~ the ASCII NAK (negative acknowledge) control cnaracter consisting ofail even-parity eight bits lOOlOl01H no error is detectedthe ~iversends back anACK (aCkno~ledge) conshytrol character namely 0000011 O The sending end will respond middotto an NAK by tranSmitting the message again until the correct panty is received Ifmiddot after a number of attempts the transmission is still in error a message can be sent to the Operatai to check for malfunctions in the transmission path

BINARY STORAGE ANORECiISTEIlS

The binary infonnation inadigitalcomputermust have a physical e~stencein some medium for storing individual bits A binary cell is a device that possesses two stable sttes and is cashypable of storing pne bit (0 or 1) oflnfotlllation The input to tbe cell receives exciJation sigshynals that set it to one of the two states The output of the cell isa pbysicalquantity that distinguishes between the two states The irtformationstored in Ii cell is 1when the cell is in one stable state and degwhen the Cell is in the other stable state

26middot Chapter 1 Digital Systems and BtnaryNumbers

Registers

A register is a group of binary cells A register with n cells can store any discrete quantity of middot information thatcontains n bits The state ofa registeris an n-tuple ofls middotand Os with each bit designating the state of one cell in the register The C()ntent ofaregister is a function of the int~rpretation given to tbeinformation stored in it Consider fQf ex~ple a 16-bitregister with the following binary content

11 00001111001001

middot Aregjs~ with 16 cells can be in one of 216 possible statesIf one asstimesthat the content cif the register represents a binaryinteger then the register can store any binarydumber from Oto 216 - 1 For the patticularexample shown the content ofthe register is the binary equivshyalent(lftbe decimal number 50121 If one assumes instead that the register stores alpbanushy

middot meric characters of an eight-bit cooe then the content of the register is any two meaningful characters For tht ASCII code with anevenplirityplaced in the eighth most significant bit position the register contains thetwo charactersC (the lefunosteightbits) and I (the rigbt~ most eight bits) If however one in~rprets the content of the register to be four decimal dig- its represented by a four-bitcode tnenthe content of the register is a four-digit decimal number In theexcess-3 code the register holqs the decimal nutriber 9096 The content of the registe~is meaningless in BCD becau~e the bit combinatiOn ltob is 110t assfgned to any decshyimal digit From this example it is clear that a register can store discrete elements of inforshymation and that the same bit configuration Inay beinterpreted dlffe(ently for different types of data

tmiddotmiddotReglsterTrail Adigitalsystenlis characteriZed by its registers and the components thatpetfolin data proshy~ssingIIl digital sy~tems a rcentgister tra1lsfer operation is abasi operation that consists of

middot a transftr of hiJWy hUormation from one ~t of registers into ano$er set of registers transfer may be dir~ctfr9m one regist~r toanlt)ther or may pass througb datamiddotprocessing circuits to petformaD operation Figure L 1 illustratel the transfer of iidOrnuttion among regshyisters anddemonstratespictorlallY [the tr8ll~~ ofbinaryinformation from akeyboard a register in the memQryullit Thehlputunit~s assumed to have a keyboard1 control cuit and aninput register Each time a key is strock the control circuit enters an ImnV$_

lent eight-bit alphanumeric character coqe into the input register We shall assume that code used is the ASCII code with an odd-parity bit The information from the input regisshyter is transferred into the eight-least significant cells Qf a proeessOr register After transfer theinpui register is cleared to enable the control to insert a new eight-bit when the keyboard is struck again Each eight-bit character transferred to the pro1c4ess(raquo register is preceded by a shift of the previous character to the next eight cens on its left~

middot a transfer -of four characters is completed the processor registeris full and its contents transferred into a memory register The content stored in die memOry register shown in Figl came from the transfer of the characters J 0 H an~ N aftet the four ap)lroJ)riatt keys were struck

Section 18 Binary Storage and Registers 27

FIGURE 11 Transfer of information among registers

To process discrete quantities of infoiniatiori in binary form a computer m~st be promiddot vided with devices that hold the (lata to be processed and with circuit elements that manipmiddot ulate individual bits of irifonnation The device most commonly used for holding data is a register Binary variables~ manipulated by means of digital logic circuits Figure 12 il~ luslrates the process of adding two l()bit binary iUlmbers Themeniory unit which no[shy

mally consists of millions of registers is shown with only three ofits registers Thepait of the processor unit showncoDsistsmiddotofthree registers-RI R2 and R3~getherwith digital logic circuits that manipulate the bits of RI and R2 and transfer into R3 a binary number equal to their arithmetic sum Memory registers store information and are incapable of pr0shy

cessing the two operands However th~ information stored in meDij)iybanbetransferred to ~ processor registers and the resUlts obtainedin processor tegisters can be transferred back into ame~ry register for storage Untill)ecded again The diagram ~wsthe90ntents of two

operands transferred from twoJDemoryregisters into RI imd R2 The digital logic circuits produce the sum which is transfened to register R3 The contents of R3 can now be 1riUlsshyferredback to one of thetnemory registers

The last two examples demonstrated the infonncion-flow capabilitieSofa digital system in a simple manner Themiddot registets of the ~ystem are the basic ele~ents for Noring and holding the binary information~igitallogic circuits process the binary ihfonaation stored in the

28 Chapter 1 DigIt bullbull Systems and Binary Numbers

Sum

FIGURE 12 Eumple of blnarylnfonn~t1on processing

registers Digitallogiccirctiits and registers are covered InChQpteB 2 throQgh 6 The metlilOlY unit is ~xPIained ill 9aptet 7 Th~ descriptton of register opetJtions at the register level and the design of digital systems are covexed in Chapter 8

19 BINARY LOGIC

Binary logic deals with variables th~ take on two discrete valueund withoperations that sumelogicalmeaning~ The two val~s the variableussume may be called~ydifferent (true andalse yel and no etc) but for ourp1llpQSe it is cpqVenienttotbink in terms of and assign the values llUld O The binary logic intr0ducedin this section is equivalent to algebra oalledBoolean algebra The fannal presentation ofBoolean algebra is covered in detail in Chapter 2 The purpose ofthis seCtion is to introduce Boo algebra ina matmerandlate it to digitallogiccircuits andmiddotbinarYsignalsmiddot

Section 19 Sinary logic 29 ~

Itkltn of IInary logic

Binarylogic consists of binary v~les and a set of logica1middotoperatiQDS The variables are desigshy ~by lettell of thCalplWlet~such asA B C x yz etc with eaCh variable baving two and oniy

two distinct posSible valueS 1and O There are three basic logical operations AND ORand NOT

1 AN]) This ~peration is represented by adotorby the absence ~f an oPerator For example x bull y =z or xy = zis~ x ANDy is equalto z~ThelogicaloperationAND is interpreted to mean that z == 1 ifand only ift~ land y = 1 otherwise z = O (Reme~r that x y andzare binary v8riablesand canmiddotbe equal either to 1 or Omiddotand nothing eise)middot

2 OR This operation IS represented by a plus sign For example x + y =z is read x OR y is equal to z meaning that z 1 if x = iorif y = lorifbothx= 1 and y = 1 If bqth X - 0 andY Omeo z= O

3bull NOT This operation is repf6sented by a prime (sometimes by an overbar) For ~xample x =Z (or~ =z) is read notdsequalto 1 meiming that z iswkatx isnot In other

words ifx = 1 then z == 0 but if x == 0 tnenz = L TheNOT operationisals(1 reshyferred tolls the complement operation since it changes ~ 1 toOand a O to 1

bull bull lt Binary logic resembles binary arithmetic and themiddot9peratioos ANDahd OR have similarishy

ties to multiplication and addition respectively In fac~ the symbols used for AND and OR are the same as those used for multiplication and addition However binary lOgic should not be conshyfused withbinaryarithIrietic One should realize thatan arithmetic variable designates a numshyber that may consist of many digits A logicmiddot variable is always either 1 or O For example in binary arithmetic we have I +1 =10(read~one plus ()fie is equal to 2) whereas in binary logicwe have 1 + 1 1 (read one OR onds equal to one)

For each combination of the values oix and y bullthere isa value of ~ $pecifiedby the definishytion of the logical operation D~linitiops of logical~perations maybe listed in a compacHorm called truth tables A truth table is atable of anpbssible combinations ofthe variables $howshying the relation between the values that the variables may take and the resultof the operation The truth tables for th~ operations ANDand OR with variables x and y are obtained by lis~ng

all possible values that the variables may have when combined in pairs bull For each combination the resUlt of die operation 18 theillistedin a separate row The truth tables for ANDORand

NOT are given in Table La These tables clearly demonstrate the definitionf the operatibns

Table 18 Truth TcibJts of Logical Operations

AND OR NOT

x y xmiddoty x y x+y

0 0 0 0 0 0 1 0 0 1

10

1 0 d 1 0 1 I 1 1 1 1 1

bull~lt~m

30 Chapter 1

Logk Gates

Digital Systems and Binary Numbers

Logic gates are electronic cirellit that operate on ~

variable

or mpre mput tignals to produce an output signal Electrical signals sUch as voltages orrutrents exist as analog signals having values over a given taDgebull saYOt03 V but in a digital system are interpreted to be either of two recognizable values 0 or 1 Voltage~opetated logic Circuits respond to two separate voltshyage levels that represent a binary varjable equal to logic I bt logic O For example a partic- ular digital system may define 10gicOas a signal equal to 0 volts lind logic 1 asa signal equal to 3 volts In practice each voltage levelhiS an acceptable rangeas shown in Fig 13

The input te~nals of digital cikuits accePt binary signals within the allowable range and respond at the output terininals with binary signals that fall within the specified range The intermediate region between the aJl()wed regions is crossed only during aState transition Any desired information for computing or control can be operated tm by passing binary signals through variQUS combinatioDsof logic gates with each signal represebting a particular binary

The graphic symbols used to deSignate themiddotthree types of gates are Mown in Fig 14 The

gates are blocks of hardware that prooocc tbeequivalent of1ogic~1 orlogic() output signals

Volts

- FGURl13

x

y

Exampleof binary slgnaJs

Signal ratlge for logieO

(a)~omiddotinput AND gate

FIGURE 14 SymbOls for digital logic circuits

(c)NOT gate or invert~

Problems 31

x-lU 1 11 P 0

y 0 0 11 1 ~

ANDxy 0 0 rTl 00

ORX+Y~ NOT x 11 0 0 I 1 1

FIGURE 15 Input-output 5Igals for gates

FIGURE 1

A B C

Gates WIth mlltlple JnpUU

A B C lJ

~

if inPllt logic ~ts are satisfied Theinput signals xaDd y intheNDaadQR gates may exist in ~ oHow-possible states 00 10 11 or 01 Il1ese ibpu~ampignals_ shown inFig lStoshygetber with the corresponding output signal foreach PfCThI~tiaiug~iDustrate the reshysponse ofeaclt gate to the four input signal~The~llisofthetiminadiagram represents time and the vertical axis sbo~~~~ it cbapg~botwcen~possible voltshy

age levels The low level represents logic O tJte high level l1lteAND _ responds With a logic ~ ~tput sipl wh~ both input ~~)e 1middot1~ lIieOR S-~with a logic 1 outpUt signal ifanylnput sigrudis lOgic 1 TheNOTgateis~~ to BUll invedet The reason for~nameis~t froJn the signalmsponae inmiddottbe timitt8 diagramwhicbsbows that theoUtputsignal inverts the logic sense of tbeiDpUtsigll8l

AND and OR gates may bavei)lQte tbantwQinputs M AND8_~itti ~input$andan OR gate with foU) inputs are shown in Fig 16 The three-inPllt AND gate responds With logic 1 output if all tbreeinputs arelogic 11jleoutputproduces lOgic Oifanymput is logic O-The

four-input OR gate responds withlogic 1 ifany input is logic 1 its clu1ptltllCCoines logic oonly when all inputs are logic O

Answers to prvblems marked with middotappearaHbe ClOd ofthe ~

11 lJltthe octal and beXadecimalliurilbers trom16ui 32UdngA B1l1ld C forthebst~ digits Usttbe numbers from 8 to 28 in base13 bull

I

12t What is the exact D1Jllbcr of bytes in a system that contains lta) 32Kbytoe (b)64M ~and (e) 640 byte$ middot7 t

32 Chapter 1 Digital Systemsand Binary Numbers

13 Convert the following nu~bers with the indicated bases to decimal (a) (4310)s (b) (198hz (c) (735)8 (d) (525)6

14 Whllt is the largest binary number that can be expressed with 14 bits WhlIt are the equivaleDt ~~ iinal and hexadecimal numbei-s

--

15 Detemrine the base of thl1 numbers in each case for the following operatio~ to be correct (a) 142 = 5 (b) 5414 = 13 (C) 24+ 17 == 40

16 The solution$to the q~cequation xl - Ux +22 oare l1 3 arid x =6 What is the base of the numbers

17 Convertthehexadecimal ntmIher 68BE to bitiary and then convert it ~mbinary to octal

18 I Convert the decirpal number 431 to binary in tWo ways (a) Convertd~y to binary (b) conshyvert first to hexadecinla1 and then from ~decimalwbinary Which method is faster

19 amppress the following nqrnbersin decinud (a) IQ11O0101)z (b) (l65his (c)(2624)8 (d) (FAFA) 16

(e) (10101010)2

110 Convert the following binary numbers tobexadeoimal and todecitnal (a) UOOlO (b) 110010 Explain why the deCimal answer in (b)is 4 times that in (a)

111 Perform the followingdiviskmin binary 11 Ion + l()t

112 Add IlniImultiply tfle following numberswiihout converting them to decimal (a) Binary nuniberilOll aiIdlOh (b) He~uumbers 2E aDd 34

1~)( Do thefoHowing con~ersionproblems (a) CorivertCiecimal2731S to binary (b) CakUlate the binary eqUivalent (f 213 outto eight pl~Then Convert from binary to

imalHowgJose istbe result to 2131 (c) Convert the binary resukin (b) into hexad~ lb~oonvert ~result to decimal Is answer tbesame

114 Obtain the is 8nd 2s complementsofthe foUowing binaryDumbcentrs (aj l)()()(J()OO (b) OOOOOOOO (c) 11011010 (d)01l10110 (e) 10000101 (0 11111111

115 Find the 9s and the 10s complement of the following detimal numbers (a) 52734630 (b) 63325600 (c) 25000009 (d) 00000000

116 (a) Find the 16s complement of B2FA (b) Convert B2FA to binary (c) Find the 2scomplement ofthe resultin (b) (d) Convert the answer in (c)to hex~malandco~ with ihe an~wer in (a)

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 11: Chapter 01 - Mano

11 Sectlon middot15middot Complements

The 10s complement ofthefustnumber isobtaineltibysublriiCtingSfrom lOin the least sig~ nificant position and subtracting all other digits from 9~ The 10s complement of the second number is obtained by leaving the to least significant Os unchanged subtracting 7 from 10 and subtracting the other three digits from 9

Similarly the 2s complement ~be fonned by leaving 1ll11east significant Os and tbe first 1 unchanged and replacing I swith Os and Os with ls in allother hi~r signifIcJUlt digits For example

the 2s cORlplement of 1101100 is 0010100

and

the 2scomplement ofOllOllHs 1001001 _ - r

The +s complement pf therrrst nJUDber i~ obt4iriedby I~vingthetwo least significant Os and the first 1 unchanged andmiddotlQen replacing ls with Os and Oswith 1~ in the other four most sigmiddot nificant digits The 2s lXgtmplement qf the second number is obtained byleaving the least sigshynificantmiddotl unchanged and (fOmplementing all other digits

In the previous definitions it was assum~dtMt the D~bers did not have a radix pomt1f the original number Noontains a radix point the point should be removed temporarily in order to form the s or(r 1)s complement The radix point is then restored to the c9ll1plementshyednumber in the same relative PositionIlis abo wOrth mentioning thatfhecontplement oftbe complement restoresthe number to its original v41ue To see this rel~tionsbipnOtethat the ts complement of N is n - N so that themiddot complement oft1e complement is n - (n - N) == N and is ltlqual to the original number

Mr8Ctiton wltl1 Complementsmiddot

1le direct metb()jiofsubtraCtion taught in elexnentaty schpOls uses the bottow concept In this QlCth9dwebortowa I from a middothigher significant position when the minuend digit is smaller than the subtrahend digit The tDethod wor~wen when peOple perfonnsubtraction with paper andpeooillIowever when subtlaction is implemented withdigi1al bardw8le the method is less e~citnt than the method that u~s compl~m~ts

The subtraction of two n-digitunSigneq numbers M N in base can be done as fonows I

1 Add the minuend M to the scompleme~t of thesubtramphend N Mathematically M+ (n N) = M N +

2 IfM ~ N ttie sum wiUproduce an end cury 11 which caD be discarded what is left is the resultM N

3 If M lt N the sum does not produce ~tlend carry JUld iseijUattor (N~ Ji) which is the s complement of (N - M) To obtain the answer in a familiar form take the s complement of the sum aruI place a negative sign in frorit

12 Chapter 1 Digital Syst-ems and Binary N~mbers

The following examples illustrate the procedure

plPi1I VsinglOs complement subtract 72532 - ~250

M = 72532

lOs complement of N + 96750 Sum= 169282

Discard end caIry lOS = -100000 Answer = 69282

Note that M bas fiv~ digits andN has only fourdigitsBoth numbers mtast have the same numshyber of digits sowe wrlteN as 03250 Taking the lOscomp~ementofNptOducesa9 in the most significant PositionThe occurrence of the end carry signifies that M ~ N 8ndtlult ~ result is therefore positive

Ulling 10s complement subtract 3250 - 72532 - ~ ~

M = 03250 JOscornplementof N =+27468

Sum= ~0718

There is no end carry Theref()re-theanswer is--(10amp complementof30718) == -69282 Note thatsince 3250 lt n532~the result is negative Becauwe are dealing with WUiigned

numbers there is really no way to get BnunSigned result for this case When subtracting complements we reoogilize the negltive answer from the~sence of the end carry and complemented result When workingwith paper and pencil we c8nchlnp the aDswer

signed negative number in oider to putH inafamiliar form Subtraction with complements is done with binary numbers in a similar manner uing

procedure outlined previously

EXAMPLE 17

Given the two binary numbersX = 1010100 and Y =1000011 performtbe $UbiDctiG (8) X - Y arid (b) Y - Xby using 2scomptem~ts -

f

- -

Section 15Complements 13

(a) x = 1010100

2s complement ofY= + -0111101

Sum = middot 10010001 Discard end carry 27 = 10000000

Answ~ X- Y = 0010001

(b) Y == 1000011 2sco~lement of X = + 0101100

Sum= 1101111

There is nQmiddotend carry Therefore the answer is Y ~X= -(2sq)mplement of 1101111) = -0010001 Subtractionof unsigned D1lJllbers ~ also bed()neby means of the (r - 1)s complement Remember that the(r- l)s complement is one lesstharithers complement BeCause of

ibis the result of adding the minue~ to tJte coQlplement of the subtiah~ndPtOductS itsum that is one less than the correct 4ifference when an end carrY oCcurs Removing the end carry and adding 1 to the sum is referred to asan end-around carry

Repeat Example 17 but this time using rs complement

(8) X y = 1010100 - 1000011middot

X= 1010100

rs complementafY= + olfnoo Som = 10010000

End-arOundmiddot~ =- ~ ~ Answermiddot X Y= middot0010001

(b) Y - X = 1000011 - 1010100

Y = 1000011

1s complement ofX = +0101011

Sum = 1101110

There is no end carry TherefOre the answer is y - X = -(1s complement of 1101110) = -0010001

bull Note that the negative resultis ob~ by taltingtbe 1 scomplemeilt of theJWltsince this is the type ofcoDiplementused The procedwewithendaroundoanyis aIs(gt Iijlpliclbleto subshytracting Unsigned deciImdnumQers with 9seomPlement

14 Chapter 1 Digital Systemsand BinayNumbers

16 SIGNED BINARYNUMBER$ ~

Positiveintegers (including zero) CaBbe ep~~ 11$ unstPecl numbers However to repshyresent negative integers we need a notation for negative srn ordinary arithmetic a negshyative number is indicated by a mulUs signmdapOsitiv~Pwtlt)e~ by aplus sign Because of lJardware limitations computers mlstrepresenlev~With~ digitsIt is customary to represent the sign witb a bit placed intheleftmotp6sitiolwfthe number The convention is tltl make the sign bit 0 for positive and 1 for negative

Itis important to realize that botp siped and unsignedtDnary 11UJDbers consist of a strfug of bits when represented in a com~ TQeuser detem1inesWbether the number is signed or unsigned If the binary number is signed then the lefuriostbitreple$ellts thtsign aud the rest of the bits represent the number Ifthebinaryllu~beiis~ tObe unsigned then the left most bit is the most significant bit of the l)uMber Fdre~the~~f bits 01001 can be consideredas 9 (unsigned binary) or as +9 (Sighedbitia1j) ~USJtheteftmostbit is O The

string ofbits 11001 represents the binary ~~v~ento~ ~w~nc~idered as an unsigned number and the binary equivalent of 9whenconsidered1l si~riumPer This is because the Ithal isintbe leftmost positiondesignatesampC nega6ye_~QtherfourJ)its represent bishynary 9 usually tlere is no cotifusionin identifying thebits~the~Qfrepresentation for the number is known in advance ~

The representation of the signed numbers in the lastexainple is referred to as the signed magnitutk coDvention In this ~otati()nthenurnber C4mSiampesOCa mQ~~andil~ymbolH

or -) or a bit (0 or 1) indicating the sign This is the representation ampr~~used in ordinary arithmetic When arithmeti~ operatioBslllieimplerneJltcldin~cOQlPuter hii more convenient to use a different systemrefetred t(gt as the si~cqmptement system~ for repre- senting negative numbers In thissystlm a neg8tielliun~r isjhdic~ted by its cornplc~mc~nt Whereas the signed-magnitude system negates a nlllllher by cbanging its sign me signed-comshyplement system negatesanwnber bytakin$ its~OinPleltleitiSinoepositife numbers always start witbO(plusin tte leftmost pOsition thecompktllint wiilalwaysstart with a 1 indicating a negative number The siped-complemelt system can use olthertbe 1s Or the 2s but the 2s complement is the mos~comtliOfi

As an exampleconsider the number9re~~ed in binary with eight bits + 9 Is sented with a sign bit of Oin the leftri1ostpOsition oIIOv~by the binary (equivalent of 9 which gives ()()()olOOl Note thai all eigbtbits must haYampa v~therefore O~s are inserted folshylowing the sign bitllp to the first 1 Although ~ is only 01K way to tepresent +9 there three different ways to represent 9 with eight ~its

s~gned~magnituderepresentation 10001001

sigried-l s-complement represe~on~ 11110110

signed-2 s-complemerit representatim 1ttltllU

In signedmagnituamp -9 isobwned from +9 by changing the sign bitmtbe leftmost ~iti(ln tromO to L In sigl1ed~ lroomplement 9isobtaidedtf~~tiog all the bits of includinj the sign bit Thesigned-2~sco~re~Qf-9 is obtampDedby ihe 2s complement oftbepOsitivenumberincludingtbesijnbIt

Sectlont6 SIgned8lnary NumberS is

Table 13 Slgtlfd Biliary Humbm

+7 +6

+5 +4 +3 +2 +l +0 0 -I

-2 -3

4 -5 -6 -1 -8

Olll 0110

0101 ( 0100

001l 0010 0001 0000

IIll 1110

nOI noo Ion 1010

1001 1000

OIll Oito eHOl OHIO OOU 0010 0001 0000 1111 1110middot dOl 1100 Ion

lOti 1001 1000

0111 OUO 0101

0100 0011 0010 0001 0000 1000 1001 1010 IOU 1100

1101 1110

lUI

Table 13 lists all possible four-bitsignedbinaryaumbers in the three representations The equivalent decimal number Is also shown for refelenoeNote that the positive n~ in all three representations are identicaland have 0 inthelefmostpcsiticm The signed2sshycompl~mentsystemhaironly onemiddotrepresentation for 0 which is always po$itive The other tw()systetns- mlve either a positive 0 or a negative 0 sometbingnoteDcounteredin ordinary arithmetic Note that all negative numbenhave alin the leftmost bitpositi~ that is the way we distinguish them from the positivenumbers With fout bits we can repreSent 16 binary numbers In the signed-magnitude aDd thelscomplement repre$eDtatipns there are eight positive numbers and eight negative numbers inciUdingtwo zeros In the2s-complement representation there are eight positive numbers includi0a one zerQ and eight negative numberS

The siped-m_gnitude system is used in ordiIlary arithmetic but is awkward when emshyployed in computer arithmetie becauIe of the ~parate bandIinJ bfthesipand the magnitude Therefore the signed-compiement systeni is normallyused The ls ~t imposes some difficulties and is seldom USedJor arithmetic openitiOns It is U$eful aSa lo~ operation since the change of 1 to Obrmiddot() to 1 is equivalent to a logical complement Operation as will be shown in the next c~The discussion~f sigiled binary ariduneti~ that fol10ws deals exshyclusively with the signe4-2soomplt_nt~tatJonQfnegadveilUlilbers hsame proshy

cedurescan beappJied to the sigMdrs-comPlemeD~Iysby incIudiOI tbe~arotmdcarry as is done with unsigned numbers

J6 Chapt~r 1 OlgltalSystlf(ns and Binary Numbels

Arithmetic Addition

The addition of two numbers in the signed-magnitudelYs_foUowsthe rules ofordinaiy arithshymetiC Ifthesi~s arethesam~we addthetwOtt~gni1U~~d ~vetbe sum the CCmmon sign Iftbe signs are diffe~nt we subtract tllcsmaUermagnitude frOtnlthe larF and give the differshyehtethe signof the larger magnitude For example (+25) +( - 37) = ~ (37 - 25) = -12 and is done by subtracung the smaller magnitude 25 from the larger magnitude 37and a~nding the sign of 37 tGtbe result Ibis is a process that requires a corripanson of the signs and magnitudes and then performing eithr additi()n or subtraction The same procedure applieato binary numbers in sigped-magnitude representation~Incontrast the rule for adding numbers in the signed-corppleme~ sy~tem does not require a comparison or su~ traction but only addjtion The procedure is very simple andcanbe stated as follows for binary numbers The 8ddltion oftwo signed binary numberS with negative numbers tepresented in signed- 2sComprement fonn is obtaiIled from theadditlooofthe two numbers includingtheii sign bits

AcentiirrY out oftbe sign-bitposition is diScacded NumerIcal e~aihpledotai1dition follow

+ 6 00000110 - 6 11UI0tO I

+13 00001101

+13 00001101 +19 00010011 + J 0Q900111 + 6 00000110 6 11111010 ~13 11110011 -1~l 11110011 7 illl1001 -19 11101101

I bull bull ~

Note that negative numbers musthil iriitially in 2seompkmentform and that if the swn ~ ~afterthladdit40nis negativeins in2s~p~t fOl1Jl - In each of thefoDrcasestlteoporationperfol1JlC(lis additionwitb the sign bit iilcluded Any catTY o~of~~-bit~onisdisc~ and negative resultsareButomaticallyin 2sshyromplementfoon

In order to obtain acOrrect answer we mustensQre that the result has a sufficient of bits to accommodate the swnlfwestartwith t~on-bltnumbers and tbeswn occupies n + 1bits we say tblltan overflow occurs~Wheri one perfotmStbc ad(JitiOJl with nllllIPTJllVIl

pencil aq overflow is not a preblem because we arcr noflimitecLbythewidth of the page jUst addanothcentr 0 to apositive number or another 1 toa negative number in the mOst cant positi()n to extend thenwnber to n+ 1 bitSand theQ perform addition Overflow is

problem in computers beqiusetbe number ofbi~~ bolla ~befis finite and a result ex~ tI1efinite val~e hy lcatmotbe accommodated

The compJement form of representiQg negativetlQUlbers is unfamiliar to those usedto signed-magnitude system To itetermine th~ value of II negatienumber insiped-2s COlIlpJe

mentit0is~ to CODVerttbe numbcr to apositie ntirit_ ~ place itiDa more formPor ~plethesig~binary number qUl00~ lii~egativebecausothe leftmost

t 1182s c0J8plemen~js~UlwhUhi$~ binaryeqqivalen of +7Wcmiddottherefore nize the Ori~nal ~atiy-eQumber to be equ~ lo-7 1

Sectlonl7 Bh1ary Codes 17

ArIthmetic SubtractIOn

Subtraction of two signed binafy numbers whe~negative numbersare in2s-complement form is simple and can be stilted as follows

Take the 2s complement of the5ubtraltend (including the sign bit) and add it to the minuend (including the sign bit) A cany oU1of thesignbit position is discarded

This prOCedure is adopted because a subtraction operation can be changed to an addition operation if the sign of the subtrahend is changed as is demonstrated by the following relationship

(plusmnA) ~ (-tB) = (plusmnA) + (-B) (plusmnA) - (-B) =plusmnA) + (+B)

But changing a positivetwober toa negative n~ber is eaampily done by taking the 2s compleshy mentof the pQsitive number The reverse is also tiUe~use theCOmPle~n~ of a negative numshyber in complement form produces the equivalent positive number To see this consider the sJlbtr~ction ( 76) -- (13) = +7 In binaIy_ with eight bits this ()peiationis written as (11111010 11110011) The subtracti~ri ischmlged ~ addition by taking the 2s complement ofthe subtrahend (-13) giving (+13) In binaly tbis~ 11 niOlO+ 00001101 = lOOOOOU1 Removing the end~ we obtain the ootrect answer ()()()()() III (+7)

Itisworth noting that binary DUmbersinthe signed-complement system are added and subshy tracted by the same basic addition and suPtraction rules as unsigned numbers Therefore comshyputersneed omy one common hardware circuit tobandle bothtypcs ofaritbtnetic The user or programmer ~ust interpret the reswtIi of $l1ch addition or subtraction differently depending on whether itisassumedtha~the numbe~ are signed ltr tinsigned

j

BINARY CODES

Digitalsystems use signalsthat have two distinct values1Uld circuit elements that havetwostashyble states There is a direct analogy anrong binary iignals binary circuitelements and binary digits A binary number ofndigitsfor example may be represented by n binary circuit eleshyments each baving an output sig~alequivalen1to Oor I Digital systems represent (Uld mashynipUlate not omy binary numbers but alsO many other diScrete elements of information Any discrete element of informatioIidlat is dis1iilct among agroup of quantities can be represented witha binary code (Le a pattern of Os and fmiddots) The codes must be in binary because in todays techIiology omy circuits that represent and manipulate patterns of 0s and ls can be manufactured economically foru~ in computers However it mtistbe realizCd that binary codes merely change the symbols not the meaning ofthe ele~nts of infonbationthat they repshyresent IT we inspect the bits of a computer at random we will find that mostofthe time they represent some tYPe of coded information rath~ than binlUY numbers

AIln-bit binary code is a groopofn hits that assumes up to 211 distinct cOmbinations of ls ~d Os with eacn combination representing one elementof tnt set that is being coded A set

of four elements clab becoded with two lilS with each ~lementassignedoneof thefoUowing bit oombinationsOOO I 10 J 1 A set of eight elements requiies a three-bit code 00 a set of

18 Chapter 1 Digital Systems and Binary Numbers

J6 elements requires a fourmiddotbit code The bit combination of ann~bit code is determined the count in binuy from 0 to 21t - t Each element must be assigned a unique binuy bit binationand no two elemerits cm havetbtsamevalueothenvisethe code assignment be ambigUous

Although the minimum nqrnber of 1lits required to code 21t distiItct quantities is nthere nomaximwn numbe( of bit that may he used for a binuy code For example the 10 digits can be coded with 10 bits and each decimal digit can be assigned a bit combination nine OSmid a 1 In this pamcularbinarycode the digit6 is assigned the bit )UllIUlauuu0001000000

BCDcode

Although the binary number systemis die ~ost natural system for a computer most people more accustomed to the d~imal system One way to resolve this difference is to convert

inlal nUmbers to binary perform all arithmetic calculations in binary and then convert the nary results back to decimal This metbodrequites that we store decimal numbers in

cOinputer so that they canbec6b~rted to binary Since the compllter Can accept only valueswe must represent the decimal digits by means ofa code that contains ls and Os also pOsSible lopedorm the arithmetic operlltiorisd1rectly on decimal numbers when they stored in the comput~ in cod~ct form

A binarycodewill have some unasSigned bit com~inatiqns ifthe num~rofelements in set is not amultiple power of 2 The 10decimai digits form such asel A biruuy code that tinguishes among 10 elements must coiltain at least four bits but 6otitofthe 16 possible binations remain unassigned Different binary code$ can bemiddotoNained by arranging four into 10 distinct combin~tions TheicodeIllcfflt oommonly used fdr the decimal digits is straight binary assf~ntlisted in Table 14 This scheil)eis called bittary~coded decimal

is commoolyreferred to as BCQ OtherdecimalcodesaIlfpossible and a few of them are sentedlaterinthis section

Table 14 BinarymiddotCoded Oeclmql (BCO)

Decimal BCD SnlboiDIgIt

o 0000 1 0001 2 0010

3 0011 4 middot0100 5 0101 6 0110 7 0111 8 1000 9 1001

Sectionmiddot 17 BInary COdes 19

Table 14 givesthe four-bit code for one decimal digit A number with k decimal digits will require 4k bits in BCD Decimal 396 is represented in BCD with 12 bits as 0011 10010110 with each group of 4 bits representing one decimal digit A decimalmiddotnumber in BCD is the

- same as itS equiyalent binary number only when the number is between 0 and 9 A BCD numshyber greater than lOJpoks different from its equivalentbinary number even though both con tainls and Os Moreover the binary Combinations 1010 thrpugh 1111 are not used arid have no meaning in BCD Consider decimal 18SlUld its corresponding value inBCD and bUtary

(185ho = (0001100001Ol)BCD = (l0111001h

The BCD value has 12 bits to encode the characters of the decimal value but the equivalent binary number needs only 8 bits It is obvious thatthe representation of a BCp number needs more bits than its equivalent binary value However there is an advantage in the use ofdecishymal numbers because compUterinput and output data are generated by people who use the decshyimal system

It is important to realize that BCD numbers are deCimal numbers and not binary numbers although they use bits in tbeir representation The only difference between a decimal number and BCD is that decimals are written with the symbOls 0 1 2 9 and BCD numbers use tbebinarycode 00000001 001O~ bull 1001The decimal value is exaCtly the same Dec~mal 10 is represented in BCD witheight b~ts as 00010000 and decitna1J5as 0001 01Of1lte corshyresponding binaryvalues are 1010 and 1111 and have only four bits

Consider the addition of two decimal digits in BCD together with a po~ible carry from a pre- vious less significant pair ofdigitsSince each digit does not exceed 9 the sum cannot be bull greater than 9 + 9 + 1 = 19 with the 1 being a previous carrySllppose we add the BCD dig-

its as if they were binary numbers Then the binary sumvill produce It result in the range from degto 19 In bin8ry thistange wil[be from 0000 to 10011 butin BCD it is frOm 0000 to

I 1001 with the first (ie leftmost) 1 bemg a carry and the next fo~ bits being the BCD sum When tPe binary sum is equalto or less than 1001 (withaut 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 (0110h to the binary Sum cOnverts it to the correct digit and also produces a catTy as required This is because a carry in themost significant bitposishytion of the binary sum and a deCimal carry differ by 16 10 = 6 Consider the following three BCD additions

4 0100 4 0100 8 1000

+S +0101 +8 +1000 +9 1001 9 1001 12 1100 17 10001

+0110 +0110----

10010 10111

In each case the two BCD digits are added as if they were two binary numbers If the binary sum is greater than or equal to 1010 we add 0110 to obtain the correct BCD sum and a carry In the flIst example the sum is equal to 9 and is the correct BCD sum In the second example

20 Chapter 1 Digital Systems and BInary Numbers

the binary sum produces an iJlv~ BCD digit The addition of0110 produces the cortect BCD sum 0010 (ie the number 2) and acanyInthetbirdexample the binalY SUDlproduces acany This condition occurs wben the $W)) is greater than or equal to 16Altbough the other fout are less than 1091 the binary 9Ulll requires acOnectionbecause of die carry Adding 0110 obtain thetequiled BCD sum 0111 (ie the numblaquo 7) and 8 BCD CiUT

The additionoftwondigit unsipedBCD numbers follows the same procedure COIlSioll the addition of 184 + 576 1= 76() in BCD

BCD 1 I 0001 10000100 184

+6101 ~

0111--- 0110 +576

lJinarysum 0111 10000 1010 Add6 ono 0110

BCDsun 0111 0110 0000 7(1)

The flfSt l~ sigDiticant pili- of BCD digits produces aBCDdigi~SllDlof 0000 and a for the next pair of digits the second parr or BCD digits plus a ~Vi0U8 cany produces a sum of 0110 and a carry for the next patr()fdigits The third pair of digits plus acarry proltIUC~ a binary s~ of 0111 and does not require a correction

Decimal Arithmetic The represeiltation of signed decimal numbers in BCD is simiiarto the tepresentation of numbers in binaryWe can useeitheI the familiar signed-magnitude system at the SllZllOO-COI1I

plemelit system The sign of a decimal number is tJSually represented with four bits to to thefour-bit code ofthe decimal digits Itis customary to designate 8 plus With four Os 8 minus with the llCDequivalent oi9 whlcq is 1001 The sigiled~magnitudesystem is seldom used in com~tersThe signed-complerDem ~~ either the 9s octhe 10s complement put the lOscomplement is the one most useP To obtain the lOs complement of aBCD numberwe first take the 9s complement then add 1 to the least significant digit The 9s Complement is calculated from the subtracloo of each digit from 9

The prltXeduresdevelope4 for the signed-2s-complement system in the ~vious also apply to the signed-IOs-complement system for decimal mimberS Addition is done summing all digits including the sign digit and discafding the end carry This operatiQ assumes that all negative numbers are in 10s-complement form COOsider the (+375) + (-240) == + 135 done inthe signed-complement system

o 375

+9 760middot

o 135

lhe 9in the leftmost pOsition of the second n~ber tepresents a minllS and 9760 is the complement o( 0240 The two numbers are added and tbe end carry is discarded to +13SOfcourse the decimal ntmlbers insi~ tile computer includingthe sign digits in BCD The addition isdone with BCDOigits as described previously

Sectionl 7 Binary Codes 21

The suQtr8ction of decimalliUJ1lbets either unsigned or in thesi~-~Oscomplement systetn is the sameu in the binary case Taketbe 10s ootnplementof the subtrahend and add i~ to themin~nd ManyooDlputerslULvespeciaJ hardware to perform arithmeticcalculations directly withdecilnal oumbers in 8tDThe~u$etofthecoBlPuter can specify programliled Wtnlctionsto JOdonn the aDtiuJletiP oPmwoowithdeQmal n1UQ~ ~ywithout having to convell them to binary

Binafy codes for decimal digits requirea minimum of four bits per digit Many different codes can be formulated by~gjng four bits into IQ distinct combinations BP) and three other representative codes are shown in Table L5 Each code uses only 10 out ofa pOssible middot16 bit combinations that can be arranged with four bits The other six Unused cOmbinations have no meaning amt should be avoided BCD and the 2421 code are examplesofweigbted codes In a weigbtedcodeeach bit position

juBsigned a weighting f~in~awaythat eaehdigitcanbe ev~by 8dding the wei~ oran the lsin thecoded combination The BCD code has weights of8 42 and I which cotteshy

spondiothe powe1Of-two valuesofeaCh bitTbebitasSignmeatOll0 for example is interpreted by the weights to represent dedma16beCause 8 X 0 +4xt +2 Xl +IX 0 6Thebit combination 1101 when weighted by the ~ve digits 2421 gives themiddotdeCimal equivalent of 2 X I +4 gtlt I + 2 KO + 1 X 1 = 7 Note that some digits cantle coded in lw9 possib)e

ways in the 2421Q)(feFOr inke decimal 4 can be asSigned to bitCombinadon 0100 or 1010 since botbcOmbinatibns add upto a totalweight of4

middot1$ Fou Dlf(et Blnqry Code$ for thtJledmol DIgits

~ IICD DIgIt sal MZt Exeet) 8 4 -~1

0 1

000() middotmiddotmiddot0000 001)1 0001

oem 0100

0000 0111

2 0010 0010 0101 0110 3 0011 OQU 0110 0101

4 0100 0100 0111 oroo 5 0101 lOll 1000 1011 6 OlIO middot1100 1001 1010 7 middot0111 1101 1010 J001 8 1000 IUOmiddot 1011 1000 9 1001 11U 1100 1111

1010 oloi 0000 0001 Uaused IOU 0110 middotOOOl 0010 bit 1100 0111 0010 0011 combishynations

nOl 1110

lOW 1001

HOI 1110

1100 1101

1111 IOU) 1111 1110

22 ChaptfrliDfgltalSystemsaod Btoary Numbers

I1te 2421 rind the

e~l3~es are exampks Of self-complementing codes Such codes have~propertyjbatthe9s~plement ofa deCimal nfunberigobtairted directly by chang-

ing 1$ to O~$ finO tYSCfb1 sie~bycomple~mmgeaCh bit in the pattem)For example decshyimat3~Sis re~ fu tbeexcess3code as 01101100 1000 The 9s compl~ntof 604 isrepRse~l00liOOllelliwbich isobiainc(himply by complementing each bit of the

code (as with the 1 s coinpl~ofbin~rillDlbers)middot Theexcess~3code has been used in some oldel coritputers because of its selfcpmplement~

ing property Excess-3 is an unweighted code inwhich each codedcombinationis obtained-fJQm the corresPonQing bin3ryvalueplus 3 Note that the BCD code is1~ self-complementing TheS 4 ~~ Icode isan example of assigning both positive and negative weights to ~ decimalcodeInthis case the bit combiDation 0110isin~reted as oecimal2 and is calcu-

latedfrom8XO+4X 1 + (2) X 1 + (1XO=2 ~

Cra Code _ _ J

l1te output data QfmaJlfpbYsicaimiddot $)ShmlS are quantities that are continuous These data bemiddottonverted~digiWforuitJefore they art applied toaliigital system Contfuuous or ~nisCOIl~middotUitodigitalfonn bymeans of an rumlog~digitalConverter It is times ~~ent tousethe Gray code slown inTable 16torepresehtdigiuU data that have oon~ fMn8D8l08 dasaTheadvantage of th( Gray cOOeover thesllaigbt binary nIl11l1hPt~

~lt~thatoWY~ hit in the codegroup changeSin going from one number to the For examplcentbullin-goingfrom 1 to 8dleGray code cblngesfrom 0100 to 1100Only the fust changesfromOto l~the odter~ I)its mnaintbesame By contrast With binary numbers change from 7 to 8wrube from 0111 to lOOOwhich causes allfciur bits to change valUes

TabielAi GtPyCode

01 Decl COde Equivalent

~ 0000 0001 0011 OOlG 011Q Olll OlO 0100 1100 11m 1111 1110 lOlQ 1011

lOOt i

1000

o 1 ~ 3

4 5 6 7 8 9

10 11

12 13 14 15

SectIOnl7 BlnarYCod~s 23

The Gray code is used in applications in which the normal sequenceOrbiruuy rium~may produce an error orambiguitymiddot during themiddot transitionfrom ODeDWDber to the next If binary numbersareusec1 acbange forexaJIlple nom 0111 to 1000 may produce anintermediateershyroneous number 1001 if the value ofthe rigbtmost bit takes longer to -change than domiddotthe valshyues of the other three bits The Graycode elimb1ates this problem since only one bit changes its valve dUrlng aily transition be~een two numbers I

Atypical appli-cation ofmiddotthe Gray code is the representation of analog data by a Continu ous change in the angUlar position of a shaft The sQaftmiddot is partitioned into segments ana each segment is assigned a number If adJacent segments are made to correspond with the Qray-Codesequence ambiguity is eliminated between the angle of thesbaft and the value encoded by the sensor

Character Code

Many applications of digital computers require the handling not only ofnumberS but also of other characterS or symbols such as the letters of the alphabet For mstancean insurance comshypany with thousands of policyholders will use a computeX to process its files To represent the names and other pertinent information it is necessary to fonnulate bull binary code for the letshyters ofthe alphabet In additiQt1 the same binary qode must represent numerals and special Characters (such as $) An a1phanumeric character setis a set ofeiements that inclUdes the 10 decimal digits the 26leuersofthealp1iabe and a nutnbeof special~S~ a set conshytains between 36~d 64 elements ifonIy capital letters areincltided or between 64 and 128 e1eJDents ifboth uppercasemiddot and lowercllle etters are inclUded In the first case we need a bi- nary code ofsix bits and in the second we need a binary cooeO(seVM bits

The standaM binary code for the alphanumeric char8cters is the American Stahdard Code for Information InterCbange (A~n) which uses seven bitS to code 128 characters asshoWn in Table 17 The seven bitsof the code are desipted by b~through h With h the mostsigshynificant bit ~e leUer A for example is represented inASCn as l(l()()()Ol (column l00~tOw 0001) The Ascn ()()de also contains 94 graphic characters that can be printed and 34 nonshyprinting characters used for variQUS control functions The graphic characters consist of the 26 uppercase letters (A through Z) the 26 lowercase letters (a through z) the 10 numerals (0 through 9) and 32 special printable characters suchaS andS

The 34 control characters are designated in the ASCTItable With abbreviated nalne8 They are listed again below the table with their functional names The control characters are used fQr routing data and arranging the printed text into a prescribed format~ There are three types of control characters format effectors information separatOrs andcommumc~on-COnlrpl char~ IlCters Format effectors are characters that control the layout ofprinting They inciude the fashymiliar word pr6cessorand typewriter controlssucb 8$ bac~pace (BS) horizontal tabulation (HT) and carriage return (CR) Information separators are used to separatetbe data into divi~ sions such as paragraphs and pages Theyinclude characters such as ~ordseparator (RS)and file separator (FS)The cODlIDunication-control characters are uSefulduriDgthe transmission of text between remote tenninals EXllll1plesof conlmunicatiOn(ODtiol~ are STX (start oftext)-and ETX (end of text) whicb are used toframe a text mesaagetnQlSlnitted through telephone wires

24 Chap~er 1 Diglt8l Systems and Binary Numbers

rblel7 Amerkcm5tandard Code for Information (nterclHlnge(ASCII)

b~jbzb 000 001 010 on 100 101 no 111

0000 NUL )jLP SP () p P 0001 SOH OC1 1 A Q a q

R0010 STX OC2 2 B b r 0011 ETX DC3 3 C S Ii S

0100 EDT 0C4 $ 4 D~ T d t 0101 ENQ NAK 5 E iU e u OUO ACK SYN amp 6 F V f v 0111 BEL ETB 7 0 W g w 1000 B8 CAN ( S H K h x 1001 HT EM ) 9 I Y Y 1010 LF SU~ 1 Z j z lOll VT ESC + 1lt r k UOO FF PS lt L I I 1101 Cit OS == - M 1 m 1110 SO R~ N 1 n shy

-0PIt st US f 1 0 0 DEL

r- Control characten

NUL NlI]l DlE Data-inkescape SOH Start of hea~ng DC1 Device cOntroll STX Start of text DC2 DevIce io~1lOi2 ETX End (Jftext i DC3 Device corUlri1 3 OOT End oftraIlsmission ~4 DeVicecoQtrol4

ENQ ampqwry NAK Negativeackilowledge ACK

Acknowledge SVN Sync~nous idle

Btl Bell ETB End-of-tmnsnussionblOck sS Backspace CAN CanCel HT Horizontal tab EM End of mediUrlt LF Lintifeed SUB Substitute VT Vertical tab ESC escape FF form feed FS File separator CR Carriigeretum GS Group separator SO shift Ollt RS Reoord sepuator SI Shlftin US Unit separator SF S~e DEL Delete

ASCII is a seven-bit codebutrnostcompUters manipulate anejght-bit quantity asa unit called a byte Therefore ASCII characters most often are stored ~e per byte The

I biti~sometimesused forotlef purposes depending ontheapplicatio~lFor example printetS recognize eightmiddotbit AScn chaiacterS with themost sigoificaot bit ~twO An atkJlitlo

Section 18 Binary Storage and Registers 2S

128 eight-bit characters with the most significant bit set tol are used for other symbols such as the Greek alpbabet or italic tyIe font

Error-Dtectlng Code

To detect errors in data communication and processing aneigbth bit is sometimes added to the ASCll cbaracter to indicate its Panty Aparitybit is an extra hit included with a message to make the total num~ of ls either even or odd Consider the fo119wing two cbaracters and their even andodd parity

With even parity With odd parity Ascn A = 1000061 01000001 11000001 ASCI( T == 101deg100 11010100 01010100

1

- Ineacb casewe insert an extra bit in the leftmost position of the code to produce an even number of 1 s intQe cbaraeter for even parity or an odd number of 1 s in the character for odd parity In generlll one or tbe oth~r parity i~ adopted with even parity being more common

The parity biqsbelpful in detecting errors during the transmission ofinformation from one location to another nisfuJictiOD is bandIed by generating an even parity bit at the sending end for ~h character The eight-bit characters that include parity bits are transmitted to their desshytination The parity ofeachebaracter is thetichecked at the receiving~nd If the parity of the received cbaracter is Dot even then at1east on~bit has changed value dUring the trmlsmission This method detects one three or any odd combination of errors in each character tb8t is transshymitted An even combination oferrors however goes undetected and additioDaterror detic- shytion codes may be needed to take care of that possibility

What is done after an errQlis detected depends on the partieu~ application One possishybilityis to request retransrois~ion of the message on the assump~on that tbeenigtr was ranshyd()m andwill not occur again Thus if thereeeiverdetects a parityerrorit sends bai~ the ASCII NAK (negative acknowledge) control cnaracter consisting ofail even-parity eight bits lOOlOl01H no error is detectedthe ~iversends back anACK (aCkno~ledge) conshytrol character namely 0000011 O The sending end will respond middotto an NAK by tranSmitting the message again until the correct panty is received Ifmiddot after a number of attempts the transmission is still in error a message can be sent to the Operatai to check for malfunctions in the transmission path

BINARY STORAGE ANORECiISTEIlS

The binary infonnation inadigitalcomputermust have a physical e~stencein some medium for storing individual bits A binary cell is a device that possesses two stable sttes and is cashypable of storing pne bit (0 or 1) oflnfotlllation The input to tbe cell receives exciJation sigshynals that set it to one of the two states The output of the cell isa pbysicalquantity that distinguishes between the two states The irtformationstored in Ii cell is 1when the cell is in one stable state and degwhen the Cell is in the other stable state

26middot Chapter 1 Digital Systems and BtnaryNumbers

Registers

A register is a group of binary cells A register with n cells can store any discrete quantity of middot information thatcontains n bits The state ofa registeris an n-tuple ofls middotand Os with each bit designating the state of one cell in the register The C()ntent ofaregister is a function of the int~rpretation given to tbeinformation stored in it Consider fQf ex~ple a 16-bitregister with the following binary content

11 00001111001001

middot Aregjs~ with 16 cells can be in one of 216 possible statesIf one asstimesthat the content cif the register represents a binaryinteger then the register can store any binarydumber from Oto 216 - 1 For the patticularexample shown the content ofthe register is the binary equivshyalent(lftbe decimal number 50121 If one assumes instead that the register stores alpbanushy

middot meric characters of an eight-bit cooe then the content of the register is any two meaningful characters For tht ASCII code with anevenplirityplaced in the eighth most significant bit position the register contains thetwo charactersC (the lefunosteightbits) and I (the rigbt~ most eight bits) If however one in~rprets the content of the register to be four decimal dig- its represented by a four-bitcode tnenthe content of the register is a four-digit decimal number In theexcess-3 code the register holqs the decimal nutriber 9096 The content of the registe~is meaningless in BCD becau~e the bit combinatiOn ltob is 110t assfgned to any decshyimal digit From this example it is clear that a register can store discrete elements of inforshymation and that the same bit configuration Inay beinterpreted dlffe(ently for different types of data

tmiddotmiddotReglsterTrail Adigitalsystenlis characteriZed by its registers and the components thatpetfolin data proshy~ssingIIl digital sy~tems a rcentgister tra1lsfer operation is abasi operation that consists of

middot a transftr of hiJWy hUormation from one ~t of registers into ano$er set of registers transfer may be dir~ctfr9m one regist~r toanlt)ther or may pass througb datamiddotprocessing circuits to petformaD operation Figure L 1 illustratel the transfer of iidOrnuttion among regshyisters anddemonstratespictorlallY [the tr8ll~~ ofbinaryinformation from akeyboard a register in the memQryullit Thehlputunit~s assumed to have a keyboard1 control cuit and aninput register Each time a key is strock the control circuit enters an ImnV$_

lent eight-bit alphanumeric character coqe into the input register We shall assume that code used is the ASCII code with an odd-parity bit The information from the input regisshyter is transferred into the eight-least significant cells Qf a proeessOr register After transfer theinpui register is cleared to enable the control to insert a new eight-bit when the keyboard is struck again Each eight-bit character transferred to the pro1c4ess(raquo register is preceded by a shift of the previous character to the next eight cens on its left~

middot a transfer -of four characters is completed the processor registeris full and its contents transferred into a memory register The content stored in die memOry register shown in Figl came from the transfer of the characters J 0 H an~ N aftet the four ap)lroJ)riatt keys were struck

Section 18 Binary Storage and Registers 27

FIGURE 11 Transfer of information among registers

To process discrete quantities of infoiniatiori in binary form a computer m~st be promiddot vided with devices that hold the (lata to be processed and with circuit elements that manipmiddot ulate individual bits of irifonnation The device most commonly used for holding data is a register Binary variables~ manipulated by means of digital logic circuits Figure 12 il~ luslrates the process of adding two l()bit binary iUlmbers Themeniory unit which no[shy

mally consists of millions of registers is shown with only three ofits registers Thepait of the processor unit showncoDsistsmiddotofthree registers-RI R2 and R3~getherwith digital logic circuits that manipulate the bits of RI and R2 and transfer into R3 a binary number equal to their arithmetic sum Memory registers store information and are incapable of pr0shy

cessing the two operands However th~ information stored in meDij)iybanbetransferred to ~ processor registers and the resUlts obtainedin processor tegisters can be transferred back into ame~ry register for storage Untill)ecded again The diagram ~wsthe90ntents of two

operands transferred from twoJDemoryregisters into RI imd R2 The digital logic circuits produce the sum which is transfened to register R3 The contents of R3 can now be 1riUlsshyferredback to one of thetnemory registers

The last two examples demonstrated the infonncion-flow capabilitieSofa digital system in a simple manner Themiddot registets of the ~ystem are the basic ele~ents for Noring and holding the binary information~igitallogic circuits process the binary ihfonaation stored in the

28 Chapter 1 DigIt bullbull Systems and Binary Numbers

Sum

FIGURE 12 Eumple of blnarylnfonn~t1on processing

registers Digitallogiccirctiits and registers are covered InChQpteB 2 throQgh 6 The metlilOlY unit is ~xPIained ill 9aptet 7 Th~ descriptton of register opetJtions at the register level and the design of digital systems are covexed in Chapter 8

19 BINARY LOGIC

Binary logic deals with variables th~ take on two discrete valueund withoperations that sumelogicalmeaning~ The two val~s the variableussume may be called~ydifferent (true andalse yel and no etc) but for ourp1llpQSe it is cpqVenienttotbink in terms of and assign the values llUld O The binary logic intr0ducedin this section is equivalent to algebra oalledBoolean algebra The fannal presentation ofBoolean algebra is covered in detail in Chapter 2 The purpose ofthis seCtion is to introduce Boo algebra ina matmerandlate it to digitallogiccircuits andmiddotbinarYsignalsmiddot

Section 19 Sinary logic 29 ~

Itkltn of IInary logic

Binarylogic consists of binary v~les and a set of logica1middotoperatiQDS The variables are desigshy ~by lettell of thCalplWlet~such asA B C x yz etc with eaCh variable baving two and oniy

two distinct posSible valueS 1and O There are three basic logical operations AND ORand NOT

1 AN]) This ~peration is represented by adotorby the absence ~f an oPerator For example x bull y =z or xy = zis~ x ANDy is equalto z~ThelogicaloperationAND is interpreted to mean that z == 1 ifand only ift~ land y = 1 otherwise z = O (Reme~r that x y andzare binary v8riablesand canmiddotbe equal either to 1 or Omiddotand nothing eise)middot

2 OR This operation IS represented by a plus sign For example x + y =z is read x OR y is equal to z meaning that z 1 if x = iorif y = lorifbothx= 1 and y = 1 If bqth X - 0 andY Omeo z= O

3bull NOT This operation is repf6sented by a prime (sometimes by an overbar) For ~xample x =Z (or~ =z) is read notdsequalto 1 meiming that z iswkatx isnot In other

words ifx = 1 then z == 0 but if x == 0 tnenz = L TheNOT operationisals(1 reshyferred tolls the complement operation since it changes ~ 1 toOand a O to 1

bull bull lt Binary logic resembles binary arithmetic and themiddot9peratioos ANDahd OR have similarishy

ties to multiplication and addition respectively In fac~ the symbols used for AND and OR are the same as those used for multiplication and addition However binary lOgic should not be conshyfused withbinaryarithIrietic One should realize thatan arithmetic variable designates a numshyber that may consist of many digits A logicmiddot variable is always either 1 or O For example in binary arithmetic we have I +1 =10(read~one plus ()fie is equal to 2) whereas in binary logicwe have 1 + 1 1 (read one OR onds equal to one)

For each combination of the values oix and y bullthere isa value of ~ $pecifiedby the definishytion of the logical operation D~linitiops of logical~perations maybe listed in a compacHorm called truth tables A truth table is atable of anpbssible combinations ofthe variables $howshying the relation between the values that the variables may take and the resultof the operation The truth tables for th~ operations ANDand OR with variables x and y are obtained by lis~ng

all possible values that the variables may have when combined in pairs bull For each combination the resUlt of die operation 18 theillistedin a separate row The truth tables for ANDORand

NOT are given in Table La These tables clearly demonstrate the definitionf the operatibns

Table 18 Truth TcibJts of Logical Operations

AND OR NOT

x y xmiddoty x y x+y

0 0 0 0 0 0 1 0 0 1

10

1 0 d 1 0 1 I 1 1 1 1 1

bull~lt~m

30 Chapter 1

Logk Gates

Digital Systems and Binary Numbers

Logic gates are electronic cirellit that operate on ~

variable

or mpre mput tignals to produce an output signal Electrical signals sUch as voltages orrutrents exist as analog signals having values over a given taDgebull saYOt03 V but in a digital system are interpreted to be either of two recognizable values 0 or 1 Voltage~opetated logic Circuits respond to two separate voltshyage levels that represent a binary varjable equal to logic I bt logic O For example a partic- ular digital system may define 10gicOas a signal equal to 0 volts lind logic 1 asa signal equal to 3 volts In practice each voltage levelhiS an acceptable rangeas shown in Fig 13

The input te~nals of digital cikuits accePt binary signals within the allowable range and respond at the output terininals with binary signals that fall within the specified range The intermediate region between the aJl()wed regions is crossed only during aState transition Any desired information for computing or control can be operated tm by passing binary signals through variQUS combinatioDsof logic gates with each signal represebting a particular binary

The graphic symbols used to deSignate themiddotthree types of gates are Mown in Fig 14 The

gates are blocks of hardware that prooocc tbeequivalent of1ogic~1 orlogic() output signals

Volts

- FGURl13

x

y

Exampleof binary slgnaJs

Signal ratlge for logieO

(a)~omiddotinput AND gate

FIGURE 14 SymbOls for digital logic circuits

(c)NOT gate or invert~

Problems 31

x-lU 1 11 P 0

y 0 0 11 1 ~

ANDxy 0 0 rTl 00

ORX+Y~ NOT x 11 0 0 I 1 1

FIGURE 15 Input-output 5Igals for gates

FIGURE 1

A B C

Gates WIth mlltlple JnpUU

A B C lJ

~

if inPllt logic ~ts are satisfied Theinput signals xaDd y intheNDaadQR gates may exist in ~ oHow-possible states 00 10 11 or 01 Il1ese ibpu~ampignals_ shown inFig lStoshygetber with the corresponding output signal foreach PfCThI~tiaiug~iDustrate the reshysponse ofeaclt gate to the four input signal~The~llisofthetiminadiagram represents time and the vertical axis sbo~~~~ it cbapg~botwcen~possible voltshy

age levels The low level represents logic O tJte high level l1lteAND _ responds With a logic ~ ~tput sipl wh~ both input ~~)e 1middot1~ lIieOR S-~with a logic 1 outpUt signal ifanylnput sigrudis lOgic 1 TheNOTgateis~~ to BUll invedet The reason for~nameis~t froJn the signalmsponae inmiddottbe timitt8 diagramwhicbsbows that theoUtputsignal inverts the logic sense of tbeiDpUtsigll8l

AND and OR gates may bavei)lQte tbantwQinputs M AND8_~itti ~input$andan OR gate with foU) inputs are shown in Fig 16 The three-inPllt AND gate responds With logic 1 output if all tbreeinputs arelogic 11jleoutputproduces lOgic Oifanymput is logic O-The

four-input OR gate responds withlogic 1 ifany input is logic 1 its clu1ptltllCCoines logic oonly when all inputs are logic O

Answers to prvblems marked with middotappearaHbe ClOd ofthe ~

11 lJltthe octal and beXadecimalliurilbers trom16ui 32UdngA B1l1ld C forthebst~ digits Usttbe numbers from 8 to 28 in base13 bull

I

12t What is the exact D1Jllbcr of bytes in a system that contains lta) 32Kbytoe (b)64M ~and (e) 640 byte$ middot7 t

32 Chapter 1 Digital Systemsand Binary Numbers

13 Convert the following nu~bers with the indicated bases to decimal (a) (4310)s (b) (198hz (c) (735)8 (d) (525)6

14 Whllt is the largest binary number that can be expressed with 14 bits WhlIt are the equivaleDt ~~ iinal and hexadecimal numbei-s

--

15 Detemrine the base of thl1 numbers in each case for the following operatio~ to be correct (a) 142 = 5 (b) 5414 = 13 (C) 24+ 17 == 40

16 The solution$to the q~cequation xl - Ux +22 oare l1 3 arid x =6 What is the base of the numbers

17 Convertthehexadecimal ntmIher 68BE to bitiary and then convert it ~mbinary to octal

18 I Convert the decirpal number 431 to binary in tWo ways (a) Convertd~y to binary (b) conshyvert first to hexadecinla1 and then from ~decimalwbinary Which method is faster

19 amppress the following nqrnbersin decinud (a) IQ11O0101)z (b) (l65his (c)(2624)8 (d) (FAFA) 16

(e) (10101010)2

110 Convert the following binary numbers tobexadeoimal and todecitnal (a) UOOlO (b) 110010 Explain why the deCimal answer in (b)is 4 times that in (a)

111 Perform the followingdiviskmin binary 11 Ion + l()t

112 Add IlniImultiply tfle following numberswiihout converting them to decimal (a) Binary nuniberilOll aiIdlOh (b) He~uumbers 2E aDd 34

1~)( Do thefoHowing con~ersionproblems (a) CorivertCiecimal2731S to binary (b) CakUlate the binary eqUivalent (f 213 outto eight pl~Then Convert from binary to

imalHowgJose istbe result to 2131 (c) Convert the binary resukin (b) into hexad~ lb~oonvert ~result to decimal Is answer tbesame

114 Obtain the is 8nd 2s complementsofthe foUowing binaryDumbcentrs (aj l)()()(J()OO (b) OOOOOOOO (c) 11011010 (d)01l10110 (e) 10000101 (0 11111111

115 Find the 9s and the 10s complement of the following detimal numbers (a) 52734630 (b) 63325600 (c) 25000009 (d) 00000000

116 (a) Find the 16s complement of B2FA (b) Convert B2FA to binary (c) Find the 2scomplement ofthe resultin (b) (d) Convert the answer in (c)to hex~malandco~ with ihe an~wer in (a)

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 12: Chapter 01 - Mano

12 Chapter 1 Digital Syst-ems and Binary N~mbers

The following examples illustrate the procedure

plPi1I VsinglOs complement subtract 72532 - ~250

M = 72532

lOs complement of N + 96750 Sum= 169282

Discard end caIry lOS = -100000 Answer = 69282

Note that M bas fiv~ digits andN has only fourdigitsBoth numbers mtast have the same numshyber of digits sowe wrlteN as 03250 Taking the lOscomp~ementofNptOducesa9 in the most significant PositionThe occurrence of the end carry signifies that M ~ N 8ndtlult ~ result is therefore positive

Ulling 10s complement subtract 3250 - 72532 - ~ ~

M = 03250 JOscornplementof N =+27468

Sum= ~0718

There is no end carry Theref()re-theanswer is--(10amp complementof30718) == -69282 Note thatsince 3250 lt n532~the result is negative Becauwe are dealing with WUiigned

numbers there is really no way to get BnunSigned result for this case When subtracting complements we reoogilize the negltive answer from the~sence of the end carry and complemented result When workingwith paper and pencil we c8nchlnp the aDswer

signed negative number in oider to putH inafamiliar form Subtraction with complements is done with binary numbers in a similar manner uing

procedure outlined previously

EXAMPLE 17

Given the two binary numbersX = 1010100 and Y =1000011 performtbe $UbiDctiG (8) X - Y arid (b) Y - Xby using 2scomptem~ts -

f

- -

Section 15Complements 13

(a) x = 1010100

2s complement ofY= + -0111101

Sum = middot 10010001 Discard end carry 27 = 10000000

Answ~ X- Y = 0010001

(b) Y == 1000011 2sco~lement of X = + 0101100

Sum= 1101111

There is nQmiddotend carry Therefore the answer is Y ~X= -(2sq)mplement of 1101111) = -0010001 Subtractionof unsigned D1lJllbers ~ also bed()neby means of the (r - 1)s complement Remember that the(r- l)s complement is one lesstharithers complement BeCause of

ibis the result of adding the minue~ to tJte coQlplement of the subtiah~ndPtOductS itsum that is one less than the correct 4ifference when an end carrY oCcurs Removing the end carry and adding 1 to the sum is referred to asan end-around carry

Repeat Example 17 but this time using rs complement

(8) X y = 1010100 - 1000011middot

X= 1010100

rs complementafY= + olfnoo Som = 10010000

End-arOundmiddot~ =- ~ ~ Answermiddot X Y= middot0010001

(b) Y - X = 1000011 - 1010100

Y = 1000011

1s complement ofX = +0101011

Sum = 1101110

There is no end carry TherefOre the answer is y - X = -(1s complement of 1101110) = -0010001

bull Note that the negative resultis ob~ by taltingtbe 1 scomplemeilt of theJWltsince this is the type ofcoDiplementused The procedwewithendaroundoanyis aIs(gt Iijlpliclbleto subshytracting Unsigned deciImdnumQers with 9seomPlement

14 Chapter 1 Digital Systemsand BinayNumbers

16 SIGNED BINARYNUMBER$ ~

Positiveintegers (including zero) CaBbe ep~~ 11$ unstPecl numbers However to repshyresent negative integers we need a notation for negative srn ordinary arithmetic a negshyative number is indicated by a mulUs signmdapOsitiv~Pwtlt)e~ by aplus sign Because of lJardware limitations computers mlstrepresenlev~With~ digitsIt is customary to represent the sign witb a bit placed intheleftmotp6sitiolwfthe number The convention is tltl make the sign bit 0 for positive and 1 for negative

Itis important to realize that botp siped and unsignedtDnary 11UJDbers consist of a strfug of bits when represented in a com~ TQeuser detem1inesWbether the number is signed or unsigned If the binary number is signed then the lefuriostbitreple$ellts thtsign aud the rest of the bits represent the number Ifthebinaryllu~beiis~ tObe unsigned then the left most bit is the most significant bit of the l)uMber Fdre~the~~f bits 01001 can be consideredas 9 (unsigned binary) or as +9 (Sighedbitia1j) ~USJtheteftmostbit is O The

string ofbits 11001 represents the binary ~~v~ento~ ~w~nc~idered as an unsigned number and the binary equivalent of 9whenconsidered1l si~riumPer This is because the Ithal isintbe leftmost positiondesignatesampC nega6ye_~QtherfourJ)its represent bishynary 9 usually tlere is no cotifusionin identifying thebits~the~Qfrepresentation for the number is known in advance ~

The representation of the signed numbers in the lastexainple is referred to as the signed magnitutk coDvention In this ~otati()nthenurnber C4mSiampesOCa mQ~~andil~ymbolH

or -) or a bit (0 or 1) indicating the sign This is the representation ampr~~used in ordinary arithmetic When arithmeti~ operatioBslllieimplerneJltcldin~cOQlPuter hii more convenient to use a different systemrefetred t(gt as the si~cqmptement system~ for repre- senting negative numbers In thissystlm a neg8tielliun~r isjhdic~ted by its cornplc~mc~nt Whereas the signed-magnitude system negates a nlllllher by cbanging its sign me signed-comshyplement system negatesanwnber bytakin$ its~OinPleltleitiSinoepositife numbers always start witbO(plusin tte leftmost pOsition thecompktllint wiilalwaysstart with a 1 indicating a negative number The siped-complemelt system can use olthertbe 1s Or the 2s but the 2s complement is the mos~comtliOfi

As an exampleconsider the number9re~~ed in binary with eight bits + 9 Is sented with a sign bit of Oin the leftri1ostpOsition oIIOv~by the binary (equivalent of 9 which gives ()()()olOOl Note thai all eigbtbits must haYampa v~therefore O~s are inserted folshylowing the sign bitllp to the first 1 Although ~ is only 01K way to tepresent +9 there three different ways to represent 9 with eight ~its

s~gned~magnituderepresentation 10001001

sigried-l s-complement represe~on~ 11110110

signed-2 s-complemerit representatim 1ttltllU

In signedmagnituamp -9 isobwned from +9 by changing the sign bitmtbe leftmost ~iti(ln tromO to L In sigl1ed~ lroomplement 9isobtaidedtf~~tiog all the bits of includinj the sign bit Thesigned-2~sco~re~Qf-9 is obtampDedby ihe 2s complement oftbepOsitivenumberincludingtbesijnbIt

Sectlont6 SIgned8lnary NumberS is

Table 13 Slgtlfd Biliary Humbm

+7 +6

+5 +4 +3 +2 +l +0 0 -I

-2 -3

4 -5 -6 -1 -8

Olll 0110

0101 ( 0100

001l 0010 0001 0000

IIll 1110

nOI noo Ion 1010

1001 1000

OIll Oito eHOl OHIO OOU 0010 0001 0000 1111 1110middot dOl 1100 Ion

lOti 1001 1000

0111 OUO 0101

0100 0011 0010 0001 0000 1000 1001 1010 IOU 1100

1101 1110

lUI

Table 13 lists all possible four-bitsignedbinaryaumbers in the three representations The equivalent decimal number Is also shown for refelenoeNote that the positive n~ in all three representations are identicaland have 0 inthelefmostpcsiticm The signed2sshycompl~mentsystemhaironly onemiddotrepresentation for 0 which is always po$itive The other tw()systetns- mlve either a positive 0 or a negative 0 sometbingnoteDcounteredin ordinary arithmetic Note that all negative numbenhave alin the leftmost bitpositi~ that is the way we distinguish them from the positivenumbers With fout bits we can repreSent 16 binary numbers In the signed-magnitude aDd thelscomplement repre$eDtatipns there are eight positive numbers and eight negative numbers inciUdingtwo zeros In the2s-complement representation there are eight positive numbers includi0a one zerQ and eight negative numberS

The siped-m_gnitude system is used in ordiIlary arithmetic but is awkward when emshyployed in computer arithmetie becauIe of the ~parate bandIinJ bfthesipand the magnitude Therefore the signed-compiement systeni is normallyused The ls ~t imposes some difficulties and is seldom USedJor arithmetic openitiOns It is U$eful aSa lo~ operation since the change of 1 to Obrmiddot() to 1 is equivalent to a logical complement Operation as will be shown in the next c~The discussion~f sigiled binary ariduneti~ that fol10ws deals exshyclusively with the signe4-2soomplt_nt~tatJonQfnegadveilUlilbers hsame proshy

cedurescan beappJied to the sigMdrs-comPlemeD~Iysby incIudiOI tbe~arotmdcarry as is done with unsigned numbers

J6 Chapt~r 1 OlgltalSystlf(ns and Binary Numbels

Arithmetic Addition

The addition of two numbers in the signed-magnitudelYs_foUowsthe rules ofordinaiy arithshymetiC Ifthesi~s arethesam~we addthetwOtt~gni1U~~d ~vetbe sum the CCmmon sign Iftbe signs are diffe~nt we subtract tllcsmaUermagnitude frOtnlthe larF and give the differshyehtethe signof the larger magnitude For example (+25) +( - 37) = ~ (37 - 25) = -12 and is done by subtracung the smaller magnitude 25 from the larger magnitude 37and a~nding the sign of 37 tGtbe result Ibis is a process that requires a corripanson of the signs and magnitudes and then performing eithr additi()n or subtraction The same procedure applieato binary numbers in sigped-magnitude representation~Incontrast the rule for adding numbers in the signed-corppleme~ sy~tem does not require a comparison or su~ traction but only addjtion The procedure is very simple andcanbe stated as follows for binary numbers The 8ddltion oftwo signed binary numberS with negative numbers tepresented in signed- 2sComprement fonn is obtaiIled from theadditlooofthe two numbers includingtheii sign bits

AcentiirrY out oftbe sign-bitposition is diScacded NumerIcal e~aihpledotai1dition follow

+ 6 00000110 - 6 11UI0tO I

+13 00001101

+13 00001101 +19 00010011 + J 0Q900111 + 6 00000110 6 11111010 ~13 11110011 -1~l 11110011 7 illl1001 -19 11101101

I bull bull ~

Note that negative numbers musthil iriitially in 2seompkmentform and that if the swn ~ ~afterthladdit40nis negativeins in2s~p~t fOl1Jl - In each of thefoDrcasestlteoporationperfol1JlC(lis additionwitb the sign bit iilcluded Any catTY o~of~~-bit~onisdisc~ and negative resultsareButomaticallyin 2sshyromplementfoon

In order to obtain acOrrect answer we mustensQre that the result has a sufficient of bits to accommodate the swnlfwestartwith t~on-bltnumbers and tbeswn occupies n + 1bits we say tblltan overflow occurs~Wheri one perfotmStbc ad(JitiOJl with nllllIPTJllVIl

pencil aq overflow is not a preblem because we arcr noflimitecLbythewidth of the page jUst addanothcentr 0 to apositive number or another 1 toa negative number in the mOst cant positi()n to extend thenwnber to n+ 1 bitSand theQ perform addition Overflow is

problem in computers beqiusetbe number ofbi~~ bolla ~befis finite and a result ex~ tI1efinite val~e hy lcatmotbe accommodated

The compJement form of representiQg negativetlQUlbers is unfamiliar to those usedto signed-magnitude system To itetermine th~ value of II negatienumber insiped-2s COlIlpJe

mentit0is~ to CODVerttbe numbcr to apositie ntirit_ ~ place itiDa more formPor ~plethesig~binary number qUl00~ lii~egativebecausothe leftmost

t 1182s c0J8plemen~js~UlwhUhi$~ binaryeqqivalen of +7Wcmiddottherefore nize the Ori~nal ~atiy-eQumber to be equ~ lo-7 1

Sectlonl7 Bh1ary Codes 17

ArIthmetic SubtractIOn

Subtraction of two signed binafy numbers whe~negative numbersare in2s-complement form is simple and can be stilted as follows

Take the 2s complement of the5ubtraltend (including the sign bit) and add it to the minuend (including the sign bit) A cany oU1of thesignbit position is discarded

This prOCedure is adopted because a subtraction operation can be changed to an addition operation if the sign of the subtrahend is changed as is demonstrated by the following relationship

(plusmnA) ~ (-tB) = (plusmnA) + (-B) (plusmnA) - (-B) =plusmnA) + (+B)

But changing a positivetwober toa negative n~ber is eaampily done by taking the 2s compleshy mentof the pQsitive number The reverse is also tiUe~use theCOmPle~n~ of a negative numshyber in complement form produces the equivalent positive number To see this consider the sJlbtr~ction ( 76) -- (13) = +7 In binaIy_ with eight bits this ()peiationis written as (11111010 11110011) The subtracti~ri ischmlged ~ addition by taking the 2s complement ofthe subtrahend (-13) giving (+13) In binaly tbis~ 11 niOlO+ 00001101 = lOOOOOU1 Removing the end~ we obtain the ootrect answer ()()()()() III (+7)

Itisworth noting that binary DUmbersinthe signed-complement system are added and subshy tracted by the same basic addition and suPtraction rules as unsigned numbers Therefore comshyputersneed omy one common hardware circuit tobandle bothtypcs ofaritbtnetic The user or programmer ~ust interpret the reswtIi of $l1ch addition or subtraction differently depending on whether itisassumedtha~the numbe~ are signed ltr tinsigned

j

BINARY CODES

Digitalsystems use signalsthat have two distinct values1Uld circuit elements that havetwostashyble states There is a direct analogy anrong binary iignals binary circuitelements and binary digits A binary number ofndigitsfor example may be represented by n binary circuit eleshyments each baving an output sig~alequivalen1to Oor I Digital systems represent (Uld mashynipUlate not omy binary numbers but alsO many other diScrete elements of information Any discrete element of informatioIidlat is dis1iilct among agroup of quantities can be represented witha binary code (Le a pattern of Os and fmiddots) The codes must be in binary because in todays techIiology omy circuits that represent and manipulate patterns of 0s and ls can be manufactured economically foru~ in computers However it mtistbe realizCd that binary codes merely change the symbols not the meaning ofthe ele~nts of infonbationthat they repshyresent IT we inspect the bits of a computer at random we will find that mostofthe time they represent some tYPe of coded information rath~ than binlUY numbers

AIln-bit binary code is a groopofn hits that assumes up to 211 distinct cOmbinations of ls ~d Os with eacn combination representing one elementof tnt set that is being coded A set

of four elements clab becoded with two lilS with each ~lementassignedoneof thefoUowing bit oombinationsOOO I 10 J 1 A set of eight elements requiies a three-bit code 00 a set of

18 Chapter 1 Digital Systems and Binary Numbers

J6 elements requires a fourmiddotbit code The bit combination of ann~bit code is determined the count in binuy from 0 to 21t - t Each element must be assigned a unique binuy bit binationand no two elemerits cm havetbtsamevalueothenvisethe code assignment be ambigUous

Although the minimum nqrnber of 1lits required to code 21t distiItct quantities is nthere nomaximwn numbe( of bit that may he used for a binuy code For example the 10 digits can be coded with 10 bits and each decimal digit can be assigned a bit combination nine OSmid a 1 In this pamcularbinarycode the digit6 is assigned the bit )UllIUlauuu0001000000

BCDcode

Although the binary number systemis die ~ost natural system for a computer most people more accustomed to the d~imal system One way to resolve this difference is to convert

inlal nUmbers to binary perform all arithmetic calculations in binary and then convert the nary results back to decimal This metbodrequites that we store decimal numbers in

cOinputer so that they canbec6b~rted to binary Since the compllter Can accept only valueswe must represent the decimal digits by means ofa code that contains ls and Os also pOsSible lopedorm the arithmetic operlltiorisd1rectly on decimal numbers when they stored in the comput~ in cod~ct form

A binarycodewill have some unasSigned bit com~inatiqns ifthe num~rofelements in set is not amultiple power of 2 The 10decimai digits form such asel A biruuy code that tinguishes among 10 elements must coiltain at least four bits but 6otitofthe 16 possible binations remain unassigned Different binary code$ can bemiddotoNained by arranging four into 10 distinct combin~tions TheicodeIllcfflt oommonly used fdr the decimal digits is straight binary assf~ntlisted in Table 14 This scheil)eis called bittary~coded decimal

is commoolyreferred to as BCQ OtherdecimalcodesaIlfpossible and a few of them are sentedlaterinthis section

Table 14 BinarymiddotCoded Oeclmql (BCO)

Decimal BCD SnlboiDIgIt

o 0000 1 0001 2 0010

3 0011 4 middot0100 5 0101 6 0110 7 0111 8 1000 9 1001

Sectionmiddot 17 BInary COdes 19

Table 14 givesthe four-bit code for one decimal digit A number with k decimal digits will require 4k bits in BCD Decimal 396 is represented in BCD with 12 bits as 0011 10010110 with each group of 4 bits representing one decimal digit A decimalmiddotnumber in BCD is the

- same as itS equiyalent binary number only when the number is between 0 and 9 A BCD numshyber greater than lOJpoks different from its equivalentbinary number even though both con tainls and Os Moreover the binary Combinations 1010 thrpugh 1111 are not used arid have no meaning in BCD Consider decimal 18SlUld its corresponding value inBCD and bUtary

(185ho = (0001100001Ol)BCD = (l0111001h

The BCD value has 12 bits to encode the characters of the decimal value but the equivalent binary number needs only 8 bits It is obvious thatthe representation of a BCp number needs more bits than its equivalent binary value However there is an advantage in the use ofdecishymal numbers because compUterinput and output data are generated by people who use the decshyimal system

It is important to realize that BCD numbers are deCimal numbers and not binary numbers although they use bits in tbeir representation The only difference between a decimal number and BCD is that decimals are written with the symbOls 0 1 2 9 and BCD numbers use tbebinarycode 00000001 001O~ bull 1001The decimal value is exaCtly the same Dec~mal 10 is represented in BCD witheight b~ts as 00010000 and decitna1J5as 0001 01Of1lte corshyresponding binaryvalues are 1010 and 1111 and have only four bits

Consider the addition of two decimal digits in BCD together with a po~ible carry from a pre- vious less significant pair ofdigitsSince each digit does not exceed 9 the sum cannot be bull greater than 9 + 9 + 1 = 19 with the 1 being a previous carrySllppose we add the BCD dig-

its as if they were binary numbers Then the binary sumvill produce It result in the range from degto 19 In bin8ry thistange wil[be from 0000 to 10011 butin BCD it is frOm 0000 to

I 1001 with the first (ie leftmost) 1 bemg a carry and the next fo~ bits being the BCD sum When tPe binary sum is equalto or less than 1001 (withaut 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 (0110h to the binary Sum cOnverts it to the correct digit and also produces a catTy as required This is because a carry in themost significant bitposishytion of the binary sum and a deCimal carry differ by 16 10 = 6 Consider the following three BCD additions

4 0100 4 0100 8 1000

+S +0101 +8 +1000 +9 1001 9 1001 12 1100 17 10001

+0110 +0110----

10010 10111

In each case the two BCD digits are added as if they were two binary numbers If the binary sum is greater than or equal to 1010 we add 0110 to obtain the correct BCD sum and a carry In the flIst example the sum is equal to 9 and is the correct BCD sum In the second example

20 Chapter 1 Digital Systems and BInary Numbers

the binary sum produces an iJlv~ BCD digit The addition of0110 produces the cortect BCD sum 0010 (ie the number 2) and acanyInthetbirdexample the binalY SUDlproduces acany This condition occurs wben the $W)) is greater than or equal to 16Altbough the other fout are less than 1091 the binary 9Ulll requires acOnectionbecause of die carry Adding 0110 obtain thetequiled BCD sum 0111 (ie the numblaquo 7) and 8 BCD CiUT

The additionoftwondigit unsipedBCD numbers follows the same procedure COIlSioll the addition of 184 + 576 1= 76() in BCD

BCD 1 I 0001 10000100 184

+6101 ~

0111--- 0110 +576

lJinarysum 0111 10000 1010 Add6 ono 0110

BCDsun 0111 0110 0000 7(1)

The flfSt l~ sigDiticant pili- of BCD digits produces aBCDdigi~SllDlof 0000 and a for the next pair of digits the second parr or BCD digits plus a ~Vi0U8 cany produces a sum of 0110 and a carry for the next patr()fdigits The third pair of digits plus acarry proltIUC~ a binary s~ of 0111 and does not require a correction

Decimal Arithmetic The represeiltation of signed decimal numbers in BCD is simiiarto the tepresentation of numbers in binaryWe can useeitheI the familiar signed-magnitude system at the SllZllOO-COI1I

plemelit system The sign of a decimal number is tJSually represented with four bits to to thefour-bit code ofthe decimal digits Itis customary to designate 8 plus With four Os 8 minus with the llCDequivalent oi9 whlcq is 1001 The sigiled~magnitudesystem is seldom used in com~tersThe signed-complerDem ~~ either the 9s octhe 10s complement put the lOscomplement is the one most useP To obtain the lOs complement of aBCD numberwe first take the 9s complement then add 1 to the least significant digit The 9s Complement is calculated from the subtracloo of each digit from 9

The prltXeduresdevelope4 for the signed-2s-complement system in the ~vious also apply to the signed-IOs-complement system for decimal mimberS Addition is done summing all digits including the sign digit and discafding the end carry This operatiQ assumes that all negative numbers are in 10s-complement form COOsider the (+375) + (-240) == + 135 done inthe signed-complement system

o 375

+9 760middot

o 135

lhe 9in the leftmost pOsition of the second n~ber tepresents a minllS and 9760 is the complement o( 0240 The two numbers are added and tbe end carry is discarded to +13SOfcourse the decimal ntmlbers insi~ tile computer includingthe sign digits in BCD The addition isdone with BCDOigits as described previously

Sectionl 7 Binary Codes 21

The suQtr8ction of decimalliUJ1lbets either unsigned or in thesi~-~Oscomplement systetn is the sameu in the binary case Taketbe 10s ootnplementof the subtrahend and add i~ to themin~nd ManyooDlputerslULvespeciaJ hardware to perform arithmeticcalculations directly withdecilnal oumbers in 8tDThe~u$etofthecoBlPuter can specify programliled Wtnlctionsto JOdonn the aDtiuJletiP oPmwoowithdeQmal n1UQ~ ~ywithout having to convell them to binary

Binafy codes for decimal digits requirea minimum of four bits per digit Many different codes can be formulated by~gjng four bits into IQ distinct combinations BP) and three other representative codes are shown in Table L5 Each code uses only 10 out ofa pOssible middot16 bit combinations that can be arranged with four bits The other six Unused cOmbinations have no meaning amt should be avoided BCD and the 2421 code are examplesofweigbted codes In a weigbtedcodeeach bit position

juBsigned a weighting f~in~awaythat eaehdigitcanbe ev~by 8dding the wei~ oran the lsin thecoded combination The BCD code has weights of8 42 and I which cotteshy

spondiothe powe1Of-two valuesofeaCh bitTbebitasSignmeatOll0 for example is interpreted by the weights to represent dedma16beCause 8 X 0 +4xt +2 Xl +IX 0 6Thebit combination 1101 when weighted by the ~ve digits 2421 gives themiddotdeCimal equivalent of 2 X I +4 gtlt I + 2 KO + 1 X 1 = 7 Note that some digits cantle coded in lw9 possib)e

ways in the 2421Q)(feFOr inke decimal 4 can be asSigned to bitCombinadon 0100 or 1010 since botbcOmbinatibns add upto a totalweight of4

middot1$ Fou Dlf(et Blnqry Code$ for thtJledmol DIgits

~ IICD DIgIt sal MZt Exeet) 8 4 -~1

0 1

000() middotmiddotmiddot0000 001)1 0001

oem 0100

0000 0111

2 0010 0010 0101 0110 3 0011 OQU 0110 0101

4 0100 0100 0111 oroo 5 0101 lOll 1000 1011 6 OlIO middot1100 1001 1010 7 middot0111 1101 1010 J001 8 1000 IUOmiddot 1011 1000 9 1001 11U 1100 1111

1010 oloi 0000 0001 Uaused IOU 0110 middotOOOl 0010 bit 1100 0111 0010 0011 combishynations

nOl 1110

lOW 1001

HOI 1110

1100 1101

1111 IOU) 1111 1110

22 ChaptfrliDfgltalSystemsaod Btoary Numbers

I1te 2421 rind the

e~l3~es are exampks Of self-complementing codes Such codes have~propertyjbatthe9s~plement ofa deCimal nfunberigobtairted directly by chang-

ing 1$ to O~$ finO tYSCfb1 sie~bycomple~mmgeaCh bit in the pattem)For example decshyimat3~Sis re~ fu tbeexcess3code as 01101100 1000 The 9s compl~ntof 604 isrepRse~l00liOOllelliwbich isobiainc(himply by complementing each bit of the

code (as with the 1 s coinpl~ofbin~rillDlbers)middot Theexcess~3code has been used in some oldel coritputers because of its selfcpmplement~

ing property Excess-3 is an unweighted code inwhich each codedcombinationis obtained-fJQm the corresPonQing bin3ryvalueplus 3 Note that the BCD code is1~ self-complementing TheS 4 ~~ Icode isan example of assigning both positive and negative weights to ~ decimalcodeInthis case the bit combiDation 0110isin~reted as oecimal2 and is calcu-

latedfrom8XO+4X 1 + (2) X 1 + (1XO=2 ~

Cra Code _ _ J

l1te output data QfmaJlfpbYsicaimiddot $)ShmlS are quantities that are continuous These data bemiddottonverted~digiWforuitJefore they art applied toaliigital system Contfuuous or ~nisCOIl~middotUitodigitalfonn bymeans of an rumlog~digitalConverter It is times ~~ent tousethe Gray code slown inTable 16torepresehtdigiuU data that have oon~ fMn8D8l08 dasaTheadvantage of th( Gray cOOeover thesllaigbt binary nIl11l1hPt~

~lt~thatoWY~ hit in the codegroup changeSin going from one number to the For examplcentbullin-goingfrom 1 to 8dleGray code cblngesfrom 0100 to 1100Only the fust changesfromOto l~the odter~ I)its mnaintbesame By contrast With binary numbers change from 7 to 8wrube from 0111 to lOOOwhich causes allfciur bits to change valUes

TabielAi GtPyCode

01 Decl COde Equivalent

~ 0000 0001 0011 OOlG 011Q Olll OlO 0100 1100 11m 1111 1110 lOlQ 1011

lOOt i

1000

o 1 ~ 3

4 5 6 7 8 9

10 11

12 13 14 15

SectIOnl7 BlnarYCod~s 23

The Gray code is used in applications in which the normal sequenceOrbiruuy rium~may produce an error orambiguitymiddot during themiddot transitionfrom ODeDWDber to the next If binary numbersareusec1 acbange forexaJIlple nom 0111 to 1000 may produce anintermediateershyroneous number 1001 if the value ofthe rigbtmost bit takes longer to -change than domiddotthe valshyues of the other three bits The Graycode elimb1ates this problem since only one bit changes its valve dUrlng aily transition be~een two numbers I

Atypical appli-cation ofmiddotthe Gray code is the representation of analog data by a Continu ous change in the angUlar position of a shaft The sQaftmiddot is partitioned into segments ana each segment is assigned a number If adJacent segments are made to correspond with the Qray-Codesequence ambiguity is eliminated between the angle of thesbaft and the value encoded by the sensor

Character Code

Many applications of digital computers require the handling not only ofnumberS but also of other characterS or symbols such as the letters of the alphabet For mstancean insurance comshypany with thousands of policyholders will use a computeX to process its files To represent the names and other pertinent information it is necessary to fonnulate bull binary code for the letshyters ofthe alphabet In additiQt1 the same binary qode must represent numerals and special Characters (such as $) An a1phanumeric character setis a set ofeiements that inclUdes the 10 decimal digits the 26leuersofthealp1iabe and a nutnbeof special~S~ a set conshytains between 36~d 64 elements ifonIy capital letters areincltided or between 64 and 128 e1eJDents ifboth uppercasemiddot and lowercllle etters are inclUded In the first case we need a bi- nary code ofsix bits and in the second we need a binary cooeO(seVM bits

The standaM binary code for the alphanumeric char8cters is the American Stahdard Code for Information InterCbange (A~n) which uses seven bitS to code 128 characters asshoWn in Table 17 The seven bitsof the code are desipted by b~through h With h the mostsigshynificant bit ~e leUer A for example is represented inASCn as l(l()()()Ol (column l00~tOw 0001) The Ascn ()()de also contains 94 graphic characters that can be printed and 34 nonshyprinting characters used for variQUS control functions The graphic characters consist of the 26 uppercase letters (A through Z) the 26 lowercase letters (a through z) the 10 numerals (0 through 9) and 32 special printable characters suchaS andS

The 34 control characters are designated in the ASCTItable With abbreviated nalne8 They are listed again below the table with their functional names The control characters are used fQr routing data and arranging the printed text into a prescribed format~ There are three types of control characters format effectors information separatOrs andcommumc~on-COnlrpl char~ IlCters Format effectors are characters that control the layout ofprinting They inciude the fashymiliar word pr6cessorand typewriter controlssucb 8$ bac~pace (BS) horizontal tabulation (HT) and carriage return (CR) Information separators are used to separatetbe data into divi~ sions such as paragraphs and pages Theyinclude characters such as ~ordseparator (RS)and file separator (FS)The cODlIDunication-control characters are uSefulduriDgthe transmission of text between remote tenninals EXllll1plesof conlmunicatiOn(ODtiol~ are STX (start oftext)-and ETX (end of text) whicb are used toframe a text mesaagetnQlSlnitted through telephone wires

24 Chap~er 1 Diglt8l Systems and Binary Numbers

rblel7 Amerkcm5tandard Code for Information (nterclHlnge(ASCII)

b~jbzb 000 001 010 on 100 101 no 111

0000 NUL )jLP SP () p P 0001 SOH OC1 1 A Q a q

R0010 STX OC2 2 B b r 0011 ETX DC3 3 C S Ii S

0100 EDT 0C4 $ 4 D~ T d t 0101 ENQ NAK 5 E iU e u OUO ACK SYN amp 6 F V f v 0111 BEL ETB 7 0 W g w 1000 B8 CAN ( S H K h x 1001 HT EM ) 9 I Y Y 1010 LF SU~ 1 Z j z lOll VT ESC + 1lt r k UOO FF PS lt L I I 1101 Cit OS == - M 1 m 1110 SO R~ N 1 n shy

-0PIt st US f 1 0 0 DEL

r- Control characten

NUL NlI]l DlE Data-inkescape SOH Start of hea~ng DC1 Device cOntroll STX Start of text DC2 DevIce io~1lOi2 ETX End (Jftext i DC3 Device corUlri1 3 OOT End oftraIlsmission ~4 DeVicecoQtrol4

ENQ ampqwry NAK Negativeackilowledge ACK

Acknowledge SVN Sync~nous idle

Btl Bell ETB End-of-tmnsnussionblOck sS Backspace CAN CanCel HT Horizontal tab EM End of mediUrlt LF Lintifeed SUB Substitute VT Vertical tab ESC escape FF form feed FS File separator CR Carriigeretum GS Group separator SO shift Ollt RS Reoord sepuator SI Shlftin US Unit separator SF S~e DEL Delete

ASCII is a seven-bit codebutrnostcompUters manipulate anejght-bit quantity asa unit called a byte Therefore ASCII characters most often are stored ~e per byte The

I biti~sometimesused forotlef purposes depending ontheapplicatio~lFor example printetS recognize eightmiddotbit AScn chaiacterS with themost sigoificaot bit ~twO An atkJlitlo

Section 18 Binary Storage and Registers 2S

128 eight-bit characters with the most significant bit set tol are used for other symbols such as the Greek alpbabet or italic tyIe font

Error-Dtectlng Code

To detect errors in data communication and processing aneigbth bit is sometimes added to the ASCll cbaracter to indicate its Panty Aparitybit is an extra hit included with a message to make the total num~ of ls either even or odd Consider the fo119wing two cbaracters and their even andodd parity

With even parity With odd parity Ascn A = 1000061 01000001 11000001 ASCI( T == 101deg100 11010100 01010100

1

- Ineacb casewe insert an extra bit in the leftmost position of the code to produce an even number of 1 s intQe cbaraeter for even parity or an odd number of 1 s in the character for odd parity In generlll one or tbe oth~r parity i~ adopted with even parity being more common

The parity biqsbelpful in detecting errors during the transmission ofinformation from one location to another nisfuJictiOD is bandIed by generating an even parity bit at the sending end for ~h character The eight-bit characters that include parity bits are transmitted to their desshytination The parity ofeachebaracter is thetichecked at the receiving~nd If the parity of the received cbaracter is Dot even then at1east on~bit has changed value dUring the trmlsmission This method detects one three or any odd combination of errors in each character tb8t is transshymitted An even combination oferrors however goes undetected and additioDaterror detic- shytion codes may be needed to take care of that possibility

What is done after an errQlis detected depends on the partieu~ application One possishybilityis to request retransrois~ion of the message on the assump~on that tbeenigtr was ranshyd()m andwill not occur again Thus if thereeeiverdetects a parityerrorit sends bai~ the ASCII NAK (negative acknowledge) control cnaracter consisting ofail even-parity eight bits lOOlOl01H no error is detectedthe ~iversends back anACK (aCkno~ledge) conshytrol character namely 0000011 O The sending end will respond middotto an NAK by tranSmitting the message again until the correct panty is received Ifmiddot after a number of attempts the transmission is still in error a message can be sent to the Operatai to check for malfunctions in the transmission path

BINARY STORAGE ANORECiISTEIlS

The binary infonnation inadigitalcomputermust have a physical e~stencein some medium for storing individual bits A binary cell is a device that possesses two stable sttes and is cashypable of storing pne bit (0 or 1) oflnfotlllation The input to tbe cell receives exciJation sigshynals that set it to one of the two states The output of the cell isa pbysicalquantity that distinguishes between the two states The irtformationstored in Ii cell is 1when the cell is in one stable state and degwhen the Cell is in the other stable state

26middot Chapter 1 Digital Systems and BtnaryNumbers

Registers

A register is a group of binary cells A register with n cells can store any discrete quantity of middot information thatcontains n bits The state ofa registeris an n-tuple ofls middotand Os with each bit designating the state of one cell in the register The C()ntent ofaregister is a function of the int~rpretation given to tbeinformation stored in it Consider fQf ex~ple a 16-bitregister with the following binary content

11 00001111001001

middot Aregjs~ with 16 cells can be in one of 216 possible statesIf one asstimesthat the content cif the register represents a binaryinteger then the register can store any binarydumber from Oto 216 - 1 For the patticularexample shown the content ofthe register is the binary equivshyalent(lftbe decimal number 50121 If one assumes instead that the register stores alpbanushy

middot meric characters of an eight-bit cooe then the content of the register is any two meaningful characters For tht ASCII code with anevenplirityplaced in the eighth most significant bit position the register contains thetwo charactersC (the lefunosteightbits) and I (the rigbt~ most eight bits) If however one in~rprets the content of the register to be four decimal dig- its represented by a four-bitcode tnenthe content of the register is a four-digit decimal number In theexcess-3 code the register holqs the decimal nutriber 9096 The content of the registe~is meaningless in BCD becau~e the bit combinatiOn ltob is 110t assfgned to any decshyimal digit From this example it is clear that a register can store discrete elements of inforshymation and that the same bit configuration Inay beinterpreted dlffe(ently for different types of data

tmiddotmiddotReglsterTrail Adigitalsystenlis characteriZed by its registers and the components thatpetfolin data proshy~ssingIIl digital sy~tems a rcentgister tra1lsfer operation is abasi operation that consists of

middot a transftr of hiJWy hUormation from one ~t of registers into ano$er set of registers transfer may be dir~ctfr9m one regist~r toanlt)ther or may pass througb datamiddotprocessing circuits to petformaD operation Figure L 1 illustratel the transfer of iidOrnuttion among regshyisters anddemonstratespictorlallY [the tr8ll~~ ofbinaryinformation from akeyboard a register in the memQryullit Thehlputunit~s assumed to have a keyboard1 control cuit and aninput register Each time a key is strock the control circuit enters an ImnV$_

lent eight-bit alphanumeric character coqe into the input register We shall assume that code used is the ASCII code with an odd-parity bit The information from the input regisshyter is transferred into the eight-least significant cells Qf a proeessOr register After transfer theinpui register is cleared to enable the control to insert a new eight-bit when the keyboard is struck again Each eight-bit character transferred to the pro1c4ess(raquo register is preceded by a shift of the previous character to the next eight cens on its left~

middot a transfer -of four characters is completed the processor registeris full and its contents transferred into a memory register The content stored in die memOry register shown in Figl came from the transfer of the characters J 0 H an~ N aftet the four ap)lroJ)riatt keys were struck

Section 18 Binary Storage and Registers 27

FIGURE 11 Transfer of information among registers

To process discrete quantities of infoiniatiori in binary form a computer m~st be promiddot vided with devices that hold the (lata to be processed and with circuit elements that manipmiddot ulate individual bits of irifonnation The device most commonly used for holding data is a register Binary variables~ manipulated by means of digital logic circuits Figure 12 il~ luslrates the process of adding two l()bit binary iUlmbers Themeniory unit which no[shy

mally consists of millions of registers is shown with only three ofits registers Thepait of the processor unit showncoDsistsmiddotofthree registers-RI R2 and R3~getherwith digital logic circuits that manipulate the bits of RI and R2 and transfer into R3 a binary number equal to their arithmetic sum Memory registers store information and are incapable of pr0shy

cessing the two operands However th~ information stored in meDij)iybanbetransferred to ~ processor registers and the resUlts obtainedin processor tegisters can be transferred back into ame~ry register for storage Untill)ecded again The diagram ~wsthe90ntents of two

operands transferred from twoJDemoryregisters into RI imd R2 The digital logic circuits produce the sum which is transfened to register R3 The contents of R3 can now be 1riUlsshyferredback to one of thetnemory registers

The last two examples demonstrated the infonncion-flow capabilitieSofa digital system in a simple manner Themiddot registets of the ~ystem are the basic ele~ents for Noring and holding the binary information~igitallogic circuits process the binary ihfonaation stored in the

28 Chapter 1 DigIt bullbull Systems and Binary Numbers

Sum

FIGURE 12 Eumple of blnarylnfonn~t1on processing

registers Digitallogiccirctiits and registers are covered InChQpteB 2 throQgh 6 The metlilOlY unit is ~xPIained ill 9aptet 7 Th~ descriptton of register opetJtions at the register level and the design of digital systems are covexed in Chapter 8

19 BINARY LOGIC

Binary logic deals with variables th~ take on two discrete valueund withoperations that sumelogicalmeaning~ The two val~s the variableussume may be called~ydifferent (true andalse yel and no etc) but for ourp1llpQSe it is cpqVenienttotbink in terms of and assign the values llUld O The binary logic intr0ducedin this section is equivalent to algebra oalledBoolean algebra The fannal presentation ofBoolean algebra is covered in detail in Chapter 2 The purpose ofthis seCtion is to introduce Boo algebra ina matmerandlate it to digitallogiccircuits andmiddotbinarYsignalsmiddot

Section 19 Sinary logic 29 ~

Itkltn of IInary logic

Binarylogic consists of binary v~les and a set of logica1middotoperatiQDS The variables are desigshy ~by lettell of thCalplWlet~such asA B C x yz etc with eaCh variable baving two and oniy

two distinct posSible valueS 1and O There are three basic logical operations AND ORand NOT

1 AN]) This ~peration is represented by adotorby the absence ~f an oPerator For example x bull y =z or xy = zis~ x ANDy is equalto z~ThelogicaloperationAND is interpreted to mean that z == 1 ifand only ift~ land y = 1 otherwise z = O (Reme~r that x y andzare binary v8riablesand canmiddotbe equal either to 1 or Omiddotand nothing eise)middot

2 OR This operation IS represented by a plus sign For example x + y =z is read x OR y is equal to z meaning that z 1 if x = iorif y = lorifbothx= 1 and y = 1 If bqth X - 0 andY Omeo z= O

3bull NOT This operation is repf6sented by a prime (sometimes by an overbar) For ~xample x =Z (or~ =z) is read notdsequalto 1 meiming that z iswkatx isnot In other

words ifx = 1 then z == 0 but if x == 0 tnenz = L TheNOT operationisals(1 reshyferred tolls the complement operation since it changes ~ 1 toOand a O to 1

bull bull lt Binary logic resembles binary arithmetic and themiddot9peratioos ANDahd OR have similarishy

ties to multiplication and addition respectively In fac~ the symbols used for AND and OR are the same as those used for multiplication and addition However binary lOgic should not be conshyfused withbinaryarithIrietic One should realize thatan arithmetic variable designates a numshyber that may consist of many digits A logicmiddot variable is always either 1 or O For example in binary arithmetic we have I +1 =10(read~one plus ()fie is equal to 2) whereas in binary logicwe have 1 + 1 1 (read one OR onds equal to one)

For each combination of the values oix and y bullthere isa value of ~ $pecifiedby the definishytion of the logical operation D~linitiops of logical~perations maybe listed in a compacHorm called truth tables A truth table is atable of anpbssible combinations ofthe variables $howshying the relation between the values that the variables may take and the resultof the operation The truth tables for th~ operations ANDand OR with variables x and y are obtained by lis~ng

all possible values that the variables may have when combined in pairs bull For each combination the resUlt of die operation 18 theillistedin a separate row The truth tables for ANDORand

NOT are given in Table La These tables clearly demonstrate the definitionf the operatibns

Table 18 Truth TcibJts of Logical Operations

AND OR NOT

x y xmiddoty x y x+y

0 0 0 0 0 0 1 0 0 1

10

1 0 d 1 0 1 I 1 1 1 1 1

bull~lt~m

30 Chapter 1

Logk Gates

Digital Systems and Binary Numbers

Logic gates are electronic cirellit that operate on ~

variable

or mpre mput tignals to produce an output signal Electrical signals sUch as voltages orrutrents exist as analog signals having values over a given taDgebull saYOt03 V but in a digital system are interpreted to be either of two recognizable values 0 or 1 Voltage~opetated logic Circuits respond to two separate voltshyage levels that represent a binary varjable equal to logic I bt logic O For example a partic- ular digital system may define 10gicOas a signal equal to 0 volts lind logic 1 asa signal equal to 3 volts In practice each voltage levelhiS an acceptable rangeas shown in Fig 13

The input te~nals of digital cikuits accePt binary signals within the allowable range and respond at the output terininals with binary signals that fall within the specified range The intermediate region between the aJl()wed regions is crossed only during aState transition Any desired information for computing or control can be operated tm by passing binary signals through variQUS combinatioDsof logic gates with each signal represebting a particular binary

The graphic symbols used to deSignate themiddotthree types of gates are Mown in Fig 14 The

gates are blocks of hardware that prooocc tbeequivalent of1ogic~1 orlogic() output signals

Volts

- FGURl13

x

y

Exampleof binary slgnaJs

Signal ratlge for logieO

(a)~omiddotinput AND gate

FIGURE 14 SymbOls for digital logic circuits

(c)NOT gate or invert~

Problems 31

x-lU 1 11 P 0

y 0 0 11 1 ~

ANDxy 0 0 rTl 00

ORX+Y~ NOT x 11 0 0 I 1 1

FIGURE 15 Input-output 5Igals for gates

FIGURE 1

A B C

Gates WIth mlltlple JnpUU

A B C lJ

~

if inPllt logic ~ts are satisfied Theinput signals xaDd y intheNDaadQR gates may exist in ~ oHow-possible states 00 10 11 or 01 Il1ese ibpu~ampignals_ shown inFig lStoshygetber with the corresponding output signal foreach PfCThI~tiaiug~iDustrate the reshysponse ofeaclt gate to the four input signal~The~llisofthetiminadiagram represents time and the vertical axis sbo~~~~ it cbapg~botwcen~possible voltshy

age levels The low level represents logic O tJte high level l1lteAND _ responds With a logic ~ ~tput sipl wh~ both input ~~)e 1middot1~ lIieOR S-~with a logic 1 outpUt signal ifanylnput sigrudis lOgic 1 TheNOTgateis~~ to BUll invedet The reason for~nameis~t froJn the signalmsponae inmiddottbe timitt8 diagramwhicbsbows that theoUtputsignal inverts the logic sense of tbeiDpUtsigll8l

AND and OR gates may bavei)lQte tbantwQinputs M AND8_~itti ~input$andan OR gate with foU) inputs are shown in Fig 16 The three-inPllt AND gate responds With logic 1 output if all tbreeinputs arelogic 11jleoutputproduces lOgic Oifanymput is logic O-The

four-input OR gate responds withlogic 1 ifany input is logic 1 its clu1ptltllCCoines logic oonly when all inputs are logic O

Answers to prvblems marked with middotappearaHbe ClOd ofthe ~

11 lJltthe octal and beXadecimalliurilbers trom16ui 32UdngA B1l1ld C forthebst~ digits Usttbe numbers from 8 to 28 in base13 bull

I

12t What is the exact D1Jllbcr of bytes in a system that contains lta) 32Kbytoe (b)64M ~and (e) 640 byte$ middot7 t

32 Chapter 1 Digital Systemsand Binary Numbers

13 Convert the following nu~bers with the indicated bases to decimal (a) (4310)s (b) (198hz (c) (735)8 (d) (525)6

14 Whllt is the largest binary number that can be expressed with 14 bits WhlIt are the equivaleDt ~~ iinal and hexadecimal numbei-s

--

15 Detemrine the base of thl1 numbers in each case for the following operatio~ to be correct (a) 142 = 5 (b) 5414 = 13 (C) 24+ 17 == 40

16 The solution$to the q~cequation xl - Ux +22 oare l1 3 arid x =6 What is the base of the numbers

17 Convertthehexadecimal ntmIher 68BE to bitiary and then convert it ~mbinary to octal

18 I Convert the decirpal number 431 to binary in tWo ways (a) Convertd~y to binary (b) conshyvert first to hexadecinla1 and then from ~decimalwbinary Which method is faster

19 amppress the following nqrnbersin decinud (a) IQ11O0101)z (b) (l65his (c)(2624)8 (d) (FAFA) 16

(e) (10101010)2

110 Convert the following binary numbers tobexadeoimal and todecitnal (a) UOOlO (b) 110010 Explain why the deCimal answer in (b)is 4 times that in (a)

111 Perform the followingdiviskmin binary 11 Ion + l()t

112 Add IlniImultiply tfle following numberswiihout converting them to decimal (a) Binary nuniberilOll aiIdlOh (b) He~uumbers 2E aDd 34

1~)( Do thefoHowing con~ersionproblems (a) CorivertCiecimal2731S to binary (b) CakUlate the binary eqUivalent (f 213 outto eight pl~Then Convert from binary to

imalHowgJose istbe result to 2131 (c) Convert the binary resukin (b) into hexad~ lb~oonvert ~result to decimal Is answer tbesame

114 Obtain the is 8nd 2s complementsofthe foUowing binaryDumbcentrs (aj l)()()(J()OO (b) OOOOOOOO (c) 11011010 (d)01l10110 (e) 10000101 (0 11111111

115 Find the 9s and the 10s complement of the following detimal numbers (a) 52734630 (b) 63325600 (c) 25000009 (d) 00000000

116 (a) Find the 16s complement of B2FA (b) Convert B2FA to binary (c) Find the 2scomplement ofthe resultin (b) (d) Convert the answer in (c)to hex~malandco~ with ihe an~wer in (a)

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 13: Chapter 01 - Mano

- -

Section 15Complements 13

(a) x = 1010100

2s complement ofY= + -0111101

Sum = middot 10010001 Discard end carry 27 = 10000000

Answ~ X- Y = 0010001

(b) Y == 1000011 2sco~lement of X = + 0101100

Sum= 1101111

There is nQmiddotend carry Therefore the answer is Y ~X= -(2sq)mplement of 1101111) = -0010001 Subtractionof unsigned D1lJllbers ~ also bed()neby means of the (r - 1)s complement Remember that the(r- l)s complement is one lesstharithers complement BeCause of

ibis the result of adding the minue~ to tJte coQlplement of the subtiah~ndPtOductS itsum that is one less than the correct 4ifference when an end carrY oCcurs Removing the end carry and adding 1 to the sum is referred to asan end-around carry

Repeat Example 17 but this time using rs complement

(8) X y = 1010100 - 1000011middot

X= 1010100

rs complementafY= + olfnoo Som = 10010000

End-arOundmiddot~ =- ~ ~ Answermiddot X Y= middot0010001

(b) Y - X = 1000011 - 1010100

Y = 1000011

1s complement ofX = +0101011

Sum = 1101110

There is no end carry TherefOre the answer is y - X = -(1s complement of 1101110) = -0010001

bull Note that the negative resultis ob~ by taltingtbe 1 scomplemeilt of theJWltsince this is the type ofcoDiplementused The procedwewithendaroundoanyis aIs(gt Iijlpliclbleto subshytracting Unsigned deciImdnumQers with 9seomPlement

14 Chapter 1 Digital Systemsand BinayNumbers

16 SIGNED BINARYNUMBER$ ~

Positiveintegers (including zero) CaBbe ep~~ 11$ unstPecl numbers However to repshyresent negative integers we need a notation for negative srn ordinary arithmetic a negshyative number is indicated by a mulUs signmdapOsitiv~Pwtlt)e~ by aplus sign Because of lJardware limitations computers mlstrepresenlev~With~ digitsIt is customary to represent the sign witb a bit placed intheleftmotp6sitiolwfthe number The convention is tltl make the sign bit 0 for positive and 1 for negative

Itis important to realize that botp siped and unsignedtDnary 11UJDbers consist of a strfug of bits when represented in a com~ TQeuser detem1inesWbether the number is signed or unsigned If the binary number is signed then the lefuriostbitreple$ellts thtsign aud the rest of the bits represent the number Ifthebinaryllu~beiis~ tObe unsigned then the left most bit is the most significant bit of the l)uMber Fdre~the~~f bits 01001 can be consideredas 9 (unsigned binary) or as +9 (Sighedbitia1j) ~USJtheteftmostbit is O The

string ofbits 11001 represents the binary ~~v~ento~ ~w~nc~idered as an unsigned number and the binary equivalent of 9whenconsidered1l si~riumPer This is because the Ithal isintbe leftmost positiondesignatesampC nega6ye_~QtherfourJ)its represent bishynary 9 usually tlere is no cotifusionin identifying thebits~the~Qfrepresentation for the number is known in advance ~

The representation of the signed numbers in the lastexainple is referred to as the signed magnitutk coDvention In this ~otati()nthenurnber C4mSiampesOCa mQ~~andil~ymbolH

or -) or a bit (0 or 1) indicating the sign This is the representation ampr~~used in ordinary arithmetic When arithmeti~ operatioBslllieimplerneJltcldin~cOQlPuter hii more convenient to use a different systemrefetred t(gt as the si~cqmptement system~ for repre- senting negative numbers In thissystlm a neg8tielliun~r isjhdic~ted by its cornplc~mc~nt Whereas the signed-magnitude system negates a nlllllher by cbanging its sign me signed-comshyplement system negatesanwnber bytakin$ its~OinPleltleitiSinoepositife numbers always start witbO(plusin tte leftmost pOsition thecompktllint wiilalwaysstart with a 1 indicating a negative number The siped-complemelt system can use olthertbe 1s Or the 2s but the 2s complement is the mos~comtliOfi

As an exampleconsider the number9re~~ed in binary with eight bits + 9 Is sented with a sign bit of Oin the leftri1ostpOsition oIIOv~by the binary (equivalent of 9 which gives ()()()olOOl Note thai all eigbtbits must haYampa v~therefore O~s are inserted folshylowing the sign bitllp to the first 1 Although ~ is only 01K way to tepresent +9 there three different ways to represent 9 with eight ~its

s~gned~magnituderepresentation 10001001

sigried-l s-complement represe~on~ 11110110

signed-2 s-complemerit representatim 1ttltllU

In signedmagnituamp -9 isobwned from +9 by changing the sign bitmtbe leftmost ~iti(ln tromO to L In sigl1ed~ lroomplement 9isobtaidedtf~~tiog all the bits of includinj the sign bit Thesigned-2~sco~re~Qf-9 is obtampDedby ihe 2s complement oftbepOsitivenumberincludingtbesijnbIt

Sectlont6 SIgned8lnary NumberS is

Table 13 Slgtlfd Biliary Humbm

+7 +6

+5 +4 +3 +2 +l +0 0 -I

-2 -3

4 -5 -6 -1 -8

Olll 0110

0101 ( 0100

001l 0010 0001 0000

IIll 1110

nOI noo Ion 1010

1001 1000

OIll Oito eHOl OHIO OOU 0010 0001 0000 1111 1110middot dOl 1100 Ion

lOti 1001 1000

0111 OUO 0101

0100 0011 0010 0001 0000 1000 1001 1010 IOU 1100

1101 1110

lUI

Table 13 lists all possible four-bitsignedbinaryaumbers in the three representations The equivalent decimal number Is also shown for refelenoeNote that the positive n~ in all three representations are identicaland have 0 inthelefmostpcsiticm The signed2sshycompl~mentsystemhaironly onemiddotrepresentation for 0 which is always po$itive The other tw()systetns- mlve either a positive 0 or a negative 0 sometbingnoteDcounteredin ordinary arithmetic Note that all negative numbenhave alin the leftmost bitpositi~ that is the way we distinguish them from the positivenumbers With fout bits we can repreSent 16 binary numbers In the signed-magnitude aDd thelscomplement repre$eDtatipns there are eight positive numbers and eight negative numbers inciUdingtwo zeros In the2s-complement representation there are eight positive numbers includi0a one zerQ and eight negative numberS

The siped-m_gnitude system is used in ordiIlary arithmetic but is awkward when emshyployed in computer arithmetie becauIe of the ~parate bandIinJ bfthesipand the magnitude Therefore the signed-compiement systeni is normallyused The ls ~t imposes some difficulties and is seldom USedJor arithmetic openitiOns It is U$eful aSa lo~ operation since the change of 1 to Obrmiddot() to 1 is equivalent to a logical complement Operation as will be shown in the next c~The discussion~f sigiled binary ariduneti~ that fol10ws deals exshyclusively with the signe4-2soomplt_nt~tatJonQfnegadveilUlilbers hsame proshy

cedurescan beappJied to the sigMdrs-comPlemeD~Iysby incIudiOI tbe~arotmdcarry as is done with unsigned numbers

J6 Chapt~r 1 OlgltalSystlf(ns and Binary Numbels

Arithmetic Addition

The addition of two numbers in the signed-magnitudelYs_foUowsthe rules ofordinaiy arithshymetiC Ifthesi~s arethesam~we addthetwOtt~gni1U~~d ~vetbe sum the CCmmon sign Iftbe signs are diffe~nt we subtract tllcsmaUermagnitude frOtnlthe larF and give the differshyehtethe signof the larger magnitude For example (+25) +( - 37) = ~ (37 - 25) = -12 and is done by subtracung the smaller magnitude 25 from the larger magnitude 37and a~nding the sign of 37 tGtbe result Ibis is a process that requires a corripanson of the signs and magnitudes and then performing eithr additi()n or subtraction The same procedure applieato binary numbers in sigped-magnitude representation~Incontrast the rule for adding numbers in the signed-corppleme~ sy~tem does not require a comparison or su~ traction but only addjtion The procedure is very simple andcanbe stated as follows for binary numbers The 8ddltion oftwo signed binary numberS with negative numbers tepresented in signed- 2sComprement fonn is obtaiIled from theadditlooofthe two numbers includingtheii sign bits

AcentiirrY out oftbe sign-bitposition is diScacded NumerIcal e~aihpledotai1dition follow

+ 6 00000110 - 6 11UI0tO I

+13 00001101

+13 00001101 +19 00010011 + J 0Q900111 + 6 00000110 6 11111010 ~13 11110011 -1~l 11110011 7 illl1001 -19 11101101

I bull bull ~

Note that negative numbers musthil iriitially in 2seompkmentform and that if the swn ~ ~afterthladdit40nis negativeins in2s~p~t fOl1Jl - In each of thefoDrcasestlteoporationperfol1JlC(lis additionwitb the sign bit iilcluded Any catTY o~of~~-bit~onisdisc~ and negative resultsareButomaticallyin 2sshyromplementfoon

In order to obtain acOrrect answer we mustensQre that the result has a sufficient of bits to accommodate the swnlfwestartwith t~on-bltnumbers and tbeswn occupies n + 1bits we say tblltan overflow occurs~Wheri one perfotmStbc ad(JitiOJl with nllllIPTJllVIl

pencil aq overflow is not a preblem because we arcr noflimitecLbythewidth of the page jUst addanothcentr 0 to apositive number or another 1 toa negative number in the mOst cant positi()n to extend thenwnber to n+ 1 bitSand theQ perform addition Overflow is

problem in computers beqiusetbe number ofbi~~ bolla ~befis finite and a result ex~ tI1efinite val~e hy lcatmotbe accommodated

The compJement form of representiQg negativetlQUlbers is unfamiliar to those usedto signed-magnitude system To itetermine th~ value of II negatienumber insiped-2s COlIlpJe

mentit0is~ to CODVerttbe numbcr to apositie ntirit_ ~ place itiDa more formPor ~plethesig~binary number qUl00~ lii~egativebecausothe leftmost

t 1182s c0J8plemen~js~UlwhUhi$~ binaryeqqivalen of +7Wcmiddottherefore nize the Ori~nal ~atiy-eQumber to be equ~ lo-7 1

Sectlonl7 Bh1ary Codes 17

ArIthmetic SubtractIOn

Subtraction of two signed binafy numbers whe~negative numbersare in2s-complement form is simple and can be stilted as follows

Take the 2s complement of the5ubtraltend (including the sign bit) and add it to the minuend (including the sign bit) A cany oU1of thesignbit position is discarded

This prOCedure is adopted because a subtraction operation can be changed to an addition operation if the sign of the subtrahend is changed as is demonstrated by the following relationship

(plusmnA) ~ (-tB) = (plusmnA) + (-B) (plusmnA) - (-B) =plusmnA) + (+B)

But changing a positivetwober toa negative n~ber is eaampily done by taking the 2s compleshy mentof the pQsitive number The reverse is also tiUe~use theCOmPle~n~ of a negative numshyber in complement form produces the equivalent positive number To see this consider the sJlbtr~ction ( 76) -- (13) = +7 In binaIy_ with eight bits this ()peiationis written as (11111010 11110011) The subtracti~ri ischmlged ~ addition by taking the 2s complement ofthe subtrahend (-13) giving (+13) In binaly tbis~ 11 niOlO+ 00001101 = lOOOOOU1 Removing the end~ we obtain the ootrect answer ()()()()() III (+7)

Itisworth noting that binary DUmbersinthe signed-complement system are added and subshy tracted by the same basic addition and suPtraction rules as unsigned numbers Therefore comshyputersneed omy one common hardware circuit tobandle bothtypcs ofaritbtnetic The user or programmer ~ust interpret the reswtIi of $l1ch addition or subtraction differently depending on whether itisassumedtha~the numbe~ are signed ltr tinsigned

j

BINARY CODES

Digitalsystems use signalsthat have two distinct values1Uld circuit elements that havetwostashyble states There is a direct analogy anrong binary iignals binary circuitelements and binary digits A binary number ofndigitsfor example may be represented by n binary circuit eleshyments each baving an output sig~alequivalen1to Oor I Digital systems represent (Uld mashynipUlate not omy binary numbers but alsO many other diScrete elements of information Any discrete element of informatioIidlat is dis1iilct among agroup of quantities can be represented witha binary code (Le a pattern of Os and fmiddots) The codes must be in binary because in todays techIiology omy circuits that represent and manipulate patterns of 0s and ls can be manufactured economically foru~ in computers However it mtistbe realizCd that binary codes merely change the symbols not the meaning ofthe ele~nts of infonbationthat they repshyresent IT we inspect the bits of a computer at random we will find that mostofthe time they represent some tYPe of coded information rath~ than binlUY numbers

AIln-bit binary code is a groopofn hits that assumes up to 211 distinct cOmbinations of ls ~d Os with eacn combination representing one elementof tnt set that is being coded A set

of four elements clab becoded with two lilS with each ~lementassignedoneof thefoUowing bit oombinationsOOO I 10 J 1 A set of eight elements requiies a three-bit code 00 a set of

18 Chapter 1 Digital Systems and Binary Numbers

J6 elements requires a fourmiddotbit code The bit combination of ann~bit code is determined the count in binuy from 0 to 21t - t Each element must be assigned a unique binuy bit binationand no two elemerits cm havetbtsamevalueothenvisethe code assignment be ambigUous

Although the minimum nqrnber of 1lits required to code 21t distiItct quantities is nthere nomaximwn numbe( of bit that may he used for a binuy code For example the 10 digits can be coded with 10 bits and each decimal digit can be assigned a bit combination nine OSmid a 1 In this pamcularbinarycode the digit6 is assigned the bit )UllIUlauuu0001000000

BCDcode

Although the binary number systemis die ~ost natural system for a computer most people more accustomed to the d~imal system One way to resolve this difference is to convert

inlal nUmbers to binary perform all arithmetic calculations in binary and then convert the nary results back to decimal This metbodrequites that we store decimal numbers in

cOinputer so that they canbec6b~rted to binary Since the compllter Can accept only valueswe must represent the decimal digits by means ofa code that contains ls and Os also pOsSible lopedorm the arithmetic operlltiorisd1rectly on decimal numbers when they stored in the comput~ in cod~ct form

A binarycodewill have some unasSigned bit com~inatiqns ifthe num~rofelements in set is not amultiple power of 2 The 10decimai digits form such asel A biruuy code that tinguishes among 10 elements must coiltain at least four bits but 6otitofthe 16 possible binations remain unassigned Different binary code$ can bemiddotoNained by arranging four into 10 distinct combin~tions TheicodeIllcfflt oommonly used fdr the decimal digits is straight binary assf~ntlisted in Table 14 This scheil)eis called bittary~coded decimal

is commoolyreferred to as BCQ OtherdecimalcodesaIlfpossible and a few of them are sentedlaterinthis section

Table 14 BinarymiddotCoded Oeclmql (BCO)

Decimal BCD SnlboiDIgIt

o 0000 1 0001 2 0010

3 0011 4 middot0100 5 0101 6 0110 7 0111 8 1000 9 1001

Sectionmiddot 17 BInary COdes 19

Table 14 givesthe four-bit code for one decimal digit A number with k decimal digits will require 4k bits in BCD Decimal 396 is represented in BCD with 12 bits as 0011 10010110 with each group of 4 bits representing one decimal digit A decimalmiddotnumber in BCD is the

- same as itS equiyalent binary number only when the number is between 0 and 9 A BCD numshyber greater than lOJpoks different from its equivalentbinary number even though both con tainls and Os Moreover the binary Combinations 1010 thrpugh 1111 are not used arid have no meaning in BCD Consider decimal 18SlUld its corresponding value inBCD and bUtary

(185ho = (0001100001Ol)BCD = (l0111001h

The BCD value has 12 bits to encode the characters of the decimal value but the equivalent binary number needs only 8 bits It is obvious thatthe representation of a BCp number needs more bits than its equivalent binary value However there is an advantage in the use ofdecishymal numbers because compUterinput and output data are generated by people who use the decshyimal system

It is important to realize that BCD numbers are deCimal numbers and not binary numbers although they use bits in tbeir representation The only difference between a decimal number and BCD is that decimals are written with the symbOls 0 1 2 9 and BCD numbers use tbebinarycode 00000001 001O~ bull 1001The decimal value is exaCtly the same Dec~mal 10 is represented in BCD witheight b~ts as 00010000 and decitna1J5as 0001 01Of1lte corshyresponding binaryvalues are 1010 and 1111 and have only four bits

Consider the addition of two decimal digits in BCD together with a po~ible carry from a pre- vious less significant pair ofdigitsSince each digit does not exceed 9 the sum cannot be bull greater than 9 + 9 + 1 = 19 with the 1 being a previous carrySllppose we add the BCD dig-

its as if they were binary numbers Then the binary sumvill produce It result in the range from degto 19 In bin8ry thistange wil[be from 0000 to 10011 butin BCD it is frOm 0000 to

I 1001 with the first (ie leftmost) 1 bemg a carry and the next fo~ bits being the BCD sum When tPe binary sum is equalto or less than 1001 (withaut 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 (0110h to the binary Sum cOnverts it to the correct digit and also produces a catTy as required This is because a carry in themost significant bitposishytion of the binary sum and a deCimal carry differ by 16 10 = 6 Consider the following three BCD additions

4 0100 4 0100 8 1000

+S +0101 +8 +1000 +9 1001 9 1001 12 1100 17 10001

+0110 +0110----

10010 10111

In each case the two BCD digits are added as if they were two binary numbers If the binary sum is greater than or equal to 1010 we add 0110 to obtain the correct BCD sum and a carry In the flIst example the sum is equal to 9 and is the correct BCD sum In the second example

20 Chapter 1 Digital Systems and BInary Numbers

the binary sum produces an iJlv~ BCD digit The addition of0110 produces the cortect BCD sum 0010 (ie the number 2) and acanyInthetbirdexample the binalY SUDlproduces acany This condition occurs wben the $W)) is greater than or equal to 16Altbough the other fout are less than 1091 the binary 9Ulll requires acOnectionbecause of die carry Adding 0110 obtain thetequiled BCD sum 0111 (ie the numblaquo 7) and 8 BCD CiUT

The additionoftwondigit unsipedBCD numbers follows the same procedure COIlSioll the addition of 184 + 576 1= 76() in BCD

BCD 1 I 0001 10000100 184

+6101 ~

0111--- 0110 +576

lJinarysum 0111 10000 1010 Add6 ono 0110

BCDsun 0111 0110 0000 7(1)

The flfSt l~ sigDiticant pili- of BCD digits produces aBCDdigi~SllDlof 0000 and a for the next pair of digits the second parr or BCD digits plus a ~Vi0U8 cany produces a sum of 0110 and a carry for the next patr()fdigits The third pair of digits plus acarry proltIUC~ a binary s~ of 0111 and does not require a correction

Decimal Arithmetic The represeiltation of signed decimal numbers in BCD is simiiarto the tepresentation of numbers in binaryWe can useeitheI the familiar signed-magnitude system at the SllZllOO-COI1I

plemelit system The sign of a decimal number is tJSually represented with four bits to to thefour-bit code ofthe decimal digits Itis customary to designate 8 plus With four Os 8 minus with the llCDequivalent oi9 whlcq is 1001 The sigiled~magnitudesystem is seldom used in com~tersThe signed-complerDem ~~ either the 9s octhe 10s complement put the lOscomplement is the one most useP To obtain the lOs complement of aBCD numberwe first take the 9s complement then add 1 to the least significant digit The 9s Complement is calculated from the subtracloo of each digit from 9

The prltXeduresdevelope4 for the signed-2s-complement system in the ~vious also apply to the signed-IOs-complement system for decimal mimberS Addition is done summing all digits including the sign digit and discafding the end carry This operatiQ assumes that all negative numbers are in 10s-complement form COOsider the (+375) + (-240) == + 135 done inthe signed-complement system

o 375

+9 760middot

o 135

lhe 9in the leftmost pOsition of the second n~ber tepresents a minllS and 9760 is the complement o( 0240 The two numbers are added and tbe end carry is discarded to +13SOfcourse the decimal ntmlbers insi~ tile computer includingthe sign digits in BCD The addition isdone with BCDOigits as described previously

Sectionl 7 Binary Codes 21

The suQtr8ction of decimalliUJ1lbets either unsigned or in thesi~-~Oscomplement systetn is the sameu in the binary case Taketbe 10s ootnplementof the subtrahend and add i~ to themin~nd ManyooDlputerslULvespeciaJ hardware to perform arithmeticcalculations directly withdecilnal oumbers in 8tDThe~u$etofthecoBlPuter can specify programliled Wtnlctionsto JOdonn the aDtiuJletiP oPmwoowithdeQmal n1UQ~ ~ywithout having to convell them to binary

Binafy codes for decimal digits requirea minimum of four bits per digit Many different codes can be formulated by~gjng four bits into IQ distinct combinations BP) and three other representative codes are shown in Table L5 Each code uses only 10 out ofa pOssible middot16 bit combinations that can be arranged with four bits The other six Unused cOmbinations have no meaning amt should be avoided BCD and the 2421 code are examplesofweigbted codes In a weigbtedcodeeach bit position

juBsigned a weighting f~in~awaythat eaehdigitcanbe ev~by 8dding the wei~ oran the lsin thecoded combination The BCD code has weights of8 42 and I which cotteshy

spondiothe powe1Of-two valuesofeaCh bitTbebitasSignmeatOll0 for example is interpreted by the weights to represent dedma16beCause 8 X 0 +4xt +2 Xl +IX 0 6Thebit combination 1101 when weighted by the ~ve digits 2421 gives themiddotdeCimal equivalent of 2 X I +4 gtlt I + 2 KO + 1 X 1 = 7 Note that some digits cantle coded in lw9 possib)e

ways in the 2421Q)(feFOr inke decimal 4 can be asSigned to bitCombinadon 0100 or 1010 since botbcOmbinatibns add upto a totalweight of4

middot1$ Fou Dlf(et Blnqry Code$ for thtJledmol DIgits

~ IICD DIgIt sal MZt Exeet) 8 4 -~1

0 1

000() middotmiddotmiddot0000 001)1 0001

oem 0100

0000 0111

2 0010 0010 0101 0110 3 0011 OQU 0110 0101

4 0100 0100 0111 oroo 5 0101 lOll 1000 1011 6 OlIO middot1100 1001 1010 7 middot0111 1101 1010 J001 8 1000 IUOmiddot 1011 1000 9 1001 11U 1100 1111

1010 oloi 0000 0001 Uaused IOU 0110 middotOOOl 0010 bit 1100 0111 0010 0011 combishynations

nOl 1110

lOW 1001

HOI 1110

1100 1101

1111 IOU) 1111 1110

22 ChaptfrliDfgltalSystemsaod Btoary Numbers

I1te 2421 rind the

e~l3~es are exampks Of self-complementing codes Such codes have~propertyjbatthe9s~plement ofa deCimal nfunberigobtairted directly by chang-

ing 1$ to O~$ finO tYSCfb1 sie~bycomple~mmgeaCh bit in the pattem)For example decshyimat3~Sis re~ fu tbeexcess3code as 01101100 1000 The 9s compl~ntof 604 isrepRse~l00liOOllelliwbich isobiainc(himply by complementing each bit of the

code (as with the 1 s coinpl~ofbin~rillDlbers)middot Theexcess~3code has been used in some oldel coritputers because of its selfcpmplement~

ing property Excess-3 is an unweighted code inwhich each codedcombinationis obtained-fJQm the corresPonQing bin3ryvalueplus 3 Note that the BCD code is1~ self-complementing TheS 4 ~~ Icode isan example of assigning both positive and negative weights to ~ decimalcodeInthis case the bit combiDation 0110isin~reted as oecimal2 and is calcu-

latedfrom8XO+4X 1 + (2) X 1 + (1XO=2 ~

Cra Code _ _ J

l1te output data QfmaJlfpbYsicaimiddot $)ShmlS are quantities that are continuous These data bemiddottonverted~digiWforuitJefore they art applied toaliigital system Contfuuous or ~nisCOIl~middotUitodigitalfonn bymeans of an rumlog~digitalConverter It is times ~~ent tousethe Gray code slown inTable 16torepresehtdigiuU data that have oon~ fMn8D8l08 dasaTheadvantage of th( Gray cOOeover thesllaigbt binary nIl11l1hPt~

~lt~thatoWY~ hit in the codegroup changeSin going from one number to the For examplcentbullin-goingfrom 1 to 8dleGray code cblngesfrom 0100 to 1100Only the fust changesfromOto l~the odter~ I)its mnaintbesame By contrast With binary numbers change from 7 to 8wrube from 0111 to lOOOwhich causes allfciur bits to change valUes

TabielAi GtPyCode

01 Decl COde Equivalent

~ 0000 0001 0011 OOlG 011Q Olll OlO 0100 1100 11m 1111 1110 lOlQ 1011

lOOt i

1000

o 1 ~ 3

4 5 6 7 8 9

10 11

12 13 14 15

SectIOnl7 BlnarYCod~s 23

The Gray code is used in applications in which the normal sequenceOrbiruuy rium~may produce an error orambiguitymiddot during themiddot transitionfrom ODeDWDber to the next If binary numbersareusec1 acbange forexaJIlple nom 0111 to 1000 may produce anintermediateershyroneous number 1001 if the value ofthe rigbtmost bit takes longer to -change than domiddotthe valshyues of the other three bits The Graycode elimb1ates this problem since only one bit changes its valve dUrlng aily transition be~een two numbers I

Atypical appli-cation ofmiddotthe Gray code is the representation of analog data by a Continu ous change in the angUlar position of a shaft The sQaftmiddot is partitioned into segments ana each segment is assigned a number If adJacent segments are made to correspond with the Qray-Codesequence ambiguity is eliminated between the angle of thesbaft and the value encoded by the sensor

Character Code

Many applications of digital computers require the handling not only ofnumberS but also of other characterS or symbols such as the letters of the alphabet For mstancean insurance comshypany with thousands of policyholders will use a computeX to process its files To represent the names and other pertinent information it is necessary to fonnulate bull binary code for the letshyters ofthe alphabet In additiQt1 the same binary qode must represent numerals and special Characters (such as $) An a1phanumeric character setis a set ofeiements that inclUdes the 10 decimal digits the 26leuersofthealp1iabe and a nutnbeof special~S~ a set conshytains between 36~d 64 elements ifonIy capital letters areincltided or between 64 and 128 e1eJDents ifboth uppercasemiddot and lowercllle etters are inclUded In the first case we need a bi- nary code ofsix bits and in the second we need a binary cooeO(seVM bits

The standaM binary code for the alphanumeric char8cters is the American Stahdard Code for Information InterCbange (A~n) which uses seven bitS to code 128 characters asshoWn in Table 17 The seven bitsof the code are desipted by b~through h With h the mostsigshynificant bit ~e leUer A for example is represented inASCn as l(l()()()Ol (column l00~tOw 0001) The Ascn ()()de also contains 94 graphic characters that can be printed and 34 nonshyprinting characters used for variQUS control functions The graphic characters consist of the 26 uppercase letters (A through Z) the 26 lowercase letters (a through z) the 10 numerals (0 through 9) and 32 special printable characters suchaS andS

The 34 control characters are designated in the ASCTItable With abbreviated nalne8 They are listed again below the table with their functional names The control characters are used fQr routing data and arranging the printed text into a prescribed format~ There are three types of control characters format effectors information separatOrs andcommumc~on-COnlrpl char~ IlCters Format effectors are characters that control the layout ofprinting They inciude the fashymiliar word pr6cessorand typewriter controlssucb 8$ bac~pace (BS) horizontal tabulation (HT) and carriage return (CR) Information separators are used to separatetbe data into divi~ sions such as paragraphs and pages Theyinclude characters such as ~ordseparator (RS)and file separator (FS)The cODlIDunication-control characters are uSefulduriDgthe transmission of text between remote tenninals EXllll1plesof conlmunicatiOn(ODtiol~ are STX (start oftext)-and ETX (end of text) whicb are used toframe a text mesaagetnQlSlnitted through telephone wires

24 Chap~er 1 Diglt8l Systems and Binary Numbers

rblel7 Amerkcm5tandard Code for Information (nterclHlnge(ASCII)

b~jbzb 000 001 010 on 100 101 no 111

0000 NUL )jLP SP () p P 0001 SOH OC1 1 A Q a q

R0010 STX OC2 2 B b r 0011 ETX DC3 3 C S Ii S

0100 EDT 0C4 $ 4 D~ T d t 0101 ENQ NAK 5 E iU e u OUO ACK SYN amp 6 F V f v 0111 BEL ETB 7 0 W g w 1000 B8 CAN ( S H K h x 1001 HT EM ) 9 I Y Y 1010 LF SU~ 1 Z j z lOll VT ESC + 1lt r k UOO FF PS lt L I I 1101 Cit OS == - M 1 m 1110 SO R~ N 1 n shy

-0PIt st US f 1 0 0 DEL

r- Control characten

NUL NlI]l DlE Data-inkescape SOH Start of hea~ng DC1 Device cOntroll STX Start of text DC2 DevIce io~1lOi2 ETX End (Jftext i DC3 Device corUlri1 3 OOT End oftraIlsmission ~4 DeVicecoQtrol4

ENQ ampqwry NAK Negativeackilowledge ACK

Acknowledge SVN Sync~nous idle

Btl Bell ETB End-of-tmnsnussionblOck sS Backspace CAN CanCel HT Horizontal tab EM End of mediUrlt LF Lintifeed SUB Substitute VT Vertical tab ESC escape FF form feed FS File separator CR Carriigeretum GS Group separator SO shift Ollt RS Reoord sepuator SI Shlftin US Unit separator SF S~e DEL Delete

ASCII is a seven-bit codebutrnostcompUters manipulate anejght-bit quantity asa unit called a byte Therefore ASCII characters most often are stored ~e per byte The

I biti~sometimesused forotlef purposes depending ontheapplicatio~lFor example printetS recognize eightmiddotbit AScn chaiacterS with themost sigoificaot bit ~twO An atkJlitlo

Section 18 Binary Storage and Registers 2S

128 eight-bit characters with the most significant bit set tol are used for other symbols such as the Greek alpbabet or italic tyIe font

Error-Dtectlng Code

To detect errors in data communication and processing aneigbth bit is sometimes added to the ASCll cbaracter to indicate its Panty Aparitybit is an extra hit included with a message to make the total num~ of ls either even or odd Consider the fo119wing two cbaracters and their even andodd parity

With even parity With odd parity Ascn A = 1000061 01000001 11000001 ASCI( T == 101deg100 11010100 01010100

1

- Ineacb casewe insert an extra bit in the leftmost position of the code to produce an even number of 1 s intQe cbaraeter for even parity or an odd number of 1 s in the character for odd parity In generlll one or tbe oth~r parity i~ adopted with even parity being more common

The parity biqsbelpful in detecting errors during the transmission ofinformation from one location to another nisfuJictiOD is bandIed by generating an even parity bit at the sending end for ~h character The eight-bit characters that include parity bits are transmitted to their desshytination The parity ofeachebaracter is thetichecked at the receiving~nd If the parity of the received cbaracter is Dot even then at1east on~bit has changed value dUring the trmlsmission This method detects one three or any odd combination of errors in each character tb8t is transshymitted An even combination oferrors however goes undetected and additioDaterror detic- shytion codes may be needed to take care of that possibility

What is done after an errQlis detected depends on the partieu~ application One possishybilityis to request retransrois~ion of the message on the assump~on that tbeenigtr was ranshyd()m andwill not occur again Thus if thereeeiverdetects a parityerrorit sends bai~ the ASCII NAK (negative acknowledge) control cnaracter consisting ofail even-parity eight bits lOOlOl01H no error is detectedthe ~iversends back anACK (aCkno~ledge) conshytrol character namely 0000011 O The sending end will respond middotto an NAK by tranSmitting the message again until the correct panty is received Ifmiddot after a number of attempts the transmission is still in error a message can be sent to the Operatai to check for malfunctions in the transmission path

BINARY STORAGE ANORECiISTEIlS

The binary infonnation inadigitalcomputermust have a physical e~stencein some medium for storing individual bits A binary cell is a device that possesses two stable sttes and is cashypable of storing pne bit (0 or 1) oflnfotlllation The input to tbe cell receives exciJation sigshynals that set it to one of the two states The output of the cell isa pbysicalquantity that distinguishes between the two states The irtformationstored in Ii cell is 1when the cell is in one stable state and degwhen the Cell is in the other stable state

26middot Chapter 1 Digital Systems and BtnaryNumbers

Registers

A register is a group of binary cells A register with n cells can store any discrete quantity of middot information thatcontains n bits The state ofa registeris an n-tuple ofls middotand Os with each bit designating the state of one cell in the register The C()ntent ofaregister is a function of the int~rpretation given to tbeinformation stored in it Consider fQf ex~ple a 16-bitregister with the following binary content

11 00001111001001

middot Aregjs~ with 16 cells can be in one of 216 possible statesIf one asstimesthat the content cif the register represents a binaryinteger then the register can store any binarydumber from Oto 216 - 1 For the patticularexample shown the content ofthe register is the binary equivshyalent(lftbe decimal number 50121 If one assumes instead that the register stores alpbanushy

middot meric characters of an eight-bit cooe then the content of the register is any two meaningful characters For tht ASCII code with anevenplirityplaced in the eighth most significant bit position the register contains thetwo charactersC (the lefunosteightbits) and I (the rigbt~ most eight bits) If however one in~rprets the content of the register to be four decimal dig- its represented by a four-bitcode tnenthe content of the register is a four-digit decimal number In theexcess-3 code the register holqs the decimal nutriber 9096 The content of the registe~is meaningless in BCD becau~e the bit combinatiOn ltob is 110t assfgned to any decshyimal digit From this example it is clear that a register can store discrete elements of inforshymation and that the same bit configuration Inay beinterpreted dlffe(ently for different types of data

tmiddotmiddotReglsterTrail Adigitalsystenlis characteriZed by its registers and the components thatpetfolin data proshy~ssingIIl digital sy~tems a rcentgister tra1lsfer operation is abasi operation that consists of

middot a transftr of hiJWy hUormation from one ~t of registers into ano$er set of registers transfer may be dir~ctfr9m one regist~r toanlt)ther or may pass througb datamiddotprocessing circuits to petformaD operation Figure L 1 illustratel the transfer of iidOrnuttion among regshyisters anddemonstratespictorlallY [the tr8ll~~ ofbinaryinformation from akeyboard a register in the memQryullit Thehlputunit~s assumed to have a keyboard1 control cuit and aninput register Each time a key is strock the control circuit enters an ImnV$_

lent eight-bit alphanumeric character coqe into the input register We shall assume that code used is the ASCII code with an odd-parity bit The information from the input regisshyter is transferred into the eight-least significant cells Qf a proeessOr register After transfer theinpui register is cleared to enable the control to insert a new eight-bit when the keyboard is struck again Each eight-bit character transferred to the pro1c4ess(raquo register is preceded by a shift of the previous character to the next eight cens on its left~

middot a transfer -of four characters is completed the processor registeris full and its contents transferred into a memory register The content stored in die memOry register shown in Figl came from the transfer of the characters J 0 H an~ N aftet the four ap)lroJ)riatt keys were struck

Section 18 Binary Storage and Registers 27

FIGURE 11 Transfer of information among registers

To process discrete quantities of infoiniatiori in binary form a computer m~st be promiddot vided with devices that hold the (lata to be processed and with circuit elements that manipmiddot ulate individual bits of irifonnation The device most commonly used for holding data is a register Binary variables~ manipulated by means of digital logic circuits Figure 12 il~ luslrates the process of adding two l()bit binary iUlmbers Themeniory unit which no[shy

mally consists of millions of registers is shown with only three ofits registers Thepait of the processor unit showncoDsistsmiddotofthree registers-RI R2 and R3~getherwith digital logic circuits that manipulate the bits of RI and R2 and transfer into R3 a binary number equal to their arithmetic sum Memory registers store information and are incapable of pr0shy

cessing the two operands However th~ information stored in meDij)iybanbetransferred to ~ processor registers and the resUlts obtainedin processor tegisters can be transferred back into ame~ry register for storage Untill)ecded again The diagram ~wsthe90ntents of two

operands transferred from twoJDemoryregisters into RI imd R2 The digital logic circuits produce the sum which is transfened to register R3 The contents of R3 can now be 1riUlsshyferredback to one of thetnemory registers

The last two examples demonstrated the infonncion-flow capabilitieSofa digital system in a simple manner Themiddot registets of the ~ystem are the basic ele~ents for Noring and holding the binary information~igitallogic circuits process the binary ihfonaation stored in the

28 Chapter 1 DigIt bullbull Systems and Binary Numbers

Sum

FIGURE 12 Eumple of blnarylnfonn~t1on processing

registers Digitallogiccirctiits and registers are covered InChQpteB 2 throQgh 6 The metlilOlY unit is ~xPIained ill 9aptet 7 Th~ descriptton of register opetJtions at the register level and the design of digital systems are covexed in Chapter 8

19 BINARY LOGIC

Binary logic deals with variables th~ take on two discrete valueund withoperations that sumelogicalmeaning~ The two val~s the variableussume may be called~ydifferent (true andalse yel and no etc) but for ourp1llpQSe it is cpqVenienttotbink in terms of and assign the values llUld O The binary logic intr0ducedin this section is equivalent to algebra oalledBoolean algebra The fannal presentation ofBoolean algebra is covered in detail in Chapter 2 The purpose ofthis seCtion is to introduce Boo algebra ina matmerandlate it to digitallogiccircuits andmiddotbinarYsignalsmiddot

Section 19 Sinary logic 29 ~

Itkltn of IInary logic

Binarylogic consists of binary v~les and a set of logica1middotoperatiQDS The variables are desigshy ~by lettell of thCalplWlet~such asA B C x yz etc with eaCh variable baving two and oniy

two distinct posSible valueS 1and O There are three basic logical operations AND ORand NOT

1 AN]) This ~peration is represented by adotorby the absence ~f an oPerator For example x bull y =z or xy = zis~ x ANDy is equalto z~ThelogicaloperationAND is interpreted to mean that z == 1 ifand only ift~ land y = 1 otherwise z = O (Reme~r that x y andzare binary v8riablesand canmiddotbe equal either to 1 or Omiddotand nothing eise)middot

2 OR This operation IS represented by a plus sign For example x + y =z is read x OR y is equal to z meaning that z 1 if x = iorif y = lorifbothx= 1 and y = 1 If bqth X - 0 andY Omeo z= O

3bull NOT This operation is repf6sented by a prime (sometimes by an overbar) For ~xample x =Z (or~ =z) is read notdsequalto 1 meiming that z iswkatx isnot In other

words ifx = 1 then z == 0 but if x == 0 tnenz = L TheNOT operationisals(1 reshyferred tolls the complement operation since it changes ~ 1 toOand a O to 1

bull bull lt Binary logic resembles binary arithmetic and themiddot9peratioos ANDahd OR have similarishy

ties to multiplication and addition respectively In fac~ the symbols used for AND and OR are the same as those used for multiplication and addition However binary lOgic should not be conshyfused withbinaryarithIrietic One should realize thatan arithmetic variable designates a numshyber that may consist of many digits A logicmiddot variable is always either 1 or O For example in binary arithmetic we have I +1 =10(read~one plus ()fie is equal to 2) whereas in binary logicwe have 1 + 1 1 (read one OR onds equal to one)

For each combination of the values oix and y bullthere isa value of ~ $pecifiedby the definishytion of the logical operation D~linitiops of logical~perations maybe listed in a compacHorm called truth tables A truth table is atable of anpbssible combinations ofthe variables $howshying the relation between the values that the variables may take and the resultof the operation The truth tables for th~ operations ANDand OR with variables x and y are obtained by lis~ng

all possible values that the variables may have when combined in pairs bull For each combination the resUlt of die operation 18 theillistedin a separate row The truth tables for ANDORand

NOT are given in Table La These tables clearly demonstrate the definitionf the operatibns

Table 18 Truth TcibJts of Logical Operations

AND OR NOT

x y xmiddoty x y x+y

0 0 0 0 0 0 1 0 0 1

10

1 0 d 1 0 1 I 1 1 1 1 1

bull~lt~m

30 Chapter 1

Logk Gates

Digital Systems and Binary Numbers

Logic gates are electronic cirellit that operate on ~

variable

or mpre mput tignals to produce an output signal Electrical signals sUch as voltages orrutrents exist as analog signals having values over a given taDgebull saYOt03 V but in a digital system are interpreted to be either of two recognizable values 0 or 1 Voltage~opetated logic Circuits respond to two separate voltshyage levels that represent a binary varjable equal to logic I bt logic O For example a partic- ular digital system may define 10gicOas a signal equal to 0 volts lind logic 1 asa signal equal to 3 volts In practice each voltage levelhiS an acceptable rangeas shown in Fig 13

The input te~nals of digital cikuits accePt binary signals within the allowable range and respond at the output terininals with binary signals that fall within the specified range The intermediate region between the aJl()wed regions is crossed only during aState transition Any desired information for computing or control can be operated tm by passing binary signals through variQUS combinatioDsof logic gates with each signal represebting a particular binary

The graphic symbols used to deSignate themiddotthree types of gates are Mown in Fig 14 The

gates are blocks of hardware that prooocc tbeequivalent of1ogic~1 orlogic() output signals

Volts

- FGURl13

x

y

Exampleof binary slgnaJs

Signal ratlge for logieO

(a)~omiddotinput AND gate

FIGURE 14 SymbOls for digital logic circuits

(c)NOT gate or invert~

Problems 31

x-lU 1 11 P 0

y 0 0 11 1 ~

ANDxy 0 0 rTl 00

ORX+Y~ NOT x 11 0 0 I 1 1

FIGURE 15 Input-output 5Igals for gates

FIGURE 1

A B C

Gates WIth mlltlple JnpUU

A B C lJ

~

if inPllt logic ~ts are satisfied Theinput signals xaDd y intheNDaadQR gates may exist in ~ oHow-possible states 00 10 11 or 01 Il1ese ibpu~ampignals_ shown inFig lStoshygetber with the corresponding output signal foreach PfCThI~tiaiug~iDustrate the reshysponse ofeaclt gate to the four input signal~The~llisofthetiminadiagram represents time and the vertical axis sbo~~~~ it cbapg~botwcen~possible voltshy

age levels The low level represents logic O tJte high level l1lteAND _ responds With a logic ~ ~tput sipl wh~ both input ~~)e 1middot1~ lIieOR S-~with a logic 1 outpUt signal ifanylnput sigrudis lOgic 1 TheNOTgateis~~ to BUll invedet The reason for~nameis~t froJn the signalmsponae inmiddottbe timitt8 diagramwhicbsbows that theoUtputsignal inverts the logic sense of tbeiDpUtsigll8l

AND and OR gates may bavei)lQte tbantwQinputs M AND8_~itti ~input$andan OR gate with foU) inputs are shown in Fig 16 The three-inPllt AND gate responds With logic 1 output if all tbreeinputs arelogic 11jleoutputproduces lOgic Oifanymput is logic O-The

four-input OR gate responds withlogic 1 ifany input is logic 1 its clu1ptltllCCoines logic oonly when all inputs are logic O

Answers to prvblems marked with middotappearaHbe ClOd ofthe ~

11 lJltthe octal and beXadecimalliurilbers trom16ui 32UdngA B1l1ld C forthebst~ digits Usttbe numbers from 8 to 28 in base13 bull

I

12t What is the exact D1Jllbcr of bytes in a system that contains lta) 32Kbytoe (b)64M ~and (e) 640 byte$ middot7 t

32 Chapter 1 Digital Systemsand Binary Numbers

13 Convert the following nu~bers with the indicated bases to decimal (a) (4310)s (b) (198hz (c) (735)8 (d) (525)6

14 Whllt is the largest binary number that can be expressed with 14 bits WhlIt are the equivaleDt ~~ iinal and hexadecimal numbei-s

--

15 Detemrine the base of thl1 numbers in each case for the following operatio~ to be correct (a) 142 = 5 (b) 5414 = 13 (C) 24+ 17 == 40

16 The solution$to the q~cequation xl - Ux +22 oare l1 3 arid x =6 What is the base of the numbers

17 Convertthehexadecimal ntmIher 68BE to bitiary and then convert it ~mbinary to octal

18 I Convert the decirpal number 431 to binary in tWo ways (a) Convertd~y to binary (b) conshyvert first to hexadecinla1 and then from ~decimalwbinary Which method is faster

19 amppress the following nqrnbersin decinud (a) IQ11O0101)z (b) (l65his (c)(2624)8 (d) (FAFA) 16

(e) (10101010)2

110 Convert the following binary numbers tobexadeoimal and todecitnal (a) UOOlO (b) 110010 Explain why the deCimal answer in (b)is 4 times that in (a)

111 Perform the followingdiviskmin binary 11 Ion + l()t

112 Add IlniImultiply tfle following numberswiihout converting them to decimal (a) Binary nuniberilOll aiIdlOh (b) He~uumbers 2E aDd 34

1~)( Do thefoHowing con~ersionproblems (a) CorivertCiecimal2731S to binary (b) CakUlate the binary eqUivalent (f 213 outto eight pl~Then Convert from binary to

imalHowgJose istbe result to 2131 (c) Convert the binary resukin (b) into hexad~ lb~oonvert ~result to decimal Is answer tbesame

114 Obtain the is 8nd 2s complementsofthe foUowing binaryDumbcentrs (aj l)()()(J()OO (b) OOOOOOOO (c) 11011010 (d)01l10110 (e) 10000101 (0 11111111

115 Find the 9s and the 10s complement of the following detimal numbers (a) 52734630 (b) 63325600 (c) 25000009 (d) 00000000

116 (a) Find the 16s complement of B2FA (b) Convert B2FA to binary (c) Find the 2scomplement ofthe resultin (b) (d) Convert the answer in (c)to hex~malandco~ with ihe an~wer in (a)

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 14: Chapter 01 - Mano

14 Chapter 1 Digital Systemsand BinayNumbers

16 SIGNED BINARYNUMBER$ ~

Positiveintegers (including zero) CaBbe ep~~ 11$ unstPecl numbers However to repshyresent negative integers we need a notation for negative srn ordinary arithmetic a negshyative number is indicated by a mulUs signmdapOsitiv~Pwtlt)e~ by aplus sign Because of lJardware limitations computers mlstrepresenlev~With~ digitsIt is customary to represent the sign witb a bit placed intheleftmotp6sitiolwfthe number The convention is tltl make the sign bit 0 for positive and 1 for negative

Itis important to realize that botp siped and unsignedtDnary 11UJDbers consist of a strfug of bits when represented in a com~ TQeuser detem1inesWbether the number is signed or unsigned If the binary number is signed then the lefuriostbitreple$ellts thtsign aud the rest of the bits represent the number Ifthebinaryllu~beiis~ tObe unsigned then the left most bit is the most significant bit of the l)uMber Fdre~the~~f bits 01001 can be consideredas 9 (unsigned binary) or as +9 (Sighedbitia1j) ~USJtheteftmostbit is O The

string ofbits 11001 represents the binary ~~v~ento~ ~w~nc~idered as an unsigned number and the binary equivalent of 9whenconsidered1l si~riumPer This is because the Ithal isintbe leftmost positiondesignatesampC nega6ye_~QtherfourJ)its represent bishynary 9 usually tlere is no cotifusionin identifying thebits~the~Qfrepresentation for the number is known in advance ~

The representation of the signed numbers in the lastexainple is referred to as the signed magnitutk coDvention In this ~otati()nthenurnber C4mSiampesOCa mQ~~andil~ymbolH

or -) or a bit (0 or 1) indicating the sign This is the representation ampr~~used in ordinary arithmetic When arithmeti~ operatioBslllieimplerneJltcldin~cOQlPuter hii more convenient to use a different systemrefetred t(gt as the si~cqmptement system~ for repre- senting negative numbers In thissystlm a neg8tielliun~r isjhdic~ted by its cornplc~mc~nt Whereas the signed-magnitude system negates a nlllllher by cbanging its sign me signed-comshyplement system negatesanwnber bytakin$ its~OinPleltleitiSinoepositife numbers always start witbO(plusin tte leftmost pOsition thecompktllint wiilalwaysstart with a 1 indicating a negative number The siped-complemelt system can use olthertbe 1s Or the 2s but the 2s complement is the mos~comtliOfi

As an exampleconsider the number9re~~ed in binary with eight bits + 9 Is sented with a sign bit of Oin the leftri1ostpOsition oIIOv~by the binary (equivalent of 9 which gives ()()()olOOl Note thai all eigbtbits must haYampa v~therefore O~s are inserted folshylowing the sign bitllp to the first 1 Although ~ is only 01K way to tepresent +9 there three different ways to represent 9 with eight ~its

s~gned~magnituderepresentation 10001001

sigried-l s-complement represe~on~ 11110110

signed-2 s-complemerit representatim 1ttltllU

In signedmagnituamp -9 isobwned from +9 by changing the sign bitmtbe leftmost ~iti(ln tromO to L In sigl1ed~ lroomplement 9isobtaidedtf~~tiog all the bits of includinj the sign bit Thesigned-2~sco~re~Qf-9 is obtampDedby ihe 2s complement oftbepOsitivenumberincludingtbesijnbIt

Sectlont6 SIgned8lnary NumberS is

Table 13 Slgtlfd Biliary Humbm

+7 +6

+5 +4 +3 +2 +l +0 0 -I

-2 -3

4 -5 -6 -1 -8

Olll 0110

0101 ( 0100

001l 0010 0001 0000

IIll 1110

nOI noo Ion 1010

1001 1000

OIll Oito eHOl OHIO OOU 0010 0001 0000 1111 1110middot dOl 1100 Ion

lOti 1001 1000

0111 OUO 0101

0100 0011 0010 0001 0000 1000 1001 1010 IOU 1100

1101 1110

lUI

Table 13 lists all possible four-bitsignedbinaryaumbers in the three representations The equivalent decimal number Is also shown for refelenoeNote that the positive n~ in all three representations are identicaland have 0 inthelefmostpcsiticm The signed2sshycompl~mentsystemhaironly onemiddotrepresentation for 0 which is always po$itive The other tw()systetns- mlve either a positive 0 or a negative 0 sometbingnoteDcounteredin ordinary arithmetic Note that all negative numbenhave alin the leftmost bitpositi~ that is the way we distinguish them from the positivenumbers With fout bits we can repreSent 16 binary numbers In the signed-magnitude aDd thelscomplement repre$eDtatipns there are eight positive numbers and eight negative numbers inciUdingtwo zeros In the2s-complement representation there are eight positive numbers includi0a one zerQ and eight negative numberS

The siped-m_gnitude system is used in ordiIlary arithmetic but is awkward when emshyployed in computer arithmetie becauIe of the ~parate bandIinJ bfthesipand the magnitude Therefore the signed-compiement systeni is normallyused The ls ~t imposes some difficulties and is seldom USedJor arithmetic openitiOns It is U$eful aSa lo~ operation since the change of 1 to Obrmiddot() to 1 is equivalent to a logical complement Operation as will be shown in the next c~The discussion~f sigiled binary ariduneti~ that fol10ws deals exshyclusively with the signe4-2soomplt_nt~tatJonQfnegadveilUlilbers hsame proshy

cedurescan beappJied to the sigMdrs-comPlemeD~Iysby incIudiOI tbe~arotmdcarry as is done with unsigned numbers

J6 Chapt~r 1 OlgltalSystlf(ns and Binary Numbels

Arithmetic Addition

The addition of two numbers in the signed-magnitudelYs_foUowsthe rules ofordinaiy arithshymetiC Ifthesi~s arethesam~we addthetwOtt~gni1U~~d ~vetbe sum the CCmmon sign Iftbe signs are diffe~nt we subtract tllcsmaUermagnitude frOtnlthe larF and give the differshyehtethe signof the larger magnitude For example (+25) +( - 37) = ~ (37 - 25) = -12 and is done by subtracung the smaller magnitude 25 from the larger magnitude 37and a~nding the sign of 37 tGtbe result Ibis is a process that requires a corripanson of the signs and magnitudes and then performing eithr additi()n or subtraction The same procedure applieato binary numbers in sigped-magnitude representation~Incontrast the rule for adding numbers in the signed-corppleme~ sy~tem does not require a comparison or su~ traction but only addjtion The procedure is very simple andcanbe stated as follows for binary numbers The 8ddltion oftwo signed binary numberS with negative numbers tepresented in signed- 2sComprement fonn is obtaiIled from theadditlooofthe two numbers includingtheii sign bits

AcentiirrY out oftbe sign-bitposition is diScacded NumerIcal e~aihpledotai1dition follow

+ 6 00000110 - 6 11UI0tO I

+13 00001101

+13 00001101 +19 00010011 + J 0Q900111 + 6 00000110 6 11111010 ~13 11110011 -1~l 11110011 7 illl1001 -19 11101101

I bull bull ~

Note that negative numbers musthil iriitially in 2seompkmentform and that if the swn ~ ~afterthladdit40nis negativeins in2s~p~t fOl1Jl - In each of thefoDrcasestlteoporationperfol1JlC(lis additionwitb the sign bit iilcluded Any catTY o~of~~-bit~onisdisc~ and negative resultsareButomaticallyin 2sshyromplementfoon

In order to obtain acOrrect answer we mustensQre that the result has a sufficient of bits to accommodate the swnlfwestartwith t~on-bltnumbers and tbeswn occupies n + 1bits we say tblltan overflow occurs~Wheri one perfotmStbc ad(JitiOJl with nllllIPTJllVIl

pencil aq overflow is not a preblem because we arcr noflimitecLbythewidth of the page jUst addanothcentr 0 to apositive number or another 1 toa negative number in the mOst cant positi()n to extend thenwnber to n+ 1 bitSand theQ perform addition Overflow is

problem in computers beqiusetbe number ofbi~~ bolla ~befis finite and a result ex~ tI1efinite val~e hy lcatmotbe accommodated

The compJement form of representiQg negativetlQUlbers is unfamiliar to those usedto signed-magnitude system To itetermine th~ value of II negatienumber insiped-2s COlIlpJe

mentit0is~ to CODVerttbe numbcr to apositie ntirit_ ~ place itiDa more formPor ~plethesig~binary number qUl00~ lii~egativebecausothe leftmost

t 1182s c0J8plemen~js~UlwhUhi$~ binaryeqqivalen of +7Wcmiddottherefore nize the Ori~nal ~atiy-eQumber to be equ~ lo-7 1

Sectlonl7 Bh1ary Codes 17

ArIthmetic SubtractIOn

Subtraction of two signed binafy numbers whe~negative numbersare in2s-complement form is simple and can be stilted as follows

Take the 2s complement of the5ubtraltend (including the sign bit) and add it to the minuend (including the sign bit) A cany oU1of thesignbit position is discarded

This prOCedure is adopted because a subtraction operation can be changed to an addition operation if the sign of the subtrahend is changed as is demonstrated by the following relationship

(plusmnA) ~ (-tB) = (plusmnA) + (-B) (plusmnA) - (-B) =plusmnA) + (+B)

But changing a positivetwober toa negative n~ber is eaampily done by taking the 2s compleshy mentof the pQsitive number The reverse is also tiUe~use theCOmPle~n~ of a negative numshyber in complement form produces the equivalent positive number To see this consider the sJlbtr~ction ( 76) -- (13) = +7 In binaIy_ with eight bits this ()peiationis written as (11111010 11110011) The subtracti~ri ischmlged ~ addition by taking the 2s complement ofthe subtrahend (-13) giving (+13) In binaly tbis~ 11 niOlO+ 00001101 = lOOOOOU1 Removing the end~ we obtain the ootrect answer ()()()()() III (+7)

Itisworth noting that binary DUmbersinthe signed-complement system are added and subshy tracted by the same basic addition and suPtraction rules as unsigned numbers Therefore comshyputersneed omy one common hardware circuit tobandle bothtypcs ofaritbtnetic The user or programmer ~ust interpret the reswtIi of $l1ch addition or subtraction differently depending on whether itisassumedtha~the numbe~ are signed ltr tinsigned

j

BINARY CODES

Digitalsystems use signalsthat have two distinct values1Uld circuit elements that havetwostashyble states There is a direct analogy anrong binary iignals binary circuitelements and binary digits A binary number ofndigitsfor example may be represented by n binary circuit eleshyments each baving an output sig~alequivalen1to Oor I Digital systems represent (Uld mashynipUlate not omy binary numbers but alsO many other diScrete elements of information Any discrete element of informatioIidlat is dis1iilct among agroup of quantities can be represented witha binary code (Le a pattern of Os and fmiddots) The codes must be in binary because in todays techIiology omy circuits that represent and manipulate patterns of 0s and ls can be manufactured economically foru~ in computers However it mtistbe realizCd that binary codes merely change the symbols not the meaning ofthe ele~nts of infonbationthat they repshyresent IT we inspect the bits of a computer at random we will find that mostofthe time they represent some tYPe of coded information rath~ than binlUY numbers

AIln-bit binary code is a groopofn hits that assumes up to 211 distinct cOmbinations of ls ~d Os with eacn combination representing one elementof tnt set that is being coded A set

of four elements clab becoded with two lilS with each ~lementassignedoneof thefoUowing bit oombinationsOOO I 10 J 1 A set of eight elements requiies a three-bit code 00 a set of

18 Chapter 1 Digital Systems and Binary Numbers

J6 elements requires a fourmiddotbit code The bit combination of ann~bit code is determined the count in binuy from 0 to 21t - t Each element must be assigned a unique binuy bit binationand no two elemerits cm havetbtsamevalueothenvisethe code assignment be ambigUous

Although the minimum nqrnber of 1lits required to code 21t distiItct quantities is nthere nomaximwn numbe( of bit that may he used for a binuy code For example the 10 digits can be coded with 10 bits and each decimal digit can be assigned a bit combination nine OSmid a 1 In this pamcularbinarycode the digit6 is assigned the bit )UllIUlauuu0001000000

BCDcode

Although the binary number systemis die ~ost natural system for a computer most people more accustomed to the d~imal system One way to resolve this difference is to convert

inlal nUmbers to binary perform all arithmetic calculations in binary and then convert the nary results back to decimal This metbodrequites that we store decimal numbers in

cOinputer so that they canbec6b~rted to binary Since the compllter Can accept only valueswe must represent the decimal digits by means ofa code that contains ls and Os also pOsSible lopedorm the arithmetic operlltiorisd1rectly on decimal numbers when they stored in the comput~ in cod~ct form

A binarycodewill have some unasSigned bit com~inatiqns ifthe num~rofelements in set is not amultiple power of 2 The 10decimai digits form such asel A biruuy code that tinguishes among 10 elements must coiltain at least four bits but 6otitofthe 16 possible binations remain unassigned Different binary code$ can bemiddotoNained by arranging four into 10 distinct combin~tions TheicodeIllcfflt oommonly used fdr the decimal digits is straight binary assf~ntlisted in Table 14 This scheil)eis called bittary~coded decimal

is commoolyreferred to as BCQ OtherdecimalcodesaIlfpossible and a few of them are sentedlaterinthis section

Table 14 BinarymiddotCoded Oeclmql (BCO)

Decimal BCD SnlboiDIgIt

o 0000 1 0001 2 0010

3 0011 4 middot0100 5 0101 6 0110 7 0111 8 1000 9 1001

Sectionmiddot 17 BInary COdes 19

Table 14 givesthe four-bit code for one decimal digit A number with k decimal digits will require 4k bits in BCD Decimal 396 is represented in BCD with 12 bits as 0011 10010110 with each group of 4 bits representing one decimal digit A decimalmiddotnumber in BCD is the

- same as itS equiyalent binary number only when the number is between 0 and 9 A BCD numshyber greater than lOJpoks different from its equivalentbinary number even though both con tainls and Os Moreover the binary Combinations 1010 thrpugh 1111 are not used arid have no meaning in BCD Consider decimal 18SlUld its corresponding value inBCD and bUtary

(185ho = (0001100001Ol)BCD = (l0111001h

The BCD value has 12 bits to encode the characters of the decimal value but the equivalent binary number needs only 8 bits It is obvious thatthe representation of a BCp number needs more bits than its equivalent binary value However there is an advantage in the use ofdecishymal numbers because compUterinput and output data are generated by people who use the decshyimal system

It is important to realize that BCD numbers are deCimal numbers and not binary numbers although they use bits in tbeir representation The only difference between a decimal number and BCD is that decimals are written with the symbOls 0 1 2 9 and BCD numbers use tbebinarycode 00000001 001O~ bull 1001The decimal value is exaCtly the same Dec~mal 10 is represented in BCD witheight b~ts as 00010000 and decitna1J5as 0001 01Of1lte corshyresponding binaryvalues are 1010 and 1111 and have only four bits

Consider the addition of two decimal digits in BCD together with a po~ible carry from a pre- vious less significant pair ofdigitsSince each digit does not exceed 9 the sum cannot be bull greater than 9 + 9 + 1 = 19 with the 1 being a previous carrySllppose we add the BCD dig-

its as if they were binary numbers Then the binary sumvill produce It result in the range from degto 19 In bin8ry thistange wil[be from 0000 to 10011 butin BCD it is frOm 0000 to

I 1001 with the first (ie leftmost) 1 bemg a carry and the next fo~ bits being the BCD sum When tPe binary sum is equalto or less than 1001 (withaut 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 (0110h to the binary Sum cOnverts it to the correct digit and also produces a catTy as required This is because a carry in themost significant bitposishytion of the binary sum and a deCimal carry differ by 16 10 = 6 Consider the following three BCD additions

4 0100 4 0100 8 1000

+S +0101 +8 +1000 +9 1001 9 1001 12 1100 17 10001

+0110 +0110----

10010 10111

In each case the two BCD digits are added as if they were two binary numbers If the binary sum is greater than or equal to 1010 we add 0110 to obtain the correct BCD sum and a carry In the flIst example the sum is equal to 9 and is the correct BCD sum In the second example

20 Chapter 1 Digital Systems and BInary Numbers

the binary sum produces an iJlv~ BCD digit The addition of0110 produces the cortect BCD sum 0010 (ie the number 2) and acanyInthetbirdexample the binalY SUDlproduces acany This condition occurs wben the $W)) is greater than or equal to 16Altbough the other fout are less than 1091 the binary 9Ulll requires acOnectionbecause of die carry Adding 0110 obtain thetequiled BCD sum 0111 (ie the numblaquo 7) and 8 BCD CiUT

The additionoftwondigit unsipedBCD numbers follows the same procedure COIlSioll the addition of 184 + 576 1= 76() in BCD

BCD 1 I 0001 10000100 184

+6101 ~

0111--- 0110 +576

lJinarysum 0111 10000 1010 Add6 ono 0110

BCDsun 0111 0110 0000 7(1)

The flfSt l~ sigDiticant pili- of BCD digits produces aBCDdigi~SllDlof 0000 and a for the next pair of digits the second parr or BCD digits plus a ~Vi0U8 cany produces a sum of 0110 and a carry for the next patr()fdigits The third pair of digits plus acarry proltIUC~ a binary s~ of 0111 and does not require a correction

Decimal Arithmetic The represeiltation of signed decimal numbers in BCD is simiiarto the tepresentation of numbers in binaryWe can useeitheI the familiar signed-magnitude system at the SllZllOO-COI1I

plemelit system The sign of a decimal number is tJSually represented with four bits to to thefour-bit code ofthe decimal digits Itis customary to designate 8 plus With four Os 8 minus with the llCDequivalent oi9 whlcq is 1001 The sigiled~magnitudesystem is seldom used in com~tersThe signed-complerDem ~~ either the 9s octhe 10s complement put the lOscomplement is the one most useP To obtain the lOs complement of aBCD numberwe first take the 9s complement then add 1 to the least significant digit The 9s Complement is calculated from the subtracloo of each digit from 9

The prltXeduresdevelope4 for the signed-2s-complement system in the ~vious also apply to the signed-IOs-complement system for decimal mimberS Addition is done summing all digits including the sign digit and discafding the end carry This operatiQ assumes that all negative numbers are in 10s-complement form COOsider the (+375) + (-240) == + 135 done inthe signed-complement system

o 375

+9 760middot

o 135

lhe 9in the leftmost pOsition of the second n~ber tepresents a minllS and 9760 is the complement o( 0240 The two numbers are added and tbe end carry is discarded to +13SOfcourse the decimal ntmlbers insi~ tile computer includingthe sign digits in BCD The addition isdone with BCDOigits as described previously

Sectionl 7 Binary Codes 21

The suQtr8ction of decimalliUJ1lbets either unsigned or in thesi~-~Oscomplement systetn is the sameu in the binary case Taketbe 10s ootnplementof the subtrahend and add i~ to themin~nd ManyooDlputerslULvespeciaJ hardware to perform arithmeticcalculations directly withdecilnal oumbers in 8tDThe~u$etofthecoBlPuter can specify programliled Wtnlctionsto JOdonn the aDtiuJletiP oPmwoowithdeQmal n1UQ~ ~ywithout having to convell them to binary

Binafy codes for decimal digits requirea minimum of four bits per digit Many different codes can be formulated by~gjng four bits into IQ distinct combinations BP) and three other representative codes are shown in Table L5 Each code uses only 10 out ofa pOssible middot16 bit combinations that can be arranged with four bits The other six Unused cOmbinations have no meaning amt should be avoided BCD and the 2421 code are examplesofweigbted codes In a weigbtedcodeeach bit position

juBsigned a weighting f~in~awaythat eaehdigitcanbe ev~by 8dding the wei~ oran the lsin thecoded combination The BCD code has weights of8 42 and I which cotteshy

spondiothe powe1Of-two valuesofeaCh bitTbebitasSignmeatOll0 for example is interpreted by the weights to represent dedma16beCause 8 X 0 +4xt +2 Xl +IX 0 6Thebit combination 1101 when weighted by the ~ve digits 2421 gives themiddotdeCimal equivalent of 2 X I +4 gtlt I + 2 KO + 1 X 1 = 7 Note that some digits cantle coded in lw9 possib)e

ways in the 2421Q)(feFOr inke decimal 4 can be asSigned to bitCombinadon 0100 or 1010 since botbcOmbinatibns add upto a totalweight of4

middot1$ Fou Dlf(et Blnqry Code$ for thtJledmol DIgits

~ IICD DIgIt sal MZt Exeet) 8 4 -~1

0 1

000() middotmiddotmiddot0000 001)1 0001

oem 0100

0000 0111

2 0010 0010 0101 0110 3 0011 OQU 0110 0101

4 0100 0100 0111 oroo 5 0101 lOll 1000 1011 6 OlIO middot1100 1001 1010 7 middot0111 1101 1010 J001 8 1000 IUOmiddot 1011 1000 9 1001 11U 1100 1111

1010 oloi 0000 0001 Uaused IOU 0110 middotOOOl 0010 bit 1100 0111 0010 0011 combishynations

nOl 1110

lOW 1001

HOI 1110

1100 1101

1111 IOU) 1111 1110

22 ChaptfrliDfgltalSystemsaod Btoary Numbers

I1te 2421 rind the

e~l3~es are exampks Of self-complementing codes Such codes have~propertyjbatthe9s~plement ofa deCimal nfunberigobtairted directly by chang-

ing 1$ to O~$ finO tYSCfb1 sie~bycomple~mmgeaCh bit in the pattem)For example decshyimat3~Sis re~ fu tbeexcess3code as 01101100 1000 The 9s compl~ntof 604 isrepRse~l00liOOllelliwbich isobiainc(himply by complementing each bit of the

code (as with the 1 s coinpl~ofbin~rillDlbers)middot Theexcess~3code has been used in some oldel coritputers because of its selfcpmplement~

ing property Excess-3 is an unweighted code inwhich each codedcombinationis obtained-fJQm the corresPonQing bin3ryvalueplus 3 Note that the BCD code is1~ self-complementing TheS 4 ~~ Icode isan example of assigning both positive and negative weights to ~ decimalcodeInthis case the bit combiDation 0110isin~reted as oecimal2 and is calcu-

latedfrom8XO+4X 1 + (2) X 1 + (1XO=2 ~

Cra Code _ _ J

l1te output data QfmaJlfpbYsicaimiddot $)ShmlS are quantities that are continuous These data bemiddottonverted~digiWforuitJefore they art applied toaliigital system Contfuuous or ~nisCOIl~middotUitodigitalfonn bymeans of an rumlog~digitalConverter It is times ~~ent tousethe Gray code slown inTable 16torepresehtdigiuU data that have oon~ fMn8D8l08 dasaTheadvantage of th( Gray cOOeover thesllaigbt binary nIl11l1hPt~

~lt~thatoWY~ hit in the codegroup changeSin going from one number to the For examplcentbullin-goingfrom 1 to 8dleGray code cblngesfrom 0100 to 1100Only the fust changesfromOto l~the odter~ I)its mnaintbesame By contrast With binary numbers change from 7 to 8wrube from 0111 to lOOOwhich causes allfciur bits to change valUes

TabielAi GtPyCode

01 Decl COde Equivalent

~ 0000 0001 0011 OOlG 011Q Olll OlO 0100 1100 11m 1111 1110 lOlQ 1011

lOOt i

1000

o 1 ~ 3

4 5 6 7 8 9

10 11

12 13 14 15

SectIOnl7 BlnarYCod~s 23

The Gray code is used in applications in which the normal sequenceOrbiruuy rium~may produce an error orambiguitymiddot during themiddot transitionfrom ODeDWDber to the next If binary numbersareusec1 acbange forexaJIlple nom 0111 to 1000 may produce anintermediateershyroneous number 1001 if the value ofthe rigbtmost bit takes longer to -change than domiddotthe valshyues of the other three bits The Graycode elimb1ates this problem since only one bit changes its valve dUrlng aily transition be~een two numbers I

Atypical appli-cation ofmiddotthe Gray code is the representation of analog data by a Continu ous change in the angUlar position of a shaft The sQaftmiddot is partitioned into segments ana each segment is assigned a number If adJacent segments are made to correspond with the Qray-Codesequence ambiguity is eliminated between the angle of thesbaft and the value encoded by the sensor

Character Code

Many applications of digital computers require the handling not only ofnumberS but also of other characterS or symbols such as the letters of the alphabet For mstancean insurance comshypany with thousands of policyholders will use a computeX to process its files To represent the names and other pertinent information it is necessary to fonnulate bull binary code for the letshyters ofthe alphabet In additiQt1 the same binary qode must represent numerals and special Characters (such as $) An a1phanumeric character setis a set ofeiements that inclUdes the 10 decimal digits the 26leuersofthealp1iabe and a nutnbeof special~S~ a set conshytains between 36~d 64 elements ifonIy capital letters areincltided or between 64 and 128 e1eJDents ifboth uppercasemiddot and lowercllle etters are inclUded In the first case we need a bi- nary code ofsix bits and in the second we need a binary cooeO(seVM bits

The standaM binary code for the alphanumeric char8cters is the American Stahdard Code for Information InterCbange (A~n) which uses seven bitS to code 128 characters asshoWn in Table 17 The seven bitsof the code are desipted by b~through h With h the mostsigshynificant bit ~e leUer A for example is represented inASCn as l(l()()()Ol (column l00~tOw 0001) The Ascn ()()de also contains 94 graphic characters that can be printed and 34 nonshyprinting characters used for variQUS control functions The graphic characters consist of the 26 uppercase letters (A through Z) the 26 lowercase letters (a through z) the 10 numerals (0 through 9) and 32 special printable characters suchaS andS

The 34 control characters are designated in the ASCTItable With abbreviated nalne8 They are listed again below the table with their functional names The control characters are used fQr routing data and arranging the printed text into a prescribed format~ There are three types of control characters format effectors information separatOrs andcommumc~on-COnlrpl char~ IlCters Format effectors are characters that control the layout ofprinting They inciude the fashymiliar word pr6cessorand typewriter controlssucb 8$ bac~pace (BS) horizontal tabulation (HT) and carriage return (CR) Information separators are used to separatetbe data into divi~ sions such as paragraphs and pages Theyinclude characters such as ~ordseparator (RS)and file separator (FS)The cODlIDunication-control characters are uSefulduriDgthe transmission of text between remote tenninals EXllll1plesof conlmunicatiOn(ODtiol~ are STX (start oftext)-and ETX (end of text) whicb are used toframe a text mesaagetnQlSlnitted through telephone wires

24 Chap~er 1 Diglt8l Systems and Binary Numbers

rblel7 Amerkcm5tandard Code for Information (nterclHlnge(ASCII)

b~jbzb 000 001 010 on 100 101 no 111

0000 NUL )jLP SP () p P 0001 SOH OC1 1 A Q a q

R0010 STX OC2 2 B b r 0011 ETX DC3 3 C S Ii S

0100 EDT 0C4 $ 4 D~ T d t 0101 ENQ NAK 5 E iU e u OUO ACK SYN amp 6 F V f v 0111 BEL ETB 7 0 W g w 1000 B8 CAN ( S H K h x 1001 HT EM ) 9 I Y Y 1010 LF SU~ 1 Z j z lOll VT ESC + 1lt r k UOO FF PS lt L I I 1101 Cit OS == - M 1 m 1110 SO R~ N 1 n shy

-0PIt st US f 1 0 0 DEL

r- Control characten

NUL NlI]l DlE Data-inkescape SOH Start of hea~ng DC1 Device cOntroll STX Start of text DC2 DevIce io~1lOi2 ETX End (Jftext i DC3 Device corUlri1 3 OOT End oftraIlsmission ~4 DeVicecoQtrol4

ENQ ampqwry NAK Negativeackilowledge ACK

Acknowledge SVN Sync~nous idle

Btl Bell ETB End-of-tmnsnussionblOck sS Backspace CAN CanCel HT Horizontal tab EM End of mediUrlt LF Lintifeed SUB Substitute VT Vertical tab ESC escape FF form feed FS File separator CR Carriigeretum GS Group separator SO shift Ollt RS Reoord sepuator SI Shlftin US Unit separator SF S~e DEL Delete

ASCII is a seven-bit codebutrnostcompUters manipulate anejght-bit quantity asa unit called a byte Therefore ASCII characters most often are stored ~e per byte The

I biti~sometimesused forotlef purposes depending ontheapplicatio~lFor example printetS recognize eightmiddotbit AScn chaiacterS with themost sigoificaot bit ~twO An atkJlitlo

Section 18 Binary Storage and Registers 2S

128 eight-bit characters with the most significant bit set tol are used for other symbols such as the Greek alpbabet or italic tyIe font

Error-Dtectlng Code

To detect errors in data communication and processing aneigbth bit is sometimes added to the ASCll cbaracter to indicate its Panty Aparitybit is an extra hit included with a message to make the total num~ of ls either even or odd Consider the fo119wing two cbaracters and their even andodd parity

With even parity With odd parity Ascn A = 1000061 01000001 11000001 ASCI( T == 101deg100 11010100 01010100

1

- Ineacb casewe insert an extra bit in the leftmost position of the code to produce an even number of 1 s intQe cbaraeter for even parity or an odd number of 1 s in the character for odd parity In generlll one or tbe oth~r parity i~ adopted with even parity being more common

The parity biqsbelpful in detecting errors during the transmission ofinformation from one location to another nisfuJictiOD is bandIed by generating an even parity bit at the sending end for ~h character The eight-bit characters that include parity bits are transmitted to their desshytination The parity ofeachebaracter is thetichecked at the receiving~nd If the parity of the received cbaracter is Dot even then at1east on~bit has changed value dUring the trmlsmission This method detects one three or any odd combination of errors in each character tb8t is transshymitted An even combination oferrors however goes undetected and additioDaterror detic- shytion codes may be needed to take care of that possibility

What is done after an errQlis detected depends on the partieu~ application One possishybilityis to request retransrois~ion of the message on the assump~on that tbeenigtr was ranshyd()m andwill not occur again Thus if thereeeiverdetects a parityerrorit sends bai~ the ASCII NAK (negative acknowledge) control cnaracter consisting ofail even-parity eight bits lOOlOl01H no error is detectedthe ~iversends back anACK (aCkno~ledge) conshytrol character namely 0000011 O The sending end will respond middotto an NAK by tranSmitting the message again until the correct panty is received Ifmiddot after a number of attempts the transmission is still in error a message can be sent to the Operatai to check for malfunctions in the transmission path

BINARY STORAGE ANORECiISTEIlS

The binary infonnation inadigitalcomputermust have a physical e~stencein some medium for storing individual bits A binary cell is a device that possesses two stable sttes and is cashypable of storing pne bit (0 or 1) oflnfotlllation The input to tbe cell receives exciJation sigshynals that set it to one of the two states The output of the cell isa pbysicalquantity that distinguishes between the two states The irtformationstored in Ii cell is 1when the cell is in one stable state and degwhen the Cell is in the other stable state

26middot Chapter 1 Digital Systems and BtnaryNumbers

Registers

A register is a group of binary cells A register with n cells can store any discrete quantity of middot information thatcontains n bits The state ofa registeris an n-tuple ofls middotand Os with each bit designating the state of one cell in the register The C()ntent ofaregister is a function of the int~rpretation given to tbeinformation stored in it Consider fQf ex~ple a 16-bitregister with the following binary content

11 00001111001001

middot Aregjs~ with 16 cells can be in one of 216 possible statesIf one asstimesthat the content cif the register represents a binaryinteger then the register can store any binarydumber from Oto 216 - 1 For the patticularexample shown the content ofthe register is the binary equivshyalent(lftbe decimal number 50121 If one assumes instead that the register stores alpbanushy

middot meric characters of an eight-bit cooe then the content of the register is any two meaningful characters For tht ASCII code with anevenplirityplaced in the eighth most significant bit position the register contains thetwo charactersC (the lefunosteightbits) and I (the rigbt~ most eight bits) If however one in~rprets the content of the register to be four decimal dig- its represented by a four-bitcode tnenthe content of the register is a four-digit decimal number In theexcess-3 code the register holqs the decimal nutriber 9096 The content of the registe~is meaningless in BCD becau~e the bit combinatiOn ltob is 110t assfgned to any decshyimal digit From this example it is clear that a register can store discrete elements of inforshymation and that the same bit configuration Inay beinterpreted dlffe(ently for different types of data

tmiddotmiddotReglsterTrail Adigitalsystenlis characteriZed by its registers and the components thatpetfolin data proshy~ssingIIl digital sy~tems a rcentgister tra1lsfer operation is abasi operation that consists of

middot a transftr of hiJWy hUormation from one ~t of registers into ano$er set of registers transfer may be dir~ctfr9m one regist~r toanlt)ther or may pass througb datamiddotprocessing circuits to petformaD operation Figure L 1 illustratel the transfer of iidOrnuttion among regshyisters anddemonstratespictorlallY [the tr8ll~~ ofbinaryinformation from akeyboard a register in the memQryullit Thehlputunit~s assumed to have a keyboard1 control cuit and aninput register Each time a key is strock the control circuit enters an ImnV$_

lent eight-bit alphanumeric character coqe into the input register We shall assume that code used is the ASCII code with an odd-parity bit The information from the input regisshyter is transferred into the eight-least significant cells Qf a proeessOr register After transfer theinpui register is cleared to enable the control to insert a new eight-bit when the keyboard is struck again Each eight-bit character transferred to the pro1c4ess(raquo register is preceded by a shift of the previous character to the next eight cens on its left~

middot a transfer -of four characters is completed the processor registeris full and its contents transferred into a memory register The content stored in die memOry register shown in Figl came from the transfer of the characters J 0 H an~ N aftet the four ap)lroJ)riatt keys were struck

Section 18 Binary Storage and Registers 27

FIGURE 11 Transfer of information among registers

To process discrete quantities of infoiniatiori in binary form a computer m~st be promiddot vided with devices that hold the (lata to be processed and with circuit elements that manipmiddot ulate individual bits of irifonnation The device most commonly used for holding data is a register Binary variables~ manipulated by means of digital logic circuits Figure 12 il~ luslrates the process of adding two l()bit binary iUlmbers Themeniory unit which no[shy

mally consists of millions of registers is shown with only three ofits registers Thepait of the processor unit showncoDsistsmiddotofthree registers-RI R2 and R3~getherwith digital logic circuits that manipulate the bits of RI and R2 and transfer into R3 a binary number equal to their arithmetic sum Memory registers store information and are incapable of pr0shy

cessing the two operands However th~ information stored in meDij)iybanbetransferred to ~ processor registers and the resUlts obtainedin processor tegisters can be transferred back into ame~ry register for storage Untill)ecded again The diagram ~wsthe90ntents of two

operands transferred from twoJDemoryregisters into RI imd R2 The digital logic circuits produce the sum which is transfened to register R3 The contents of R3 can now be 1riUlsshyferredback to one of thetnemory registers

The last two examples demonstrated the infonncion-flow capabilitieSofa digital system in a simple manner Themiddot registets of the ~ystem are the basic ele~ents for Noring and holding the binary information~igitallogic circuits process the binary ihfonaation stored in the

28 Chapter 1 DigIt bullbull Systems and Binary Numbers

Sum

FIGURE 12 Eumple of blnarylnfonn~t1on processing

registers Digitallogiccirctiits and registers are covered InChQpteB 2 throQgh 6 The metlilOlY unit is ~xPIained ill 9aptet 7 Th~ descriptton of register opetJtions at the register level and the design of digital systems are covexed in Chapter 8

19 BINARY LOGIC

Binary logic deals with variables th~ take on two discrete valueund withoperations that sumelogicalmeaning~ The two val~s the variableussume may be called~ydifferent (true andalse yel and no etc) but for ourp1llpQSe it is cpqVenienttotbink in terms of and assign the values llUld O The binary logic intr0ducedin this section is equivalent to algebra oalledBoolean algebra The fannal presentation ofBoolean algebra is covered in detail in Chapter 2 The purpose ofthis seCtion is to introduce Boo algebra ina matmerandlate it to digitallogiccircuits andmiddotbinarYsignalsmiddot

Section 19 Sinary logic 29 ~

Itkltn of IInary logic

Binarylogic consists of binary v~les and a set of logica1middotoperatiQDS The variables are desigshy ~by lettell of thCalplWlet~such asA B C x yz etc with eaCh variable baving two and oniy

two distinct posSible valueS 1and O There are three basic logical operations AND ORand NOT

1 AN]) This ~peration is represented by adotorby the absence ~f an oPerator For example x bull y =z or xy = zis~ x ANDy is equalto z~ThelogicaloperationAND is interpreted to mean that z == 1 ifand only ift~ land y = 1 otherwise z = O (Reme~r that x y andzare binary v8riablesand canmiddotbe equal either to 1 or Omiddotand nothing eise)middot

2 OR This operation IS represented by a plus sign For example x + y =z is read x OR y is equal to z meaning that z 1 if x = iorif y = lorifbothx= 1 and y = 1 If bqth X - 0 andY Omeo z= O

3bull NOT This operation is repf6sented by a prime (sometimes by an overbar) For ~xample x =Z (or~ =z) is read notdsequalto 1 meiming that z iswkatx isnot In other

words ifx = 1 then z == 0 but if x == 0 tnenz = L TheNOT operationisals(1 reshyferred tolls the complement operation since it changes ~ 1 toOand a O to 1

bull bull lt Binary logic resembles binary arithmetic and themiddot9peratioos ANDahd OR have similarishy

ties to multiplication and addition respectively In fac~ the symbols used for AND and OR are the same as those used for multiplication and addition However binary lOgic should not be conshyfused withbinaryarithIrietic One should realize thatan arithmetic variable designates a numshyber that may consist of many digits A logicmiddot variable is always either 1 or O For example in binary arithmetic we have I +1 =10(read~one plus ()fie is equal to 2) whereas in binary logicwe have 1 + 1 1 (read one OR onds equal to one)

For each combination of the values oix and y bullthere isa value of ~ $pecifiedby the definishytion of the logical operation D~linitiops of logical~perations maybe listed in a compacHorm called truth tables A truth table is atable of anpbssible combinations ofthe variables $howshying the relation between the values that the variables may take and the resultof the operation The truth tables for th~ operations ANDand OR with variables x and y are obtained by lis~ng

all possible values that the variables may have when combined in pairs bull For each combination the resUlt of die operation 18 theillistedin a separate row The truth tables for ANDORand

NOT are given in Table La These tables clearly demonstrate the definitionf the operatibns

Table 18 Truth TcibJts of Logical Operations

AND OR NOT

x y xmiddoty x y x+y

0 0 0 0 0 0 1 0 0 1

10

1 0 d 1 0 1 I 1 1 1 1 1

bull~lt~m

30 Chapter 1

Logk Gates

Digital Systems and Binary Numbers

Logic gates are electronic cirellit that operate on ~

variable

or mpre mput tignals to produce an output signal Electrical signals sUch as voltages orrutrents exist as analog signals having values over a given taDgebull saYOt03 V but in a digital system are interpreted to be either of two recognizable values 0 or 1 Voltage~opetated logic Circuits respond to two separate voltshyage levels that represent a binary varjable equal to logic I bt logic O For example a partic- ular digital system may define 10gicOas a signal equal to 0 volts lind logic 1 asa signal equal to 3 volts In practice each voltage levelhiS an acceptable rangeas shown in Fig 13

The input te~nals of digital cikuits accePt binary signals within the allowable range and respond at the output terininals with binary signals that fall within the specified range The intermediate region between the aJl()wed regions is crossed only during aState transition Any desired information for computing or control can be operated tm by passing binary signals through variQUS combinatioDsof logic gates with each signal represebting a particular binary

The graphic symbols used to deSignate themiddotthree types of gates are Mown in Fig 14 The

gates are blocks of hardware that prooocc tbeequivalent of1ogic~1 orlogic() output signals

Volts

- FGURl13

x

y

Exampleof binary slgnaJs

Signal ratlge for logieO

(a)~omiddotinput AND gate

FIGURE 14 SymbOls for digital logic circuits

(c)NOT gate or invert~

Problems 31

x-lU 1 11 P 0

y 0 0 11 1 ~

ANDxy 0 0 rTl 00

ORX+Y~ NOT x 11 0 0 I 1 1

FIGURE 15 Input-output 5Igals for gates

FIGURE 1

A B C

Gates WIth mlltlple JnpUU

A B C lJ

~

if inPllt logic ~ts are satisfied Theinput signals xaDd y intheNDaadQR gates may exist in ~ oHow-possible states 00 10 11 or 01 Il1ese ibpu~ampignals_ shown inFig lStoshygetber with the corresponding output signal foreach PfCThI~tiaiug~iDustrate the reshysponse ofeaclt gate to the four input signal~The~llisofthetiminadiagram represents time and the vertical axis sbo~~~~ it cbapg~botwcen~possible voltshy

age levels The low level represents logic O tJte high level l1lteAND _ responds With a logic ~ ~tput sipl wh~ both input ~~)e 1middot1~ lIieOR S-~with a logic 1 outpUt signal ifanylnput sigrudis lOgic 1 TheNOTgateis~~ to BUll invedet The reason for~nameis~t froJn the signalmsponae inmiddottbe timitt8 diagramwhicbsbows that theoUtputsignal inverts the logic sense of tbeiDpUtsigll8l

AND and OR gates may bavei)lQte tbantwQinputs M AND8_~itti ~input$andan OR gate with foU) inputs are shown in Fig 16 The three-inPllt AND gate responds With logic 1 output if all tbreeinputs arelogic 11jleoutputproduces lOgic Oifanymput is logic O-The

four-input OR gate responds withlogic 1 ifany input is logic 1 its clu1ptltllCCoines logic oonly when all inputs are logic O

Answers to prvblems marked with middotappearaHbe ClOd ofthe ~

11 lJltthe octal and beXadecimalliurilbers trom16ui 32UdngA B1l1ld C forthebst~ digits Usttbe numbers from 8 to 28 in base13 bull

I

12t What is the exact D1Jllbcr of bytes in a system that contains lta) 32Kbytoe (b)64M ~and (e) 640 byte$ middot7 t

32 Chapter 1 Digital Systemsand Binary Numbers

13 Convert the following nu~bers with the indicated bases to decimal (a) (4310)s (b) (198hz (c) (735)8 (d) (525)6

14 Whllt is the largest binary number that can be expressed with 14 bits WhlIt are the equivaleDt ~~ iinal and hexadecimal numbei-s

--

15 Detemrine the base of thl1 numbers in each case for the following operatio~ to be correct (a) 142 = 5 (b) 5414 = 13 (C) 24+ 17 == 40

16 The solution$to the q~cequation xl - Ux +22 oare l1 3 arid x =6 What is the base of the numbers

17 Convertthehexadecimal ntmIher 68BE to bitiary and then convert it ~mbinary to octal

18 I Convert the decirpal number 431 to binary in tWo ways (a) Convertd~y to binary (b) conshyvert first to hexadecinla1 and then from ~decimalwbinary Which method is faster

19 amppress the following nqrnbersin decinud (a) IQ11O0101)z (b) (l65his (c)(2624)8 (d) (FAFA) 16

(e) (10101010)2

110 Convert the following binary numbers tobexadeoimal and todecitnal (a) UOOlO (b) 110010 Explain why the deCimal answer in (b)is 4 times that in (a)

111 Perform the followingdiviskmin binary 11 Ion + l()t

112 Add IlniImultiply tfle following numberswiihout converting them to decimal (a) Binary nuniberilOll aiIdlOh (b) He~uumbers 2E aDd 34

1~)( Do thefoHowing con~ersionproblems (a) CorivertCiecimal2731S to binary (b) CakUlate the binary eqUivalent (f 213 outto eight pl~Then Convert from binary to

imalHowgJose istbe result to 2131 (c) Convert the binary resukin (b) into hexad~ lb~oonvert ~result to decimal Is answer tbesame

114 Obtain the is 8nd 2s complementsofthe foUowing binaryDumbcentrs (aj l)()()(J()OO (b) OOOOOOOO (c) 11011010 (d)01l10110 (e) 10000101 (0 11111111

115 Find the 9s and the 10s complement of the following detimal numbers (a) 52734630 (b) 63325600 (c) 25000009 (d) 00000000

116 (a) Find the 16s complement of B2FA (b) Convert B2FA to binary (c) Find the 2scomplement ofthe resultin (b) (d) Convert the answer in (c)to hex~malandco~ with ihe an~wer in (a)

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 15: Chapter 01 - Mano

Sectlont6 SIgned8lnary NumberS is

Table 13 Slgtlfd Biliary Humbm

+7 +6

+5 +4 +3 +2 +l +0 0 -I

-2 -3

4 -5 -6 -1 -8

Olll 0110

0101 ( 0100

001l 0010 0001 0000

IIll 1110

nOI noo Ion 1010

1001 1000

OIll Oito eHOl OHIO OOU 0010 0001 0000 1111 1110middot dOl 1100 Ion

lOti 1001 1000

0111 OUO 0101

0100 0011 0010 0001 0000 1000 1001 1010 IOU 1100

1101 1110

lUI

Table 13 lists all possible four-bitsignedbinaryaumbers in the three representations The equivalent decimal number Is also shown for refelenoeNote that the positive n~ in all three representations are identicaland have 0 inthelefmostpcsiticm The signed2sshycompl~mentsystemhaironly onemiddotrepresentation for 0 which is always po$itive The other tw()systetns- mlve either a positive 0 or a negative 0 sometbingnoteDcounteredin ordinary arithmetic Note that all negative numbenhave alin the leftmost bitpositi~ that is the way we distinguish them from the positivenumbers With fout bits we can repreSent 16 binary numbers In the signed-magnitude aDd thelscomplement repre$eDtatipns there are eight positive numbers and eight negative numbers inciUdingtwo zeros In the2s-complement representation there are eight positive numbers includi0a one zerQ and eight negative numberS

The siped-m_gnitude system is used in ordiIlary arithmetic but is awkward when emshyployed in computer arithmetie becauIe of the ~parate bandIinJ bfthesipand the magnitude Therefore the signed-compiement systeni is normallyused The ls ~t imposes some difficulties and is seldom USedJor arithmetic openitiOns It is U$eful aSa lo~ operation since the change of 1 to Obrmiddot() to 1 is equivalent to a logical complement Operation as will be shown in the next c~The discussion~f sigiled binary ariduneti~ that fol10ws deals exshyclusively with the signe4-2soomplt_nt~tatJonQfnegadveilUlilbers hsame proshy

cedurescan beappJied to the sigMdrs-comPlemeD~Iysby incIudiOI tbe~arotmdcarry as is done with unsigned numbers

J6 Chapt~r 1 OlgltalSystlf(ns and Binary Numbels

Arithmetic Addition

The addition of two numbers in the signed-magnitudelYs_foUowsthe rules ofordinaiy arithshymetiC Ifthesi~s arethesam~we addthetwOtt~gni1U~~d ~vetbe sum the CCmmon sign Iftbe signs are diffe~nt we subtract tllcsmaUermagnitude frOtnlthe larF and give the differshyehtethe signof the larger magnitude For example (+25) +( - 37) = ~ (37 - 25) = -12 and is done by subtracung the smaller magnitude 25 from the larger magnitude 37and a~nding the sign of 37 tGtbe result Ibis is a process that requires a corripanson of the signs and magnitudes and then performing eithr additi()n or subtraction The same procedure applieato binary numbers in sigped-magnitude representation~Incontrast the rule for adding numbers in the signed-corppleme~ sy~tem does not require a comparison or su~ traction but only addjtion The procedure is very simple andcanbe stated as follows for binary numbers The 8ddltion oftwo signed binary numberS with negative numbers tepresented in signed- 2sComprement fonn is obtaiIled from theadditlooofthe two numbers includingtheii sign bits

AcentiirrY out oftbe sign-bitposition is diScacded NumerIcal e~aihpledotai1dition follow

+ 6 00000110 - 6 11UI0tO I

+13 00001101

+13 00001101 +19 00010011 + J 0Q900111 + 6 00000110 6 11111010 ~13 11110011 -1~l 11110011 7 illl1001 -19 11101101

I bull bull ~

Note that negative numbers musthil iriitially in 2seompkmentform and that if the swn ~ ~afterthladdit40nis negativeins in2s~p~t fOl1Jl - In each of thefoDrcasestlteoporationperfol1JlC(lis additionwitb the sign bit iilcluded Any catTY o~of~~-bit~onisdisc~ and negative resultsareButomaticallyin 2sshyromplementfoon

In order to obtain acOrrect answer we mustensQre that the result has a sufficient of bits to accommodate the swnlfwestartwith t~on-bltnumbers and tbeswn occupies n + 1bits we say tblltan overflow occurs~Wheri one perfotmStbc ad(JitiOJl with nllllIPTJllVIl

pencil aq overflow is not a preblem because we arcr noflimitecLbythewidth of the page jUst addanothcentr 0 to apositive number or another 1 toa negative number in the mOst cant positi()n to extend thenwnber to n+ 1 bitSand theQ perform addition Overflow is

problem in computers beqiusetbe number ofbi~~ bolla ~befis finite and a result ex~ tI1efinite val~e hy lcatmotbe accommodated

The compJement form of representiQg negativetlQUlbers is unfamiliar to those usedto signed-magnitude system To itetermine th~ value of II negatienumber insiped-2s COlIlpJe

mentit0is~ to CODVerttbe numbcr to apositie ntirit_ ~ place itiDa more formPor ~plethesig~binary number qUl00~ lii~egativebecausothe leftmost

t 1182s c0J8plemen~js~UlwhUhi$~ binaryeqqivalen of +7Wcmiddottherefore nize the Ori~nal ~atiy-eQumber to be equ~ lo-7 1

Sectlonl7 Bh1ary Codes 17

ArIthmetic SubtractIOn

Subtraction of two signed binafy numbers whe~negative numbersare in2s-complement form is simple and can be stilted as follows

Take the 2s complement of the5ubtraltend (including the sign bit) and add it to the minuend (including the sign bit) A cany oU1of thesignbit position is discarded

This prOCedure is adopted because a subtraction operation can be changed to an addition operation if the sign of the subtrahend is changed as is demonstrated by the following relationship

(plusmnA) ~ (-tB) = (plusmnA) + (-B) (plusmnA) - (-B) =plusmnA) + (+B)

But changing a positivetwober toa negative n~ber is eaampily done by taking the 2s compleshy mentof the pQsitive number The reverse is also tiUe~use theCOmPle~n~ of a negative numshyber in complement form produces the equivalent positive number To see this consider the sJlbtr~ction ( 76) -- (13) = +7 In binaIy_ with eight bits this ()peiationis written as (11111010 11110011) The subtracti~ri ischmlged ~ addition by taking the 2s complement ofthe subtrahend (-13) giving (+13) In binaly tbis~ 11 niOlO+ 00001101 = lOOOOOU1 Removing the end~ we obtain the ootrect answer ()()()()() III (+7)

Itisworth noting that binary DUmbersinthe signed-complement system are added and subshy tracted by the same basic addition and suPtraction rules as unsigned numbers Therefore comshyputersneed omy one common hardware circuit tobandle bothtypcs ofaritbtnetic The user or programmer ~ust interpret the reswtIi of $l1ch addition or subtraction differently depending on whether itisassumedtha~the numbe~ are signed ltr tinsigned

j

BINARY CODES

Digitalsystems use signalsthat have two distinct values1Uld circuit elements that havetwostashyble states There is a direct analogy anrong binary iignals binary circuitelements and binary digits A binary number ofndigitsfor example may be represented by n binary circuit eleshyments each baving an output sig~alequivalen1to Oor I Digital systems represent (Uld mashynipUlate not omy binary numbers but alsO many other diScrete elements of information Any discrete element of informatioIidlat is dis1iilct among agroup of quantities can be represented witha binary code (Le a pattern of Os and fmiddots) The codes must be in binary because in todays techIiology omy circuits that represent and manipulate patterns of 0s and ls can be manufactured economically foru~ in computers However it mtistbe realizCd that binary codes merely change the symbols not the meaning ofthe ele~nts of infonbationthat they repshyresent IT we inspect the bits of a computer at random we will find that mostofthe time they represent some tYPe of coded information rath~ than binlUY numbers

AIln-bit binary code is a groopofn hits that assumes up to 211 distinct cOmbinations of ls ~d Os with eacn combination representing one elementof tnt set that is being coded A set

of four elements clab becoded with two lilS with each ~lementassignedoneof thefoUowing bit oombinationsOOO I 10 J 1 A set of eight elements requiies a three-bit code 00 a set of

18 Chapter 1 Digital Systems and Binary Numbers

J6 elements requires a fourmiddotbit code The bit combination of ann~bit code is determined the count in binuy from 0 to 21t - t Each element must be assigned a unique binuy bit binationand no two elemerits cm havetbtsamevalueothenvisethe code assignment be ambigUous

Although the minimum nqrnber of 1lits required to code 21t distiItct quantities is nthere nomaximwn numbe( of bit that may he used for a binuy code For example the 10 digits can be coded with 10 bits and each decimal digit can be assigned a bit combination nine OSmid a 1 In this pamcularbinarycode the digit6 is assigned the bit )UllIUlauuu0001000000

BCDcode

Although the binary number systemis die ~ost natural system for a computer most people more accustomed to the d~imal system One way to resolve this difference is to convert

inlal nUmbers to binary perform all arithmetic calculations in binary and then convert the nary results back to decimal This metbodrequites that we store decimal numbers in

cOinputer so that they canbec6b~rted to binary Since the compllter Can accept only valueswe must represent the decimal digits by means ofa code that contains ls and Os also pOsSible lopedorm the arithmetic operlltiorisd1rectly on decimal numbers when they stored in the comput~ in cod~ct form

A binarycodewill have some unasSigned bit com~inatiqns ifthe num~rofelements in set is not amultiple power of 2 The 10decimai digits form such asel A biruuy code that tinguishes among 10 elements must coiltain at least four bits but 6otitofthe 16 possible binations remain unassigned Different binary code$ can bemiddotoNained by arranging four into 10 distinct combin~tions TheicodeIllcfflt oommonly used fdr the decimal digits is straight binary assf~ntlisted in Table 14 This scheil)eis called bittary~coded decimal

is commoolyreferred to as BCQ OtherdecimalcodesaIlfpossible and a few of them are sentedlaterinthis section

Table 14 BinarymiddotCoded Oeclmql (BCO)

Decimal BCD SnlboiDIgIt

o 0000 1 0001 2 0010

3 0011 4 middot0100 5 0101 6 0110 7 0111 8 1000 9 1001

Sectionmiddot 17 BInary COdes 19

Table 14 givesthe four-bit code for one decimal digit A number with k decimal digits will require 4k bits in BCD Decimal 396 is represented in BCD with 12 bits as 0011 10010110 with each group of 4 bits representing one decimal digit A decimalmiddotnumber in BCD is the

- same as itS equiyalent binary number only when the number is between 0 and 9 A BCD numshyber greater than lOJpoks different from its equivalentbinary number even though both con tainls and Os Moreover the binary Combinations 1010 thrpugh 1111 are not used arid have no meaning in BCD Consider decimal 18SlUld its corresponding value inBCD and bUtary

(185ho = (0001100001Ol)BCD = (l0111001h

The BCD value has 12 bits to encode the characters of the decimal value but the equivalent binary number needs only 8 bits It is obvious thatthe representation of a BCp number needs more bits than its equivalent binary value However there is an advantage in the use ofdecishymal numbers because compUterinput and output data are generated by people who use the decshyimal system

It is important to realize that BCD numbers are deCimal numbers and not binary numbers although they use bits in tbeir representation The only difference between a decimal number and BCD is that decimals are written with the symbOls 0 1 2 9 and BCD numbers use tbebinarycode 00000001 001O~ bull 1001The decimal value is exaCtly the same Dec~mal 10 is represented in BCD witheight b~ts as 00010000 and decitna1J5as 0001 01Of1lte corshyresponding binaryvalues are 1010 and 1111 and have only four bits

Consider the addition of two decimal digits in BCD together with a po~ible carry from a pre- vious less significant pair ofdigitsSince each digit does not exceed 9 the sum cannot be bull greater than 9 + 9 + 1 = 19 with the 1 being a previous carrySllppose we add the BCD dig-

its as if they were binary numbers Then the binary sumvill produce It result in the range from degto 19 In bin8ry thistange wil[be from 0000 to 10011 butin BCD it is frOm 0000 to

I 1001 with the first (ie leftmost) 1 bemg a carry and the next fo~ bits being the BCD sum When tPe binary sum is equalto or less than 1001 (withaut 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 (0110h to the binary Sum cOnverts it to the correct digit and also produces a catTy as required This is because a carry in themost significant bitposishytion of the binary sum and a deCimal carry differ by 16 10 = 6 Consider the following three BCD additions

4 0100 4 0100 8 1000

+S +0101 +8 +1000 +9 1001 9 1001 12 1100 17 10001

+0110 +0110----

10010 10111

In each case the two BCD digits are added as if they were two binary numbers If the binary sum is greater than or equal to 1010 we add 0110 to obtain the correct BCD sum and a carry In the flIst example the sum is equal to 9 and is the correct BCD sum In the second example

20 Chapter 1 Digital Systems and BInary Numbers

the binary sum produces an iJlv~ BCD digit The addition of0110 produces the cortect BCD sum 0010 (ie the number 2) and acanyInthetbirdexample the binalY SUDlproduces acany This condition occurs wben the $W)) is greater than or equal to 16Altbough the other fout are less than 1091 the binary 9Ulll requires acOnectionbecause of die carry Adding 0110 obtain thetequiled BCD sum 0111 (ie the numblaquo 7) and 8 BCD CiUT

The additionoftwondigit unsipedBCD numbers follows the same procedure COIlSioll the addition of 184 + 576 1= 76() in BCD

BCD 1 I 0001 10000100 184

+6101 ~

0111--- 0110 +576

lJinarysum 0111 10000 1010 Add6 ono 0110

BCDsun 0111 0110 0000 7(1)

The flfSt l~ sigDiticant pili- of BCD digits produces aBCDdigi~SllDlof 0000 and a for the next pair of digits the second parr or BCD digits plus a ~Vi0U8 cany produces a sum of 0110 and a carry for the next patr()fdigits The third pair of digits plus acarry proltIUC~ a binary s~ of 0111 and does not require a correction

Decimal Arithmetic The represeiltation of signed decimal numbers in BCD is simiiarto the tepresentation of numbers in binaryWe can useeitheI the familiar signed-magnitude system at the SllZllOO-COI1I

plemelit system The sign of a decimal number is tJSually represented with four bits to to thefour-bit code ofthe decimal digits Itis customary to designate 8 plus With four Os 8 minus with the llCDequivalent oi9 whlcq is 1001 The sigiled~magnitudesystem is seldom used in com~tersThe signed-complerDem ~~ either the 9s octhe 10s complement put the lOscomplement is the one most useP To obtain the lOs complement of aBCD numberwe first take the 9s complement then add 1 to the least significant digit The 9s Complement is calculated from the subtracloo of each digit from 9

The prltXeduresdevelope4 for the signed-2s-complement system in the ~vious also apply to the signed-IOs-complement system for decimal mimberS Addition is done summing all digits including the sign digit and discafding the end carry This operatiQ assumes that all negative numbers are in 10s-complement form COOsider the (+375) + (-240) == + 135 done inthe signed-complement system

o 375

+9 760middot

o 135

lhe 9in the leftmost pOsition of the second n~ber tepresents a minllS and 9760 is the complement o( 0240 The two numbers are added and tbe end carry is discarded to +13SOfcourse the decimal ntmlbers insi~ tile computer includingthe sign digits in BCD The addition isdone with BCDOigits as described previously

Sectionl 7 Binary Codes 21

The suQtr8ction of decimalliUJ1lbets either unsigned or in thesi~-~Oscomplement systetn is the sameu in the binary case Taketbe 10s ootnplementof the subtrahend and add i~ to themin~nd ManyooDlputerslULvespeciaJ hardware to perform arithmeticcalculations directly withdecilnal oumbers in 8tDThe~u$etofthecoBlPuter can specify programliled Wtnlctionsto JOdonn the aDtiuJletiP oPmwoowithdeQmal n1UQ~ ~ywithout having to convell them to binary

Binafy codes for decimal digits requirea minimum of four bits per digit Many different codes can be formulated by~gjng four bits into IQ distinct combinations BP) and three other representative codes are shown in Table L5 Each code uses only 10 out ofa pOssible middot16 bit combinations that can be arranged with four bits The other six Unused cOmbinations have no meaning amt should be avoided BCD and the 2421 code are examplesofweigbted codes In a weigbtedcodeeach bit position

juBsigned a weighting f~in~awaythat eaehdigitcanbe ev~by 8dding the wei~ oran the lsin thecoded combination The BCD code has weights of8 42 and I which cotteshy

spondiothe powe1Of-two valuesofeaCh bitTbebitasSignmeatOll0 for example is interpreted by the weights to represent dedma16beCause 8 X 0 +4xt +2 Xl +IX 0 6Thebit combination 1101 when weighted by the ~ve digits 2421 gives themiddotdeCimal equivalent of 2 X I +4 gtlt I + 2 KO + 1 X 1 = 7 Note that some digits cantle coded in lw9 possib)e

ways in the 2421Q)(feFOr inke decimal 4 can be asSigned to bitCombinadon 0100 or 1010 since botbcOmbinatibns add upto a totalweight of4

middot1$ Fou Dlf(et Blnqry Code$ for thtJledmol DIgits

~ IICD DIgIt sal MZt Exeet) 8 4 -~1

0 1

000() middotmiddotmiddot0000 001)1 0001

oem 0100

0000 0111

2 0010 0010 0101 0110 3 0011 OQU 0110 0101

4 0100 0100 0111 oroo 5 0101 lOll 1000 1011 6 OlIO middot1100 1001 1010 7 middot0111 1101 1010 J001 8 1000 IUOmiddot 1011 1000 9 1001 11U 1100 1111

1010 oloi 0000 0001 Uaused IOU 0110 middotOOOl 0010 bit 1100 0111 0010 0011 combishynations

nOl 1110

lOW 1001

HOI 1110

1100 1101

1111 IOU) 1111 1110

22 ChaptfrliDfgltalSystemsaod Btoary Numbers

I1te 2421 rind the

e~l3~es are exampks Of self-complementing codes Such codes have~propertyjbatthe9s~plement ofa deCimal nfunberigobtairted directly by chang-

ing 1$ to O~$ finO tYSCfb1 sie~bycomple~mmgeaCh bit in the pattem)For example decshyimat3~Sis re~ fu tbeexcess3code as 01101100 1000 The 9s compl~ntof 604 isrepRse~l00liOOllelliwbich isobiainc(himply by complementing each bit of the

code (as with the 1 s coinpl~ofbin~rillDlbers)middot Theexcess~3code has been used in some oldel coritputers because of its selfcpmplement~

ing property Excess-3 is an unweighted code inwhich each codedcombinationis obtained-fJQm the corresPonQing bin3ryvalueplus 3 Note that the BCD code is1~ self-complementing TheS 4 ~~ Icode isan example of assigning both positive and negative weights to ~ decimalcodeInthis case the bit combiDation 0110isin~reted as oecimal2 and is calcu-

latedfrom8XO+4X 1 + (2) X 1 + (1XO=2 ~

Cra Code _ _ J

l1te output data QfmaJlfpbYsicaimiddot $)ShmlS are quantities that are continuous These data bemiddottonverted~digiWforuitJefore they art applied toaliigital system Contfuuous or ~nisCOIl~middotUitodigitalfonn bymeans of an rumlog~digitalConverter It is times ~~ent tousethe Gray code slown inTable 16torepresehtdigiuU data that have oon~ fMn8D8l08 dasaTheadvantage of th( Gray cOOeover thesllaigbt binary nIl11l1hPt~

~lt~thatoWY~ hit in the codegroup changeSin going from one number to the For examplcentbullin-goingfrom 1 to 8dleGray code cblngesfrom 0100 to 1100Only the fust changesfromOto l~the odter~ I)its mnaintbesame By contrast With binary numbers change from 7 to 8wrube from 0111 to lOOOwhich causes allfciur bits to change valUes

TabielAi GtPyCode

01 Decl COde Equivalent

~ 0000 0001 0011 OOlG 011Q Olll OlO 0100 1100 11m 1111 1110 lOlQ 1011

lOOt i

1000

o 1 ~ 3

4 5 6 7 8 9

10 11

12 13 14 15

SectIOnl7 BlnarYCod~s 23

The Gray code is used in applications in which the normal sequenceOrbiruuy rium~may produce an error orambiguitymiddot during themiddot transitionfrom ODeDWDber to the next If binary numbersareusec1 acbange forexaJIlple nom 0111 to 1000 may produce anintermediateershyroneous number 1001 if the value ofthe rigbtmost bit takes longer to -change than domiddotthe valshyues of the other three bits The Graycode elimb1ates this problem since only one bit changes its valve dUrlng aily transition be~een two numbers I

Atypical appli-cation ofmiddotthe Gray code is the representation of analog data by a Continu ous change in the angUlar position of a shaft The sQaftmiddot is partitioned into segments ana each segment is assigned a number If adJacent segments are made to correspond with the Qray-Codesequence ambiguity is eliminated between the angle of thesbaft and the value encoded by the sensor

Character Code

Many applications of digital computers require the handling not only ofnumberS but also of other characterS or symbols such as the letters of the alphabet For mstancean insurance comshypany with thousands of policyholders will use a computeX to process its files To represent the names and other pertinent information it is necessary to fonnulate bull binary code for the letshyters ofthe alphabet In additiQt1 the same binary qode must represent numerals and special Characters (such as $) An a1phanumeric character setis a set ofeiements that inclUdes the 10 decimal digits the 26leuersofthealp1iabe and a nutnbeof special~S~ a set conshytains between 36~d 64 elements ifonIy capital letters areincltided or between 64 and 128 e1eJDents ifboth uppercasemiddot and lowercllle etters are inclUded In the first case we need a bi- nary code ofsix bits and in the second we need a binary cooeO(seVM bits

The standaM binary code for the alphanumeric char8cters is the American Stahdard Code for Information InterCbange (A~n) which uses seven bitS to code 128 characters asshoWn in Table 17 The seven bitsof the code are desipted by b~through h With h the mostsigshynificant bit ~e leUer A for example is represented inASCn as l(l()()()Ol (column l00~tOw 0001) The Ascn ()()de also contains 94 graphic characters that can be printed and 34 nonshyprinting characters used for variQUS control functions The graphic characters consist of the 26 uppercase letters (A through Z) the 26 lowercase letters (a through z) the 10 numerals (0 through 9) and 32 special printable characters suchaS andS

The 34 control characters are designated in the ASCTItable With abbreviated nalne8 They are listed again below the table with their functional names The control characters are used fQr routing data and arranging the printed text into a prescribed format~ There are three types of control characters format effectors information separatOrs andcommumc~on-COnlrpl char~ IlCters Format effectors are characters that control the layout ofprinting They inciude the fashymiliar word pr6cessorand typewriter controlssucb 8$ bac~pace (BS) horizontal tabulation (HT) and carriage return (CR) Information separators are used to separatetbe data into divi~ sions such as paragraphs and pages Theyinclude characters such as ~ordseparator (RS)and file separator (FS)The cODlIDunication-control characters are uSefulduriDgthe transmission of text between remote tenninals EXllll1plesof conlmunicatiOn(ODtiol~ are STX (start oftext)-and ETX (end of text) whicb are used toframe a text mesaagetnQlSlnitted through telephone wires

24 Chap~er 1 Diglt8l Systems and Binary Numbers

rblel7 Amerkcm5tandard Code for Information (nterclHlnge(ASCII)

b~jbzb 000 001 010 on 100 101 no 111

0000 NUL )jLP SP () p P 0001 SOH OC1 1 A Q a q

R0010 STX OC2 2 B b r 0011 ETX DC3 3 C S Ii S

0100 EDT 0C4 $ 4 D~ T d t 0101 ENQ NAK 5 E iU e u OUO ACK SYN amp 6 F V f v 0111 BEL ETB 7 0 W g w 1000 B8 CAN ( S H K h x 1001 HT EM ) 9 I Y Y 1010 LF SU~ 1 Z j z lOll VT ESC + 1lt r k UOO FF PS lt L I I 1101 Cit OS == - M 1 m 1110 SO R~ N 1 n shy

-0PIt st US f 1 0 0 DEL

r- Control characten

NUL NlI]l DlE Data-inkescape SOH Start of hea~ng DC1 Device cOntroll STX Start of text DC2 DevIce io~1lOi2 ETX End (Jftext i DC3 Device corUlri1 3 OOT End oftraIlsmission ~4 DeVicecoQtrol4

ENQ ampqwry NAK Negativeackilowledge ACK

Acknowledge SVN Sync~nous idle

Btl Bell ETB End-of-tmnsnussionblOck sS Backspace CAN CanCel HT Horizontal tab EM End of mediUrlt LF Lintifeed SUB Substitute VT Vertical tab ESC escape FF form feed FS File separator CR Carriigeretum GS Group separator SO shift Ollt RS Reoord sepuator SI Shlftin US Unit separator SF S~e DEL Delete

ASCII is a seven-bit codebutrnostcompUters manipulate anejght-bit quantity asa unit called a byte Therefore ASCII characters most often are stored ~e per byte The

I biti~sometimesused forotlef purposes depending ontheapplicatio~lFor example printetS recognize eightmiddotbit AScn chaiacterS with themost sigoificaot bit ~twO An atkJlitlo

Section 18 Binary Storage and Registers 2S

128 eight-bit characters with the most significant bit set tol are used for other symbols such as the Greek alpbabet or italic tyIe font

Error-Dtectlng Code

To detect errors in data communication and processing aneigbth bit is sometimes added to the ASCll cbaracter to indicate its Panty Aparitybit is an extra hit included with a message to make the total num~ of ls either even or odd Consider the fo119wing two cbaracters and their even andodd parity

With even parity With odd parity Ascn A = 1000061 01000001 11000001 ASCI( T == 101deg100 11010100 01010100

1

- Ineacb casewe insert an extra bit in the leftmost position of the code to produce an even number of 1 s intQe cbaraeter for even parity or an odd number of 1 s in the character for odd parity In generlll one or tbe oth~r parity i~ adopted with even parity being more common

The parity biqsbelpful in detecting errors during the transmission ofinformation from one location to another nisfuJictiOD is bandIed by generating an even parity bit at the sending end for ~h character The eight-bit characters that include parity bits are transmitted to their desshytination The parity ofeachebaracter is thetichecked at the receiving~nd If the parity of the received cbaracter is Dot even then at1east on~bit has changed value dUring the trmlsmission This method detects one three or any odd combination of errors in each character tb8t is transshymitted An even combination oferrors however goes undetected and additioDaterror detic- shytion codes may be needed to take care of that possibility

What is done after an errQlis detected depends on the partieu~ application One possishybilityis to request retransrois~ion of the message on the assump~on that tbeenigtr was ranshyd()m andwill not occur again Thus if thereeeiverdetects a parityerrorit sends bai~ the ASCII NAK (negative acknowledge) control cnaracter consisting ofail even-parity eight bits lOOlOl01H no error is detectedthe ~iversends back anACK (aCkno~ledge) conshytrol character namely 0000011 O The sending end will respond middotto an NAK by tranSmitting the message again until the correct panty is received Ifmiddot after a number of attempts the transmission is still in error a message can be sent to the Operatai to check for malfunctions in the transmission path

BINARY STORAGE ANORECiISTEIlS

The binary infonnation inadigitalcomputermust have a physical e~stencein some medium for storing individual bits A binary cell is a device that possesses two stable sttes and is cashypable of storing pne bit (0 or 1) oflnfotlllation The input to tbe cell receives exciJation sigshynals that set it to one of the two states The output of the cell isa pbysicalquantity that distinguishes between the two states The irtformationstored in Ii cell is 1when the cell is in one stable state and degwhen the Cell is in the other stable state

26middot Chapter 1 Digital Systems and BtnaryNumbers

Registers

A register is a group of binary cells A register with n cells can store any discrete quantity of middot information thatcontains n bits The state ofa registeris an n-tuple ofls middotand Os with each bit designating the state of one cell in the register The C()ntent ofaregister is a function of the int~rpretation given to tbeinformation stored in it Consider fQf ex~ple a 16-bitregister with the following binary content

11 00001111001001

middot Aregjs~ with 16 cells can be in one of 216 possible statesIf one asstimesthat the content cif the register represents a binaryinteger then the register can store any binarydumber from Oto 216 - 1 For the patticularexample shown the content ofthe register is the binary equivshyalent(lftbe decimal number 50121 If one assumes instead that the register stores alpbanushy

middot meric characters of an eight-bit cooe then the content of the register is any two meaningful characters For tht ASCII code with anevenplirityplaced in the eighth most significant bit position the register contains thetwo charactersC (the lefunosteightbits) and I (the rigbt~ most eight bits) If however one in~rprets the content of the register to be four decimal dig- its represented by a four-bitcode tnenthe content of the register is a four-digit decimal number In theexcess-3 code the register holqs the decimal nutriber 9096 The content of the registe~is meaningless in BCD becau~e the bit combinatiOn ltob is 110t assfgned to any decshyimal digit From this example it is clear that a register can store discrete elements of inforshymation and that the same bit configuration Inay beinterpreted dlffe(ently for different types of data

tmiddotmiddotReglsterTrail Adigitalsystenlis characteriZed by its registers and the components thatpetfolin data proshy~ssingIIl digital sy~tems a rcentgister tra1lsfer operation is abasi operation that consists of

middot a transftr of hiJWy hUormation from one ~t of registers into ano$er set of registers transfer may be dir~ctfr9m one regist~r toanlt)ther or may pass througb datamiddotprocessing circuits to petformaD operation Figure L 1 illustratel the transfer of iidOrnuttion among regshyisters anddemonstratespictorlallY [the tr8ll~~ ofbinaryinformation from akeyboard a register in the memQryullit Thehlputunit~s assumed to have a keyboard1 control cuit and aninput register Each time a key is strock the control circuit enters an ImnV$_

lent eight-bit alphanumeric character coqe into the input register We shall assume that code used is the ASCII code with an odd-parity bit The information from the input regisshyter is transferred into the eight-least significant cells Qf a proeessOr register After transfer theinpui register is cleared to enable the control to insert a new eight-bit when the keyboard is struck again Each eight-bit character transferred to the pro1c4ess(raquo register is preceded by a shift of the previous character to the next eight cens on its left~

middot a transfer -of four characters is completed the processor registeris full and its contents transferred into a memory register The content stored in die memOry register shown in Figl came from the transfer of the characters J 0 H an~ N aftet the four ap)lroJ)riatt keys were struck

Section 18 Binary Storage and Registers 27

FIGURE 11 Transfer of information among registers

To process discrete quantities of infoiniatiori in binary form a computer m~st be promiddot vided with devices that hold the (lata to be processed and with circuit elements that manipmiddot ulate individual bits of irifonnation The device most commonly used for holding data is a register Binary variables~ manipulated by means of digital logic circuits Figure 12 il~ luslrates the process of adding two l()bit binary iUlmbers Themeniory unit which no[shy

mally consists of millions of registers is shown with only three ofits registers Thepait of the processor unit showncoDsistsmiddotofthree registers-RI R2 and R3~getherwith digital logic circuits that manipulate the bits of RI and R2 and transfer into R3 a binary number equal to their arithmetic sum Memory registers store information and are incapable of pr0shy

cessing the two operands However th~ information stored in meDij)iybanbetransferred to ~ processor registers and the resUlts obtainedin processor tegisters can be transferred back into ame~ry register for storage Untill)ecded again The diagram ~wsthe90ntents of two

operands transferred from twoJDemoryregisters into RI imd R2 The digital logic circuits produce the sum which is transfened to register R3 The contents of R3 can now be 1riUlsshyferredback to one of thetnemory registers

The last two examples demonstrated the infonncion-flow capabilitieSofa digital system in a simple manner Themiddot registets of the ~ystem are the basic ele~ents for Noring and holding the binary information~igitallogic circuits process the binary ihfonaation stored in the

28 Chapter 1 DigIt bullbull Systems and Binary Numbers

Sum

FIGURE 12 Eumple of blnarylnfonn~t1on processing

registers Digitallogiccirctiits and registers are covered InChQpteB 2 throQgh 6 The metlilOlY unit is ~xPIained ill 9aptet 7 Th~ descriptton of register opetJtions at the register level and the design of digital systems are covexed in Chapter 8

19 BINARY LOGIC

Binary logic deals with variables th~ take on two discrete valueund withoperations that sumelogicalmeaning~ The two val~s the variableussume may be called~ydifferent (true andalse yel and no etc) but for ourp1llpQSe it is cpqVenienttotbink in terms of and assign the values llUld O The binary logic intr0ducedin this section is equivalent to algebra oalledBoolean algebra The fannal presentation ofBoolean algebra is covered in detail in Chapter 2 The purpose ofthis seCtion is to introduce Boo algebra ina matmerandlate it to digitallogiccircuits andmiddotbinarYsignalsmiddot

Section 19 Sinary logic 29 ~

Itkltn of IInary logic

Binarylogic consists of binary v~les and a set of logica1middotoperatiQDS The variables are desigshy ~by lettell of thCalplWlet~such asA B C x yz etc with eaCh variable baving two and oniy

two distinct posSible valueS 1and O There are three basic logical operations AND ORand NOT

1 AN]) This ~peration is represented by adotorby the absence ~f an oPerator For example x bull y =z or xy = zis~ x ANDy is equalto z~ThelogicaloperationAND is interpreted to mean that z == 1 ifand only ift~ land y = 1 otherwise z = O (Reme~r that x y andzare binary v8riablesand canmiddotbe equal either to 1 or Omiddotand nothing eise)middot

2 OR This operation IS represented by a plus sign For example x + y =z is read x OR y is equal to z meaning that z 1 if x = iorif y = lorifbothx= 1 and y = 1 If bqth X - 0 andY Omeo z= O

3bull NOT This operation is repf6sented by a prime (sometimes by an overbar) For ~xample x =Z (or~ =z) is read notdsequalto 1 meiming that z iswkatx isnot In other

words ifx = 1 then z == 0 but if x == 0 tnenz = L TheNOT operationisals(1 reshyferred tolls the complement operation since it changes ~ 1 toOand a O to 1

bull bull lt Binary logic resembles binary arithmetic and themiddot9peratioos ANDahd OR have similarishy

ties to multiplication and addition respectively In fac~ the symbols used for AND and OR are the same as those used for multiplication and addition However binary lOgic should not be conshyfused withbinaryarithIrietic One should realize thatan arithmetic variable designates a numshyber that may consist of many digits A logicmiddot variable is always either 1 or O For example in binary arithmetic we have I +1 =10(read~one plus ()fie is equal to 2) whereas in binary logicwe have 1 + 1 1 (read one OR onds equal to one)

For each combination of the values oix and y bullthere isa value of ~ $pecifiedby the definishytion of the logical operation D~linitiops of logical~perations maybe listed in a compacHorm called truth tables A truth table is atable of anpbssible combinations ofthe variables $howshying the relation between the values that the variables may take and the resultof the operation The truth tables for th~ operations ANDand OR with variables x and y are obtained by lis~ng

all possible values that the variables may have when combined in pairs bull For each combination the resUlt of die operation 18 theillistedin a separate row The truth tables for ANDORand

NOT are given in Table La These tables clearly demonstrate the definitionf the operatibns

Table 18 Truth TcibJts of Logical Operations

AND OR NOT

x y xmiddoty x y x+y

0 0 0 0 0 0 1 0 0 1

10

1 0 d 1 0 1 I 1 1 1 1 1

bull~lt~m

30 Chapter 1

Logk Gates

Digital Systems and Binary Numbers

Logic gates are electronic cirellit that operate on ~

variable

or mpre mput tignals to produce an output signal Electrical signals sUch as voltages orrutrents exist as analog signals having values over a given taDgebull saYOt03 V but in a digital system are interpreted to be either of two recognizable values 0 or 1 Voltage~opetated logic Circuits respond to two separate voltshyage levels that represent a binary varjable equal to logic I bt logic O For example a partic- ular digital system may define 10gicOas a signal equal to 0 volts lind logic 1 asa signal equal to 3 volts In practice each voltage levelhiS an acceptable rangeas shown in Fig 13

The input te~nals of digital cikuits accePt binary signals within the allowable range and respond at the output terininals with binary signals that fall within the specified range The intermediate region between the aJl()wed regions is crossed only during aState transition Any desired information for computing or control can be operated tm by passing binary signals through variQUS combinatioDsof logic gates with each signal represebting a particular binary

The graphic symbols used to deSignate themiddotthree types of gates are Mown in Fig 14 The

gates are blocks of hardware that prooocc tbeequivalent of1ogic~1 orlogic() output signals

Volts

- FGURl13

x

y

Exampleof binary slgnaJs

Signal ratlge for logieO

(a)~omiddotinput AND gate

FIGURE 14 SymbOls for digital logic circuits

(c)NOT gate or invert~

Problems 31

x-lU 1 11 P 0

y 0 0 11 1 ~

ANDxy 0 0 rTl 00

ORX+Y~ NOT x 11 0 0 I 1 1

FIGURE 15 Input-output 5Igals for gates

FIGURE 1

A B C

Gates WIth mlltlple JnpUU

A B C lJ

~

if inPllt logic ~ts are satisfied Theinput signals xaDd y intheNDaadQR gates may exist in ~ oHow-possible states 00 10 11 or 01 Il1ese ibpu~ampignals_ shown inFig lStoshygetber with the corresponding output signal foreach PfCThI~tiaiug~iDustrate the reshysponse ofeaclt gate to the four input signal~The~llisofthetiminadiagram represents time and the vertical axis sbo~~~~ it cbapg~botwcen~possible voltshy

age levels The low level represents logic O tJte high level l1lteAND _ responds With a logic ~ ~tput sipl wh~ both input ~~)e 1middot1~ lIieOR S-~with a logic 1 outpUt signal ifanylnput sigrudis lOgic 1 TheNOTgateis~~ to BUll invedet The reason for~nameis~t froJn the signalmsponae inmiddottbe timitt8 diagramwhicbsbows that theoUtputsignal inverts the logic sense of tbeiDpUtsigll8l

AND and OR gates may bavei)lQte tbantwQinputs M AND8_~itti ~input$andan OR gate with foU) inputs are shown in Fig 16 The three-inPllt AND gate responds With logic 1 output if all tbreeinputs arelogic 11jleoutputproduces lOgic Oifanymput is logic O-The

four-input OR gate responds withlogic 1 ifany input is logic 1 its clu1ptltllCCoines logic oonly when all inputs are logic O

Answers to prvblems marked with middotappearaHbe ClOd ofthe ~

11 lJltthe octal and beXadecimalliurilbers trom16ui 32UdngA B1l1ld C forthebst~ digits Usttbe numbers from 8 to 28 in base13 bull

I

12t What is the exact D1Jllbcr of bytes in a system that contains lta) 32Kbytoe (b)64M ~and (e) 640 byte$ middot7 t

32 Chapter 1 Digital Systemsand Binary Numbers

13 Convert the following nu~bers with the indicated bases to decimal (a) (4310)s (b) (198hz (c) (735)8 (d) (525)6

14 Whllt is the largest binary number that can be expressed with 14 bits WhlIt are the equivaleDt ~~ iinal and hexadecimal numbei-s

--

15 Detemrine the base of thl1 numbers in each case for the following operatio~ to be correct (a) 142 = 5 (b) 5414 = 13 (C) 24+ 17 == 40

16 The solution$to the q~cequation xl - Ux +22 oare l1 3 arid x =6 What is the base of the numbers

17 Convertthehexadecimal ntmIher 68BE to bitiary and then convert it ~mbinary to octal

18 I Convert the decirpal number 431 to binary in tWo ways (a) Convertd~y to binary (b) conshyvert first to hexadecinla1 and then from ~decimalwbinary Which method is faster

19 amppress the following nqrnbersin decinud (a) IQ11O0101)z (b) (l65his (c)(2624)8 (d) (FAFA) 16

(e) (10101010)2

110 Convert the following binary numbers tobexadeoimal and todecitnal (a) UOOlO (b) 110010 Explain why the deCimal answer in (b)is 4 times that in (a)

111 Perform the followingdiviskmin binary 11 Ion + l()t

112 Add IlniImultiply tfle following numberswiihout converting them to decimal (a) Binary nuniberilOll aiIdlOh (b) He~uumbers 2E aDd 34

1~)( Do thefoHowing con~ersionproblems (a) CorivertCiecimal2731S to binary (b) CakUlate the binary eqUivalent (f 213 outto eight pl~Then Convert from binary to

imalHowgJose istbe result to 2131 (c) Convert the binary resukin (b) into hexad~ lb~oonvert ~result to decimal Is answer tbesame

114 Obtain the is 8nd 2s complementsofthe foUowing binaryDumbcentrs (aj l)()()(J()OO (b) OOOOOOOO (c) 11011010 (d)01l10110 (e) 10000101 (0 11111111

115 Find the 9s and the 10s complement of the following detimal numbers (a) 52734630 (b) 63325600 (c) 25000009 (d) 00000000

116 (a) Find the 16s complement of B2FA (b) Convert B2FA to binary (c) Find the 2scomplement ofthe resultin (b) (d) Convert the answer in (c)to hex~malandco~ with ihe an~wer in (a)

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 16: Chapter 01 - Mano

J6 Chapt~r 1 OlgltalSystlf(ns and Binary Numbels

Arithmetic Addition

The addition of two numbers in the signed-magnitudelYs_foUowsthe rules ofordinaiy arithshymetiC Ifthesi~s arethesam~we addthetwOtt~gni1U~~d ~vetbe sum the CCmmon sign Iftbe signs are diffe~nt we subtract tllcsmaUermagnitude frOtnlthe larF and give the differshyehtethe signof the larger magnitude For example (+25) +( - 37) = ~ (37 - 25) = -12 and is done by subtracung the smaller magnitude 25 from the larger magnitude 37and a~nding the sign of 37 tGtbe result Ibis is a process that requires a corripanson of the signs and magnitudes and then performing eithr additi()n or subtraction The same procedure applieato binary numbers in sigped-magnitude representation~Incontrast the rule for adding numbers in the signed-corppleme~ sy~tem does not require a comparison or su~ traction but only addjtion The procedure is very simple andcanbe stated as follows for binary numbers The 8ddltion oftwo signed binary numberS with negative numbers tepresented in signed- 2sComprement fonn is obtaiIled from theadditlooofthe two numbers includingtheii sign bits

AcentiirrY out oftbe sign-bitposition is diScacded NumerIcal e~aihpledotai1dition follow

+ 6 00000110 - 6 11UI0tO I

+13 00001101

+13 00001101 +19 00010011 + J 0Q900111 + 6 00000110 6 11111010 ~13 11110011 -1~l 11110011 7 illl1001 -19 11101101

I bull bull ~

Note that negative numbers musthil iriitially in 2seompkmentform and that if the swn ~ ~afterthladdit40nis negativeins in2s~p~t fOl1Jl - In each of thefoDrcasestlteoporationperfol1JlC(lis additionwitb the sign bit iilcluded Any catTY o~of~~-bit~onisdisc~ and negative resultsareButomaticallyin 2sshyromplementfoon

In order to obtain acOrrect answer we mustensQre that the result has a sufficient of bits to accommodate the swnlfwestartwith t~on-bltnumbers and tbeswn occupies n + 1bits we say tblltan overflow occurs~Wheri one perfotmStbc ad(JitiOJl with nllllIPTJllVIl

pencil aq overflow is not a preblem because we arcr noflimitecLbythewidth of the page jUst addanothcentr 0 to apositive number or another 1 toa negative number in the mOst cant positi()n to extend thenwnber to n+ 1 bitSand theQ perform addition Overflow is

problem in computers beqiusetbe number ofbi~~ bolla ~befis finite and a result ex~ tI1efinite val~e hy lcatmotbe accommodated

The compJement form of representiQg negativetlQUlbers is unfamiliar to those usedto signed-magnitude system To itetermine th~ value of II negatienumber insiped-2s COlIlpJe

mentit0is~ to CODVerttbe numbcr to apositie ntirit_ ~ place itiDa more formPor ~plethesig~binary number qUl00~ lii~egativebecausothe leftmost

t 1182s c0J8plemen~js~UlwhUhi$~ binaryeqqivalen of +7Wcmiddottherefore nize the Ori~nal ~atiy-eQumber to be equ~ lo-7 1

Sectlonl7 Bh1ary Codes 17

ArIthmetic SubtractIOn

Subtraction of two signed binafy numbers whe~negative numbersare in2s-complement form is simple and can be stilted as follows

Take the 2s complement of the5ubtraltend (including the sign bit) and add it to the minuend (including the sign bit) A cany oU1of thesignbit position is discarded

This prOCedure is adopted because a subtraction operation can be changed to an addition operation if the sign of the subtrahend is changed as is demonstrated by the following relationship

(plusmnA) ~ (-tB) = (plusmnA) + (-B) (plusmnA) - (-B) =plusmnA) + (+B)

But changing a positivetwober toa negative n~ber is eaampily done by taking the 2s compleshy mentof the pQsitive number The reverse is also tiUe~use theCOmPle~n~ of a negative numshyber in complement form produces the equivalent positive number To see this consider the sJlbtr~ction ( 76) -- (13) = +7 In binaIy_ with eight bits this ()peiationis written as (11111010 11110011) The subtracti~ri ischmlged ~ addition by taking the 2s complement ofthe subtrahend (-13) giving (+13) In binaly tbis~ 11 niOlO+ 00001101 = lOOOOOU1 Removing the end~ we obtain the ootrect answer ()()()()() III (+7)

Itisworth noting that binary DUmbersinthe signed-complement system are added and subshy tracted by the same basic addition and suPtraction rules as unsigned numbers Therefore comshyputersneed omy one common hardware circuit tobandle bothtypcs ofaritbtnetic The user or programmer ~ust interpret the reswtIi of $l1ch addition or subtraction differently depending on whether itisassumedtha~the numbe~ are signed ltr tinsigned

j

BINARY CODES

Digitalsystems use signalsthat have two distinct values1Uld circuit elements that havetwostashyble states There is a direct analogy anrong binary iignals binary circuitelements and binary digits A binary number ofndigitsfor example may be represented by n binary circuit eleshyments each baving an output sig~alequivalen1to Oor I Digital systems represent (Uld mashynipUlate not omy binary numbers but alsO many other diScrete elements of information Any discrete element of informatioIidlat is dis1iilct among agroup of quantities can be represented witha binary code (Le a pattern of Os and fmiddots) The codes must be in binary because in todays techIiology omy circuits that represent and manipulate patterns of 0s and ls can be manufactured economically foru~ in computers However it mtistbe realizCd that binary codes merely change the symbols not the meaning ofthe ele~nts of infonbationthat they repshyresent IT we inspect the bits of a computer at random we will find that mostofthe time they represent some tYPe of coded information rath~ than binlUY numbers

AIln-bit binary code is a groopofn hits that assumes up to 211 distinct cOmbinations of ls ~d Os with eacn combination representing one elementof tnt set that is being coded A set

of four elements clab becoded with two lilS with each ~lementassignedoneof thefoUowing bit oombinationsOOO I 10 J 1 A set of eight elements requiies a three-bit code 00 a set of

18 Chapter 1 Digital Systems and Binary Numbers

J6 elements requires a fourmiddotbit code The bit combination of ann~bit code is determined the count in binuy from 0 to 21t - t Each element must be assigned a unique binuy bit binationand no two elemerits cm havetbtsamevalueothenvisethe code assignment be ambigUous

Although the minimum nqrnber of 1lits required to code 21t distiItct quantities is nthere nomaximwn numbe( of bit that may he used for a binuy code For example the 10 digits can be coded with 10 bits and each decimal digit can be assigned a bit combination nine OSmid a 1 In this pamcularbinarycode the digit6 is assigned the bit )UllIUlauuu0001000000

BCDcode

Although the binary number systemis die ~ost natural system for a computer most people more accustomed to the d~imal system One way to resolve this difference is to convert

inlal nUmbers to binary perform all arithmetic calculations in binary and then convert the nary results back to decimal This metbodrequites that we store decimal numbers in

cOinputer so that they canbec6b~rted to binary Since the compllter Can accept only valueswe must represent the decimal digits by means ofa code that contains ls and Os also pOsSible lopedorm the arithmetic operlltiorisd1rectly on decimal numbers when they stored in the comput~ in cod~ct form

A binarycodewill have some unasSigned bit com~inatiqns ifthe num~rofelements in set is not amultiple power of 2 The 10decimai digits form such asel A biruuy code that tinguishes among 10 elements must coiltain at least four bits but 6otitofthe 16 possible binations remain unassigned Different binary code$ can bemiddotoNained by arranging four into 10 distinct combin~tions TheicodeIllcfflt oommonly used fdr the decimal digits is straight binary assf~ntlisted in Table 14 This scheil)eis called bittary~coded decimal

is commoolyreferred to as BCQ OtherdecimalcodesaIlfpossible and a few of them are sentedlaterinthis section

Table 14 BinarymiddotCoded Oeclmql (BCO)

Decimal BCD SnlboiDIgIt

o 0000 1 0001 2 0010

3 0011 4 middot0100 5 0101 6 0110 7 0111 8 1000 9 1001

Sectionmiddot 17 BInary COdes 19

Table 14 givesthe four-bit code for one decimal digit A number with k decimal digits will require 4k bits in BCD Decimal 396 is represented in BCD with 12 bits as 0011 10010110 with each group of 4 bits representing one decimal digit A decimalmiddotnumber in BCD is the

- same as itS equiyalent binary number only when the number is between 0 and 9 A BCD numshyber greater than lOJpoks different from its equivalentbinary number even though both con tainls and Os Moreover the binary Combinations 1010 thrpugh 1111 are not used arid have no meaning in BCD Consider decimal 18SlUld its corresponding value inBCD and bUtary

(185ho = (0001100001Ol)BCD = (l0111001h

The BCD value has 12 bits to encode the characters of the decimal value but the equivalent binary number needs only 8 bits It is obvious thatthe representation of a BCp number needs more bits than its equivalent binary value However there is an advantage in the use ofdecishymal numbers because compUterinput and output data are generated by people who use the decshyimal system

It is important to realize that BCD numbers are deCimal numbers and not binary numbers although they use bits in tbeir representation The only difference between a decimal number and BCD is that decimals are written with the symbOls 0 1 2 9 and BCD numbers use tbebinarycode 00000001 001O~ bull 1001The decimal value is exaCtly the same Dec~mal 10 is represented in BCD witheight b~ts as 00010000 and decitna1J5as 0001 01Of1lte corshyresponding binaryvalues are 1010 and 1111 and have only four bits

Consider the addition of two decimal digits in BCD together with a po~ible carry from a pre- vious less significant pair ofdigitsSince each digit does not exceed 9 the sum cannot be bull greater than 9 + 9 + 1 = 19 with the 1 being a previous carrySllppose we add the BCD dig-

its as if they were binary numbers Then the binary sumvill produce It result in the range from degto 19 In bin8ry thistange wil[be from 0000 to 10011 butin BCD it is frOm 0000 to

I 1001 with the first (ie leftmost) 1 bemg a carry and the next fo~ bits being the BCD sum When tPe binary sum is equalto or less than 1001 (withaut 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 (0110h to the binary Sum cOnverts it to the correct digit and also produces a catTy as required This is because a carry in themost significant bitposishytion of the binary sum and a deCimal carry differ by 16 10 = 6 Consider the following three BCD additions

4 0100 4 0100 8 1000

+S +0101 +8 +1000 +9 1001 9 1001 12 1100 17 10001

+0110 +0110----

10010 10111

In each case the two BCD digits are added as if they were two binary numbers If the binary sum is greater than or equal to 1010 we add 0110 to obtain the correct BCD sum and a carry In the flIst example the sum is equal to 9 and is the correct BCD sum In the second example

20 Chapter 1 Digital Systems and BInary Numbers

the binary sum produces an iJlv~ BCD digit The addition of0110 produces the cortect BCD sum 0010 (ie the number 2) and acanyInthetbirdexample the binalY SUDlproduces acany This condition occurs wben the $W)) is greater than or equal to 16Altbough the other fout are less than 1091 the binary 9Ulll requires acOnectionbecause of die carry Adding 0110 obtain thetequiled BCD sum 0111 (ie the numblaquo 7) and 8 BCD CiUT

The additionoftwondigit unsipedBCD numbers follows the same procedure COIlSioll the addition of 184 + 576 1= 76() in BCD

BCD 1 I 0001 10000100 184

+6101 ~

0111--- 0110 +576

lJinarysum 0111 10000 1010 Add6 ono 0110

BCDsun 0111 0110 0000 7(1)

The flfSt l~ sigDiticant pili- of BCD digits produces aBCDdigi~SllDlof 0000 and a for the next pair of digits the second parr or BCD digits plus a ~Vi0U8 cany produces a sum of 0110 and a carry for the next patr()fdigits The third pair of digits plus acarry proltIUC~ a binary s~ of 0111 and does not require a correction

Decimal Arithmetic The represeiltation of signed decimal numbers in BCD is simiiarto the tepresentation of numbers in binaryWe can useeitheI the familiar signed-magnitude system at the SllZllOO-COI1I

plemelit system The sign of a decimal number is tJSually represented with four bits to to thefour-bit code ofthe decimal digits Itis customary to designate 8 plus With four Os 8 minus with the llCDequivalent oi9 whlcq is 1001 The sigiled~magnitudesystem is seldom used in com~tersThe signed-complerDem ~~ either the 9s octhe 10s complement put the lOscomplement is the one most useP To obtain the lOs complement of aBCD numberwe first take the 9s complement then add 1 to the least significant digit The 9s Complement is calculated from the subtracloo of each digit from 9

The prltXeduresdevelope4 for the signed-2s-complement system in the ~vious also apply to the signed-IOs-complement system for decimal mimberS Addition is done summing all digits including the sign digit and discafding the end carry This operatiQ assumes that all negative numbers are in 10s-complement form COOsider the (+375) + (-240) == + 135 done inthe signed-complement system

o 375

+9 760middot

o 135

lhe 9in the leftmost pOsition of the second n~ber tepresents a minllS and 9760 is the complement o( 0240 The two numbers are added and tbe end carry is discarded to +13SOfcourse the decimal ntmlbers insi~ tile computer includingthe sign digits in BCD The addition isdone with BCDOigits as described previously

Sectionl 7 Binary Codes 21

The suQtr8ction of decimalliUJ1lbets either unsigned or in thesi~-~Oscomplement systetn is the sameu in the binary case Taketbe 10s ootnplementof the subtrahend and add i~ to themin~nd ManyooDlputerslULvespeciaJ hardware to perform arithmeticcalculations directly withdecilnal oumbers in 8tDThe~u$etofthecoBlPuter can specify programliled Wtnlctionsto JOdonn the aDtiuJletiP oPmwoowithdeQmal n1UQ~ ~ywithout having to convell them to binary

Binafy codes for decimal digits requirea minimum of four bits per digit Many different codes can be formulated by~gjng four bits into IQ distinct combinations BP) and three other representative codes are shown in Table L5 Each code uses only 10 out ofa pOssible middot16 bit combinations that can be arranged with four bits The other six Unused cOmbinations have no meaning amt should be avoided BCD and the 2421 code are examplesofweigbted codes In a weigbtedcodeeach bit position

juBsigned a weighting f~in~awaythat eaehdigitcanbe ev~by 8dding the wei~ oran the lsin thecoded combination The BCD code has weights of8 42 and I which cotteshy

spondiothe powe1Of-two valuesofeaCh bitTbebitasSignmeatOll0 for example is interpreted by the weights to represent dedma16beCause 8 X 0 +4xt +2 Xl +IX 0 6Thebit combination 1101 when weighted by the ~ve digits 2421 gives themiddotdeCimal equivalent of 2 X I +4 gtlt I + 2 KO + 1 X 1 = 7 Note that some digits cantle coded in lw9 possib)e

ways in the 2421Q)(feFOr inke decimal 4 can be asSigned to bitCombinadon 0100 or 1010 since botbcOmbinatibns add upto a totalweight of4

middot1$ Fou Dlf(et Blnqry Code$ for thtJledmol DIgits

~ IICD DIgIt sal MZt Exeet) 8 4 -~1

0 1

000() middotmiddotmiddot0000 001)1 0001

oem 0100

0000 0111

2 0010 0010 0101 0110 3 0011 OQU 0110 0101

4 0100 0100 0111 oroo 5 0101 lOll 1000 1011 6 OlIO middot1100 1001 1010 7 middot0111 1101 1010 J001 8 1000 IUOmiddot 1011 1000 9 1001 11U 1100 1111

1010 oloi 0000 0001 Uaused IOU 0110 middotOOOl 0010 bit 1100 0111 0010 0011 combishynations

nOl 1110

lOW 1001

HOI 1110

1100 1101

1111 IOU) 1111 1110

22 ChaptfrliDfgltalSystemsaod Btoary Numbers

I1te 2421 rind the

e~l3~es are exampks Of self-complementing codes Such codes have~propertyjbatthe9s~plement ofa deCimal nfunberigobtairted directly by chang-

ing 1$ to O~$ finO tYSCfb1 sie~bycomple~mmgeaCh bit in the pattem)For example decshyimat3~Sis re~ fu tbeexcess3code as 01101100 1000 The 9s compl~ntof 604 isrepRse~l00liOOllelliwbich isobiainc(himply by complementing each bit of the

code (as with the 1 s coinpl~ofbin~rillDlbers)middot Theexcess~3code has been used in some oldel coritputers because of its selfcpmplement~

ing property Excess-3 is an unweighted code inwhich each codedcombinationis obtained-fJQm the corresPonQing bin3ryvalueplus 3 Note that the BCD code is1~ self-complementing TheS 4 ~~ Icode isan example of assigning both positive and negative weights to ~ decimalcodeInthis case the bit combiDation 0110isin~reted as oecimal2 and is calcu-

latedfrom8XO+4X 1 + (2) X 1 + (1XO=2 ~

Cra Code _ _ J

l1te output data QfmaJlfpbYsicaimiddot $)ShmlS are quantities that are continuous These data bemiddottonverted~digiWforuitJefore they art applied toaliigital system Contfuuous or ~nisCOIl~middotUitodigitalfonn bymeans of an rumlog~digitalConverter It is times ~~ent tousethe Gray code slown inTable 16torepresehtdigiuU data that have oon~ fMn8D8l08 dasaTheadvantage of th( Gray cOOeover thesllaigbt binary nIl11l1hPt~

~lt~thatoWY~ hit in the codegroup changeSin going from one number to the For examplcentbullin-goingfrom 1 to 8dleGray code cblngesfrom 0100 to 1100Only the fust changesfromOto l~the odter~ I)its mnaintbesame By contrast With binary numbers change from 7 to 8wrube from 0111 to lOOOwhich causes allfciur bits to change valUes

TabielAi GtPyCode

01 Decl COde Equivalent

~ 0000 0001 0011 OOlG 011Q Olll OlO 0100 1100 11m 1111 1110 lOlQ 1011

lOOt i

1000

o 1 ~ 3

4 5 6 7 8 9

10 11

12 13 14 15

SectIOnl7 BlnarYCod~s 23

The Gray code is used in applications in which the normal sequenceOrbiruuy rium~may produce an error orambiguitymiddot during themiddot transitionfrom ODeDWDber to the next If binary numbersareusec1 acbange forexaJIlple nom 0111 to 1000 may produce anintermediateershyroneous number 1001 if the value ofthe rigbtmost bit takes longer to -change than domiddotthe valshyues of the other three bits The Graycode elimb1ates this problem since only one bit changes its valve dUrlng aily transition be~een two numbers I

Atypical appli-cation ofmiddotthe Gray code is the representation of analog data by a Continu ous change in the angUlar position of a shaft The sQaftmiddot is partitioned into segments ana each segment is assigned a number If adJacent segments are made to correspond with the Qray-Codesequence ambiguity is eliminated between the angle of thesbaft and the value encoded by the sensor

Character Code

Many applications of digital computers require the handling not only ofnumberS but also of other characterS or symbols such as the letters of the alphabet For mstancean insurance comshypany with thousands of policyholders will use a computeX to process its files To represent the names and other pertinent information it is necessary to fonnulate bull binary code for the letshyters ofthe alphabet In additiQt1 the same binary qode must represent numerals and special Characters (such as $) An a1phanumeric character setis a set ofeiements that inclUdes the 10 decimal digits the 26leuersofthealp1iabe and a nutnbeof special~S~ a set conshytains between 36~d 64 elements ifonIy capital letters areincltided or between 64 and 128 e1eJDents ifboth uppercasemiddot and lowercllle etters are inclUded In the first case we need a bi- nary code ofsix bits and in the second we need a binary cooeO(seVM bits

The standaM binary code for the alphanumeric char8cters is the American Stahdard Code for Information InterCbange (A~n) which uses seven bitS to code 128 characters asshoWn in Table 17 The seven bitsof the code are desipted by b~through h With h the mostsigshynificant bit ~e leUer A for example is represented inASCn as l(l()()()Ol (column l00~tOw 0001) The Ascn ()()de also contains 94 graphic characters that can be printed and 34 nonshyprinting characters used for variQUS control functions The graphic characters consist of the 26 uppercase letters (A through Z) the 26 lowercase letters (a through z) the 10 numerals (0 through 9) and 32 special printable characters suchaS andS

The 34 control characters are designated in the ASCTItable With abbreviated nalne8 They are listed again below the table with their functional names The control characters are used fQr routing data and arranging the printed text into a prescribed format~ There are three types of control characters format effectors information separatOrs andcommumc~on-COnlrpl char~ IlCters Format effectors are characters that control the layout ofprinting They inciude the fashymiliar word pr6cessorand typewriter controlssucb 8$ bac~pace (BS) horizontal tabulation (HT) and carriage return (CR) Information separators are used to separatetbe data into divi~ sions such as paragraphs and pages Theyinclude characters such as ~ordseparator (RS)and file separator (FS)The cODlIDunication-control characters are uSefulduriDgthe transmission of text between remote tenninals EXllll1plesof conlmunicatiOn(ODtiol~ are STX (start oftext)-and ETX (end of text) whicb are used toframe a text mesaagetnQlSlnitted through telephone wires

24 Chap~er 1 Diglt8l Systems and Binary Numbers

rblel7 Amerkcm5tandard Code for Information (nterclHlnge(ASCII)

b~jbzb 000 001 010 on 100 101 no 111

0000 NUL )jLP SP () p P 0001 SOH OC1 1 A Q a q

R0010 STX OC2 2 B b r 0011 ETX DC3 3 C S Ii S

0100 EDT 0C4 $ 4 D~ T d t 0101 ENQ NAK 5 E iU e u OUO ACK SYN amp 6 F V f v 0111 BEL ETB 7 0 W g w 1000 B8 CAN ( S H K h x 1001 HT EM ) 9 I Y Y 1010 LF SU~ 1 Z j z lOll VT ESC + 1lt r k UOO FF PS lt L I I 1101 Cit OS == - M 1 m 1110 SO R~ N 1 n shy

-0PIt st US f 1 0 0 DEL

r- Control characten

NUL NlI]l DlE Data-inkescape SOH Start of hea~ng DC1 Device cOntroll STX Start of text DC2 DevIce io~1lOi2 ETX End (Jftext i DC3 Device corUlri1 3 OOT End oftraIlsmission ~4 DeVicecoQtrol4

ENQ ampqwry NAK Negativeackilowledge ACK

Acknowledge SVN Sync~nous idle

Btl Bell ETB End-of-tmnsnussionblOck sS Backspace CAN CanCel HT Horizontal tab EM End of mediUrlt LF Lintifeed SUB Substitute VT Vertical tab ESC escape FF form feed FS File separator CR Carriigeretum GS Group separator SO shift Ollt RS Reoord sepuator SI Shlftin US Unit separator SF S~e DEL Delete

ASCII is a seven-bit codebutrnostcompUters manipulate anejght-bit quantity asa unit called a byte Therefore ASCII characters most often are stored ~e per byte The

I biti~sometimesused forotlef purposes depending ontheapplicatio~lFor example printetS recognize eightmiddotbit AScn chaiacterS with themost sigoificaot bit ~twO An atkJlitlo

Section 18 Binary Storage and Registers 2S

128 eight-bit characters with the most significant bit set tol are used for other symbols such as the Greek alpbabet or italic tyIe font

Error-Dtectlng Code

To detect errors in data communication and processing aneigbth bit is sometimes added to the ASCll cbaracter to indicate its Panty Aparitybit is an extra hit included with a message to make the total num~ of ls either even or odd Consider the fo119wing two cbaracters and their even andodd parity

With even parity With odd parity Ascn A = 1000061 01000001 11000001 ASCI( T == 101deg100 11010100 01010100

1

- Ineacb casewe insert an extra bit in the leftmost position of the code to produce an even number of 1 s intQe cbaraeter for even parity or an odd number of 1 s in the character for odd parity In generlll one or tbe oth~r parity i~ adopted with even parity being more common

The parity biqsbelpful in detecting errors during the transmission ofinformation from one location to another nisfuJictiOD is bandIed by generating an even parity bit at the sending end for ~h character The eight-bit characters that include parity bits are transmitted to their desshytination The parity ofeachebaracter is thetichecked at the receiving~nd If the parity of the received cbaracter is Dot even then at1east on~bit has changed value dUring the trmlsmission This method detects one three or any odd combination of errors in each character tb8t is transshymitted An even combination oferrors however goes undetected and additioDaterror detic- shytion codes may be needed to take care of that possibility

What is done after an errQlis detected depends on the partieu~ application One possishybilityis to request retransrois~ion of the message on the assump~on that tbeenigtr was ranshyd()m andwill not occur again Thus if thereeeiverdetects a parityerrorit sends bai~ the ASCII NAK (negative acknowledge) control cnaracter consisting ofail even-parity eight bits lOOlOl01H no error is detectedthe ~iversends back anACK (aCkno~ledge) conshytrol character namely 0000011 O The sending end will respond middotto an NAK by tranSmitting the message again until the correct panty is received Ifmiddot after a number of attempts the transmission is still in error a message can be sent to the Operatai to check for malfunctions in the transmission path

BINARY STORAGE ANORECiISTEIlS

The binary infonnation inadigitalcomputermust have a physical e~stencein some medium for storing individual bits A binary cell is a device that possesses two stable sttes and is cashypable of storing pne bit (0 or 1) oflnfotlllation The input to tbe cell receives exciJation sigshynals that set it to one of the two states The output of the cell isa pbysicalquantity that distinguishes between the two states The irtformationstored in Ii cell is 1when the cell is in one stable state and degwhen the Cell is in the other stable state

26middot Chapter 1 Digital Systems and BtnaryNumbers

Registers

A register is a group of binary cells A register with n cells can store any discrete quantity of middot information thatcontains n bits The state ofa registeris an n-tuple ofls middotand Os with each bit designating the state of one cell in the register The C()ntent ofaregister is a function of the int~rpretation given to tbeinformation stored in it Consider fQf ex~ple a 16-bitregister with the following binary content

11 00001111001001

middot Aregjs~ with 16 cells can be in one of 216 possible statesIf one asstimesthat the content cif the register represents a binaryinteger then the register can store any binarydumber from Oto 216 - 1 For the patticularexample shown the content ofthe register is the binary equivshyalent(lftbe decimal number 50121 If one assumes instead that the register stores alpbanushy

middot meric characters of an eight-bit cooe then the content of the register is any two meaningful characters For tht ASCII code with anevenplirityplaced in the eighth most significant bit position the register contains thetwo charactersC (the lefunosteightbits) and I (the rigbt~ most eight bits) If however one in~rprets the content of the register to be four decimal dig- its represented by a four-bitcode tnenthe content of the register is a four-digit decimal number In theexcess-3 code the register holqs the decimal nutriber 9096 The content of the registe~is meaningless in BCD becau~e the bit combinatiOn ltob is 110t assfgned to any decshyimal digit From this example it is clear that a register can store discrete elements of inforshymation and that the same bit configuration Inay beinterpreted dlffe(ently for different types of data

tmiddotmiddotReglsterTrail Adigitalsystenlis characteriZed by its registers and the components thatpetfolin data proshy~ssingIIl digital sy~tems a rcentgister tra1lsfer operation is abasi operation that consists of

middot a transftr of hiJWy hUormation from one ~t of registers into ano$er set of registers transfer may be dir~ctfr9m one regist~r toanlt)ther or may pass througb datamiddotprocessing circuits to petformaD operation Figure L 1 illustratel the transfer of iidOrnuttion among regshyisters anddemonstratespictorlallY [the tr8ll~~ ofbinaryinformation from akeyboard a register in the memQryullit Thehlputunit~s assumed to have a keyboard1 control cuit and aninput register Each time a key is strock the control circuit enters an ImnV$_

lent eight-bit alphanumeric character coqe into the input register We shall assume that code used is the ASCII code with an odd-parity bit The information from the input regisshyter is transferred into the eight-least significant cells Qf a proeessOr register After transfer theinpui register is cleared to enable the control to insert a new eight-bit when the keyboard is struck again Each eight-bit character transferred to the pro1c4ess(raquo register is preceded by a shift of the previous character to the next eight cens on its left~

middot a transfer -of four characters is completed the processor registeris full and its contents transferred into a memory register The content stored in die memOry register shown in Figl came from the transfer of the characters J 0 H an~ N aftet the four ap)lroJ)riatt keys were struck

Section 18 Binary Storage and Registers 27

FIGURE 11 Transfer of information among registers

To process discrete quantities of infoiniatiori in binary form a computer m~st be promiddot vided with devices that hold the (lata to be processed and with circuit elements that manipmiddot ulate individual bits of irifonnation The device most commonly used for holding data is a register Binary variables~ manipulated by means of digital logic circuits Figure 12 il~ luslrates the process of adding two l()bit binary iUlmbers Themeniory unit which no[shy

mally consists of millions of registers is shown with only three ofits registers Thepait of the processor unit showncoDsistsmiddotofthree registers-RI R2 and R3~getherwith digital logic circuits that manipulate the bits of RI and R2 and transfer into R3 a binary number equal to their arithmetic sum Memory registers store information and are incapable of pr0shy

cessing the two operands However th~ information stored in meDij)iybanbetransferred to ~ processor registers and the resUlts obtainedin processor tegisters can be transferred back into ame~ry register for storage Untill)ecded again The diagram ~wsthe90ntents of two

operands transferred from twoJDemoryregisters into RI imd R2 The digital logic circuits produce the sum which is transfened to register R3 The contents of R3 can now be 1riUlsshyferredback to one of thetnemory registers

The last two examples demonstrated the infonncion-flow capabilitieSofa digital system in a simple manner Themiddot registets of the ~ystem are the basic ele~ents for Noring and holding the binary information~igitallogic circuits process the binary ihfonaation stored in the

28 Chapter 1 DigIt bullbull Systems and Binary Numbers

Sum

FIGURE 12 Eumple of blnarylnfonn~t1on processing

registers Digitallogiccirctiits and registers are covered InChQpteB 2 throQgh 6 The metlilOlY unit is ~xPIained ill 9aptet 7 Th~ descriptton of register opetJtions at the register level and the design of digital systems are covexed in Chapter 8

19 BINARY LOGIC

Binary logic deals with variables th~ take on two discrete valueund withoperations that sumelogicalmeaning~ The two val~s the variableussume may be called~ydifferent (true andalse yel and no etc) but for ourp1llpQSe it is cpqVenienttotbink in terms of and assign the values llUld O The binary logic intr0ducedin this section is equivalent to algebra oalledBoolean algebra The fannal presentation ofBoolean algebra is covered in detail in Chapter 2 The purpose ofthis seCtion is to introduce Boo algebra ina matmerandlate it to digitallogiccircuits andmiddotbinarYsignalsmiddot

Section 19 Sinary logic 29 ~

Itkltn of IInary logic

Binarylogic consists of binary v~les and a set of logica1middotoperatiQDS The variables are desigshy ~by lettell of thCalplWlet~such asA B C x yz etc with eaCh variable baving two and oniy

two distinct posSible valueS 1and O There are three basic logical operations AND ORand NOT

1 AN]) This ~peration is represented by adotorby the absence ~f an oPerator For example x bull y =z or xy = zis~ x ANDy is equalto z~ThelogicaloperationAND is interpreted to mean that z == 1 ifand only ift~ land y = 1 otherwise z = O (Reme~r that x y andzare binary v8riablesand canmiddotbe equal either to 1 or Omiddotand nothing eise)middot

2 OR This operation IS represented by a plus sign For example x + y =z is read x OR y is equal to z meaning that z 1 if x = iorif y = lorifbothx= 1 and y = 1 If bqth X - 0 andY Omeo z= O

3bull NOT This operation is repf6sented by a prime (sometimes by an overbar) For ~xample x =Z (or~ =z) is read notdsequalto 1 meiming that z iswkatx isnot In other

words ifx = 1 then z == 0 but if x == 0 tnenz = L TheNOT operationisals(1 reshyferred tolls the complement operation since it changes ~ 1 toOand a O to 1

bull bull lt Binary logic resembles binary arithmetic and themiddot9peratioos ANDahd OR have similarishy

ties to multiplication and addition respectively In fac~ the symbols used for AND and OR are the same as those used for multiplication and addition However binary lOgic should not be conshyfused withbinaryarithIrietic One should realize thatan arithmetic variable designates a numshyber that may consist of many digits A logicmiddot variable is always either 1 or O For example in binary arithmetic we have I +1 =10(read~one plus ()fie is equal to 2) whereas in binary logicwe have 1 + 1 1 (read one OR onds equal to one)

For each combination of the values oix and y bullthere isa value of ~ $pecifiedby the definishytion of the logical operation D~linitiops of logical~perations maybe listed in a compacHorm called truth tables A truth table is atable of anpbssible combinations ofthe variables $howshying the relation between the values that the variables may take and the resultof the operation The truth tables for th~ operations ANDand OR with variables x and y are obtained by lis~ng

all possible values that the variables may have when combined in pairs bull For each combination the resUlt of die operation 18 theillistedin a separate row The truth tables for ANDORand

NOT are given in Table La These tables clearly demonstrate the definitionf the operatibns

Table 18 Truth TcibJts of Logical Operations

AND OR NOT

x y xmiddoty x y x+y

0 0 0 0 0 0 1 0 0 1

10

1 0 d 1 0 1 I 1 1 1 1 1

bull~lt~m

30 Chapter 1

Logk Gates

Digital Systems and Binary Numbers

Logic gates are electronic cirellit that operate on ~

variable

or mpre mput tignals to produce an output signal Electrical signals sUch as voltages orrutrents exist as analog signals having values over a given taDgebull saYOt03 V but in a digital system are interpreted to be either of two recognizable values 0 or 1 Voltage~opetated logic Circuits respond to two separate voltshyage levels that represent a binary varjable equal to logic I bt logic O For example a partic- ular digital system may define 10gicOas a signal equal to 0 volts lind logic 1 asa signal equal to 3 volts In practice each voltage levelhiS an acceptable rangeas shown in Fig 13

The input te~nals of digital cikuits accePt binary signals within the allowable range and respond at the output terininals with binary signals that fall within the specified range The intermediate region between the aJl()wed regions is crossed only during aState transition Any desired information for computing or control can be operated tm by passing binary signals through variQUS combinatioDsof logic gates with each signal represebting a particular binary

The graphic symbols used to deSignate themiddotthree types of gates are Mown in Fig 14 The

gates are blocks of hardware that prooocc tbeequivalent of1ogic~1 orlogic() output signals

Volts

- FGURl13

x

y

Exampleof binary slgnaJs

Signal ratlge for logieO

(a)~omiddotinput AND gate

FIGURE 14 SymbOls for digital logic circuits

(c)NOT gate or invert~

Problems 31

x-lU 1 11 P 0

y 0 0 11 1 ~

ANDxy 0 0 rTl 00

ORX+Y~ NOT x 11 0 0 I 1 1

FIGURE 15 Input-output 5Igals for gates

FIGURE 1

A B C

Gates WIth mlltlple JnpUU

A B C lJ

~

if inPllt logic ~ts are satisfied Theinput signals xaDd y intheNDaadQR gates may exist in ~ oHow-possible states 00 10 11 or 01 Il1ese ibpu~ampignals_ shown inFig lStoshygetber with the corresponding output signal foreach PfCThI~tiaiug~iDustrate the reshysponse ofeaclt gate to the four input signal~The~llisofthetiminadiagram represents time and the vertical axis sbo~~~~ it cbapg~botwcen~possible voltshy

age levels The low level represents logic O tJte high level l1lteAND _ responds With a logic ~ ~tput sipl wh~ both input ~~)e 1middot1~ lIieOR S-~with a logic 1 outpUt signal ifanylnput sigrudis lOgic 1 TheNOTgateis~~ to BUll invedet The reason for~nameis~t froJn the signalmsponae inmiddottbe timitt8 diagramwhicbsbows that theoUtputsignal inverts the logic sense of tbeiDpUtsigll8l

AND and OR gates may bavei)lQte tbantwQinputs M AND8_~itti ~input$andan OR gate with foU) inputs are shown in Fig 16 The three-inPllt AND gate responds With logic 1 output if all tbreeinputs arelogic 11jleoutputproduces lOgic Oifanymput is logic O-The

four-input OR gate responds withlogic 1 ifany input is logic 1 its clu1ptltllCCoines logic oonly when all inputs are logic O

Answers to prvblems marked with middotappearaHbe ClOd ofthe ~

11 lJltthe octal and beXadecimalliurilbers trom16ui 32UdngA B1l1ld C forthebst~ digits Usttbe numbers from 8 to 28 in base13 bull

I

12t What is the exact D1Jllbcr of bytes in a system that contains lta) 32Kbytoe (b)64M ~and (e) 640 byte$ middot7 t

32 Chapter 1 Digital Systemsand Binary Numbers

13 Convert the following nu~bers with the indicated bases to decimal (a) (4310)s (b) (198hz (c) (735)8 (d) (525)6

14 Whllt is the largest binary number that can be expressed with 14 bits WhlIt are the equivaleDt ~~ iinal and hexadecimal numbei-s

--

15 Detemrine the base of thl1 numbers in each case for the following operatio~ to be correct (a) 142 = 5 (b) 5414 = 13 (C) 24+ 17 == 40

16 The solution$to the q~cequation xl - Ux +22 oare l1 3 arid x =6 What is the base of the numbers

17 Convertthehexadecimal ntmIher 68BE to bitiary and then convert it ~mbinary to octal

18 I Convert the decirpal number 431 to binary in tWo ways (a) Convertd~y to binary (b) conshyvert first to hexadecinla1 and then from ~decimalwbinary Which method is faster

19 amppress the following nqrnbersin decinud (a) IQ11O0101)z (b) (l65his (c)(2624)8 (d) (FAFA) 16

(e) (10101010)2

110 Convert the following binary numbers tobexadeoimal and todecitnal (a) UOOlO (b) 110010 Explain why the deCimal answer in (b)is 4 times that in (a)

111 Perform the followingdiviskmin binary 11 Ion + l()t

112 Add IlniImultiply tfle following numberswiihout converting them to decimal (a) Binary nuniberilOll aiIdlOh (b) He~uumbers 2E aDd 34

1~)( Do thefoHowing con~ersionproblems (a) CorivertCiecimal2731S to binary (b) CakUlate the binary eqUivalent (f 213 outto eight pl~Then Convert from binary to

imalHowgJose istbe result to 2131 (c) Convert the binary resukin (b) into hexad~ lb~oonvert ~result to decimal Is answer tbesame

114 Obtain the is 8nd 2s complementsofthe foUowing binaryDumbcentrs (aj l)()()(J()OO (b) OOOOOOOO (c) 11011010 (d)01l10110 (e) 10000101 (0 11111111

115 Find the 9s and the 10s complement of the following detimal numbers (a) 52734630 (b) 63325600 (c) 25000009 (d) 00000000

116 (a) Find the 16s complement of B2FA (b) Convert B2FA to binary (c) Find the 2scomplement ofthe resultin (b) (d) Convert the answer in (c)to hex~malandco~ with ihe an~wer in (a)

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 17: Chapter 01 - Mano

Sectlonl7 Bh1ary Codes 17

ArIthmetic SubtractIOn

Subtraction of two signed binafy numbers whe~negative numbersare in2s-complement form is simple and can be stilted as follows

Take the 2s complement of the5ubtraltend (including the sign bit) and add it to the minuend (including the sign bit) A cany oU1of thesignbit position is discarded

This prOCedure is adopted because a subtraction operation can be changed to an addition operation if the sign of the subtrahend is changed as is demonstrated by the following relationship

(plusmnA) ~ (-tB) = (plusmnA) + (-B) (plusmnA) - (-B) =plusmnA) + (+B)

But changing a positivetwober toa negative n~ber is eaampily done by taking the 2s compleshy mentof the pQsitive number The reverse is also tiUe~use theCOmPle~n~ of a negative numshyber in complement form produces the equivalent positive number To see this consider the sJlbtr~ction ( 76) -- (13) = +7 In binaIy_ with eight bits this ()peiationis written as (11111010 11110011) The subtracti~ri ischmlged ~ addition by taking the 2s complement ofthe subtrahend (-13) giving (+13) In binaly tbis~ 11 niOlO+ 00001101 = lOOOOOU1 Removing the end~ we obtain the ootrect answer ()()()()() III (+7)

Itisworth noting that binary DUmbersinthe signed-complement system are added and subshy tracted by the same basic addition and suPtraction rules as unsigned numbers Therefore comshyputersneed omy one common hardware circuit tobandle bothtypcs ofaritbtnetic The user or programmer ~ust interpret the reswtIi of $l1ch addition or subtraction differently depending on whether itisassumedtha~the numbe~ are signed ltr tinsigned

j

BINARY CODES

Digitalsystems use signalsthat have two distinct values1Uld circuit elements that havetwostashyble states There is a direct analogy anrong binary iignals binary circuitelements and binary digits A binary number ofndigitsfor example may be represented by n binary circuit eleshyments each baving an output sig~alequivalen1to Oor I Digital systems represent (Uld mashynipUlate not omy binary numbers but alsO many other diScrete elements of information Any discrete element of informatioIidlat is dis1iilct among agroup of quantities can be represented witha binary code (Le a pattern of Os and fmiddots) The codes must be in binary because in todays techIiology omy circuits that represent and manipulate patterns of 0s and ls can be manufactured economically foru~ in computers However it mtistbe realizCd that binary codes merely change the symbols not the meaning ofthe ele~nts of infonbationthat they repshyresent IT we inspect the bits of a computer at random we will find that mostofthe time they represent some tYPe of coded information rath~ than binlUY numbers

AIln-bit binary code is a groopofn hits that assumes up to 211 distinct cOmbinations of ls ~d Os with eacn combination representing one elementof tnt set that is being coded A set

of four elements clab becoded with two lilS with each ~lementassignedoneof thefoUowing bit oombinationsOOO I 10 J 1 A set of eight elements requiies a three-bit code 00 a set of

18 Chapter 1 Digital Systems and Binary Numbers

J6 elements requires a fourmiddotbit code The bit combination of ann~bit code is determined the count in binuy from 0 to 21t - t Each element must be assigned a unique binuy bit binationand no two elemerits cm havetbtsamevalueothenvisethe code assignment be ambigUous

Although the minimum nqrnber of 1lits required to code 21t distiItct quantities is nthere nomaximwn numbe( of bit that may he used for a binuy code For example the 10 digits can be coded with 10 bits and each decimal digit can be assigned a bit combination nine OSmid a 1 In this pamcularbinarycode the digit6 is assigned the bit )UllIUlauuu0001000000

BCDcode

Although the binary number systemis die ~ost natural system for a computer most people more accustomed to the d~imal system One way to resolve this difference is to convert

inlal nUmbers to binary perform all arithmetic calculations in binary and then convert the nary results back to decimal This metbodrequites that we store decimal numbers in

cOinputer so that they canbec6b~rted to binary Since the compllter Can accept only valueswe must represent the decimal digits by means ofa code that contains ls and Os also pOsSible lopedorm the arithmetic operlltiorisd1rectly on decimal numbers when they stored in the comput~ in cod~ct form

A binarycodewill have some unasSigned bit com~inatiqns ifthe num~rofelements in set is not amultiple power of 2 The 10decimai digits form such asel A biruuy code that tinguishes among 10 elements must coiltain at least four bits but 6otitofthe 16 possible binations remain unassigned Different binary code$ can bemiddotoNained by arranging four into 10 distinct combin~tions TheicodeIllcfflt oommonly used fdr the decimal digits is straight binary assf~ntlisted in Table 14 This scheil)eis called bittary~coded decimal

is commoolyreferred to as BCQ OtherdecimalcodesaIlfpossible and a few of them are sentedlaterinthis section

Table 14 BinarymiddotCoded Oeclmql (BCO)

Decimal BCD SnlboiDIgIt

o 0000 1 0001 2 0010

3 0011 4 middot0100 5 0101 6 0110 7 0111 8 1000 9 1001

Sectionmiddot 17 BInary COdes 19

Table 14 givesthe four-bit code for one decimal digit A number with k decimal digits will require 4k bits in BCD Decimal 396 is represented in BCD with 12 bits as 0011 10010110 with each group of 4 bits representing one decimal digit A decimalmiddotnumber in BCD is the

- same as itS equiyalent binary number only when the number is between 0 and 9 A BCD numshyber greater than lOJpoks different from its equivalentbinary number even though both con tainls and Os Moreover the binary Combinations 1010 thrpugh 1111 are not used arid have no meaning in BCD Consider decimal 18SlUld its corresponding value inBCD and bUtary

(185ho = (0001100001Ol)BCD = (l0111001h

The BCD value has 12 bits to encode the characters of the decimal value but the equivalent binary number needs only 8 bits It is obvious thatthe representation of a BCp number needs more bits than its equivalent binary value However there is an advantage in the use ofdecishymal numbers because compUterinput and output data are generated by people who use the decshyimal system

It is important to realize that BCD numbers are deCimal numbers and not binary numbers although they use bits in tbeir representation The only difference between a decimal number and BCD is that decimals are written with the symbOls 0 1 2 9 and BCD numbers use tbebinarycode 00000001 001O~ bull 1001The decimal value is exaCtly the same Dec~mal 10 is represented in BCD witheight b~ts as 00010000 and decitna1J5as 0001 01Of1lte corshyresponding binaryvalues are 1010 and 1111 and have only four bits

Consider the addition of two decimal digits in BCD together with a po~ible carry from a pre- vious less significant pair ofdigitsSince each digit does not exceed 9 the sum cannot be bull greater than 9 + 9 + 1 = 19 with the 1 being a previous carrySllppose we add the BCD dig-

its as if they were binary numbers Then the binary sumvill produce It result in the range from degto 19 In bin8ry thistange wil[be from 0000 to 10011 butin BCD it is frOm 0000 to

I 1001 with the first (ie leftmost) 1 bemg a carry and the next fo~ bits being the BCD sum When tPe binary sum is equalto or less than 1001 (withaut 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 (0110h to the binary Sum cOnverts it to the correct digit and also produces a catTy as required This is because a carry in themost significant bitposishytion of the binary sum and a deCimal carry differ by 16 10 = 6 Consider the following three BCD additions

4 0100 4 0100 8 1000

+S +0101 +8 +1000 +9 1001 9 1001 12 1100 17 10001

+0110 +0110----

10010 10111

In each case the two BCD digits are added as if they were two binary numbers If the binary sum is greater than or equal to 1010 we add 0110 to obtain the correct BCD sum and a carry In the flIst example the sum is equal to 9 and is the correct BCD sum In the second example

20 Chapter 1 Digital Systems and BInary Numbers

the binary sum produces an iJlv~ BCD digit The addition of0110 produces the cortect BCD sum 0010 (ie the number 2) and acanyInthetbirdexample the binalY SUDlproduces acany This condition occurs wben the $W)) is greater than or equal to 16Altbough the other fout are less than 1091 the binary 9Ulll requires acOnectionbecause of die carry Adding 0110 obtain thetequiled BCD sum 0111 (ie the numblaquo 7) and 8 BCD CiUT

The additionoftwondigit unsipedBCD numbers follows the same procedure COIlSioll the addition of 184 + 576 1= 76() in BCD

BCD 1 I 0001 10000100 184

+6101 ~

0111--- 0110 +576

lJinarysum 0111 10000 1010 Add6 ono 0110

BCDsun 0111 0110 0000 7(1)

The flfSt l~ sigDiticant pili- of BCD digits produces aBCDdigi~SllDlof 0000 and a for the next pair of digits the second parr or BCD digits plus a ~Vi0U8 cany produces a sum of 0110 and a carry for the next patr()fdigits The third pair of digits plus acarry proltIUC~ a binary s~ of 0111 and does not require a correction

Decimal Arithmetic The represeiltation of signed decimal numbers in BCD is simiiarto the tepresentation of numbers in binaryWe can useeitheI the familiar signed-magnitude system at the SllZllOO-COI1I

plemelit system The sign of a decimal number is tJSually represented with four bits to to thefour-bit code ofthe decimal digits Itis customary to designate 8 plus With four Os 8 minus with the llCDequivalent oi9 whlcq is 1001 The sigiled~magnitudesystem is seldom used in com~tersThe signed-complerDem ~~ either the 9s octhe 10s complement put the lOscomplement is the one most useP To obtain the lOs complement of aBCD numberwe first take the 9s complement then add 1 to the least significant digit The 9s Complement is calculated from the subtracloo of each digit from 9

The prltXeduresdevelope4 for the signed-2s-complement system in the ~vious also apply to the signed-IOs-complement system for decimal mimberS Addition is done summing all digits including the sign digit and discafding the end carry This operatiQ assumes that all negative numbers are in 10s-complement form COOsider the (+375) + (-240) == + 135 done inthe signed-complement system

o 375

+9 760middot

o 135

lhe 9in the leftmost pOsition of the second n~ber tepresents a minllS and 9760 is the complement o( 0240 The two numbers are added and tbe end carry is discarded to +13SOfcourse the decimal ntmlbers insi~ tile computer includingthe sign digits in BCD The addition isdone with BCDOigits as described previously

Sectionl 7 Binary Codes 21

The suQtr8ction of decimalliUJ1lbets either unsigned or in thesi~-~Oscomplement systetn is the sameu in the binary case Taketbe 10s ootnplementof the subtrahend and add i~ to themin~nd ManyooDlputerslULvespeciaJ hardware to perform arithmeticcalculations directly withdecilnal oumbers in 8tDThe~u$etofthecoBlPuter can specify programliled Wtnlctionsto JOdonn the aDtiuJletiP oPmwoowithdeQmal n1UQ~ ~ywithout having to convell them to binary

Binafy codes for decimal digits requirea minimum of four bits per digit Many different codes can be formulated by~gjng four bits into IQ distinct combinations BP) and three other representative codes are shown in Table L5 Each code uses only 10 out ofa pOssible middot16 bit combinations that can be arranged with four bits The other six Unused cOmbinations have no meaning amt should be avoided BCD and the 2421 code are examplesofweigbted codes In a weigbtedcodeeach bit position

juBsigned a weighting f~in~awaythat eaehdigitcanbe ev~by 8dding the wei~ oran the lsin thecoded combination The BCD code has weights of8 42 and I which cotteshy

spondiothe powe1Of-two valuesofeaCh bitTbebitasSignmeatOll0 for example is interpreted by the weights to represent dedma16beCause 8 X 0 +4xt +2 Xl +IX 0 6Thebit combination 1101 when weighted by the ~ve digits 2421 gives themiddotdeCimal equivalent of 2 X I +4 gtlt I + 2 KO + 1 X 1 = 7 Note that some digits cantle coded in lw9 possib)e

ways in the 2421Q)(feFOr inke decimal 4 can be asSigned to bitCombinadon 0100 or 1010 since botbcOmbinatibns add upto a totalweight of4

middot1$ Fou Dlf(et Blnqry Code$ for thtJledmol DIgits

~ IICD DIgIt sal MZt Exeet) 8 4 -~1

0 1

000() middotmiddotmiddot0000 001)1 0001

oem 0100

0000 0111

2 0010 0010 0101 0110 3 0011 OQU 0110 0101

4 0100 0100 0111 oroo 5 0101 lOll 1000 1011 6 OlIO middot1100 1001 1010 7 middot0111 1101 1010 J001 8 1000 IUOmiddot 1011 1000 9 1001 11U 1100 1111

1010 oloi 0000 0001 Uaused IOU 0110 middotOOOl 0010 bit 1100 0111 0010 0011 combishynations

nOl 1110

lOW 1001

HOI 1110

1100 1101

1111 IOU) 1111 1110

22 ChaptfrliDfgltalSystemsaod Btoary Numbers

I1te 2421 rind the

e~l3~es are exampks Of self-complementing codes Such codes have~propertyjbatthe9s~plement ofa deCimal nfunberigobtairted directly by chang-

ing 1$ to O~$ finO tYSCfb1 sie~bycomple~mmgeaCh bit in the pattem)For example decshyimat3~Sis re~ fu tbeexcess3code as 01101100 1000 The 9s compl~ntof 604 isrepRse~l00liOOllelliwbich isobiainc(himply by complementing each bit of the

code (as with the 1 s coinpl~ofbin~rillDlbers)middot Theexcess~3code has been used in some oldel coritputers because of its selfcpmplement~

ing property Excess-3 is an unweighted code inwhich each codedcombinationis obtained-fJQm the corresPonQing bin3ryvalueplus 3 Note that the BCD code is1~ self-complementing TheS 4 ~~ Icode isan example of assigning both positive and negative weights to ~ decimalcodeInthis case the bit combiDation 0110isin~reted as oecimal2 and is calcu-

latedfrom8XO+4X 1 + (2) X 1 + (1XO=2 ~

Cra Code _ _ J

l1te output data QfmaJlfpbYsicaimiddot $)ShmlS are quantities that are continuous These data bemiddottonverted~digiWforuitJefore they art applied toaliigital system Contfuuous or ~nisCOIl~middotUitodigitalfonn bymeans of an rumlog~digitalConverter It is times ~~ent tousethe Gray code slown inTable 16torepresehtdigiuU data that have oon~ fMn8D8l08 dasaTheadvantage of th( Gray cOOeover thesllaigbt binary nIl11l1hPt~

~lt~thatoWY~ hit in the codegroup changeSin going from one number to the For examplcentbullin-goingfrom 1 to 8dleGray code cblngesfrom 0100 to 1100Only the fust changesfromOto l~the odter~ I)its mnaintbesame By contrast With binary numbers change from 7 to 8wrube from 0111 to lOOOwhich causes allfciur bits to change valUes

TabielAi GtPyCode

01 Decl COde Equivalent

~ 0000 0001 0011 OOlG 011Q Olll OlO 0100 1100 11m 1111 1110 lOlQ 1011

lOOt i

1000

o 1 ~ 3

4 5 6 7 8 9

10 11

12 13 14 15

SectIOnl7 BlnarYCod~s 23

The Gray code is used in applications in which the normal sequenceOrbiruuy rium~may produce an error orambiguitymiddot during themiddot transitionfrom ODeDWDber to the next If binary numbersareusec1 acbange forexaJIlple nom 0111 to 1000 may produce anintermediateershyroneous number 1001 if the value ofthe rigbtmost bit takes longer to -change than domiddotthe valshyues of the other three bits The Graycode elimb1ates this problem since only one bit changes its valve dUrlng aily transition be~een two numbers I

Atypical appli-cation ofmiddotthe Gray code is the representation of analog data by a Continu ous change in the angUlar position of a shaft The sQaftmiddot is partitioned into segments ana each segment is assigned a number If adJacent segments are made to correspond with the Qray-Codesequence ambiguity is eliminated between the angle of thesbaft and the value encoded by the sensor

Character Code

Many applications of digital computers require the handling not only ofnumberS but also of other characterS or symbols such as the letters of the alphabet For mstancean insurance comshypany with thousands of policyholders will use a computeX to process its files To represent the names and other pertinent information it is necessary to fonnulate bull binary code for the letshyters ofthe alphabet In additiQt1 the same binary qode must represent numerals and special Characters (such as $) An a1phanumeric character setis a set ofeiements that inclUdes the 10 decimal digits the 26leuersofthealp1iabe and a nutnbeof special~S~ a set conshytains between 36~d 64 elements ifonIy capital letters areincltided or between 64 and 128 e1eJDents ifboth uppercasemiddot and lowercllle etters are inclUded In the first case we need a bi- nary code ofsix bits and in the second we need a binary cooeO(seVM bits

The standaM binary code for the alphanumeric char8cters is the American Stahdard Code for Information InterCbange (A~n) which uses seven bitS to code 128 characters asshoWn in Table 17 The seven bitsof the code are desipted by b~through h With h the mostsigshynificant bit ~e leUer A for example is represented inASCn as l(l()()()Ol (column l00~tOw 0001) The Ascn ()()de also contains 94 graphic characters that can be printed and 34 nonshyprinting characters used for variQUS control functions The graphic characters consist of the 26 uppercase letters (A through Z) the 26 lowercase letters (a through z) the 10 numerals (0 through 9) and 32 special printable characters suchaS andS

The 34 control characters are designated in the ASCTItable With abbreviated nalne8 They are listed again below the table with their functional names The control characters are used fQr routing data and arranging the printed text into a prescribed format~ There are three types of control characters format effectors information separatOrs andcommumc~on-COnlrpl char~ IlCters Format effectors are characters that control the layout ofprinting They inciude the fashymiliar word pr6cessorand typewriter controlssucb 8$ bac~pace (BS) horizontal tabulation (HT) and carriage return (CR) Information separators are used to separatetbe data into divi~ sions such as paragraphs and pages Theyinclude characters such as ~ordseparator (RS)and file separator (FS)The cODlIDunication-control characters are uSefulduriDgthe transmission of text between remote tenninals EXllll1plesof conlmunicatiOn(ODtiol~ are STX (start oftext)-and ETX (end of text) whicb are used toframe a text mesaagetnQlSlnitted through telephone wires

24 Chap~er 1 Diglt8l Systems and Binary Numbers

rblel7 Amerkcm5tandard Code for Information (nterclHlnge(ASCII)

b~jbzb 000 001 010 on 100 101 no 111

0000 NUL )jLP SP () p P 0001 SOH OC1 1 A Q a q

R0010 STX OC2 2 B b r 0011 ETX DC3 3 C S Ii S

0100 EDT 0C4 $ 4 D~ T d t 0101 ENQ NAK 5 E iU e u OUO ACK SYN amp 6 F V f v 0111 BEL ETB 7 0 W g w 1000 B8 CAN ( S H K h x 1001 HT EM ) 9 I Y Y 1010 LF SU~ 1 Z j z lOll VT ESC + 1lt r k UOO FF PS lt L I I 1101 Cit OS == - M 1 m 1110 SO R~ N 1 n shy

-0PIt st US f 1 0 0 DEL

r- Control characten

NUL NlI]l DlE Data-inkescape SOH Start of hea~ng DC1 Device cOntroll STX Start of text DC2 DevIce io~1lOi2 ETX End (Jftext i DC3 Device corUlri1 3 OOT End oftraIlsmission ~4 DeVicecoQtrol4

ENQ ampqwry NAK Negativeackilowledge ACK

Acknowledge SVN Sync~nous idle

Btl Bell ETB End-of-tmnsnussionblOck sS Backspace CAN CanCel HT Horizontal tab EM End of mediUrlt LF Lintifeed SUB Substitute VT Vertical tab ESC escape FF form feed FS File separator CR Carriigeretum GS Group separator SO shift Ollt RS Reoord sepuator SI Shlftin US Unit separator SF S~e DEL Delete

ASCII is a seven-bit codebutrnostcompUters manipulate anejght-bit quantity asa unit called a byte Therefore ASCII characters most often are stored ~e per byte The

I biti~sometimesused forotlef purposes depending ontheapplicatio~lFor example printetS recognize eightmiddotbit AScn chaiacterS with themost sigoificaot bit ~twO An atkJlitlo

Section 18 Binary Storage and Registers 2S

128 eight-bit characters with the most significant bit set tol are used for other symbols such as the Greek alpbabet or italic tyIe font

Error-Dtectlng Code

To detect errors in data communication and processing aneigbth bit is sometimes added to the ASCll cbaracter to indicate its Panty Aparitybit is an extra hit included with a message to make the total num~ of ls either even or odd Consider the fo119wing two cbaracters and their even andodd parity

With even parity With odd parity Ascn A = 1000061 01000001 11000001 ASCI( T == 101deg100 11010100 01010100

1

- Ineacb casewe insert an extra bit in the leftmost position of the code to produce an even number of 1 s intQe cbaraeter for even parity or an odd number of 1 s in the character for odd parity In generlll one or tbe oth~r parity i~ adopted with even parity being more common

The parity biqsbelpful in detecting errors during the transmission ofinformation from one location to another nisfuJictiOD is bandIed by generating an even parity bit at the sending end for ~h character The eight-bit characters that include parity bits are transmitted to their desshytination The parity ofeachebaracter is thetichecked at the receiving~nd If the parity of the received cbaracter is Dot even then at1east on~bit has changed value dUring the trmlsmission This method detects one three or any odd combination of errors in each character tb8t is transshymitted An even combination oferrors however goes undetected and additioDaterror detic- shytion codes may be needed to take care of that possibility

What is done after an errQlis detected depends on the partieu~ application One possishybilityis to request retransrois~ion of the message on the assump~on that tbeenigtr was ranshyd()m andwill not occur again Thus if thereeeiverdetects a parityerrorit sends bai~ the ASCII NAK (negative acknowledge) control cnaracter consisting ofail even-parity eight bits lOOlOl01H no error is detectedthe ~iversends back anACK (aCkno~ledge) conshytrol character namely 0000011 O The sending end will respond middotto an NAK by tranSmitting the message again until the correct panty is received Ifmiddot after a number of attempts the transmission is still in error a message can be sent to the Operatai to check for malfunctions in the transmission path

BINARY STORAGE ANORECiISTEIlS

The binary infonnation inadigitalcomputermust have a physical e~stencein some medium for storing individual bits A binary cell is a device that possesses two stable sttes and is cashypable of storing pne bit (0 or 1) oflnfotlllation The input to tbe cell receives exciJation sigshynals that set it to one of the two states The output of the cell isa pbysicalquantity that distinguishes between the two states The irtformationstored in Ii cell is 1when the cell is in one stable state and degwhen the Cell is in the other stable state

26middot Chapter 1 Digital Systems and BtnaryNumbers

Registers

A register is a group of binary cells A register with n cells can store any discrete quantity of middot information thatcontains n bits The state ofa registeris an n-tuple ofls middotand Os with each bit designating the state of one cell in the register The C()ntent ofaregister is a function of the int~rpretation given to tbeinformation stored in it Consider fQf ex~ple a 16-bitregister with the following binary content

11 00001111001001

middot Aregjs~ with 16 cells can be in one of 216 possible statesIf one asstimesthat the content cif the register represents a binaryinteger then the register can store any binarydumber from Oto 216 - 1 For the patticularexample shown the content ofthe register is the binary equivshyalent(lftbe decimal number 50121 If one assumes instead that the register stores alpbanushy

middot meric characters of an eight-bit cooe then the content of the register is any two meaningful characters For tht ASCII code with anevenplirityplaced in the eighth most significant bit position the register contains thetwo charactersC (the lefunosteightbits) and I (the rigbt~ most eight bits) If however one in~rprets the content of the register to be four decimal dig- its represented by a four-bitcode tnenthe content of the register is a four-digit decimal number In theexcess-3 code the register holqs the decimal nutriber 9096 The content of the registe~is meaningless in BCD becau~e the bit combinatiOn ltob is 110t assfgned to any decshyimal digit From this example it is clear that a register can store discrete elements of inforshymation and that the same bit configuration Inay beinterpreted dlffe(ently for different types of data

tmiddotmiddotReglsterTrail Adigitalsystenlis characteriZed by its registers and the components thatpetfolin data proshy~ssingIIl digital sy~tems a rcentgister tra1lsfer operation is abasi operation that consists of

middot a transftr of hiJWy hUormation from one ~t of registers into ano$er set of registers transfer may be dir~ctfr9m one regist~r toanlt)ther or may pass througb datamiddotprocessing circuits to petformaD operation Figure L 1 illustratel the transfer of iidOrnuttion among regshyisters anddemonstratespictorlallY [the tr8ll~~ ofbinaryinformation from akeyboard a register in the memQryullit Thehlputunit~s assumed to have a keyboard1 control cuit and aninput register Each time a key is strock the control circuit enters an ImnV$_

lent eight-bit alphanumeric character coqe into the input register We shall assume that code used is the ASCII code with an odd-parity bit The information from the input regisshyter is transferred into the eight-least significant cells Qf a proeessOr register After transfer theinpui register is cleared to enable the control to insert a new eight-bit when the keyboard is struck again Each eight-bit character transferred to the pro1c4ess(raquo register is preceded by a shift of the previous character to the next eight cens on its left~

middot a transfer -of four characters is completed the processor registeris full and its contents transferred into a memory register The content stored in die memOry register shown in Figl came from the transfer of the characters J 0 H an~ N aftet the four ap)lroJ)riatt keys were struck

Section 18 Binary Storage and Registers 27

FIGURE 11 Transfer of information among registers

To process discrete quantities of infoiniatiori in binary form a computer m~st be promiddot vided with devices that hold the (lata to be processed and with circuit elements that manipmiddot ulate individual bits of irifonnation The device most commonly used for holding data is a register Binary variables~ manipulated by means of digital logic circuits Figure 12 il~ luslrates the process of adding two l()bit binary iUlmbers Themeniory unit which no[shy

mally consists of millions of registers is shown with only three ofits registers Thepait of the processor unit showncoDsistsmiddotofthree registers-RI R2 and R3~getherwith digital logic circuits that manipulate the bits of RI and R2 and transfer into R3 a binary number equal to their arithmetic sum Memory registers store information and are incapable of pr0shy

cessing the two operands However th~ information stored in meDij)iybanbetransferred to ~ processor registers and the resUlts obtainedin processor tegisters can be transferred back into ame~ry register for storage Untill)ecded again The diagram ~wsthe90ntents of two

operands transferred from twoJDemoryregisters into RI imd R2 The digital logic circuits produce the sum which is transfened to register R3 The contents of R3 can now be 1riUlsshyferredback to one of thetnemory registers

The last two examples demonstrated the infonncion-flow capabilitieSofa digital system in a simple manner Themiddot registets of the ~ystem are the basic ele~ents for Noring and holding the binary information~igitallogic circuits process the binary ihfonaation stored in the

28 Chapter 1 DigIt bullbull Systems and Binary Numbers

Sum

FIGURE 12 Eumple of blnarylnfonn~t1on processing

registers Digitallogiccirctiits and registers are covered InChQpteB 2 throQgh 6 The metlilOlY unit is ~xPIained ill 9aptet 7 Th~ descriptton of register opetJtions at the register level and the design of digital systems are covexed in Chapter 8

19 BINARY LOGIC

Binary logic deals with variables th~ take on two discrete valueund withoperations that sumelogicalmeaning~ The two val~s the variableussume may be called~ydifferent (true andalse yel and no etc) but for ourp1llpQSe it is cpqVenienttotbink in terms of and assign the values llUld O The binary logic intr0ducedin this section is equivalent to algebra oalledBoolean algebra The fannal presentation ofBoolean algebra is covered in detail in Chapter 2 The purpose ofthis seCtion is to introduce Boo algebra ina matmerandlate it to digitallogiccircuits andmiddotbinarYsignalsmiddot

Section 19 Sinary logic 29 ~

Itkltn of IInary logic

Binarylogic consists of binary v~les and a set of logica1middotoperatiQDS The variables are desigshy ~by lettell of thCalplWlet~such asA B C x yz etc with eaCh variable baving two and oniy

two distinct posSible valueS 1and O There are three basic logical operations AND ORand NOT

1 AN]) This ~peration is represented by adotorby the absence ~f an oPerator For example x bull y =z or xy = zis~ x ANDy is equalto z~ThelogicaloperationAND is interpreted to mean that z == 1 ifand only ift~ land y = 1 otherwise z = O (Reme~r that x y andzare binary v8riablesand canmiddotbe equal either to 1 or Omiddotand nothing eise)middot

2 OR This operation IS represented by a plus sign For example x + y =z is read x OR y is equal to z meaning that z 1 if x = iorif y = lorifbothx= 1 and y = 1 If bqth X - 0 andY Omeo z= O

3bull NOT This operation is repf6sented by a prime (sometimes by an overbar) For ~xample x =Z (or~ =z) is read notdsequalto 1 meiming that z iswkatx isnot In other

words ifx = 1 then z == 0 but if x == 0 tnenz = L TheNOT operationisals(1 reshyferred tolls the complement operation since it changes ~ 1 toOand a O to 1

bull bull lt Binary logic resembles binary arithmetic and themiddot9peratioos ANDahd OR have similarishy

ties to multiplication and addition respectively In fac~ the symbols used for AND and OR are the same as those used for multiplication and addition However binary lOgic should not be conshyfused withbinaryarithIrietic One should realize thatan arithmetic variable designates a numshyber that may consist of many digits A logicmiddot variable is always either 1 or O For example in binary arithmetic we have I +1 =10(read~one plus ()fie is equal to 2) whereas in binary logicwe have 1 + 1 1 (read one OR onds equal to one)

For each combination of the values oix and y bullthere isa value of ~ $pecifiedby the definishytion of the logical operation D~linitiops of logical~perations maybe listed in a compacHorm called truth tables A truth table is atable of anpbssible combinations ofthe variables $howshying the relation between the values that the variables may take and the resultof the operation The truth tables for th~ operations ANDand OR with variables x and y are obtained by lis~ng

all possible values that the variables may have when combined in pairs bull For each combination the resUlt of die operation 18 theillistedin a separate row The truth tables for ANDORand

NOT are given in Table La These tables clearly demonstrate the definitionf the operatibns

Table 18 Truth TcibJts of Logical Operations

AND OR NOT

x y xmiddoty x y x+y

0 0 0 0 0 0 1 0 0 1

10

1 0 d 1 0 1 I 1 1 1 1 1

bull~lt~m

30 Chapter 1

Logk Gates

Digital Systems and Binary Numbers

Logic gates are electronic cirellit that operate on ~

variable

or mpre mput tignals to produce an output signal Electrical signals sUch as voltages orrutrents exist as analog signals having values over a given taDgebull saYOt03 V but in a digital system are interpreted to be either of two recognizable values 0 or 1 Voltage~opetated logic Circuits respond to two separate voltshyage levels that represent a binary varjable equal to logic I bt logic O For example a partic- ular digital system may define 10gicOas a signal equal to 0 volts lind logic 1 asa signal equal to 3 volts In practice each voltage levelhiS an acceptable rangeas shown in Fig 13

The input te~nals of digital cikuits accePt binary signals within the allowable range and respond at the output terininals with binary signals that fall within the specified range The intermediate region between the aJl()wed regions is crossed only during aState transition Any desired information for computing or control can be operated tm by passing binary signals through variQUS combinatioDsof logic gates with each signal represebting a particular binary

The graphic symbols used to deSignate themiddotthree types of gates are Mown in Fig 14 The

gates are blocks of hardware that prooocc tbeequivalent of1ogic~1 orlogic() output signals

Volts

- FGURl13

x

y

Exampleof binary slgnaJs

Signal ratlge for logieO

(a)~omiddotinput AND gate

FIGURE 14 SymbOls for digital logic circuits

(c)NOT gate or invert~

Problems 31

x-lU 1 11 P 0

y 0 0 11 1 ~

ANDxy 0 0 rTl 00

ORX+Y~ NOT x 11 0 0 I 1 1

FIGURE 15 Input-output 5Igals for gates

FIGURE 1

A B C

Gates WIth mlltlple JnpUU

A B C lJ

~

if inPllt logic ~ts are satisfied Theinput signals xaDd y intheNDaadQR gates may exist in ~ oHow-possible states 00 10 11 or 01 Il1ese ibpu~ampignals_ shown inFig lStoshygetber with the corresponding output signal foreach PfCThI~tiaiug~iDustrate the reshysponse ofeaclt gate to the four input signal~The~llisofthetiminadiagram represents time and the vertical axis sbo~~~~ it cbapg~botwcen~possible voltshy

age levels The low level represents logic O tJte high level l1lteAND _ responds With a logic ~ ~tput sipl wh~ both input ~~)e 1middot1~ lIieOR S-~with a logic 1 outpUt signal ifanylnput sigrudis lOgic 1 TheNOTgateis~~ to BUll invedet The reason for~nameis~t froJn the signalmsponae inmiddottbe timitt8 diagramwhicbsbows that theoUtputsignal inverts the logic sense of tbeiDpUtsigll8l

AND and OR gates may bavei)lQte tbantwQinputs M AND8_~itti ~input$andan OR gate with foU) inputs are shown in Fig 16 The three-inPllt AND gate responds With logic 1 output if all tbreeinputs arelogic 11jleoutputproduces lOgic Oifanymput is logic O-The

four-input OR gate responds withlogic 1 ifany input is logic 1 its clu1ptltllCCoines logic oonly when all inputs are logic O

Answers to prvblems marked with middotappearaHbe ClOd ofthe ~

11 lJltthe octal and beXadecimalliurilbers trom16ui 32UdngA B1l1ld C forthebst~ digits Usttbe numbers from 8 to 28 in base13 bull

I

12t What is the exact D1Jllbcr of bytes in a system that contains lta) 32Kbytoe (b)64M ~and (e) 640 byte$ middot7 t

32 Chapter 1 Digital Systemsand Binary Numbers

13 Convert the following nu~bers with the indicated bases to decimal (a) (4310)s (b) (198hz (c) (735)8 (d) (525)6

14 Whllt is the largest binary number that can be expressed with 14 bits WhlIt are the equivaleDt ~~ iinal and hexadecimal numbei-s

--

15 Detemrine the base of thl1 numbers in each case for the following operatio~ to be correct (a) 142 = 5 (b) 5414 = 13 (C) 24+ 17 == 40

16 The solution$to the q~cequation xl - Ux +22 oare l1 3 arid x =6 What is the base of the numbers

17 Convertthehexadecimal ntmIher 68BE to bitiary and then convert it ~mbinary to octal

18 I Convert the decirpal number 431 to binary in tWo ways (a) Convertd~y to binary (b) conshyvert first to hexadecinla1 and then from ~decimalwbinary Which method is faster

19 amppress the following nqrnbersin decinud (a) IQ11O0101)z (b) (l65his (c)(2624)8 (d) (FAFA) 16

(e) (10101010)2

110 Convert the following binary numbers tobexadeoimal and todecitnal (a) UOOlO (b) 110010 Explain why the deCimal answer in (b)is 4 times that in (a)

111 Perform the followingdiviskmin binary 11 Ion + l()t

112 Add IlniImultiply tfle following numberswiihout converting them to decimal (a) Binary nuniberilOll aiIdlOh (b) He~uumbers 2E aDd 34

1~)( Do thefoHowing con~ersionproblems (a) CorivertCiecimal2731S to binary (b) CakUlate the binary eqUivalent (f 213 outto eight pl~Then Convert from binary to

imalHowgJose istbe result to 2131 (c) Convert the binary resukin (b) into hexad~ lb~oonvert ~result to decimal Is answer tbesame

114 Obtain the is 8nd 2s complementsofthe foUowing binaryDumbcentrs (aj l)()()(J()OO (b) OOOOOOOO (c) 11011010 (d)01l10110 (e) 10000101 (0 11111111

115 Find the 9s and the 10s complement of the following detimal numbers (a) 52734630 (b) 63325600 (c) 25000009 (d) 00000000

116 (a) Find the 16s complement of B2FA (b) Convert B2FA to binary (c) Find the 2scomplement ofthe resultin (b) (d) Convert the answer in (c)to hex~malandco~ with ihe an~wer in (a)

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 18: Chapter 01 - Mano

18 Chapter 1 Digital Systems and Binary Numbers

J6 elements requires a fourmiddotbit code The bit combination of ann~bit code is determined the count in binuy from 0 to 21t - t Each element must be assigned a unique binuy bit binationand no two elemerits cm havetbtsamevalueothenvisethe code assignment be ambigUous

Although the minimum nqrnber of 1lits required to code 21t distiItct quantities is nthere nomaximwn numbe( of bit that may he used for a binuy code For example the 10 digits can be coded with 10 bits and each decimal digit can be assigned a bit combination nine OSmid a 1 In this pamcularbinarycode the digit6 is assigned the bit )UllIUlauuu0001000000

BCDcode

Although the binary number systemis die ~ost natural system for a computer most people more accustomed to the d~imal system One way to resolve this difference is to convert

inlal nUmbers to binary perform all arithmetic calculations in binary and then convert the nary results back to decimal This metbodrequites that we store decimal numbers in

cOinputer so that they canbec6b~rted to binary Since the compllter Can accept only valueswe must represent the decimal digits by means ofa code that contains ls and Os also pOsSible lopedorm the arithmetic operlltiorisd1rectly on decimal numbers when they stored in the comput~ in cod~ct form

A binarycodewill have some unasSigned bit com~inatiqns ifthe num~rofelements in set is not amultiple power of 2 The 10decimai digits form such asel A biruuy code that tinguishes among 10 elements must coiltain at least four bits but 6otitofthe 16 possible binations remain unassigned Different binary code$ can bemiddotoNained by arranging four into 10 distinct combin~tions TheicodeIllcfflt oommonly used fdr the decimal digits is straight binary assf~ntlisted in Table 14 This scheil)eis called bittary~coded decimal

is commoolyreferred to as BCQ OtherdecimalcodesaIlfpossible and a few of them are sentedlaterinthis section

Table 14 BinarymiddotCoded Oeclmql (BCO)

Decimal BCD SnlboiDIgIt

o 0000 1 0001 2 0010

3 0011 4 middot0100 5 0101 6 0110 7 0111 8 1000 9 1001

Sectionmiddot 17 BInary COdes 19

Table 14 givesthe four-bit code for one decimal digit A number with k decimal digits will require 4k bits in BCD Decimal 396 is represented in BCD with 12 bits as 0011 10010110 with each group of 4 bits representing one decimal digit A decimalmiddotnumber in BCD is the

- same as itS equiyalent binary number only when the number is between 0 and 9 A BCD numshyber greater than lOJpoks different from its equivalentbinary number even though both con tainls and Os Moreover the binary Combinations 1010 thrpugh 1111 are not used arid have no meaning in BCD Consider decimal 18SlUld its corresponding value inBCD and bUtary

(185ho = (0001100001Ol)BCD = (l0111001h

The BCD value has 12 bits to encode the characters of the decimal value but the equivalent binary number needs only 8 bits It is obvious thatthe representation of a BCp number needs more bits than its equivalent binary value However there is an advantage in the use ofdecishymal numbers because compUterinput and output data are generated by people who use the decshyimal system

It is important to realize that BCD numbers are deCimal numbers and not binary numbers although they use bits in tbeir representation The only difference between a decimal number and BCD is that decimals are written with the symbOls 0 1 2 9 and BCD numbers use tbebinarycode 00000001 001O~ bull 1001The decimal value is exaCtly the same Dec~mal 10 is represented in BCD witheight b~ts as 00010000 and decitna1J5as 0001 01Of1lte corshyresponding binaryvalues are 1010 and 1111 and have only four bits

Consider the addition of two decimal digits in BCD together with a po~ible carry from a pre- vious less significant pair ofdigitsSince each digit does not exceed 9 the sum cannot be bull greater than 9 + 9 + 1 = 19 with the 1 being a previous carrySllppose we add the BCD dig-

its as if they were binary numbers Then the binary sumvill produce It result in the range from degto 19 In bin8ry thistange wil[be from 0000 to 10011 butin BCD it is frOm 0000 to

I 1001 with the first (ie leftmost) 1 bemg a carry and the next fo~ bits being the BCD sum When tPe binary sum is equalto or less than 1001 (withaut 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 (0110h to the binary Sum cOnverts it to the correct digit and also produces a catTy as required This is because a carry in themost significant bitposishytion of the binary sum and a deCimal carry differ by 16 10 = 6 Consider the following three BCD additions

4 0100 4 0100 8 1000

+S +0101 +8 +1000 +9 1001 9 1001 12 1100 17 10001

+0110 +0110----

10010 10111

In each case the two BCD digits are added as if they were two binary numbers If the binary sum is greater than or equal to 1010 we add 0110 to obtain the correct BCD sum and a carry In the flIst example the sum is equal to 9 and is the correct BCD sum In the second example

20 Chapter 1 Digital Systems and BInary Numbers

the binary sum produces an iJlv~ BCD digit The addition of0110 produces the cortect BCD sum 0010 (ie the number 2) and acanyInthetbirdexample the binalY SUDlproduces acany This condition occurs wben the $W)) is greater than or equal to 16Altbough the other fout are less than 1091 the binary 9Ulll requires acOnectionbecause of die carry Adding 0110 obtain thetequiled BCD sum 0111 (ie the numblaquo 7) and 8 BCD CiUT

The additionoftwondigit unsipedBCD numbers follows the same procedure COIlSioll the addition of 184 + 576 1= 76() in BCD

BCD 1 I 0001 10000100 184

+6101 ~

0111--- 0110 +576

lJinarysum 0111 10000 1010 Add6 ono 0110

BCDsun 0111 0110 0000 7(1)

The flfSt l~ sigDiticant pili- of BCD digits produces aBCDdigi~SllDlof 0000 and a for the next pair of digits the second parr or BCD digits plus a ~Vi0U8 cany produces a sum of 0110 and a carry for the next patr()fdigits The third pair of digits plus acarry proltIUC~ a binary s~ of 0111 and does not require a correction

Decimal Arithmetic The represeiltation of signed decimal numbers in BCD is simiiarto the tepresentation of numbers in binaryWe can useeitheI the familiar signed-magnitude system at the SllZllOO-COI1I

plemelit system The sign of a decimal number is tJSually represented with four bits to to thefour-bit code ofthe decimal digits Itis customary to designate 8 plus With four Os 8 minus with the llCDequivalent oi9 whlcq is 1001 The sigiled~magnitudesystem is seldom used in com~tersThe signed-complerDem ~~ either the 9s octhe 10s complement put the lOscomplement is the one most useP To obtain the lOs complement of aBCD numberwe first take the 9s complement then add 1 to the least significant digit The 9s Complement is calculated from the subtracloo of each digit from 9

The prltXeduresdevelope4 for the signed-2s-complement system in the ~vious also apply to the signed-IOs-complement system for decimal mimberS Addition is done summing all digits including the sign digit and discafding the end carry This operatiQ assumes that all negative numbers are in 10s-complement form COOsider the (+375) + (-240) == + 135 done inthe signed-complement system

o 375

+9 760middot

o 135

lhe 9in the leftmost pOsition of the second n~ber tepresents a minllS and 9760 is the complement o( 0240 The two numbers are added and tbe end carry is discarded to +13SOfcourse the decimal ntmlbers insi~ tile computer includingthe sign digits in BCD The addition isdone with BCDOigits as described previously

Sectionl 7 Binary Codes 21

The suQtr8ction of decimalliUJ1lbets either unsigned or in thesi~-~Oscomplement systetn is the sameu in the binary case Taketbe 10s ootnplementof the subtrahend and add i~ to themin~nd ManyooDlputerslULvespeciaJ hardware to perform arithmeticcalculations directly withdecilnal oumbers in 8tDThe~u$etofthecoBlPuter can specify programliled Wtnlctionsto JOdonn the aDtiuJletiP oPmwoowithdeQmal n1UQ~ ~ywithout having to convell them to binary

Binafy codes for decimal digits requirea minimum of four bits per digit Many different codes can be formulated by~gjng four bits into IQ distinct combinations BP) and three other representative codes are shown in Table L5 Each code uses only 10 out ofa pOssible middot16 bit combinations that can be arranged with four bits The other six Unused cOmbinations have no meaning amt should be avoided BCD and the 2421 code are examplesofweigbted codes In a weigbtedcodeeach bit position

juBsigned a weighting f~in~awaythat eaehdigitcanbe ev~by 8dding the wei~ oran the lsin thecoded combination The BCD code has weights of8 42 and I which cotteshy

spondiothe powe1Of-two valuesofeaCh bitTbebitasSignmeatOll0 for example is interpreted by the weights to represent dedma16beCause 8 X 0 +4xt +2 Xl +IX 0 6Thebit combination 1101 when weighted by the ~ve digits 2421 gives themiddotdeCimal equivalent of 2 X I +4 gtlt I + 2 KO + 1 X 1 = 7 Note that some digits cantle coded in lw9 possib)e

ways in the 2421Q)(feFOr inke decimal 4 can be asSigned to bitCombinadon 0100 or 1010 since botbcOmbinatibns add upto a totalweight of4

middot1$ Fou Dlf(et Blnqry Code$ for thtJledmol DIgits

~ IICD DIgIt sal MZt Exeet) 8 4 -~1

0 1

000() middotmiddotmiddot0000 001)1 0001

oem 0100

0000 0111

2 0010 0010 0101 0110 3 0011 OQU 0110 0101

4 0100 0100 0111 oroo 5 0101 lOll 1000 1011 6 OlIO middot1100 1001 1010 7 middot0111 1101 1010 J001 8 1000 IUOmiddot 1011 1000 9 1001 11U 1100 1111

1010 oloi 0000 0001 Uaused IOU 0110 middotOOOl 0010 bit 1100 0111 0010 0011 combishynations

nOl 1110

lOW 1001

HOI 1110

1100 1101

1111 IOU) 1111 1110

22 ChaptfrliDfgltalSystemsaod Btoary Numbers

I1te 2421 rind the

e~l3~es are exampks Of self-complementing codes Such codes have~propertyjbatthe9s~plement ofa deCimal nfunberigobtairted directly by chang-

ing 1$ to O~$ finO tYSCfb1 sie~bycomple~mmgeaCh bit in the pattem)For example decshyimat3~Sis re~ fu tbeexcess3code as 01101100 1000 The 9s compl~ntof 604 isrepRse~l00liOOllelliwbich isobiainc(himply by complementing each bit of the

code (as with the 1 s coinpl~ofbin~rillDlbers)middot Theexcess~3code has been used in some oldel coritputers because of its selfcpmplement~

ing property Excess-3 is an unweighted code inwhich each codedcombinationis obtained-fJQm the corresPonQing bin3ryvalueplus 3 Note that the BCD code is1~ self-complementing TheS 4 ~~ Icode isan example of assigning both positive and negative weights to ~ decimalcodeInthis case the bit combiDation 0110isin~reted as oecimal2 and is calcu-

latedfrom8XO+4X 1 + (2) X 1 + (1XO=2 ~

Cra Code _ _ J

l1te output data QfmaJlfpbYsicaimiddot $)ShmlS are quantities that are continuous These data bemiddottonverted~digiWforuitJefore they art applied toaliigital system Contfuuous or ~nisCOIl~middotUitodigitalfonn bymeans of an rumlog~digitalConverter It is times ~~ent tousethe Gray code slown inTable 16torepresehtdigiuU data that have oon~ fMn8D8l08 dasaTheadvantage of th( Gray cOOeover thesllaigbt binary nIl11l1hPt~

~lt~thatoWY~ hit in the codegroup changeSin going from one number to the For examplcentbullin-goingfrom 1 to 8dleGray code cblngesfrom 0100 to 1100Only the fust changesfromOto l~the odter~ I)its mnaintbesame By contrast With binary numbers change from 7 to 8wrube from 0111 to lOOOwhich causes allfciur bits to change valUes

TabielAi GtPyCode

01 Decl COde Equivalent

~ 0000 0001 0011 OOlG 011Q Olll OlO 0100 1100 11m 1111 1110 lOlQ 1011

lOOt i

1000

o 1 ~ 3

4 5 6 7 8 9

10 11

12 13 14 15

SectIOnl7 BlnarYCod~s 23

The Gray code is used in applications in which the normal sequenceOrbiruuy rium~may produce an error orambiguitymiddot during themiddot transitionfrom ODeDWDber to the next If binary numbersareusec1 acbange forexaJIlple nom 0111 to 1000 may produce anintermediateershyroneous number 1001 if the value ofthe rigbtmost bit takes longer to -change than domiddotthe valshyues of the other three bits The Graycode elimb1ates this problem since only one bit changes its valve dUrlng aily transition be~een two numbers I

Atypical appli-cation ofmiddotthe Gray code is the representation of analog data by a Continu ous change in the angUlar position of a shaft The sQaftmiddot is partitioned into segments ana each segment is assigned a number If adJacent segments are made to correspond with the Qray-Codesequence ambiguity is eliminated between the angle of thesbaft and the value encoded by the sensor

Character Code

Many applications of digital computers require the handling not only ofnumberS but also of other characterS or symbols such as the letters of the alphabet For mstancean insurance comshypany with thousands of policyholders will use a computeX to process its files To represent the names and other pertinent information it is necessary to fonnulate bull binary code for the letshyters ofthe alphabet In additiQt1 the same binary qode must represent numerals and special Characters (such as $) An a1phanumeric character setis a set ofeiements that inclUdes the 10 decimal digits the 26leuersofthealp1iabe and a nutnbeof special~S~ a set conshytains between 36~d 64 elements ifonIy capital letters areincltided or between 64 and 128 e1eJDents ifboth uppercasemiddot and lowercllle etters are inclUded In the first case we need a bi- nary code ofsix bits and in the second we need a binary cooeO(seVM bits

The standaM binary code for the alphanumeric char8cters is the American Stahdard Code for Information InterCbange (A~n) which uses seven bitS to code 128 characters asshoWn in Table 17 The seven bitsof the code are desipted by b~through h With h the mostsigshynificant bit ~e leUer A for example is represented inASCn as l(l()()()Ol (column l00~tOw 0001) The Ascn ()()de also contains 94 graphic characters that can be printed and 34 nonshyprinting characters used for variQUS control functions The graphic characters consist of the 26 uppercase letters (A through Z) the 26 lowercase letters (a through z) the 10 numerals (0 through 9) and 32 special printable characters suchaS andS

The 34 control characters are designated in the ASCTItable With abbreviated nalne8 They are listed again below the table with their functional names The control characters are used fQr routing data and arranging the printed text into a prescribed format~ There are three types of control characters format effectors information separatOrs andcommumc~on-COnlrpl char~ IlCters Format effectors are characters that control the layout ofprinting They inciude the fashymiliar word pr6cessorand typewriter controlssucb 8$ bac~pace (BS) horizontal tabulation (HT) and carriage return (CR) Information separators are used to separatetbe data into divi~ sions such as paragraphs and pages Theyinclude characters such as ~ordseparator (RS)and file separator (FS)The cODlIDunication-control characters are uSefulduriDgthe transmission of text between remote tenninals EXllll1plesof conlmunicatiOn(ODtiol~ are STX (start oftext)-and ETX (end of text) whicb are used toframe a text mesaagetnQlSlnitted through telephone wires

24 Chap~er 1 Diglt8l Systems and Binary Numbers

rblel7 Amerkcm5tandard Code for Information (nterclHlnge(ASCII)

b~jbzb 000 001 010 on 100 101 no 111

0000 NUL )jLP SP () p P 0001 SOH OC1 1 A Q a q

R0010 STX OC2 2 B b r 0011 ETX DC3 3 C S Ii S

0100 EDT 0C4 $ 4 D~ T d t 0101 ENQ NAK 5 E iU e u OUO ACK SYN amp 6 F V f v 0111 BEL ETB 7 0 W g w 1000 B8 CAN ( S H K h x 1001 HT EM ) 9 I Y Y 1010 LF SU~ 1 Z j z lOll VT ESC + 1lt r k UOO FF PS lt L I I 1101 Cit OS == - M 1 m 1110 SO R~ N 1 n shy

-0PIt st US f 1 0 0 DEL

r- Control characten

NUL NlI]l DlE Data-inkescape SOH Start of hea~ng DC1 Device cOntroll STX Start of text DC2 DevIce io~1lOi2 ETX End (Jftext i DC3 Device corUlri1 3 OOT End oftraIlsmission ~4 DeVicecoQtrol4

ENQ ampqwry NAK Negativeackilowledge ACK

Acknowledge SVN Sync~nous idle

Btl Bell ETB End-of-tmnsnussionblOck sS Backspace CAN CanCel HT Horizontal tab EM End of mediUrlt LF Lintifeed SUB Substitute VT Vertical tab ESC escape FF form feed FS File separator CR Carriigeretum GS Group separator SO shift Ollt RS Reoord sepuator SI Shlftin US Unit separator SF S~e DEL Delete

ASCII is a seven-bit codebutrnostcompUters manipulate anejght-bit quantity asa unit called a byte Therefore ASCII characters most often are stored ~e per byte The

I biti~sometimesused forotlef purposes depending ontheapplicatio~lFor example printetS recognize eightmiddotbit AScn chaiacterS with themost sigoificaot bit ~twO An atkJlitlo

Section 18 Binary Storage and Registers 2S

128 eight-bit characters with the most significant bit set tol are used for other symbols such as the Greek alpbabet or italic tyIe font

Error-Dtectlng Code

To detect errors in data communication and processing aneigbth bit is sometimes added to the ASCll cbaracter to indicate its Panty Aparitybit is an extra hit included with a message to make the total num~ of ls either even or odd Consider the fo119wing two cbaracters and their even andodd parity

With even parity With odd parity Ascn A = 1000061 01000001 11000001 ASCI( T == 101deg100 11010100 01010100

1

- Ineacb casewe insert an extra bit in the leftmost position of the code to produce an even number of 1 s intQe cbaraeter for even parity or an odd number of 1 s in the character for odd parity In generlll one or tbe oth~r parity i~ adopted with even parity being more common

The parity biqsbelpful in detecting errors during the transmission ofinformation from one location to another nisfuJictiOD is bandIed by generating an even parity bit at the sending end for ~h character The eight-bit characters that include parity bits are transmitted to their desshytination The parity ofeachebaracter is thetichecked at the receiving~nd If the parity of the received cbaracter is Dot even then at1east on~bit has changed value dUring the trmlsmission This method detects one three or any odd combination of errors in each character tb8t is transshymitted An even combination oferrors however goes undetected and additioDaterror detic- shytion codes may be needed to take care of that possibility

What is done after an errQlis detected depends on the partieu~ application One possishybilityis to request retransrois~ion of the message on the assump~on that tbeenigtr was ranshyd()m andwill not occur again Thus if thereeeiverdetects a parityerrorit sends bai~ the ASCII NAK (negative acknowledge) control cnaracter consisting ofail even-parity eight bits lOOlOl01H no error is detectedthe ~iversends back anACK (aCkno~ledge) conshytrol character namely 0000011 O The sending end will respond middotto an NAK by tranSmitting the message again until the correct panty is received Ifmiddot after a number of attempts the transmission is still in error a message can be sent to the Operatai to check for malfunctions in the transmission path

BINARY STORAGE ANORECiISTEIlS

The binary infonnation inadigitalcomputermust have a physical e~stencein some medium for storing individual bits A binary cell is a device that possesses two stable sttes and is cashypable of storing pne bit (0 or 1) oflnfotlllation The input to tbe cell receives exciJation sigshynals that set it to one of the two states The output of the cell isa pbysicalquantity that distinguishes between the two states The irtformationstored in Ii cell is 1when the cell is in one stable state and degwhen the Cell is in the other stable state

26middot Chapter 1 Digital Systems and BtnaryNumbers

Registers

A register is a group of binary cells A register with n cells can store any discrete quantity of middot information thatcontains n bits The state ofa registeris an n-tuple ofls middotand Os with each bit designating the state of one cell in the register The C()ntent ofaregister is a function of the int~rpretation given to tbeinformation stored in it Consider fQf ex~ple a 16-bitregister with the following binary content

11 00001111001001

middot Aregjs~ with 16 cells can be in one of 216 possible statesIf one asstimesthat the content cif the register represents a binaryinteger then the register can store any binarydumber from Oto 216 - 1 For the patticularexample shown the content ofthe register is the binary equivshyalent(lftbe decimal number 50121 If one assumes instead that the register stores alpbanushy

middot meric characters of an eight-bit cooe then the content of the register is any two meaningful characters For tht ASCII code with anevenplirityplaced in the eighth most significant bit position the register contains thetwo charactersC (the lefunosteightbits) and I (the rigbt~ most eight bits) If however one in~rprets the content of the register to be four decimal dig- its represented by a four-bitcode tnenthe content of the register is a four-digit decimal number In theexcess-3 code the register holqs the decimal nutriber 9096 The content of the registe~is meaningless in BCD becau~e the bit combinatiOn ltob is 110t assfgned to any decshyimal digit From this example it is clear that a register can store discrete elements of inforshymation and that the same bit configuration Inay beinterpreted dlffe(ently for different types of data

tmiddotmiddotReglsterTrail Adigitalsystenlis characteriZed by its registers and the components thatpetfolin data proshy~ssingIIl digital sy~tems a rcentgister tra1lsfer operation is abasi operation that consists of

middot a transftr of hiJWy hUormation from one ~t of registers into ano$er set of registers transfer may be dir~ctfr9m one regist~r toanlt)ther or may pass througb datamiddotprocessing circuits to petformaD operation Figure L 1 illustratel the transfer of iidOrnuttion among regshyisters anddemonstratespictorlallY [the tr8ll~~ ofbinaryinformation from akeyboard a register in the memQryullit Thehlputunit~s assumed to have a keyboard1 control cuit and aninput register Each time a key is strock the control circuit enters an ImnV$_

lent eight-bit alphanumeric character coqe into the input register We shall assume that code used is the ASCII code with an odd-parity bit The information from the input regisshyter is transferred into the eight-least significant cells Qf a proeessOr register After transfer theinpui register is cleared to enable the control to insert a new eight-bit when the keyboard is struck again Each eight-bit character transferred to the pro1c4ess(raquo register is preceded by a shift of the previous character to the next eight cens on its left~

middot a transfer -of four characters is completed the processor registeris full and its contents transferred into a memory register The content stored in die memOry register shown in Figl came from the transfer of the characters J 0 H an~ N aftet the four ap)lroJ)riatt keys were struck

Section 18 Binary Storage and Registers 27

FIGURE 11 Transfer of information among registers

To process discrete quantities of infoiniatiori in binary form a computer m~st be promiddot vided with devices that hold the (lata to be processed and with circuit elements that manipmiddot ulate individual bits of irifonnation The device most commonly used for holding data is a register Binary variables~ manipulated by means of digital logic circuits Figure 12 il~ luslrates the process of adding two l()bit binary iUlmbers Themeniory unit which no[shy

mally consists of millions of registers is shown with only three ofits registers Thepait of the processor unit showncoDsistsmiddotofthree registers-RI R2 and R3~getherwith digital logic circuits that manipulate the bits of RI and R2 and transfer into R3 a binary number equal to their arithmetic sum Memory registers store information and are incapable of pr0shy

cessing the two operands However th~ information stored in meDij)iybanbetransferred to ~ processor registers and the resUlts obtainedin processor tegisters can be transferred back into ame~ry register for storage Untill)ecded again The diagram ~wsthe90ntents of two

operands transferred from twoJDemoryregisters into RI imd R2 The digital logic circuits produce the sum which is transfened to register R3 The contents of R3 can now be 1riUlsshyferredback to one of thetnemory registers

The last two examples demonstrated the infonncion-flow capabilitieSofa digital system in a simple manner Themiddot registets of the ~ystem are the basic ele~ents for Noring and holding the binary information~igitallogic circuits process the binary ihfonaation stored in the

28 Chapter 1 DigIt bullbull Systems and Binary Numbers

Sum

FIGURE 12 Eumple of blnarylnfonn~t1on processing

registers Digitallogiccirctiits and registers are covered InChQpteB 2 throQgh 6 The metlilOlY unit is ~xPIained ill 9aptet 7 Th~ descriptton of register opetJtions at the register level and the design of digital systems are covexed in Chapter 8

19 BINARY LOGIC

Binary logic deals with variables th~ take on two discrete valueund withoperations that sumelogicalmeaning~ The two val~s the variableussume may be called~ydifferent (true andalse yel and no etc) but for ourp1llpQSe it is cpqVenienttotbink in terms of and assign the values llUld O The binary logic intr0ducedin this section is equivalent to algebra oalledBoolean algebra The fannal presentation ofBoolean algebra is covered in detail in Chapter 2 The purpose ofthis seCtion is to introduce Boo algebra ina matmerandlate it to digitallogiccircuits andmiddotbinarYsignalsmiddot

Section 19 Sinary logic 29 ~

Itkltn of IInary logic

Binarylogic consists of binary v~les and a set of logica1middotoperatiQDS The variables are desigshy ~by lettell of thCalplWlet~such asA B C x yz etc with eaCh variable baving two and oniy

two distinct posSible valueS 1and O There are three basic logical operations AND ORand NOT

1 AN]) This ~peration is represented by adotorby the absence ~f an oPerator For example x bull y =z or xy = zis~ x ANDy is equalto z~ThelogicaloperationAND is interpreted to mean that z == 1 ifand only ift~ land y = 1 otherwise z = O (Reme~r that x y andzare binary v8riablesand canmiddotbe equal either to 1 or Omiddotand nothing eise)middot

2 OR This operation IS represented by a plus sign For example x + y =z is read x OR y is equal to z meaning that z 1 if x = iorif y = lorifbothx= 1 and y = 1 If bqth X - 0 andY Omeo z= O

3bull NOT This operation is repf6sented by a prime (sometimes by an overbar) For ~xample x =Z (or~ =z) is read notdsequalto 1 meiming that z iswkatx isnot In other

words ifx = 1 then z == 0 but if x == 0 tnenz = L TheNOT operationisals(1 reshyferred tolls the complement operation since it changes ~ 1 toOand a O to 1

bull bull lt Binary logic resembles binary arithmetic and themiddot9peratioos ANDahd OR have similarishy

ties to multiplication and addition respectively In fac~ the symbols used for AND and OR are the same as those used for multiplication and addition However binary lOgic should not be conshyfused withbinaryarithIrietic One should realize thatan arithmetic variable designates a numshyber that may consist of many digits A logicmiddot variable is always either 1 or O For example in binary arithmetic we have I +1 =10(read~one plus ()fie is equal to 2) whereas in binary logicwe have 1 + 1 1 (read one OR onds equal to one)

For each combination of the values oix and y bullthere isa value of ~ $pecifiedby the definishytion of the logical operation D~linitiops of logical~perations maybe listed in a compacHorm called truth tables A truth table is atable of anpbssible combinations ofthe variables $howshying the relation between the values that the variables may take and the resultof the operation The truth tables for th~ operations ANDand OR with variables x and y are obtained by lis~ng

all possible values that the variables may have when combined in pairs bull For each combination the resUlt of die operation 18 theillistedin a separate row The truth tables for ANDORand

NOT are given in Table La These tables clearly demonstrate the definitionf the operatibns

Table 18 Truth TcibJts of Logical Operations

AND OR NOT

x y xmiddoty x y x+y

0 0 0 0 0 0 1 0 0 1

10

1 0 d 1 0 1 I 1 1 1 1 1

bull~lt~m

30 Chapter 1

Logk Gates

Digital Systems and Binary Numbers

Logic gates are electronic cirellit that operate on ~

variable

or mpre mput tignals to produce an output signal Electrical signals sUch as voltages orrutrents exist as analog signals having values over a given taDgebull saYOt03 V but in a digital system are interpreted to be either of two recognizable values 0 or 1 Voltage~opetated logic Circuits respond to two separate voltshyage levels that represent a binary varjable equal to logic I bt logic O For example a partic- ular digital system may define 10gicOas a signal equal to 0 volts lind logic 1 asa signal equal to 3 volts In practice each voltage levelhiS an acceptable rangeas shown in Fig 13

The input te~nals of digital cikuits accePt binary signals within the allowable range and respond at the output terininals with binary signals that fall within the specified range The intermediate region between the aJl()wed regions is crossed only during aState transition Any desired information for computing or control can be operated tm by passing binary signals through variQUS combinatioDsof logic gates with each signal represebting a particular binary

The graphic symbols used to deSignate themiddotthree types of gates are Mown in Fig 14 The

gates are blocks of hardware that prooocc tbeequivalent of1ogic~1 orlogic() output signals

Volts

- FGURl13

x

y

Exampleof binary slgnaJs

Signal ratlge for logieO

(a)~omiddotinput AND gate

FIGURE 14 SymbOls for digital logic circuits

(c)NOT gate or invert~

Problems 31

x-lU 1 11 P 0

y 0 0 11 1 ~

ANDxy 0 0 rTl 00

ORX+Y~ NOT x 11 0 0 I 1 1

FIGURE 15 Input-output 5Igals for gates

FIGURE 1

A B C

Gates WIth mlltlple JnpUU

A B C lJ

~

if inPllt logic ~ts are satisfied Theinput signals xaDd y intheNDaadQR gates may exist in ~ oHow-possible states 00 10 11 or 01 Il1ese ibpu~ampignals_ shown inFig lStoshygetber with the corresponding output signal foreach PfCThI~tiaiug~iDustrate the reshysponse ofeaclt gate to the four input signal~The~llisofthetiminadiagram represents time and the vertical axis sbo~~~~ it cbapg~botwcen~possible voltshy

age levels The low level represents logic O tJte high level l1lteAND _ responds With a logic ~ ~tput sipl wh~ both input ~~)e 1middot1~ lIieOR S-~with a logic 1 outpUt signal ifanylnput sigrudis lOgic 1 TheNOTgateis~~ to BUll invedet The reason for~nameis~t froJn the signalmsponae inmiddottbe timitt8 diagramwhicbsbows that theoUtputsignal inverts the logic sense of tbeiDpUtsigll8l

AND and OR gates may bavei)lQte tbantwQinputs M AND8_~itti ~input$andan OR gate with foU) inputs are shown in Fig 16 The three-inPllt AND gate responds With logic 1 output if all tbreeinputs arelogic 11jleoutputproduces lOgic Oifanymput is logic O-The

four-input OR gate responds withlogic 1 ifany input is logic 1 its clu1ptltllCCoines logic oonly when all inputs are logic O

Answers to prvblems marked with middotappearaHbe ClOd ofthe ~

11 lJltthe octal and beXadecimalliurilbers trom16ui 32UdngA B1l1ld C forthebst~ digits Usttbe numbers from 8 to 28 in base13 bull

I

12t What is the exact D1Jllbcr of bytes in a system that contains lta) 32Kbytoe (b)64M ~and (e) 640 byte$ middot7 t

32 Chapter 1 Digital Systemsand Binary Numbers

13 Convert the following nu~bers with the indicated bases to decimal (a) (4310)s (b) (198hz (c) (735)8 (d) (525)6

14 Whllt is the largest binary number that can be expressed with 14 bits WhlIt are the equivaleDt ~~ iinal and hexadecimal numbei-s

--

15 Detemrine the base of thl1 numbers in each case for the following operatio~ to be correct (a) 142 = 5 (b) 5414 = 13 (C) 24+ 17 == 40

16 The solution$to the q~cequation xl - Ux +22 oare l1 3 arid x =6 What is the base of the numbers

17 Convertthehexadecimal ntmIher 68BE to bitiary and then convert it ~mbinary to octal

18 I Convert the decirpal number 431 to binary in tWo ways (a) Convertd~y to binary (b) conshyvert first to hexadecinla1 and then from ~decimalwbinary Which method is faster

19 amppress the following nqrnbersin decinud (a) IQ11O0101)z (b) (l65his (c)(2624)8 (d) (FAFA) 16

(e) (10101010)2

110 Convert the following binary numbers tobexadeoimal and todecitnal (a) UOOlO (b) 110010 Explain why the deCimal answer in (b)is 4 times that in (a)

111 Perform the followingdiviskmin binary 11 Ion + l()t

112 Add IlniImultiply tfle following numberswiihout converting them to decimal (a) Binary nuniberilOll aiIdlOh (b) He~uumbers 2E aDd 34

1~)( Do thefoHowing con~ersionproblems (a) CorivertCiecimal2731S to binary (b) CakUlate the binary eqUivalent (f 213 outto eight pl~Then Convert from binary to

imalHowgJose istbe result to 2131 (c) Convert the binary resukin (b) into hexad~ lb~oonvert ~result to decimal Is answer tbesame

114 Obtain the is 8nd 2s complementsofthe foUowing binaryDumbcentrs (aj l)()()(J()OO (b) OOOOOOOO (c) 11011010 (d)01l10110 (e) 10000101 (0 11111111

115 Find the 9s and the 10s complement of the following detimal numbers (a) 52734630 (b) 63325600 (c) 25000009 (d) 00000000

116 (a) Find the 16s complement of B2FA (b) Convert B2FA to binary (c) Find the 2scomplement ofthe resultin (b) (d) Convert the answer in (c)to hex~malandco~ with ihe an~wer in (a)

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 19: Chapter 01 - Mano

Sectionmiddot 17 BInary COdes 19

Table 14 givesthe four-bit code for one decimal digit A number with k decimal digits will require 4k bits in BCD Decimal 396 is represented in BCD with 12 bits as 0011 10010110 with each group of 4 bits representing one decimal digit A decimalmiddotnumber in BCD is the

- same as itS equiyalent binary number only when the number is between 0 and 9 A BCD numshyber greater than lOJpoks different from its equivalentbinary number even though both con tainls and Os Moreover the binary Combinations 1010 thrpugh 1111 are not used arid have no meaning in BCD Consider decimal 18SlUld its corresponding value inBCD and bUtary

(185ho = (0001100001Ol)BCD = (l0111001h

The BCD value has 12 bits to encode the characters of the decimal value but the equivalent binary number needs only 8 bits It is obvious thatthe representation of a BCp number needs more bits than its equivalent binary value However there is an advantage in the use ofdecishymal numbers because compUterinput and output data are generated by people who use the decshyimal system

It is important to realize that BCD numbers are deCimal numbers and not binary numbers although they use bits in tbeir representation The only difference between a decimal number and BCD is that decimals are written with the symbOls 0 1 2 9 and BCD numbers use tbebinarycode 00000001 001O~ bull 1001The decimal value is exaCtly the same Dec~mal 10 is represented in BCD witheight b~ts as 00010000 and decitna1J5as 0001 01Of1lte corshyresponding binaryvalues are 1010 and 1111 and have only four bits

Consider the addition of two decimal digits in BCD together with a po~ible carry from a pre- vious less significant pair ofdigitsSince each digit does not exceed 9 the sum cannot be bull greater than 9 + 9 + 1 = 19 with the 1 being a previous carrySllppose we add the BCD dig-

its as if they were binary numbers Then the binary sumvill produce It result in the range from degto 19 In bin8ry thistange wil[be from 0000 to 10011 butin BCD it is frOm 0000 to

I 1001 with the first (ie leftmost) 1 bemg a carry and the next fo~ bits being the BCD sum When tPe binary sum is equalto or less than 1001 (withaut 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 (0110h to the binary Sum cOnverts it to the correct digit and also produces a catTy as required This is because a carry in themost significant bitposishytion of the binary sum and a deCimal carry differ by 16 10 = 6 Consider the following three BCD additions

4 0100 4 0100 8 1000

+S +0101 +8 +1000 +9 1001 9 1001 12 1100 17 10001

+0110 +0110----

10010 10111

In each case the two BCD digits are added as if they were two binary numbers If the binary sum is greater than or equal to 1010 we add 0110 to obtain the correct BCD sum and a carry In the flIst example the sum is equal to 9 and is the correct BCD sum In the second example

20 Chapter 1 Digital Systems and BInary Numbers

the binary sum produces an iJlv~ BCD digit The addition of0110 produces the cortect BCD sum 0010 (ie the number 2) and acanyInthetbirdexample the binalY SUDlproduces acany This condition occurs wben the $W)) is greater than or equal to 16Altbough the other fout are less than 1091 the binary 9Ulll requires acOnectionbecause of die carry Adding 0110 obtain thetequiled BCD sum 0111 (ie the numblaquo 7) and 8 BCD CiUT

The additionoftwondigit unsipedBCD numbers follows the same procedure COIlSioll the addition of 184 + 576 1= 76() in BCD

BCD 1 I 0001 10000100 184

+6101 ~

0111--- 0110 +576

lJinarysum 0111 10000 1010 Add6 ono 0110

BCDsun 0111 0110 0000 7(1)

The flfSt l~ sigDiticant pili- of BCD digits produces aBCDdigi~SllDlof 0000 and a for the next pair of digits the second parr or BCD digits plus a ~Vi0U8 cany produces a sum of 0110 and a carry for the next patr()fdigits The third pair of digits plus acarry proltIUC~ a binary s~ of 0111 and does not require a correction

Decimal Arithmetic The represeiltation of signed decimal numbers in BCD is simiiarto the tepresentation of numbers in binaryWe can useeitheI the familiar signed-magnitude system at the SllZllOO-COI1I

plemelit system The sign of a decimal number is tJSually represented with four bits to to thefour-bit code ofthe decimal digits Itis customary to designate 8 plus With four Os 8 minus with the llCDequivalent oi9 whlcq is 1001 The sigiled~magnitudesystem is seldom used in com~tersThe signed-complerDem ~~ either the 9s octhe 10s complement put the lOscomplement is the one most useP To obtain the lOs complement of aBCD numberwe first take the 9s complement then add 1 to the least significant digit The 9s Complement is calculated from the subtracloo of each digit from 9

The prltXeduresdevelope4 for the signed-2s-complement system in the ~vious also apply to the signed-IOs-complement system for decimal mimberS Addition is done summing all digits including the sign digit and discafding the end carry This operatiQ assumes that all negative numbers are in 10s-complement form COOsider the (+375) + (-240) == + 135 done inthe signed-complement system

o 375

+9 760middot

o 135

lhe 9in the leftmost pOsition of the second n~ber tepresents a minllS and 9760 is the complement o( 0240 The two numbers are added and tbe end carry is discarded to +13SOfcourse the decimal ntmlbers insi~ tile computer includingthe sign digits in BCD The addition isdone with BCDOigits as described previously

Sectionl 7 Binary Codes 21

The suQtr8ction of decimalliUJ1lbets either unsigned or in thesi~-~Oscomplement systetn is the sameu in the binary case Taketbe 10s ootnplementof the subtrahend and add i~ to themin~nd ManyooDlputerslULvespeciaJ hardware to perform arithmeticcalculations directly withdecilnal oumbers in 8tDThe~u$etofthecoBlPuter can specify programliled Wtnlctionsto JOdonn the aDtiuJletiP oPmwoowithdeQmal n1UQ~ ~ywithout having to convell them to binary

Binafy codes for decimal digits requirea minimum of four bits per digit Many different codes can be formulated by~gjng four bits into IQ distinct combinations BP) and three other representative codes are shown in Table L5 Each code uses only 10 out ofa pOssible middot16 bit combinations that can be arranged with four bits The other six Unused cOmbinations have no meaning amt should be avoided BCD and the 2421 code are examplesofweigbted codes In a weigbtedcodeeach bit position

juBsigned a weighting f~in~awaythat eaehdigitcanbe ev~by 8dding the wei~ oran the lsin thecoded combination The BCD code has weights of8 42 and I which cotteshy

spondiothe powe1Of-two valuesofeaCh bitTbebitasSignmeatOll0 for example is interpreted by the weights to represent dedma16beCause 8 X 0 +4xt +2 Xl +IX 0 6Thebit combination 1101 when weighted by the ~ve digits 2421 gives themiddotdeCimal equivalent of 2 X I +4 gtlt I + 2 KO + 1 X 1 = 7 Note that some digits cantle coded in lw9 possib)e

ways in the 2421Q)(feFOr inke decimal 4 can be asSigned to bitCombinadon 0100 or 1010 since botbcOmbinatibns add upto a totalweight of4

middot1$ Fou Dlf(et Blnqry Code$ for thtJledmol DIgits

~ IICD DIgIt sal MZt Exeet) 8 4 -~1

0 1

000() middotmiddotmiddot0000 001)1 0001

oem 0100

0000 0111

2 0010 0010 0101 0110 3 0011 OQU 0110 0101

4 0100 0100 0111 oroo 5 0101 lOll 1000 1011 6 OlIO middot1100 1001 1010 7 middot0111 1101 1010 J001 8 1000 IUOmiddot 1011 1000 9 1001 11U 1100 1111

1010 oloi 0000 0001 Uaused IOU 0110 middotOOOl 0010 bit 1100 0111 0010 0011 combishynations

nOl 1110

lOW 1001

HOI 1110

1100 1101

1111 IOU) 1111 1110

22 ChaptfrliDfgltalSystemsaod Btoary Numbers

I1te 2421 rind the

e~l3~es are exampks Of self-complementing codes Such codes have~propertyjbatthe9s~plement ofa deCimal nfunberigobtairted directly by chang-

ing 1$ to O~$ finO tYSCfb1 sie~bycomple~mmgeaCh bit in the pattem)For example decshyimat3~Sis re~ fu tbeexcess3code as 01101100 1000 The 9s compl~ntof 604 isrepRse~l00liOOllelliwbich isobiainc(himply by complementing each bit of the

code (as with the 1 s coinpl~ofbin~rillDlbers)middot Theexcess~3code has been used in some oldel coritputers because of its selfcpmplement~

ing property Excess-3 is an unweighted code inwhich each codedcombinationis obtained-fJQm the corresPonQing bin3ryvalueplus 3 Note that the BCD code is1~ self-complementing TheS 4 ~~ Icode isan example of assigning both positive and negative weights to ~ decimalcodeInthis case the bit combiDation 0110isin~reted as oecimal2 and is calcu-

latedfrom8XO+4X 1 + (2) X 1 + (1XO=2 ~

Cra Code _ _ J

l1te output data QfmaJlfpbYsicaimiddot $)ShmlS are quantities that are continuous These data bemiddottonverted~digiWforuitJefore they art applied toaliigital system Contfuuous or ~nisCOIl~middotUitodigitalfonn bymeans of an rumlog~digitalConverter It is times ~~ent tousethe Gray code slown inTable 16torepresehtdigiuU data that have oon~ fMn8D8l08 dasaTheadvantage of th( Gray cOOeover thesllaigbt binary nIl11l1hPt~

~lt~thatoWY~ hit in the codegroup changeSin going from one number to the For examplcentbullin-goingfrom 1 to 8dleGray code cblngesfrom 0100 to 1100Only the fust changesfromOto l~the odter~ I)its mnaintbesame By contrast With binary numbers change from 7 to 8wrube from 0111 to lOOOwhich causes allfciur bits to change valUes

TabielAi GtPyCode

01 Decl COde Equivalent

~ 0000 0001 0011 OOlG 011Q Olll OlO 0100 1100 11m 1111 1110 lOlQ 1011

lOOt i

1000

o 1 ~ 3

4 5 6 7 8 9

10 11

12 13 14 15

SectIOnl7 BlnarYCod~s 23

The Gray code is used in applications in which the normal sequenceOrbiruuy rium~may produce an error orambiguitymiddot during themiddot transitionfrom ODeDWDber to the next If binary numbersareusec1 acbange forexaJIlple nom 0111 to 1000 may produce anintermediateershyroneous number 1001 if the value ofthe rigbtmost bit takes longer to -change than domiddotthe valshyues of the other three bits The Graycode elimb1ates this problem since only one bit changes its valve dUrlng aily transition be~een two numbers I

Atypical appli-cation ofmiddotthe Gray code is the representation of analog data by a Continu ous change in the angUlar position of a shaft The sQaftmiddot is partitioned into segments ana each segment is assigned a number If adJacent segments are made to correspond with the Qray-Codesequence ambiguity is eliminated between the angle of thesbaft and the value encoded by the sensor

Character Code

Many applications of digital computers require the handling not only ofnumberS but also of other characterS or symbols such as the letters of the alphabet For mstancean insurance comshypany with thousands of policyholders will use a computeX to process its files To represent the names and other pertinent information it is necessary to fonnulate bull binary code for the letshyters ofthe alphabet In additiQt1 the same binary qode must represent numerals and special Characters (such as $) An a1phanumeric character setis a set ofeiements that inclUdes the 10 decimal digits the 26leuersofthealp1iabe and a nutnbeof special~S~ a set conshytains between 36~d 64 elements ifonIy capital letters areincltided or between 64 and 128 e1eJDents ifboth uppercasemiddot and lowercllle etters are inclUded In the first case we need a bi- nary code ofsix bits and in the second we need a binary cooeO(seVM bits

The standaM binary code for the alphanumeric char8cters is the American Stahdard Code for Information InterCbange (A~n) which uses seven bitS to code 128 characters asshoWn in Table 17 The seven bitsof the code are desipted by b~through h With h the mostsigshynificant bit ~e leUer A for example is represented inASCn as l(l()()()Ol (column l00~tOw 0001) The Ascn ()()de also contains 94 graphic characters that can be printed and 34 nonshyprinting characters used for variQUS control functions The graphic characters consist of the 26 uppercase letters (A through Z) the 26 lowercase letters (a through z) the 10 numerals (0 through 9) and 32 special printable characters suchaS andS

The 34 control characters are designated in the ASCTItable With abbreviated nalne8 They are listed again below the table with their functional names The control characters are used fQr routing data and arranging the printed text into a prescribed format~ There are three types of control characters format effectors information separatOrs andcommumc~on-COnlrpl char~ IlCters Format effectors are characters that control the layout ofprinting They inciude the fashymiliar word pr6cessorand typewriter controlssucb 8$ bac~pace (BS) horizontal tabulation (HT) and carriage return (CR) Information separators are used to separatetbe data into divi~ sions such as paragraphs and pages Theyinclude characters such as ~ordseparator (RS)and file separator (FS)The cODlIDunication-control characters are uSefulduriDgthe transmission of text between remote tenninals EXllll1plesof conlmunicatiOn(ODtiol~ are STX (start oftext)-and ETX (end of text) whicb are used toframe a text mesaagetnQlSlnitted through telephone wires

24 Chap~er 1 Diglt8l Systems and Binary Numbers

rblel7 Amerkcm5tandard Code for Information (nterclHlnge(ASCII)

b~jbzb 000 001 010 on 100 101 no 111

0000 NUL )jLP SP () p P 0001 SOH OC1 1 A Q a q

R0010 STX OC2 2 B b r 0011 ETX DC3 3 C S Ii S

0100 EDT 0C4 $ 4 D~ T d t 0101 ENQ NAK 5 E iU e u OUO ACK SYN amp 6 F V f v 0111 BEL ETB 7 0 W g w 1000 B8 CAN ( S H K h x 1001 HT EM ) 9 I Y Y 1010 LF SU~ 1 Z j z lOll VT ESC + 1lt r k UOO FF PS lt L I I 1101 Cit OS == - M 1 m 1110 SO R~ N 1 n shy

-0PIt st US f 1 0 0 DEL

r- Control characten

NUL NlI]l DlE Data-inkescape SOH Start of hea~ng DC1 Device cOntroll STX Start of text DC2 DevIce io~1lOi2 ETX End (Jftext i DC3 Device corUlri1 3 OOT End oftraIlsmission ~4 DeVicecoQtrol4

ENQ ampqwry NAK Negativeackilowledge ACK

Acknowledge SVN Sync~nous idle

Btl Bell ETB End-of-tmnsnussionblOck sS Backspace CAN CanCel HT Horizontal tab EM End of mediUrlt LF Lintifeed SUB Substitute VT Vertical tab ESC escape FF form feed FS File separator CR Carriigeretum GS Group separator SO shift Ollt RS Reoord sepuator SI Shlftin US Unit separator SF S~e DEL Delete

ASCII is a seven-bit codebutrnostcompUters manipulate anejght-bit quantity asa unit called a byte Therefore ASCII characters most often are stored ~e per byte The

I biti~sometimesused forotlef purposes depending ontheapplicatio~lFor example printetS recognize eightmiddotbit AScn chaiacterS with themost sigoificaot bit ~twO An atkJlitlo

Section 18 Binary Storage and Registers 2S

128 eight-bit characters with the most significant bit set tol are used for other symbols such as the Greek alpbabet or italic tyIe font

Error-Dtectlng Code

To detect errors in data communication and processing aneigbth bit is sometimes added to the ASCll cbaracter to indicate its Panty Aparitybit is an extra hit included with a message to make the total num~ of ls either even or odd Consider the fo119wing two cbaracters and their even andodd parity

With even parity With odd parity Ascn A = 1000061 01000001 11000001 ASCI( T == 101deg100 11010100 01010100

1

- Ineacb casewe insert an extra bit in the leftmost position of the code to produce an even number of 1 s intQe cbaraeter for even parity or an odd number of 1 s in the character for odd parity In generlll one or tbe oth~r parity i~ adopted with even parity being more common

The parity biqsbelpful in detecting errors during the transmission ofinformation from one location to another nisfuJictiOD is bandIed by generating an even parity bit at the sending end for ~h character The eight-bit characters that include parity bits are transmitted to their desshytination The parity ofeachebaracter is thetichecked at the receiving~nd If the parity of the received cbaracter is Dot even then at1east on~bit has changed value dUring the trmlsmission This method detects one three or any odd combination of errors in each character tb8t is transshymitted An even combination oferrors however goes undetected and additioDaterror detic- shytion codes may be needed to take care of that possibility

What is done after an errQlis detected depends on the partieu~ application One possishybilityis to request retransrois~ion of the message on the assump~on that tbeenigtr was ranshyd()m andwill not occur again Thus if thereeeiverdetects a parityerrorit sends bai~ the ASCII NAK (negative acknowledge) control cnaracter consisting ofail even-parity eight bits lOOlOl01H no error is detectedthe ~iversends back anACK (aCkno~ledge) conshytrol character namely 0000011 O The sending end will respond middotto an NAK by tranSmitting the message again until the correct panty is received Ifmiddot after a number of attempts the transmission is still in error a message can be sent to the Operatai to check for malfunctions in the transmission path

BINARY STORAGE ANORECiISTEIlS

The binary infonnation inadigitalcomputermust have a physical e~stencein some medium for storing individual bits A binary cell is a device that possesses two stable sttes and is cashypable of storing pne bit (0 or 1) oflnfotlllation The input to tbe cell receives exciJation sigshynals that set it to one of the two states The output of the cell isa pbysicalquantity that distinguishes between the two states The irtformationstored in Ii cell is 1when the cell is in one stable state and degwhen the Cell is in the other stable state

26middot Chapter 1 Digital Systems and BtnaryNumbers

Registers

A register is a group of binary cells A register with n cells can store any discrete quantity of middot information thatcontains n bits The state ofa registeris an n-tuple ofls middotand Os with each bit designating the state of one cell in the register The C()ntent ofaregister is a function of the int~rpretation given to tbeinformation stored in it Consider fQf ex~ple a 16-bitregister with the following binary content

11 00001111001001

middot Aregjs~ with 16 cells can be in one of 216 possible statesIf one asstimesthat the content cif the register represents a binaryinteger then the register can store any binarydumber from Oto 216 - 1 For the patticularexample shown the content ofthe register is the binary equivshyalent(lftbe decimal number 50121 If one assumes instead that the register stores alpbanushy

middot meric characters of an eight-bit cooe then the content of the register is any two meaningful characters For tht ASCII code with anevenplirityplaced in the eighth most significant bit position the register contains thetwo charactersC (the lefunosteightbits) and I (the rigbt~ most eight bits) If however one in~rprets the content of the register to be four decimal dig- its represented by a four-bitcode tnenthe content of the register is a four-digit decimal number In theexcess-3 code the register holqs the decimal nutriber 9096 The content of the registe~is meaningless in BCD becau~e the bit combinatiOn ltob is 110t assfgned to any decshyimal digit From this example it is clear that a register can store discrete elements of inforshymation and that the same bit configuration Inay beinterpreted dlffe(ently for different types of data

tmiddotmiddotReglsterTrail Adigitalsystenlis characteriZed by its registers and the components thatpetfolin data proshy~ssingIIl digital sy~tems a rcentgister tra1lsfer operation is abasi operation that consists of

middot a transftr of hiJWy hUormation from one ~t of registers into ano$er set of registers transfer may be dir~ctfr9m one regist~r toanlt)ther or may pass througb datamiddotprocessing circuits to petformaD operation Figure L 1 illustratel the transfer of iidOrnuttion among regshyisters anddemonstratespictorlallY [the tr8ll~~ ofbinaryinformation from akeyboard a register in the memQryullit Thehlputunit~s assumed to have a keyboard1 control cuit and aninput register Each time a key is strock the control circuit enters an ImnV$_

lent eight-bit alphanumeric character coqe into the input register We shall assume that code used is the ASCII code with an odd-parity bit The information from the input regisshyter is transferred into the eight-least significant cells Qf a proeessOr register After transfer theinpui register is cleared to enable the control to insert a new eight-bit when the keyboard is struck again Each eight-bit character transferred to the pro1c4ess(raquo register is preceded by a shift of the previous character to the next eight cens on its left~

middot a transfer -of four characters is completed the processor registeris full and its contents transferred into a memory register The content stored in die memOry register shown in Figl came from the transfer of the characters J 0 H an~ N aftet the four ap)lroJ)riatt keys were struck

Section 18 Binary Storage and Registers 27

FIGURE 11 Transfer of information among registers

To process discrete quantities of infoiniatiori in binary form a computer m~st be promiddot vided with devices that hold the (lata to be processed and with circuit elements that manipmiddot ulate individual bits of irifonnation The device most commonly used for holding data is a register Binary variables~ manipulated by means of digital logic circuits Figure 12 il~ luslrates the process of adding two l()bit binary iUlmbers Themeniory unit which no[shy

mally consists of millions of registers is shown with only three ofits registers Thepait of the processor unit showncoDsistsmiddotofthree registers-RI R2 and R3~getherwith digital logic circuits that manipulate the bits of RI and R2 and transfer into R3 a binary number equal to their arithmetic sum Memory registers store information and are incapable of pr0shy

cessing the two operands However th~ information stored in meDij)iybanbetransferred to ~ processor registers and the resUlts obtainedin processor tegisters can be transferred back into ame~ry register for storage Untill)ecded again The diagram ~wsthe90ntents of two

operands transferred from twoJDemoryregisters into RI imd R2 The digital logic circuits produce the sum which is transfened to register R3 The contents of R3 can now be 1riUlsshyferredback to one of thetnemory registers

The last two examples demonstrated the infonncion-flow capabilitieSofa digital system in a simple manner Themiddot registets of the ~ystem are the basic ele~ents for Noring and holding the binary information~igitallogic circuits process the binary ihfonaation stored in the

28 Chapter 1 DigIt bullbull Systems and Binary Numbers

Sum

FIGURE 12 Eumple of blnarylnfonn~t1on processing

registers Digitallogiccirctiits and registers are covered InChQpteB 2 throQgh 6 The metlilOlY unit is ~xPIained ill 9aptet 7 Th~ descriptton of register opetJtions at the register level and the design of digital systems are covexed in Chapter 8

19 BINARY LOGIC

Binary logic deals with variables th~ take on two discrete valueund withoperations that sumelogicalmeaning~ The two val~s the variableussume may be called~ydifferent (true andalse yel and no etc) but for ourp1llpQSe it is cpqVenienttotbink in terms of and assign the values llUld O The binary logic intr0ducedin this section is equivalent to algebra oalledBoolean algebra The fannal presentation ofBoolean algebra is covered in detail in Chapter 2 The purpose ofthis seCtion is to introduce Boo algebra ina matmerandlate it to digitallogiccircuits andmiddotbinarYsignalsmiddot

Section 19 Sinary logic 29 ~

Itkltn of IInary logic

Binarylogic consists of binary v~les and a set of logica1middotoperatiQDS The variables are desigshy ~by lettell of thCalplWlet~such asA B C x yz etc with eaCh variable baving two and oniy

two distinct posSible valueS 1and O There are three basic logical operations AND ORand NOT

1 AN]) This ~peration is represented by adotorby the absence ~f an oPerator For example x bull y =z or xy = zis~ x ANDy is equalto z~ThelogicaloperationAND is interpreted to mean that z == 1 ifand only ift~ land y = 1 otherwise z = O (Reme~r that x y andzare binary v8riablesand canmiddotbe equal either to 1 or Omiddotand nothing eise)middot

2 OR This operation IS represented by a plus sign For example x + y =z is read x OR y is equal to z meaning that z 1 if x = iorif y = lorifbothx= 1 and y = 1 If bqth X - 0 andY Omeo z= O

3bull NOT This operation is repf6sented by a prime (sometimes by an overbar) For ~xample x =Z (or~ =z) is read notdsequalto 1 meiming that z iswkatx isnot In other

words ifx = 1 then z == 0 but if x == 0 tnenz = L TheNOT operationisals(1 reshyferred tolls the complement operation since it changes ~ 1 toOand a O to 1

bull bull lt Binary logic resembles binary arithmetic and themiddot9peratioos ANDahd OR have similarishy

ties to multiplication and addition respectively In fac~ the symbols used for AND and OR are the same as those used for multiplication and addition However binary lOgic should not be conshyfused withbinaryarithIrietic One should realize thatan arithmetic variable designates a numshyber that may consist of many digits A logicmiddot variable is always either 1 or O For example in binary arithmetic we have I +1 =10(read~one plus ()fie is equal to 2) whereas in binary logicwe have 1 + 1 1 (read one OR onds equal to one)

For each combination of the values oix and y bullthere isa value of ~ $pecifiedby the definishytion of the logical operation D~linitiops of logical~perations maybe listed in a compacHorm called truth tables A truth table is atable of anpbssible combinations ofthe variables $howshying the relation between the values that the variables may take and the resultof the operation The truth tables for th~ operations ANDand OR with variables x and y are obtained by lis~ng

all possible values that the variables may have when combined in pairs bull For each combination the resUlt of die operation 18 theillistedin a separate row The truth tables for ANDORand

NOT are given in Table La These tables clearly demonstrate the definitionf the operatibns

Table 18 Truth TcibJts of Logical Operations

AND OR NOT

x y xmiddoty x y x+y

0 0 0 0 0 0 1 0 0 1

10

1 0 d 1 0 1 I 1 1 1 1 1

bull~lt~m

30 Chapter 1

Logk Gates

Digital Systems and Binary Numbers

Logic gates are electronic cirellit that operate on ~

variable

or mpre mput tignals to produce an output signal Electrical signals sUch as voltages orrutrents exist as analog signals having values over a given taDgebull saYOt03 V but in a digital system are interpreted to be either of two recognizable values 0 or 1 Voltage~opetated logic Circuits respond to two separate voltshyage levels that represent a binary varjable equal to logic I bt logic O For example a partic- ular digital system may define 10gicOas a signal equal to 0 volts lind logic 1 asa signal equal to 3 volts In practice each voltage levelhiS an acceptable rangeas shown in Fig 13

The input te~nals of digital cikuits accePt binary signals within the allowable range and respond at the output terininals with binary signals that fall within the specified range The intermediate region between the aJl()wed regions is crossed only during aState transition Any desired information for computing or control can be operated tm by passing binary signals through variQUS combinatioDsof logic gates with each signal represebting a particular binary

The graphic symbols used to deSignate themiddotthree types of gates are Mown in Fig 14 The

gates are blocks of hardware that prooocc tbeequivalent of1ogic~1 orlogic() output signals

Volts

- FGURl13

x

y

Exampleof binary slgnaJs

Signal ratlge for logieO

(a)~omiddotinput AND gate

FIGURE 14 SymbOls for digital logic circuits

(c)NOT gate or invert~

Problems 31

x-lU 1 11 P 0

y 0 0 11 1 ~

ANDxy 0 0 rTl 00

ORX+Y~ NOT x 11 0 0 I 1 1

FIGURE 15 Input-output 5Igals for gates

FIGURE 1

A B C

Gates WIth mlltlple JnpUU

A B C lJ

~

if inPllt logic ~ts are satisfied Theinput signals xaDd y intheNDaadQR gates may exist in ~ oHow-possible states 00 10 11 or 01 Il1ese ibpu~ampignals_ shown inFig lStoshygetber with the corresponding output signal foreach PfCThI~tiaiug~iDustrate the reshysponse ofeaclt gate to the four input signal~The~llisofthetiminadiagram represents time and the vertical axis sbo~~~~ it cbapg~botwcen~possible voltshy

age levels The low level represents logic O tJte high level l1lteAND _ responds With a logic ~ ~tput sipl wh~ both input ~~)e 1middot1~ lIieOR S-~with a logic 1 outpUt signal ifanylnput sigrudis lOgic 1 TheNOTgateis~~ to BUll invedet The reason for~nameis~t froJn the signalmsponae inmiddottbe timitt8 diagramwhicbsbows that theoUtputsignal inverts the logic sense of tbeiDpUtsigll8l

AND and OR gates may bavei)lQte tbantwQinputs M AND8_~itti ~input$andan OR gate with foU) inputs are shown in Fig 16 The three-inPllt AND gate responds With logic 1 output if all tbreeinputs arelogic 11jleoutputproduces lOgic Oifanymput is logic O-The

four-input OR gate responds withlogic 1 ifany input is logic 1 its clu1ptltllCCoines logic oonly when all inputs are logic O

Answers to prvblems marked with middotappearaHbe ClOd ofthe ~

11 lJltthe octal and beXadecimalliurilbers trom16ui 32UdngA B1l1ld C forthebst~ digits Usttbe numbers from 8 to 28 in base13 bull

I

12t What is the exact D1Jllbcr of bytes in a system that contains lta) 32Kbytoe (b)64M ~and (e) 640 byte$ middot7 t

32 Chapter 1 Digital Systemsand Binary Numbers

13 Convert the following nu~bers with the indicated bases to decimal (a) (4310)s (b) (198hz (c) (735)8 (d) (525)6

14 Whllt is the largest binary number that can be expressed with 14 bits WhlIt are the equivaleDt ~~ iinal and hexadecimal numbei-s

--

15 Detemrine the base of thl1 numbers in each case for the following operatio~ to be correct (a) 142 = 5 (b) 5414 = 13 (C) 24+ 17 == 40

16 The solution$to the q~cequation xl - Ux +22 oare l1 3 arid x =6 What is the base of the numbers

17 Convertthehexadecimal ntmIher 68BE to bitiary and then convert it ~mbinary to octal

18 I Convert the decirpal number 431 to binary in tWo ways (a) Convertd~y to binary (b) conshyvert first to hexadecinla1 and then from ~decimalwbinary Which method is faster

19 amppress the following nqrnbersin decinud (a) IQ11O0101)z (b) (l65his (c)(2624)8 (d) (FAFA) 16

(e) (10101010)2

110 Convert the following binary numbers tobexadeoimal and todecitnal (a) UOOlO (b) 110010 Explain why the deCimal answer in (b)is 4 times that in (a)

111 Perform the followingdiviskmin binary 11 Ion + l()t

112 Add IlniImultiply tfle following numberswiihout converting them to decimal (a) Binary nuniberilOll aiIdlOh (b) He~uumbers 2E aDd 34

1~)( Do thefoHowing con~ersionproblems (a) CorivertCiecimal2731S to binary (b) CakUlate the binary eqUivalent (f 213 outto eight pl~Then Convert from binary to

imalHowgJose istbe result to 2131 (c) Convert the binary resukin (b) into hexad~ lb~oonvert ~result to decimal Is answer tbesame

114 Obtain the is 8nd 2s complementsofthe foUowing binaryDumbcentrs (aj l)()()(J()OO (b) OOOOOOOO (c) 11011010 (d)01l10110 (e) 10000101 (0 11111111

115 Find the 9s and the 10s complement of the following detimal numbers (a) 52734630 (b) 63325600 (c) 25000009 (d) 00000000

116 (a) Find the 16s complement of B2FA (b) Convert B2FA to binary (c) Find the 2scomplement ofthe resultin (b) (d) Convert the answer in (c)to hex~malandco~ with ihe an~wer in (a)

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 20: Chapter 01 - Mano

20 Chapter 1 Digital Systems and BInary Numbers

the binary sum produces an iJlv~ BCD digit The addition of0110 produces the cortect BCD sum 0010 (ie the number 2) and acanyInthetbirdexample the binalY SUDlproduces acany This condition occurs wben the $W)) is greater than or equal to 16Altbough the other fout are less than 1091 the binary 9Ulll requires acOnectionbecause of die carry Adding 0110 obtain thetequiled BCD sum 0111 (ie the numblaquo 7) and 8 BCD CiUT

The additionoftwondigit unsipedBCD numbers follows the same procedure COIlSioll the addition of 184 + 576 1= 76() in BCD

BCD 1 I 0001 10000100 184

+6101 ~

0111--- 0110 +576

lJinarysum 0111 10000 1010 Add6 ono 0110

BCDsun 0111 0110 0000 7(1)

The flfSt l~ sigDiticant pili- of BCD digits produces aBCDdigi~SllDlof 0000 and a for the next pair of digits the second parr or BCD digits plus a ~Vi0U8 cany produces a sum of 0110 and a carry for the next patr()fdigits The third pair of digits plus acarry proltIUC~ a binary s~ of 0111 and does not require a correction

Decimal Arithmetic The represeiltation of signed decimal numbers in BCD is simiiarto the tepresentation of numbers in binaryWe can useeitheI the familiar signed-magnitude system at the SllZllOO-COI1I

plemelit system The sign of a decimal number is tJSually represented with four bits to to thefour-bit code ofthe decimal digits Itis customary to designate 8 plus With four Os 8 minus with the llCDequivalent oi9 whlcq is 1001 The sigiled~magnitudesystem is seldom used in com~tersThe signed-complerDem ~~ either the 9s octhe 10s complement put the lOscomplement is the one most useP To obtain the lOs complement of aBCD numberwe first take the 9s complement then add 1 to the least significant digit The 9s Complement is calculated from the subtracloo of each digit from 9

The prltXeduresdevelope4 for the signed-2s-complement system in the ~vious also apply to the signed-IOs-complement system for decimal mimberS Addition is done summing all digits including the sign digit and discafding the end carry This operatiQ assumes that all negative numbers are in 10s-complement form COOsider the (+375) + (-240) == + 135 done inthe signed-complement system

o 375

+9 760middot

o 135

lhe 9in the leftmost pOsition of the second n~ber tepresents a minllS and 9760 is the complement o( 0240 The two numbers are added and tbe end carry is discarded to +13SOfcourse the decimal ntmlbers insi~ tile computer includingthe sign digits in BCD The addition isdone with BCDOigits as described previously

Sectionl 7 Binary Codes 21

The suQtr8ction of decimalliUJ1lbets either unsigned or in thesi~-~Oscomplement systetn is the sameu in the binary case Taketbe 10s ootnplementof the subtrahend and add i~ to themin~nd ManyooDlputerslULvespeciaJ hardware to perform arithmeticcalculations directly withdecilnal oumbers in 8tDThe~u$etofthecoBlPuter can specify programliled Wtnlctionsto JOdonn the aDtiuJletiP oPmwoowithdeQmal n1UQ~ ~ywithout having to convell them to binary

Binafy codes for decimal digits requirea minimum of four bits per digit Many different codes can be formulated by~gjng four bits into IQ distinct combinations BP) and three other representative codes are shown in Table L5 Each code uses only 10 out ofa pOssible middot16 bit combinations that can be arranged with four bits The other six Unused cOmbinations have no meaning amt should be avoided BCD and the 2421 code are examplesofweigbted codes In a weigbtedcodeeach bit position

juBsigned a weighting f~in~awaythat eaehdigitcanbe ev~by 8dding the wei~ oran the lsin thecoded combination The BCD code has weights of8 42 and I which cotteshy

spondiothe powe1Of-two valuesofeaCh bitTbebitasSignmeatOll0 for example is interpreted by the weights to represent dedma16beCause 8 X 0 +4xt +2 Xl +IX 0 6Thebit combination 1101 when weighted by the ~ve digits 2421 gives themiddotdeCimal equivalent of 2 X I +4 gtlt I + 2 KO + 1 X 1 = 7 Note that some digits cantle coded in lw9 possib)e

ways in the 2421Q)(feFOr inke decimal 4 can be asSigned to bitCombinadon 0100 or 1010 since botbcOmbinatibns add upto a totalweight of4

middot1$ Fou Dlf(et Blnqry Code$ for thtJledmol DIgits

~ IICD DIgIt sal MZt Exeet) 8 4 -~1

0 1

000() middotmiddotmiddot0000 001)1 0001

oem 0100

0000 0111

2 0010 0010 0101 0110 3 0011 OQU 0110 0101

4 0100 0100 0111 oroo 5 0101 lOll 1000 1011 6 OlIO middot1100 1001 1010 7 middot0111 1101 1010 J001 8 1000 IUOmiddot 1011 1000 9 1001 11U 1100 1111

1010 oloi 0000 0001 Uaused IOU 0110 middotOOOl 0010 bit 1100 0111 0010 0011 combishynations

nOl 1110

lOW 1001

HOI 1110

1100 1101

1111 IOU) 1111 1110

22 ChaptfrliDfgltalSystemsaod Btoary Numbers

I1te 2421 rind the

e~l3~es are exampks Of self-complementing codes Such codes have~propertyjbatthe9s~plement ofa deCimal nfunberigobtairted directly by chang-

ing 1$ to O~$ finO tYSCfb1 sie~bycomple~mmgeaCh bit in the pattem)For example decshyimat3~Sis re~ fu tbeexcess3code as 01101100 1000 The 9s compl~ntof 604 isrepRse~l00liOOllelliwbich isobiainc(himply by complementing each bit of the

code (as with the 1 s coinpl~ofbin~rillDlbers)middot Theexcess~3code has been used in some oldel coritputers because of its selfcpmplement~

ing property Excess-3 is an unweighted code inwhich each codedcombinationis obtained-fJQm the corresPonQing bin3ryvalueplus 3 Note that the BCD code is1~ self-complementing TheS 4 ~~ Icode isan example of assigning both positive and negative weights to ~ decimalcodeInthis case the bit combiDation 0110isin~reted as oecimal2 and is calcu-

latedfrom8XO+4X 1 + (2) X 1 + (1XO=2 ~

Cra Code _ _ J

l1te output data QfmaJlfpbYsicaimiddot $)ShmlS are quantities that are continuous These data bemiddottonverted~digiWforuitJefore they art applied toaliigital system Contfuuous or ~nisCOIl~middotUitodigitalfonn bymeans of an rumlog~digitalConverter It is times ~~ent tousethe Gray code slown inTable 16torepresehtdigiuU data that have oon~ fMn8D8l08 dasaTheadvantage of th( Gray cOOeover thesllaigbt binary nIl11l1hPt~

~lt~thatoWY~ hit in the codegroup changeSin going from one number to the For examplcentbullin-goingfrom 1 to 8dleGray code cblngesfrom 0100 to 1100Only the fust changesfromOto l~the odter~ I)its mnaintbesame By contrast With binary numbers change from 7 to 8wrube from 0111 to lOOOwhich causes allfciur bits to change valUes

TabielAi GtPyCode

01 Decl COde Equivalent

~ 0000 0001 0011 OOlG 011Q Olll OlO 0100 1100 11m 1111 1110 lOlQ 1011

lOOt i

1000

o 1 ~ 3

4 5 6 7 8 9

10 11

12 13 14 15

SectIOnl7 BlnarYCod~s 23

The Gray code is used in applications in which the normal sequenceOrbiruuy rium~may produce an error orambiguitymiddot during themiddot transitionfrom ODeDWDber to the next If binary numbersareusec1 acbange forexaJIlple nom 0111 to 1000 may produce anintermediateershyroneous number 1001 if the value ofthe rigbtmost bit takes longer to -change than domiddotthe valshyues of the other three bits The Graycode elimb1ates this problem since only one bit changes its valve dUrlng aily transition be~een two numbers I

Atypical appli-cation ofmiddotthe Gray code is the representation of analog data by a Continu ous change in the angUlar position of a shaft The sQaftmiddot is partitioned into segments ana each segment is assigned a number If adJacent segments are made to correspond with the Qray-Codesequence ambiguity is eliminated between the angle of thesbaft and the value encoded by the sensor

Character Code

Many applications of digital computers require the handling not only ofnumberS but also of other characterS or symbols such as the letters of the alphabet For mstancean insurance comshypany with thousands of policyholders will use a computeX to process its files To represent the names and other pertinent information it is necessary to fonnulate bull binary code for the letshyters ofthe alphabet In additiQt1 the same binary qode must represent numerals and special Characters (such as $) An a1phanumeric character setis a set ofeiements that inclUdes the 10 decimal digits the 26leuersofthealp1iabe and a nutnbeof special~S~ a set conshytains between 36~d 64 elements ifonIy capital letters areincltided or between 64 and 128 e1eJDents ifboth uppercasemiddot and lowercllle etters are inclUded In the first case we need a bi- nary code ofsix bits and in the second we need a binary cooeO(seVM bits

The standaM binary code for the alphanumeric char8cters is the American Stahdard Code for Information InterCbange (A~n) which uses seven bitS to code 128 characters asshoWn in Table 17 The seven bitsof the code are desipted by b~through h With h the mostsigshynificant bit ~e leUer A for example is represented inASCn as l(l()()()Ol (column l00~tOw 0001) The Ascn ()()de also contains 94 graphic characters that can be printed and 34 nonshyprinting characters used for variQUS control functions The graphic characters consist of the 26 uppercase letters (A through Z) the 26 lowercase letters (a through z) the 10 numerals (0 through 9) and 32 special printable characters suchaS andS

The 34 control characters are designated in the ASCTItable With abbreviated nalne8 They are listed again below the table with their functional names The control characters are used fQr routing data and arranging the printed text into a prescribed format~ There are three types of control characters format effectors information separatOrs andcommumc~on-COnlrpl char~ IlCters Format effectors are characters that control the layout ofprinting They inciude the fashymiliar word pr6cessorand typewriter controlssucb 8$ bac~pace (BS) horizontal tabulation (HT) and carriage return (CR) Information separators are used to separatetbe data into divi~ sions such as paragraphs and pages Theyinclude characters such as ~ordseparator (RS)and file separator (FS)The cODlIDunication-control characters are uSefulduriDgthe transmission of text between remote tenninals EXllll1plesof conlmunicatiOn(ODtiol~ are STX (start oftext)-and ETX (end of text) whicb are used toframe a text mesaagetnQlSlnitted through telephone wires

24 Chap~er 1 Diglt8l Systems and Binary Numbers

rblel7 Amerkcm5tandard Code for Information (nterclHlnge(ASCII)

b~jbzb 000 001 010 on 100 101 no 111

0000 NUL )jLP SP () p P 0001 SOH OC1 1 A Q a q

R0010 STX OC2 2 B b r 0011 ETX DC3 3 C S Ii S

0100 EDT 0C4 $ 4 D~ T d t 0101 ENQ NAK 5 E iU e u OUO ACK SYN amp 6 F V f v 0111 BEL ETB 7 0 W g w 1000 B8 CAN ( S H K h x 1001 HT EM ) 9 I Y Y 1010 LF SU~ 1 Z j z lOll VT ESC + 1lt r k UOO FF PS lt L I I 1101 Cit OS == - M 1 m 1110 SO R~ N 1 n shy

-0PIt st US f 1 0 0 DEL

r- Control characten

NUL NlI]l DlE Data-inkescape SOH Start of hea~ng DC1 Device cOntroll STX Start of text DC2 DevIce io~1lOi2 ETX End (Jftext i DC3 Device corUlri1 3 OOT End oftraIlsmission ~4 DeVicecoQtrol4

ENQ ampqwry NAK Negativeackilowledge ACK

Acknowledge SVN Sync~nous idle

Btl Bell ETB End-of-tmnsnussionblOck sS Backspace CAN CanCel HT Horizontal tab EM End of mediUrlt LF Lintifeed SUB Substitute VT Vertical tab ESC escape FF form feed FS File separator CR Carriigeretum GS Group separator SO shift Ollt RS Reoord sepuator SI Shlftin US Unit separator SF S~e DEL Delete

ASCII is a seven-bit codebutrnostcompUters manipulate anejght-bit quantity asa unit called a byte Therefore ASCII characters most often are stored ~e per byte The

I biti~sometimesused forotlef purposes depending ontheapplicatio~lFor example printetS recognize eightmiddotbit AScn chaiacterS with themost sigoificaot bit ~twO An atkJlitlo

Section 18 Binary Storage and Registers 2S

128 eight-bit characters with the most significant bit set tol are used for other symbols such as the Greek alpbabet or italic tyIe font

Error-Dtectlng Code

To detect errors in data communication and processing aneigbth bit is sometimes added to the ASCll cbaracter to indicate its Panty Aparitybit is an extra hit included with a message to make the total num~ of ls either even or odd Consider the fo119wing two cbaracters and their even andodd parity

With even parity With odd parity Ascn A = 1000061 01000001 11000001 ASCI( T == 101deg100 11010100 01010100

1

- Ineacb casewe insert an extra bit in the leftmost position of the code to produce an even number of 1 s intQe cbaraeter for even parity or an odd number of 1 s in the character for odd parity In generlll one or tbe oth~r parity i~ adopted with even parity being more common

The parity biqsbelpful in detecting errors during the transmission ofinformation from one location to another nisfuJictiOD is bandIed by generating an even parity bit at the sending end for ~h character The eight-bit characters that include parity bits are transmitted to their desshytination The parity ofeachebaracter is thetichecked at the receiving~nd If the parity of the received cbaracter is Dot even then at1east on~bit has changed value dUring the trmlsmission This method detects one three or any odd combination of errors in each character tb8t is transshymitted An even combination oferrors however goes undetected and additioDaterror detic- shytion codes may be needed to take care of that possibility

What is done after an errQlis detected depends on the partieu~ application One possishybilityis to request retransrois~ion of the message on the assump~on that tbeenigtr was ranshyd()m andwill not occur again Thus if thereeeiverdetects a parityerrorit sends bai~ the ASCII NAK (negative acknowledge) control cnaracter consisting ofail even-parity eight bits lOOlOl01H no error is detectedthe ~iversends back anACK (aCkno~ledge) conshytrol character namely 0000011 O The sending end will respond middotto an NAK by tranSmitting the message again until the correct panty is received Ifmiddot after a number of attempts the transmission is still in error a message can be sent to the Operatai to check for malfunctions in the transmission path

BINARY STORAGE ANORECiISTEIlS

The binary infonnation inadigitalcomputermust have a physical e~stencein some medium for storing individual bits A binary cell is a device that possesses two stable sttes and is cashypable of storing pne bit (0 or 1) oflnfotlllation The input to tbe cell receives exciJation sigshynals that set it to one of the two states The output of the cell isa pbysicalquantity that distinguishes between the two states The irtformationstored in Ii cell is 1when the cell is in one stable state and degwhen the Cell is in the other stable state

26middot Chapter 1 Digital Systems and BtnaryNumbers

Registers

A register is a group of binary cells A register with n cells can store any discrete quantity of middot information thatcontains n bits The state ofa registeris an n-tuple ofls middotand Os with each bit designating the state of one cell in the register The C()ntent ofaregister is a function of the int~rpretation given to tbeinformation stored in it Consider fQf ex~ple a 16-bitregister with the following binary content

11 00001111001001

middot Aregjs~ with 16 cells can be in one of 216 possible statesIf one asstimesthat the content cif the register represents a binaryinteger then the register can store any binarydumber from Oto 216 - 1 For the patticularexample shown the content ofthe register is the binary equivshyalent(lftbe decimal number 50121 If one assumes instead that the register stores alpbanushy

middot meric characters of an eight-bit cooe then the content of the register is any two meaningful characters For tht ASCII code with anevenplirityplaced in the eighth most significant bit position the register contains thetwo charactersC (the lefunosteightbits) and I (the rigbt~ most eight bits) If however one in~rprets the content of the register to be four decimal dig- its represented by a four-bitcode tnenthe content of the register is a four-digit decimal number In theexcess-3 code the register holqs the decimal nutriber 9096 The content of the registe~is meaningless in BCD becau~e the bit combinatiOn ltob is 110t assfgned to any decshyimal digit From this example it is clear that a register can store discrete elements of inforshymation and that the same bit configuration Inay beinterpreted dlffe(ently for different types of data

tmiddotmiddotReglsterTrail Adigitalsystenlis characteriZed by its registers and the components thatpetfolin data proshy~ssingIIl digital sy~tems a rcentgister tra1lsfer operation is abasi operation that consists of

middot a transftr of hiJWy hUormation from one ~t of registers into ano$er set of registers transfer may be dir~ctfr9m one regist~r toanlt)ther or may pass througb datamiddotprocessing circuits to petformaD operation Figure L 1 illustratel the transfer of iidOrnuttion among regshyisters anddemonstratespictorlallY [the tr8ll~~ ofbinaryinformation from akeyboard a register in the memQryullit Thehlputunit~s assumed to have a keyboard1 control cuit and aninput register Each time a key is strock the control circuit enters an ImnV$_

lent eight-bit alphanumeric character coqe into the input register We shall assume that code used is the ASCII code with an odd-parity bit The information from the input regisshyter is transferred into the eight-least significant cells Qf a proeessOr register After transfer theinpui register is cleared to enable the control to insert a new eight-bit when the keyboard is struck again Each eight-bit character transferred to the pro1c4ess(raquo register is preceded by a shift of the previous character to the next eight cens on its left~

middot a transfer -of four characters is completed the processor registeris full and its contents transferred into a memory register The content stored in die memOry register shown in Figl came from the transfer of the characters J 0 H an~ N aftet the four ap)lroJ)riatt keys were struck

Section 18 Binary Storage and Registers 27

FIGURE 11 Transfer of information among registers

To process discrete quantities of infoiniatiori in binary form a computer m~st be promiddot vided with devices that hold the (lata to be processed and with circuit elements that manipmiddot ulate individual bits of irifonnation The device most commonly used for holding data is a register Binary variables~ manipulated by means of digital logic circuits Figure 12 il~ luslrates the process of adding two l()bit binary iUlmbers Themeniory unit which no[shy

mally consists of millions of registers is shown with only three ofits registers Thepait of the processor unit showncoDsistsmiddotofthree registers-RI R2 and R3~getherwith digital logic circuits that manipulate the bits of RI and R2 and transfer into R3 a binary number equal to their arithmetic sum Memory registers store information and are incapable of pr0shy

cessing the two operands However th~ information stored in meDij)iybanbetransferred to ~ processor registers and the resUlts obtainedin processor tegisters can be transferred back into ame~ry register for storage Untill)ecded again The diagram ~wsthe90ntents of two

operands transferred from twoJDemoryregisters into RI imd R2 The digital logic circuits produce the sum which is transfened to register R3 The contents of R3 can now be 1riUlsshyferredback to one of thetnemory registers

The last two examples demonstrated the infonncion-flow capabilitieSofa digital system in a simple manner Themiddot registets of the ~ystem are the basic ele~ents for Noring and holding the binary information~igitallogic circuits process the binary ihfonaation stored in the

28 Chapter 1 DigIt bullbull Systems and Binary Numbers

Sum

FIGURE 12 Eumple of blnarylnfonn~t1on processing

registers Digitallogiccirctiits and registers are covered InChQpteB 2 throQgh 6 The metlilOlY unit is ~xPIained ill 9aptet 7 Th~ descriptton of register opetJtions at the register level and the design of digital systems are covexed in Chapter 8

19 BINARY LOGIC

Binary logic deals with variables th~ take on two discrete valueund withoperations that sumelogicalmeaning~ The two val~s the variableussume may be called~ydifferent (true andalse yel and no etc) but for ourp1llpQSe it is cpqVenienttotbink in terms of and assign the values llUld O The binary logic intr0ducedin this section is equivalent to algebra oalledBoolean algebra The fannal presentation ofBoolean algebra is covered in detail in Chapter 2 The purpose ofthis seCtion is to introduce Boo algebra ina matmerandlate it to digitallogiccircuits andmiddotbinarYsignalsmiddot

Section 19 Sinary logic 29 ~

Itkltn of IInary logic

Binarylogic consists of binary v~les and a set of logica1middotoperatiQDS The variables are desigshy ~by lettell of thCalplWlet~such asA B C x yz etc with eaCh variable baving two and oniy

two distinct posSible valueS 1and O There are three basic logical operations AND ORand NOT

1 AN]) This ~peration is represented by adotorby the absence ~f an oPerator For example x bull y =z or xy = zis~ x ANDy is equalto z~ThelogicaloperationAND is interpreted to mean that z == 1 ifand only ift~ land y = 1 otherwise z = O (Reme~r that x y andzare binary v8riablesand canmiddotbe equal either to 1 or Omiddotand nothing eise)middot

2 OR This operation IS represented by a plus sign For example x + y =z is read x OR y is equal to z meaning that z 1 if x = iorif y = lorifbothx= 1 and y = 1 If bqth X - 0 andY Omeo z= O

3bull NOT This operation is repf6sented by a prime (sometimes by an overbar) For ~xample x =Z (or~ =z) is read notdsequalto 1 meiming that z iswkatx isnot In other

words ifx = 1 then z == 0 but if x == 0 tnenz = L TheNOT operationisals(1 reshyferred tolls the complement operation since it changes ~ 1 toOand a O to 1

bull bull lt Binary logic resembles binary arithmetic and themiddot9peratioos ANDahd OR have similarishy

ties to multiplication and addition respectively In fac~ the symbols used for AND and OR are the same as those used for multiplication and addition However binary lOgic should not be conshyfused withbinaryarithIrietic One should realize thatan arithmetic variable designates a numshyber that may consist of many digits A logicmiddot variable is always either 1 or O For example in binary arithmetic we have I +1 =10(read~one plus ()fie is equal to 2) whereas in binary logicwe have 1 + 1 1 (read one OR onds equal to one)

For each combination of the values oix and y bullthere isa value of ~ $pecifiedby the definishytion of the logical operation D~linitiops of logical~perations maybe listed in a compacHorm called truth tables A truth table is atable of anpbssible combinations ofthe variables $howshying the relation between the values that the variables may take and the resultof the operation The truth tables for th~ operations ANDand OR with variables x and y are obtained by lis~ng

all possible values that the variables may have when combined in pairs bull For each combination the resUlt of die operation 18 theillistedin a separate row The truth tables for ANDORand

NOT are given in Table La These tables clearly demonstrate the definitionf the operatibns

Table 18 Truth TcibJts of Logical Operations

AND OR NOT

x y xmiddoty x y x+y

0 0 0 0 0 0 1 0 0 1

10

1 0 d 1 0 1 I 1 1 1 1 1

bull~lt~m

30 Chapter 1

Logk Gates

Digital Systems and Binary Numbers

Logic gates are electronic cirellit that operate on ~

variable

or mpre mput tignals to produce an output signal Electrical signals sUch as voltages orrutrents exist as analog signals having values over a given taDgebull saYOt03 V but in a digital system are interpreted to be either of two recognizable values 0 or 1 Voltage~opetated logic Circuits respond to two separate voltshyage levels that represent a binary varjable equal to logic I bt logic O For example a partic- ular digital system may define 10gicOas a signal equal to 0 volts lind logic 1 asa signal equal to 3 volts In practice each voltage levelhiS an acceptable rangeas shown in Fig 13

The input te~nals of digital cikuits accePt binary signals within the allowable range and respond at the output terininals with binary signals that fall within the specified range The intermediate region between the aJl()wed regions is crossed only during aState transition Any desired information for computing or control can be operated tm by passing binary signals through variQUS combinatioDsof logic gates with each signal represebting a particular binary

The graphic symbols used to deSignate themiddotthree types of gates are Mown in Fig 14 The

gates are blocks of hardware that prooocc tbeequivalent of1ogic~1 orlogic() output signals

Volts

- FGURl13

x

y

Exampleof binary slgnaJs

Signal ratlge for logieO

(a)~omiddotinput AND gate

FIGURE 14 SymbOls for digital logic circuits

(c)NOT gate or invert~

Problems 31

x-lU 1 11 P 0

y 0 0 11 1 ~

ANDxy 0 0 rTl 00

ORX+Y~ NOT x 11 0 0 I 1 1

FIGURE 15 Input-output 5Igals for gates

FIGURE 1

A B C

Gates WIth mlltlple JnpUU

A B C lJ

~

if inPllt logic ~ts are satisfied Theinput signals xaDd y intheNDaadQR gates may exist in ~ oHow-possible states 00 10 11 or 01 Il1ese ibpu~ampignals_ shown inFig lStoshygetber with the corresponding output signal foreach PfCThI~tiaiug~iDustrate the reshysponse ofeaclt gate to the four input signal~The~llisofthetiminadiagram represents time and the vertical axis sbo~~~~ it cbapg~botwcen~possible voltshy

age levels The low level represents logic O tJte high level l1lteAND _ responds With a logic ~ ~tput sipl wh~ both input ~~)e 1middot1~ lIieOR S-~with a logic 1 outpUt signal ifanylnput sigrudis lOgic 1 TheNOTgateis~~ to BUll invedet The reason for~nameis~t froJn the signalmsponae inmiddottbe timitt8 diagramwhicbsbows that theoUtputsignal inverts the logic sense of tbeiDpUtsigll8l

AND and OR gates may bavei)lQte tbantwQinputs M AND8_~itti ~input$andan OR gate with foU) inputs are shown in Fig 16 The three-inPllt AND gate responds With logic 1 output if all tbreeinputs arelogic 11jleoutputproduces lOgic Oifanymput is logic O-The

four-input OR gate responds withlogic 1 ifany input is logic 1 its clu1ptltllCCoines logic oonly when all inputs are logic O

Answers to prvblems marked with middotappearaHbe ClOd ofthe ~

11 lJltthe octal and beXadecimalliurilbers trom16ui 32UdngA B1l1ld C forthebst~ digits Usttbe numbers from 8 to 28 in base13 bull

I

12t What is the exact D1Jllbcr of bytes in a system that contains lta) 32Kbytoe (b)64M ~and (e) 640 byte$ middot7 t

32 Chapter 1 Digital Systemsand Binary Numbers

13 Convert the following nu~bers with the indicated bases to decimal (a) (4310)s (b) (198hz (c) (735)8 (d) (525)6

14 Whllt is the largest binary number that can be expressed with 14 bits WhlIt are the equivaleDt ~~ iinal and hexadecimal numbei-s

--

15 Detemrine the base of thl1 numbers in each case for the following operatio~ to be correct (a) 142 = 5 (b) 5414 = 13 (C) 24+ 17 == 40

16 The solution$to the q~cequation xl - Ux +22 oare l1 3 arid x =6 What is the base of the numbers

17 Convertthehexadecimal ntmIher 68BE to bitiary and then convert it ~mbinary to octal

18 I Convert the decirpal number 431 to binary in tWo ways (a) Convertd~y to binary (b) conshyvert first to hexadecinla1 and then from ~decimalwbinary Which method is faster

19 amppress the following nqrnbersin decinud (a) IQ11O0101)z (b) (l65his (c)(2624)8 (d) (FAFA) 16

(e) (10101010)2

110 Convert the following binary numbers tobexadeoimal and todecitnal (a) UOOlO (b) 110010 Explain why the deCimal answer in (b)is 4 times that in (a)

111 Perform the followingdiviskmin binary 11 Ion + l()t

112 Add IlniImultiply tfle following numberswiihout converting them to decimal (a) Binary nuniberilOll aiIdlOh (b) He~uumbers 2E aDd 34

1~)( Do thefoHowing con~ersionproblems (a) CorivertCiecimal2731S to binary (b) CakUlate the binary eqUivalent (f 213 outto eight pl~Then Convert from binary to

imalHowgJose istbe result to 2131 (c) Convert the binary resukin (b) into hexad~ lb~oonvert ~result to decimal Is answer tbesame

114 Obtain the is 8nd 2s complementsofthe foUowing binaryDumbcentrs (aj l)()()(J()OO (b) OOOOOOOO (c) 11011010 (d)01l10110 (e) 10000101 (0 11111111

115 Find the 9s and the 10s complement of the following detimal numbers (a) 52734630 (b) 63325600 (c) 25000009 (d) 00000000

116 (a) Find the 16s complement of B2FA (b) Convert B2FA to binary (c) Find the 2scomplement ofthe resultin (b) (d) Convert the answer in (c)to hex~malandco~ with ihe an~wer in (a)

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 21: Chapter 01 - Mano

Sectionl 7 Binary Codes 21

The suQtr8ction of decimalliUJ1lbets either unsigned or in thesi~-~Oscomplement systetn is the sameu in the binary case Taketbe 10s ootnplementof the subtrahend and add i~ to themin~nd ManyooDlputerslULvespeciaJ hardware to perform arithmeticcalculations directly withdecilnal oumbers in 8tDThe~u$etofthecoBlPuter can specify programliled Wtnlctionsto JOdonn the aDtiuJletiP oPmwoowithdeQmal n1UQ~ ~ywithout having to convell them to binary

Binafy codes for decimal digits requirea minimum of four bits per digit Many different codes can be formulated by~gjng four bits into IQ distinct combinations BP) and three other representative codes are shown in Table L5 Each code uses only 10 out ofa pOssible middot16 bit combinations that can be arranged with four bits The other six Unused cOmbinations have no meaning amt should be avoided BCD and the 2421 code are examplesofweigbted codes In a weigbtedcodeeach bit position

juBsigned a weighting f~in~awaythat eaehdigitcanbe ev~by 8dding the wei~ oran the lsin thecoded combination The BCD code has weights of8 42 and I which cotteshy

spondiothe powe1Of-two valuesofeaCh bitTbebitasSignmeatOll0 for example is interpreted by the weights to represent dedma16beCause 8 X 0 +4xt +2 Xl +IX 0 6Thebit combination 1101 when weighted by the ~ve digits 2421 gives themiddotdeCimal equivalent of 2 X I +4 gtlt I + 2 KO + 1 X 1 = 7 Note that some digits cantle coded in lw9 possib)e

ways in the 2421Q)(feFOr inke decimal 4 can be asSigned to bitCombinadon 0100 or 1010 since botbcOmbinatibns add upto a totalweight of4

middot1$ Fou Dlf(et Blnqry Code$ for thtJledmol DIgits

~ IICD DIgIt sal MZt Exeet) 8 4 -~1

0 1

000() middotmiddotmiddot0000 001)1 0001

oem 0100

0000 0111

2 0010 0010 0101 0110 3 0011 OQU 0110 0101

4 0100 0100 0111 oroo 5 0101 lOll 1000 1011 6 OlIO middot1100 1001 1010 7 middot0111 1101 1010 J001 8 1000 IUOmiddot 1011 1000 9 1001 11U 1100 1111

1010 oloi 0000 0001 Uaused IOU 0110 middotOOOl 0010 bit 1100 0111 0010 0011 combishynations

nOl 1110

lOW 1001

HOI 1110

1100 1101

1111 IOU) 1111 1110

22 ChaptfrliDfgltalSystemsaod Btoary Numbers

I1te 2421 rind the

e~l3~es are exampks Of self-complementing codes Such codes have~propertyjbatthe9s~plement ofa deCimal nfunberigobtairted directly by chang-

ing 1$ to O~$ finO tYSCfb1 sie~bycomple~mmgeaCh bit in the pattem)For example decshyimat3~Sis re~ fu tbeexcess3code as 01101100 1000 The 9s compl~ntof 604 isrepRse~l00liOOllelliwbich isobiainc(himply by complementing each bit of the

code (as with the 1 s coinpl~ofbin~rillDlbers)middot Theexcess~3code has been used in some oldel coritputers because of its selfcpmplement~

ing property Excess-3 is an unweighted code inwhich each codedcombinationis obtained-fJQm the corresPonQing bin3ryvalueplus 3 Note that the BCD code is1~ self-complementing TheS 4 ~~ Icode isan example of assigning both positive and negative weights to ~ decimalcodeInthis case the bit combiDation 0110isin~reted as oecimal2 and is calcu-

latedfrom8XO+4X 1 + (2) X 1 + (1XO=2 ~

Cra Code _ _ J

l1te output data QfmaJlfpbYsicaimiddot $)ShmlS are quantities that are continuous These data bemiddottonverted~digiWforuitJefore they art applied toaliigital system Contfuuous or ~nisCOIl~middotUitodigitalfonn bymeans of an rumlog~digitalConverter It is times ~~ent tousethe Gray code slown inTable 16torepresehtdigiuU data that have oon~ fMn8D8l08 dasaTheadvantage of th( Gray cOOeover thesllaigbt binary nIl11l1hPt~

~lt~thatoWY~ hit in the codegroup changeSin going from one number to the For examplcentbullin-goingfrom 1 to 8dleGray code cblngesfrom 0100 to 1100Only the fust changesfromOto l~the odter~ I)its mnaintbesame By contrast With binary numbers change from 7 to 8wrube from 0111 to lOOOwhich causes allfciur bits to change valUes

TabielAi GtPyCode

01 Decl COde Equivalent

~ 0000 0001 0011 OOlG 011Q Olll OlO 0100 1100 11m 1111 1110 lOlQ 1011

lOOt i

1000

o 1 ~ 3

4 5 6 7 8 9

10 11

12 13 14 15

SectIOnl7 BlnarYCod~s 23

The Gray code is used in applications in which the normal sequenceOrbiruuy rium~may produce an error orambiguitymiddot during themiddot transitionfrom ODeDWDber to the next If binary numbersareusec1 acbange forexaJIlple nom 0111 to 1000 may produce anintermediateershyroneous number 1001 if the value ofthe rigbtmost bit takes longer to -change than domiddotthe valshyues of the other three bits The Graycode elimb1ates this problem since only one bit changes its valve dUrlng aily transition be~een two numbers I

Atypical appli-cation ofmiddotthe Gray code is the representation of analog data by a Continu ous change in the angUlar position of a shaft The sQaftmiddot is partitioned into segments ana each segment is assigned a number If adJacent segments are made to correspond with the Qray-Codesequence ambiguity is eliminated between the angle of thesbaft and the value encoded by the sensor

Character Code

Many applications of digital computers require the handling not only ofnumberS but also of other characterS or symbols such as the letters of the alphabet For mstancean insurance comshypany with thousands of policyholders will use a computeX to process its files To represent the names and other pertinent information it is necessary to fonnulate bull binary code for the letshyters ofthe alphabet In additiQt1 the same binary qode must represent numerals and special Characters (such as $) An a1phanumeric character setis a set ofeiements that inclUdes the 10 decimal digits the 26leuersofthealp1iabe and a nutnbeof special~S~ a set conshytains between 36~d 64 elements ifonIy capital letters areincltided or between 64 and 128 e1eJDents ifboth uppercasemiddot and lowercllle etters are inclUded In the first case we need a bi- nary code ofsix bits and in the second we need a binary cooeO(seVM bits

The standaM binary code for the alphanumeric char8cters is the American Stahdard Code for Information InterCbange (A~n) which uses seven bitS to code 128 characters asshoWn in Table 17 The seven bitsof the code are desipted by b~through h With h the mostsigshynificant bit ~e leUer A for example is represented inASCn as l(l()()()Ol (column l00~tOw 0001) The Ascn ()()de also contains 94 graphic characters that can be printed and 34 nonshyprinting characters used for variQUS control functions The graphic characters consist of the 26 uppercase letters (A through Z) the 26 lowercase letters (a through z) the 10 numerals (0 through 9) and 32 special printable characters suchaS andS

The 34 control characters are designated in the ASCTItable With abbreviated nalne8 They are listed again below the table with their functional names The control characters are used fQr routing data and arranging the printed text into a prescribed format~ There are three types of control characters format effectors information separatOrs andcommumc~on-COnlrpl char~ IlCters Format effectors are characters that control the layout ofprinting They inciude the fashymiliar word pr6cessorand typewriter controlssucb 8$ bac~pace (BS) horizontal tabulation (HT) and carriage return (CR) Information separators are used to separatetbe data into divi~ sions such as paragraphs and pages Theyinclude characters such as ~ordseparator (RS)and file separator (FS)The cODlIDunication-control characters are uSefulduriDgthe transmission of text between remote tenninals EXllll1plesof conlmunicatiOn(ODtiol~ are STX (start oftext)-and ETX (end of text) whicb are used toframe a text mesaagetnQlSlnitted through telephone wires

24 Chap~er 1 Diglt8l Systems and Binary Numbers

rblel7 Amerkcm5tandard Code for Information (nterclHlnge(ASCII)

b~jbzb 000 001 010 on 100 101 no 111

0000 NUL )jLP SP () p P 0001 SOH OC1 1 A Q a q

R0010 STX OC2 2 B b r 0011 ETX DC3 3 C S Ii S

0100 EDT 0C4 $ 4 D~ T d t 0101 ENQ NAK 5 E iU e u OUO ACK SYN amp 6 F V f v 0111 BEL ETB 7 0 W g w 1000 B8 CAN ( S H K h x 1001 HT EM ) 9 I Y Y 1010 LF SU~ 1 Z j z lOll VT ESC + 1lt r k UOO FF PS lt L I I 1101 Cit OS == - M 1 m 1110 SO R~ N 1 n shy

-0PIt st US f 1 0 0 DEL

r- Control characten

NUL NlI]l DlE Data-inkescape SOH Start of hea~ng DC1 Device cOntroll STX Start of text DC2 DevIce io~1lOi2 ETX End (Jftext i DC3 Device corUlri1 3 OOT End oftraIlsmission ~4 DeVicecoQtrol4

ENQ ampqwry NAK Negativeackilowledge ACK

Acknowledge SVN Sync~nous idle

Btl Bell ETB End-of-tmnsnussionblOck sS Backspace CAN CanCel HT Horizontal tab EM End of mediUrlt LF Lintifeed SUB Substitute VT Vertical tab ESC escape FF form feed FS File separator CR Carriigeretum GS Group separator SO shift Ollt RS Reoord sepuator SI Shlftin US Unit separator SF S~e DEL Delete

ASCII is a seven-bit codebutrnostcompUters manipulate anejght-bit quantity asa unit called a byte Therefore ASCII characters most often are stored ~e per byte The

I biti~sometimesused forotlef purposes depending ontheapplicatio~lFor example printetS recognize eightmiddotbit AScn chaiacterS with themost sigoificaot bit ~twO An atkJlitlo

Section 18 Binary Storage and Registers 2S

128 eight-bit characters with the most significant bit set tol are used for other symbols such as the Greek alpbabet or italic tyIe font

Error-Dtectlng Code

To detect errors in data communication and processing aneigbth bit is sometimes added to the ASCll cbaracter to indicate its Panty Aparitybit is an extra hit included with a message to make the total num~ of ls either even or odd Consider the fo119wing two cbaracters and their even andodd parity

With even parity With odd parity Ascn A = 1000061 01000001 11000001 ASCI( T == 101deg100 11010100 01010100

1

- Ineacb casewe insert an extra bit in the leftmost position of the code to produce an even number of 1 s intQe cbaraeter for even parity or an odd number of 1 s in the character for odd parity In generlll one or tbe oth~r parity i~ adopted with even parity being more common

The parity biqsbelpful in detecting errors during the transmission ofinformation from one location to another nisfuJictiOD is bandIed by generating an even parity bit at the sending end for ~h character The eight-bit characters that include parity bits are transmitted to their desshytination The parity ofeachebaracter is thetichecked at the receiving~nd If the parity of the received cbaracter is Dot even then at1east on~bit has changed value dUring the trmlsmission This method detects one three or any odd combination of errors in each character tb8t is transshymitted An even combination oferrors however goes undetected and additioDaterror detic- shytion codes may be needed to take care of that possibility

What is done after an errQlis detected depends on the partieu~ application One possishybilityis to request retransrois~ion of the message on the assump~on that tbeenigtr was ranshyd()m andwill not occur again Thus if thereeeiverdetects a parityerrorit sends bai~ the ASCII NAK (negative acknowledge) control cnaracter consisting ofail even-parity eight bits lOOlOl01H no error is detectedthe ~iversends back anACK (aCkno~ledge) conshytrol character namely 0000011 O The sending end will respond middotto an NAK by tranSmitting the message again until the correct panty is received Ifmiddot after a number of attempts the transmission is still in error a message can be sent to the Operatai to check for malfunctions in the transmission path

BINARY STORAGE ANORECiISTEIlS

The binary infonnation inadigitalcomputermust have a physical e~stencein some medium for storing individual bits A binary cell is a device that possesses two stable sttes and is cashypable of storing pne bit (0 or 1) oflnfotlllation The input to tbe cell receives exciJation sigshynals that set it to one of the two states The output of the cell isa pbysicalquantity that distinguishes between the two states The irtformationstored in Ii cell is 1when the cell is in one stable state and degwhen the Cell is in the other stable state

26middot Chapter 1 Digital Systems and BtnaryNumbers

Registers

A register is a group of binary cells A register with n cells can store any discrete quantity of middot information thatcontains n bits The state ofa registeris an n-tuple ofls middotand Os with each bit designating the state of one cell in the register The C()ntent ofaregister is a function of the int~rpretation given to tbeinformation stored in it Consider fQf ex~ple a 16-bitregister with the following binary content

11 00001111001001

middot Aregjs~ with 16 cells can be in one of 216 possible statesIf one asstimesthat the content cif the register represents a binaryinteger then the register can store any binarydumber from Oto 216 - 1 For the patticularexample shown the content ofthe register is the binary equivshyalent(lftbe decimal number 50121 If one assumes instead that the register stores alpbanushy

middot meric characters of an eight-bit cooe then the content of the register is any two meaningful characters For tht ASCII code with anevenplirityplaced in the eighth most significant bit position the register contains thetwo charactersC (the lefunosteightbits) and I (the rigbt~ most eight bits) If however one in~rprets the content of the register to be four decimal dig- its represented by a four-bitcode tnenthe content of the register is a four-digit decimal number In theexcess-3 code the register holqs the decimal nutriber 9096 The content of the registe~is meaningless in BCD becau~e the bit combinatiOn ltob is 110t assfgned to any decshyimal digit From this example it is clear that a register can store discrete elements of inforshymation and that the same bit configuration Inay beinterpreted dlffe(ently for different types of data

tmiddotmiddotReglsterTrail Adigitalsystenlis characteriZed by its registers and the components thatpetfolin data proshy~ssingIIl digital sy~tems a rcentgister tra1lsfer operation is abasi operation that consists of

middot a transftr of hiJWy hUormation from one ~t of registers into ano$er set of registers transfer may be dir~ctfr9m one regist~r toanlt)ther or may pass througb datamiddotprocessing circuits to petformaD operation Figure L 1 illustratel the transfer of iidOrnuttion among regshyisters anddemonstratespictorlallY [the tr8ll~~ ofbinaryinformation from akeyboard a register in the memQryullit Thehlputunit~s assumed to have a keyboard1 control cuit and aninput register Each time a key is strock the control circuit enters an ImnV$_

lent eight-bit alphanumeric character coqe into the input register We shall assume that code used is the ASCII code with an odd-parity bit The information from the input regisshyter is transferred into the eight-least significant cells Qf a proeessOr register After transfer theinpui register is cleared to enable the control to insert a new eight-bit when the keyboard is struck again Each eight-bit character transferred to the pro1c4ess(raquo register is preceded by a shift of the previous character to the next eight cens on its left~

middot a transfer -of four characters is completed the processor registeris full and its contents transferred into a memory register The content stored in die memOry register shown in Figl came from the transfer of the characters J 0 H an~ N aftet the four ap)lroJ)riatt keys were struck

Section 18 Binary Storage and Registers 27

FIGURE 11 Transfer of information among registers

To process discrete quantities of infoiniatiori in binary form a computer m~st be promiddot vided with devices that hold the (lata to be processed and with circuit elements that manipmiddot ulate individual bits of irifonnation The device most commonly used for holding data is a register Binary variables~ manipulated by means of digital logic circuits Figure 12 il~ luslrates the process of adding two l()bit binary iUlmbers Themeniory unit which no[shy

mally consists of millions of registers is shown with only three ofits registers Thepait of the processor unit showncoDsistsmiddotofthree registers-RI R2 and R3~getherwith digital logic circuits that manipulate the bits of RI and R2 and transfer into R3 a binary number equal to their arithmetic sum Memory registers store information and are incapable of pr0shy

cessing the two operands However th~ information stored in meDij)iybanbetransferred to ~ processor registers and the resUlts obtainedin processor tegisters can be transferred back into ame~ry register for storage Untill)ecded again The diagram ~wsthe90ntents of two

operands transferred from twoJDemoryregisters into RI imd R2 The digital logic circuits produce the sum which is transfened to register R3 The contents of R3 can now be 1riUlsshyferredback to one of thetnemory registers

The last two examples demonstrated the infonncion-flow capabilitieSofa digital system in a simple manner Themiddot registets of the ~ystem are the basic ele~ents for Noring and holding the binary information~igitallogic circuits process the binary ihfonaation stored in the

28 Chapter 1 DigIt bullbull Systems and Binary Numbers

Sum

FIGURE 12 Eumple of blnarylnfonn~t1on processing

registers Digitallogiccirctiits and registers are covered InChQpteB 2 throQgh 6 The metlilOlY unit is ~xPIained ill 9aptet 7 Th~ descriptton of register opetJtions at the register level and the design of digital systems are covexed in Chapter 8

19 BINARY LOGIC

Binary logic deals with variables th~ take on two discrete valueund withoperations that sumelogicalmeaning~ The two val~s the variableussume may be called~ydifferent (true andalse yel and no etc) but for ourp1llpQSe it is cpqVenienttotbink in terms of and assign the values llUld O The binary logic intr0ducedin this section is equivalent to algebra oalledBoolean algebra The fannal presentation ofBoolean algebra is covered in detail in Chapter 2 The purpose ofthis seCtion is to introduce Boo algebra ina matmerandlate it to digitallogiccircuits andmiddotbinarYsignalsmiddot

Section 19 Sinary logic 29 ~

Itkltn of IInary logic

Binarylogic consists of binary v~les and a set of logica1middotoperatiQDS The variables are desigshy ~by lettell of thCalplWlet~such asA B C x yz etc with eaCh variable baving two and oniy

two distinct posSible valueS 1and O There are three basic logical operations AND ORand NOT

1 AN]) This ~peration is represented by adotorby the absence ~f an oPerator For example x bull y =z or xy = zis~ x ANDy is equalto z~ThelogicaloperationAND is interpreted to mean that z == 1 ifand only ift~ land y = 1 otherwise z = O (Reme~r that x y andzare binary v8riablesand canmiddotbe equal either to 1 or Omiddotand nothing eise)middot

2 OR This operation IS represented by a plus sign For example x + y =z is read x OR y is equal to z meaning that z 1 if x = iorif y = lorifbothx= 1 and y = 1 If bqth X - 0 andY Omeo z= O

3bull NOT This operation is repf6sented by a prime (sometimes by an overbar) For ~xample x =Z (or~ =z) is read notdsequalto 1 meiming that z iswkatx isnot In other

words ifx = 1 then z == 0 but if x == 0 tnenz = L TheNOT operationisals(1 reshyferred tolls the complement operation since it changes ~ 1 toOand a O to 1

bull bull lt Binary logic resembles binary arithmetic and themiddot9peratioos ANDahd OR have similarishy

ties to multiplication and addition respectively In fac~ the symbols used for AND and OR are the same as those used for multiplication and addition However binary lOgic should not be conshyfused withbinaryarithIrietic One should realize thatan arithmetic variable designates a numshyber that may consist of many digits A logicmiddot variable is always either 1 or O For example in binary arithmetic we have I +1 =10(read~one plus ()fie is equal to 2) whereas in binary logicwe have 1 + 1 1 (read one OR onds equal to one)

For each combination of the values oix and y bullthere isa value of ~ $pecifiedby the definishytion of the logical operation D~linitiops of logical~perations maybe listed in a compacHorm called truth tables A truth table is atable of anpbssible combinations ofthe variables $howshying the relation between the values that the variables may take and the resultof the operation The truth tables for th~ operations ANDand OR with variables x and y are obtained by lis~ng

all possible values that the variables may have when combined in pairs bull For each combination the resUlt of die operation 18 theillistedin a separate row The truth tables for ANDORand

NOT are given in Table La These tables clearly demonstrate the definitionf the operatibns

Table 18 Truth TcibJts of Logical Operations

AND OR NOT

x y xmiddoty x y x+y

0 0 0 0 0 0 1 0 0 1

10

1 0 d 1 0 1 I 1 1 1 1 1

bull~lt~m

30 Chapter 1

Logk Gates

Digital Systems and Binary Numbers

Logic gates are electronic cirellit that operate on ~

variable

or mpre mput tignals to produce an output signal Electrical signals sUch as voltages orrutrents exist as analog signals having values over a given taDgebull saYOt03 V but in a digital system are interpreted to be either of two recognizable values 0 or 1 Voltage~opetated logic Circuits respond to two separate voltshyage levels that represent a binary varjable equal to logic I bt logic O For example a partic- ular digital system may define 10gicOas a signal equal to 0 volts lind logic 1 asa signal equal to 3 volts In practice each voltage levelhiS an acceptable rangeas shown in Fig 13

The input te~nals of digital cikuits accePt binary signals within the allowable range and respond at the output terininals with binary signals that fall within the specified range The intermediate region between the aJl()wed regions is crossed only during aState transition Any desired information for computing or control can be operated tm by passing binary signals through variQUS combinatioDsof logic gates with each signal represebting a particular binary

The graphic symbols used to deSignate themiddotthree types of gates are Mown in Fig 14 The

gates are blocks of hardware that prooocc tbeequivalent of1ogic~1 orlogic() output signals

Volts

- FGURl13

x

y

Exampleof binary slgnaJs

Signal ratlge for logieO

(a)~omiddotinput AND gate

FIGURE 14 SymbOls for digital logic circuits

(c)NOT gate or invert~

Problems 31

x-lU 1 11 P 0

y 0 0 11 1 ~

ANDxy 0 0 rTl 00

ORX+Y~ NOT x 11 0 0 I 1 1

FIGURE 15 Input-output 5Igals for gates

FIGURE 1

A B C

Gates WIth mlltlple JnpUU

A B C lJ

~

if inPllt logic ~ts are satisfied Theinput signals xaDd y intheNDaadQR gates may exist in ~ oHow-possible states 00 10 11 or 01 Il1ese ibpu~ampignals_ shown inFig lStoshygetber with the corresponding output signal foreach PfCThI~tiaiug~iDustrate the reshysponse ofeaclt gate to the four input signal~The~llisofthetiminadiagram represents time and the vertical axis sbo~~~~ it cbapg~botwcen~possible voltshy

age levels The low level represents logic O tJte high level l1lteAND _ responds With a logic ~ ~tput sipl wh~ both input ~~)e 1middot1~ lIieOR S-~with a logic 1 outpUt signal ifanylnput sigrudis lOgic 1 TheNOTgateis~~ to BUll invedet The reason for~nameis~t froJn the signalmsponae inmiddottbe timitt8 diagramwhicbsbows that theoUtputsignal inverts the logic sense of tbeiDpUtsigll8l

AND and OR gates may bavei)lQte tbantwQinputs M AND8_~itti ~input$andan OR gate with foU) inputs are shown in Fig 16 The three-inPllt AND gate responds With logic 1 output if all tbreeinputs arelogic 11jleoutputproduces lOgic Oifanymput is logic O-The

four-input OR gate responds withlogic 1 ifany input is logic 1 its clu1ptltllCCoines logic oonly when all inputs are logic O

Answers to prvblems marked with middotappearaHbe ClOd ofthe ~

11 lJltthe octal and beXadecimalliurilbers trom16ui 32UdngA B1l1ld C forthebst~ digits Usttbe numbers from 8 to 28 in base13 bull

I

12t What is the exact D1Jllbcr of bytes in a system that contains lta) 32Kbytoe (b)64M ~and (e) 640 byte$ middot7 t

32 Chapter 1 Digital Systemsand Binary Numbers

13 Convert the following nu~bers with the indicated bases to decimal (a) (4310)s (b) (198hz (c) (735)8 (d) (525)6

14 Whllt is the largest binary number that can be expressed with 14 bits WhlIt are the equivaleDt ~~ iinal and hexadecimal numbei-s

--

15 Detemrine the base of thl1 numbers in each case for the following operatio~ to be correct (a) 142 = 5 (b) 5414 = 13 (C) 24+ 17 == 40

16 The solution$to the q~cequation xl - Ux +22 oare l1 3 arid x =6 What is the base of the numbers

17 Convertthehexadecimal ntmIher 68BE to bitiary and then convert it ~mbinary to octal

18 I Convert the decirpal number 431 to binary in tWo ways (a) Convertd~y to binary (b) conshyvert first to hexadecinla1 and then from ~decimalwbinary Which method is faster

19 amppress the following nqrnbersin decinud (a) IQ11O0101)z (b) (l65his (c)(2624)8 (d) (FAFA) 16

(e) (10101010)2

110 Convert the following binary numbers tobexadeoimal and todecitnal (a) UOOlO (b) 110010 Explain why the deCimal answer in (b)is 4 times that in (a)

111 Perform the followingdiviskmin binary 11 Ion + l()t

112 Add IlniImultiply tfle following numberswiihout converting them to decimal (a) Binary nuniberilOll aiIdlOh (b) He~uumbers 2E aDd 34

1~)( Do thefoHowing con~ersionproblems (a) CorivertCiecimal2731S to binary (b) CakUlate the binary eqUivalent (f 213 outto eight pl~Then Convert from binary to

imalHowgJose istbe result to 2131 (c) Convert the binary resukin (b) into hexad~ lb~oonvert ~result to decimal Is answer tbesame

114 Obtain the is 8nd 2s complementsofthe foUowing binaryDumbcentrs (aj l)()()(J()OO (b) OOOOOOOO (c) 11011010 (d)01l10110 (e) 10000101 (0 11111111

115 Find the 9s and the 10s complement of the following detimal numbers (a) 52734630 (b) 63325600 (c) 25000009 (d) 00000000

116 (a) Find the 16s complement of B2FA (b) Convert B2FA to binary (c) Find the 2scomplement ofthe resultin (b) (d) Convert the answer in (c)to hex~malandco~ with ihe an~wer in (a)

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 22: Chapter 01 - Mano

22 ChaptfrliDfgltalSystemsaod Btoary Numbers

I1te 2421 rind the

e~l3~es are exampks Of self-complementing codes Such codes have~propertyjbatthe9s~plement ofa deCimal nfunberigobtairted directly by chang-

ing 1$ to O~$ finO tYSCfb1 sie~bycomple~mmgeaCh bit in the pattem)For example decshyimat3~Sis re~ fu tbeexcess3code as 01101100 1000 The 9s compl~ntof 604 isrepRse~l00liOOllelliwbich isobiainc(himply by complementing each bit of the

code (as with the 1 s coinpl~ofbin~rillDlbers)middot Theexcess~3code has been used in some oldel coritputers because of its selfcpmplement~

ing property Excess-3 is an unweighted code inwhich each codedcombinationis obtained-fJQm the corresPonQing bin3ryvalueplus 3 Note that the BCD code is1~ self-complementing TheS 4 ~~ Icode isan example of assigning both positive and negative weights to ~ decimalcodeInthis case the bit combiDation 0110isin~reted as oecimal2 and is calcu-

latedfrom8XO+4X 1 + (2) X 1 + (1XO=2 ~

Cra Code _ _ J

l1te output data QfmaJlfpbYsicaimiddot $)ShmlS are quantities that are continuous These data bemiddottonverted~digiWforuitJefore they art applied toaliigital system Contfuuous or ~nisCOIl~middotUitodigitalfonn bymeans of an rumlog~digitalConverter It is times ~~ent tousethe Gray code slown inTable 16torepresehtdigiuU data that have oon~ fMn8D8l08 dasaTheadvantage of th( Gray cOOeover thesllaigbt binary nIl11l1hPt~

~lt~thatoWY~ hit in the codegroup changeSin going from one number to the For examplcentbullin-goingfrom 1 to 8dleGray code cblngesfrom 0100 to 1100Only the fust changesfromOto l~the odter~ I)its mnaintbesame By contrast With binary numbers change from 7 to 8wrube from 0111 to lOOOwhich causes allfciur bits to change valUes

TabielAi GtPyCode

01 Decl COde Equivalent

~ 0000 0001 0011 OOlG 011Q Olll OlO 0100 1100 11m 1111 1110 lOlQ 1011

lOOt i

1000

o 1 ~ 3

4 5 6 7 8 9

10 11

12 13 14 15

SectIOnl7 BlnarYCod~s 23

The Gray code is used in applications in which the normal sequenceOrbiruuy rium~may produce an error orambiguitymiddot during themiddot transitionfrom ODeDWDber to the next If binary numbersareusec1 acbange forexaJIlple nom 0111 to 1000 may produce anintermediateershyroneous number 1001 if the value ofthe rigbtmost bit takes longer to -change than domiddotthe valshyues of the other three bits The Graycode elimb1ates this problem since only one bit changes its valve dUrlng aily transition be~een two numbers I

Atypical appli-cation ofmiddotthe Gray code is the representation of analog data by a Continu ous change in the angUlar position of a shaft The sQaftmiddot is partitioned into segments ana each segment is assigned a number If adJacent segments are made to correspond with the Qray-Codesequence ambiguity is eliminated between the angle of thesbaft and the value encoded by the sensor

Character Code

Many applications of digital computers require the handling not only ofnumberS but also of other characterS or symbols such as the letters of the alphabet For mstancean insurance comshypany with thousands of policyholders will use a computeX to process its files To represent the names and other pertinent information it is necessary to fonnulate bull binary code for the letshyters ofthe alphabet In additiQt1 the same binary qode must represent numerals and special Characters (such as $) An a1phanumeric character setis a set ofeiements that inclUdes the 10 decimal digits the 26leuersofthealp1iabe and a nutnbeof special~S~ a set conshytains between 36~d 64 elements ifonIy capital letters areincltided or between 64 and 128 e1eJDents ifboth uppercasemiddot and lowercllle etters are inclUded In the first case we need a bi- nary code ofsix bits and in the second we need a binary cooeO(seVM bits

The standaM binary code for the alphanumeric char8cters is the American Stahdard Code for Information InterCbange (A~n) which uses seven bitS to code 128 characters asshoWn in Table 17 The seven bitsof the code are desipted by b~through h With h the mostsigshynificant bit ~e leUer A for example is represented inASCn as l(l()()()Ol (column l00~tOw 0001) The Ascn ()()de also contains 94 graphic characters that can be printed and 34 nonshyprinting characters used for variQUS control functions The graphic characters consist of the 26 uppercase letters (A through Z) the 26 lowercase letters (a through z) the 10 numerals (0 through 9) and 32 special printable characters suchaS andS

The 34 control characters are designated in the ASCTItable With abbreviated nalne8 They are listed again below the table with their functional names The control characters are used fQr routing data and arranging the printed text into a prescribed format~ There are three types of control characters format effectors information separatOrs andcommumc~on-COnlrpl char~ IlCters Format effectors are characters that control the layout ofprinting They inciude the fashymiliar word pr6cessorand typewriter controlssucb 8$ bac~pace (BS) horizontal tabulation (HT) and carriage return (CR) Information separators are used to separatetbe data into divi~ sions such as paragraphs and pages Theyinclude characters such as ~ordseparator (RS)and file separator (FS)The cODlIDunication-control characters are uSefulduriDgthe transmission of text between remote tenninals EXllll1plesof conlmunicatiOn(ODtiol~ are STX (start oftext)-and ETX (end of text) whicb are used toframe a text mesaagetnQlSlnitted through telephone wires

24 Chap~er 1 Diglt8l Systems and Binary Numbers

rblel7 Amerkcm5tandard Code for Information (nterclHlnge(ASCII)

b~jbzb 000 001 010 on 100 101 no 111

0000 NUL )jLP SP () p P 0001 SOH OC1 1 A Q a q

R0010 STX OC2 2 B b r 0011 ETX DC3 3 C S Ii S

0100 EDT 0C4 $ 4 D~ T d t 0101 ENQ NAK 5 E iU e u OUO ACK SYN amp 6 F V f v 0111 BEL ETB 7 0 W g w 1000 B8 CAN ( S H K h x 1001 HT EM ) 9 I Y Y 1010 LF SU~ 1 Z j z lOll VT ESC + 1lt r k UOO FF PS lt L I I 1101 Cit OS == - M 1 m 1110 SO R~ N 1 n shy

-0PIt st US f 1 0 0 DEL

r- Control characten

NUL NlI]l DlE Data-inkescape SOH Start of hea~ng DC1 Device cOntroll STX Start of text DC2 DevIce io~1lOi2 ETX End (Jftext i DC3 Device corUlri1 3 OOT End oftraIlsmission ~4 DeVicecoQtrol4

ENQ ampqwry NAK Negativeackilowledge ACK

Acknowledge SVN Sync~nous idle

Btl Bell ETB End-of-tmnsnussionblOck sS Backspace CAN CanCel HT Horizontal tab EM End of mediUrlt LF Lintifeed SUB Substitute VT Vertical tab ESC escape FF form feed FS File separator CR Carriigeretum GS Group separator SO shift Ollt RS Reoord sepuator SI Shlftin US Unit separator SF S~e DEL Delete

ASCII is a seven-bit codebutrnostcompUters manipulate anejght-bit quantity asa unit called a byte Therefore ASCII characters most often are stored ~e per byte The

I biti~sometimesused forotlef purposes depending ontheapplicatio~lFor example printetS recognize eightmiddotbit AScn chaiacterS with themost sigoificaot bit ~twO An atkJlitlo

Section 18 Binary Storage and Registers 2S

128 eight-bit characters with the most significant bit set tol are used for other symbols such as the Greek alpbabet or italic tyIe font

Error-Dtectlng Code

To detect errors in data communication and processing aneigbth bit is sometimes added to the ASCll cbaracter to indicate its Panty Aparitybit is an extra hit included with a message to make the total num~ of ls either even or odd Consider the fo119wing two cbaracters and their even andodd parity

With even parity With odd parity Ascn A = 1000061 01000001 11000001 ASCI( T == 101deg100 11010100 01010100

1

- Ineacb casewe insert an extra bit in the leftmost position of the code to produce an even number of 1 s intQe cbaraeter for even parity or an odd number of 1 s in the character for odd parity In generlll one or tbe oth~r parity i~ adopted with even parity being more common

The parity biqsbelpful in detecting errors during the transmission ofinformation from one location to another nisfuJictiOD is bandIed by generating an even parity bit at the sending end for ~h character The eight-bit characters that include parity bits are transmitted to their desshytination The parity ofeachebaracter is thetichecked at the receiving~nd If the parity of the received cbaracter is Dot even then at1east on~bit has changed value dUring the trmlsmission This method detects one three or any odd combination of errors in each character tb8t is transshymitted An even combination oferrors however goes undetected and additioDaterror detic- shytion codes may be needed to take care of that possibility

What is done after an errQlis detected depends on the partieu~ application One possishybilityis to request retransrois~ion of the message on the assump~on that tbeenigtr was ranshyd()m andwill not occur again Thus if thereeeiverdetects a parityerrorit sends bai~ the ASCII NAK (negative acknowledge) control cnaracter consisting ofail even-parity eight bits lOOlOl01H no error is detectedthe ~iversends back anACK (aCkno~ledge) conshytrol character namely 0000011 O The sending end will respond middotto an NAK by tranSmitting the message again until the correct panty is received Ifmiddot after a number of attempts the transmission is still in error a message can be sent to the Operatai to check for malfunctions in the transmission path

BINARY STORAGE ANORECiISTEIlS

The binary infonnation inadigitalcomputermust have a physical e~stencein some medium for storing individual bits A binary cell is a device that possesses two stable sttes and is cashypable of storing pne bit (0 or 1) oflnfotlllation The input to tbe cell receives exciJation sigshynals that set it to one of the two states The output of the cell isa pbysicalquantity that distinguishes between the two states The irtformationstored in Ii cell is 1when the cell is in one stable state and degwhen the Cell is in the other stable state

26middot Chapter 1 Digital Systems and BtnaryNumbers

Registers

A register is a group of binary cells A register with n cells can store any discrete quantity of middot information thatcontains n bits The state ofa registeris an n-tuple ofls middotand Os with each bit designating the state of one cell in the register The C()ntent ofaregister is a function of the int~rpretation given to tbeinformation stored in it Consider fQf ex~ple a 16-bitregister with the following binary content

11 00001111001001

middot Aregjs~ with 16 cells can be in one of 216 possible statesIf one asstimesthat the content cif the register represents a binaryinteger then the register can store any binarydumber from Oto 216 - 1 For the patticularexample shown the content ofthe register is the binary equivshyalent(lftbe decimal number 50121 If one assumes instead that the register stores alpbanushy

middot meric characters of an eight-bit cooe then the content of the register is any two meaningful characters For tht ASCII code with anevenplirityplaced in the eighth most significant bit position the register contains thetwo charactersC (the lefunosteightbits) and I (the rigbt~ most eight bits) If however one in~rprets the content of the register to be four decimal dig- its represented by a four-bitcode tnenthe content of the register is a four-digit decimal number In theexcess-3 code the register holqs the decimal nutriber 9096 The content of the registe~is meaningless in BCD becau~e the bit combinatiOn ltob is 110t assfgned to any decshyimal digit From this example it is clear that a register can store discrete elements of inforshymation and that the same bit configuration Inay beinterpreted dlffe(ently for different types of data

tmiddotmiddotReglsterTrail Adigitalsystenlis characteriZed by its registers and the components thatpetfolin data proshy~ssingIIl digital sy~tems a rcentgister tra1lsfer operation is abasi operation that consists of

middot a transftr of hiJWy hUormation from one ~t of registers into ano$er set of registers transfer may be dir~ctfr9m one regist~r toanlt)ther or may pass througb datamiddotprocessing circuits to petformaD operation Figure L 1 illustratel the transfer of iidOrnuttion among regshyisters anddemonstratespictorlallY [the tr8ll~~ ofbinaryinformation from akeyboard a register in the memQryullit Thehlputunit~s assumed to have a keyboard1 control cuit and aninput register Each time a key is strock the control circuit enters an ImnV$_

lent eight-bit alphanumeric character coqe into the input register We shall assume that code used is the ASCII code with an odd-parity bit The information from the input regisshyter is transferred into the eight-least significant cells Qf a proeessOr register After transfer theinpui register is cleared to enable the control to insert a new eight-bit when the keyboard is struck again Each eight-bit character transferred to the pro1c4ess(raquo register is preceded by a shift of the previous character to the next eight cens on its left~

middot a transfer -of four characters is completed the processor registeris full and its contents transferred into a memory register The content stored in die memOry register shown in Figl came from the transfer of the characters J 0 H an~ N aftet the four ap)lroJ)riatt keys were struck

Section 18 Binary Storage and Registers 27

FIGURE 11 Transfer of information among registers

To process discrete quantities of infoiniatiori in binary form a computer m~st be promiddot vided with devices that hold the (lata to be processed and with circuit elements that manipmiddot ulate individual bits of irifonnation The device most commonly used for holding data is a register Binary variables~ manipulated by means of digital logic circuits Figure 12 il~ luslrates the process of adding two l()bit binary iUlmbers Themeniory unit which no[shy

mally consists of millions of registers is shown with only three ofits registers Thepait of the processor unit showncoDsistsmiddotofthree registers-RI R2 and R3~getherwith digital logic circuits that manipulate the bits of RI and R2 and transfer into R3 a binary number equal to their arithmetic sum Memory registers store information and are incapable of pr0shy

cessing the two operands However th~ information stored in meDij)iybanbetransferred to ~ processor registers and the resUlts obtainedin processor tegisters can be transferred back into ame~ry register for storage Untill)ecded again The diagram ~wsthe90ntents of two

operands transferred from twoJDemoryregisters into RI imd R2 The digital logic circuits produce the sum which is transfened to register R3 The contents of R3 can now be 1riUlsshyferredback to one of thetnemory registers

The last two examples demonstrated the infonncion-flow capabilitieSofa digital system in a simple manner Themiddot registets of the ~ystem are the basic ele~ents for Noring and holding the binary information~igitallogic circuits process the binary ihfonaation stored in the

28 Chapter 1 DigIt bullbull Systems and Binary Numbers

Sum

FIGURE 12 Eumple of blnarylnfonn~t1on processing

registers Digitallogiccirctiits and registers are covered InChQpteB 2 throQgh 6 The metlilOlY unit is ~xPIained ill 9aptet 7 Th~ descriptton of register opetJtions at the register level and the design of digital systems are covexed in Chapter 8

19 BINARY LOGIC

Binary logic deals with variables th~ take on two discrete valueund withoperations that sumelogicalmeaning~ The two val~s the variableussume may be called~ydifferent (true andalse yel and no etc) but for ourp1llpQSe it is cpqVenienttotbink in terms of and assign the values llUld O The binary logic intr0ducedin this section is equivalent to algebra oalledBoolean algebra The fannal presentation ofBoolean algebra is covered in detail in Chapter 2 The purpose ofthis seCtion is to introduce Boo algebra ina matmerandlate it to digitallogiccircuits andmiddotbinarYsignalsmiddot

Section 19 Sinary logic 29 ~

Itkltn of IInary logic

Binarylogic consists of binary v~les and a set of logica1middotoperatiQDS The variables are desigshy ~by lettell of thCalplWlet~such asA B C x yz etc with eaCh variable baving two and oniy

two distinct posSible valueS 1and O There are three basic logical operations AND ORand NOT

1 AN]) This ~peration is represented by adotorby the absence ~f an oPerator For example x bull y =z or xy = zis~ x ANDy is equalto z~ThelogicaloperationAND is interpreted to mean that z == 1 ifand only ift~ land y = 1 otherwise z = O (Reme~r that x y andzare binary v8riablesand canmiddotbe equal either to 1 or Omiddotand nothing eise)middot

2 OR This operation IS represented by a plus sign For example x + y =z is read x OR y is equal to z meaning that z 1 if x = iorif y = lorifbothx= 1 and y = 1 If bqth X - 0 andY Omeo z= O

3bull NOT This operation is repf6sented by a prime (sometimes by an overbar) For ~xample x =Z (or~ =z) is read notdsequalto 1 meiming that z iswkatx isnot In other

words ifx = 1 then z == 0 but if x == 0 tnenz = L TheNOT operationisals(1 reshyferred tolls the complement operation since it changes ~ 1 toOand a O to 1

bull bull lt Binary logic resembles binary arithmetic and themiddot9peratioos ANDahd OR have similarishy

ties to multiplication and addition respectively In fac~ the symbols used for AND and OR are the same as those used for multiplication and addition However binary lOgic should not be conshyfused withbinaryarithIrietic One should realize thatan arithmetic variable designates a numshyber that may consist of many digits A logicmiddot variable is always either 1 or O For example in binary arithmetic we have I +1 =10(read~one plus ()fie is equal to 2) whereas in binary logicwe have 1 + 1 1 (read one OR onds equal to one)

For each combination of the values oix and y bullthere isa value of ~ $pecifiedby the definishytion of the logical operation D~linitiops of logical~perations maybe listed in a compacHorm called truth tables A truth table is atable of anpbssible combinations ofthe variables $howshying the relation between the values that the variables may take and the resultof the operation The truth tables for th~ operations ANDand OR with variables x and y are obtained by lis~ng

all possible values that the variables may have when combined in pairs bull For each combination the resUlt of die operation 18 theillistedin a separate row The truth tables for ANDORand

NOT are given in Table La These tables clearly demonstrate the definitionf the operatibns

Table 18 Truth TcibJts of Logical Operations

AND OR NOT

x y xmiddoty x y x+y

0 0 0 0 0 0 1 0 0 1

10

1 0 d 1 0 1 I 1 1 1 1 1

bull~lt~m

30 Chapter 1

Logk Gates

Digital Systems and Binary Numbers

Logic gates are electronic cirellit that operate on ~

variable

or mpre mput tignals to produce an output signal Electrical signals sUch as voltages orrutrents exist as analog signals having values over a given taDgebull saYOt03 V but in a digital system are interpreted to be either of two recognizable values 0 or 1 Voltage~opetated logic Circuits respond to two separate voltshyage levels that represent a binary varjable equal to logic I bt logic O For example a partic- ular digital system may define 10gicOas a signal equal to 0 volts lind logic 1 asa signal equal to 3 volts In practice each voltage levelhiS an acceptable rangeas shown in Fig 13

The input te~nals of digital cikuits accePt binary signals within the allowable range and respond at the output terininals with binary signals that fall within the specified range The intermediate region between the aJl()wed regions is crossed only during aState transition Any desired information for computing or control can be operated tm by passing binary signals through variQUS combinatioDsof logic gates with each signal represebting a particular binary

The graphic symbols used to deSignate themiddotthree types of gates are Mown in Fig 14 The

gates are blocks of hardware that prooocc tbeequivalent of1ogic~1 orlogic() output signals

Volts

- FGURl13

x

y

Exampleof binary slgnaJs

Signal ratlge for logieO

(a)~omiddotinput AND gate

FIGURE 14 SymbOls for digital logic circuits

(c)NOT gate or invert~

Problems 31

x-lU 1 11 P 0

y 0 0 11 1 ~

ANDxy 0 0 rTl 00

ORX+Y~ NOT x 11 0 0 I 1 1

FIGURE 15 Input-output 5Igals for gates

FIGURE 1

A B C

Gates WIth mlltlple JnpUU

A B C lJ

~

if inPllt logic ~ts are satisfied Theinput signals xaDd y intheNDaadQR gates may exist in ~ oHow-possible states 00 10 11 or 01 Il1ese ibpu~ampignals_ shown inFig lStoshygetber with the corresponding output signal foreach PfCThI~tiaiug~iDustrate the reshysponse ofeaclt gate to the four input signal~The~llisofthetiminadiagram represents time and the vertical axis sbo~~~~ it cbapg~botwcen~possible voltshy

age levels The low level represents logic O tJte high level l1lteAND _ responds With a logic ~ ~tput sipl wh~ both input ~~)e 1middot1~ lIieOR S-~with a logic 1 outpUt signal ifanylnput sigrudis lOgic 1 TheNOTgateis~~ to BUll invedet The reason for~nameis~t froJn the signalmsponae inmiddottbe timitt8 diagramwhicbsbows that theoUtputsignal inverts the logic sense of tbeiDpUtsigll8l

AND and OR gates may bavei)lQte tbantwQinputs M AND8_~itti ~input$andan OR gate with foU) inputs are shown in Fig 16 The three-inPllt AND gate responds With logic 1 output if all tbreeinputs arelogic 11jleoutputproduces lOgic Oifanymput is logic O-The

four-input OR gate responds withlogic 1 ifany input is logic 1 its clu1ptltllCCoines logic oonly when all inputs are logic O

Answers to prvblems marked with middotappearaHbe ClOd ofthe ~

11 lJltthe octal and beXadecimalliurilbers trom16ui 32UdngA B1l1ld C forthebst~ digits Usttbe numbers from 8 to 28 in base13 bull

I

12t What is the exact D1Jllbcr of bytes in a system that contains lta) 32Kbytoe (b)64M ~and (e) 640 byte$ middot7 t

32 Chapter 1 Digital Systemsand Binary Numbers

13 Convert the following nu~bers with the indicated bases to decimal (a) (4310)s (b) (198hz (c) (735)8 (d) (525)6

14 Whllt is the largest binary number that can be expressed with 14 bits WhlIt are the equivaleDt ~~ iinal and hexadecimal numbei-s

--

15 Detemrine the base of thl1 numbers in each case for the following operatio~ to be correct (a) 142 = 5 (b) 5414 = 13 (C) 24+ 17 == 40

16 The solution$to the q~cequation xl - Ux +22 oare l1 3 arid x =6 What is the base of the numbers

17 Convertthehexadecimal ntmIher 68BE to bitiary and then convert it ~mbinary to octal

18 I Convert the decirpal number 431 to binary in tWo ways (a) Convertd~y to binary (b) conshyvert first to hexadecinla1 and then from ~decimalwbinary Which method is faster

19 amppress the following nqrnbersin decinud (a) IQ11O0101)z (b) (l65his (c)(2624)8 (d) (FAFA) 16

(e) (10101010)2

110 Convert the following binary numbers tobexadeoimal and todecitnal (a) UOOlO (b) 110010 Explain why the deCimal answer in (b)is 4 times that in (a)

111 Perform the followingdiviskmin binary 11 Ion + l()t

112 Add IlniImultiply tfle following numberswiihout converting them to decimal (a) Binary nuniberilOll aiIdlOh (b) He~uumbers 2E aDd 34

1~)( Do thefoHowing con~ersionproblems (a) CorivertCiecimal2731S to binary (b) CakUlate the binary eqUivalent (f 213 outto eight pl~Then Convert from binary to

imalHowgJose istbe result to 2131 (c) Convert the binary resukin (b) into hexad~ lb~oonvert ~result to decimal Is answer tbesame

114 Obtain the is 8nd 2s complementsofthe foUowing binaryDumbcentrs (aj l)()()(J()OO (b) OOOOOOOO (c) 11011010 (d)01l10110 (e) 10000101 (0 11111111

115 Find the 9s and the 10s complement of the following detimal numbers (a) 52734630 (b) 63325600 (c) 25000009 (d) 00000000

116 (a) Find the 16s complement of B2FA (b) Convert B2FA to binary (c) Find the 2scomplement ofthe resultin (b) (d) Convert the answer in (c)to hex~malandco~ with ihe an~wer in (a)

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 23: Chapter 01 - Mano

SectIOnl7 BlnarYCod~s 23

The Gray code is used in applications in which the normal sequenceOrbiruuy rium~may produce an error orambiguitymiddot during themiddot transitionfrom ODeDWDber to the next If binary numbersareusec1 acbange forexaJIlple nom 0111 to 1000 may produce anintermediateershyroneous number 1001 if the value ofthe rigbtmost bit takes longer to -change than domiddotthe valshyues of the other three bits The Graycode elimb1ates this problem since only one bit changes its valve dUrlng aily transition be~een two numbers I

Atypical appli-cation ofmiddotthe Gray code is the representation of analog data by a Continu ous change in the angUlar position of a shaft The sQaftmiddot is partitioned into segments ana each segment is assigned a number If adJacent segments are made to correspond with the Qray-Codesequence ambiguity is eliminated between the angle of thesbaft and the value encoded by the sensor

Character Code

Many applications of digital computers require the handling not only ofnumberS but also of other characterS or symbols such as the letters of the alphabet For mstancean insurance comshypany with thousands of policyholders will use a computeX to process its files To represent the names and other pertinent information it is necessary to fonnulate bull binary code for the letshyters ofthe alphabet In additiQt1 the same binary qode must represent numerals and special Characters (such as $) An a1phanumeric character setis a set ofeiements that inclUdes the 10 decimal digits the 26leuersofthealp1iabe and a nutnbeof special~S~ a set conshytains between 36~d 64 elements ifonIy capital letters areincltided or between 64 and 128 e1eJDents ifboth uppercasemiddot and lowercllle etters are inclUded In the first case we need a bi- nary code ofsix bits and in the second we need a binary cooeO(seVM bits

The standaM binary code for the alphanumeric char8cters is the American Stahdard Code for Information InterCbange (A~n) which uses seven bitS to code 128 characters asshoWn in Table 17 The seven bitsof the code are desipted by b~through h With h the mostsigshynificant bit ~e leUer A for example is represented inASCn as l(l()()()Ol (column l00~tOw 0001) The Ascn ()()de also contains 94 graphic characters that can be printed and 34 nonshyprinting characters used for variQUS control functions The graphic characters consist of the 26 uppercase letters (A through Z) the 26 lowercase letters (a through z) the 10 numerals (0 through 9) and 32 special printable characters suchaS andS

The 34 control characters are designated in the ASCTItable With abbreviated nalne8 They are listed again below the table with their functional names The control characters are used fQr routing data and arranging the printed text into a prescribed format~ There are three types of control characters format effectors information separatOrs andcommumc~on-COnlrpl char~ IlCters Format effectors are characters that control the layout ofprinting They inciude the fashymiliar word pr6cessorand typewriter controlssucb 8$ bac~pace (BS) horizontal tabulation (HT) and carriage return (CR) Information separators are used to separatetbe data into divi~ sions such as paragraphs and pages Theyinclude characters such as ~ordseparator (RS)and file separator (FS)The cODlIDunication-control characters are uSefulduriDgthe transmission of text between remote tenninals EXllll1plesof conlmunicatiOn(ODtiol~ are STX (start oftext)-and ETX (end of text) whicb are used toframe a text mesaagetnQlSlnitted through telephone wires

24 Chap~er 1 Diglt8l Systems and Binary Numbers

rblel7 Amerkcm5tandard Code for Information (nterclHlnge(ASCII)

b~jbzb 000 001 010 on 100 101 no 111

0000 NUL )jLP SP () p P 0001 SOH OC1 1 A Q a q

R0010 STX OC2 2 B b r 0011 ETX DC3 3 C S Ii S

0100 EDT 0C4 $ 4 D~ T d t 0101 ENQ NAK 5 E iU e u OUO ACK SYN amp 6 F V f v 0111 BEL ETB 7 0 W g w 1000 B8 CAN ( S H K h x 1001 HT EM ) 9 I Y Y 1010 LF SU~ 1 Z j z lOll VT ESC + 1lt r k UOO FF PS lt L I I 1101 Cit OS == - M 1 m 1110 SO R~ N 1 n shy

-0PIt st US f 1 0 0 DEL

r- Control characten

NUL NlI]l DlE Data-inkescape SOH Start of hea~ng DC1 Device cOntroll STX Start of text DC2 DevIce io~1lOi2 ETX End (Jftext i DC3 Device corUlri1 3 OOT End oftraIlsmission ~4 DeVicecoQtrol4

ENQ ampqwry NAK Negativeackilowledge ACK

Acknowledge SVN Sync~nous idle

Btl Bell ETB End-of-tmnsnussionblOck sS Backspace CAN CanCel HT Horizontal tab EM End of mediUrlt LF Lintifeed SUB Substitute VT Vertical tab ESC escape FF form feed FS File separator CR Carriigeretum GS Group separator SO shift Ollt RS Reoord sepuator SI Shlftin US Unit separator SF S~e DEL Delete

ASCII is a seven-bit codebutrnostcompUters manipulate anejght-bit quantity asa unit called a byte Therefore ASCII characters most often are stored ~e per byte The

I biti~sometimesused forotlef purposes depending ontheapplicatio~lFor example printetS recognize eightmiddotbit AScn chaiacterS with themost sigoificaot bit ~twO An atkJlitlo

Section 18 Binary Storage and Registers 2S

128 eight-bit characters with the most significant bit set tol are used for other symbols such as the Greek alpbabet or italic tyIe font

Error-Dtectlng Code

To detect errors in data communication and processing aneigbth bit is sometimes added to the ASCll cbaracter to indicate its Panty Aparitybit is an extra hit included with a message to make the total num~ of ls either even or odd Consider the fo119wing two cbaracters and their even andodd parity

With even parity With odd parity Ascn A = 1000061 01000001 11000001 ASCI( T == 101deg100 11010100 01010100

1

- Ineacb casewe insert an extra bit in the leftmost position of the code to produce an even number of 1 s intQe cbaraeter for even parity or an odd number of 1 s in the character for odd parity In generlll one or tbe oth~r parity i~ adopted with even parity being more common

The parity biqsbelpful in detecting errors during the transmission ofinformation from one location to another nisfuJictiOD is bandIed by generating an even parity bit at the sending end for ~h character The eight-bit characters that include parity bits are transmitted to their desshytination The parity ofeachebaracter is thetichecked at the receiving~nd If the parity of the received cbaracter is Dot even then at1east on~bit has changed value dUring the trmlsmission This method detects one three or any odd combination of errors in each character tb8t is transshymitted An even combination oferrors however goes undetected and additioDaterror detic- shytion codes may be needed to take care of that possibility

What is done after an errQlis detected depends on the partieu~ application One possishybilityis to request retransrois~ion of the message on the assump~on that tbeenigtr was ranshyd()m andwill not occur again Thus if thereeeiverdetects a parityerrorit sends bai~ the ASCII NAK (negative acknowledge) control cnaracter consisting ofail even-parity eight bits lOOlOl01H no error is detectedthe ~iversends back anACK (aCkno~ledge) conshytrol character namely 0000011 O The sending end will respond middotto an NAK by tranSmitting the message again until the correct panty is received Ifmiddot after a number of attempts the transmission is still in error a message can be sent to the Operatai to check for malfunctions in the transmission path

BINARY STORAGE ANORECiISTEIlS

The binary infonnation inadigitalcomputermust have a physical e~stencein some medium for storing individual bits A binary cell is a device that possesses two stable sttes and is cashypable of storing pne bit (0 or 1) oflnfotlllation The input to tbe cell receives exciJation sigshynals that set it to one of the two states The output of the cell isa pbysicalquantity that distinguishes between the two states The irtformationstored in Ii cell is 1when the cell is in one stable state and degwhen the Cell is in the other stable state

26middot Chapter 1 Digital Systems and BtnaryNumbers

Registers

A register is a group of binary cells A register with n cells can store any discrete quantity of middot information thatcontains n bits The state ofa registeris an n-tuple ofls middotand Os with each bit designating the state of one cell in the register The C()ntent ofaregister is a function of the int~rpretation given to tbeinformation stored in it Consider fQf ex~ple a 16-bitregister with the following binary content

11 00001111001001

middot Aregjs~ with 16 cells can be in one of 216 possible statesIf one asstimesthat the content cif the register represents a binaryinteger then the register can store any binarydumber from Oto 216 - 1 For the patticularexample shown the content ofthe register is the binary equivshyalent(lftbe decimal number 50121 If one assumes instead that the register stores alpbanushy

middot meric characters of an eight-bit cooe then the content of the register is any two meaningful characters For tht ASCII code with anevenplirityplaced in the eighth most significant bit position the register contains thetwo charactersC (the lefunosteightbits) and I (the rigbt~ most eight bits) If however one in~rprets the content of the register to be four decimal dig- its represented by a four-bitcode tnenthe content of the register is a four-digit decimal number In theexcess-3 code the register holqs the decimal nutriber 9096 The content of the registe~is meaningless in BCD becau~e the bit combinatiOn ltob is 110t assfgned to any decshyimal digit From this example it is clear that a register can store discrete elements of inforshymation and that the same bit configuration Inay beinterpreted dlffe(ently for different types of data

tmiddotmiddotReglsterTrail Adigitalsystenlis characteriZed by its registers and the components thatpetfolin data proshy~ssingIIl digital sy~tems a rcentgister tra1lsfer operation is abasi operation that consists of

middot a transftr of hiJWy hUormation from one ~t of registers into ano$er set of registers transfer may be dir~ctfr9m one regist~r toanlt)ther or may pass througb datamiddotprocessing circuits to petformaD operation Figure L 1 illustratel the transfer of iidOrnuttion among regshyisters anddemonstratespictorlallY [the tr8ll~~ ofbinaryinformation from akeyboard a register in the memQryullit Thehlputunit~s assumed to have a keyboard1 control cuit and aninput register Each time a key is strock the control circuit enters an ImnV$_

lent eight-bit alphanumeric character coqe into the input register We shall assume that code used is the ASCII code with an odd-parity bit The information from the input regisshyter is transferred into the eight-least significant cells Qf a proeessOr register After transfer theinpui register is cleared to enable the control to insert a new eight-bit when the keyboard is struck again Each eight-bit character transferred to the pro1c4ess(raquo register is preceded by a shift of the previous character to the next eight cens on its left~

middot a transfer -of four characters is completed the processor registeris full and its contents transferred into a memory register The content stored in die memOry register shown in Figl came from the transfer of the characters J 0 H an~ N aftet the four ap)lroJ)riatt keys were struck

Section 18 Binary Storage and Registers 27

FIGURE 11 Transfer of information among registers

To process discrete quantities of infoiniatiori in binary form a computer m~st be promiddot vided with devices that hold the (lata to be processed and with circuit elements that manipmiddot ulate individual bits of irifonnation The device most commonly used for holding data is a register Binary variables~ manipulated by means of digital logic circuits Figure 12 il~ luslrates the process of adding two l()bit binary iUlmbers Themeniory unit which no[shy

mally consists of millions of registers is shown with only three ofits registers Thepait of the processor unit showncoDsistsmiddotofthree registers-RI R2 and R3~getherwith digital logic circuits that manipulate the bits of RI and R2 and transfer into R3 a binary number equal to their arithmetic sum Memory registers store information and are incapable of pr0shy

cessing the two operands However th~ information stored in meDij)iybanbetransferred to ~ processor registers and the resUlts obtainedin processor tegisters can be transferred back into ame~ry register for storage Untill)ecded again The diagram ~wsthe90ntents of two

operands transferred from twoJDemoryregisters into RI imd R2 The digital logic circuits produce the sum which is transfened to register R3 The contents of R3 can now be 1riUlsshyferredback to one of thetnemory registers

The last two examples demonstrated the infonncion-flow capabilitieSofa digital system in a simple manner Themiddot registets of the ~ystem are the basic ele~ents for Noring and holding the binary information~igitallogic circuits process the binary ihfonaation stored in the

28 Chapter 1 DigIt bullbull Systems and Binary Numbers

Sum

FIGURE 12 Eumple of blnarylnfonn~t1on processing

registers Digitallogiccirctiits and registers are covered InChQpteB 2 throQgh 6 The metlilOlY unit is ~xPIained ill 9aptet 7 Th~ descriptton of register opetJtions at the register level and the design of digital systems are covexed in Chapter 8

19 BINARY LOGIC

Binary logic deals with variables th~ take on two discrete valueund withoperations that sumelogicalmeaning~ The two val~s the variableussume may be called~ydifferent (true andalse yel and no etc) but for ourp1llpQSe it is cpqVenienttotbink in terms of and assign the values llUld O The binary logic intr0ducedin this section is equivalent to algebra oalledBoolean algebra The fannal presentation ofBoolean algebra is covered in detail in Chapter 2 The purpose ofthis seCtion is to introduce Boo algebra ina matmerandlate it to digitallogiccircuits andmiddotbinarYsignalsmiddot

Section 19 Sinary logic 29 ~

Itkltn of IInary logic

Binarylogic consists of binary v~les and a set of logica1middotoperatiQDS The variables are desigshy ~by lettell of thCalplWlet~such asA B C x yz etc with eaCh variable baving two and oniy

two distinct posSible valueS 1and O There are three basic logical operations AND ORand NOT

1 AN]) This ~peration is represented by adotorby the absence ~f an oPerator For example x bull y =z or xy = zis~ x ANDy is equalto z~ThelogicaloperationAND is interpreted to mean that z == 1 ifand only ift~ land y = 1 otherwise z = O (Reme~r that x y andzare binary v8riablesand canmiddotbe equal either to 1 or Omiddotand nothing eise)middot

2 OR This operation IS represented by a plus sign For example x + y =z is read x OR y is equal to z meaning that z 1 if x = iorif y = lorifbothx= 1 and y = 1 If bqth X - 0 andY Omeo z= O

3bull NOT This operation is repf6sented by a prime (sometimes by an overbar) For ~xample x =Z (or~ =z) is read notdsequalto 1 meiming that z iswkatx isnot In other

words ifx = 1 then z == 0 but if x == 0 tnenz = L TheNOT operationisals(1 reshyferred tolls the complement operation since it changes ~ 1 toOand a O to 1

bull bull lt Binary logic resembles binary arithmetic and themiddot9peratioos ANDahd OR have similarishy

ties to multiplication and addition respectively In fac~ the symbols used for AND and OR are the same as those used for multiplication and addition However binary lOgic should not be conshyfused withbinaryarithIrietic One should realize thatan arithmetic variable designates a numshyber that may consist of many digits A logicmiddot variable is always either 1 or O For example in binary arithmetic we have I +1 =10(read~one plus ()fie is equal to 2) whereas in binary logicwe have 1 + 1 1 (read one OR onds equal to one)

For each combination of the values oix and y bullthere isa value of ~ $pecifiedby the definishytion of the logical operation D~linitiops of logical~perations maybe listed in a compacHorm called truth tables A truth table is atable of anpbssible combinations ofthe variables $howshying the relation between the values that the variables may take and the resultof the operation The truth tables for th~ operations ANDand OR with variables x and y are obtained by lis~ng

all possible values that the variables may have when combined in pairs bull For each combination the resUlt of die operation 18 theillistedin a separate row The truth tables for ANDORand

NOT are given in Table La These tables clearly demonstrate the definitionf the operatibns

Table 18 Truth TcibJts of Logical Operations

AND OR NOT

x y xmiddoty x y x+y

0 0 0 0 0 0 1 0 0 1

10

1 0 d 1 0 1 I 1 1 1 1 1

bull~lt~m

30 Chapter 1

Logk Gates

Digital Systems and Binary Numbers

Logic gates are electronic cirellit that operate on ~

variable

or mpre mput tignals to produce an output signal Electrical signals sUch as voltages orrutrents exist as analog signals having values over a given taDgebull saYOt03 V but in a digital system are interpreted to be either of two recognizable values 0 or 1 Voltage~opetated logic Circuits respond to two separate voltshyage levels that represent a binary varjable equal to logic I bt logic O For example a partic- ular digital system may define 10gicOas a signal equal to 0 volts lind logic 1 asa signal equal to 3 volts In practice each voltage levelhiS an acceptable rangeas shown in Fig 13

The input te~nals of digital cikuits accePt binary signals within the allowable range and respond at the output terininals with binary signals that fall within the specified range The intermediate region between the aJl()wed regions is crossed only during aState transition Any desired information for computing or control can be operated tm by passing binary signals through variQUS combinatioDsof logic gates with each signal represebting a particular binary

The graphic symbols used to deSignate themiddotthree types of gates are Mown in Fig 14 The

gates are blocks of hardware that prooocc tbeequivalent of1ogic~1 orlogic() output signals

Volts

- FGURl13

x

y

Exampleof binary slgnaJs

Signal ratlge for logieO

(a)~omiddotinput AND gate

FIGURE 14 SymbOls for digital logic circuits

(c)NOT gate or invert~

Problems 31

x-lU 1 11 P 0

y 0 0 11 1 ~

ANDxy 0 0 rTl 00

ORX+Y~ NOT x 11 0 0 I 1 1

FIGURE 15 Input-output 5Igals for gates

FIGURE 1

A B C

Gates WIth mlltlple JnpUU

A B C lJ

~

if inPllt logic ~ts are satisfied Theinput signals xaDd y intheNDaadQR gates may exist in ~ oHow-possible states 00 10 11 or 01 Il1ese ibpu~ampignals_ shown inFig lStoshygetber with the corresponding output signal foreach PfCThI~tiaiug~iDustrate the reshysponse ofeaclt gate to the four input signal~The~llisofthetiminadiagram represents time and the vertical axis sbo~~~~ it cbapg~botwcen~possible voltshy

age levels The low level represents logic O tJte high level l1lteAND _ responds With a logic ~ ~tput sipl wh~ both input ~~)e 1middot1~ lIieOR S-~with a logic 1 outpUt signal ifanylnput sigrudis lOgic 1 TheNOTgateis~~ to BUll invedet The reason for~nameis~t froJn the signalmsponae inmiddottbe timitt8 diagramwhicbsbows that theoUtputsignal inverts the logic sense of tbeiDpUtsigll8l

AND and OR gates may bavei)lQte tbantwQinputs M AND8_~itti ~input$andan OR gate with foU) inputs are shown in Fig 16 The three-inPllt AND gate responds With logic 1 output if all tbreeinputs arelogic 11jleoutputproduces lOgic Oifanymput is logic O-The

four-input OR gate responds withlogic 1 ifany input is logic 1 its clu1ptltllCCoines logic oonly when all inputs are logic O

Answers to prvblems marked with middotappearaHbe ClOd ofthe ~

11 lJltthe octal and beXadecimalliurilbers trom16ui 32UdngA B1l1ld C forthebst~ digits Usttbe numbers from 8 to 28 in base13 bull

I

12t What is the exact D1Jllbcr of bytes in a system that contains lta) 32Kbytoe (b)64M ~and (e) 640 byte$ middot7 t

32 Chapter 1 Digital Systemsand Binary Numbers

13 Convert the following nu~bers with the indicated bases to decimal (a) (4310)s (b) (198hz (c) (735)8 (d) (525)6

14 Whllt is the largest binary number that can be expressed with 14 bits WhlIt are the equivaleDt ~~ iinal and hexadecimal numbei-s

--

15 Detemrine the base of thl1 numbers in each case for the following operatio~ to be correct (a) 142 = 5 (b) 5414 = 13 (C) 24+ 17 == 40

16 The solution$to the q~cequation xl - Ux +22 oare l1 3 arid x =6 What is the base of the numbers

17 Convertthehexadecimal ntmIher 68BE to bitiary and then convert it ~mbinary to octal

18 I Convert the decirpal number 431 to binary in tWo ways (a) Convertd~y to binary (b) conshyvert first to hexadecinla1 and then from ~decimalwbinary Which method is faster

19 amppress the following nqrnbersin decinud (a) IQ11O0101)z (b) (l65his (c)(2624)8 (d) (FAFA) 16

(e) (10101010)2

110 Convert the following binary numbers tobexadeoimal and todecitnal (a) UOOlO (b) 110010 Explain why the deCimal answer in (b)is 4 times that in (a)

111 Perform the followingdiviskmin binary 11 Ion + l()t

112 Add IlniImultiply tfle following numberswiihout converting them to decimal (a) Binary nuniberilOll aiIdlOh (b) He~uumbers 2E aDd 34

1~)( Do thefoHowing con~ersionproblems (a) CorivertCiecimal2731S to binary (b) CakUlate the binary eqUivalent (f 213 outto eight pl~Then Convert from binary to

imalHowgJose istbe result to 2131 (c) Convert the binary resukin (b) into hexad~ lb~oonvert ~result to decimal Is answer tbesame

114 Obtain the is 8nd 2s complementsofthe foUowing binaryDumbcentrs (aj l)()()(J()OO (b) OOOOOOOO (c) 11011010 (d)01l10110 (e) 10000101 (0 11111111

115 Find the 9s and the 10s complement of the following detimal numbers (a) 52734630 (b) 63325600 (c) 25000009 (d) 00000000

116 (a) Find the 16s complement of B2FA (b) Convert B2FA to binary (c) Find the 2scomplement ofthe resultin (b) (d) Convert the answer in (c)to hex~malandco~ with ihe an~wer in (a)

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 24: Chapter 01 - Mano

24 Chap~er 1 Diglt8l Systems and Binary Numbers

rblel7 Amerkcm5tandard Code for Information (nterclHlnge(ASCII)

b~jbzb 000 001 010 on 100 101 no 111

0000 NUL )jLP SP () p P 0001 SOH OC1 1 A Q a q

R0010 STX OC2 2 B b r 0011 ETX DC3 3 C S Ii S

0100 EDT 0C4 $ 4 D~ T d t 0101 ENQ NAK 5 E iU e u OUO ACK SYN amp 6 F V f v 0111 BEL ETB 7 0 W g w 1000 B8 CAN ( S H K h x 1001 HT EM ) 9 I Y Y 1010 LF SU~ 1 Z j z lOll VT ESC + 1lt r k UOO FF PS lt L I I 1101 Cit OS == - M 1 m 1110 SO R~ N 1 n shy

-0PIt st US f 1 0 0 DEL

r- Control characten

NUL NlI]l DlE Data-inkescape SOH Start of hea~ng DC1 Device cOntroll STX Start of text DC2 DevIce io~1lOi2 ETX End (Jftext i DC3 Device corUlri1 3 OOT End oftraIlsmission ~4 DeVicecoQtrol4

ENQ ampqwry NAK Negativeackilowledge ACK

Acknowledge SVN Sync~nous idle

Btl Bell ETB End-of-tmnsnussionblOck sS Backspace CAN CanCel HT Horizontal tab EM End of mediUrlt LF Lintifeed SUB Substitute VT Vertical tab ESC escape FF form feed FS File separator CR Carriigeretum GS Group separator SO shift Ollt RS Reoord sepuator SI Shlftin US Unit separator SF S~e DEL Delete

ASCII is a seven-bit codebutrnostcompUters manipulate anejght-bit quantity asa unit called a byte Therefore ASCII characters most often are stored ~e per byte The

I biti~sometimesused forotlef purposes depending ontheapplicatio~lFor example printetS recognize eightmiddotbit AScn chaiacterS with themost sigoificaot bit ~twO An atkJlitlo

Section 18 Binary Storage and Registers 2S

128 eight-bit characters with the most significant bit set tol are used for other symbols such as the Greek alpbabet or italic tyIe font

Error-Dtectlng Code

To detect errors in data communication and processing aneigbth bit is sometimes added to the ASCll cbaracter to indicate its Panty Aparitybit is an extra hit included with a message to make the total num~ of ls either even or odd Consider the fo119wing two cbaracters and their even andodd parity

With even parity With odd parity Ascn A = 1000061 01000001 11000001 ASCI( T == 101deg100 11010100 01010100

1

- Ineacb casewe insert an extra bit in the leftmost position of the code to produce an even number of 1 s intQe cbaraeter for even parity or an odd number of 1 s in the character for odd parity In generlll one or tbe oth~r parity i~ adopted with even parity being more common

The parity biqsbelpful in detecting errors during the transmission ofinformation from one location to another nisfuJictiOD is bandIed by generating an even parity bit at the sending end for ~h character The eight-bit characters that include parity bits are transmitted to their desshytination The parity ofeachebaracter is thetichecked at the receiving~nd If the parity of the received cbaracter is Dot even then at1east on~bit has changed value dUring the trmlsmission This method detects one three or any odd combination of errors in each character tb8t is transshymitted An even combination oferrors however goes undetected and additioDaterror detic- shytion codes may be needed to take care of that possibility

What is done after an errQlis detected depends on the partieu~ application One possishybilityis to request retransrois~ion of the message on the assump~on that tbeenigtr was ranshyd()m andwill not occur again Thus if thereeeiverdetects a parityerrorit sends bai~ the ASCII NAK (negative acknowledge) control cnaracter consisting ofail even-parity eight bits lOOlOl01H no error is detectedthe ~iversends back anACK (aCkno~ledge) conshytrol character namely 0000011 O The sending end will respond middotto an NAK by tranSmitting the message again until the correct panty is received Ifmiddot after a number of attempts the transmission is still in error a message can be sent to the Operatai to check for malfunctions in the transmission path

BINARY STORAGE ANORECiISTEIlS

The binary infonnation inadigitalcomputermust have a physical e~stencein some medium for storing individual bits A binary cell is a device that possesses two stable sttes and is cashypable of storing pne bit (0 or 1) oflnfotlllation The input to tbe cell receives exciJation sigshynals that set it to one of the two states The output of the cell isa pbysicalquantity that distinguishes between the two states The irtformationstored in Ii cell is 1when the cell is in one stable state and degwhen the Cell is in the other stable state

26middot Chapter 1 Digital Systems and BtnaryNumbers

Registers

A register is a group of binary cells A register with n cells can store any discrete quantity of middot information thatcontains n bits The state ofa registeris an n-tuple ofls middotand Os with each bit designating the state of one cell in the register The C()ntent ofaregister is a function of the int~rpretation given to tbeinformation stored in it Consider fQf ex~ple a 16-bitregister with the following binary content

11 00001111001001

middot Aregjs~ with 16 cells can be in one of 216 possible statesIf one asstimesthat the content cif the register represents a binaryinteger then the register can store any binarydumber from Oto 216 - 1 For the patticularexample shown the content ofthe register is the binary equivshyalent(lftbe decimal number 50121 If one assumes instead that the register stores alpbanushy

middot meric characters of an eight-bit cooe then the content of the register is any two meaningful characters For tht ASCII code with anevenplirityplaced in the eighth most significant bit position the register contains thetwo charactersC (the lefunosteightbits) and I (the rigbt~ most eight bits) If however one in~rprets the content of the register to be four decimal dig- its represented by a four-bitcode tnenthe content of the register is a four-digit decimal number In theexcess-3 code the register holqs the decimal nutriber 9096 The content of the registe~is meaningless in BCD becau~e the bit combinatiOn ltob is 110t assfgned to any decshyimal digit From this example it is clear that a register can store discrete elements of inforshymation and that the same bit configuration Inay beinterpreted dlffe(ently for different types of data

tmiddotmiddotReglsterTrail Adigitalsystenlis characteriZed by its registers and the components thatpetfolin data proshy~ssingIIl digital sy~tems a rcentgister tra1lsfer operation is abasi operation that consists of

middot a transftr of hiJWy hUormation from one ~t of registers into ano$er set of registers transfer may be dir~ctfr9m one regist~r toanlt)ther or may pass througb datamiddotprocessing circuits to petformaD operation Figure L 1 illustratel the transfer of iidOrnuttion among regshyisters anddemonstratespictorlallY [the tr8ll~~ ofbinaryinformation from akeyboard a register in the memQryullit Thehlputunit~s assumed to have a keyboard1 control cuit and aninput register Each time a key is strock the control circuit enters an ImnV$_

lent eight-bit alphanumeric character coqe into the input register We shall assume that code used is the ASCII code with an odd-parity bit The information from the input regisshyter is transferred into the eight-least significant cells Qf a proeessOr register After transfer theinpui register is cleared to enable the control to insert a new eight-bit when the keyboard is struck again Each eight-bit character transferred to the pro1c4ess(raquo register is preceded by a shift of the previous character to the next eight cens on its left~

middot a transfer -of four characters is completed the processor registeris full and its contents transferred into a memory register The content stored in die memOry register shown in Figl came from the transfer of the characters J 0 H an~ N aftet the four ap)lroJ)riatt keys were struck

Section 18 Binary Storage and Registers 27

FIGURE 11 Transfer of information among registers

To process discrete quantities of infoiniatiori in binary form a computer m~st be promiddot vided with devices that hold the (lata to be processed and with circuit elements that manipmiddot ulate individual bits of irifonnation The device most commonly used for holding data is a register Binary variables~ manipulated by means of digital logic circuits Figure 12 il~ luslrates the process of adding two l()bit binary iUlmbers Themeniory unit which no[shy

mally consists of millions of registers is shown with only three ofits registers Thepait of the processor unit showncoDsistsmiddotofthree registers-RI R2 and R3~getherwith digital logic circuits that manipulate the bits of RI and R2 and transfer into R3 a binary number equal to their arithmetic sum Memory registers store information and are incapable of pr0shy

cessing the two operands However th~ information stored in meDij)iybanbetransferred to ~ processor registers and the resUlts obtainedin processor tegisters can be transferred back into ame~ry register for storage Untill)ecded again The diagram ~wsthe90ntents of two

operands transferred from twoJDemoryregisters into RI imd R2 The digital logic circuits produce the sum which is transfened to register R3 The contents of R3 can now be 1riUlsshyferredback to one of thetnemory registers

The last two examples demonstrated the infonncion-flow capabilitieSofa digital system in a simple manner Themiddot registets of the ~ystem are the basic ele~ents for Noring and holding the binary information~igitallogic circuits process the binary ihfonaation stored in the

28 Chapter 1 DigIt bullbull Systems and Binary Numbers

Sum

FIGURE 12 Eumple of blnarylnfonn~t1on processing

registers Digitallogiccirctiits and registers are covered InChQpteB 2 throQgh 6 The metlilOlY unit is ~xPIained ill 9aptet 7 Th~ descriptton of register opetJtions at the register level and the design of digital systems are covexed in Chapter 8

19 BINARY LOGIC

Binary logic deals with variables th~ take on two discrete valueund withoperations that sumelogicalmeaning~ The two val~s the variableussume may be called~ydifferent (true andalse yel and no etc) but for ourp1llpQSe it is cpqVenienttotbink in terms of and assign the values llUld O The binary logic intr0ducedin this section is equivalent to algebra oalledBoolean algebra The fannal presentation ofBoolean algebra is covered in detail in Chapter 2 The purpose ofthis seCtion is to introduce Boo algebra ina matmerandlate it to digitallogiccircuits andmiddotbinarYsignalsmiddot

Section 19 Sinary logic 29 ~

Itkltn of IInary logic

Binarylogic consists of binary v~les and a set of logica1middotoperatiQDS The variables are desigshy ~by lettell of thCalplWlet~such asA B C x yz etc with eaCh variable baving two and oniy

two distinct posSible valueS 1and O There are three basic logical operations AND ORand NOT

1 AN]) This ~peration is represented by adotorby the absence ~f an oPerator For example x bull y =z or xy = zis~ x ANDy is equalto z~ThelogicaloperationAND is interpreted to mean that z == 1 ifand only ift~ land y = 1 otherwise z = O (Reme~r that x y andzare binary v8riablesand canmiddotbe equal either to 1 or Omiddotand nothing eise)middot

2 OR This operation IS represented by a plus sign For example x + y =z is read x OR y is equal to z meaning that z 1 if x = iorif y = lorifbothx= 1 and y = 1 If bqth X - 0 andY Omeo z= O

3bull NOT This operation is repf6sented by a prime (sometimes by an overbar) For ~xample x =Z (or~ =z) is read notdsequalto 1 meiming that z iswkatx isnot In other

words ifx = 1 then z == 0 but if x == 0 tnenz = L TheNOT operationisals(1 reshyferred tolls the complement operation since it changes ~ 1 toOand a O to 1

bull bull lt Binary logic resembles binary arithmetic and themiddot9peratioos ANDahd OR have similarishy

ties to multiplication and addition respectively In fac~ the symbols used for AND and OR are the same as those used for multiplication and addition However binary lOgic should not be conshyfused withbinaryarithIrietic One should realize thatan arithmetic variable designates a numshyber that may consist of many digits A logicmiddot variable is always either 1 or O For example in binary arithmetic we have I +1 =10(read~one plus ()fie is equal to 2) whereas in binary logicwe have 1 + 1 1 (read one OR onds equal to one)

For each combination of the values oix and y bullthere isa value of ~ $pecifiedby the definishytion of the logical operation D~linitiops of logical~perations maybe listed in a compacHorm called truth tables A truth table is atable of anpbssible combinations ofthe variables $howshying the relation between the values that the variables may take and the resultof the operation The truth tables for th~ operations ANDand OR with variables x and y are obtained by lis~ng

all possible values that the variables may have when combined in pairs bull For each combination the resUlt of die operation 18 theillistedin a separate row The truth tables for ANDORand

NOT are given in Table La These tables clearly demonstrate the definitionf the operatibns

Table 18 Truth TcibJts of Logical Operations

AND OR NOT

x y xmiddoty x y x+y

0 0 0 0 0 0 1 0 0 1

10

1 0 d 1 0 1 I 1 1 1 1 1

bull~lt~m

30 Chapter 1

Logk Gates

Digital Systems and Binary Numbers

Logic gates are electronic cirellit that operate on ~

variable

or mpre mput tignals to produce an output signal Electrical signals sUch as voltages orrutrents exist as analog signals having values over a given taDgebull saYOt03 V but in a digital system are interpreted to be either of two recognizable values 0 or 1 Voltage~opetated logic Circuits respond to two separate voltshyage levels that represent a binary varjable equal to logic I bt logic O For example a partic- ular digital system may define 10gicOas a signal equal to 0 volts lind logic 1 asa signal equal to 3 volts In practice each voltage levelhiS an acceptable rangeas shown in Fig 13

The input te~nals of digital cikuits accePt binary signals within the allowable range and respond at the output terininals with binary signals that fall within the specified range The intermediate region between the aJl()wed regions is crossed only during aState transition Any desired information for computing or control can be operated tm by passing binary signals through variQUS combinatioDsof logic gates with each signal represebting a particular binary

The graphic symbols used to deSignate themiddotthree types of gates are Mown in Fig 14 The

gates are blocks of hardware that prooocc tbeequivalent of1ogic~1 orlogic() output signals

Volts

- FGURl13

x

y

Exampleof binary slgnaJs

Signal ratlge for logieO

(a)~omiddotinput AND gate

FIGURE 14 SymbOls for digital logic circuits

(c)NOT gate or invert~

Problems 31

x-lU 1 11 P 0

y 0 0 11 1 ~

ANDxy 0 0 rTl 00

ORX+Y~ NOT x 11 0 0 I 1 1

FIGURE 15 Input-output 5Igals for gates

FIGURE 1

A B C

Gates WIth mlltlple JnpUU

A B C lJ

~

if inPllt logic ~ts are satisfied Theinput signals xaDd y intheNDaadQR gates may exist in ~ oHow-possible states 00 10 11 or 01 Il1ese ibpu~ampignals_ shown inFig lStoshygetber with the corresponding output signal foreach PfCThI~tiaiug~iDustrate the reshysponse ofeaclt gate to the four input signal~The~llisofthetiminadiagram represents time and the vertical axis sbo~~~~ it cbapg~botwcen~possible voltshy

age levels The low level represents logic O tJte high level l1lteAND _ responds With a logic ~ ~tput sipl wh~ both input ~~)e 1middot1~ lIieOR S-~with a logic 1 outpUt signal ifanylnput sigrudis lOgic 1 TheNOTgateis~~ to BUll invedet The reason for~nameis~t froJn the signalmsponae inmiddottbe timitt8 diagramwhicbsbows that theoUtputsignal inverts the logic sense of tbeiDpUtsigll8l

AND and OR gates may bavei)lQte tbantwQinputs M AND8_~itti ~input$andan OR gate with foU) inputs are shown in Fig 16 The three-inPllt AND gate responds With logic 1 output if all tbreeinputs arelogic 11jleoutputproduces lOgic Oifanymput is logic O-The

four-input OR gate responds withlogic 1 ifany input is logic 1 its clu1ptltllCCoines logic oonly when all inputs are logic O

Answers to prvblems marked with middotappearaHbe ClOd ofthe ~

11 lJltthe octal and beXadecimalliurilbers trom16ui 32UdngA B1l1ld C forthebst~ digits Usttbe numbers from 8 to 28 in base13 bull

I

12t What is the exact D1Jllbcr of bytes in a system that contains lta) 32Kbytoe (b)64M ~and (e) 640 byte$ middot7 t

32 Chapter 1 Digital Systemsand Binary Numbers

13 Convert the following nu~bers with the indicated bases to decimal (a) (4310)s (b) (198hz (c) (735)8 (d) (525)6

14 Whllt is the largest binary number that can be expressed with 14 bits WhlIt are the equivaleDt ~~ iinal and hexadecimal numbei-s

--

15 Detemrine the base of thl1 numbers in each case for the following operatio~ to be correct (a) 142 = 5 (b) 5414 = 13 (C) 24+ 17 == 40

16 The solution$to the q~cequation xl - Ux +22 oare l1 3 arid x =6 What is the base of the numbers

17 Convertthehexadecimal ntmIher 68BE to bitiary and then convert it ~mbinary to octal

18 I Convert the decirpal number 431 to binary in tWo ways (a) Convertd~y to binary (b) conshyvert first to hexadecinla1 and then from ~decimalwbinary Which method is faster

19 amppress the following nqrnbersin decinud (a) IQ11O0101)z (b) (l65his (c)(2624)8 (d) (FAFA) 16

(e) (10101010)2

110 Convert the following binary numbers tobexadeoimal and todecitnal (a) UOOlO (b) 110010 Explain why the deCimal answer in (b)is 4 times that in (a)

111 Perform the followingdiviskmin binary 11 Ion + l()t

112 Add IlniImultiply tfle following numberswiihout converting them to decimal (a) Binary nuniberilOll aiIdlOh (b) He~uumbers 2E aDd 34

1~)( Do thefoHowing con~ersionproblems (a) CorivertCiecimal2731S to binary (b) CakUlate the binary eqUivalent (f 213 outto eight pl~Then Convert from binary to

imalHowgJose istbe result to 2131 (c) Convert the binary resukin (b) into hexad~ lb~oonvert ~result to decimal Is answer tbesame

114 Obtain the is 8nd 2s complementsofthe foUowing binaryDumbcentrs (aj l)()()(J()OO (b) OOOOOOOO (c) 11011010 (d)01l10110 (e) 10000101 (0 11111111

115 Find the 9s and the 10s complement of the following detimal numbers (a) 52734630 (b) 63325600 (c) 25000009 (d) 00000000

116 (a) Find the 16s complement of B2FA (b) Convert B2FA to binary (c) Find the 2scomplement ofthe resultin (b) (d) Convert the answer in (c)to hex~malandco~ with ihe an~wer in (a)

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 25: Chapter 01 - Mano

Section 18 Binary Storage and Registers 2S

128 eight-bit characters with the most significant bit set tol are used for other symbols such as the Greek alpbabet or italic tyIe font

Error-Dtectlng Code

To detect errors in data communication and processing aneigbth bit is sometimes added to the ASCll cbaracter to indicate its Panty Aparitybit is an extra hit included with a message to make the total num~ of ls either even or odd Consider the fo119wing two cbaracters and their even andodd parity

With even parity With odd parity Ascn A = 1000061 01000001 11000001 ASCI( T == 101deg100 11010100 01010100

1

- Ineacb casewe insert an extra bit in the leftmost position of the code to produce an even number of 1 s intQe cbaraeter for even parity or an odd number of 1 s in the character for odd parity In generlll one or tbe oth~r parity i~ adopted with even parity being more common

The parity biqsbelpful in detecting errors during the transmission ofinformation from one location to another nisfuJictiOD is bandIed by generating an even parity bit at the sending end for ~h character The eight-bit characters that include parity bits are transmitted to their desshytination The parity ofeachebaracter is thetichecked at the receiving~nd If the parity of the received cbaracter is Dot even then at1east on~bit has changed value dUring the trmlsmission This method detects one three or any odd combination of errors in each character tb8t is transshymitted An even combination oferrors however goes undetected and additioDaterror detic- shytion codes may be needed to take care of that possibility

What is done after an errQlis detected depends on the partieu~ application One possishybilityis to request retransrois~ion of the message on the assump~on that tbeenigtr was ranshyd()m andwill not occur again Thus if thereeeiverdetects a parityerrorit sends bai~ the ASCII NAK (negative acknowledge) control cnaracter consisting ofail even-parity eight bits lOOlOl01H no error is detectedthe ~iversends back anACK (aCkno~ledge) conshytrol character namely 0000011 O The sending end will respond middotto an NAK by tranSmitting the message again until the correct panty is received Ifmiddot after a number of attempts the transmission is still in error a message can be sent to the Operatai to check for malfunctions in the transmission path

BINARY STORAGE ANORECiISTEIlS

The binary infonnation inadigitalcomputermust have a physical e~stencein some medium for storing individual bits A binary cell is a device that possesses two stable sttes and is cashypable of storing pne bit (0 or 1) oflnfotlllation The input to tbe cell receives exciJation sigshynals that set it to one of the two states The output of the cell isa pbysicalquantity that distinguishes between the two states The irtformationstored in Ii cell is 1when the cell is in one stable state and degwhen the Cell is in the other stable state

26middot Chapter 1 Digital Systems and BtnaryNumbers

Registers

A register is a group of binary cells A register with n cells can store any discrete quantity of middot information thatcontains n bits The state ofa registeris an n-tuple ofls middotand Os with each bit designating the state of one cell in the register The C()ntent ofaregister is a function of the int~rpretation given to tbeinformation stored in it Consider fQf ex~ple a 16-bitregister with the following binary content

11 00001111001001

middot Aregjs~ with 16 cells can be in one of 216 possible statesIf one asstimesthat the content cif the register represents a binaryinteger then the register can store any binarydumber from Oto 216 - 1 For the patticularexample shown the content ofthe register is the binary equivshyalent(lftbe decimal number 50121 If one assumes instead that the register stores alpbanushy

middot meric characters of an eight-bit cooe then the content of the register is any two meaningful characters For tht ASCII code with anevenplirityplaced in the eighth most significant bit position the register contains thetwo charactersC (the lefunosteightbits) and I (the rigbt~ most eight bits) If however one in~rprets the content of the register to be four decimal dig- its represented by a four-bitcode tnenthe content of the register is a four-digit decimal number In theexcess-3 code the register holqs the decimal nutriber 9096 The content of the registe~is meaningless in BCD becau~e the bit combinatiOn ltob is 110t assfgned to any decshyimal digit From this example it is clear that a register can store discrete elements of inforshymation and that the same bit configuration Inay beinterpreted dlffe(ently for different types of data

tmiddotmiddotReglsterTrail Adigitalsystenlis characteriZed by its registers and the components thatpetfolin data proshy~ssingIIl digital sy~tems a rcentgister tra1lsfer operation is abasi operation that consists of

middot a transftr of hiJWy hUormation from one ~t of registers into ano$er set of registers transfer may be dir~ctfr9m one regist~r toanlt)ther or may pass througb datamiddotprocessing circuits to petformaD operation Figure L 1 illustratel the transfer of iidOrnuttion among regshyisters anddemonstratespictorlallY [the tr8ll~~ ofbinaryinformation from akeyboard a register in the memQryullit Thehlputunit~s assumed to have a keyboard1 control cuit and aninput register Each time a key is strock the control circuit enters an ImnV$_

lent eight-bit alphanumeric character coqe into the input register We shall assume that code used is the ASCII code with an odd-parity bit The information from the input regisshyter is transferred into the eight-least significant cells Qf a proeessOr register After transfer theinpui register is cleared to enable the control to insert a new eight-bit when the keyboard is struck again Each eight-bit character transferred to the pro1c4ess(raquo register is preceded by a shift of the previous character to the next eight cens on its left~

middot a transfer -of four characters is completed the processor registeris full and its contents transferred into a memory register The content stored in die memOry register shown in Figl came from the transfer of the characters J 0 H an~ N aftet the four ap)lroJ)riatt keys were struck

Section 18 Binary Storage and Registers 27

FIGURE 11 Transfer of information among registers

To process discrete quantities of infoiniatiori in binary form a computer m~st be promiddot vided with devices that hold the (lata to be processed and with circuit elements that manipmiddot ulate individual bits of irifonnation The device most commonly used for holding data is a register Binary variables~ manipulated by means of digital logic circuits Figure 12 il~ luslrates the process of adding two l()bit binary iUlmbers Themeniory unit which no[shy

mally consists of millions of registers is shown with only three ofits registers Thepait of the processor unit showncoDsistsmiddotofthree registers-RI R2 and R3~getherwith digital logic circuits that manipulate the bits of RI and R2 and transfer into R3 a binary number equal to their arithmetic sum Memory registers store information and are incapable of pr0shy

cessing the two operands However th~ information stored in meDij)iybanbetransferred to ~ processor registers and the resUlts obtainedin processor tegisters can be transferred back into ame~ry register for storage Untill)ecded again The diagram ~wsthe90ntents of two

operands transferred from twoJDemoryregisters into RI imd R2 The digital logic circuits produce the sum which is transfened to register R3 The contents of R3 can now be 1riUlsshyferredback to one of thetnemory registers

The last two examples demonstrated the infonncion-flow capabilitieSofa digital system in a simple manner Themiddot registets of the ~ystem are the basic ele~ents for Noring and holding the binary information~igitallogic circuits process the binary ihfonaation stored in the

28 Chapter 1 DigIt bullbull Systems and Binary Numbers

Sum

FIGURE 12 Eumple of blnarylnfonn~t1on processing

registers Digitallogiccirctiits and registers are covered InChQpteB 2 throQgh 6 The metlilOlY unit is ~xPIained ill 9aptet 7 Th~ descriptton of register opetJtions at the register level and the design of digital systems are covexed in Chapter 8

19 BINARY LOGIC

Binary logic deals with variables th~ take on two discrete valueund withoperations that sumelogicalmeaning~ The two val~s the variableussume may be called~ydifferent (true andalse yel and no etc) but for ourp1llpQSe it is cpqVenienttotbink in terms of and assign the values llUld O The binary logic intr0ducedin this section is equivalent to algebra oalledBoolean algebra The fannal presentation ofBoolean algebra is covered in detail in Chapter 2 The purpose ofthis seCtion is to introduce Boo algebra ina matmerandlate it to digitallogiccircuits andmiddotbinarYsignalsmiddot

Section 19 Sinary logic 29 ~

Itkltn of IInary logic

Binarylogic consists of binary v~les and a set of logica1middotoperatiQDS The variables are desigshy ~by lettell of thCalplWlet~such asA B C x yz etc with eaCh variable baving two and oniy

two distinct posSible valueS 1and O There are three basic logical operations AND ORand NOT

1 AN]) This ~peration is represented by adotorby the absence ~f an oPerator For example x bull y =z or xy = zis~ x ANDy is equalto z~ThelogicaloperationAND is interpreted to mean that z == 1 ifand only ift~ land y = 1 otherwise z = O (Reme~r that x y andzare binary v8riablesand canmiddotbe equal either to 1 or Omiddotand nothing eise)middot

2 OR This operation IS represented by a plus sign For example x + y =z is read x OR y is equal to z meaning that z 1 if x = iorif y = lorifbothx= 1 and y = 1 If bqth X - 0 andY Omeo z= O

3bull NOT This operation is repf6sented by a prime (sometimes by an overbar) For ~xample x =Z (or~ =z) is read notdsequalto 1 meiming that z iswkatx isnot In other

words ifx = 1 then z == 0 but if x == 0 tnenz = L TheNOT operationisals(1 reshyferred tolls the complement operation since it changes ~ 1 toOand a O to 1

bull bull lt Binary logic resembles binary arithmetic and themiddot9peratioos ANDahd OR have similarishy

ties to multiplication and addition respectively In fac~ the symbols used for AND and OR are the same as those used for multiplication and addition However binary lOgic should not be conshyfused withbinaryarithIrietic One should realize thatan arithmetic variable designates a numshyber that may consist of many digits A logicmiddot variable is always either 1 or O For example in binary arithmetic we have I +1 =10(read~one plus ()fie is equal to 2) whereas in binary logicwe have 1 + 1 1 (read one OR onds equal to one)

For each combination of the values oix and y bullthere isa value of ~ $pecifiedby the definishytion of the logical operation D~linitiops of logical~perations maybe listed in a compacHorm called truth tables A truth table is atable of anpbssible combinations ofthe variables $howshying the relation between the values that the variables may take and the resultof the operation The truth tables for th~ operations ANDand OR with variables x and y are obtained by lis~ng

all possible values that the variables may have when combined in pairs bull For each combination the resUlt of die operation 18 theillistedin a separate row The truth tables for ANDORand

NOT are given in Table La These tables clearly demonstrate the definitionf the operatibns

Table 18 Truth TcibJts of Logical Operations

AND OR NOT

x y xmiddoty x y x+y

0 0 0 0 0 0 1 0 0 1

10

1 0 d 1 0 1 I 1 1 1 1 1

bull~lt~m

30 Chapter 1

Logk Gates

Digital Systems and Binary Numbers

Logic gates are electronic cirellit that operate on ~

variable

or mpre mput tignals to produce an output signal Electrical signals sUch as voltages orrutrents exist as analog signals having values over a given taDgebull saYOt03 V but in a digital system are interpreted to be either of two recognizable values 0 or 1 Voltage~opetated logic Circuits respond to two separate voltshyage levels that represent a binary varjable equal to logic I bt logic O For example a partic- ular digital system may define 10gicOas a signal equal to 0 volts lind logic 1 asa signal equal to 3 volts In practice each voltage levelhiS an acceptable rangeas shown in Fig 13

The input te~nals of digital cikuits accePt binary signals within the allowable range and respond at the output terininals with binary signals that fall within the specified range The intermediate region between the aJl()wed regions is crossed only during aState transition Any desired information for computing or control can be operated tm by passing binary signals through variQUS combinatioDsof logic gates with each signal represebting a particular binary

The graphic symbols used to deSignate themiddotthree types of gates are Mown in Fig 14 The

gates are blocks of hardware that prooocc tbeequivalent of1ogic~1 orlogic() output signals

Volts

- FGURl13

x

y

Exampleof binary slgnaJs

Signal ratlge for logieO

(a)~omiddotinput AND gate

FIGURE 14 SymbOls for digital logic circuits

(c)NOT gate or invert~

Problems 31

x-lU 1 11 P 0

y 0 0 11 1 ~

ANDxy 0 0 rTl 00

ORX+Y~ NOT x 11 0 0 I 1 1

FIGURE 15 Input-output 5Igals for gates

FIGURE 1

A B C

Gates WIth mlltlple JnpUU

A B C lJ

~

if inPllt logic ~ts are satisfied Theinput signals xaDd y intheNDaadQR gates may exist in ~ oHow-possible states 00 10 11 or 01 Il1ese ibpu~ampignals_ shown inFig lStoshygetber with the corresponding output signal foreach PfCThI~tiaiug~iDustrate the reshysponse ofeaclt gate to the four input signal~The~llisofthetiminadiagram represents time and the vertical axis sbo~~~~ it cbapg~botwcen~possible voltshy

age levels The low level represents logic O tJte high level l1lteAND _ responds With a logic ~ ~tput sipl wh~ both input ~~)e 1middot1~ lIieOR S-~with a logic 1 outpUt signal ifanylnput sigrudis lOgic 1 TheNOTgateis~~ to BUll invedet The reason for~nameis~t froJn the signalmsponae inmiddottbe timitt8 diagramwhicbsbows that theoUtputsignal inverts the logic sense of tbeiDpUtsigll8l

AND and OR gates may bavei)lQte tbantwQinputs M AND8_~itti ~input$andan OR gate with foU) inputs are shown in Fig 16 The three-inPllt AND gate responds With logic 1 output if all tbreeinputs arelogic 11jleoutputproduces lOgic Oifanymput is logic O-The

four-input OR gate responds withlogic 1 ifany input is logic 1 its clu1ptltllCCoines logic oonly when all inputs are logic O

Answers to prvblems marked with middotappearaHbe ClOd ofthe ~

11 lJltthe octal and beXadecimalliurilbers trom16ui 32UdngA B1l1ld C forthebst~ digits Usttbe numbers from 8 to 28 in base13 bull

I

12t What is the exact D1Jllbcr of bytes in a system that contains lta) 32Kbytoe (b)64M ~and (e) 640 byte$ middot7 t

32 Chapter 1 Digital Systemsand Binary Numbers

13 Convert the following nu~bers with the indicated bases to decimal (a) (4310)s (b) (198hz (c) (735)8 (d) (525)6

14 Whllt is the largest binary number that can be expressed with 14 bits WhlIt are the equivaleDt ~~ iinal and hexadecimal numbei-s

--

15 Detemrine the base of thl1 numbers in each case for the following operatio~ to be correct (a) 142 = 5 (b) 5414 = 13 (C) 24+ 17 == 40

16 The solution$to the q~cequation xl - Ux +22 oare l1 3 arid x =6 What is the base of the numbers

17 Convertthehexadecimal ntmIher 68BE to bitiary and then convert it ~mbinary to octal

18 I Convert the decirpal number 431 to binary in tWo ways (a) Convertd~y to binary (b) conshyvert first to hexadecinla1 and then from ~decimalwbinary Which method is faster

19 amppress the following nqrnbersin decinud (a) IQ11O0101)z (b) (l65his (c)(2624)8 (d) (FAFA) 16

(e) (10101010)2

110 Convert the following binary numbers tobexadeoimal and todecitnal (a) UOOlO (b) 110010 Explain why the deCimal answer in (b)is 4 times that in (a)

111 Perform the followingdiviskmin binary 11 Ion + l()t

112 Add IlniImultiply tfle following numberswiihout converting them to decimal (a) Binary nuniberilOll aiIdlOh (b) He~uumbers 2E aDd 34

1~)( Do thefoHowing con~ersionproblems (a) CorivertCiecimal2731S to binary (b) CakUlate the binary eqUivalent (f 213 outto eight pl~Then Convert from binary to

imalHowgJose istbe result to 2131 (c) Convert the binary resukin (b) into hexad~ lb~oonvert ~result to decimal Is answer tbesame

114 Obtain the is 8nd 2s complementsofthe foUowing binaryDumbcentrs (aj l)()()(J()OO (b) OOOOOOOO (c) 11011010 (d)01l10110 (e) 10000101 (0 11111111

115 Find the 9s and the 10s complement of the following detimal numbers (a) 52734630 (b) 63325600 (c) 25000009 (d) 00000000

116 (a) Find the 16s complement of B2FA (b) Convert B2FA to binary (c) Find the 2scomplement ofthe resultin (b) (d) Convert the answer in (c)to hex~malandco~ with ihe an~wer in (a)

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 26: Chapter 01 - Mano

26middot Chapter 1 Digital Systems and BtnaryNumbers

Registers

A register is a group of binary cells A register with n cells can store any discrete quantity of middot information thatcontains n bits The state ofa registeris an n-tuple ofls middotand Os with each bit designating the state of one cell in the register The C()ntent ofaregister is a function of the int~rpretation given to tbeinformation stored in it Consider fQf ex~ple a 16-bitregister with the following binary content

11 00001111001001

middot Aregjs~ with 16 cells can be in one of 216 possible statesIf one asstimesthat the content cif the register represents a binaryinteger then the register can store any binarydumber from Oto 216 - 1 For the patticularexample shown the content ofthe register is the binary equivshyalent(lftbe decimal number 50121 If one assumes instead that the register stores alpbanushy

middot meric characters of an eight-bit cooe then the content of the register is any two meaningful characters For tht ASCII code with anevenplirityplaced in the eighth most significant bit position the register contains thetwo charactersC (the lefunosteightbits) and I (the rigbt~ most eight bits) If however one in~rprets the content of the register to be four decimal dig- its represented by a four-bitcode tnenthe content of the register is a four-digit decimal number In theexcess-3 code the register holqs the decimal nutriber 9096 The content of the registe~is meaningless in BCD becau~e the bit combinatiOn ltob is 110t assfgned to any decshyimal digit From this example it is clear that a register can store discrete elements of inforshymation and that the same bit configuration Inay beinterpreted dlffe(ently for different types of data

tmiddotmiddotReglsterTrail Adigitalsystenlis characteriZed by its registers and the components thatpetfolin data proshy~ssingIIl digital sy~tems a rcentgister tra1lsfer operation is abasi operation that consists of

middot a transftr of hiJWy hUormation from one ~t of registers into ano$er set of registers transfer may be dir~ctfr9m one regist~r toanlt)ther or may pass througb datamiddotprocessing circuits to petformaD operation Figure L 1 illustratel the transfer of iidOrnuttion among regshyisters anddemonstratespictorlallY [the tr8ll~~ ofbinaryinformation from akeyboard a register in the memQryullit Thehlputunit~s assumed to have a keyboard1 control cuit and aninput register Each time a key is strock the control circuit enters an ImnV$_

lent eight-bit alphanumeric character coqe into the input register We shall assume that code used is the ASCII code with an odd-parity bit The information from the input regisshyter is transferred into the eight-least significant cells Qf a proeessOr register After transfer theinpui register is cleared to enable the control to insert a new eight-bit when the keyboard is struck again Each eight-bit character transferred to the pro1c4ess(raquo register is preceded by a shift of the previous character to the next eight cens on its left~

middot a transfer -of four characters is completed the processor registeris full and its contents transferred into a memory register The content stored in die memOry register shown in Figl came from the transfer of the characters J 0 H an~ N aftet the four ap)lroJ)riatt keys were struck

Section 18 Binary Storage and Registers 27

FIGURE 11 Transfer of information among registers

To process discrete quantities of infoiniatiori in binary form a computer m~st be promiddot vided with devices that hold the (lata to be processed and with circuit elements that manipmiddot ulate individual bits of irifonnation The device most commonly used for holding data is a register Binary variables~ manipulated by means of digital logic circuits Figure 12 il~ luslrates the process of adding two l()bit binary iUlmbers Themeniory unit which no[shy

mally consists of millions of registers is shown with only three ofits registers Thepait of the processor unit showncoDsistsmiddotofthree registers-RI R2 and R3~getherwith digital logic circuits that manipulate the bits of RI and R2 and transfer into R3 a binary number equal to their arithmetic sum Memory registers store information and are incapable of pr0shy

cessing the two operands However th~ information stored in meDij)iybanbetransferred to ~ processor registers and the resUlts obtainedin processor tegisters can be transferred back into ame~ry register for storage Untill)ecded again The diagram ~wsthe90ntents of two

operands transferred from twoJDemoryregisters into RI imd R2 The digital logic circuits produce the sum which is transfened to register R3 The contents of R3 can now be 1riUlsshyferredback to one of thetnemory registers

The last two examples demonstrated the infonncion-flow capabilitieSofa digital system in a simple manner Themiddot registets of the ~ystem are the basic ele~ents for Noring and holding the binary information~igitallogic circuits process the binary ihfonaation stored in the

28 Chapter 1 DigIt bullbull Systems and Binary Numbers

Sum

FIGURE 12 Eumple of blnarylnfonn~t1on processing

registers Digitallogiccirctiits and registers are covered InChQpteB 2 throQgh 6 The metlilOlY unit is ~xPIained ill 9aptet 7 Th~ descriptton of register opetJtions at the register level and the design of digital systems are covexed in Chapter 8

19 BINARY LOGIC

Binary logic deals with variables th~ take on two discrete valueund withoperations that sumelogicalmeaning~ The two val~s the variableussume may be called~ydifferent (true andalse yel and no etc) but for ourp1llpQSe it is cpqVenienttotbink in terms of and assign the values llUld O The binary logic intr0ducedin this section is equivalent to algebra oalledBoolean algebra The fannal presentation ofBoolean algebra is covered in detail in Chapter 2 The purpose ofthis seCtion is to introduce Boo algebra ina matmerandlate it to digitallogiccircuits andmiddotbinarYsignalsmiddot

Section 19 Sinary logic 29 ~

Itkltn of IInary logic

Binarylogic consists of binary v~les and a set of logica1middotoperatiQDS The variables are desigshy ~by lettell of thCalplWlet~such asA B C x yz etc with eaCh variable baving two and oniy

two distinct posSible valueS 1and O There are three basic logical operations AND ORand NOT

1 AN]) This ~peration is represented by adotorby the absence ~f an oPerator For example x bull y =z or xy = zis~ x ANDy is equalto z~ThelogicaloperationAND is interpreted to mean that z == 1 ifand only ift~ land y = 1 otherwise z = O (Reme~r that x y andzare binary v8riablesand canmiddotbe equal either to 1 or Omiddotand nothing eise)middot

2 OR This operation IS represented by a plus sign For example x + y =z is read x OR y is equal to z meaning that z 1 if x = iorif y = lorifbothx= 1 and y = 1 If bqth X - 0 andY Omeo z= O

3bull NOT This operation is repf6sented by a prime (sometimes by an overbar) For ~xample x =Z (or~ =z) is read notdsequalto 1 meiming that z iswkatx isnot In other

words ifx = 1 then z == 0 but if x == 0 tnenz = L TheNOT operationisals(1 reshyferred tolls the complement operation since it changes ~ 1 toOand a O to 1

bull bull lt Binary logic resembles binary arithmetic and themiddot9peratioos ANDahd OR have similarishy

ties to multiplication and addition respectively In fac~ the symbols used for AND and OR are the same as those used for multiplication and addition However binary lOgic should not be conshyfused withbinaryarithIrietic One should realize thatan arithmetic variable designates a numshyber that may consist of many digits A logicmiddot variable is always either 1 or O For example in binary arithmetic we have I +1 =10(read~one plus ()fie is equal to 2) whereas in binary logicwe have 1 + 1 1 (read one OR onds equal to one)

For each combination of the values oix and y bullthere isa value of ~ $pecifiedby the definishytion of the logical operation D~linitiops of logical~perations maybe listed in a compacHorm called truth tables A truth table is atable of anpbssible combinations ofthe variables $howshying the relation between the values that the variables may take and the resultof the operation The truth tables for th~ operations ANDand OR with variables x and y are obtained by lis~ng

all possible values that the variables may have when combined in pairs bull For each combination the resUlt of die operation 18 theillistedin a separate row The truth tables for ANDORand

NOT are given in Table La These tables clearly demonstrate the definitionf the operatibns

Table 18 Truth TcibJts of Logical Operations

AND OR NOT

x y xmiddoty x y x+y

0 0 0 0 0 0 1 0 0 1

10

1 0 d 1 0 1 I 1 1 1 1 1

bull~lt~m

30 Chapter 1

Logk Gates

Digital Systems and Binary Numbers

Logic gates are electronic cirellit that operate on ~

variable

or mpre mput tignals to produce an output signal Electrical signals sUch as voltages orrutrents exist as analog signals having values over a given taDgebull saYOt03 V but in a digital system are interpreted to be either of two recognizable values 0 or 1 Voltage~opetated logic Circuits respond to two separate voltshyage levels that represent a binary varjable equal to logic I bt logic O For example a partic- ular digital system may define 10gicOas a signal equal to 0 volts lind logic 1 asa signal equal to 3 volts In practice each voltage levelhiS an acceptable rangeas shown in Fig 13

The input te~nals of digital cikuits accePt binary signals within the allowable range and respond at the output terininals with binary signals that fall within the specified range The intermediate region between the aJl()wed regions is crossed only during aState transition Any desired information for computing or control can be operated tm by passing binary signals through variQUS combinatioDsof logic gates with each signal represebting a particular binary

The graphic symbols used to deSignate themiddotthree types of gates are Mown in Fig 14 The

gates are blocks of hardware that prooocc tbeequivalent of1ogic~1 orlogic() output signals

Volts

- FGURl13

x

y

Exampleof binary slgnaJs

Signal ratlge for logieO

(a)~omiddotinput AND gate

FIGURE 14 SymbOls for digital logic circuits

(c)NOT gate or invert~

Problems 31

x-lU 1 11 P 0

y 0 0 11 1 ~

ANDxy 0 0 rTl 00

ORX+Y~ NOT x 11 0 0 I 1 1

FIGURE 15 Input-output 5Igals for gates

FIGURE 1

A B C

Gates WIth mlltlple JnpUU

A B C lJ

~

if inPllt logic ~ts are satisfied Theinput signals xaDd y intheNDaadQR gates may exist in ~ oHow-possible states 00 10 11 or 01 Il1ese ibpu~ampignals_ shown inFig lStoshygetber with the corresponding output signal foreach PfCThI~tiaiug~iDustrate the reshysponse ofeaclt gate to the four input signal~The~llisofthetiminadiagram represents time and the vertical axis sbo~~~~ it cbapg~botwcen~possible voltshy

age levels The low level represents logic O tJte high level l1lteAND _ responds With a logic ~ ~tput sipl wh~ both input ~~)e 1middot1~ lIieOR S-~with a logic 1 outpUt signal ifanylnput sigrudis lOgic 1 TheNOTgateis~~ to BUll invedet The reason for~nameis~t froJn the signalmsponae inmiddottbe timitt8 diagramwhicbsbows that theoUtputsignal inverts the logic sense of tbeiDpUtsigll8l

AND and OR gates may bavei)lQte tbantwQinputs M AND8_~itti ~input$andan OR gate with foU) inputs are shown in Fig 16 The three-inPllt AND gate responds With logic 1 output if all tbreeinputs arelogic 11jleoutputproduces lOgic Oifanymput is logic O-The

four-input OR gate responds withlogic 1 ifany input is logic 1 its clu1ptltllCCoines logic oonly when all inputs are logic O

Answers to prvblems marked with middotappearaHbe ClOd ofthe ~

11 lJltthe octal and beXadecimalliurilbers trom16ui 32UdngA B1l1ld C forthebst~ digits Usttbe numbers from 8 to 28 in base13 bull

I

12t What is the exact D1Jllbcr of bytes in a system that contains lta) 32Kbytoe (b)64M ~and (e) 640 byte$ middot7 t

32 Chapter 1 Digital Systemsand Binary Numbers

13 Convert the following nu~bers with the indicated bases to decimal (a) (4310)s (b) (198hz (c) (735)8 (d) (525)6

14 Whllt is the largest binary number that can be expressed with 14 bits WhlIt are the equivaleDt ~~ iinal and hexadecimal numbei-s

--

15 Detemrine the base of thl1 numbers in each case for the following operatio~ to be correct (a) 142 = 5 (b) 5414 = 13 (C) 24+ 17 == 40

16 The solution$to the q~cequation xl - Ux +22 oare l1 3 arid x =6 What is the base of the numbers

17 Convertthehexadecimal ntmIher 68BE to bitiary and then convert it ~mbinary to octal

18 I Convert the decirpal number 431 to binary in tWo ways (a) Convertd~y to binary (b) conshyvert first to hexadecinla1 and then from ~decimalwbinary Which method is faster

19 amppress the following nqrnbersin decinud (a) IQ11O0101)z (b) (l65his (c)(2624)8 (d) (FAFA) 16

(e) (10101010)2

110 Convert the following binary numbers tobexadeoimal and todecitnal (a) UOOlO (b) 110010 Explain why the deCimal answer in (b)is 4 times that in (a)

111 Perform the followingdiviskmin binary 11 Ion + l()t

112 Add IlniImultiply tfle following numberswiihout converting them to decimal (a) Binary nuniberilOll aiIdlOh (b) He~uumbers 2E aDd 34

1~)( Do thefoHowing con~ersionproblems (a) CorivertCiecimal2731S to binary (b) CakUlate the binary eqUivalent (f 213 outto eight pl~Then Convert from binary to

imalHowgJose istbe result to 2131 (c) Convert the binary resukin (b) into hexad~ lb~oonvert ~result to decimal Is answer tbesame

114 Obtain the is 8nd 2s complementsofthe foUowing binaryDumbcentrs (aj l)()()(J()OO (b) OOOOOOOO (c) 11011010 (d)01l10110 (e) 10000101 (0 11111111

115 Find the 9s and the 10s complement of the following detimal numbers (a) 52734630 (b) 63325600 (c) 25000009 (d) 00000000

116 (a) Find the 16s complement of B2FA (b) Convert B2FA to binary (c) Find the 2scomplement ofthe resultin (b) (d) Convert the answer in (c)to hex~malandco~ with ihe an~wer in (a)

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 27: Chapter 01 - Mano

Section 18 Binary Storage and Registers 27

FIGURE 11 Transfer of information among registers

To process discrete quantities of infoiniatiori in binary form a computer m~st be promiddot vided with devices that hold the (lata to be processed and with circuit elements that manipmiddot ulate individual bits of irifonnation The device most commonly used for holding data is a register Binary variables~ manipulated by means of digital logic circuits Figure 12 il~ luslrates the process of adding two l()bit binary iUlmbers Themeniory unit which no[shy

mally consists of millions of registers is shown with only three ofits registers Thepait of the processor unit showncoDsistsmiddotofthree registers-RI R2 and R3~getherwith digital logic circuits that manipulate the bits of RI and R2 and transfer into R3 a binary number equal to their arithmetic sum Memory registers store information and are incapable of pr0shy

cessing the two operands However th~ information stored in meDij)iybanbetransferred to ~ processor registers and the resUlts obtainedin processor tegisters can be transferred back into ame~ry register for storage Untill)ecded again The diagram ~wsthe90ntents of two

operands transferred from twoJDemoryregisters into RI imd R2 The digital logic circuits produce the sum which is transfened to register R3 The contents of R3 can now be 1riUlsshyferredback to one of thetnemory registers

The last two examples demonstrated the infonncion-flow capabilitieSofa digital system in a simple manner Themiddot registets of the ~ystem are the basic ele~ents for Noring and holding the binary information~igitallogic circuits process the binary ihfonaation stored in the

28 Chapter 1 DigIt bullbull Systems and Binary Numbers

Sum

FIGURE 12 Eumple of blnarylnfonn~t1on processing

registers Digitallogiccirctiits and registers are covered InChQpteB 2 throQgh 6 The metlilOlY unit is ~xPIained ill 9aptet 7 Th~ descriptton of register opetJtions at the register level and the design of digital systems are covexed in Chapter 8

19 BINARY LOGIC

Binary logic deals with variables th~ take on two discrete valueund withoperations that sumelogicalmeaning~ The two val~s the variableussume may be called~ydifferent (true andalse yel and no etc) but for ourp1llpQSe it is cpqVenienttotbink in terms of and assign the values llUld O The binary logic intr0ducedin this section is equivalent to algebra oalledBoolean algebra The fannal presentation ofBoolean algebra is covered in detail in Chapter 2 The purpose ofthis seCtion is to introduce Boo algebra ina matmerandlate it to digitallogiccircuits andmiddotbinarYsignalsmiddot

Section 19 Sinary logic 29 ~

Itkltn of IInary logic

Binarylogic consists of binary v~les and a set of logica1middotoperatiQDS The variables are desigshy ~by lettell of thCalplWlet~such asA B C x yz etc with eaCh variable baving two and oniy

two distinct posSible valueS 1and O There are three basic logical operations AND ORand NOT

1 AN]) This ~peration is represented by adotorby the absence ~f an oPerator For example x bull y =z or xy = zis~ x ANDy is equalto z~ThelogicaloperationAND is interpreted to mean that z == 1 ifand only ift~ land y = 1 otherwise z = O (Reme~r that x y andzare binary v8riablesand canmiddotbe equal either to 1 or Omiddotand nothing eise)middot

2 OR This operation IS represented by a plus sign For example x + y =z is read x OR y is equal to z meaning that z 1 if x = iorif y = lorifbothx= 1 and y = 1 If bqth X - 0 andY Omeo z= O

3bull NOT This operation is repf6sented by a prime (sometimes by an overbar) For ~xample x =Z (or~ =z) is read notdsequalto 1 meiming that z iswkatx isnot In other

words ifx = 1 then z == 0 but if x == 0 tnenz = L TheNOT operationisals(1 reshyferred tolls the complement operation since it changes ~ 1 toOand a O to 1

bull bull lt Binary logic resembles binary arithmetic and themiddot9peratioos ANDahd OR have similarishy

ties to multiplication and addition respectively In fac~ the symbols used for AND and OR are the same as those used for multiplication and addition However binary lOgic should not be conshyfused withbinaryarithIrietic One should realize thatan arithmetic variable designates a numshyber that may consist of many digits A logicmiddot variable is always either 1 or O For example in binary arithmetic we have I +1 =10(read~one plus ()fie is equal to 2) whereas in binary logicwe have 1 + 1 1 (read one OR onds equal to one)

For each combination of the values oix and y bullthere isa value of ~ $pecifiedby the definishytion of the logical operation D~linitiops of logical~perations maybe listed in a compacHorm called truth tables A truth table is atable of anpbssible combinations ofthe variables $howshying the relation between the values that the variables may take and the resultof the operation The truth tables for th~ operations ANDand OR with variables x and y are obtained by lis~ng

all possible values that the variables may have when combined in pairs bull For each combination the resUlt of die operation 18 theillistedin a separate row The truth tables for ANDORand

NOT are given in Table La These tables clearly demonstrate the definitionf the operatibns

Table 18 Truth TcibJts of Logical Operations

AND OR NOT

x y xmiddoty x y x+y

0 0 0 0 0 0 1 0 0 1

10

1 0 d 1 0 1 I 1 1 1 1 1

bull~lt~m

30 Chapter 1

Logk Gates

Digital Systems and Binary Numbers

Logic gates are electronic cirellit that operate on ~

variable

or mpre mput tignals to produce an output signal Electrical signals sUch as voltages orrutrents exist as analog signals having values over a given taDgebull saYOt03 V but in a digital system are interpreted to be either of two recognizable values 0 or 1 Voltage~opetated logic Circuits respond to two separate voltshyage levels that represent a binary varjable equal to logic I bt logic O For example a partic- ular digital system may define 10gicOas a signal equal to 0 volts lind logic 1 asa signal equal to 3 volts In practice each voltage levelhiS an acceptable rangeas shown in Fig 13

The input te~nals of digital cikuits accePt binary signals within the allowable range and respond at the output terininals with binary signals that fall within the specified range The intermediate region between the aJl()wed regions is crossed only during aState transition Any desired information for computing or control can be operated tm by passing binary signals through variQUS combinatioDsof logic gates with each signal represebting a particular binary

The graphic symbols used to deSignate themiddotthree types of gates are Mown in Fig 14 The

gates are blocks of hardware that prooocc tbeequivalent of1ogic~1 orlogic() output signals

Volts

- FGURl13

x

y

Exampleof binary slgnaJs

Signal ratlge for logieO

(a)~omiddotinput AND gate

FIGURE 14 SymbOls for digital logic circuits

(c)NOT gate or invert~

Problems 31

x-lU 1 11 P 0

y 0 0 11 1 ~

ANDxy 0 0 rTl 00

ORX+Y~ NOT x 11 0 0 I 1 1

FIGURE 15 Input-output 5Igals for gates

FIGURE 1

A B C

Gates WIth mlltlple JnpUU

A B C lJ

~

if inPllt logic ~ts are satisfied Theinput signals xaDd y intheNDaadQR gates may exist in ~ oHow-possible states 00 10 11 or 01 Il1ese ibpu~ampignals_ shown inFig lStoshygetber with the corresponding output signal foreach PfCThI~tiaiug~iDustrate the reshysponse ofeaclt gate to the four input signal~The~llisofthetiminadiagram represents time and the vertical axis sbo~~~~ it cbapg~botwcen~possible voltshy

age levels The low level represents logic O tJte high level l1lteAND _ responds With a logic ~ ~tput sipl wh~ both input ~~)e 1middot1~ lIieOR S-~with a logic 1 outpUt signal ifanylnput sigrudis lOgic 1 TheNOTgateis~~ to BUll invedet The reason for~nameis~t froJn the signalmsponae inmiddottbe timitt8 diagramwhicbsbows that theoUtputsignal inverts the logic sense of tbeiDpUtsigll8l

AND and OR gates may bavei)lQte tbantwQinputs M AND8_~itti ~input$andan OR gate with foU) inputs are shown in Fig 16 The three-inPllt AND gate responds With logic 1 output if all tbreeinputs arelogic 11jleoutputproduces lOgic Oifanymput is logic O-The

four-input OR gate responds withlogic 1 ifany input is logic 1 its clu1ptltllCCoines logic oonly when all inputs are logic O

Answers to prvblems marked with middotappearaHbe ClOd ofthe ~

11 lJltthe octal and beXadecimalliurilbers trom16ui 32UdngA B1l1ld C forthebst~ digits Usttbe numbers from 8 to 28 in base13 bull

I

12t What is the exact D1Jllbcr of bytes in a system that contains lta) 32Kbytoe (b)64M ~and (e) 640 byte$ middot7 t

32 Chapter 1 Digital Systemsand Binary Numbers

13 Convert the following nu~bers with the indicated bases to decimal (a) (4310)s (b) (198hz (c) (735)8 (d) (525)6

14 Whllt is the largest binary number that can be expressed with 14 bits WhlIt are the equivaleDt ~~ iinal and hexadecimal numbei-s

--

15 Detemrine the base of thl1 numbers in each case for the following operatio~ to be correct (a) 142 = 5 (b) 5414 = 13 (C) 24+ 17 == 40

16 The solution$to the q~cequation xl - Ux +22 oare l1 3 arid x =6 What is the base of the numbers

17 Convertthehexadecimal ntmIher 68BE to bitiary and then convert it ~mbinary to octal

18 I Convert the decirpal number 431 to binary in tWo ways (a) Convertd~y to binary (b) conshyvert first to hexadecinla1 and then from ~decimalwbinary Which method is faster

19 amppress the following nqrnbersin decinud (a) IQ11O0101)z (b) (l65his (c)(2624)8 (d) (FAFA) 16

(e) (10101010)2

110 Convert the following binary numbers tobexadeoimal and todecitnal (a) UOOlO (b) 110010 Explain why the deCimal answer in (b)is 4 times that in (a)

111 Perform the followingdiviskmin binary 11 Ion + l()t

112 Add IlniImultiply tfle following numberswiihout converting them to decimal (a) Binary nuniberilOll aiIdlOh (b) He~uumbers 2E aDd 34

1~)( Do thefoHowing con~ersionproblems (a) CorivertCiecimal2731S to binary (b) CakUlate the binary eqUivalent (f 213 outto eight pl~Then Convert from binary to

imalHowgJose istbe result to 2131 (c) Convert the binary resukin (b) into hexad~ lb~oonvert ~result to decimal Is answer tbesame

114 Obtain the is 8nd 2s complementsofthe foUowing binaryDumbcentrs (aj l)()()(J()OO (b) OOOOOOOO (c) 11011010 (d)01l10110 (e) 10000101 (0 11111111

115 Find the 9s and the 10s complement of the following detimal numbers (a) 52734630 (b) 63325600 (c) 25000009 (d) 00000000

116 (a) Find the 16s complement of B2FA (b) Convert B2FA to binary (c) Find the 2scomplement ofthe resultin (b) (d) Convert the answer in (c)to hex~malandco~ with ihe an~wer in (a)

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 28: Chapter 01 - Mano

28 Chapter 1 DigIt bullbull Systems and Binary Numbers

Sum

FIGURE 12 Eumple of blnarylnfonn~t1on processing

registers Digitallogiccirctiits and registers are covered InChQpteB 2 throQgh 6 The metlilOlY unit is ~xPIained ill 9aptet 7 Th~ descriptton of register opetJtions at the register level and the design of digital systems are covexed in Chapter 8

19 BINARY LOGIC

Binary logic deals with variables th~ take on two discrete valueund withoperations that sumelogicalmeaning~ The two val~s the variableussume may be called~ydifferent (true andalse yel and no etc) but for ourp1llpQSe it is cpqVenienttotbink in terms of and assign the values llUld O The binary logic intr0ducedin this section is equivalent to algebra oalledBoolean algebra The fannal presentation ofBoolean algebra is covered in detail in Chapter 2 The purpose ofthis seCtion is to introduce Boo algebra ina matmerandlate it to digitallogiccircuits andmiddotbinarYsignalsmiddot

Section 19 Sinary logic 29 ~

Itkltn of IInary logic

Binarylogic consists of binary v~les and a set of logica1middotoperatiQDS The variables are desigshy ~by lettell of thCalplWlet~such asA B C x yz etc with eaCh variable baving two and oniy

two distinct posSible valueS 1and O There are three basic logical operations AND ORand NOT

1 AN]) This ~peration is represented by adotorby the absence ~f an oPerator For example x bull y =z or xy = zis~ x ANDy is equalto z~ThelogicaloperationAND is interpreted to mean that z == 1 ifand only ift~ land y = 1 otherwise z = O (Reme~r that x y andzare binary v8riablesand canmiddotbe equal either to 1 or Omiddotand nothing eise)middot

2 OR This operation IS represented by a plus sign For example x + y =z is read x OR y is equal to z meaning that z 1 if x = iorif y = lorifbothx= 1 and y = 1 If bqth X - 0 andY Omeo z= O

3bull NOT This operation is repf6sented by a prime (sometimes by an overbar) For ~xample x =Z (or~ =z) is read notdsequalto 1 meiming that z iswkatx isnot In other

words ifx = 1 then z == 0 but if x == 0 tnenz = L TheNOT operationisals(1 reshyferred tolls the complement operation since it changes ~ 1 toOand a O to 1

bull bull lt Binary logic resembles binary arithmetic and themiddot9peratioos ANDahd OR have similarishy

ties to multiplication and addition respectively In fac~ the symbols used for AND and OR are the same as those used for multiplication and addition However binary lOgic should not be conshyfused withbinaryarithIrietic One should realize thatan arithmetic variable designates a numshyber that may consist of many digits A logicmiddot variable is always either 1 or O For example in binary arithmetic we have I +1 =10(read~one plus ()fie is equal to 2) whereas in binary logicwe have 1 + 1 1 (read one OR onds equal to one)

For each combination of the values oix and y bullthere isa value of ~ $pecifiedby the definishytion of the logical operation D~linitiops of logical~perations maybe listed in a compacHorm called truth tables A truth table is atable of anpbssible combinations ofthe variables $howshying the relation between the values that the variables may take and the resultof the operation The truth tables for th~ operations ANDand OR with variables x and y are obtained by lis~ng

all possible values that the variables may have when combined in pairs bull For each combination the resUlt of die operation 18 theillistedin a separate row The truth tables for ANDORand

NOT are given in Table La These tables clearly demonstrate the definitionf the operatibns

Table 18 Truth TcibJts of Logical Operations

AND OR NOT

x y xmiddoty x y x+y

0 0 0 0 0 0 1 0 0 1

10

1 0 d 1 0 1 I 1 1 1 1 1

bull~lt~m

30 Chapter 1

Logk Gates

Digital Systems and Binary Numbers

Logic gates are electronic cirellit that operate on ~

variable

or mpre mput tignals to produce an output signal Electrical signals sUch as voltages orrutrents exist as analog signals having values over a given taDgebull saYOt03 V but in a digital system are interpreted to be either of two recognizable values 0 or 1 Voltage~opetated logic Circuits respond to two separate voltshyage levels that represent a binary varjable equal to logic I bt logic O For example a partic- ular digital system may define 10gicOas a signal equal to 0 volts lind logic 1 asa signal equal to 3 volts In practice each voltage levelhiS an acceptable rangeas shown in Fig 13

The input te~nals of digital cikuits accePt binary signals within the allowable range and respond at the output terininals with binary signals that fall within the specified range The intermediate region between the aJl()wed regions is crossed only during aState transition Any desired information for computing or control can be operated tm by passing binary signals through variQUS combinatioDsof logic gates with each signal represebting a particular binary

The graphic symbols used to deSignate themiddotthree types of gates are Mown in Fig 14 The

gates are blocks of hardware that prooocc tbeequivalent of1ogic~1 orlogic() output signals

Volts

- FGURl13

x

y

Exampleof binary slgnaJs

Signal ratlge for logieO

(a)~omiddotinput AND gate

FIGURE 14 SymbOls for digital logic circuits

(c)NOT gate or invert~

Problems 31

x-lU 1 11 P 0

y 0 0 11 1 ~

ANDxy 0 0 rTl 00

ORX+Y~ NOT x 11 0 0 I 1 1

FIGURE 15 Input-output 5Igals for gates

FIGURE 1

A B C

Gates WIth mlltlple JnpUU

A B C lJ

~

if inPllt logic ~ts are satisfied Theinput signals xaDd y intheNDaadQR gates may exist in ~ oHow-possible states 00 10 11 or 01 Il1ese ibpu~ampignals_ shown inFig lStoshygetber with the corresponding output signal foreach PfCThI~tiaiug~iDustrate the reshysponse ofeaclt gate to the four input signal~The~llisofthetiminadiagram represents time and the vertical axis sbo~~~~ it cbapg~botwcen~possible voltshy

age levels The low level represents logic O tJte high level l1lteAND _ responds With a logic ~ ~tput sipl wh~ both input ~~)e 1middot1~ lIieOR S-~with a logic 1 outpUt signal ifanylnput sigrudis lOgic 1 TheNOTgateis~~ to BUll invedet The reason for~nameis~t froJn the signalmsponae inmiddottbe timitt8 diagramwhicbsbows that theoUtputsignal inverts the logic sense of tbeiDpUtsigll8l

AND and OR gates may bavei)lQte tbantwQinputs M AND8_~itti ~input$andan OR gate with foU) inputs are shown in Fig 16 The three-inPllt AND gate responds With logic 1 output if all tbreeinputs arelogic 11jleoutputproduces lOgic Oifanymput is logic O-The

four-input OR gate responds withlogic 1 ifany input is logic 1 its clu1ptltllCCoines logic oonly when all inputs are logic O

Answers to prvblems marked with middotappearaHbe ClOd ofthe ~

11 lJltthe octal and beXadecimalliurilbers trom16ui 32UdngA B1l1ld C forthebst~ digits Usttbe numbers from 8 to 28 in base13 bull

I

12t What is the exact D1Jllbcr of bytes in a system that contains lta) 32Kbytoe (b)64M ~and (e) 640 byte$ middot7 t

32 Chapter 1 Digital Systemsand Binary Numbers

13 Convert the following nu~bers with the indicated bases to decimal (a) (4310)s (b) (198hz (c) (735)8 (d) (525)6

14 Whllt is the largest binary number that can be expressed with 14 bits WhlIt are the equivaleDt ~~ iinal and hexadecimal numbei-s

--

15 Detemrine the base of thl1 numbers in each case for the following operatio~ to be correct (a) 142 = 5 (b) 5414 = 13 (C) 24+ 17 == 40

16 The solution$to the q~cequation xl - Ux +22 oare l1 3 arid x =6 What is the base of the numbers

17 Convertthehexadecimal ntmIher 68BE to bitiary and then convert it ~mbinary to octal

18 I Convert the decirpal number 431 to binary in tWo ways (a) Convertd~y to binary (b) conshyvert first to hexadecinla1 and then from ~decimalwbinary Which method is faster

19 amppress the following nqrnbersin decinud (a) IQ11O0101)z (b) (l65his (c)(2624)8 (d) (FAFA) 16

(e) (10101010)2

110 Convert the following binary numbers tobexadeoimal and todecitnal (a) UOOlO (b) 110010 Explain why the deCimal answer in (b)is 4 times that in (a)

111 Perform the followingdiviskmin binary 11 Ion + l()t

112 Add IlniImultiply tfle following numberswiihout converting them to decimal (a) Binary nuniberilOll aiIdlOh (b) He~uumbers 2E aDd 34

1~)( Do thefoHowing con~ersionproblems (a) CorivertCiecimal2731S to binary (b) CakUlate the binary eqUivalent (f 213 outto eight pl~Then Convert from binary to

imalHowgJose istbe result to 2131 (c) Convert the binary resukin (b) into hexad~ lb~oonvert ~result to decimal Is answer tbesame

114 Obtain the is 8nd 2s complementsofthe foUowing binaryDumbcentrs (aj l)()()(J()OO (b) OOOOOOOO (c) 11011010 (d)01l10110 (e) 10000101 (0 11111111

115 Find the 9s and the 10s complement of the following detimal numbers (a) 52734630 (b) 63325600 (c) 25000009 (d) 00000000

116 (a) Find the 16s complement of B2FA (b) Convert B2FA to binary (c) Find the 2scomplement ofthe resultin (b) (d) Convert the answer in (c)to hex~malandco~ with ihe an~wer in (a)

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 29: Chapter 01 - Mano

Section 19 Sinary logic 29 ~

Itkltn of IInary logic

Binarylogic consists of binary v~les and a set of logica1middotoperatiQDS The variables are desigshy ~by lettell of thCalplWlet~such asA B C x yz etc with eaCh variable baving two and oniy

two distinct posSible valueS 1and O There are three basic logical operations AND ORand NOT

1 AN]) This ~peration is represented by adotorby the absence ~f an oPerator For example x bull y =z or xy = zis~ x ANDy is equalto z~ThelogicaloperationAND is interpreted to mean that z == 1 ifand only ift~ land y = 1 otherwise z = O (Reme~r that x y andzare binary v8riablesand canmiddotbe equal either to 1 or Omiddotand nothing eise)middot

2 OR This operation IS represented by a plus sign For example x + y =z is read x OR y is equal to z meaning that z 1 if x = iorif y = lorifbothx= 1 and y = 1 If bqth X - 0 andY Omeo z= O

3bull NOT This operation is repf6sented by a prime (sometimes by an overbar) For ~xample x =Z (or~ =z) is read notdsequalto 1 meiming that z iswkatx isnot In other

words ifx = 1 then z == 0 but if x == 0 tnenz = L TheNOT operationisals(1 reshyferred tolls the complement operation since it changes ~ 1 toOand a O to 1

bull bull lt Binary logic resembles binary arithmetic and themiddot9peratioos ANDahd OR have similarishy

ties to multiplication and addition respectively In fac~ the symbols used for AND and OR are the same as those used for multiplication and addition However binary lOgic should not be conshyfused withbinaryarithIrietic One should realize thatan arithmetic variable designates a numshyber that may consist of many digits A logicmiddot variable is always either 1 or O For example in binary arithmetic we have I +1 =10(read~one plus ()fie is equal to 2) whereas in binary logicwe have 1 + 1 1 (read one OR onds equal to one)

For each combination of the values oix and y bullthere isa value of ~ $pecifiedby the definishytion of the logical operation D~linitiops of logical~perations maybe listed in a compacHorm called truth tables A truth table is atable of anpbssible combinations ofthe variables $howshying the relation between the values that the variables may take and the resultof the operation The truth tables for th~ operations ANDand OR with variables x and y are obtained by lis~ng

all possible values that the variables may have when combined in pairs bull For each combination the resUlt of die operation 18 theillistedin a separate row The truth tables for ANDORand

NOT are given in Table La These tables clearly demonstrate the definitionf the operatibns

Table 18 Truth TcibJts of Logical Operations

AND OR NOT

x y xmiddoty x y x+y

0 0 0 0 0 0 1 0 0 1

10

1 0 d 1 0 1 I 1 1 1 1 1

bull~lt~m

30 Chapter 1

Logk Gates

Digital Systems and Binary Numbers

Logic gates are electronic cirellit that operate on ~

variable

or mpre mput tignals to produce an output signal Electrical signals sUch as voltages orrutrents exist as analog signals having values over a given taDgebull saYOt03 V but in a digital system are interpreted to be either of two recognizable values 0 or 1 Voltage~opetated logic Circuits respond to two separate voltshyage levels that represent a binary varjable equal to logic I bt logic O For example a partic- ular digital system may define 10gicOas a signal equal to 0 volts lind logic 1 asa signal equal to 3 volts In practice each voltage levelhiS an acceptable rangeas shown in Fig 13

The input te~nals of digital cikuits accePt binary signals within the allowable range and respond at the output terininals with binary signals that fall within the specified range The intermediate region between the aJl()wed regions is crossed only during aState transition Any desired information for computing or control can be operated tm by passing binary signals through variQUS combinatioDsof logic gates with each signal represebting a particular binary

The graphic symbols used to deSignate themiddotthree types of gates are Mown in Fig 14 The

gates are blocks of hardware that prooocc tbeequivalent of1ogic~1 orlogic() output signals

Volts

- FGURl13

x

y

Exampleof binary slgnaJs

Signal ratlge for logieO

(a)~omiddotinput AND gate

FIGURE 14 SymbOls for digital logic circuits

(c)NOT gate or invert~

Problems 31

x-lU 1 11 P 0

y 0 0 11 1 ~

ANDxy 0 0 rTl 00

ORX+Y~ NOT x 11 0 0 I 1 1

FIGURE 15 Input-output 5Igals for gates

FIGURE 1

A B C

Gates WIth mlltlple JnpUU

A B C lJ

~

if inPllt logic ~ts are satisfied Theinput signals xaDd y intheNDaadQR gates may exist in ~ oHow-possible states 00 10 11 or 01 Il1ese ibpu~ampignals_ shown inFig lStoshygetber with the corresponding output signal foreach PfCThI~tiaiug~iDustrate the reshysponse ofeaclt gate to the four input signal~The~llisofthetiminadiagram represents time and the vertical axis sbo~~~~ it cbapg~botwcen~possible voltshy

age levels The low level represents logic O tJte high level l1lteAND _ responds With a logic ~ ~tput sipl wh~ both input ~~)e 1middot1~ lIieOR S-~with a logic 1 outpUt signal ifanylnput sigrudis lOgic 1 TheNOTgateis~~ to BUll invedet The reason for~nameis~t froJn the signalmsponae inmiddottbe timitt8 diagramwhicbsbows that theoUtputsignal inverts the logic sense of tbeiDpUtsigll8l

AND and OR gates may bavei)lQte tbantwQinputs M AND8_~itti ~input$andan OR gate with foU) inputs are shown in Fig 16 The three-inPllt AND gate responds With logic 1 output if all tbreeinputs arelogic 11jleoutputproduces lOgic Oifanymput is logic O-The

four-input OR gate responds withlogic 1 ifany input is logic 1 its clu1ptltllCCoines logic oonly when all inputs are logic O

Answers to prvblems marked with middotappearaHbe ClOd ofthe ~

11 lJltthe octal and beXadecimalliurilbers trom16ui 32UdngA B1l1ld C forthebst~ digits Usttbe numbers from 8 to 28 in base13 bull

I

12t What is the exact D1Jllbcr of bytes in a system that contains lta) 32Kbytoe (b)64M ~and (e) 640 byte$ middot7 t

32 Chapter 1 Digital Systemsand Binary Numbers

13 Convert the following nu~bers with the indicated bases to decimal (a) (4310)s (b) (198hz (c) (735)8 (d) (525)6

14 Whllt is the largest binary number that can be expressed with 14 bits WhlIt are the equivaleDt ~~ iinal and hexadecimal numbei-s

--

15 Detemrine the base of thl1 numbers in each case for the following operatio~ to be correct (a) 142 = 5 (b) 5414 = 13 (C) 24+ 17 == 40

16 The solution$to the q~cequation xl - Ux +22 oare l1 3 arid x =6 What is the base of the numbers

17 Convertthehexadecimal ntmIher 68BE to bitiary and then convert it ~mbinary to octal

18 I Convert the decirpal number 431 to binary in tWo ways (a) Convertd~y to binary (b) conshyvert first to hexadecinla1 and then from ~decimalwbinary Which method is faster

19 amppress the following nqrnbersin decinud (a) IQ11O0101)z (b) (l65his (c)(2624)8 (d) (FAFA) 16

(e) (10101010)2

110 Convert the following binary numbers tobexadeoimal and todecitnal (a) UOOlO (b) 110010 Explain why the deCimal answer in (b)is 4 times that in (a)

111 Perform the followingdiviskmin binary 11 Ion + l()t

112 Add IlniImultiply tfle following numberswiihout converting them to decimal (a) Binary nuniberilOll aiIdlOh (b) He~uumbers 2E aDd 34

1~)( Do thefoHowing con~ersionproblems (a) CorivertCiecimal2731S to binary (b) CakUlate the binary eqUivalent (f 213 outto eight pl~Then Convert from binary to

imalHowgJose istbe result to 2131 (c) Convert the binary resukin (b) into hexad~ lb~oonvert ~result to decimal Is answer tbesame

114 Obtain the is 8nd 2s complementsofthe foUowing binaryDumbcentrs (aj l)()()(J()OO (b) OOOOOOOO (c) 11011010 (d)01l10110 (e) 10000101 (0 11111111

115 Find the 9s and the 10s complement of the following detimal numbers (a) 52734630 (b) 63325600 (c) 25000009 (d) 00000000

116 (a) Find the 16s complement of B2FA (b) Convert B2FA to binary (c) Find the 2scomplement ofthe resultin (b) (d) Convert the answer in (c)to hex~malandco~ with ihe an~wer in (a)

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 30: Chapter 01 - Mano

30 Chapter 1

Logk Gates

Digital Systems and Binary Numbers

Logic gates are electronic cirellit that operate on ~

variable

or mpre mput tignals to produce an output signal Electrical signals sUch as voltages orrutrents exist as analog signals having values over a given taDgebull saYOt03 V but in a digital system are interpreted to be either of two recognizable values 0 or 1 Voltage~opetated logic Circuits respond to two separate voltshyage levels that represent a binary varjable equal to logic I bt logic O For example a partic- ular digital system may define 10gicOas a signal equal to 0 volts lind logic 1 asa signal equal to 3 volts In practice each voltage levelhiS an acceptable rangeas shown in Fig 13

The input te~nals of digital cikuits accePt binary signals within the allowable range and respond at the output terininals with binary signals that fall within the specified range The intermediate region between the aJl()wed regions is crossed only during aState transition Any desired information for computing or control can be operated tm by passing binary signals through variQUS combinatioDsof logic gates with each signal represebting a particular binary

The graphic symbols used to deSignate themiddotthree types of gates are Mown in Fig 14 The

gates are blocks of hardware that prooocc tbeequivalent of1ogic~1 orlogic() output signals

Volts

- FGURl13

x

y

Exampleof binary slgnaJs

Signal ratlge for logieO

(a)~omiddotinput AND gate

FIGURE 14 SymbOls for digital logic circuits

(c)NOT gate or invert~

Problems 31

x-lU 1 11 P 0

y 0 0 11 1 ~

ANDxy 0 0 rTl 00

ORX+Y~ NOT x 11 0 0 I 1 1

FIGURE 15 Input-output 5Igals for gates

FIGURE 1

A B C

Gates WIth mlltlple JnpUU

A B C lJ

~

if inPllt logic ~ts are satisfied Theinput signals xaDd y intheNDaadQR gates may exist in ~ oHow-possible states 00 10 11 or 01 Il1ese ibpu~ampignals_ shown inFig lStoshygetber with the corresponding output signal foreach PfCThI~tiaiug~iDustrate the reshysponse ofeaclt gate to the four input signal~The~llisofthetiminadiagram represents time and the vertical axis sbo~~~~ it cbapg~botwcen~possible voltshy

age levels The low level represents logic O tJte high level l1lteAND _ responds With a logic ~ ~tput sipl wh~ both input ~~)e 1middot1~ lIieOR S-~with a logic 1 outpUt signal ifanylnput sigrudis lOgic 1 TheNOTgateis~~ to BUll invedet The reason for~nameis~t froJn the signalmsponae inmiddottbe timitt8 diagramwhicbsbows that theoUtputsignal inverts the logic sense of tbeiDpUtsigll8l

AND and OR gates may bavei)lQte tbantwQinputs M AND8_~itti ~input$andan OR gate with foU) inputs are shown in Fig 16 The three-inPllt AND gate responds With logic 1 output if all tbreeinputs arelogic 11jleoutputproduces lOgic Oifanymput is logic O-The

four-input OR gate responds withlogic 1 ifany input is logic 1 its clu1ptltllCCoines logic oonly when all inputs are logic O

Answers to prvblems marked with middotappearaHbe ClOd ofthe ~

11 lJltthe octal and beXadecimalliurilbers trom16ui 32UdngA B1l1ld C forthebst~ digits Usttbe numbers from 8 to 28 in base13 bull

I

12t What is the exact D1Jllbcr of bytes in a system that contains lta) 32Kbytoe (b)64M ~and (e) 640 byte$ middot7 t

32 Chapter 1 Digital Systemsand Binary Numbers

13 Convert the following nu~bers with the indicated bases to decimal (a) (4310)s (b) (198hz (c) (735)8 (d) (525)6

14 Whllt is the largest binary number that can be expressed with 14 bits WhlIt are the equivaleDt ~~ iinal and hexadecimal numbei-s

--

15 Detemrine the base of thl1 numbers in each case for the following operatio~ to be correct (a) 142 = 5 (b) 5414 = 13 (C) 24+ 17 == 40

16 The solution$to the q~cequation xl - Ux +22 oare l1 3 arid x =6 What is the base of the numbers

17 Convertthehexadecimal ntmIher 68BE to bitiary and then convert it ~mbinary to octal

18 I Convert the decirpal number 431 to binary in tWo ways (a) Convertd~y to binary (b) conshyvert first to hexadecinla1 and then from ~decimalwbinary Which method is faster

19 amppress the following nqrnbersin decinud (a) IQ11O0101)z (b) (l65his (c)(2624)8 (d) (FAFA) 16

(e) (10101010)2

110 Convert the following binary numbers tobexadeoimal and todecitnal (a) UOOlO (b) 110010 Explain why the deCimal answer in (b)is 4 times that in (a)

111 Perform the followingdiviskmin binary 11 Ion + l()t

112 Add IlniImultiply tfle following numberswiihout converting them to decimal (a) Binary nuniberilOll aiIdlOh (b) He~uumbers 2E aDd 34

1~)( Do thefoHowing con~ersionproblems (a) CorivertCiecimal2731S to binary (b) CakUlate the binary eqUivalent (f 213 outto eight pl~Then Convert from binary to

imalHowgJose istbe result to 2131 (c) Convert the binary resukin (b) into hexad~ lb~oonvert ~result to decimal Is answer tbesame

114 Obtain the is 8nd 2s complementsofthe foUowing binaryDumbcentrs (aj l)()()(J()OO (b) OOOOOOOO (c) 11011010 (d)01l10110 (e) 10000101 (0 11111111

115 Find the 9s and the 10s complement of the following detimal numbers (a) 52734630 (b) 63325600 (c) 25000009 (d) 00000000

116 (a) Find the 16s complement of B2FA (b) Convert B2FA to binary (c) Find the 2scomplement ofthe resultin (b) (d) Convert the answer in (c)to hex~malandco~ with ihe an~wer in (a)

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 31: Chapter 01 - Mano

Problems 31

x-lU 1 11 P 0

y 0 0 11 1 ~

ANDxy 0 0 rTl 00

ORX+Y~ NOT x 11 0 0 I 1 1

FIGURE 15 Input-output 5Igals for gates

FIGURE 1

A B C

Gates WIth mlltlple JnpUU

A B C lJ

~

if inPllt logic ~ts are satisfied Theinput signals xaDd y intheNDaadQR gates may exist in ~ oHow-possible states 00 10 11 or 01 Il1ese ibpu~ampignals_ shown inFig lStoshygetber with the corresponding output signal foreach PfCThI~tiaiug~iDustrate the reshysponse ofeaclt gate to the four input signal~The~llisofthetiminadiagram represents time and the vertical axis sbo~~~~ it cbapg~botwcen~possible voltshy

age levels The low level represents logic O tJte high level l1lteAND _ responds With a logic ~ ~tput sipl wh~ both input ~~)e 1middot1~ lIieOR S-~with a logic 1 outpUt signal ifanylnput sigrudis lOgic 1 TheNOTgateis~~ to BUll invedet The reason for~nameis~t froJn the signalmsponae inmiddottbe timitt8 diagramwhicbsbows that theoUtputsignal inverts the logic sense of tbeiDpUtsigll8l

AND and OR gates may bavei)lQte tbantwQinputs M AND8_~itti ~input$andan OR gate with foU) inputs are shown in Fig 16 The three-inPllt AND gate responds With logic 1 output if all tbreeinputs arelogic 11jleoutputproduces lOgic Oifanymput is logic O-The

four-input OR gate responds withlogic 1 ifany input is logic 1 its clu1ptltllCCoines logic oonly when all inputs are logic O

Answers to prvblems marked with middotappearaHbe ClOd ofthe ~

11 lJltthe octal and beXadecimalliurilbers trom16ui 32UdngA B1l1ld C forthebst~ digits Usttbe numbers from 8 to 28 in base13 bull

I

12t What is the exact D1Jllbcr of bytes in a system that contains lta) 32Kbytoe (b)64M ~and (e) 640 byte$ middot7 t

32 Chapter 1 Digital Systemsand Binary Numbers

13 Convert the following nu~bers with the indicated bases to decimal (a) (4310)s (b) (198hz (c) (735)8 (d) (525)6

14 Whllt is the largest binary number that can be expressed with 14 bits WhlIt are the equivaleDt ~~ iinal and hexadecimal numbei-s

--

15 Detemrine the base of thl1 numbers in each case for the following operatio~ to be correct (a) 142 = 5 (b) 5414 = 13 (C) 24+ 17 == 40

16 The solution$to the q~cequation xl - Ux +22 oare l1 3 arid x =6 What is the base of the numbers

17 Convertthehexadecimal ntmIher 68BE to bitiary and then convert it ~mbinary to octal

18 I Convert the decirpal number 431 to binary in tWo ways (a) Convertd~y to binary (b) conshyvert first to hexadecinla1 and then from ~decimalwbinary Which method is faster

19 amppress the following nqrnbersin decinud (a) IQ11O0101)z (b) (l65his (c)(2624)8 (d) (FAFA) 16

(e) (10101010)2

110 Convert the following binary numbers tobexadeoimal and todecitnal (a) UOOlO (b) 110010 Explain why the deCimal answer in (b)is 4 times that in (a)

111 Perform the followingdiviskmin binary 11 Ion + l()t

112 Add IlniImultiply tfle following numberswiihout converting them to decimal (a) Binary nuniberilOll aiIdlOh (b) He~uumbers 2E aDd 34

1~)( Do thefoHowing con~ersionproblems (a) CorivertCiecimal2731S to binary (b) CakUlate the binary eqUivalent (f 213 outto eight pl~Then Convert from binary to

imalHowgJose istbe result to 2131 (c) Convert the binary resukin (b) into hexad~ lb~oonvert ~result to decimal Is answer tbesame

114 Obtain the is 8nd 2s complementsofthe foUowing binaryDumbcentrs (aj l)()()(J()OO (b) OOOOOOOO (c) 11011010 (d)01l10110 (e) 10000101 (0 11111111

115 Find the 9s and the 10s complement of the following detimal numbers (a) 52734630 (b) 63325600 (c) 25000009 (d) 00000000

116 (a) Find the 16s complement of B2FA (b) Convert B2FA to binary (c) Find the 2scomplement ofthe resultin (b) (d) Convert the answer in (c)to hex~malandco~ with ihe an~wer in (a)

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 32: Chapter 01 - Mano

32 Chapter 1 Digital Systemsand Binary Numbers

13 Convert the following nu~bers with the indicated bases to decimal (a) (4310)s (b) (198hz (c) (735)8 (d) (525)6

14 Whllt is the largest binary number that can be expressed with 14 bits WhlIt are the equivaleDt ~~ iinal and hexadecimal numbei-s

--

15 Detemrine the base of thl1 numbers in each case for the following operatio~ to be correct (a) 142 = 5 (b) 5414 = 13 (C) 24+ 17 == 40

16 The solution$to the q~cequation xl - Ux +22 oare l1 3 arid x =6 What is the base of the numbers

17 Convertthehexadecimal ntmIher 68BE to bitiary and then convert it ~mbinary to octal

18 I Convert the decirpal number 431 to binary in tWo ways (a) Convertd~y to binary (b) conshyvert first to hexadecinla1 and then from ~decimalwbinary Which method is faster

19 amppress the following nqrnbersin decinud (a) IQ11O0101)z (b) (l65his (c)(2624)8 (d) (FAFA) 16

(e) (10101010)2

110 Convert the following binary numbers tobexadeoimal and todecitnal (a) UOOlO (b) 110010 Explain why the deCimal answer in (b)is 4 times that in (a)

111 Perform the followingdiviskmin binary 11 Ion + l()t

112 Add IlniImultiply tfle following numberswiihout converting them to decimal (a) Binary nuniberilOll aiIdlOh (b) He~uumbers 2E aDd 34

1~)( Do thefoHowing con~ersionproblems (a) CorivertCiecimal2731S to binary (b) CakUlate the binary eqUivalent (f 213 outto eight pl~Then Convert from binary to

imalHowgJose istbe result to 2131 (c) Convert the binary resukin (b) into hexad~ lb~oonvert ~result to decimal Is answer tbesame

114 Obtain the is 8nd 2s complementsofthe foUowing binaryDumbcentrs (aj l)()()(J()OO (b) OOOOOOOO (c) 11011010 (d)01l10110 (e) 10000101 (0 11111111

115 Find the 9s and the 10s complement of the following detimal numbers (a) 52734630 (b) 63325600 (c) 25000009 (d) 00000000

116 (a) Find the 16s complement of B2FA (b) Convert B2FA to binary (c) Find the 2scomplement ofthe resultin (b) (d) Convert the answer in (c)to hex~malandco~ with ihe an~wer in (a)

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 33: Chapter 01 - Mano

Problems 33

middot117 Perform subtraction on the given unsigned numbers using the lOs complement of the su~trashybend Where the result should be negative find its 10s comple~t and affix a minus sign Vershyify your answers (a) 6428 3409 (b) 125 - i800 (c) 2043 -6152 (d)I6~1 -14~

1~18 Perform $ubtraCtion on the given unsigned bipary numbers usiIigthe 2s complement of the SlJhshy trahend Where the result should be negative find its 2s complement and ~lX a minus sign

(a) iOOll - 10001 (b) 100010 100011 (c) 1001 101000 (d) 110000 - 10101

11~ The following decimal numbers are shown in sign-magnitude forin +9286 and +801 Convert them to signed~ IOs~omplement fonn and perfomHhe following Operations (note that the sum is + 10627 and requires fiv~ digits and a sign) (a) (+9286) + (+801) (b) (+9286)+ (-80l)

(c) (-9286) + (+801) (d) (9286)+ (-80l)

120 Conven decimal +46 and +29 to binlll) u~ing the signed-2s-complementrepresentation and eRough digitsto aceommodate the numbetll Then perfonnthe binary equiva1~t of (+29) + (-49) (29) + (149) andJ -29) + (-49) Convert the answers back to decitnal and verify that they are correct

121 If the numbers +9742)10 and (+641ho are in signe4imagnitude fonnllt their sum is (+10383)10 and requires fiv~ digits aad a sign COvert thl numbers to signed-l0s-compIeshyment form aad find the following sums (8) (+9742) +(+641) (b) (+9742) + (-641) (c) (--9742) + (+641) (d) ( 9742) + (-641)

122 Conven decimalS723 to bOth BCD and ASCII codes For AScn an even parity bit is to be apshypended at the left

123 Represent the unsigned decimal numbers 842 and 537 in BcD and then show the steps necesshy$8l) to form their sum

124 Formulate a weighted binary code for thedeclmal digits using weights

(a) 63 I 1

(b) 6421

125 RepreselJt the decinud number 5137 in (a) BCD (b) excess-3 code (c) 2421 code and (d) a 63p code

126 Fmd the 9s complement of decima15137 and express it in 2421 code Show thatthe result is the ls complement oftampe answer to (c) in Jroblem 125 nis demonstrates that the 2421 code is self-complementing

127 Assign a binary code in some Orderly manpertothe 52 playing cards Use the minimum number Gfbits

128 Write the expression uOBoole in ASCD using an eight-bi~ code Include the period and the space Treat the leftmost bit of each character as a parity bit Each eight-bit code should have

even parity (George Boo~e was a 19ttt century nipthematiciaa Boolean algebra introduced in the next chapter bears his name)

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 34: Chapter 01 - Mano

34 Chapter 1 Digital Systems~nd BlnaryNumbers

129 Decodethe following ASCn code

l00tXnO 11010011101100 1101100 lOOO1111100(gt011nOl00 1100101 1110011

130 The following in sma of ASCII ~baracter$whose bjt pa~lulve l)een CQBVerted into bexashydecimal for CQmpactness 73 F4 135 76 BS 4ASF 62 73 Of theeightbjts in each pair of digits the leftmost is a parity bit The remainfugbits afethe ASCI( code (a) Convert the $tiinjtO bit fann and decode the AScn

(b)Pctermine the parity U$ed odd or even

131 Howmanypriniing characters afe there 1n ASCII How U18fly of them are specialcharacteJs (not 1ettenor nl1Jl)ef8ls)

1-32 What bit mustbeCom~mented to cbange8D ASCII letlertrOm capital to lowercase and vice versa

1U Thestateofa12-bit iegister is l()()()10010111 Wbatis its content if it represents bull(a) thtee decinlal digits in BCD (Iraquo threedecimal digiSin the eXCess-3 code (c)thtee4ecimal digits in theM-2-1 code (d)abinalynumber

134 List the ASCII code for tile 10 declmaldlaitswith anoddparitybit in the leftmost position

1BYmeatisof~tbmngdiagram$imilartot1g1SshowlhellignalsOfIhemiddotoutpl1tdandginPig asfwtctkllls Qf the thtee jnputs ab and c Use aIleigJlt pos$iblecombiDations of a b and c

abc

f

----g

RGU PlU

1NBy means of atUningdilgnun ~ toFig 15 ~ the signals oftbeQUtputs f and g in P136 as functions of the twQillpUtfa ~d b Use all (our possiQle c~OJisofa and b

a b

f

g

fiGURE PlU

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf
Page 35: Chapter 01 - Mano

References 3S

1 CAV~AOH J J19amp4Di$ital epmpiIerAri~ NeW York MQGtawmDmiddot MANo M M 1988 Computer Erigmeering HanlwareJJesign Englewood Cliffs NJ PrentiCe Hall

NELSON V P H T NAOLE J 0 IRWIN and B D CARROLL 1997 Digital Logic Circuit Analy- sis and ~sign Upper S~dleRiver NJ Prenti~ Han SCHMID H 1974 Decimal Computation~ New York John Wiley

  • Chapter 01 - part 01
  • Chapter 01 - part 02
  • Chapter 01 - part 03pdf