Professional Documents
Culture Documents
ECE 120: Introduction to Computing © 2016 Steven S. Lumetta. All rights reserved. slide 1 ECE 120: Introduction to Computing © 2016 Steven S. Lumetta. All rights reserved. slide 2
ECE 120: Introduction to Computing © 2016 Steven S. Lumetta. All rights reserved. slide 3 ECE 120: Introduction to Computing © 2016 Steven S. Lumetta. All rights reserved. slide 4
10/21/2016
Use Keyless Entry as a Motivating Example A List of Abstract States Need Only List States
meaning state
driver’s other alarm In a list of abstract states,
door doors on? ◦ we can just list the states.
vehicle
locked
LOCKED locked locked no ◦ Adding human meanings is optional
(good to have if state names are generic).
driver door
DRIVER unlocked locked no
unlocked Including outputs
all doors
UNLOCKED unlocked unlocked no ◦ is also optional,
unlocked
◦ and implies that
alarm
ALARM locked locked yes outputs depend only on state.*
sounding
*An extra assumption that we will always make in our class.
Table is a list of abstract states.
ECE 120: Introduction to Computing © 2016 Steven S. Lumetta. All rights reserved. slide 5 ECE 120: Introduction to Computing © 2016 Steven S. Lumetta. All rights reserved. slide 6
An Abstract Next-State Table Captures Expected Behavior Abstract Next-State Table Does Not Answer All Questions
To specify transitions, we use a next-state We wrote transitions for typical use cases, but
table, which maps combinations of states and the table can be incomplete, ambiguous,
inputs into next states. and even inconsistent.
This is an abstract next-state table. For example, what happens if the user pushes
“lock” and “unlock” at the same time?
state action/input next state state action/input next state
LOCKED push “unlock” DRIVER LOCKED push “unlock” DRIVER
DRIVER push “unlock” UNLOCKED DRIVER push “unlock” UNLOCKED
(any) push “lock” LOCKED (any) push “lock” LOCKED
(any) push “panic” ALARM (any) push “panic” ALARM
ECE 120: Introduction to Computing © 2016 Steven S. Lumetta. All rights reserved. slide 7 ECE 120: Introduction to Computing © 2016 Steven S. Lumetta. All rights reserved. slide 8
10/21/2016
Many Design Decisions are Usually Needed Abstract State Transition Diagram: the Same Information
push
All such design decision questions should “lock”
eventually be considered, and preferably push “unlock”
We can LOCKED DRIVER
answered. represent the push “lock”
Be aware: any digital logic same
push “panic”
push “unlock”
implementation will define answers. information
push “lock”
push
Only when any possible answer is acceptable as a graph “panic”
should you make use of “don’t cares.” called an
abstract state
Typically, you should review the final transition
push
implementation to determine how any “lock”
questions left open are answered. diagram. ALARM
UN-
push push “panic” LOCKED
“panic”
ECE 120: Introduction to Computing © 2016 Steven S. Lumetta. All rights reserved. slide 9 ECE 120: Introduction to Computing © 2016 Steven S. Lumetta. All rights reserved. slide 10
It’s Time to Make Our Design Complete and Concrete Let’s Start with the State Identifiers
The abstract next-state table and the abstract How many bits do we need
state transition diagram (can) contain to identify a state?
exactly the same information.
There are 4 states.
They answer the same questions. .
And neither is complete.
ECE 120: Introduction to Computing © 2016 Steven S. Lumetta. All rights reserved. slide 11 ECE 120: Introduction to Computing © 2016 Steven S. Lumetta. All rights reserved. slide 12
10/21/2016
All Outputs and Inputs Must Also Use Bits We Next Choose a Representation for States
What about outputs? Now we can choose a representation for states
D driver door; 1 means unlocked and rewrite our list of states.
R remaining doors; 1 means unlocked The order of states in the list doesn’t matter.
A alarm; 1 means alarm is sounding meaning state S1 S 0 D R A
And inputs? vehicle locked LOCKED 00 0 0 0
U unlock button; 1 means it’s been pressed driver door unlocked DRIVER 10 1 0 0
L lock button; 1 means it’s been pressed all doors unlocked UNLOCKED 11 1 1 0
P panic button; 1 means it’s been pressed
alarm sounding ALARM 01 0 0 1
ECE 120: Introduction to Computing © 2016 Steven S. Lumetta. All rights reserved. slide 13 ECE 120: Introduction to Computing © 2016 Steven S. Lumetta. All rights reserved. slide 14
Choice of Representation Affects Amount of Logic Needed Use to Denote the Next State (in Next Clock Cycle)
As you may realize The +’s in indicate that these are values
◦ from your experience with bit-sliced designs, in the next clock cycle.
◦ the representation does matter Let’s rewrite the next-state table with bits.
(for the amount of logic needed). ◦ The table gives us as a function of
We will talk more later about ways to choose. current state S1S0 and inputs ULP.
◦ Such tables typically use binary order for
states (vertical) and inputs (horizontal).
◦ We use Grey code order on both axes for
convenience (in copying to K-maps).
ECE 120: Introduction to Computing © 2016 Steven S. Lumetta. All rights reserved. slide 15 ECE 120: Introduction to Computing © 2016 Steven S. Lumetta. All rights reserved. slide 16
10/21/2016
How to Fill in the Next-State Table Completing the Design Requires Decisions
ECE 120: Introduction to Computing © 2016 Steven S. Lumetta. All rights reserved. slide 17 ECE 120: Introduction to Computing © 2016 Steven S. Lumetta. All rights reserved. slide 18
Make Design Decisions Early When Possible Start by Deciding How to Handle Multiple Buttons
ECE 120: Introduction to Computing © 2016 Steven S. Lumetta. All rights reserved. slide 19 ECE 120: Introduction to Computing © 2016 Steven S. Lumetta. All rights reserved. slide 20
10/21/2016
Start with the Panic Button (Highest Priority) Continue with the Lock Button (Second Priority)
What if the user pushes nothing? Two transitions were defined for Unlock.
current ULP current ULP from LOCKED
state state
S1S0 000 001 011 010 110 111 101 100 S1S0 000 001 011 010 110 111 101 100
00 00 01 01 00 00 01 01 00 00 01 01 00 00 01 01 10
01 01 01 01 00 00 01 01 01 01 01 01 00 00 What01
01 about
11 11 01 01 00 00 01 01 11 11 01 01 00 00 01 these?
01
10 10 01 01 00 00 01 01 10 10 01 01 00 00 01 01 11
What should happen if we press “unlock” Ignore Unlock in both other cases.
when the car is already fully unlocked current ULP from ALARM
(in the UNLOCKED state)? state
S1S0 000 001 011 010 110 111 101 100
Maybe just stay UNLOCKED.
00 00 01 01 00 00 01 01 10
What should happen if we press “unlock”
while the alarm is sounding? 01 01 01 01 00 00 01 01 01
◦ Continue to lock out an attacker / thief? 11 11 01 01 00 00 01 01 11
◦ Or open the doors so that the owner can 10 10 01 01 00 00 01 01 11
climb inside quickly?
from UNLOCKED
ECE 120: Introduction to Computing © 2016 Steven S. Lumetta. All rights reserved. slide 25 ECE 120: Introduction to Computing © 2016 Steven S. Lumetta. All rights reserved. slide 26
The Rest You Know How to Do One Last Tool: the Complete State Transition Diagram
The rest is K-maps, expressions, and logic. The complete state transition diagram
1. Express and in terms contains the information in both the
of S1, S0, U, L, and P. state list and the next-state table.
2. Express D, R, and A in terms of S1, S0.
inputs for this transition
3. Build the combinational logic.
state ID / outputs
4. Put the next state expressions and ULP = _ _ _
into the D inputs of two flip-flops.
You should do it as an exercise. Break up the STATE
truth tables or use 5-variable K-maps. S1S0/DRA
ECE 120: Introduction to Computing © 2016 Steven S. Lumetta. All rights reserved. slide 27 ECE 120: Introduction to Computing © 2016 Steven S. Lumetta. All rights reserved. slide 28
10/21/2016
ULP=100
multiple next states).
ULP=xx1
ULP = x00
ULP=x10
ULP=xx1
For example,
◦ self-loop from ALARM labeled ULP=xx1,x0x:
ULP=
ULP=000 ◦ the patterns x01 match both labels!
x10
ALARM
UN- or 100 ◦ In this case, these two combinations go
01/001
LOCKED to the same next state, so it’s ok.
ULP=xx1 11/110
ULP=xx1,x0x
ECE 120: Introduction to Computing © 2016 Steven S. Lumetta. All rights reserved. slide 29 ECE 120: Introduction to Computing © 2016 Steven S. Lumetta. All rights reserved. slide 30