资源描述
单击此处编辑母版标题样式,单击此处编辑母版文本样式,第二级,第三级,第四级,第五级,*,*,有利于学习和创新的组织管理机制,创造充满活力的创新激励机制,以市场为导向,以顾客价值追求为中心的企业文化氛围,依赖既开放又相互信任的合作环境。,Chapter 2 Number Systems and codes(,数系与编码,),Numeric Data,Number Systems and their Conversions,(,数值信息,数制及其转换),Nonnumeric Data,Codes,(,非数值信息,编码),Digital Logic Design and Application,(,数字逻辑设计及应用,),1,Review of Chapter 2(,第二章内容回顾,),Binary,Octal,and Hexadecimal Numbers(,二进制、八进制、十六进制,),Positional Number System,(,按位计数制,),Digital Logic Design and Application(,数字逻辑设计及应用,),2,Review of Chapter 2(,第二章内容回顾,),General Positional-Number-System Conversion,(,常用按位计数制的转换,),A Number in any Radix to Radix 10:Expanding the formula using radix-10 arithmetic,(,任意进制数,十进制数:利用位权展开,),Digital Logic Design and Application(,数字逻辑设计及应用,),3,Review of Chapter 2(,第二章内容回顾,),General Positional-Number-System Conversion,(,常用按位计数制的转换,),A Number in Radix 10 to any Radix:Radix Multiplication or Division,(,十进制,其它进制:基数乘除法,),Note:Decimal Fraction Parts Conversion,注意:小数部分的转换(误差),Digital Logic Design and Application(,数字逻辑设计及应用,),4,Review of Chapter 2(,第二章内容回顾,),Addition and Subtraction of Nondecimal Numbers,(,非十进制的加法和减法,),(,Table 2-3),进位输入,Cin,、进位输出,Cout,、本位和,S,借位输入,B,in,、借位输出,B,out,、本位差,D,Digital Logic Design and Application(,数字逻辑设计及应用,),5,Review of Chapter 2(,第二章内容回顾,),Representation of Negative Numbers,(,负数的表示,),Signed-Magnitude,符号数值(原码),Complement Number Systems(,补码数制,),Radix Complement(,基数补码,),Diminished Radix Complement,基数减1补码(基数反码),Digital Logic Design and Application(,数字逻辑设计及应用,),6,Review of Chapter 2(,第二章内容回顾,),Binary Signed-Magnitude,Ones Complement,and Twos Complement Representation,(,二进制的原码、反码、补码,),正数的原码、反码、补码表示相同,负数的原码表示:符号位为,1,负数的反码表示:,符号位不变,其余在原码基础上按位取反,在,|,D,|,的原码基础上按位取反(包括符号位),负数的补码表示:反码,+1,Digital Logic Design and Application(,数字逻辑设计及应用,),7,2.5.4 Twos Complement Representation(,二进制补码表示法,),An n-bit,Twos-Complement,range is,(n,位二进制补码表示范围,),:,2,n-1,+(2,n-1,1),Only one representations of Zero,(,零只有一种表示,),Obtain a Twos-Complement,(,二进制补码的求取,),:,Ones Complement(,反码,)+1,(为什么?),Expanding the Sign Bit(,符号位扩展,),Digital Logic Design and Application(,数字逻辑设计及应用,),8,2.5 Representation of Negative Numbers(,负数的表示,),Example 2.5.2,:,Write the 8-bit signed-magnitude,twos-complement for each of these binary numbers.,(,分别写出下面二进制数的,8,位符号,数值码、补码,),(1101)2,(0.1101)2,Digital Logic Design and Application(,数字逻辑设计及应用,),9,2.5 Representation of Negative Numbers(,负数的表示,),Digital Logic Design and Application(,数字逻辑设计及应用,),1,、,(,1101),2,2,、,(,0.1101),2,1,、,5,位二进制表示:,原码 反码 补码,1,1101,1,0010,1,0011,2,、,8,位二进制表示:,原码 反码 补码,1,000,1101,1,111,0010,1,111,0011,D,反,反,=,D,D,补,补,=,D,10,2.6,Twos Complement Addition and Subtraction(,二进制补码的加法和减法,),Addition Rules:Added by ordinary binary addition(,加法:按普通二进制加法相加,)P.39,Subtraction Rules:Taking its twos complement,then add,(,减法:将减数求补,再相加,),Digital Logic Design and Application(,数字逻辑设计及应用,),11,2.6,Twos Complement Addition and Subtraction(,二进制补码的加法和减法,),Digital Logic Design and Application(,数字逻辑设计及应用,),2 0010,3 1101,5,0101,5,1011,7 0111,8 11000,7 0111,1 0001,4,1100,6,1010,3 10011,5 1011,12,13,Adder/Subtractor Example:Calculator,Previous calculator used separate adder and subtractor,DIP swi,t,ches,1,0,8-bit,r,e,g,is,t,er,C,A,L,C,LEDs,e,f,clk,ld,8,8,8,0,0,8,8,8,8,8,2,x,1,0,1,1,0,wi,ci,A,A,B,B,S,S,c,o,w,o,8-bit adder,8-bit subt,r,a,c,t,or,13,14,Adder/Subtractor Example:Calculator,Improve by using adder/subtractor,and twos complement numbers,DIP switches,1,0,8-bit register,8-bit adder/subtractor,sub,C,A,L,C,LEDs,e,S,A,B,f,clk,ld,1,0,8,8,8,8,14,2.6,Twos Complement Addition and Subtraction(,二进制补码的加法和减法,),Overflow,(溢出),如果加法运算产生的和超出了数制表示的范围,则结果发生了溢出(,Overflow,)。,对于二进制补码,加数的符号相同,和的符号与加数的符号不同。(或者,,C,in,与,C,out,不同),P.41,对于无符号二进制数,若最高有效位上发生进位或借位,就指示结果超出范围。,5 1011,7 0111,6,1010,3,0011,11 10101,5,10 1010,6,Digital Logic Design and Application(,数字逻辑设计及应用,),15,16,Overflow,Sometimes result cant be represented with given number of bits,Either too large magnitude of positive or negative,Ex.4-bit twos complement addition of 0111+0001(7+1=8).But 4-bit twos complement cant represent number 7,0111+0001=1000 WRONG answer,1000 in twos complement is-8,not+8,Adder/subtractor should indicate when overflow has occurred,so result can be discarded,16,17,Detecting Overflow:Method 1,For twos complement numbers,overflow occurs when the two numbers sign bits are the same but differ from the results sign bit,If the two numbers sign bits are initially different,overflow is impossible,Adding positive and negative cant exceed largest magnitude positive or negative,0,1,1,1,1,0,0,0,+,0,0,0,1,sign bits,overflow,(,a,),1,1,1,1,0,1,1,1,+,0,1,0,0,overflow,(,b,),1,0,0,0,1,1,1,1,+,1,0,1,1,no overflow,(,c,),If the numbers sign bits have the same value,which,differs from the results sign bit,overflow has occurred.,17,18,Detecting Overflow:Method 2,Even simpler method:Detect difference between carry-in to sign bit and carry-out from sign bit,0,1,1,1,1,1,1,1,0,0,1,0,0,0,+,0,0,0,1,overflow,(,a,),1,1,1,0,0,0,1,0,1,1,1,+,0,1,0,0,overflow,(,b,),1,0,0,0,0,0,0,1,1,1,1,+,1,0,1,1,no over
展开阅读全文