boolean algebra binary arithmetic august 28, 2001 ellen spertus mcs 111
TRANSCRIPT
Boolean AlgebraBinary Arithmetic
August 28, 2001
Ellen Spertus
MCS 111
2
What you will learn this semester
• Given devices that implement simple boolean functions…
• Understand how a computer works– Build an actual computer that you will
program– Study the MIPS architecture
• Write assembly language programs• Learn the implementation of a MIPS subset
3
How you will learn
• Readings
• Lectures and discussion
• Homework assignments to review lecture material
Lab assignments to apply ideas in depth (every 2-3 weeks)
4
Boolean algebra
• George Boole (1815-1864)
• What is an algebra?
• Boolean values
• Boolean operations
• Boolean functions
5
What is an algebra?
• Term from Hisab al-jabr w'al-muqabala by al-Khwarizmi (~780-850, Baghdad)
• Consists of– a set of values
(e.g., the integers)– a set of functions
• multiplication• addition
6
Expressing functions• What’s a function?
• What are these functions?• Why is this a bad way of expressing a function over the integers?
inputs outputs x f(x) x y f(x, y) 0 1 1 1 1 1 2 2 1 2 2 3 3 2 4 3 4 4 2 5 : : : : :
7
Boolean values
• false • 0• low
• true • 1• high
8
Boolean operations
• identity
• not
• or
• and
• xor (exclusive or)
• nand (not and)
• nor (not or)
9
Identity
x x 0 1
0
Note: Bebop calls this “buf” (for “buffer”).
10
Not
x x 0 1
0
Note: Some people write x’ instead of x. The “bubble” (or “bobble”) means “not”.
11
And
a b a·b 0 0 0 1 1 0 1 1
Notes: Some people write a^b or a&b. The gate is shaped like a “D” as in “anD”.
and01
12
Or
a b a+b 0 0 0 1 1 0 1 1
Note: Some people write ab or a|b.
0
1or
1or
1
13
Exclusive-or (xor)
a b ab 0 0 0 1 1 0 1 1
0
1
1
1
14
Nand
a b a·b a·b 0 0 0 0 1 0 1 0 0 1 1 1
15
Nor
a b a+b a+b 0 0 0 0 1 1 1 0 1 1 1 1
16
What you will learn
• Given devices that implement simple boolean functions…
• Understand how a computer works
17
Base-10 (decimal) arithmetic
• Uses the ten numbers from 0 to 9
• Each column represents a power of 10
Thousands (10 3) column
Hundreds (10 2) column
Tens (10 1) column
Ones (10 0) column
1999 10= 1x10 3 + 9x10 2 + 9x10 1 + 9x10 0
18
Base-2 (binary) arithmetic
• Uses the two numbers from 0 to 1
• Every column represents a power of 2
10012= 1x2 3 + 0x2 2 + 0x2 1 + 1x2 0
Eights (2 3) column
Fours (2 2) column
Twos (2 1) column
Ones (2 0) column
19
Converting from base-2 to base-10
32 16 8 4 2 1 1 0 0 1 = 1 0 1 1 = 1 0 1 0 1 =
1 1 1 1 1 1 =
20
Converting from base-10 to base-2
64 32 16 8 4 2 1 = 16 = 55 = 75 = 84
21
Addition
1 9 9 8 1 0 1 1 + 1 1 + 1 1 2 0 0 9 1 1 1 0
Base-10 Base-2
Note: A binary digit is called a bit. The bit with the lowest exponent (20) is called the least significant bit (LSB). The bit with the highest exponent is the most significant bit (MSB).
22
Practice binary arithmetic
1 0 1 1 1 1 1 + 1 1 + 1
23
Count on your fingers!
How high can you count with– 5 fingers?– 10 fingers?
24
Looking ahead
• For you to do– Complete and turn in information form– Read syllabus and policies– Homework, due Tuesday, September 4
• Coming up – Thursday: Digital computing– Next week: First lab sessions