Water reservoir controller
15%fsmfsm-designA water reservoir serves a small community. Three level sensors are mounted at different heights: s[1] is the lowest, s[2] the middle, and s[3] the highest. A sensor outputs 1 whenever the water is at or above its height, so the sensor vector is always thermometer-coded — only the values 000, 001, 011, and 111 ever occur (the test stimulus respects this, and the level only moves one range at a time).
Build a Moore FSM that controls three inflow valves fr1, fr2, fr3 and a supplemental-flow signal dfr. The lower the water, the more valves open:
| Water level | s[3:1] | fr3 | fr2 | fr1 |
|---|---|---|---|---|
Above s[3] | 111 | 0 | 0 | 0 |
Between s[2] and s[3] | 011 | 0 | 0 | 1 |
Between s[1] and s[2] | 001 | 0 | 1 | 1 |
Below s[1] | 000 | 1 | 1 | 1 |
The dfr output adds hysteresis based on where the level came from:
- If the level falls into the current range (the previous range was higher),
dfr = 1, and it stays 1 for as long as the level remains in that range. - If the level rises into the current range (the previous range was lower),
dfr = 0while it remains in that range. - Below
s[1],dfris always 1. Aboves[3],dfris always 0.
This means the two middle ranges each need two states (one entered from above, one from below) — six states total.
The active-high reset is synchronous and puts the FSM in the state equivalent to the water having been below s[1] for a long time: all of fr1, fr2, fr3, and dfr asserted.