500 likes | 511 Views
Digi t al C ircuit Design. Digit a l Syst e ms and Bin a ry Numb e rs. Depa r t m ent of Com p uter Science Nat i onal C h ia o Tun g. l d v an@ c s . nc t u. edu . tw h t t p: //ww w . cs. n c t u . e du .t w /~l d v a n/. Digi t al C ircuit Design. Outl i ne. L ec t ure 1.
E N D
DigitalCircuit Design DigitalSystemsand BinaryNumbers DepartmentofComputerScienceNationalChiaoTung ldvan@cs.nctu.edu.twhttp://www.cs.nctu.edu.tw/~ldvan/
DigitalCircuit Design Outline Lecture 1 Digital Systems Binary Numbers Number-BaseConversion OctalandHexadecimalNumber SignedBinaryNumbers Binary Codes Binary Storage andRegisters Binary Logic Lan-DaVan
DigitalCircuit Design Digital System Lecture 1 • Digital ageandinformationage Digital computers • generalpurposes • manyscientific,industrialandcommercialapplications • Digital systems • telephoneswitchingexchanges • digitalcamera • electroniccalculators,PDA's • digitalTV • Discrete information-processingsystems • manipulatediscreteelementsofinformation Lan-DaVan
DigitalCircuit Design A DigitalComputerExample Lecture 1 Memory Control unit Datapath CPU Inputs: Keyboard, Outputs: CRT, mouse,modem, microphone LCD, modem, speakers Input/Output Synchronous or Asynchronous? Lan-DaVan
DigitalCircuit Design Signal Lecture 1 • Aninformationvariablerepresentedby physicalquantity Fordigitalsystems,thevariabletakes on digitalvalues • Twolevel,orbinaryvaluesarethemostprevalentvalues • Binary valuesare representedabstractly by: • digits0 and1 • words(symbols)False(F)andTrue(T) • words(symbols)Low(L)andHigh (H) • wordsOnandOff. • Binary valuesare representedby valuesor rangesof values of physicalquantities Lan-DaVan
DigitalCircuit Design Signal Lecture 1 • Analogsignal • t->y: y=f(t),y:C,n:C • Discrete-timesignal • n->y:y=f(nT),y:C,n:Z • Digitalsignal • n->y:y=D{f(nT)},y:Z,n:Z (1110)2 (1000)2 y y y (1011)2 ( 3) ( 2) (1)(1) (1000)2 t n Discrete-Time Signal n AnalogSignal DigitalSignal Lan-DaVan
DigitalCircuit Design BinaryNumbers Lecture 1 Baseor radix Decimal number …a5a4a3a2a1a0.a1a2a3… aj Decimal point Example: 7,329 7103310221019100 Generalform of base-r system a rnarn1 n n1 1 2 m 2 1 • a2raraa ra2r • amr 1 0 1 Coefficient:aj =0 to r 1 Lan-DaVan
DigitalCircuit Design BinaryNumbers Lecture 1 Example:Base-2 number (11010.11)2(26.75)10 124123022121020121122 Example:Base-5 number (4021.2)5 453052251150251(511.4) 5 10 Example:Base-8 number (127.4)8 182281780481(87.5) 10 Example:Base-16number (B65F)111636162516115160(46,687) 1610 Lan-DaVan
DigitalCircuit Design BinaryNumbers Lecture 1 Example:Base-2number (110101)2321641(53)10 SpecialPowersof2 (1024)isKilo, denoted"K" 210 220(1,048,576)is Mega,denoted"M" 230(1,073,741,824)is Giga, denoted"G" Lan-DaVan
DigitalCircuit Design BinaryNumbers Lecture 1 Arithmeticoperations withnumbersinbaserfollowthesamerulesas decimal numbers. Lan-DaVan
DigitalCircuit Design BinaryArithmetic Lecture 1 Subtraction Minuend: 101101 Addition Augend: 101101 ATddheenbd:in+a1r0y01m11ultiplicationtableisSsuimbtpraleh:end: 100111 01=01001|0010=0|01=0Difference:1 000110 Sum0: | 11= MEuxlttiepnlidciantgiomnultiplicationtomultipledigits: Lan-DaVan
DigitalCircuit Design OctalandHexadecimalNumbers Lecture 1 Numberswithdifferentbases:Table1.2. Lan-DaVan
DigitalCircuit Design Number-BaseConversions Lecture 1 Example1.1 Convertdecimal41to binary.Theprocessis continueduntiltheintegerquotient becomes 0. 10/2 5 2 5/2 2/2 1 1/2 0 Lan-DaVan
DigitalCircuit Design Number-BaseConversions Lecture 1 Thearithmeticprocesscanbemanipulatedmoreconvenientlyas follows: Answer=(101001)2 Lan-DaVan
DigitalCircuit Design Number-BaseConversions Lecture 1 Example1.2 Convertdecimal153tooctal.Therequiredbaser is 8. Lan-DaVan
DigitalCircuit Design Number-BaseConversions Lecture 1 Example1.3 Convert(0.6875)10to binary. Theprocessis continueduntilthefraction becomes0 or untilthenumberof digitshas sufficient accuracy. Toconvertadecimalfractiontoa numberexpressedin baser,asimilar procedureisused.However,multiplicationis by rinsteadof2,andthe coefficientsfoundfromtheintegersmayrangein value from0tor1 insteadof0and1. Lan-DaVan
DigitalCircuit Design Number-BaseConversions Lecture 1 Example1.4 Convert (0.513)10tooctal. FromExamples1.1 and1.3: From Examples1.2and1.4: (41.6875)10= (101001.1011)2 (153.513)10= (231.406517)8 Lan-DaVan
DigitalCircuit Design Number-BaseConversions Lecture 1 Conversionfrom binaryto octalcanbe doneby positioningthebinarynumberinto groups of three digitseach, starting from thebinarypointand proceedingtotheleft and totheright. (10110001101011.111100000110)2=(26153.7406)8 2 6 1 5 3 7 4 0 6 Conversionfrom binaryto hexadecimalis similar,exceptthat the binarynumberis dividedinto groupsof four digits: Conversionfrom octalor hexadecimaltobinaryis doneby reversingthepreceding procedure. Lan-DaVan
DigitalCircuit Design Complements Lecture 1 Therearetwotypesofcomplementsforeachbase-rsystem:theradixcomplementand diminishedradixcomplement. ther's complementandthesecondas the(r1)'s complement. • DiminishedRadix Complement Example: For binarynumbers,r= 2andr –1 = 1,so the1'scomplementofN is (2n1) –N. Example: Lan-DaVan
DigitalCircuit Design Complements • Lecture 1 • Radix Complement Ther's complementof an n-digitnumberN inbaser is definedas rn–N for N ≠ 0 and as 0 forN =0.Comparingwiththe(r1) 's complement,wenotethat the r's complementis obtainedbyadding1 tothe(r 1) 's complement,since rn–N = [(rn1)–N] +1. Example:Base-10 The10's complementof012398is 987602 The10's complementof246700is 753300 Example:Base-2 The2'scomplementof 1101100is 0010100 The2'scomplementof 0110111is 1001001 Lan-DaVan
DigitalCircuit Design Complements • Lecture 1 • SubtractionwithComplements • Thesubtractionof twon-digitunsignednumbersM–Ninbaser canbedoneas follows: an Lan-DaVan
DigitalCircuit Design Complements Lecture 1 Example1.5 Using10's complement,subtract72532–3250. Example1.6 Using10's complement,subtract3250–72532 Thereis noendcarry. Lan-DaVan DCD-0 Therefore,theansweris –(10's complementof30718)= 69282.
DigitalCircuit Design Complements Lecture 1 Example1.7 GiventhetwobinarynumbersX =1010100andY =1000011,performthesubtraction(a) X–Yand (b) YX byusing2'scomplement. Thereis noend carry. Therefore,theansweris Y–X =(2'scomplement of1101111)=0010001. Lan-DaVan
DigitalCircuit Design Complements Lecture 1 Subtractionof unsignednumberscanalsobedonebymeansofthe(r 1)'s complement. Rememberthat the(r 1) 'scomplementis onelessthanthe r's complement. Example1.8 Repeat Example1.7,butthis timeusing1'scomplement. Lan-Da Thereis noend carry, Therefore,theansweris Y–X =(1'scomplement of1101110)=0010001. Van
DigitalCircuit Design SignedBinaryNumbers Lecture 1 Torepresentnegativeintegers,weneeda notationfor negativevalues. Itis customary to representthesignwitha bit placedintheleftmostpositionofthe number. Theconventionis tomakethesignbit 0 for positiveand1 fornegative. Example: Lan-DaVan
DigitalCircuit Design SignedBinaryNumbers Lecture 1 Table3 listsallpossiblefour-bitsignedbinarynumbersinthethree representations. Lan-DaVan
DigitalCircuit Design SignedBinaryNumbers • Lecture 1 • ArithmeticAddition • Theadditionof two numbers inthe signed-magnitudesystem followsthe rules of ordinary arithmetic.If thesignsarethe same,weaddthe two magnitudesand give thesum the commonsign.If thesignsaredifferent,wesubtract the smaller magnitude fromthelargerandgive thedifference thesign if the largermagnitude. • Theadditionoftwosignedbinarynumberswithnegative numbersrepresentedin signed-2's-complementform is obtainedfromtheadditionof thetwonumbers, includingtheirsign bits. • Acarryoutof thesign-bitpositionis discarded. • Example: Lan-DaVan
DigitalCircuit Design SignedBinaryNumbers • Lecture 1 • ArithmeticSubtraction • In 2’s-complementform: • Takethe2’s complementofthesubtrahend(includingthesignbit)andadd it to • theminuend(includingsignbit). • Acarryoutof sign-bitpositionis discarded. (A)(B)(A)(B) (A)(B)(A)(B) Example: (6)(13) (1111101011110011) (11111010+00001101) 00000111(+7) Lan-DaVan
DigitalCircuit Design BCDCode Lecture 1 Anumberwithkdecimaldigitswill require 4k bitsinBCD.Decimal396 isrepresentedinBCD with12bitsas 0011 10010110,witheach groupof 4bits representingonedecimaldigit. AdecimalnumberinBCD is the sameas its equivalentbinary number onlywhenthenumberis between0 and9.ABCD number greater than 10 looksdifferentfrom itsequivalentbinarynumber,even though bothcontain1'sand0's. Moreover, the binarycombinations 1010through1111arenot usedand have no meaninginBCD. • BCD Code Lan-DaVan
DigitalCircuit Design BCD Code Lecture 1 Example: Considerdecimal185and its correspondingvalueinBCD andbinary: • BCDAddition Lan-DaVan
DigitalCircuit Design BCD Code Lecture 1 Example: Considertheadditionof 184+576=760inBCD: • DecimalArithmetic 1 Lan-DaVan
DigitalCircuit Design Other DecimalCodes Lecture 1 • OtherDecimalCodes Lan-DaVan
DigitalCircuit Design GrayCode Lecture 1 • GrayCode Lan-DaVan
DigitalCircuit Design GrayCode Lecture 1 Does thisspecialGraycodepropertyhave anyvalue? AnExample:OpticalShaftEncoder 111 000 100 000 B0 B1 B 101 001 001 110 2 G2 G1 G0 111 010 011 101 100011 (a)BinaryCode for Positions0through7 110010 (b)GrayCodeforPositions0through7 Lan-DaVan
DigitalCircuit Design ASCIICharacterCode Lecture 1 • ASCIICharacterCode Lan-DaVan DCD-01-35
DigitalCircuit Design ASCIICharacterCode Lecture 1 • ASCIICharacterCode Lan-DaVan
DigitalCircuit Design ASCIICharacterCode • Lecture 1 • American StandardCodeforInformationInterchange(Refer toTable 1.7) • Apopularcodeusedto represent information sentas character-based data. • Ituses7-bits torepresent: • 94Graphic printingcharacters. • 34Non-printingcharacters • Somenon-printingcharacters are usedfortext format(e.g. • BS= Backspace,CR= carriagereturn) • Othernon-printingcharacters areusedforrecordmarking and flow control (e.g. STX andETX startandendtextareas). Lan-DaVan
DigitalCircuit Design ASCIICharacterCode • Lecture 1 • ASCIIhassome interestingproperties: • Digits0to 9 spanHexadecimalvalues3016to 3916. • UppercaseA -Zspan4116to 5A16. • Lowercasea -zspan6116to 7A16 . • Lowerto uppercase translation(andviceversa) occursbyflippingbit 6. • Delete(DEL)isall bitsset,a carryoverfromwhen punchedpapertape wasusedto store messages. • Punchingall holesina roweraseda mistake! Lan-DaVan
DigitalCircuit Design ErrorDetectionCode • Lecture 1 • Error-DetectingCode • Todetect errors indata communicationandprocessing,aneighthbitis sometimes added to theASCII charactertoindicateitsparity. • Aparitybit is anextrabit includedwithamessageto makethetotalnumberof 1's • either even or odd. • Example: • Considerthefollowingtwocharacters andtheir evenandodd parity: Lan-DaVan
DigitalCircuit Design ErrorDetectionCode • Lecture 1 • Error-DetectingCode • Redundancy(e.g.extra information),intheformof extra bits, canbe incorporatedinto binarycodewords to detect and correcterrors. • Asimpleformof redundancyisparity, anextra bit appended ontothecodeword tomake thenumberof 1’s oddor even. • Parity can detect all single-biterrors andsome multiple-bit errors. • Acodewordhasevenparityifthe numberof 1’s inthecode word is even. • Acodewordhasoddparityifthe numberof 1’s inthecode word is odd. Lan-DaVan
DigitalCircuit Design ConversionorCoding? Lecture 1 DoNOTmixupconversion of a decimal number toa binarynumber withcodinga decimal number witha BINARYCODE. 1310= 11012(Thisisconversion) 13 0001|0011(Thisis coding) Lan-DaVan
DigitalCircuit Design BinaryStorageandRegisters • Lecture 1 • Registers • Abinarycellis a devicethatpossessestwostablestates andis capableof storing one of the twostates. • Aregisteris a groupof binarycells.Aregisterwithncellscanstoreany discrete quantityofinformationthat containsnbits. 2npossiblestates • ncells • Abinarycell • twostablestate • storeonebitofinformation • examples:flip-flopcircuits,ferrite cores, capacitor • Aregister • agroupof binarycells • AXinx86CPU • RegisterTransfer • atransfer of theinformationstored inone registerto another • one of the majoroperationsindigitalsystem Lan-DaVan
DigitalCircuit Design Transferof Information Lecture 1 Lan-DaVan
DigitalCircuit Design ExampleofBinary InformationProcessing Lecture 1 Lan-DaVan DCD-01-44
DigitalCircuit Design BinaryLogic Lecture 1 Binarylogicconsists of binaryvariablesanda setoflogicaloperations. Thevariables aredesignatedby letters of thealphabet,suchasA, B, C, x, y,z, etc,witheach variablehavingtwoandonlytwodistinctpossiblevalues:1 and0,Therearethree basic logicaloperations:AND,OR,and NOT. Lan-DaVan DCD-01-45
DigitalCircuit Design BinaryLogic • Lecture 1 • The truthtablesforAND, OR,and NOTaregiveninTable1.8. Lan-DaVan
DigitalCircuit Design BinaryLogic Lecture 1 • Logic gates • Example of binarysignals Lan-DaVan
DigitalCircuit Design BinaryLogic • Lecture 1 • Logic gates • GraphicSymbolsand Input-OutputSignalsforLogicgates: Lan-DaVan DCD-01-48 Input-Outputsignals forgates
DigitalCircuit Design BinaryLogic • Lecture 1 • Logic gates • GraphicSymbolsand Input-OutputSignalsforLogicgates: Lan-DaVan
DigitalCircuit Design Conclusion Lecture 1 • Youhavelearnedthefollowingterms: • Binarynumber • NumberConversion • Complement • Simplearithmetic • Binarycodes • Storageandregister • Binarylogic Lan-DaVan