state machine design and synthesis

20
State-machine design and synthesis The creative part, like writing a program Turning the crank, like a compiler does

Upload: abhilash-nair

Post on 22-May-2015

505 views

Category:

Education


2 download

DESCRIPTION

Lec7

TRANSCRIPT

Page 1: State Machine Design and Synthesis

State-machine design and synthesis

The creative part, like writing a program

Turning the crank, like a compiler does

Page 2: State Machine Design and Synthesis

Designing State Machines Using State Diagrams

• State-diagram design is simpler but it is more prone to errors.– State table is an exhaustive listing of the next states for

each state/input combination. No ambiguity is possible.– When constructing a state diagram there is no guarantee

that the transition expressions written on the arcs leaving a particular state, cover all input combination exactly once.

Page 3: State Machine Design and Synthesis

Designing State Machines Using State Diagrams

• Mutual exclusion: For each state the logical product of each pair of transition expression on arcs leaving that state should be zero. If there are n arcs then there are n(n-1)/2 logical products to evaluate

• All inclusion: For each state the logical sum of the transition expressions on all arcs leaving the state should be one.

• A state table guarantees mutual exclusion and all inclusion• A state diagram needs to be verified for mutual exclusion

and all inclusion so that there is no ambiguity.

Page 4: State Machine Design and Synthesis

State

S

Input AB Output

ZMeaning 00 01 11 10

Initial State INIT A0 A0 A1 A1 0

Got A = 0 A0 OK00 OK00 A1 A1 0

Got A = 1 A1 A0 A0 OK11 OK11 0

Got A = 00 OK00 OK00 OK00 OK01 A1 1

Got A = 11 OK11 A0 OK10 OK11 OK11 1

Got A = 01, B = 1 OK01 A0 OK10 OK11 OK11 1

Got A = 10, B = 1 OK10 OK00 OK00 OK01 A1 1

S*

• 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 5: State Machine Design and Synthesis

State

S

Input AB Output

ZMeaning 00 01 11 10

Initial State INIT A0 A0 A1 A1 0

Got A = 0 A0 OK00 OK00 A1 A1 0

Got A = 1 A1 A0 A0 OK11 OK11 0

Got A = 00 or A = 10, B = 1

OK00 OK00 OK00 OK11 A1 1

Got A = 11or A = 01, B = 1

OK11 A0 OK00 OK11 OK11 1

S*

• Minimized State Table

Page 6: State Machine Design and Synthesis

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

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.”

Rissacher EE365Lect #11

Page 7: State Machine Design and Synthesis

State assignment contd.

• The design example has 5 states, so minimum f/fs required are 3

• For 3 f/fs we have 8 states and we require only 5

• Hence there will be 3 unused states

• Two approaches

-Minimal Risk

-Minimal Cost

Page 8: State Machine Design and Synthesis

• All unused states are identified and explicit next state entries are made so that, for any input combination the unused states will go to the ‘initial’, ‘idle’ or ‘safe’ state

Minimal Risk

Minimal Cost

• All unused states are identified and next state entries are marked as ‘don’t cares’. In most cases this simplifies the excitation logic. However, the machine’s behavior if it enters an unused state may be pretty weird

Page 9: State Machine Design and Synthesis

• Choose an initial coded state into which the machine can easily be forced at reset (00.. Or 11..)

• Minimize the number of state variables that change on each transition

• Maximize the number of state variables that do not change in a group of related states. ( a group of states in which most of the transitions stay in the group)

Guidelines for state assignments

Page 10: State Machine Design and Synthesis

• Exploit symmetries in the problem specification and the corresponding symmetries in the state table.

• If there are unused states then use the ‘best’ available states

• Decompose the set of states into individual bits or fields, where they have a well defined meaning with respect to the input effects or output behavior

• Consider more than the minimum number of state variables

Guidelines for state assignments

Page 11: State Machine Design and Synthesis

State assignment contd.• 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 12: State Machine Design and Synthesis

• It uses 1 bit per state

• Simple

• Each f/f needs to be set to ‘1’ for transitions in only one state

• More number of f/fs

• Usually used for a machine with S states that is required to have a set of 1 out-of-S coded outputs indicating its current state. The one-hot -coded f/f outputs can be used directly for this purpose, with no additional combinational output logic

One–hot assignment

Page 13: State Machine Design and Synthesis

• It uses a ‘no-hot’ combination for the initial state

Reasons

-Easy to initialize most storage devices to 0

-Initial state in particular is usually not visited once the machine gets going

Almost One–hot assignment

Page 14: State Machine Design and Synthesis

• Initial state is 000 which is easy to force using Reset signal

• Q1 is used to indicate whether the machine is in INIT state or not

-Q1 = 0 implies INIT state

-Q1 = 1 implies non-INIT states

• Q2 indicates that the conditions for a ‘1’ output are satisfied in the current state.

-Q2 = 0 for A0, A1 states

-Q2 = 1 for OK0, OK1 states

Incorporation of some guidelines

Page 15: State Machine Design and Synthesis

• Q3 indicates the previous value of A.

-Q3 = 0 for OK0, A0 states

-Q3 = 1 for OK1, A1 states

• By decomposing the state bits meanings in this way, we can expect the next state and output logic to be simpler than in a ‘random’ assignment

Incorporation of some guidelines

Page 16: State Machine Design and Synthesis

Transition/output table (decomposed assignment)

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

transition table (now with D1 D2 D3)

Rissacher EE365Lect #11

D1 D2 D3

Page 17: State Machine Design and Synthesis

Develop excitation equations

• Assume unused states have next-state = 000

Rissacher EE365Lect #11

Page 18: State Machine Design and Synthesis

D1 = 1D2 = Q1 • Q3´ • A´ + Q3 • A + Q2 • BD3 = A

Rissacher EE365Lect #11

Option: Minimize

with “Don’t Cares”

Page 19: State Machine Design and Synthesis

Q1

Q2Q3 0 1

00 0 0

01 d 0

11 d 1

10 d 1

Z = Q2

Output Equation

Page 20: State Machine Design and Synthesis

Rissacher EE365Lect #11

Circuit using minimized equations