资源预览内容
第1页 / 共38页
第2页 / 共38页
第3页 / 共38页
第4页 / 共38页
第5页 / 共38页
第6页 / 共38页
第7页 / 共38页
第8页 / 共38页
第9页 / 共38页
第10页 / 共38页
亲,该文档总共38页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
计算机组成原理Principles of Computer Organization广义双语教学课程http:/211.64.192.109/skyclass25/青岛理工大学 校级精品课程http:/jx.qtech.edu.cn/ec/C84/1第3章 运算方法和运算部件( 5 )Floating-point computation in a computer can run into three kinds of problems: An operation can be mathematically illegal, such as division by zero. An operation can be legal in principle, but not supported by the specific format, for example, calculating the square root of 1 or the inverse sine of 2 (both of which result in complex numbers). An operation can be legal in principle, but the result can be impossible to represent in the specified format, because the exponent is too large or too small to encode in the exponent field. Such an event is called an overflow (exponent too large) or underflow (exponent too small). 23.5 浮点数的运算方法Floating-Point Arithmetic浮点加减法运算浮点乘法运算Floating-Point MultiplicationFloating-Point Addition R is the output; F is the instruction from the Control Unit; D is an output status. In computing, an arithmetic logic unit (ALU) is a digital circuit that performs arithmetic and logical operations.Mathematician John von Neumann proposed the ALU concept in 1945, when he wrote a report on the foundations for a new computer called the EDVAC.Von Neumann stated that an ALU is a necessity for a computer because it is guaranteed that a computer will have to compute basic mathematical operations, including addition, subtraction, multiplication, and division.ALU26计算机中的所有算术运算(、)都可用加法和移 位来完成,所以ALU中的最主要的部件是加法器。ALU也是计算机中传送数据的一条重要途径。通用寄存器组用来暂存参与运算的数据和某些中间运算结果。The inputs to the ALU are the data to be operated on (called operands) and a code from the control unit indicating which operation to perform. Its output is the result of the computation.In many designs the ALU also takes or generates as inputs or outputs a set of condition codes from or to a status register. These codes are used to indicate cases such as carry-in or carry-out, overflow, divide-by-zero, etc.ALU27状态标志位用来记录算术/逻辑运算或测试操作的结果状态。这 些状态通常用作程序条件转移指令的判断条件,所以又称为“程序 状态字”(PSW),“条件码寄存器”(Condition Codes)等。常用的状态标志(Flag)有: 进位标志Cy(加法运算结果最高位产生进位或减法运算结果 最高位有借位时,Cy置1) 零标志Z(运算结果为0时,Z置1) 符号标志S(算术运算结果的最高位为1即认为是负值,S置1) 溢出标志V(算术运算结果发生溢出时,V置1) 奇偶标志P(逻辑运算结果有偶数个1时,P置1)28输入数据选择电路用来选择把哪一个或哪两个数据送入 ALU,以及决定送入的数据是以补码或是以反码的形式。输出数据控制电路一般有移位功能,并具有把加法器输出的 数据传送到通用寄存器的通路和通往总线的控制电路。多路开关多路开关ALU移位电路 多路开关控制信号功能控制控制信号斜传电路如果ALU与各寄存器之间有直接数据通路29如果,ALU与各寄存器之间采用总线结构内部单数据总线结构的运算器暂存器ALU内部总线功能控制移位电路30缓冲器通用寄存器组ALU移位电路总 线 1总 线 2内部双数据总线结构的运算器ALU与各寄存器之间采用总线结构31总线 旁路器通用寄存器组ALU移位电路总线1总线2总线3内部三数据总线结构的运算器ALU与各寄存器之间采用总线结构32浮点运算部件 Floating Point UnitA Floating Point Unit also performs arithmetic operations between two values, but they do so for numbers in floating point representation, which is much more complicated than the twos complement representation used in a typical ALU. 每个浮点部件都包含阶码运算和尾数运算两个定点运算器。浮点运算器包含浮点加法、乘法和除法三个浮点运算部件。In order to do these calculations, a FPU has several complex circuits built-in, including some internal ALUs.333.1.2 十进制数的编码与运算(1) 8421码的加法运算两个8421 BCD码数相加如果按照二进制数加法规则进行,当 其和小于或等于9时,结果是正确的。例如,计算2348?0010 0011 ) 0100 10000110 1011低4位大于9 +) 0110加6修正0111 0001和数是71十进制数是以十为模,“逢十进一”的。但4位二进制数的模是2416,当和大于9而小于16时,加法器 并不产生进位。此时,和数是10101111,这6种代码不是8421 码,结果是错误的。因此,应对和数的对应位进行加6修正。34当两个8421码数相加,和大于16时,会产生进位。但这是按模16进位的,故结果比正确的和数小6,也是错误 的,需加6修正。如,计算1829?0001 1000 ) 0010 10010100 0001低位向高位产生进位 ) 0110加6修正0100 0111和数是47实现8421 码加减法运算的加法器是在二进制加法器的基础上 ,增加一些逻辑电路,根据是否有进位或借位,以及和是否大于 9等条件决定是否要进行修正。也可预先在被加数的各位上加6,然后再与加数相加。若本位 有进位,则结果正确,否则再减去6就得到正确结果。这样就不 需判断和是否大于9。 35(2)余3码的加法运算余3码的每个代码都比对应的8421码多0011。若一位十进制 数的8421 码为X,则该数的余3码YX0011。两个一位的余三码数相加,若没有进位,和SY1Y2X 10011X 200110011(X 1X 20011)即和数比正确的余3码数多了0011。故应将多出的0011减去。如,计算15?0100 )1000 1100无进位 )0011减3修正1001 和是636若两个余3码数相加产生进位,则应加3修正。如,计算1618?0100 1001 )0100 1011 1001 0100 ) 0011低位加3修正 )0011高位减3修正 0110 0111和是3437Homework3 - 21,22,The IEEE has standardized the computer representation for binary floating-point numbers in IEEE 754. This standard is followed by almost all modern machines.Single precision, called “float“ in the C language family, and “real“ or “real*4“ in Fortran. This is a binary format that occupies 32 bits and its significand has a precision of 24 bits (about 7 decimal digits).Double precision, called “double“ in the C language family, and “double precision“ or “real*8“ in Fortran. This is a binary format that occupies 64 bits (8 bytes) and its significand has a precision of 53 bits (about 16 decimal digits).下次课有小测验(第3章)设计性大作业1请在第4周末交38
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号