introduction to computer engineering { eecs...
TRANSCRIPT
Introduction to Computer Engineering – EECS 203http://ziyang.eecs.northwestern.edu/∼dickrp/eecs203/
Instructor: Robert DickOffice: L477 TechEmail: [email protected]: 847–467–2298
TA: Neal OzaOffice: Tech. Inst. L375Phone: 847-467-0033Email: [email protected]
TT: David BildOffice: Tech. Inst. L470Phone: 847-491-2083Email: [email protected]
Finite State MachinesFlip Flops
DebouncingHomework
Outline
1. Finite State Machines
2. Flip Flops
3. Debouncing
4. Homework
2 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
Word description to state diagram
Design a vending machine controller that will release (outputsignal r) an apple as soon as 30¢ have been inserted
The machine’s sensors will clock your controller when an eventoccurs. The machine accepts only dimes (input signal d) andquarters (input signal q) and does not give change
When an apple is removed from the open machine, it indicatesthis by clocking the controller with an input of d
The sensors use only a single bit to communicate with thecontroller
3 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
Word description to state diagram
We can enumerate the inputs on which an apple should bereleased
ddd + ddq + dq + qd + qq
d(dd + dq + q) + q(d + q)
d(d(d + q) + q) + q(d + q)
For d , i = 0, for q, i = 1
0(0(0 + 1) + 1) + 1(0 + 1)
4 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
Word description to state diagram
1
0
0
1
0
1
0
0
1
0(0(0 + 1) + 1) + 1(0 + 1)
1
A/0
B/0
C/0
D/1
E/0
0
0
1
X
0(0(0 + 1) + 1) + 1(0 + 1)
X
1
X
A/0
B/0
C/0
D/1
E/0
0
0
1
X
0(0(0 + 1) + 1) + 1(0 + 1)
X
1
A/0
B/0
C/0
D/1
5 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
Word description to state diagram
1
0
0
1
0
1
0
0
1
0(0(0 + 1) + 1) + 1(0 + 1)
1
A/0
B/0
C/0
D/1
E/0
0
0
1
X
0(0(0 + 1) + 1) + 1(0 + 1)
X
1
X
A/0
B/0
C/0
D/1
E/0
0
0
1
X
0(0(0 + 1) + 1) + 1(0 + 1)
X
1
A/0
B/0
C/0
D/1
5 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
Word description to state diagram
1
0
0
1
0
1
0
0
1
0(0(0 + 1) + 1) + 1(0 + 1)
1
A/0
B/0
C/0
D/1
E/0
0
0
1
X
0(0(0 + 1) + 1) + 1(0 + 1)
X
1
X
A/0
B/0
C/0
D/1
E/0
0
0
1
X
0(0(0 + 1) + 1) + 1(0 + 1)
X
1
A/0
B/0
C/0
D/1
5 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
State diagram to state table
Currentnext
statestate output (r)
i=0 i=1
A B E 0B C D 0C D D 0D A A 1E D D 0
6 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
Moore block diagram
combinational logic
sequential elements
combinational logic
feedback
inputs
outputs
7 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
Mealy block diagram
combinational logic
sequential elements
outputs
inputs
feedback
8 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
Moore FSMs
0
0
1
1
1
00 1
D/1
A/0 B/0
C/0
9 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
Mealy FSMs
1/X
1/0
0/0
0/0
0/1
1/0
1/1
0/1
CD
BA
10 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
Mealy tabular form
s+/qs 0 1
A D/0 B/XB C/1 B/0C A/0 B/1D C/1 C/0
11 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
FSM design summary
Specify requirements in natural form
Manually derive state diagram
Automatic way to go from English to FSM, however more theoryrequiredCan minimize state count, however, more theory also requiredSee me if you want more information on this, or take a compilerscourse and a graduate-level switching theory course, or take myECE 303
Assign values to states to minimize logic complexity
Optimize implementation of state and output functions
12 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
Outline
1. Finite State Machines
2. Flip Flops
3. Debouncing
4. Homework
13 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
Back to latches
Latches: Level sensitive
Flip-flops: Edge-triggered
14 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
Review: Clocking conventions
D Q
CLK
Active-high transparent
D Q
CLK
Active-low transparent
Positive (rising) edge Negative (falling) edge
D Q D Q
CLKCLK
15 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
Latch and flip-flop equations
RS
Q+ = S + R Q
D
Q+ = D
16 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
Latch and flip-flop equations
JK
Q+ = J Q + K Q
T
Q+ = T ⊕ Q
17 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
JK latch
R−S
latch
K
J S
R
Q
Q
Use output feedback to ensure that RS 6= 11Q+ = Q K + Q J
18 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
JK latch
J K Q Q+
0 0 0 0hold
0 0 1 1
0 1 0 0reset
0 1 1 0
1 0 0 1set
1 0 1 1
1 1 0 1toggle
1 1 1 0
19 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
JK race
100 Set Reset Toggle
Race Condition
J
K
Q
Q
20 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
Falling edge-triggered D flip-flop
Use two stages of latches
When clock is high
First stage samples input w.o. changing second stageSecond stage holds value
When clock goes low
First stage holds value and sets or resets second stageSecond stage transmits first stage
Q+ = D
One of the most commonly used flip-flops
21 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
Falling edge-triggered D flip-flop
DD
lk=
RR
SS
00
00
DD
DDDD
=1
DD
C
Clock high22 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
Falling edge-triggered D flip-flop
Holds D when
clock goes low
Holds D when
clock goes low
Q
Q
DD
Clk=1
RR
SS
00
00
DD
DDDD
=
DD
Clock switchingInputs sampled on falling edge, outputs change after falling edge
23 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
Falling edge-triggered D flip-flop
?
Clk=
RR
SS
D
0
DDDD
=
RR
SS
DD
0
D
Clock low24 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
Another view of an edge-triggered DFF
Q
D
clk
R
R Q
R Q
S
S Q
QS
Q
Q
25 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
Edge triggered timing
Positive edge−
t riggered FF
Negative edge−
t riggered FF
100
D
CLK
Qpos
Qpos
Qneg
Qneg
26 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
RS clocked latch
Storage element in narrow width clocked systems
Dangerous
Fundamental building block of many flip-flop types
27 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
JK flip-flop
Versatile building block
Building block for D and T flip-flops
Has two inputs resulting in increased wiring complexity
Edge-triggered varieties exist
28 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
D flip-flop
Minimizes input wiring
Simple to use
Common choice for basic memory elements in sequential circuits
29 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
Outline
1. Finite State Machines
2. Flip Flops
3. Debouncing
4. Homework
30 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
Debouncing
Mechanical switches bounce!
What happens if multiple pulses?
Mutliple state transitions
Need to clean up signal
31 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
Schmitt triggers
A B
A
Low
High
32 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
Schmitt triggers
A B
A
Low
High
VTL
VTH
32 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
Schmitt triggers
A B
A
Low
High
VTL
VTH
32 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
Schmitt triggers
transition
A B
A
Low
High
VTL
VTH
32 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
Schmitt triggers
transition
B
A B
A
Low
High
VTL
VTH
32 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
Debouncing
0
1
2
3
4
5
-1.0e-03 -5.0e-04 0.0e+00 5.0e-04 1.0e-03 1.5e-03
V
T (s)
Schmitt trig.RC
0.751.65
33 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
Outline
1. Finite State Machines
2. Flip Flops
3. Debouncing
4. Homework
34 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
Assigned reading
M. Morris Mano and Charles R. Kime. Logic and ComputerDesign Fundamentals. Prentice-Hall, NJ, fourth edition, 2008
Review Sections 5.1–5.7
If FSMs don’t make sense now, please ask questions, or see meFSMs are tricky at first – Almost everybody has this moment ofepiphany at which they suddenly make sense
Section 9.1–9.6
35 R. Dick Introduction to Computer Engineering – EECS 203
Finite State MachinesFlip Flops
DebouncingHomework
Computer geek culture references
Parsers and lexical analyzers
Writing problem-specific languages
A. V. Aho, R. Sethi, and J. D. Ullman. Compilers principles,techniques, and tools. Addison-Wesley, MA, 1986
Lex and yacc
Flex and bison
36 R. Dick Introduction to Computer Engineering – EECS 203