boolean algebra binary arithmetic august 28, 2001 ellen spertus mcs 111
TRANSCRIPT
![Page 1: Boolean Algebra Binary Arithmetic August 28, 2001 Ellen Spertus MCS 111](https://reader035.vdocuments.site/reader035/viewer/2022062409/5697bfda1a28abf838cafeab/html5/thumbnails/1.jpg)
Boolean AlgebraBinary Arithmetic
August 28, 2001
Ellen Spertus
MCS 111
![Page 2: Boolean Algebra Binary Arithmetic August 28, 2001 Ellen Spertus MCS 111](https://reader035.vdocuments.site/reader035/viewer/2022062409/5697bfda1a28abf838cafeab/html5/thumbnails/2.jpg)
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
![Page 3: Boolean Algebra Binary Arithmetic August 28, 2001 Ellen Spertus MCS 111](https://reader035.vdocuments.site/reader035/viewer/2022062409/5697bfda1a28abf838cafeab/html5/thumbnails/3.jpg)
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)
![Page 4: Boolean Algebra Binary Arithmetic August 28, 2001 Ellen Spertus MCS 111](https://reader035.vdocuments.site/reader035/viewer/2022062409/5697bfda1a28abf838cafeab/html5/thumbnails/4.jpg)
4
Boolean algebra
• George Boole (1815-1864)
• What is an algebra?
• Boolean values
• Boolean operations
• Boolean functions
![Page 5: Boolean Algebra Binary Arithmetic August 28, 2001 Ellen Spertus MCS 111](https://reader035.vdocuments.site/reader035/viewer/2022062409/5697bfda1a28abf838cafeab/html5/thumbnails/5.jpg)
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
![Page 6: Boolean Algebra Binary Arithmetic August 28, 2001 Ellen Spertus MCS 111](https://reader035.vdocuments.site/reader035/viewer/2022062409/5697bfda1a28abf838cafeab/html5/thumbnails/6.jpg)
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 : : : : :
![Page 7: Boolean Algebra Binary Arithmetic August 28, 2001 Ellen Spertus MCS 111](https://reader035.vdocuments.site/reader035/viewer/2022062409/5697bfda1a28abf838cafeab/html5/thumbnails/7.jpg)
7
Boolean values
• false • 0• low
• true • 1• high
![Page 8: Boolean Algebra Binary Arithmetic August 28, 2001 Ellen Spertus MCS 111](https://reader035.vdocuments.site/reader035/viewer/2022062409/5697bfda1a28abf838cafeab/html5/thumbnails/8.jpg)
8
Boolean operations
• identity
• not
• or
• and
• xor (exclusive or)
• nand (not and)
• nor (not or)
![Page 9: Boolean Algebra Binary Arithmetic August 28, 2001 Ellen Spertus MCS 111](https://reader035.vdocuments.site/reader035/viewer/2022062409/5697bfda1a28abf838cafeab/html5/thumbnails/9.jpg)
9
Identity
x x 0 1
0
Note: Bebop calls this “buf” (for “buffer”).
![Page 10: Boolean Algebra Binary Arithmetic August 28, 2001 Ellen Spertus MCS 111](https://reader035.vdocuments.site/reader035/viewer/2022062409/5697bfda1a28abf838cafeab/html5/thumbnails/10.jpg)
10
Not
x x 0 1
0
Note: Some people write x’ instead of x. The “bubble” (or “bobble”) means “not”.
![Page 11: Boolean Algebra Binary Arithmetic August 28, 2001 Ellen Spertus MCS 111](https://reader035.vdocuments.site/reader035/viewer/2022062409/5697bfda1a28abf838cafeab/html5/thumbnails/11.jpg)
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
![Page 12: Boolean Algebra Binary Arithmetic August 28, 2001 Ellen Spertus MCS 111](https://reader035.vdocuments.site/reader035/viewer/2022062409/5697bfda1a28abf838cafeab/html5/thumbnails/12.jpg)
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
![Page 13: Boolean Algebra Binary Arithmetic August 28, 2001 Ellen Spertus MCS 111](https://reader035.vdocuments.site/reader035/viewer/2022062409/5697bfda1a28abf838cafeab/html5/thumbnails/13.jpg)
13
Exclusive-or (xor)
a b ab 0 0 0 1 1 0 1 1
0
1
1
1
![Page 14: Boolean Algebra Binary Arithmetic August 28, 2001 Ellen Spertus MCS 111](https://reader035.vdocuments.site/reader035/viewer/2022062409/5697bfda1a28abf838cafeab/html5/thumbnails/14.jpg)
14
Nand
a b a·b a·b 0 0 0 0 1 0 1 0 0 1 1 1
![Page 15: Boolean Algebra Binary Arithmetic August 28, 2001 Ellen Spertus MCS 111](https://reader035.vdocuments.site/reader035/viewer/2022062409/5697bfda1a28abf838cafeab/html5/thumbnails/15.jpg)
15
Nor
a b a+b a+b 0 0 0 0 1 1 1 0 1 1 1 1
![Page 16: Boolean Algebra Binary Arithmetic August 28, 2001 Ellen Spertus MCS 111](https://reader035.vdocuments.site/reader035/viewer/2022062409/5697bfda1a28abf838cafeab/html5/thumbnails/16.jpg)
16
What you will learn
• Given devices that implement simple boolean functions…
• Understand how a computer works
![Page 17: Boolean Algebra Binary Arithmetic August 28, 2001 Ellen Spertus MCS 111](https://reader035.vdocuments.site/reader035/viewer/2022062409/5697bfda1a28abf838cafeab/html5/thumbnails/17.jpg)
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
![Page 18: Boolean Algebra Binary Arithmetic August 28, 2001 Ellen Spertus MCS 111](https://reader035.vdocuments.site/reader035/viewer/2022062409/5697bfda1a28abf838cafeab/html5/thumbnails/18.jpg)
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
![Page 19: Boolean Algebra Binary Arithmetic August 28, 2001 Ellen Spertus MCS 111](https://reader035.vdocuments.site/reader035/viewer/2022062409/5697bfda1a28abf838cafeab/html5/thumbnails/19.jpg)
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 =
![Page 20: Boolean Algebra Binary Arithmetic August 28, 2001 Ellen Spertus MCS 111](https://reader035.vdocuments.site/reader035/viewer/2022062409/5697bfda1a28abf838cafeab/html5/thumbnails/20.jpg)
20
Converting from base-10 to base-2
64 32 16 8 4 2 1 = 16 = 55 = 75 = 84
![Page 21: Boolean Algebra Binary Arithmetic August 28, 2001 Ellen Spertus MCS 111](https://reader035.vdocuments.site/reader035/viewer/2022062409/5697bfda1a28abf838cafeab/html5/thumbnails/21.jpg)
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).
![Page 22: Boolean Algebra Binary Arithmetic August 28, 2001 Ellen Spertus MCS 111](https://reader035.vdocuments.site/reader035/viewer/2022062409/5697bfda1a28abf838cafeab/html5/thumbnails/22.jpg)
22
Practice binary arithmetic
1 0 1 1 1 1 1 + 1 1 + 1
![Page 23: Boolean Algebra Binary Arithmetic August 28, 2001 Ellen Spertus MCS 111](https://reader035.vdocuments.site/reader035/viewer/2022062409/5697bfda1a28abf838cafeab/html5/thumbnails/23.jpg)
23
Count on your fingers!
How high can you count with– 5 fingers?– 10 fingers?
![Page 24: Boolean Algebra Binary Arithmetic August 28, 2001 Ellen Spertus MCS 111](https://reader035.vdocuments.site/reader035/viewer/2022062409/5697bfda1a28abf838cafeab/html5/thumbnails/24.jpg)
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