FSM 3: one-hot logic by inspection
15%fsmThe same four-state Moore machine again:
| Current state | next state when in = 0 | next state when in = 1 | output out |
|---|---|---|---|
| A | A | B | 0 |
| B | C | B | 0 |
| C | A | D | 0 |
| D | C | B | 1 |
This time the state is one-hot encoded: state[0] corresponds to A, state[1] to B, state[2] to C, and state[3] to D (exactly one bit is 1 at a time).
Implement the next-state and output logic by inspection of the one-hot encoding: each next_state bit is simply the OR of the conditions for every transition arc that enters that state, where each arc contributes state[source] & (in condition). For example, state A is entered from A when in = 0 and from C when in = 0, so next_state[0] = (state[0] | state[2]) & ~in.
Write all four next_state equations this way, plus out. Do not decode the state with a case statement or comparisons — the equations must be the sum-of-products form above. (The grader applies non-one-hot state patterns too, which only the inspection-derived equations produce.)