版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、09.10.2020,数字逻辑设计及应用,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、9 weight:10i radix:10 power:i,start from the left of the decimal p
2、oint, increase 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 fraction dp-1dp-2d1d0.d-1d-2d-n General expression:,2. Binary numbers radix:2 digits:0、1,also
3、 be called bit, weight:2i,数字逻辑设计及应用,4,A binary number 1011010.1012,:,an arbitrary binary number B bp-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
4、Bit MSB: Most Significant 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 binar
5、y-hexadecimal relations,数字逻辑设计及应用,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 lef
6、t of the MSB; so do the right。 Exp:do the following positional-number-system conversion 。 1111011010.00112=( ? )8=( ? )h Solution: =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=
7、( ?)2 96CA.28h=( ?)2,数字逻辑设计及应用,11,2.3 general positional-number-system conversions,Radix-r-to-decimal conversion: Each radix-r numbers digit multiply by its own weight, and add them . Exp:512.46=( ?)d 1、decimal-to-radix-r conversioninteger part methods:除基取余 The integer of a p digits number in radix
8、r is: Divide 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.,数字逻辑设计及应用,12,Exp: 371d =(?)2=(?)8=(?)h 2、 decimal-to-radix-r conversionfraction part methods:乘基取整 The fraction of a p digits number in radix r is : Mul
9、tiply 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.,数字逻辑设计及应用,13,Exp8: 0.71875d=( ? )2=( ? )8=( ? )h 3、summary of the positional-number-system conversions (1) conversion between dec
10、imal 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 number,数字逻辑设计及应用,14,2.4 addition and subtraction of nondecimal number,1、Rules of bin
11、ary addition and subtraction (1)rules of addition S=x+y+Cin Exp:01001011+10001111=?,initial carry,carry,数字逻辑设计及应用,15,(2)Rules of Binary Subtraction,d=x-y-bin Exp: 11000=?,initial borrow,borrow,数字逻辑设计及应用,16,2. addition and subtraction of octal and hexadecimal,addition: If two digits sum is greater th
12、an 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.,数字逻辑设计及应用,17,2.5 Representation of Negative Numbers,1、signed-magnitude representation unsigned numbers:just the magnitude
13、 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、,数字逻辑设计及应用,18,in binary number, sign bit+magnitude The MSB of a bit string is used as the
14、 sign bit:0“+”,1“-” this type of signed binary number is called Signed Magnitude (S-M码,或原码)。 比如,+11101=011101 -1011=11011,数字逻辑设计及应用,19, The range of S-Ms representable numbers. an n-bit S-M number B: bn-1bn-2b1b0 Its range is: -(2n-1-1) +(2n-1-1) Include two zero: -0 and +0 Exp:find the S-M of the f
15、ollowing signed numbers。How to represent by using 8-bit S-M. +11101, -1011,+18,-18 the fault of S-M which is used in arithmetical operation:it cant be calculated directly.,符号位,数字逻辑设计及应用,20,2、Complement Number System,radix complement (基数补码数制) diminished radix-complement (基数减1补码数制) An n-digit number D
16、 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.,数字逻辑设计及应用,21,3. Twos-complement Representation,Twos complement is a method for representing signed integers as binary numbers. n-bit
17、binary number B=bn-1b1b0,the twos complement is: B 2s =2n-B for Exp., 8-bit binary number twos complement 0000000028-0=00000000 0000000128-1=11111111 0000001028-10=11111110 1111111100000001,数字逻辑设计及应用,22,Define these twos complement as signed number, the MSB is served as sign bit。 MSB=0,positive numb
18、er MSB=1,negative number weight of the sign bit: MSB=0,weight +2n-1 MSB=1,weignt - 2n-1 Range of the value:positive 0+(2n-1-1); negative (-2n-1)-1。 Only one zero in twos complement.,数字逻辑设计及应用,23,twos complement number and their decimal equivalent,数字逻辑设计及应用,24,数字逻辑设计及应用,25,property,sign bit =0, S-M a
19、nd 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?,数字逻辑设计及应用,26,Same value, but has opposite sign symbol,数字逻辑设计及应用,27,So, to calculate the 2s complement of an
20、 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 10111111,数字逻辑
21、设计及应用,28,An n-bit binary number B=bn-1b1b0,the ones-complement is : B 1s =2n-1-B It 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)-0 positive +0(2n-1-1),4. Ones-complement
22、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 integer number is obtained by complementing each one of the bits (the n-bit binary number), i.e., a 1 is replaced by
23、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. are successive increased by 1.,Summary of S-M, 2s comp. , 1s comp.,数字逻辑设计及应用,31,All of these th
24、ree 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.,数字逻辑设计及应用,32,Calculate signed integers S-M, 2s-comp. , 1s-comp.,positive
25、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-b
26、it 1s-complement of the given number Exp13: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 an m-bit one: (a)if m n,append (m-n) copies of Xs sign bit to the left of X;
27、 (b)if m n,discard Xs( n-m )leftmost bit。 So do to 1s-complement.,数字逻辑设计及应用,34,2.6 Twos-complement Addition and Subtraction,1、Rules Two operands add or subtract directly 。 Exp: 3+3,4+(-5),7-3,1-6,,符号数表格,数字逻辑设计及应用,35,2. A graphical view,Modular: the biggest number of quantities that a n-bit system ca
28、n 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-1),or -(2n-1),overflow is occurred. Detecting of ov
29、erflow: 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 subtrahend by taking its 2s complement, and the
30、n 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-complement. If the result of addition oper
31、ation 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-3 code: a set of n-bit in which different bit strings represent different numbers of other things is called a code. code word: a part
32、icular 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 left to right is:23、22、21、20。a
33、lso called 8421BCD。 (1)representing numbers by BCD like,11d, BCD00010001 256d, BCD 0010 0101 0110 (2) Packed BCD two-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,sum1001,then add 0110 to the result。 Exp.:,数字逻辑设计及应用,43,2. Other decimal codes,P.49 table2-9, Excess-3 code:the code wor
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026一季度浙商银行广州分行社会招聘笔试历年典型考题及考点剖析附带答案详解
- 2025黑龙江佳木斯市同江市市属国有企业招聘16人笔试历年常考点试题专练附带答案详解
- 2025陕西西咸新区水务集团有限公司招聘23人笔试历年备考题库附带答案详解2套
- 2025陕西建工第四建设集团有限公司招聘122人笔试历年备考题库附带答案详解
- 2025重庆气体压缩机厂有限责任公司招聘14人笔试历年备考题库附带答案详解
- 2027年开封文创职业学院高职单招职业技能考试题库附参考答案详解【黄金题型】
- 2024年渭南职业技术学院高职单招职业适应性测试考试题库附完整答案详解(名师系列)
- 2024年中原科技学院许昌校区单招综合素质考试模拟试卷(历年真题)附答案详解
- 2026年西安航空职业技术学院高职单招职业技能考试模拟试卷(考试直接用)附答案详解
- 2026年德州工程职业学院高职单招职业技能考试题库【综合卷】附答案详解
- 滚针美容治疗技术解析
- 儿童自闭症康复中心项目商业计划书
- 莱州市月季产业发展规划(2018-2022年)
- 2025黑龙江七台河辰能生物质发电有限公司招聘笔试参考题库附带答案详解
- 中世纪欧洲大学的兴起与发展
- 《毛泽东思想和中国特色社会主义理论体系概论》附有答案
- 兰州市文职辅警招聘考试真题
- 田英章毛笔楷书2500字(简体版)
- 柴油机发电作业岗位职业危害告知卡
- 胰腺癌的影像诊断与鉴别诊断
- GCP培训教学讲解课件
评论
0/150
提交评论