wire / wire-format / finite-state-machine
A finite state machine (FSM) has states, inputs, outputs, and transitions. Mealy machine: output depends on current state AND input. Moore machine: output depends only on current state. State encoding: binary (minimum bits), one-hot (one bit per state, simpler logic), Gray code (adjacent states differ by one bit, reduces glitches).
aka: Finite state machine (Mealy and Moore)
spec: Digital logic design
A finite state machine (FSM) has states, inputs, outputs, and transitions. Mealy machine: output depends on current state AND input. Moore machine: output depends only on current state. State encoding: binary (minimum bits), one-hot (one bit per state, simpler logic), Gray code (adjacent states differ by one bit, reduces glitches).
| field | size | meaning |
|---|---|---|
| Mealy machine | model | Output = f(state, input). Output can change immediately on input change (faster). More outputs possible. |
| Moore machine | model | Output = f(state). Output changes only on state transition (simpler, no glitches). Fewer outputs. |
| State register | n bits | Holds the current state. n = ceil(log2(num_states)) for binary encoding. |
| Next state logic | combinational | Computes next state from current state + inputs. |
| Output logic | combinational | Mealy: f(state, input). Moore: f(state). |
| One-hot encoding | num_states bits | One bit per state. Simpler next-state logic (fewer gates) but more flip-flops. |
| Binary encoding | ceil(log2(n)) bits | Minimum flip-flops but complex next-state logic. |
| Gray code | ceil(log2(n)) bits | Adjacent states differ by one bit. Reduces glitches in asynchronous outputs. |
example:
00 00
FSM (placeholder)
agent: curl -H 'accept: application/json' wire.phall.io/wire-format/finite-state-machine
or /wire-format/finite-state-machine.json