数字设计课件第二章

上传人:无*** 文档编号:202603707 上传时间:2023-04-22 格式:PPT 页数:47 大小:440KB
返回 下载 相关 举报
数字设计课件第二章_第1页
第1页 / 共47页
数字设计课件第二章_第2页
第2页 / 共47页
数字设计课件第二章_第3页
第3页 / 共47页
点击查看更多>>
资源描述
Chapter2 Number Chapter2 Number Systems and CodeSystems and Code重点重点:1)二进制、八进制和十六进制数的表达及)二进制、八进制和十六进制数的表达及各种数制之间的相互转换;各种数制之间的相互转换;2)符号数的表达及其加、减运算;)符号数的表达及其加、减运算;3)BCD编码和编码和GRAY码。码。4/22/20234/22/20231 1 Positional Number Systems1.Decimal number d digits:0、1、2、3、4、5、6、7、8、9weight:10iradix:10power:i,start from the left of the decimal point,increase by one for each successive position from 0;from the right of the decimal point,decrease by one from(-1).powerweightdigitradix2 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,weight:2i3A2,:,: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.43.Others LSB:Least Significant Bit MSB:Most Significant Bit b bp-1p-1b bp-2p-2bb1 1b b0 0.b.b-1-1bb-n-nMSBLSB52.2 Octal and Hexadecimal NumbersOctalHexadecimalradix816weight8i16idigits0、1、2、3、4、5、6、70、1、2、3、4、5、6、7、8、9、A、B、C、D、E、FGeneralexpression6Exp3:give the decimal value of the following numbers.8=h=2.2-8 and 2-16 numbers Convensions octal01234567binary section000001010011100101110111Table 1 relation between binary and octal 7hexadecimalbinary section0000010001200103001140100501016011070111hexadecimalbinary section8100091001A1010B1011C1100D1101E1110F1111Table 2 binary-hexadecimal relations8(a)binaryoctal、hexadecimal conversionslStarting at the binary point,separate the bits into groups of 3 or 4,and replace each group with the corresponding octal or hexadecimal digit.lIf 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:do the following positional-number-system conversion。2=(?)8=(?)hSolution:8h9(b)octal,hexadecimal-binary number conversionReplace each octal or hexadecimal with the corresponding group of 3 or 4bits.Exp:267.248=(?)?)2 96CA.28h=(?)?)2102.3 general positional-number-system conversionslRadix-r-to-decimal conversion:Each radix-r numbers digit multiply by its own weight,and add them.Exp:6=(?)?)d1、decimal-to-radix-r conversioninteger partmethods:除基取余:除基取余The integer of a p digits number in radix r is:uDivide the formula by r successively,yield the successive digits of the integer of D(radix r)from the right to left till the quotient is 0.11Exp:371d=(?)2=(?)8=(?)h2、decimal-to-radix-r conversionfraction partmethods:乘基取整:乘基取整The fraction of a p digits number in radix r is:uMultiply the formula by r successively,yield the successive digits of the fraction of D(radix r)from the left to right till the required digits d-1,d-2,d-n are acquired.12Exp8:d=(?)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,binary-to-hexadecimal or reverse,be converted directly conforming to the section-replace rules.others,radix-r numberdecimal radix-j number13 addition and subtraction of nondecimal number1、Rules of binary addition and subtraction(1)rules of additionS=x+y+CinExp:01001011+10001111=?CinxyCoutS0000000101010010111010001101101101011111initial carrycarry000011110c c14(2)Rules of Binary Subtractiond=x-y-binExp:11001100-01011100=?bi nxyboutd0000000111010010110010011101101100011111initial borrowborrow011100000b b152.addition and subtraction of octal and hexadecimaladdition:If two digits sum is greater than the radix on each column,then carry 1 to the next more significant bit.subtraction:If the minuend is less than subtrahend,then borrow 1 from the next more significant bit.16 Representation of Negative Numbers1、signed-magnitude representation unsigned numbers:just the magnitude of a number is represented,no+or-sign symbol before the number。signed numbers:+or-is added to the left of the number。representation of signed number:sign symbol+number magnitude,like+34d、-1102、+1Dh、17in 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=011101 -1011=1101118 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 arithmetical operation:it cant be calculated directly.符号符号位位数值数值192、Complement Number Systemradix 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)shows some rs and(r-1)s complement.203.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=111111110000001028-10=11111110111111110000000121Define 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 one zero in twos complement.22twos complement number and their decimal equivalent2s complementdecimal00000000000000001+101111111+12710000000-12810000001-12711111110-211111111-1232s-complementdecimal equivalentS-M000000000000000001000000000000001+100000001.01111111+1270111111110000000-128-10000001-1271111111111111110-21000001011111111-11000000124propertysign 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 representation of a negative decimal number?25Decimal equivalent4-bits 2s complement-81000-71001-61010-51011-41100-31101-21110-11111Its original binary numberDecimal equivalent1000801117011060101501004001130010200011互互为为补补数数Same value,but has opposite sign symbolSame value,but has opposite sign symbol26So,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(-65d)in 8-bit form.Solution:+65 01000001-65 binary equivalent of 65 is 01000001,invert bit by bit 10111110 add 1 1011111127An 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,negative,weight-(2n-1-1)。Range of representable numbers:negative -(2n-1-1)-0positive+0(2n-1-1)4.Ones-complement Representation281s-complements propertyN-bit positive integers are represented in the same way as n-bit sign-magnitude notation.The ones-complement of an n-bit negative integer 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=1110110129decimalS-M2s comp.1s comp.-1100111111110-2101011101101-3101111011100-4110011001011-5110110111010-6111010101001-7111110011000-8-1000-decimalS-M2s comp.1s comp.7011101110111601100110011050101010101014010001000100300110011001120010001000101000100010001000001000000011110000返回返回From the least number to biggest number,2s comp.and From the least number to biggest number,2s comp.and 1s comp.are successive increased by 1.1s comp.are successive increased by 1.Summary of S-M,2s comp.,1s comp.30All 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 different at all.S-M2s comp.1s comp.positive+0(2n-1-1)+0(2n-1-1)+0(2n-1-1)negative-(2n-1-1)-0(-2n-1)-1-(2n-1-1)-031Calculate 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 equivalent 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,-1101325.Sign extension When we convert an n-bit 2s complement number X into an m-bit one:(a)if m n,append(m-n)copies of Xs sign bit to the left of X;(b)if m+(2n-1-1),or 1001,then add 0110 to the result。Exp.:1001make a correction422.Other decimal codesP.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 from left to right。self-complement43 Gray code 3-bit mechanical encoding diskstraightforward binary encoding(natural binary codes)two successive values differ in only one bit00000101001110010111011100000101101011011110110044Constructing an n-bit gray code1-bit gray code:0,1The first 2n code 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.45Exp:reflected binary codeDecimal numbernaturalBinary code2-bit Gray code3-bit Gray code000/00000000101/00101001210/01011011311/01110010410011051011116110101711110046translating a binary value into the corresponding Gray codeBinary 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 147
展开阅读全文
相关资源
相关搜索

最新文档


当前位置:首页 > 压缩资料 > 基础医学


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!