计算机组成结构 week02-3_第1页
计算机组成结构 week02-3_第2页
计算机组成结构 week02-3_第3页
计算机组成结构 week02-3_第4页
计算机组成结构 week02-3_第5页
已阅读5页,还剩43页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、5/3/2022CDA31001Outline Announcement Review Unsigned and signed number representations Floating point number representation IEEE 754 standard Instruction set architecture concept5/3/2022CDA31002Announcement Program examples (C or MIPS) are available and will be available at /liux

2、/courses/cda3100/inclassexamples/ 1/12/2015 12:55:01 PMweek02-3.ppt3 The positive half from 0 to 2,147,483,647 The negative half from -2,147,483,648 to -132 Bit Signed Numbers in Twos Complement1/12/2015 12:55:26 PMweek02-3.ppt4General Numbering System Base X In base X, the value of Note the formula

3、 is also valid for a floating point number The value of 011ddddnn0110011110)0(dXdXdXdXXdXdXdXdXdnnnnnnniii21011.ddddddnn332211001111XdXdXdXdXdXdXdXdnnnnnniii1/12/2015 12:56:32 PMweek02-3.ppt5Unsigned Examples 101.11two= 22 + 20 + 2-1 + 2-2 = 5.75 3F.3hex = 316 + 15 160 + 316-1 = 63.18751/12/2015 12:

4、58:12 PMweek02-3.ppt6Decimal to Binary Floating Point Given a floating number in decimal, how to find its binary floating point representation? Lets take 0.1ten as example33221100111122222222ddddddddnnnnnniii1/12/2015 1:00:16 PMweek02-3.ppt7Example Convert 0.1ten to binary floating number00 0 0 1 1

5、0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 10 4 . 022 . 01 2 . 126 . 01 6 . 128 . 00 8 . 024 . 00 4 . 022 . 00 2 . 021 . 01/12/2015 1:02:04 PMweek02-3.ppt8How to Convert Decimal to Base X - Fraction We know how to do that for the integer part and here we only talk about the fraction part inputVal is the

6、fraction part of a number/liux/courses/cda3100/inclassexamples/decimal-baseX-float.c/liux/courses/cda3100/inclassexamples/baseX-decimal-float.c1/12/2015 1:02:49 PMweek02-3.ppt9Floating Point Numbers Scientific notation for decimal numbers A number is represent

7、ed by a significand (or mantissa) and an integer exponent Where F is the significand, and E the exponent Here S represents the sign Examples include ESF10) 1(421000001. 0101415926. 31/12/2015 1:03:48 PMweek02-3.ppt10Normalized Number Normalized number A scientific notation is normalized if there is

8、a single non-zero digit to the left of the floating point For example, are normalized are not normalized9ten9ten103.15576or 100 . 18ten8ten1031.5576or 1010. 01/12/2015 1:08:02 PMweek02-3.ppt11Floating Points in Binary Normalized binary scientific notation For a fixed number of bits, we need to decid

9、e How many bits for the significand (or fraction) How many bits for the exponent There is a trade-off between precision and range More bits for significand increases precision while more bits for exponent increases the rangeyyyytwoxxxxxxxxxx2. 11/12/2015 1:08:16 PMweek02-3.ppt12IEEE 754 Floating Poi

10、nt Standard Single precision Represented by 32 bits Since the leading 1 bit in the significand in normalized binary numbers is always 1, it is not represented explicitly5/3/2022CDA310013Exponent If we represent exponents using twos complement, then it would not be intuitive as small numbers appear t

11、o be larger3130292827262524232221201918171615141312111098765432100 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 03130292827262524232221201918171615141312111098765432100 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 05/3/2022CDA310014Biased Notation The most negative expo

12、nent will be represented as 0000 and the most positive as 11111 That is, we need to subtract the bias from the corresponding unassigned value The value of an IEEE 754 single precision is)127Exponent(2)Fraction. 01 () 1(S313029282726252423222120191817161514131211109876543210sexponentfraction1 bit8 bi

13、ts23 bits5/3/2022CDA310015Example 101.11two= 22 + 20 + 2-1 + 2-2 = 5.75 The normalized binary number will be 1.011122 = 1.01112(129-127) So the exponent is 129ten = 10000001As a hexadecimal number, the representation is 0 x40B80000 3130292827262524232221201918171615141312111098765432100 1 0 0 0 0 0

14、0 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 05/3/2022CDA310016Example So the exponent is 123ten = 01111011As a hexadecimal number, the representation is 0 x3DCCCCCC 3130292827262524232221201918171615141312111098765432100 0 1 1 1 1 0 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 012712321001. 1

15、00110 . 01 . 0twotwoten5/3/2022CDA3100170.1 Caused Serious Losses5/3/2022CDA310018IEEE 754 Double Precision It uses 64 bits (two 32-bit words) 1 bit for the sign 11 bits for the exponent 52 bits for the fraction 1023 as the bias313029282726252423222120191817161514131211109876543210sExponentfraction1

16、 bit11 bits20 bitsFraction (continued)32 bits5/3/2022CDA310019Example (Double Precision) 101.11two= 22 + 20 + 2-1 + 2-2 = 5.75 The normalized binary number will be 1.011122 = 1.01112(1025-1023) So the exponent is 1025ten = 10000000001twoAs a hexadecimal number, the representation is 0 x4017 0000 000

17、0 00003130292827262524232221201918171615141312111098765432100 1 0 0 0 0 0 0 0 0 0 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 03130292827262524232221201918171615141312111098765432100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 05/3/2022CDA310020Special CasesSingle precisionDouble precisi

18、onObject representedExponentFractionExponentFraction000000nonzero0nonzerodenormalized number1-254anything1-2046anythingfloating-point number255020470 infinity255nonzero2047nonzeroNaN (Not a number)In 2008, denormalized numbers are renamed to subnormal ones5/3/2022CDA310021Ranges for IEEE 754 Single

19、Precision Largest positive number Smallest positive number Floating-point number Denormalized number3130292827262524232221201918171615141312111098765432100 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 13130292827262524232221201918171615141312111098765432100 0 0 0 0 0 0 0 1 0 0 0 0 0 0

20、 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 03130292827262524232221201918171615141312111098765432100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 11/12/2015 11:17:14 PMweek02-3.ppt22Ranges for IEEE 754 Single Precision Largest positive number Smallest positive number Floating-point number - norm

21、alized Denormalized number Overflow and underflow Overflow if the exponent is too large to be represented Underflow if the exponent is too small to be represented38104128)127254(23103.4028235516925440170418348438528859813402823466222)211 (38126)1271(10175494351. 122)0 . 01 (23(0 126)14945(0.02)221.4

22、012985 10(0 126)( 1)(00.Fraction)2S5/3/2022CDA310023Ranges for IEEE 754 Double Precision Largest positive number Smallest positive number Floating-point number Denormalized number52(0 1022)1074324(0.02)224.94065646 103081022)10231(102250738585. 222)0 . 01 (3089711024)10232046(52106231577976931348. 1

23、222)211 (0 1022)( 1)(00.Fraction)2S5/3/2022CDA310024Range for Intels 80-bit Format Intels IA-32 internally uses a 80-bit floating point (extended precision representation) It includes a sign bit, a 16-bit exponent, and 63-bit significant (64-bit if the implied 1 is also included) The bias is 32767 W

24、hat is the largest positive number? What is the smallest positive number?5/3/2022CDA310025Bit Fields in C C (C+ also) allows bit fields to be defined within words All the fields must fit within a single word Fields must be integral types Starts from the right-most bit31302928272625242322212019181716

25、1514131211109876543210sexponentfraction1 bit8 bits23 bits5/3/2022CDA310026Endianness Byte ordering How a multiple byte data stored in memory Endianness (from Gullivers Travels) Big endian significant byte of a multi-byte word is stored at the memory address e.g. Sun Sparc, PowerPC Little endian sign

26、ificant byte of a multi-byte word is stored at the memory address e.g. Intel x865/3/2022CDA310027Endianness - continued Note that the bit fields depend on the endianness of the machine313029282726252423222120191817161514131211109876543210sexponentfraction1 bit8 bits23 bitsBit field direction on litt

27、le endian machinesBit field direction on big endian machines5/3/2022CDA310028Bit Fields in C The formula to compute the decimal floating point value using the bit fields is Note that the prototype for pow is defined in and the function is defined in the math library (using lm to link the math librar

28、y)5/3/2022CDA310029Meaning of Bit Patterns What a bit pattern represents depends what it is for Example, the following bit pattern A twos complement integer An unsigned integer A single precision floating-point number A MIPS instruction3130292827262524232221201918171615141312111098765432101 0 1 0 1

29、1 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 05/3/2022CDA310030Meaning of Bit Patterns What a bit pattern represents depends what it is for Example, the following bit pattern A twos complement integer An unsigned integer A single precision floating-point A MIPS instruction31302928272625242322

30、21201918171615141312111098765432101 0 1 0 1 1 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 05/3/2022CDA310031Stored Program Concept Programs consist of instructions and data Instructions are also represented as 0s and 1s Before a program runs, it will be loaded and stored in memory; it can be r

31、ead and written just like numbers A program is executed instruction by instruction These apply to all kinds of programs, operating systems, applications, games, and so on1/12/2015 10:56:39 PMweek02-3.ppt33GoogleEarth.exe1/12/2015 10:56:38 PMweek02-3.ppt34Linux Kernel1/12/2015 10:56:38 PMweek02-3.ppt

32、35Five Classic Components1/12/2015 10:56:37 PMweek02-3.ppt36Instruction Set Architectures An instruction set architecture specifies Instructions Registers Memory access Input/output An instruction set architecture provides an abstraction of the hardware implementation The hardware implementation dec

33、ides what and how instructions are implemented1/12/2015 10:56:37 PMweek02-3.ppt37Abstract View of MIPS Implementation1/12/2015 10:56:35 PMweek02-3.ppt38Instruction Execution Steps Instruction fetch step Fetch the instruction from memory and compute the address of the next sequential instruction Inst

34、ruction decode and register fetch step Decode the instruction and read registers Instruction execution Memory access / result Memory 1/12/2015 10:56:35 PMweek02-3.ppt39Instructions Note the operands for an arithmetic instruction must be from registers Reading from and storing to memory can be done using only specific instructions1/12/2015 10:56:34 PMweek02-3.ppt40Arithmetic Instruction Execution1/12/2015 10:56:34 PMweek02-3.ppt411/12/2015 10:56:24 PMweek02-3.ppt42Summary Now we know how to represent unsigned, signed, and floating points in computers Unsigned Signed using twos co

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论