Presentation is loading. Please wait.

Presentation is loading. Please wait.

ECE 352 Digital System Fundamentals

Similar presentations


Presentation on theme: "ECE 352 Digital System Fundamentals"— Presentation transcript:

1 ECE 352 Digital System Fundamentals
State Minimization Unused States In this video, we will examine techniques that can be used to reduce the number of flip-flops and logic gates needed to design a finite state machine.

2 State Minimization Sometimes during design, we might think we need more states than we actually do… Adding a state can increase # of storage elements: # FFs ≥ ceil(log2(# states)) Eliminating redundant states: Reuse states when possible (loop back) Merge states when appropriate (same outgoing transitions and same outputs) After each merge, also need to check if the newly merged state can be merged with any others Remember – only OUTGOING transitions matter! When designing a state diagram, states and transitions are added to achieve the desired behavior. Since there is no formal, ordered approach for adding states and transitions, the resulting state diagram sometimes contains more states than are necessary. In order to minimize the number of states, you should look to reuse and merge states whenever possible. Two states can be merged if they have the same outputs and the same next state for all input combinations. Once two states have been merged, you should re-examine the resulting FSM and see if any other states can be merged.

3 Identifying Merge-able States
Moore Machine: Merge states w/same outputs & next state To merge two states: Their outputs must match Arrows must go to the same places for the same values (same “next state”) Remember to match outgoing transitions! In a Moore FSM, we can merge states that have the same output and same next states. We examine pairs of states, checking that the output of the two states is the same AND the corresponding outgoing transitions both go to the same state.

4 Identifying Merge-able States
Moore Machine: Merge states w/same outputs & next state To merge two states: Their outputs must match Arrows must go to the same places for the same values (same “next state”) Remember to match outgoing transitions! Same transition for A=0 Same outputs Here we can see that states K & L both have an output of 0. We also notice when input A equals 0, both transition arrows go to state L. When input A=1, both states K and L transition into state M. Since the outputs match and the outgoing transitions end in the same state, we can merge states K and L. Same transition for A=1 FSM with merged KL state

5 Identifying Merge-able States
Mealy Machine: Merge states w/same next state / output transitions To merge two states: Arrows must go to the same places for the same input values Outputs must match on arrows also Remember to match outgoing transitions! In a Mealy FSM we identify merge-able states in the same way, except the output also depends on the input. For a pair of states, we need to make sure that the outgoing transitions go to the same state and that the output values on the transitions are identical.

6 Identifying Merge-able States
Mealy Machine: Merge states w/same next state / output transitions To merge two states: Arrows must go to the same places for the same input values Outputs must match on arrows also Remember to match outgoing transitions! Same transition for A=0 Same outputs on A=1 transitions We see that for states X and Z, when the input is 0, both states transition to state Y AND they both have an output of 1. We also see when the input is 1, both states X and Z transition to state X AND both of the outputs on those transitions are 0. This means that states X and Z both represent the same the state of being, so we can merge them and the FSM’s behavior will not change. Same outputs on A=0 transitions Same transition for A=1 FSM with merged XZ state

7 Unused States With n flip-flops, the FSM will have 2n states
Specification may not require all 2n states, so we have a choice: Consider those states don’t-care situations Benefit: simplifies the logic Downside: what if we transition to an unused state? Assign a next state value to all states Benefit: can reset or signal an error Downside: requires more logic Often times when we design a FSM, there are more states than we need. We need to decide what should happen if the machine enters one of those unused states. One option is to treat the behavior in those states as don’t-cares. The benefit of treating the unused states as don’t-cares is that this may result in simpler next-state and output logic. The other option we have is to explicitly set the next state and output value of any unused states. This can be useful if we want the machine to transition into an error state indicating that the FSM has malfunctioned, or to reset the FSM by having it transition to the initial state.

8 Unused States Example Here’s an example FSM, where state 3 is unused.

9 Unused States Example 0/0 11 1/1 D0 = Q1 A + Q1 A D1 = Q0 A Y = Q1 A
Based on the don’t-cares for state 3, we would determine that the optimal 2-level next-state and output logic is as shown. Based on those equations, we now know what the actual values for state 3 will be. We can then annotate the state diagram to show the actual behavior of state 3. D0 = Q1 A + Q1 A D1 = Q0 A X X X 0 0 1 1 1 Y = Q1 A

10 Unused States Example 0/0
In this example, we don’t care what happens if we get to the 11 state But we may want to know what happens If our circuit goes into this state, we need to debug it! 0/0 11 1/1 Under normal conditions we should never transition into state 3. But if we do, we might want to know how the FSM would react so we can debug our design.

11 Don’t-Cares Don’t-cares can express that a particular variable does not affect a transition Similar to shorthand notation where we use X in an input column of a truth table Example: In state K, only care about A, and in state M, only care about B… In this case, each arrow represents two transitions Don’t-cares can also be used to simplify output equations, but that is less common Unused states are not the only scenario where don’t-cares are used with finite state machines. Many state machines have multiple inputs. In a given state, an individual input may have no effect on the FSM’s behavior. In these cases, we indicate that the input is a don’t-care with an X. In the example shown, when we are in state K, input B does not affect which state will be the next state, so we mark it as a don’t-care. This means that each arrow actually represents two transitions. In some unusual cases, we may not care about the value of an output in certain states and can use an X there as well.

12 ECE 352 Digital System Fundamentals
State Minimization Unused States That concludes this video.


Download ppt "ECE 352 Digital System Fundamentals"

Similar presentations


Ads by Google