Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices...
-
Upload
morgan-washington -
Category
Documents
-
view
215 -
download
0
Transcript of Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices...
![Page 1: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/1.jpg)
Ellen Spertus
MCS 111
October 16, 2001
Review
![Page 2: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/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
August 28 (Boolean Algebra and Binary Arithmetic)
![Page 3: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/3.jpg)
3
Boolean algebra
• Two values: – 0 / false / low / ground– 1 / true / high / power
• Functions– One input: identity, not– Two input:
• and, or, xor• nand, nor
August 28 (Boolean Algebra and Binary Arithmetic)
![Page 4: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/4.jpg)
4
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
August 28 (Boolean Algebra and Binary Arithmetic)
![Page 5: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/5.jpg)
5
Count on your fingers!
How high can you count with– 5 fingers?– 10 fingers?
August 28 (Boolean Algebra and Binary Arithmetic)
![Page 6: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/6.jpg)
6
f1(A)A
A
Bf2(A,B)
f3(A,B)
A
B
Homework 1 (Boolean algebra and binary numbers)
![Page 7: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/7.jpg)
7
From switches to functions
• We can build switches.
• We can build and and not gates from switches.
• We can build from and and not gates.
• Therefore,
August 30 (Digital Computing)
![Page 8: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/8.jpg)
8
Digital computing ~1940
• Boolean logic– true/false– and, or, etc.
• Electronic switches– electromagnetic relays– vacuum tubes
• Binary numbers
August 30 (Digital Computing)
Claude Shannon (1916-2001)
Konrad Zuse(1910-1995)
![Page 9: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/9.jpg)
9
Big Picture
• Any number can be represented as 0s and 1s• Functions can be represented as a table• Any table of 0s and 1s can be interpreted as
a truth table• Any truth table can be converted into a
boolean function• We can implement boolean functions with
switches
September 4 (Karnaugh Maps)
![Page 10: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/10.jpg)
10
Karnaugh Maps
What purpose do they serve?
![Page 11: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/11.jpg)
11
Rules for Karnaugh maps
• Label each axis with a gray code, i.e., only change one bit at a time.
• Regions can stretch horizontally or vertically.
• Each side of a region must be a power of 2 (e.g., 1, 2, or 4).
• For simplest formula, choose ________ region and make use of “don’t care”s.
• Regions may wrap around the edges.September 4 (Karnaugh Maps)
![Page 12: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/12.jpg)
12
Big Picture
• Any number can be represented as 0s and 1s.
• Any table of 0s and 1s can be interpreted as a truth table.
• We can implement boolean functions with switches.
Any truth table can be converted into a boolean function.
September 4 (Karnaugh Maps)
![Page 13: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/13.jpg)
13
Types of logic
• Combinational logic– No loops– Output only depends on current inputs
• Sequential logic– Loops– Output depends on current inputs and past
state– Can implement memory
September 13, 18 (Combinational Logic)
![Page 14: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/14.jpg)
14
R-S latchR S Q(n+) ~Q(n+) 0 0 Q(n) ~Q(n) 0 1 1 0 1 0 0 1 1 1 0 0
R
S
Q
~Q
September 13, 18 (Combinational Logic)
![Page 15: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/15.jpg)
15
RS-latch dangerous transition
R
S
Q
~Q
1 0
1 0 0
0
September 13, 18 (Combinational Logic)
![Page 16: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/16.jpg)
16
D-latch
R
S
Q
~QD
E
Prevents dangerous transition.
September 13, 18 (Combinational Logic)
![Page 17: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/17.jpg)
17
D-latch behavior
D E R S behavior 0 0 0 1 1 0 1 1
enable
data Q
~QD
September 13, 18 (Combinational Logic)
When E is _____, Q = D. Otherwise, Q keeps its old value.
![Page 18: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/18.jpg)
18
D flip-flop
Passes data through on rising edge of clock.
QD
~Q
data Q data Qdata
enable enable
clock
Q
September 13, 18 (Combinational Logic)
![Page 19: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/19.jpg)
19
Clocks
• Most computers have a “clock” that generates a “square wave”
• Clock cycle time is measured in seconds
• Clock frequency is measured in Hertz (cycles per second)
• Example– Clock cycle time: .1 s– Clock frequency: 10 Hz
September 13, 18 (Combinational Logic)
![Page 20: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/20.jpg)
20
Common prefixes
• giga- (G): billion (109)
• mega- (M): million (106)
• kilo- (K or k): thousand (103)
• milli (m): one-thousandth (10-3)
• micro (): one-millionth (10-6)
• nano (n): one-billionth (10-9)
September 13, 18 (Combinational Logic)
![Page 21: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/21.jpg)
21
Converting time to frequency
210 ns = 2.1 102 ns (cycle time of IBM PC)
= 2.1 102 10-9 s
= 2.1 10-7 s
frequency = 1/(2.1 10-7) Hz
= 1/(2.1) 107 Hz
.5 107 Hz
5 106 Hz
5 MHz (actually, 4.77 MHz)
September 13, 18 (Combinational Logic)
![Page 22: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/22.jpg)
22
Counter (Lab 1B)
D flip-flop– Remembers current counter value– Acts as a barrier for the counter value
data QD
flipflop
ALU
1
44
4
4
clock
September 13, 18 (Combinational Logic)
![Page 23: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/23.jpg)
23
Big picture
Java/Pascal/C code
Assembly language
Machine language
Hardware
count = index + 1
add $s1, $s2, 1
00010111 00010010 00000001
September 20 (Assembly Language)
![Page 24: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/24.jpg)
24
Data storage and use
• Registers– 32 locations– Each 32 bits wide– Can operate on them
directly:• add, sub, slt, …• sll, srl• beq, bne, …• mul• not, and, or
• Main memory (RAM)– Millions of locations– Each 8 bits (1 byte) wide– Cannot operate on them
directly• lw loads word from
memory into register• sw stores word from
register into memory
September 20 (Assembly Language)
![Page 25: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/25.jpg)
25
Storing words in bytes
address contents
0 00000000two
1 00000000two
2 00000000two
3 00000001two
: :
• Little-endian The “little end”
(least significant byte) is stored first in memory.
• Big-endian The “big end”
(most significant byte) is stored first in memory.
September 20 (Assembly Language)
![Page 26: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/26.jpg)
26
Scalars vs. arrays
• Scalar variable– Single item, e.g., count– Takes up one word of memory
• Array– Many items, e.g., a[0]…a[7]– Each element takes up one word of
memory
September 27 (Arrays and Loops)
![Page 27: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/27.jpg)
27
Rules for accessing arrays
• The array is stored somewhere in memory. Put the address of the base (beginning) of the array into a register.
• Assuming each element of the array is one word (4 bytes) long, the offset (distance from base) of element n is 4*n.
September 27 (Arrays and Loops)
![Page 28: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/28.jpg)
28
Procedure calls
Caller 200: add $a0, $zero, 3 204: add $a1, $zero, 6 208: jal sum 212: ...
Callee
sum: 500: add $v0, $a0, $a1 504: jr $ra
Program counter (PC):
Return address ($ra):
October 2 (Procedure Calls)
![Page 29: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/29.jpg)
29
Factorialfact: # Store callee-saved values subi $sp, $sp, 8 # create space on stack for two items sw $ra, 4($sp) # store $ra (return address) on stack sw $a0, 0($sp) # store $a0 (n) on stack bne $a0, $zero, else_clause # if (n>0) goto else_clause # Base case addi $v0, $zero, 1 # prepare to return the value 1 addi $sp, $sp, 8 # return stack pointer to its original value jr $ra # return to caller
else_clause: subi $a0, $a0, 1 # n = n - 1 jal fact # make recursive call lw $ra, 4($sp) # restore $ra from stack lw $a0, 0($sp) # restore $a0 from stack addi $sp, $sp, 8 # return stack pointer to its original value mult $v0, $v0, $a0 # multiply fact(n-1)*n jr $ra # return to caller
Note: Save any values that you may need later onto the stack.
October 2 (Procedure Calls)
![Page 30: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/30.jpg)
30
Representations of numbers
• What’s the point?
Homework 6 (Beyond positive integers)
![Page 31: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/31.jpg)
31
Conversion to two’s complement
• To negate a number– Flip the bits– Add one
• Practice-2110
610
-15010
Homework 6 (Beyond positive integers)
±128 64 32 16 8 4 2 1
![Page 32: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/32.jpg)
32
Conversion from two’s complement
• To negate a number– Flip the bits– Add one
• Practice11110011
10001100
11111111Homework 6 (Beyond positive integers)
±128 64 32 16 8 4 2 1
![Page 33: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/33.jpg)
33
Signed instructions
Assume that memory location 50 contains the value 150ten (10100000two)
lb $t0, 50($zero)
lbu $t1, 50($zero)
slt $t2, $t0, $t1
sltu $t3, $t0, $t1
Homework 6 (Beyond positive integers)
![Page 34: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/34.jpg)
34
Upper-case letters
Representations:– Characters
• A –• Z
– ASCII decimal• 65 –• 90
– ASCII binary• 01000000 –• 01010000
Homework 6 (Beyond positive integers)
![Page 35: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/35.jpg)
35
upperCase (1)
# if argument < ‘A’, return 0
slti $t0, $a0, 65 # ‘A’
beq $t0, $zero, lab1
add $v0, $zero, $zero
jr $ra
lab1:
# Return whether argument <= ‘Z’
slti $t0, $a0, 91 # ‘Z’ + 1
add $v0, $t0, $zero
jr $ra
Homework 6 (Beyond positive integers)
![Page 36: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/36.jpg)
36
upperCase (2)
srl $t0, $a0, 5 # shift right 5
li $t1, 2 # load 2
beq $t0, $t1, yes # compare to 2
li $v0, 0 # return false
jr $ra
yes:
li $v0, 1 # return true
jr $ra
Homework 6 (Beyond positive integers)
![Page 37: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/37.jpg)
37
Floating-point numbers
• Representation (October 9)– Sign bit– Significand– Exponent
• Addition (October 11)– How to– Overflow, underflow– Limited precision
![Page 38: Ellen Spertus MCS 111 October 16, 2001 Review. 2 What you will learn this semester Given devices that implement simple boolean functions… Understand how.](https://reader035.fdocuments.net/reader035/viewer/2022062519/5697c0301a28abf838cdaab2/html5/thumbnails/38.jpg)
38
Summary
Using nothing more than a bunch of ____________, we can perform computations on:positive and negative integersfractionscharacters– MIPS assembly instructions– Java programs