1 ee121 john wakerly lecture #12 pld-based state machine structures with statements finite-memory...

24
1 EE121 John Wakerly Lecture #12 PLD-based state machine structures WITH statements Finite-memory state-machine design PLD-based state-machine design

Upload: opal-payne

Post on 18-Jan-2016

243 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 EE121 John Wakerly Lecture #12 PLD-based state machine structures WITH statements Finite-memory state-machine design PLD-based state-machine design

1

EE121 John Wakerly Lecture #12

PLD-based state machine structures

WITH statements

Finite-memory state-machine design

PLD-based state-machine design

Page 2: 1 EE121 John Wakerly Lecture #12 PLD-based state machine structures WITH statements Finite-memory state-machine design PLD-based state-machine design

2

PLD-based state-machine

timing

Page 3: 1 EE121 John Wakerly Lecture #12 PLD-based state machine structures WITH statements Finite-memory state-machine design PLD-based state-machine design

3

Multiple PLDs

registeredpipelined

registeredpipelined

Page 4: 1 EE121 John Wakerly Lecture #12 PLD-based state machine structures WITH statements Finite-memory state-machine design PLD-based state-machine design

4

Normal vs. pipelined Moore outputs• Assume 3 state variables, Q1, Q2, Q3.

Z = G(Q1, Q2, Q3) [Moore output]

Z := ?? [equivalent pipelined Moore output]

• Transition equationsQ1 := F1(Q1,Q2,Q3,inputs);

Q2 := F2(Q1,Q2,Q3,inputs);

Q3 := F3(Q1,Q2,Q3,inputs);

• Pipelined output equation:Z := G( F1(Q1,Q2,Q3,inputs), F2(Q1,Q2,Q3,inputs),

F3(Q1,Q2,Q3,inputs) );

• Can’t do this with Mealy outputs unless “inputs” are applied one clock tick earlier.

Page 5: 1 EE121 John Wakerly Lecture #12 PLD-based state machine structures WITH statements Finite-memory state-machine design PLD-based state-machine design

5

WITH statements

Page 6: 1 EE121 John Wakerly Lecture #12 PLD-based state machine structures WITH statements Finite-memory state-machine design PLD-based state-machine design

6

Example: Another combination lock

• Unlock after input sequence 0110111• Also provide “hint” output (1 => correct move).

Page 7: 1 EE121 John Wakerly Lecture #12 PLD-based state machine structures WITH statements Finite-memory state-machine design PLD-based state-machine design

7

Page 8: 1 EE121 John Wakerly Lecture #12 PLD-based state machine structures WITH statements Finite-memory state-machine design PLD-based state-machine design

8

WITH recommendations

• If you must use WITH statements, be sure to assign an output value for all states/transitions.

• Be very careful about registered vs. combinational assignments.

• It’s usually more convenient to specify output values using separate equations in the “equations” section of the program:

UNLK = (S==X0110111) & (X==0);HINT = (S==ZIP) & (X==0) # (S==X0) & (X==1) ... # (S==X0110111) & (X==0);

Page 9: 1 EE121 John Wakerly Lecture #12 PLD-based state machine structures WITH statements Finite-memory state-machine design PLD-based state-machine design

9

Finite-Memory State Machines

• In general, a state machine’s future operation depends on all the inputs it received since reset.

• Some state machines depend only on the inputs received over the last few clock ticks.

• Idea:– Use a register to keep track of the machine’s input

values over the last few clock ticks.– Determine the current output as a combinational

function of the past inputs history.

Page 10: 1 EE121 John Wakerly Lecture #12 PLD-based state machine structures WITH statements Finite-memory state-machine design PLD-based state-machine design

10

Example: the combination lock again

This program has a bug(I can unlock in just sixclock ticks after reset.)

Page 11: 1 EE121 John Wakerly Lecture #12 PLD-based state machine structures WITH statements Finite-memory state-machine design PLD-based state-machine design

11

T-bird tail-lights example

Page 12: 1 EE121 John Wakerly Lecture #12 PLD-based state machine structures WITH statements Finite-memory state-machine design PLD-based state-machine design

12

Statediagram

Inputs:LEFT, RIGHT, HAZ

Outputs:Six lamps(function of state only

Page 13: 1 EE121 John Wakerly Lecture #12 PLD-based state machine structures WITH statements Finite-memory state-machine design PLD-based state-machine design

13

ABEL program

Page 14: 1 EE121 John Wakerly Lecture #12 PLD-based state machine structures WITH statements Finite-memory state-machine design PLD-based state-machine design

14

ABEL “state diagram”

Page 15: 1 EE121 John Wakerly Lecture #12 PLD-based state machine structures WITH statements Finite-memory state-machine design PLD-based state-machine design

15

Output logic

• Implement this table in another PLD that has Q2, Q1, Q0 (QSTATE) as inputs.

• Total # of PLD outputs is 3 + 6 = 9.

Page 16: 1 EE121 John Wakerly Lecture #12 PLD-based state machine structures WITH statements Finite-memory state-machine design PLD-based state-machine design

16

Output-coded state assignment

• Each state has a unique encoding using just the lamp-output bits.

Page 17: 1 EE121 John Wakerly Lecture #12 PLD-based state machine structures WITH statements Finite-memory state-machine design PLD-based state-machine design

17

Sunnyvale Traffic-Light Controller

Page 18: 1 EE121 John Wakerly Lecture #12 PLD-based state machine structures WITH statements Finite-memory state-machine design PLD-based state-machine design

18

Traffic-Light I/O

• Inputs– NSCAR (north-south car sensors)– EWCAR (east-west car sensors)– TMSHORT (short timer -- 5 seconds)– TMLONG (long timer -- 5 minutes)

• Outputs– NSRED, NSYELLOW, NSGREEN (lights)– EWRED, EWYELLOW, EWGREEN (lights)– TMRESET (timer start)

Page 19: 1 EE121 John Wakerly Lecture #12 PLD-based state machine structures WITH statements Finite-memory state-machine design PLD-based state-machine design

19

State Diagram (ABEL)

• Outputs will be a function of state

Page 20: 1 EE121 John Wakerly Lecture #12 PLD-based state machine structures WITH statements Finite-memory state-machine design PLD-based state-machine design

20

• East-west states are symmetric.

Page 21: 1 EE121 John Wakerly Lecture #12 PLD-based state machine structures WITH statements Finite-memory state-machine design PLD-based state-machine design

21

State encoding

Page 22: 1 EE121 John Wakerly Lecture #12 PLD-based state machine structures WITH statements Finite-memory state-machine design PLD-based state-machine design

22

Output logic

Page 23: 1 EE121 John Wakerly Lecture #12 PLD-based state machine structures WITH statements Finite-memory state-machine design PLD-based state-machine design

23

Output-coded state assignment

Page 24: 1 EE121 John Wakerly Lecture #12 PLD-based state machine structures WITH statements Finite-memory state-machine design PLD-based state-machine design

24

Next Time

• Digital-to-analog conversion• Analog-to-digital conversion• Read D-to-A and A-to-D notes