Practice
Fountain Stagger
The Marchetti fountain has 4 pump groups: the perimeter jets, two arc rings, and the center plume. Each group starts through a contactor (a heavy relay that switches the pump motor). The contactors used to close on the same clock cycle. Four motors starting at once tripped the plaza's feed breaker about one morning in five. The city electrician's report is one sentence: start them 4 counts apart and the breaker holds.
Here is the catch. The show controller is a small programmable logic chip (a CPLD) with 6 spare macrocells, and in this chip family one macrocell means one flip-flop. The obvious design, a chain of delay stages with one flip-flop per count, synthesizes to 13 flip-flops. It does not fit.
Your task: build the staggered starter in 6 flip-flops or fewer. When go rises, en(0) starts first, and en(1), en(2), en(3) join at 4-count intervals. Everything stays on while go stays high. The go line is also the dead-man switch, the line that must stay high for anything to run. Every contactor must release the moment go drops, not a clock cycle later, and the next start replays the whole stagger. The Netlist tab keeps the score, and the house record is 4.
Interface
| Port | Direction | Type | Description |
|---|---|---|---|
clk | in | 1 bit | Clock |
rst | in | 1 bit | Synchronous reset (active high) |
go | in | 1 bit | Run command and dead-man from the controller |
en | out | 4-bit vector | Contactor enables, bit 0 = perimeter jets |
Behavior
- Call cycle 1 the first full clock cycle after
gois sampled high at a rising edge en(0)is high during cycle 1 and every following cycle whilegostays highen(1)joins from cycle 5,en(2)from cycle 9,en(3)from cycle 13, each staying high whilegoholds- Once all four are on, the pattern holds steady for as long as
gostays high, however long that is - When
gogoes low, all four enables are low by the next check, and the stagger starts over on the next assertion ofgo - A one-cycle dropout of
gorestarts the full sequence rst = 1at a rising edge clears the stagger timer; during that cycleen(0)followsgoand the other three enables are low- The reset cycle does not advance the sequence: with
goheld high, the full stagger replays, counted from the first edge afterrstfalls
What the bench checks
- The testbench checks all four enables on every cycle
- The testbench drives full ramps, long holds, dead-man drops from every phase, a one-cycle
goblip, and a reset in mid-ramp - After every drop of
goit also probes the enables between clock edges: a release that waits for the next edge fails
Constraints
the stagger counting is synchronous to clk. The dead-man release is not: a dropped go must reach the enables without waiting for a clock edge.
this models the enable logic for the four contactors. The contactors themselves, the pump motors, and the plaza's feed breaker are out of scope.
6 flip-flops or fewer as reported by the Netlist tab FFs stat after synthesis (the delay-chain draft measures 13; the record is 4).
The enables may be plain combinational decode. The testbench cannot count flip-flops; it only enforces behavior. The budget is on your honor.
Do not add ports.
Click Run to execute your code. Output will appear here.