Docsity

Number System, Boolean Operations - Computer Architecture I | CS 231, Study notes of Computer Architecture and Organization

Partial preview of the text

Download Number System, Boolean Operations - Computer Architecture I | CS 231 and more Study notes Computer Architecture and Organization in PDF only on Docsity!

  • CS231: Computer Architecture I Friday, January 26,

CS 231 - Computer Architecture I

Review/Discussion

-^ Number Systems^ –^

Binary – Octal – Hexadecimal

-^ Boolean Operations^ –^

Functions – Operators – Truth Tables – Logic Gates – Expression and Circuits

-^ Circuit Analysis •^ Truth Tables •^ Boolean Algebra^ –^

deMorgans Laws

-^ Maxterms/Minterms

CS 231 - Computer Architecture I

Number systems

-^ To get started, we’ll discuss one of the fundamental conceptsunderlying digital computer design:

Deep down inside, computers work with just 1s and 0s.

-^ Computers use voltages to represent information. In modern CPUs thevoltage is usually limited to 1.6-1.8V to minimize power consumption. •^ It’s convenient for us to translate these analogvoltages 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 withjust 1s and 0s. – Then we’ll introduce special operationsfor computing with 1s and 0s, by treating them asthe logical values “true” and “false.”

Volts1.8 1 0 0

CS 231 - Computer Architecture I

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 theweights like this: •^ To find the decimal value of a number, multiply each digit by its weightand sum the products.

.^3

Digits

1/^
1/^

Weights

.^3

Digits

-1^10
-2^10
-3^10

Weights

(^2) ( 1 x 10 ) + (^6 x 10

1 ) + (^2 x 10

0 ) + (^3 x 10

-1) + (^7 x 10

-2) + (^5

-3x 10) =

CS 231 - Computer Architecture I

Converting decimal to binary

-^ To convert a decimal integer into binary, keep dividing by 2 until thequotient is 0. Collect the remainders in

reverse

order.

-^ To convert a fraction, keep multiplying the fractional part by 2 until itbecomes 0. Collect the integer parts in forward order. •^ Example: 162.375: •^ So, 162.

=^1010001010
.^0112
= 81^

rem^0 81 / 2^

= 40^

rem^1 40 / 2 = 20

rem^

rem^

10 / 2^
= 5^

rem^0 5 / 2 = 2

rem

rem

1 / 2^ = 0

rem

0.375 x 2 =

0.750 x 2 =

0.500 x 2 =

Example

Converting Binary to Decimal^ 100110.

Example

Converting Decimal to Binary^ 201.

Example

Converting Decimal to Binary^ 244.

CS 231 - Computer Architecture I

Binary and hexadecimal conversions

-^ Converting from hexadecimal to binary is easy: just replace each hexdigit with its equivalent 4-bit binary sequence. •^ To convert from binary to hex, make groups of 4 bits, starting from thebinary point. Add 0s to the ends of the number if needed. Then, justconvert each bit group to its corresponding hex digit.

=^16
.^
=^0010
.^0011
=^10112
.^0010

2

=^ B^
4.^
2 C

(^161111) F (^1011) B (^01117) (^00113)

(^1110) E (^1010) A (^01106) (^00102)

(^1101) D (^10019) (^01015) (^00011)

(^1100) C (^10008) (^01004) (^00000)

BinaryHex BinaryHex BinaryHex BinaryHex

Example

Converting Hexadecimal to Binary^ F2A8.

CS 231 - Computer Architecture I

Boolean values

-^ Earlier, we used electrical voltages to representtwo discrete values 1 and 0, from which

binary numbers

can be formed. • It’s also possible to think of voltages as representingtwo^ 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 designfunctions and hardware for doing arbitrary computations.

Volts1.8^0 True False

CS 231 - Computer Architecture I

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

x^ y^ f(x,y) 0 0 0 …^ …^ … 2 2 6 …^ …^ … 23 41 87 …^ …^ …^ and^ finite.

An^ expression f(x,y) = 2x + y= x + x + y= 2(x + y/2)= ...

is finite but not unique

A^ function table

is unique but infinite

CS 231 - Computer Architecture I

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’)

CS 231 - Computer Architecture I

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), truthtables 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.

x^ y^

z^ f(x,y,z) 0 0

0 1 0 0

1 1 0 1

0 1 0 1

1 1 1 0

0 0 1 0

1 1 1 1

0 0 1 1

1 1

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’