Chapter 2 Data Representation in Computer Systems 2.1 Introduction
Total Page:16
File Type:pdf, Size:1020Kb
QUIZ ch.1 • 1st generation • Integrated circuits • 2nd generation • Density of silicon chips doubles every 1.5 yrs. rd • 3 generation • Multi-core CPU th • 4 generation • Transistors • 5th generation • Cost of manufacturing • Rock’s Law infrastructure doubles every 4 yrs. • Vacuum tubes • Moore’s Law • VLSI QUIZ ch.1 The highest # of transistors in a CPU commercially available today is about: • 100 million • 500 million • 1 billion • 2 billion • 2.5 billion • 5 billion QUIZ ch.1 The highest # of transistors in a CPU commercially available today is about: • 100 million • 500 million “As of 2012, the highest transistor count in a commercially available CPU is over 2.5 • 1 billion billion transistors, in Intel's 10-core Xeon • 2 billion Westmere-EX. • 2.5 billion Xilinx currently holds the "world-record" for an FPGA containing 6.8 billion transistors.” Source: Wikipedia – Transistor_count Chapter 2 Data Representation in Computer Systems 2.1 Introduction • A bit is the most basic unit of information in a computer. – It is a state of “on” or “off” in a digital circuit. – Sometimes these states are “high” or “low” voltage instead of “on” or “off..” • A byte is a group of eight bits. – A byte is the smallest possible addressable unit of computer storage. – The term, “addressable,” means that a particular byte can be retrieved according to its location in memory. 5 2.1 Introduction A word is a contiguous group of bytes. – Words can be any number of bits or bytes. – Word sizes of 16, 32, or 64 bits are most common. – Intel: 16 bits = 1 word, 32 bits = double word, 64 bits = quad word – In a word-addressable system, a word is the smallest addressable unit of storage. 6 QUIZ A word is a contiguous group of bytes. – Words can be any number of bits or bytes. – Word sizes of 16, 32, or 64 bits are most common. – Intel: 16 bits = 1 word, 32 bits = double word, 64 bits = quad word – In a word-addressable system, a word is the smallest addressable unit of storage. Does the word size belong to the organization or architecture of a computer? 7 QUIZ What is the word size in the MARIE architecture? The meaning of “full n-bit computer” (8, 16, 32, 64 etc.) All data-related operations must be performed on n bits: • Word size → n bits • MBR, AC → n bits • ALU → n bits • Data bus → n bits / cycle – n bit wide @ 1 transf./cycle – n/2 bit wide @ 2 transf./cycle – etc. • Usually InReg, OutReg 9 The meaning of “n-bit computer” (8, 16, 32, 64 etc.) However, not all parameters of the computer need be exactly n bits: • Opcode length • Address length, PC, MAR • Instruction length, IR – It’s even variable in CISC! 10 2.1 Introduction A group of four bits is called a nibble. (nybble ??) – Bytes consist of two nibbles: a “high-order nibble,” and a “low-order” nibble. In each case, find the h-o and l-o nibble: • 0110 1011 (binary) • E7 (hex) • 42 (dec) • 325 (oct) 11 2.2 Positional Numbering Systems Bytes store numbers using the position of each bit to represent a power of 2. – The binary system is also called the base-2 system. – Our decimal system is the base-10 system. It uses powers of 10 for each position in a number. – Any integer quantity can be represented exactly using any base (or radix). 12 2.2 Positional Numbering Systems • The decimal number 947 in powers of 10 is: 9 10 2 + 4 10 1 + 7 10 0 • The decimal number 5836.47 in powers of 10 is: 5 10 3 + 8 10 2 + 3 10 1 + 6 10 0 -1 -2 + 4 10 + 7 10 13 2.2 Positional Number Systems • The binary number 11001 in powers of 2 is: 1 2 4 + 1 2 3 + 0 2 2 + 0 2 1 + 1 2 0 = 16 + 8 + 0 + 0 + 1 = 25 • When the radix of a number is something other than 10, the base is denoted by a subscript. – Sometimes, the subscript 10 is added for emphasis: 110012 = 2510 14 2.3 Converting Between Bases Converting unsigned integers Two algorithms: 1.Top-down = repeated subtraction 2.Bottom-up = repeated division (and remainder) 15 Converting – Repeated subtraction Example: convert the decimal number 190 to base 3. – First question: how many digits are needed? – A: 3 5 = 243 > 190 so our result will be less than five digits wide. – The largest power of 3 that we need is therefore 3 4 = 81. – How many times does 81 fit inside 190? – A: 81 2 = 162. – Write down the 2 and subtract 162 16 from 190, giving 28. Then repeat for the quantity that was left over: – The next power of 3 is 3 3 = 27. We’ll need one of these, so we subtract 27 and write down the numeral 1 in our result. – The next power of 3, 3 2 = 9, is too large, but we have to assign a placeholder of zero and carry down the 1. 17 Continue until 30 (=1, a.k.a. units): – 3 1 = 3 is again too large, so we assign a zero placeholder. – The last power of 3, 3 0 = 1, is our last choice, and it gives us a difference of zero. – Our result, reading from top to bottom is: 19010 = 210013 18 Extra-credit QUIZ 19 Converting: repeated division Converting 190 to base 3... Our result, reading from bottom to top is: 19010 = 210013 20 QUIZ Convert the decimal number 462 to base 5 using repeated division. 21 2.3 Converting Between Bases Converting unsigned fractions • Fractional values can be approximated in all base systems. • Unlike integes, fractions do not necessarily have exact representations under all bases. – E.g. ½ (0.5 dec) is exactly representable in the binary and decimal systems, but not in base 3) 22 2.3 Converting Between Bases decimal point ↔ radix point Digits to the right of a radix point represent negative powers of the radix: -1 -2 0.4710 = 4 10 + 7 10 -1 -2 0.112 = 1 2 + 1 2 = ½ + ¼ = 0.5 + 0.25 = 0.75 23 2.3 Converting Between Bases As with integer conversions, we can use two methods: • Repeated subtraction • Repeated multiplication 24 Fractions: repeated subtraction Identical to the subtraction method for positive integers. Instead of subtracting positive powers of the target radix, we subtract negative powers of the radix. We always start with the largest value first, R -1, and work our way along using larger negative exponents. 25 Fractions: repeated subtraction Example: convert the decimal 0.8125 to binary. • Our result, reading from top to bottom is: 0.812510 = 0.11012 Works with any base, not just binary! 26 Fractions: repeated subtraction QUIZ: convert the decimal 0.3 to binary. 27 Fractions: repeated multiplication Example: convert the decimal 0.8125 to binary • First we multiply by the radix 2. • The one in the units place is the first binary digit 28 Fractions: repeated multiplication Converting 0.8125 to binary . • Ignoring the value in the units place, we continue multiplying each fractional part by the radix. 29 Fractions: repeated multiplication Converting 0.8125 to binary . • We are finished when the product is zero, or we have reached the desired number of binary places. • Reading bits from top to bottom: 0.812510 = 0.11012 This method also works with any base. Just use the target base as the multiplier. 30 Your turn! Convert the decimal 0.3 to binary by repeated multiplication. Use 8 bits of precision. 31 Individual work for next time • Read pp.57-63 of text • Follow and understand examples 2.1 through 2.8 • Solve in notebook end-of-chapter Ex.1 (p.117) 32 Larger Bases • The binary numbering system is the most important radix system for digital computers. • However, it is difficult to read long strings of binary numbers -- and even a modestly-sized decimal number becomes a very long binary number. – For example: 110101000110112 = 1359510 33 Octal – an “Evolutionary dead-end”? The 6-bit computers: • Motivated by the 6-bit codes for printable graphic patterns common in the U.S. Army and Navy • 6, 18, 26, 36, 48-bit words • Some history: – 18-Bit Computers from DEC – 36-bit Wikipedia • Edged out of the market by the need for floating- point – IBM System/360 (1965) – 8-bit microprocessors (1970s) 34 Octal – an “Evolutionary dead-end”? Unisys is still successful with their 36- and 48- bit machines : • Clearpath Dorado line of 36-bit CISC high- end servers • Clearpath Libra line of 48-bit mainframes … although they are being transitioned to Intel Xeon chips (64-bit): see article 35 Hexadecimal • For compactness and ease of reading, binary values are usually expressed using the hexadecimal (base 16) number system. • The hex digits: 0 – 9, A, B, C, D, E, F • It is easy to convert between base 16 and base 2, because 16 = 24 → one-to-one correspondence between hex digits and groups of four bits A group of four binary digits is called a nibble or a hextet 36 Converting Between Bases which are powers of 2 is easy! Using hextets, the binary number 110101000110112 (= 1359510) in hexadecimal is: If the number of bits is not a multiple of 4, pad on the left with zeros. Octal (base 8) values are derived from binary by using groups of three bits (8 = 23): Octal was very useful when computers used six-bit words. 37 QUIZ: Convert from hex to octal ? 2 A F16 = 8 38 Operations with unsigned integers • Addition They can all be • Subtraction performed with pencil • Multiplication and paper exactly as in • Division decimal (carry, borrow, long division, etc.) 39 Operations with unsigned integers • Addition They can all be • Subtraction performed with pencil • Multiplication and paper exactly as in • Division decimal (carry, borrow, long division, etc.) Example: 1101 0001 : 101 40 2.4 Signed Integer Representation To represent signed integers, computer use the high- order bit to indicate the sign of a number.