CS231: Computer Architecture I: María J. Garzarán Spring 2008
CS231: Computer Architecture I: María J. Garzarán Spring 2008
CS231: Computer Architecture I: María J. Garzarán Spring 2008
Mara J. Garzarn
Spring 2008
Number systems
Introduction to CS231
Decimal review
1
100
2
1
3
1/10
7
1/100
5
Digits
1/1000 Weights
The weights are all powers of the base, which is 10. We can rewrite the
weights like this:
1
102
6
10
6
101
2
100
3
10-1
7
10-2
5
10-3
Digits
Weights
To find the decimal value of a number, multiply each digit by its weight
and sum the products.
(1 x 102) + (6 x 101) + (2 x 100) + (3 x 10-1) + (7 x 10-2) + (5 x 10-3) = 162.375
Introduction to CS231
1
22
0
21
1
20
0
2-1
1
2-2
24
25
26
27
=
=
=
=
16
32
64
128
28 = 256
29 = 512
210 = 1024
Introduction to CS231
162 / 2
81 / 2
40 / 2
20 / 2
10 / 2
5/2
2/2
1/2
=
=
=
=
=
=
=
=
81
40
20
10
5
2
1
0
rem
rem
rem
rem
rem
rem
rem
rem
0
1
0
0
0
1
0
1
0.375 x 2 = 0.750
0.750 x 2 = 1.500
0.500 x 2 = 1.000
Introduction to CS231
Introduction to CS231
Decimal
Decimal
00
11
22
33
44
55
66
77
88
99
10
10
11
11
12
12
13
13
14
14
15
15
Introduction to CS231
Binary
Binary
0000
0000
0001
0001
0010
0010
0011
0011
0100
0100
0101
0101
0110
0110
0111
0111
1000
1000
1001
1001
1010
1010
1011
1011
1100
1100
1101
1101
1110
1110
1111
1111
Hex
Hex
00
11
22
33
44
55
66
77
88
99
AA
BB
CC
DD
EE
FF
516
C16
Hex
Binary
Hex
Binary
Hex
Binary
Hex
Binary
0000
0100
1000
1100
0001
0101
1001
1101
0010
0110
1010
1110
0011
0111
1011
1111
Introduction to CS231
Introduction to CS231
10
Boolean Operations
11
Boolean values
Volts
Earlier, we used electrical voltages to represent
1.8
two discrete values 1 and 0, from which binary numbers
can be formed.
True
Its also possible to think of voltages as representing
two logical values, true and false.
False
For simplicity, we often still write digits instead:
0
1
is
true
0 is false
We will use this interpretation along with special operations to design
functions and hardware for doing arbitrary computations.
Introduction to CS231
12
Functions
Computers take inputs and produce outputs, just like functions in math!
Mathematical functions can be expressed in two ways:
An expression is
finite but not unique
f(x,y) = 2x + y
=x+x+y
= 2(x + y/2)
= ...
A function table is
unique but infinite
x
f(x,y)
23
41
87
Introduction to CS231
13
AND (product)
of two inputs
Expression:
xy, or xy
Truth table:
OR (sum) of
two inputs
NOT
(complement)
on one input
x+y
xy
x+y
Introduction to CS231
14
Boolean expressions
Introduction to CS231
15
Truth tables
f(0,0,0)
f(0,0,1)
f(0,1,0)
f(0,1,1)
f(1,0,0)
f(1,0,1)
f(1,1,0)
f(1,1,1)
= (0 + 1)0 + 1
= (0 + 1)1 + 1
= (0 + 0)0 + 1
= (0 + 0)1 + 1
= (1 + 1)0 + 0
= (1 + 1)1 + 0
= (1 + 0)0 + 0
= (1 + 0)1 + 0
=1
=1
=1
=1
=0
=1
=0
=1
f(x,y,z)
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
1
1
1
1
0
1
0
1
Introduction to CS231
16
Operation:
Expression:
AND (product)
of two inputs
xy, or xy
OR (sum) of
two inputs
x+y
NOT
(complement)
on one input
x
Logic gate:
Introduction to CS231
17
Introduction to CS231
18
Next time, well look at how Boolean algebra can help simplify
expressions, which in turn will lead to simpler circuits.
Introduction to CS231
19