1 ee121 john wakerly lecture #11 sequential-circuit design sequential-circuit synthesis

20
1 EE121 John Wakerly Lecture #11 Sequential-circuit design Sequential-circuit synthesis

Upload: noah-hicks

Post on 05-Jan-2016

232 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 EE121 John Wakerly Lecture #11 Sequential-circuit design Sequential-circuit synthesis

1

EE121 John Wakerly Lecture #11

Sequential-circuit design

Sequential-circuit synthesis

Page 2: 1 EE121 John Wakerly Lecture #11 Sequential-circuit design Sequential-circuit synthesis

2

State-machine design and synthesis

• Example: Design a combination lock with two inputs, X1 and X2. Open for the sequence X1, X2, X2 (one input per clock).

The creative part, like writing a program

Turning the crank, like a compiler does

Page 3: 1 EE121 John Wakerly Lecture #11 Sequential-circuit design Sequential-circuit synthesis

3

• Example: Design a combination lock with two inputs, X1 and X2. Open for the sequence X1, X2, X2 (one input per clock).

• Specification ambiguities are resolved in the state table.

State X1 X2-------------------------- -----------------------------------------------Meaning Name 00 01 10 11 UNLOCK

-------------------------- -----------------------------------------------

Start A A A B A 0

Got X1 B A C A A 0

Got X1,X2 C A D A A 0

Got X1,X2,X2 D A A B A 1(D)

(D)

(C)

(B)

Page 4: 1 EE121 John Wakerly Lecture #11 Sequential-circuit design Sequential-circuit synthesis

4

State Assignment

• Can minimize number of states (see text), but hardly anyone bothers anymore.

• Need to assign state-variable combinations to states.– Minimum number of variables for n states is log2 n

– Using more than minimum number may be advantageous in some situations, e.g., one variable per state (“one-hot”) (see text).

– Example -- 4 states, 2 state variables (Q1,Q2):

A ==> 00B ==> 01C ==> 10D ==> 11

Up to this point is “art”, the rest is just “turning the crank.”

Page 5: 1 EE121 John Wakerly Lecture #11 Sequential-circuit design Sequential-circuit synthesis

5

Transition table

• Substitute state-variable combinations for states in the state table.

State X1 X2-------------------------- -----------------------------------------------Meaning Q1 Q2 00 01 10 11 UNLOCK

-------------------------- -----------------------------------------------

---------------------------------------------- Q1 Q2

Start 0 0 0 0 0 0 0 1 0 0 0

Got X1 0 1 0 0 1 0 0 0 0 0 0

Got X1,X2 1 0 0 0 1 1 0 0 0 0 0

Got X1,X2,X2 1 1 0 0 0 0 0 1 0 0 1

Page 6: 1 EE121 John Wakerly Lecture #11 Sequential-circuit design Sequential-circuit synthesis

6

Transition equations; circuit

• Transition table specifies each state variable (Q1, Q2) as a combinational logic function of Q1, Q2, X1, X2.– Find a realization of each function by your favorite

means -- ad hoc, minimal sum-of-products, etc.

• Build the circuit.

UNLOCKD Q

D Q

Q1

Q2

X1

X2

CLK

Q1

Q2

Q1

Q2

Page 7: 1 EE121 John Wakerly Lecture #11 Sequential-circuit design Sequential-circuit synthesis

7

Design using ABEL state diagrams

state_diagram LOCKSTstate A: if X1&!X2 then B else A;state B: if !X1&X2 then C else A;state C: if !X1&X2 then D else C;state D: if X1&!X2 then B else A;

equationsUNLOCK = (LOCKST==D);

LOCKST = [Q1,Q2];A = [ 0, 0];B = [ 0, 1];C = [ 1, 0];D = [ 1, 1];

State assignment

LOCKST = [Q1,Q2];A = [ 0, 0];B = [ 0, 1];C = [ 1, 1];D = [ 1, 0];

Different order

LOCKST = [Q1,Q2,Q3,Q4];A = [ 1, 0, 0, 0];B = [ 0, 1, 0, 0];C = [ 0, 0, 1, 0];D = [ 0, 0, 0, 1];

One-hot assignment

Page 8: 1 EE121 John Wakerly Lecture #11 Sequential-circuit design Sequential-circuit synthesis

8

Another design example (from text)

• Design a machine with inputs A and B and output Z that is 1 if:– A had the same value at the two previous ticks– B has been 1 since the last time the above was true

Page 9: 1 EE121 John Wakerly Lecture #11 Sequential-circuit design Sequential-circuit synthesis

9

State assignment

• There are 6,720 different state assignments of 5 states to 3 variables.– And there are even more using 4 or more variables

• Here are a few “obvious” or “interesting” ones:

Page 10: 1 EE121 John Wakerly Lecture #11 Sequential-circuit design Sequential-circuit synthesis

10

Transition/output table (decomposed assignment)

• Simple textual substitution• With D flip-flops, excitation table is identical to

transition table.

Page 11: 1 EE121 John Wakerly Lecture #11 Sequential-circuit design Sequential-circuit synthesis

11

Develop excitation equations

• Assume unused states have next-state = 000

Page 12: 1 EE121 John Wakerly Lecture #11 Sequential-circuit design Sequential-circuit synthesis

12

Same example using ABEL

• Note about reset inputs:– You always need a “power-on” reset input for a

sequential circuit.– Previous example did not use synchronous reset

because of manual-synthesis complexity.– Asynchronous reset is sometimes used (PR and

CLR inputs of flip-flops).

Page 13: 1 EE121 John Wakerly Lecture #11 Sequential-circuit design Sequential-circuit synthesis

13

“State Diagram”

This essentially mimics the state table.

Page 14: 1 EE121 John Wakerly Lecture #11 Sequential-circuit design Sequential-circuit synthesis

14

State assignment

• Note definition of “extra” states.

Page 15: 1 EE121 John Wakerly Lecture #11 Sequential-circuit design Sequential-circuit synthesis

15

Odds ’n’ ends

• Good behavior for extra states

• Clock and output equations

• Alternative state assignments are easy– Modify state definitions and possibly output pins

and extra states.– Unspecified states go to 0,0,…0.

Page 16: 1 EE121 John Wakerly Lecture #11 Sequential-circuit design Sequential-circuit synthesis

16

ABEL-derived excitation equations

• Equivalent to what was derived by hand, with the addition of the RESET input.

Page 17: 1 EE121 John Wakerly Lecture #11 Sequential-circuit design Sequential-circuit synthesis

17

And now for something completely different...

• ABEL’s language features can be used to enable a different, “hybrid” approach.

• Use one register to keep track of the previous value of A; use a state machine for the rest.

Records previous value of A

Page 18: 1 EE121 John Wakerly Lecture #11 Sequential-circuit design Sequential-circuit synthesis

18

Simpler, more natural state machine

• Really an example of “state-machine decomposition.”

Page 19: 1 EE121 John Wakerly Lecture #11 Sequential-circuit design Sequential-circuit synthesis

19

Equations and state assignments

Page 20: 1 EE121 John Wakerly Lecture #11 Sequential-circuit design Sequential-circuit synthesis

20

Wrap-up

• Next time: PLD-based state-machine design examples

• Discussion of Lab #5

• How to deal with pushbuttons, edge detection, etc.