Title: Midterm Review
1Midterm Review
2Administrivia The Midterm
- Problem solving
- What logic gates do
- How to build circuits that realize truth tables
- Addition circuitry
- Memory
- State machines to model situations
- Building the logic for state machines
- Putting it together to build a computer
- Programming the computer using machine language
- Representing information
- Understanding key ideas
- Von Neumann machine
- Moores law
3Extra Midterm help
- DPD office hours Wednesday 24
- My office, CS 219
- Check with qlv and wtcorrea for other hours
4More for Less --Moores Law
- Everything doubles every 18 months
- Memory/dollar
- Disk/dollar
- Transistors per inch
- Processor speed
- Network bandwidth
5Practical Details
- Problem sets 20
- Lab reports 10
- Midterm exam 25
- Final exam 25
- Class Participation 20
6Building a computer
7Layers of Abstraction
- Build more and more powerful tools out of simpler
ones.
Really Simple Stuff
Computers
8A Simple Logic Puzzle
- Frank will go to the party if Ed goes
AND Dan does NOT. - Dan will go if Bob does NOT go OR if Carole goes.
- Ed will go to the party if Alice AND Bob go.
- Alice and Bob decide to go,but Carol stays home.
- Will Frank go to the party?
9Using 0s and 1s
- What do 0s and 1s mean?
- For now, well take Natural meanings
- For example, if we have a variable Alice
forwhether Alice goes to the party, - If Alice goes, we write Alice 1
- If Alice doesnt, we write Alice 0
0 False
1 True
10Logic Gates
- Computers are circuits made of Logic Gates.
- Logic gates manipulate 0s and 1s (False and
True) by letting electrons flow or not. - Well look at three types of Logic Gates
- AND are all inputs true?
- OR is one input true?
- NOT flip the truth value
11AND Gate
W X Y Z 0 0 0 0 0 0 1 0 0 1 0 0 0 1
1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1 1
12OR Gate
W
Z
W X Y Z 0 0 0 0 0 0 1 1 0 1 0 1 0 1
1 1 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1 1
X
Y
13NOT Gate
- Yanni will go to the party if Xena does NOT go.
Y
X
Shorthand
X
Y
X Y 0 1 1 0
Truth Table
14Logic Puzzle Circuit
Alice
Ed
Frank
Bob
Dan
Carole
Dan will go if Bob does NOT go OR if Carole goes.
15Given Any Truth Table
A B C F 0 0 0 0 0 0 1 1 0 1 0 1 0 1
1 0 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 0
16Given Any Truth Table
A B C F 0 0 0 0 0 0 1 1 0 1 0 1 0 1
1 0 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 0
A
B
C
A
B
C
A
B
C
Build AND gate for each output 1
17Given Any Truth Table
A
Finally, combine ANDswith an OR gate.
B
C
A
F
B
C
A
Can build logic for any Truth table this way
B
C
18Universality
- Note same idea works no matter how manyinput
variables. So for ANY Truth Table we can write
down,we can make a circuit for it using only 3
Logic Gates AND, OR, NOT - This gives us a very powerful tool !
- But, in practice, we are limited in size we can
realize numeracy exercise.
19Our First Abstract Tool
Universal Method Circuits for ANY Truth Table
0s 1s
Universal Method
Computers
We are here
20Powers of 2 (cont.)
- Some rough numbers
- 210 ? 1,000 (103 ) kilo
- 220 ? 1,000,000 (106 ) mega RAM
- 230 ? 109 giga disk
- 240 ? 1012 tera BIG disk
- 250 ? 1015 peta
- 260 ? 1018 exa knowledge
21Representing Information
- We represent information with 0s and 1s
- Numbers
- Use binary or hexadecimal
- Letters
- Use ASCII
- Sounds
- Use samples
- Images
- Use pixels
22Adding Binary Numbers
X
Y
sum
X
Y
X
carry
Y
23Addition
We can use 1 building block to add numbers of any
length. Black box operation
ith bit of X
ith bit of Z
ith bit of Y
carry bit out
carry bit
Abstraction in action -- This is a piece of a
carry-ripple adder
24Carry-Ripple Adder
Z1
Z2
Universal Circuit For Z2 and carry
X2
Z0
Universal Circuit For Z2 and carry
X1
Universal Circuit
X0
C2
Y2
Y0
Y1
C1
C0
0
Fixed at 0
X2 X1 X0 Y2 Y1
Y0 C2 Z2 Z1 Z0
25Memory
26Enter Rita
- Matt doesnt like Rita
- Matt decides to go to the party if Sue decides to
go OR - If he (Matt) already feels like going AND Rita
decides NOT to go.
Sue
Matt
Rita
Feedback Wire
27The Flip-Flop
Set
M
Reset
- M becomes 1 if Set is turned on
- M becomes 0 if Reset is turned on
- Otherwise (if Set and Reset are both 0), M just
remembers its value
28The Flip-Flop
S
M
R
- M becomes 1 if Set is turned on
- M becomes 0 if Reset is turned on
- Otherwise (if Set and Reset are both 0), M just
remembers its value
29The Data Flip-Flop
D
M
Write
- If Write 0, M just keeps its value.(It ignores
D.) - If Write 1, then M becomes set to D
30RAM
- Group 8 of them together.
- 8 bits (b)is called abyte (B).
- Most RAMis arrangedin bytes.
31RAM (cont.)
- We want a HUGE number of such 1 byte memory
cells. - Problem How do we indicate which byte ofmemory
we want to use at any given time?
32RAM (cont.)
20 bits of address
Address
Data Output
Data input
Write
8 bits (1 byte)of data
33Review
On our way to building a computer
Represent Info with 0s 1s (aka bits)
Logic Circuits Universal Method
0s 1s
Memory Circuits
Computers
We are here
34The System Clock
- 500 Mhz Pentium III computer
- What does 500 Mhz mean?
- It refers to the speed of the System
Clock. (actually this is only one of the
clocks) - All digital systems have such Clocks, even
traffic lights and elevator control systems.
35Our System A Traffic Light
36A Traffic Light
- Intersection of two one-way roads
A
B
Car Sensors
37Traffic Light Behavior
Otherwise
NoteClock beats every 4 sec.So Light is
Yellow for 4 sec.
IF A1 AND B0
Light A
Always
Always
IF A0 AND B1
Otherwise
Light B
38Traffic Light State Machine
Otherwise
NoteClock beats every 4 sec.So Light is
Yellow for 4 sec.
IF A1 AND B0
Light A
Always
Always
IF A0 AND B1
Otherwise
Light B
39Traffic Light States
Otherwise
IF A1 AND B0
01
00
Light A
Always
Always
IF A0 AND B1
11
10
Otherwise
Light B
40Traffic Light Behavior
Build A Truth Table for next state / Output
41Traffic Light Design
Current State
2-bit Memory Register
Logic For Next State Output
Clock
Sensor A
6 Outputs for eachLight
Sensor B
42Design for Any State Machine
Manybits
Current State
Memory Register
Logic For Next State Output
Clock
Inputs
Outputs
43State Machinesin Real Life
- Elevator control systems
- Car control systems
- VCRs
- Alarm Clocks
- Personal Computers
- Just about everything!
44Computers
45Computer Architecture
CPU
Keyboard
Display
Bus
Hard Disk
CD-ROM
RAM
46The Bus
- Communication on the bus is via postcards
- CPU puts Keyboard, did the user type anything?
(represented in some way) on the Bus.
CPU
Keyboard
Display
Bus
Keyboard, did the user type anything?
47The Bus
- Each device (except CPU) is a State Machine that
constantly checks to see whats on the Bus.
CPU
Keyboard
Display
Bus
Keyboard, did the user type anything?
48The Bus
- Keyboard notices that its name is on the Bus,and
reads info. Other devices ignore the info.
CPU
Keyboard
Display
Bus
Keyboard, did the user type anything?
49The Bus
- Keyboard then writes CPU Yes, user typed a.
to the Bus.
CPU
Keyboard
Display
Bus
CPU Yes, user typed a.
50The Bus
- At some point, CPU reads the Bus, and getsthe
Keyboards response.
CPU
Keyboard
Display
Bus
CPU Yes, user typed a.
51The CPU (cont.)
Memory Registers
Control Unit(State Machine)
52Important Point
- One of the important features of the von Neumann
model is the fact that - The instructions themselves
- And
- The data the instructions manipulate
- are all stored in the same RAM.
- This was one of the revolutionary features of the
modern computer, totally unlike Punch-Card
computers proposed in the past.
53Important Point
- This innovation is crucial to modern computing.
- It even allows for the possibility of programs
that change themselves as they are executed. - With great power comes great risk
- Computer Viruses!
54Machine Language
- We now have a machine that can execute
instructions. - Basic Questions
- What instructions?
- How do computers understand these instructions?
(Representation) - What does software look like to acomputer?
55Instructions
0 halt 1 add 2 subtract 3 multiply 4 bus
output 5 jump 6 jump if positive 7 jump
count 8 bus input 9 load A store B load
direct/addr. C NAND D AND E Shift Right F
Shift Left
56Adding Numbers
- Simple Program to calculate1 2 3 4 5 6
21 15 (hex)
10 Load R0 ? 0001 (always 1) 11 Load R2 ?
0000 (running total) 12 Load R1 ? 0001
(current number) 13 Add R2 ? R2 R1
(R21) 14 Add R1 ? R1 R0 (R12) 15 Add
R2 ? R2 R1 (R23) 16 Add R1 ? R1 R0
(R13) 17 Add R2 ? R2 R1 (R26) 18 Add
R1 ? R1 R0 (R14) 19 Add R2 ? R2 R1
(R2A) 1A Add R1 ? R1 R0 (R15) 1B Add
R2 ? R2 R1 (R2F) 1C Add R1 ? R1 R0
(R16) 1D Add R2 ? R2 R1 (R215) 1E halt
57Adding Numbers
- Alternate Loop using Jump Count for1 2 3
4 5 N
10 Load R1 ? 0006 (N) 11 Load R2 ?
0000 (running total) 12 Add R2 ? R2
R1 (add in N) 13 Jump to 12 and
(If N isnt 0 yet, decrease R1 if (R1gt0)
Let NN-1, and go back) 14 halt
(N is now 0, and R2 12N)
58Sound is a waveform
59Sampling the waveform
60The approximation
61Even finer sampling
62Digital vs. Analog
- A sound file is just a sequence of bytes
- On a CD, the sampling rate is 44,100 samples per
second. Each sample is quantized into a number in
the range from 0 to 65,535, So a CD has 44,100
numbers (each 2 bytes) per channel per second of
music. - A graphic image is just a sequence of bytes
- An image is made up of pixels
- Each pixel might be represented by 3 bytes giving
color intensities. - Manipulating sounds or images just involves
manipulating numbers
63Numeracy
- CD has 44,100 2 byte samples per second.
- 44,100 x 2 x 60 x 2 (channels) 10.09 megabytes
per CD minute - A CD is 74 minutes (746 megabytes) long.
- MP3 players typically use memory 32 or 64
megabytes in size. (or 3-6 minutes) - Compression is needed
64The need for compression
- A CD is 746 megabytes long
- A printed page requires 86.4 Megabytes of storage
65Simple compression
- Simple compression
- Use redundancy
- More complex compression
- Lossy vs. lossless
- Ideas for lossy
- Drop frequencies you cant hear
- Drop small differences you wont notice
66More complex compression
- Lossy compression
- Can save space by eliminating parts of the
image/sound that dont matter very much - Big savings compared to lossless, but the signal
cannot be fully recovered. - Ideas
- Dropping frequencies you cant hear
- Dropping small differences you wont notice
- Generally large savings compared to lossless
67Pause for experiment