Clocked Synchronous State-machine Analysis Given the circuit diagram of a state machine: Analyze the combinational logic to determine flip-flop input (excitation) equations: D i = F i (Q, inputs) The input to each flip-flop is based upon current state and circuit inputs. 2 Substitute excitation equations into flip-flop characteristic equations, giving transition equations: Q i * = H i ( D i ) 3 From the circuit, find output equations: Z = G (Q, inputs) The outputs are based upon the current state and possibly the inputs. 4 Construct a state transition/output table from the transition and output equations: Similar to truth table. Present state on the left side. Outputs and next state for each input value on the right side. Provide meaningful names for the states in state table, if possible. 5 Draw the state diagram which is the graphical representation of state table. # Lec # 5 Winter 200 2-5-2002
State Machine Analysis Example Analyze the state machine: Input (or excitation) equations: D0 = Q. X x D Q Q D = Q. x + Q0. x Q' Q' 2 Characteristic equations: Q0* = D0 Q* = D D Q Q0 Find State equations: CP Q' Q0' Q0* = Q. x Q* = Q. x + Q0. x y 3 Output equation: y = (Q0 + Q). x' This is a Mealy Machine since output = G(current state, input) #2 Lec # 5 Winter 200 2-5-2002
State Machine Analysis Example 4 From the state equations and output equation, construct the state transition/output table: State equations: Q0* = Q. x Q* = Q. x + Q0. x Output equation: y = (Q0 + Q). x' Current State x Q Q0 0 0 0 00,0 0,0 0 00,,0 0 00, 0,0 00, 0,0 Q* Q0*, y Input Next State when x =0 Output for current state when x =0 Next State when x = Output for current state when x = #3 Lec # 5 Winter 200 2-5-2002
State Machine Analysis Example 5 Draw the state diagram of the state machine. state transition/output table state diagram x Q Q0 0 0 0 00,0 0,0 0 00,,0 0 00, 0,0 00, 0,0 Q* Q0*, y 0/0 00 /0 0/ 0/ 0/ 0 0 /0 Arc = input x / output y Node = state /0 /0 #4 Lec # 5 Winter 200 2-5-2002
Clocked State-machine Analysis: State Naming State Naming: Optionally name the states and substitute state names S for state-variable combinations in transition/output table and in state diagram. Example: For a circuit with two flip-flops: Q Q0 0 0 A 0 B 0 C D State Name #5 Lec # 5 Winter 200 2-5-2002
Clocked State-machine Analysis Example: Transition/Output Table Using State Names For the last example naming The States: Transition/output Table: Q Q0 State Name 0 0 A 0 B 0 C D Transition/output Table using state names: A B C D x Q Q0 0 0 0 00,0 0,0 0 00,,0 0 00, 0,0 00, 0,0 Q* Q0*, y x S 0 A A,0 B,0 B A, D,0 C A, C,0 D A, C,0 S*, y #6 Lec # 5 Winter 200 2-5-2002
Clocked State-machine Analysis Example: State Diagram Using State Naming Naming The States: State Diagram without state naming: Q Q0 State Name 0 0 A 0 B 0 C D State Diagram with state naming: 0/0 00 0/ 0 /0 0/0 A 0/ C /0 /0 0/ 0/ /0 /0 0/ 0/ /0 0 /0 Arc = input x / output y Node = state B /0 D #7 Lec # 5 Winter 200 2-5-2002
Clocked State-machine Analysis: State Machine Timing Diagram The timing diagram for a state machine graphically shows the state machine response in terms of state variables and output signals vs. time for given time-varying input signals and a given initial state. State machine timing diagrams can be generated using transition/output tables or state diagrams. Timing diagrams can be used to account for both combinational and flip-flop propagation delays. Example: For the state machine in the previous example show the timing diagram for the following input, assuming an initial state A and ignoring propagation delays: Cycle: 0 2 3 4 5 6 7 Clock 0 Time Input X 0 #8 Lec # 5 Winter 200 2-5-2002
State Machine Timing Diagram Example Cycle: 0 2 3 4 5 6 7 Clock 0 Time Input X 0 Q Q0 0 0 A B D C A A B A Output Y #9 Lec # 5 Winter 200 2-5-2002
State Machine Analysis Example 2 Analyze the state machine: X Y Q2 D0 D Q CLK Q Q0 Z Q0 D D Q CLK Q Q Q D2 D Q CLK Q Q2 Q2 Z2 CLK Input Logic F State Memory Output Logic G #0 Lec # 5 Winter 200 2-5-2002
State Machine Analysis Example 2 Excitation Equations D0 = X. Y.Q2 D = X. Q0 D2 = Y + Q 2 Characteristic Equations Q0* = D0 Q* = D Q2* = D2 State or Transition Equations Q0* = D0 = X. Y. Q2 Q* = D = X. Q0 Q2* = D2 = Y + Q 3 Output Equations Z = X. Q0 + Q Z2= (Q. Q2) # Lec # 5 Winter 200 2-5-2002
State Machine Analysis Example 2 4 From the state equations and output equation, construct the state transition/output table: state XY name Q2 Q Q0 00 0 0 A 0 0 0 00, 000, 000, 0, B 0 0 00, 000, 00,, C 0 0 00, 0 00, 0 00, 0 0, 0 D 0 00, 0 00, 0 0,, E 0 0 00, 000, 000, 00, F 0 00, 000, 00, 0, G 0 00, 00 00, 00 00, 00 00, 00 H 00, 00 00, 00 0, 0 0,0 Transition Equations Q0* = D0 = X. Y. Q2 Q* = D = X. Q0 Q2* = D2 = Y + Q Q2* Q* Q0*, Z Z2 (Next State, Outputs) Output Equations Z = X. Q0 + Q Z2= (Q. Q2) #2 Lec # 5 Winter 200 2-5-2002
State-machine Analysis Example 2: Transition/Output Table Using State Names XY S 00 0 0 A E, A, A, F, B E, A, C, H, C E, 0 E, 0 E, 0 F, 0 D E, 0 E, 0 G, H, E E, A, A, E, F E, A, C, G, G E, 00 E, 00 E, 00 E, 00 H E, 00 E, 00 G, 0 G,0 S*, Z Z2 #3 Lec # 5 Winter 200 2-5-2002
State-machine Analysis Example 2: State Diagram (incomplete) Y () () X Y B X Y () A X Y () X Y () C H XY () XY X +Y X Y (0) (0) () XY () XY () D X (0) G E F Arc: input expression (outputs) = expression (Z /Z2) #4 Lec # 5 Winter 200 2-5-2002
State Machine Analysis Example 3 Analyze the state machine: X J J Q Q Z Y K K Q J2 J Q Q2 K2 K Q CLK #5 Lec # 5 Winter 200 2-5-2002
State Machine Analysis Example 3 Excitation Equations J = X K = X Y J2 = X K2 = 0 2 Characteristic Equations Q*= J Q + K Q Q*= J Q + K Q Q2* = J2 Q2 + K2 Q2 Transition Equations Q* = X Q + (X Y) Q = X Q + X Q + Y Q Q2* = X Q2 + 0 Q2 = X Q2 + Q2 3 Output Equation Z = X Q + Q2 #6 Lec # 5 Winter 200 2-5-2002
State Machine Analysis Example 3 4 From the state equations and output equation, construct the state transition/output table: XY S Q Q2 00 0 0 A 0 0 0,0 0,0 0,0 0,0 B 0 0, 0,,, C 0,0,0 00, 0, D,, 0,, Q* Q2*, Z Transition Equations Q* = X Q + X Q + Y Q Q2* = X Q2 + Q2 Output Equation Z = X Q + Q2 #7 Lec # 5 Winter 200 2-5-2002
State-machine Analysis Example 3: Transition/Output Table Using State Names XY S 00 0 0 A B,0 B,0 C,0 C,0 B B, B, D, D, C D,0 D,0 A, C, D D, D, B, D, S*, Z #8 Lec # 5 Winter 200 2-5-2002
State-machine Analysis Example 3: State Diagram Arc Format: inputs xy output z A 00,0 0 B 00,0 00,0,0 D 0, 00,0 0 0, C 0 0 #9 Lec # 5 Winter 200 2-5-2002