Bottling Line Eject Delay
Line 2 caps six hundred bottles a minute. The vision camera at the capper raises flag for one clock cycle when a cap is crooked, and the air ejector sits three starwheel pockets downstream, one pocket per clock. This block has exactly one job: delay flag by three cycles and present it as eject, so the jet fires when the bad bottle, and only the bad bottle, is in front of it.
The contractor signed it off from the maintenance panel with a thumb on the test button. Since production started, QA keeps finding crooked caps in shipped cases while the jet blasts good bottles two pockets early. In simulation the fault is plain: the flag comes out one cycle after it goes in, not three. The testbench fires single-frame rejects, two rejects separated by a single quiet cycle, the contractor's thumb-on-the-button pattern (flag held high four cycles straight), and a reset in the middle of a delay in flight, and it checks eject on every cycle.
Interface
| Port | Direction | Type | Description |
|---|---|---|---|
clk | in | 1 bit | Clock, one starwheel pocket per cycle |
rst | in | 1 bit | Synchronous reset (active high) |
flag | in | 1 bit | Reject flag from the camera, 1 cycle wide |
eject | out | 1 bit | Ejector fire command (registered) |
Behavior
ejectreproducesflagdelayed by exactly three clock cycles:ejectduring any cycle equalsflagthree cycles earlier- Pulse shapes are preserved exactly: single-cycle flags come out single-cycle, back-to-back patterns come out unchanged
rst = 1at a clock edge clearsejectand every delay stage; flags already in flight are discarded and must never emerge after the reset- After reset is released,
ejectstays 0 until the first post-reset flag has had its three cycles - The testbench checks
ejecton every cycle
One trace tells the whole story: a flag in cycle 1 fires the jet in cycle 4, three pockets later.
cycle : 0 1 2 3 4 5
flag : 0 1 0 0 0 0
eject : 0 0 0 0 1 0
Constraints
Everything is synchronous to clk and eject is registered. The template contains the shipped implementation: fix it in place rather than starting over. The three delay stages are already declared and the structure is right.
Click Run to execute your code. Output will appear here.