数字设计课件第二章.ppt

上传人:小飞机 文档编号:5984830 上传时间:2023-09-11 格式:PPT 页数:47 大小:441.50KB
返回 下载 相关 举报
数字设计课件第二章.ppt_第1页
第1页 / 共47页
数字设计课件第二章.ppt_第2页
第2页 / 共47页
数字设计课件第二章.ppt_第3页
第3页 / 共47页
数字设计课件第二章.ppt_第4页
第4页 / 共47页
数字设计课件第二章.ppt_第5页
第5页 / 共47页
点击查看更多>>
资源描述

《数字设计课件第二章.ppt》由会员分享,可在线阅读,更多相关《数字设计课件第二章.ppt(47页珍藏版)》请在三一办公上搜索。

1、2023/9/11,数字逻辑设计及应用,1,Chapter2 Number Systems and Code,重点:1)二进制、八进制和十六进制数的表达及各种数制之间的相互转换;2)符号数的表达及其加、减运算;3)BCD编码和GRAY码。,数字逻辑设计及应用,2,2.1 Positional Number Systems,1.Decimal number A decimal number 1536.79d digits:0、1、2、3、4、5、6、7、8、9weight:10iradix:10power:i,start from the left of the decimal point,in

2、crease by one for each successive position from 0;from the right of the decimal point,decrease by one from(-1).,数字逻辑设计及应用,3,An arbitrary decimal number D with p digits in integer and n digits in fractiondp-1dp-2d1d0.d-1d-2d-nGeneral expression:,2.Binary numbersradix:2digits:0、1,also be called bit,we

3、ight:2i,数字逻辑设计及应用,4,A binary number 1011010.1012,:,an arbitrary binary number Bbp-1bp-2b1b0.b-1b-n,the general expressions:The sum of each digit multiplied by the corresponding power of the radix is the binary numbers decimal value.,数字逻辑设计及应用,5,3.Others LSB:Least Significant Bit MSB:Most Significant

4、 Bit bp-1bp-2b1b0.b-1b-n,MSB,LSB,数字逻辑设计及应用,6,2.2 Octal and Hexadecimal Numbers,1.concept,数字逻辑设计及应用,7,Exp3:give the decimal value of the following numbers.215.78=3AD.8h=2.2-8 and 2-16 numbers Convensions,Table 1 relation between binary and octal,数字逻辑设计及应用,8,Table 2 binary-hexadecimal relations,数字逻辑设计

5、及应用,9,(a)binaryoctal、hexadecimal conversions,Starting at the binary point,separate the bits into groups of 3 or 4,and replace each group with the corresponding octal or hexadecimal digit.If the leftmost group fall short of 3 or 4 bits,then 0 should be added to the left of the MSB;so do the right。Exp

6、:do the following positional-number-system conversion。1111011010.00112=(?)8=(?)hSolution:=1732.148=3DA.3h,数字逻辑设计及应用,10,(b)octal,hexadecimal-binary number conversion,Replace each octal or hexadecimal with the corresponding group of 3 or 4bits.Exp:267.248=(?)2 96CA.28h=(?)2,数字逻辑设计及应用,11,2.3 general po

7、sitional-number-system conversions,Radix-r-to-decimal conversion:Each radix-r numbers digit multiply by its own weight,and add them.Exp:512.46=(?)d1、decimal-to-radix-r conversioninteger partmethods:除基取余The integer of a p digits number in radix r is:Divide the formula by r successively,yield the succ

8、essive digits of the integer of D(radix r)from the right to left till the quotient is 0.,数字逻辑设计及应用,12,Exp:371d=(?)2=(?)8=(?)h2、decimal-to-radix-r conversionfraction partmethods:乘基取整The fraction of a p digits number in radix r is:Multiply the formula by r successively,yield the successive digits of t

9、he fraction of D(radix r)from the left to right till the required digits d-1,d-2,d-n are acquired.,数字逻辑设计及应用,13,Exp8:0.71875d=(?)2=(?)8=(?)h3、summary of the positional-number-system conversions(1)conversion between decimal and radix r(2)radix-r-to-radix-j conversion(non-decimal)binary-to-octal,binar

10、y-to-hexadecimal or reverse,be converted directly conforming to the section-replace rules.others,radix-r numberdecimal radix-j number,数字逻辑设计及应用,14,2.4 addition and subtraction of nondecimal number,1、Rules of binary addition and subtraction(1)rules of additionS=x+y+CinExp:01001011+10001111=?,initial

11、carry,carry,数字逻辑设计及应用,15,(2)Rules of Binary Subtraction,d=x-y-binExp:11001100-01011100=?,initial borrow,borrow,数字逻辑设计及应用,16,2.addition and subtraction of octal and hexadecimal,addition:If two digits sum is greater than the radix on each column,then carry 1 to the next more significant bit.subtractio

12、n:If the minuend is less than subtrahend,then borrow 1 from the next more significant bit.,数字逻辑设计及应用,17,2.5 Representation of Negative Numbers,1、signed-magnitude representation unsigned numbers:just the magnitude of a number is represented,no+or-sign symbol before the number。signed numbers:+or-is ad

13、ded to the left of the number。representation of signed number:sign symbol+number magnitude,like+34d、-1102、+1Dh、,数字逻辑设计及应用,18,in binary number,sign bit+magnitudeThe MSB of a bit string is used as the sign bit:0“+”,1“-”this type of signed binary number is called Signed Magnitude(S-M码,或原码)。比如,+11101=01

14、1101-1011=11011,数字逻辑设计及应用,19,The range of S-Ms representable numbers.an n-bit S-M number B:bn-1bn-2b1b0Its range is:-(2n-1-1)+(2n-1-1)Include two zero:-0 and+0Exp:find the S-M of the following signed numbers。How to represent by using 8-bit S-M.+11101,-1011,+18,-18the fault of S-M which is used in ar

15、ithmetical operation:it cant be calculated directly.,符号位,数字逻辑设计及应用,20,2、Complement Number System,radix complement(基数补码数制)diminished radix-complement(基数减1补码数制)An n-digit number D in radix r:D=dn-1d1d0,radix-complement diminished radix-complement(也称基数反码)Relation between these two:Table 2-4,2-5(P.36)sh

16、ows some rs and(r-1)s complement.,数字逻辑设计及应用,21,3.Twos-complement Representation,Twos complement is a method for representing signed integers as binary numbers.n-bit binary number B=bn-1b1b0,the twos complement is:B 2s=2n-B for Exp.,8-bit binary number twos complement0000000028-0=000000000000000128-1

17、=111111110000001028-10=111111101111111100000001,数字逻辑设计及应用,22,Define these twos complement as signed number,the MSB is served as sign bit。MSB=0,positive number MSB=1,negative numberweight of the sign bit:MSB=0,weight+2n-1 MSB=1,weignt-2n-1Range of the value:positive 0+(2n-1-1);negative(-2n-1)-1。Only

18、one zero in twos complement.,数字逻辑设计及应用,23,twos complement number and their decimal equivalent,数字逻辑设计及应用,24,数字逻辑设计及应用,25,property,sign bit=0,S-M and twos-complement have the same decimal value;sign bit=1,S-M and twos-complement have different decimal value。How to find the twos-complement representati

19、on of a negative decimal number?,数字逻辑设计及应用,26,Same value,but has opposite sign symbol,数字逻辑设计及应用,27,So,to calculate the 2s complement of an negative integer,invert the n-bit binary equivalent of the given number magnitude bit by bit,and then add 1 to the LSB.Exp:calculate the 2s complement of(+65)and

20、(-65d)in 8-bit form.Solution:+65 01000001-65 binary equivalent of 65 is 01000001,invert bit by bit 10111110 add 1 10111111,数字逻辑设计及应用,28,An n-bit binary number B=bn-1b1b0,the ones-complement is:B 1s=2n-1-BIt is also the method of representing signed binary numbers.MSB=0,positive,weight+(2n-1-1)MSB=1,

21、negative,weight-(2n-1-1)。Range of representable numbers:negative-(2n-1-1)-0positive+0(2n-1-1),4.Ones-complement Representation,数字逻辑设计及应用,29,1s-complements property,N-bit positive integers are represented in the same way as n-bit sign-magnitude notation.The ones-complement of an n-bit negative intege

22、r number is obtained by complementing each one of the bits(the n-bit binary number),i.e.,a 1 is replaced by a 0,and a 0 is replaced by a 1.Exp.8-bit 1s-complement of the number.+18d=00010010-18d=1s complement of 18=11101101,数字逻辑设计及应用,30,返回,From the least number to biggest number,2s comp.and 1s comp.

23、are successive increased by 1.,Summary of S-M,2s comp.,1s comp.,数字逻辑设计及应用,31,All of these three are used to represent signed integer number in binary system.Comparing of the representing range of the value Representations of positive integer are same;but the representations of negative integer are d

24、ifferent at all.,数字逻辑设计及应用,32,Calculate signed integers S-M,2s-comp.,1s-comp.,positive signed number:convert the given number into the wanted n-bit binary equivalent.negative signed number:first convert the number into n-bit binary equivalent,S-M let MSB=1;1s-complement invert the n-bit binary equiv

25、alent bit by bit,get the n-bit 1s-comp.;2s-complement add 1 to the LSB of the n-bit 1s-complement of the given numberExp13:Finding the S-M,2s-comp,1s-comp of the following signed number in 8-bit。+60,-60,+10010,-1101,数字逻辑设计及应用,33,5.Sign extension,When we convert an n-bit 2s complement number X into a

26、n m-bit one:(a)if m n,append(m-n)copies of Xs sign bit to the left of X;(b)if m n,discard Xs(n-m)leftmost bit。So do to 1s-complement.,数字逻辑设计及应用,34,2.6 Twos-complement Addition and Subtraction,1、RulesTwo operands add or subtract directly。Exp:3+3,4+(-5),7-3,1-6,,符号数表格,数字逻辑设计及应用,35,2.A graphical view,M

27、odular:the biggest number of quantities that a n-bit system can represent is 2n.Modular operation:m MOD 2n=m-i2n(i=int()Exp:18 MOD 16=2,+2,数字逻辑设计及应用,36,3.overflow,If an addition operation produces a result that exceeds the range of the number system,overflow is said to occur.that is,if result+(2n-1-

28、1),or-(2n-1),overflow is occurred.Detecting of overflow:An addition overflows if the addends signs are the same but the sums sign is different from the addends.Exp:judge whether the result of the addition overflow or not。11111101+10000001,数字逻辑设计及应用,37,4.Subtraction rules,m-n=m+(2n-n)Negate the subtr

29、ahend by taking its 2s complement,and then add it to the minuend using the normal rules for addition.,-2,数字逻辑设计及应用,38,Exp:,数字逻辑设计及应用,39,5.Twos-complement and Unsigned Binary Numbers,When n-bit binary numbers are taken for unsigned number,the rules of addition and subtraction are as same as the 2s-co

30、mplement.If the result of addition operation exceed the range of n-bit system,a carry is produced to the left more significant bit.,数字逻辑设计及应用,40,2.10 Binary Codes for Decimal Numbers,Emphasis:BCD,excess-3code:a set of n-bit in which different bit strings represent different numbers of other things i

31、s called a code.code word:a particular combination of n bit-values.1、BCD code the digits 09 are encoded by 4-bit unsigned binary representations,0000 through 1001.and the words 1010 1111 are not used.(invalid code word),数字逻辑设计及应用,41,BCDs property,BCD is weighted code,the weights for the bits from le

32、ft to right is:23、22、21、20。also called 8421BCD。(1)representing numbers by BCDlike,11d,BCD00010001256d,BCD 0010 0101 0110(2)Packed BCDtwo-digits-per-byte,数字逻辑设计及应用,42,(3)Addition with BCD be similar to 4-bit unsigned binary number addition.But a correction must be made if the sum exceeds 1001 if,sum1

33、001,then add 0110 to the result。Exp.:,数字逻辑设计及应用,43,2.Other decimal codes,P.49 table2-9,Excess-3 code:the code word for each decimal digit is the corresponding BCD code word plus 0011.it is a self-complement code.2421 code:weighted code,each bit of the code word has assigned weight with 2,4,2 and 1 f

34、rom left to right。self-complement,数字逻辑设计及应用,44,2.11 Gray code,3-bit mechanical encoding diskstraightforward binary encoding(natural binary codes)two successive values differ in only one bit,000,001,010,011,100,101,110,111,数字逻辑设计及应用,45,Constructing an n-bit gray code,1-bit gray code:0,1The first 2n c

35、ode words of an(n+1)-bit Gray code equal the code words of an n-bit Gray code,written in order with a leading 0 appended.The last 2n code words of an(n+1)-bit Gray code equal the code words of an n-bit Gray code,but written in reverse order with a leading 1 appended.,数字逻辑设计及应用,46,Exp:reflected binary code,数字逻辑设计及应用,47,translating a binary value into the corresponding Gray code,Binary number bn-1bn-2b1b0Gray code gn-1gn-2g1g0Then gn-1=bn-1 bit i of a Gray-code word is 0 if bits i and i+1 of the corresponding binary code word are the same,else bit i is 1.101102=()grey解:B 1 0 1 1 0 G 1 1 1 0 1,

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号