Lecture 3 Ferury 6 ern University of pplied ciences ev. f57fc 3. We hve seen tht circuit cn hve multiple (n) inputs, e.g.,, C, We hve lso seen tht circuit cn hve multiple (m) outputs, e.g. X, Y,, ; or formulted differently, the circuit contins m logic functions Finlly we hve seen how to derive the smllest representtion of those m logic functions The question is now: How do we interpret s designer those inputs nd outputs? Ech of the n inputs nd m outputs represent quntity tht cn e either or ; we cll this it Multiple its cn e grouped together to form one dimensionl rrys; the well known groups re: The ile s group of 4 its, e.g. The yte s group of 8 its ( iles), e.g. ev. f57fc 3. Ordering The groups re nice, ut how do we form ile from the inputs,, C, nd D?. CD?. CD? 3. CD? 4. We need to define n order to e le to uniquely identify the inputs nd outputs Let us define i i [..(n )] s the set of ordered inputs of circuit, e.g. for n=8 the yte formed y the inputs is: 7 6 5 4 3 Let us define O j j [..(m )] s the set of ordered outputs of circuit, e.g. for m=4 the ile formed y the outputs is: O 3 O O O The its nd O re clled the Lest ignificnt its The its n nd O m re clled the Most ignificnt its We lwys write : M L ev. f57fc 3.3
nterprettion O 3 O O 4 Here we hve house with 5 light switches (inputs) nd 3 lmps (outputs). The interprettion of the inputs nd outputs is in this cse the switching of the light sources. This functions cn e s complex s we wnt. There re vrious interprettions of the inputs nd outputs of digitl system, numers re one of them ev. f57fc 3.4 turl umers () For the reminder of the discussion of the numer systems we will use the interprettion of the set of ordered inputs i ; the interprettion of the set of ordered outputs O j is identicl ssuming yte of ordered inputs, thn we could interpret the it ptterns s: 7 6 5 4 3 Deciml 3 4 5 6 7 8 This is the so clled one-hot encoding However these encodings re not very efficient! ev. f57fc 3.5 turl umers () in plce-vlue nottion More compct nd elegnt re the positionl systems like the deciml system we re used to: 3. +. +. 3 3 + + Ech numer consists of i digits The position of the digit denotes its importnce digit d p [..( )] t position p [..(i )] given the se hs the importnce p The numer is therey defined y: i = d p p p= ev. f57fc 3.6
turl umers () in plce-vlue nottion Other plce-vlued numers: The inry numer system: 9 8 7 6 5 4 3 The se =, nd the digit rnge is d p [, ] = + 9 + 6 + 5 + 3 + = 665 The octl numer system: 9 8 7 6 5 4 3 55 o The se = 8, nd the digit rnge is d p [..7] 55 o = 5 8 3 + 8 + 5 8 + 8 = 665 The hexdeciml numer system: 9 8 7 6 5 4 3 x69 The se = 6, nd the digit rnge is d p [..9,,, C, D, E, F] x69 = 6 + 6 6 + 9 6 = 665 ev. f57fc 3.7 turl umers () in plce-vlue nottion How to trnsform 3645 dec to plce-vlue numer with se = 7? 7 7 3 7 7 4 7 4 4 7 5 7 4 4 9 3 8 3 6 4 5 dec = 3 4 5 =7 7 3 6 4 5 5 3 5 4 4 5 5 We strt the division The rest is the digit t position, e.g. 3645 = 5 7 + 5 7 s 5 [..6] we hve to continue the division ow [..6] we re done. Let s check: 3645? = 4 + 9 + 96 + 4 + 5 ev. f57fc 3.8 The ddition How do we dd two plce-vlued numers? Crries: 3 5 9 + 7 5 ssume we wnt to determine = 3 + 59 We strt dding the digits t position p =, e.g. = { d + d = 3 + = 5, the resulting digit d r = <, nd the crry { < c = We continue to position p = ; t ll positions p the sum equls to p = dp + dp + c p, note: c =! Wht hppens if crry c 3 = (for exmple if = + )? ev. f57fc 3.9
The ddition; Limittions of Digitl ystems ssume following inry dder: + We hve circuit tht dds the numers nd n cse = nd = something strnge hppens, s = +! We cll this n overflow sitution n overflow cn occur s ny digitl system hs only limited numer of k-its (k = 3 for this exmple) Given this limittion of k-its, digitl system hs rnge in which it cn represent numers, e.g. for nd k = 3 the representtion rnge is [..( k )] [..7] Q Q Q ev. f57fc 3. The ustrction imilr to the ddition we cn lso sustrct two plce-vlued numers: orrows: 7 5 5 9 3 ssume we wnt to determine = 75 59 We strt t position p =, e.g. = d d = 5 = 3, the resulting digit {d d r = d d d ( + d ) d d < d, nd the orrow { d = d < d We continue to position p = ; t ll positions p the sustrction { equls to p = dp dp p dp dp + p ( + dp ) dp p dp < dp + p ote: =! ev. f57fc 3. The ustrction; o egtive umers ssume following inry sustrctor: Q Q Q We hve circuit tht sustrct the numers nd n cse = nd = something strnge hppens, s =! We cll this n underflow sitution ev. f57fc 3.
ntegers () sign-nd-mgnitude representtion The set of integers contins the turl umers nd their negtives (,,,3,4,...) n the deciml system we use the sign-nd-mgnitude nottion, e.g. +4 nd -4 where the + is often omitted mportnt: the sign-nd-mgnitude nottion hs two s, nmely + D -! n the inry system, we do not hve + nd -, we only hve nd However, y the introduction of the M s sign-it we cn crete inry form of the sign-nd-mgnitude representtion y interpreting =+ nd =-: 3 + x! 3 x! ev. f57fc 3.3 ddition nd ustrction with ntegers () deciml sustrction =- we normlly rewrite to deciml ddition =+C y forming the negte of the sustrctor, e.g. C = -, this cn e esily ccomplished y chnging the sign in sign-nd-mgnitude system. For inry sign-nd-mgnitude interprettion this opertion would e n inversion of the sign-it. n sign-nd-mgnitude representtion we cn write this ddition s: s z = s + s c C 3 = 4 + (+ ) The ddition is complex : s s c Condition: s z Exmples: + + none + + C + = 3 none + C + () = 3 + C + C + () = < C C + () = + C C + = < C + C + = ev. f57fc 3.4 ntegers () one s-complement representtion ddition nd sustrction in the sign-nd-mgnitude representtion requires n dder nd sustrctor, cn t we find nother representtion tht requires less complexity? Wht if insted of inverting only the sign it to represent negtive numer, we invert (one s-complement) ll its: Dec.: nputs: sign-nd-mgnitude: s-complement: +3 + + + 3 OTE: one s-complement representtion lso hs representtions for! ev. f57fc 3.5
ntegers () one s-complement representtion ddition nd sutrcting one s-complement numers is esier thn doing the sme in sign-nd-mgnitude representtion: sustrction =- is gin trnsformed into n ddition =+C y forming the one s-complement C=- (y inverting [complementing] ll the its of ). The ddition =+C cn now e performed y inry ddition s for, with the difference tht crry c k hs to e dded t the L position; this is the so clled end-round crry ddition: + 3 3 + + One scomplement: +3 3 + + + ev. f57fc 3.6 ntegers () one s-complement representtion + 3 3 + + One scomplement: +3 + + + 3 One s-complement is gret, s for oth the ddition nd sustrction of integers we only require inverters nd n end-round crry dder However, n end-round crry dder is slow! Oservtion: The end crry c n is only when one of the vriles or C in =+C is negtive! Why not dd to ll negtive numers? ev. f57fc 3.7 ntegers () two s-complement representtion Two scomplement: One scomplement: The positive numers in two s-complement nottion hve sme it encodings s the other presented numer interprettion systems The + nd - mp on the sme it pttern in the two s-complement nottion resulting in single! The remining it pttern is mpped to -4 +3 + + + 3 +3 + + 3 4 ev. f57fc 3.8
ntegers () one s versus two s complement One s complement ddition/sustrction: +/ O = +/ O O O One s complement is slow due to the end-round crry Two s complement is fster, nd hs only one! ev. f57fc 3.9 ntegers () Excess- representtion The two s complement representtion is commonly used to represent integers in for exmple Processors, Digitl ignl Processors, nd others However, there exists nother importnt representtion: the Excess- representtion, lso clled the ised representtion The Excess- representtion uses pre-specified numer s ising vlue. The deciml numer is represented y ll s Exmple: The three it Excess-3 representtion 4 3 3 The Excess- representtion is minly used in nlog to Digitl converters nd the EEE floting-point stndrd Performing clcultions in the Excess- representtion is only in few cses simple nd out of the scope of this course! ev. f57fc 3. ntegers () Overflow nd Underflow Did we solve the overflow nd underflow prolem? o, s we still hve only k-its to represent numers! We just chnged the rnges: epresenttion: umer: Deciml rnge: inry x x k ign-nd-mgn. x ( k ) x k One s-compl. x ( k ) x k Two s-compl. x ( k ) x k Excess- x x k ( + ) OTE: The two s complement nd excess- representtions hve n symmetric rnge nd do not hve + nd ; they hve single! n cse the deciml clcultion results in vlue x outside the given rnges we phse n overflow or underflow prolem! The detection of overflow nd underflow is outside the scope of this course! ev. f57fc 3.
ummry ( nd ) ll numer representtions re noted s series of its from M...L: For numer representtion of k-its we cn represent the deciml equivlents like: epresenttion: umer: Deciml rnge: inry x x k ign-nd-mgn. x ( k ) x k One s-compl. x ( k ) x k Two s-compl. x ( k ) x k Excess- x x k ( + ) To convert positive (negtive) integer into negtive (positive) one we hve to complement the representtion s: epresenttion: Complement: ign-nd-mgn. nvert sign it One s-compl. nvert ll its Two s-compl. nvert ll its nd dd Excess- lookup in tle ev. f57fc 3. Multipliction ememer: The clssic deciml pen nd pper multipliction: inry multipliction: l l 4 8 3 6 4 4 3 x + + x inry multipliction is performed similr, ut much simpler! s: = nd = (ote: This represent n D gte!) ev. f57fc 3.3 Multipliction 3 3 Hlf dder Hlf dder Hlf dder O = x Overflow O 3 O O O ev. f57fc 3.4
D D D D Division ememer: The clssic deciml pen nd pper division: inry division: l 8 4 4 3 8 3 8 5 4 8 3 6 8 8 8 eminder eminder inry division is performed identicl, ut simpler! s for ech resulting digit we only hve to sustrct once! ev. f57fc 3.5 Division O O O 3 O = % O D = / O 3 O O O 3 O 3 How cn we represent the numer when eminder, e.g. 3 =? ev. f57fc 3.6 Fixed Point representtion () The set on el numers contins ll integers nd ll frctions m n el numers re normlly noted in the deciml system y plcing deciml point: 3.535 We cll this nottion the fixed point representtion of rel numer. ecll: Plce-nd-vlue nottion 3 3. +. +. + 5. + 3. + 5. 3. 5 3 5 3 + + + 5 + 3 + 5 i i Therefore: = d p p ecomes = d p p p= p=j We cn do the sme for ll plce-nd-vlue notted numers of ny se! ev. f57fc 3.7
Floting Point representtion () Wht out very ig nd very smll numers? ig numer like 845949496795.853 we normlly write s.8459 5 or.8459 E5 nd smll numers line. we similrly write s.7545 5 or.7545 E 5 We cll this the floting point representtion, where numer is represented y mntiss nd exponent. The mntiss is in fixed-point representtion, whilst the exponent is in plce-nd-vlue representtion: =.7545 5 mntiss =.7545 where: < mntiss < exponent = 5 where: < exponent < ev. f57fc 3.8 Floting Point representtion () We cn lso represent floting point numers using set of its (EEE 754 stndrd) This is for exmple used in every computer to represent the types flot, doule, etc. For flot often single precision floting point representtion is used: ign it Exponent Excess7. +.577965 x + < Mntiss < Fixed Point ev. f57fc 3.9