Presentation is loading. Please wait.

Presentation is loading. Please wait.

June 10, 2002©2000-2002 Howard Huang1 Number systems To get started, we’ll discuss one of the fundamental concepts underlying digital computer design:

Similar presentations


Presentation on theme: "June 10, 2002©2000-2002 Howard Huang1 Number systems To get started, we’ll discuss one of the fundamental concepts underlying digital computer design:"— Presentation transcript:

1 June 10, 2002©2000-2002 Howard Huang1 Number systems To get started, we’ll discuss one of the fundamental concepts underlying digital computer design: Deep down inside, computers work with just 1s and 0s. Computers use voltages to represent information. In modern CPUs the voltage is usually limited to 1.6-1.8V to minimize power consumption. It’s convenient for us to translate these analog voltages into the discrete, or digital, values 1 and 0. But how can two lousy digits be useful for anything? – First, we’ll see how to represent numbers with just 1s and 0s. – Then we’ll introduce special operations for computing with 1s and 0s, by treating them as the logical values “true” and “false.” Volts 1.8 0 1 0

2 June 10, 2002Number Systems2 Today’s lecture Having seen an overview last week, – We will now start a more thorough study Number systems – Review of binary number representation – How to convert between binary and decimal representations – Octal and Hex representations Basic boolean operations – AND, OR and NOT – The idea of “Truth Table” – Boolean functions and expressions – Truth table for Boolean expressions

3 June 10, 2002Number Systems3 Decimal review Numbers consist of a bunch of digits, each with a weight: The weights are all powers of the base, which is 10. We can rewrite the weights like this: To find the decimal value of a number, multiply each digit by its weight and sum the products. (1 x 10 2 ) + (6 x 10 1 ) + (2 x 10 0 ) + (3 x 10 -1 ) + (7 x 10 -2 ) + (5 x 10 -3 ) = 162.375

4 June 10, 2002Number Systems4 Converting binary to decimal We can use the same trick to convert binary, or base 2, numbers to decimal. The only difference is that the weights are powers of 2. For example, here is 1101.01 in binary: The decimal value is: (1 x 2 3 ) + (1 x 2 2 ) + (0 x 2 1 ) + (1 x 2 0 ) + (0 x 2 -1 ) + (1 x 2 -2 ) = 8+ 4+ 0+ 1+ 0+ 0.25= 13.25

5 June 10, 2002Number Systems5 Converting decimal to binary To convert a decimal integer into binary, keep dividing by 2 until the quotient is 0. Collect the remainders in reverse order. To convert a fraction, keep multiplying the fractional part by 2 until it becomes 0. Collect the integer parts in forward order. Example: 162.375: So, 162.375 10 = 10100010.011 2 162 / 2= 81rem 0 81 / 2= 40rem 1 40 / 2= 20rem 0 20 / 2= 10rem 0 10 / 2= 5rem 0 5 / 2= 2rem 1 2 / 2= 1rem 0 1 / 2= 0rem 1 0.375 x 2 = 0.750 0.750 x 2 = 1.500 0.500 x 2 = 1.000

6 June 10, 2002Number Systems6 Why does this work? This works for converting from decimal to any base Why? Think about converting 162.375 from decimal to decimal. Each division strips off the rightmost digit (the remainder). The quotient represents the remaining digits in the number. Similarly, to convert fractions, each multiplication strips off the leftmost digit (the integer part). The fraction represents the remaining digits. 162 / 10= 16rem 2 16 / 10= 1rem 6 1 / 10= 0rem 1 0.375 x 10 = 3.750 0.750 x 10 = 7.500 0.500 x 10 = 5.000

7 June 10, 2002Number Systems7 Base 16 is useful too The hexadecimal system uses 16 digits: 0 1 2 3 4 5 6 7 8 9 A B C D E F You can convert between base 10 and base 16 using techniques like the ones we just showed for converting between decimal and binary. For our purposes, base 16 is most useful as a “shorthand” notation for binary numbers. – Since 16 = 2 4, one hexadecimal digit is equivalent to 4 binary digits. – It’s often easier to work with a number like B4 instead of 10110100. Hex is frequently used to specify things like 32-bit IP addresses and 24-bit colors.

8 June 10, 2002Number Systems8 Binary and hexadecimal conversions Converting from hexadecimal to binary is easy: just replace each hex digit with its equivalent 4-bit binary sequence. To convert from binary to hex, make groups of 4 bits, starting from the binary point. Add 0s to the ends of the number if needed. Then, just convert each bit group to its corresponding hex digit. 261.35 16 = 2 6 1. 3 5 16 =001001100001.00110101 2 10110100.001011 2 =10110100.00101100 2 = B 4. 2 C 16

9 June 10, 2002Number Systems9 Number Systems Summary Computers are binary devices. – We’re forced to think in terms of base 2. – Today we learned how to convert numbers between binary, decimal and hexadecimal. We’ve already seen some of the recurring themes of architecture: – We use 0 and 1 as abstractions for analog voltages. – We showed how to represent numbers using just these two signals. Next we’ll introduce special operations for binary values and show how those correspond to circuits.

10 June 10, 2002©2000-2002 Howard Huang10 Boolean Operations So far, we’ve talked about how arbitrary numbers can be represented using just the two binary values 1 and 0. Now we’ll interpret voltages as the logical values “true” and “false” instead. We’ll show: – How functions can be defined for expressing computations – How to build circuits that implement our functions in hardware

11 June 10, 2002Number Systems11 Boolean values Earlier, we used electrical voltages to represent two discrete values 1 and 0, from which binary numbers can be formed. It’s also possible to think of voltages as representing two logical values, true and false. For simplicity, we often still write digits instead: – 1 is true – 0 is false We will use this interpretation along with special operations to design functions and hardware for doing arbitrary computations. Volts 1.8 0 True False

12 June 10, 2002Number Systems12 Functions Computers take inputs and produce outputs, just like functions in math! Mathematical functions can be expressed in two ways: We can represent logical functions in two analogous ways too: – A finite, but non-unique Boolean expression. – A truth table, which will turn out to be unique and finite. f(x,y)= 2x + y = x + x + y = 2(x + y/2) =... An expression is finite but not unique A function table is unique but infinite

13 June 10, 2002Number Systems13 Basic Boolean operations There are three basic operations for logical values. AND (product) of two inputs OR (sum) of two inputs NOT (complement) on one input xy, or x  yx + yx’ Operation: Expression: Truth table:

14 June 10, 2002Number Systems14 Boolean expressions We can use these basic operations to form more complex expressions: f(x,y,z) = (x + y’)z + x’ Some terminology and notation: – f is the name of the function. – (x,y,z) are the input variables, each representing 1 or 0. Listing the inputs is optional, but sometimes helpful. – A literal is any occurrence of an input variable or its complement. The function above has four literals: x, y’, z, and x’. Precedences are important, but not too difficult. – NOT has the highest precedence, followed by AND, and then OR. – Fully parenthesized, the function above would be kind of messy: f(x,y,z) = (((x +(y’))z) + x’)

15 June 10, 2002Number Systems15 Truth tables A truth table shows all possible inputs and outputs of a function. Remember that each input variable represents either 1 or 0. – Because there are only a finite number of values (1 and 0), truth tables themselves are finite. – A function with n variables has 2 n possible combinations of inputs. Inputs are listed in binary order—in this example, from 000 to 111. f(0,0,0)= (0 + 1)0 + 1= 1 f(0,0,1)= (0 + 1)1 + 1= 1 f(0,1,0)= (0 + 0)0 + 1= 1 f(0,1,1)= (0 + 0)1 + 1= 1 f(1,0,0)= (1 + 1)0 + 0= 0 f(1,0,1)= (1 + 1)1 + 0= 1 f(1,1,0)= (1 + 0)0 + 0= 0 f(1,1,1)= (1 + 0)1 + 0= 1 f(x,y,z) = (x + y’)z + x’

16 June 10, 2002Number Systems16 Primitive logic gates Each of our basic operations can be implemented in hardware using a primitive logic gate. – Symbols for each of the logic gates are shown below. – These gates output the product, sum or complement of their inputs. Logic gate: AND (product) of two inputs OR (sum) of two inputs NOT (complement) on one input xy, or x  yx + yx’ Operation: Expression:

17 June 10, 2002Number Systems17 Expressions and circuits Any Boolean expression can be converted into a circuit by combining basic gates in a relatively straightforward way. The diagram below shows the inputs and outputs of each gate. The precedences are explicit in a circuit. Clearly, we have to make sure that the hardware does operations in the right order! (x + y’)z + x’

18 June 10, 2002Number Systems18 Boolean operations summary We can interpret high or low voltage as representing true or false. A variable whose value can be either 1 or 0 is called a Boolean variable. AND, OR, and NOT are the basic Boolean operations. We can express Boolean functions with either an expression or a truth table. Every Boolean expression can be converted to a circuit. Next time, we’ll look at how Boolean algebra can help simplify expressions, which in turn will lead to simpler circuits.


Download ppt "June 10, 2002©2000-2002 Howard Huang1 Number systems To get started, we’ll discuss one of the fundamental concepts underlying digital computer design:"

Similar presentations


Ads by Google