资源预览内容
第1页 / 共46页
第2页 / 共46页
第3页 / 共46页
第4页 / 共46页
第5页 / 共46页
第6页 / 共46页
第7页 / 共46页
第8页 / 共46页
第9页 / 共46页
第10页 / 共46页
亲,该文档总共46页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
1,Digital Logic Design and ApplicationLecture #4,Chap. 2 Number systems and Codes,UESTC, Spring 2013,Introduction,所有信息都可以用有限位的二进制数字表示,因此数字系统可以处理任何信息。 如何用二进制数字量来表示、运算信息 模拟量有正、负之分 模拟量有整、零之别 除了二进制还有其他表示方法吗 不能或不便抽象为两值子集的信息如何处理?,2,学习要求,掌握:十进制、二进制、八进制和十六进制数的表示方法以及它们之间的相互转换、二进制数的运算;符号数的表达:符号-数值码(Signed-Magnitude System、原码),二进制补码(twos complement,补码)、二进制反码(ones complement, 反码)表示以及它们之间的相互转换;符号数的运算;溢出的概念。 掌握:其他信息的编码表达:BCD码(Binary Codes for Decimal numbers)、n中取1码(独热码)、格雷码(Gray code)的特点及其与二进制数之间的转换关系; 了解:模拟信息的数字表达:A/D转换的基本概念; 了解:字符的代码表示,二进制代码在状态、条件等的表示方面的应用;,3,2.1 Positional Number system,用进位的方法进行计数的数制称为进位计数制(或按位计数制 Positional Number system)。,4,Digit,Radix,Number,Weighted sum of the digits.,Weight,2.1 Positional Number system,5,数制的三要素为: 数码(digit):0r-1,进位规律:逢r进一,借一当r。 基数(base/radix):数码的进制数r,也称为基数(底数)。 位权(weight):ri,数码在一个数中的位置不同,其大小就不同。i是数码所在的位置,称为数位。,2.1 Positional Number system,Decimal(十进制) Digit:0 9,逢10进1,借1当10 Weight:(10) 10 i Radix: 10,2.1 Positional Number system,Binary (二进制 ) Digit :0 1,逢2进1,借一当2 Weight: (2) 10 i Radix: 2,二进制的优点:运算简单,电路简单,工作可靠。数字电路中多使用二进制. 二进制的不足:一个较大的十进制用二进制表示需要较多的位,为了克服二进制书写太长的缺点,常用八进制和十六进制。,2.1 Positional Number system,Octal(八进制) Digit:0 7,逢8进1,借1当8 Weight: (8) 10 i Radix:8,Hexadecimal(十六进制) Digit:0 9 AF(1015),逢16进1,借1当16 Weight:(16) 10 i Radix:16,2.2 Octal B:Binary; O: Octal; H: Hexadecimal,2.2 Octal 为了保证原码加减法的正确才需要负数的补码表达形式;正数的原/反/补码相同. 从正数A计算-A的补码有两种等效方法: -A的补码=2n-A=A的原码按位取反(带符号位)+1。 从负数-A计算-(-A)的补码有两种等效方法: -(-A)的补码= 2n-(-A)补=(-A)的补码按位取反+1。 正数的补码MSB为0 ,负数的补码MSB为1. N位二进制原码/反码/补码均可以表示2n个数。 二进制原码和反码中零有两种表达形式,补码中零只有一种表达方式,即+0。 N位二进制补码可以表示-2n-1,原码/反码中没有。 二进制原/反/补码均有顺序递增/减的规律。,40,41,4-bit twos-complement numbers,42,2.6 Twos-Complement Addition and Subtraction,Addition Rules: By ordinary binary addition, ignoring any carries beyond the MSB; No different cases based on operands signs! 按照无符号数的加法规则相加,符号位参加运算。,3 1 1 0 1 + 5 + 1 0 1 1 8 1 1 0 0 0,+7 0 1 1 1 + 4 + 1 1 0 0 +3 1 0 0 1 1,+2 0 0 1 0 + +5 + 0 1 0 1 +7 0 1 1 1,7 3 10,5 6 11,1 0 1 1 + 1 0 1 0 1 0 1 0 1, 5,0 1 1 1 0 0 1 1 1 0 1 0, 6,43,2.6 Twos-Complement Addition and subtraction,Overflow(溢出) Occurs if result is out of range Addends with different sign will not produce an overflow. 异号数相加不会产生溢出. if the addends signs are the same but the sums sign is different from the addends.同号数相加,结果为异号则溢出。 If the carries into and out of the sign position are different. 符号位的 cin cout,44,2.6 Twos-Complement Addition and Subtraction,Subtraction Rules: Taking subtrahends 2s-complement, then add it to minuend Negating the subtrahend, adding the minuend with Cin=1,+4 +3,0100 0011,1 0100 + 1100,1 0001,cin ,1 0010 + 0010,0101,cin ,Overflow in subtraction can be detected using the same rule as in addition.,45,第2章作业(P7476),2.1 (e) (i)(j) 2.2 (a) (e) 2.3 (b) (e) 2.5 (e) (j) 2.6 (b) (f) 2.7 2.8 (a) 2.9 (b) 2.10 (c),2.11 ( +18 , 49) 2.12 (b) (c) 2.19(思考) 2.26 (思考) 2.33 2.34 补充习题,Backups,46,
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号