Practice
Market Sign LED Chain
St Jude's covered market hung a two-lamp smart sign above its fish entrance. Each lamp held one chip, and data passed through both on one wire.
The colors looked right for one frame. Then each update slid them one lamp farther down the chain. The controller left too little low time between frames.
The chips never latched, so each new frame pushed the old bits farther along. Soon the red and green lamps traded places after every update.
Your task: build a sender with exact pulse widths and a real latch gap. Send both lamp colors in order, then hold the wire low long enough.
Interface
| Port | Direction | Type | Description |
|---|---|---|---|
clk | in | 1 bit | 20 MHz clock, 50 ns per clock |
rst | in | 1 bit | Synchronous reset (active high) |
start | in | 1 bit | Send one frame |
rgb0 | in | 24-bit vector | First lamp color, red in bits 23..16, green in 15..8, and blue in 7..0 |
rgb1 | in | 24-bit vector | Second lamp color, red in bits 23..16, green in 15..8, and blue in 7..0 |
din | out | 1 bit | Chain data wire, idle low, registered |
busy | out | 1 bit | High while a frame runs, registered |
done | out | 1 bit | One-clock pulse on the frame's final gap clock, registered |
Behavior
startis honored only while the sender sits idle, and the accepted frame begins on the following clock- Acceptance takes a snapshot of both color inputs
- A running frame keeps that snapshot even if
rgb0orrgb1change beneath it - A busy sender pays no attention to new
startassertions busygoes high at acceptance and remains high through the final latch-gap clock- Each lamp contributes 24 bits in green, red, then blue byte order
- Within every byte, the most significant bit is sent first
- The 24 bits from
rgb0are sent first, followed by the 24 bits fromrgb1 - Every bit occupies exactly 25 clocks
- A zero bit drives
dinhigh for exactly 8 clocks, then low for exactly 17 clocks - A one bit drives
dinhigh for exactly 16 clocks, then low for exactly 9 clocks - All 48 bits are sent back to back with no extra clocks between them
- After the 48th bit,
dinremains low for exactly 1000 clocks, which is 50 us donepulses exactly once, on the final clock of the 1000-clock latch gapbusyremains high during thedonepulse- On the next clock,
busyanddonefall together, and the unit becomes idle - While idle,
din,busy, anddoneare low rsthigh at any rising edge drives all outputs low, returns the unit to idle, and cancels all frame progress- No cancelled frame resumes after reset
What the bench checks
- A decoder plays the two chips: it measures every high run in clocks, classifies all 48 bits, and maps them back to each lamp's color
- Pulse widths are exact: a high run of anything but 8 or 16 clocks fails, as does a low remainder of anything but 17 or 9
- The latch gap is counted to the clock: a frame that ends before 1000 low clocks is called out as the colors sliding down the chain
- Both color inputs switch to decoys one clock after acceptance, so a frame built from live inputs decodes wrong
- Extra
startpulses land mid-bit, deep in the gap, and on the final gap clock, and none may leave a mark - It asserts reset during a high pulse, a low remainder, and the latch gap
- After every reset it expects the wire low on the very next clock and no cancelled frame resuming
Constraints
everything is synchronous to the 20 MHz clk; inputs are sampled on rising edges, and all outputs are registered.
this models the data wire's digital pulse train at exact clock counts; the chips' analog thresholds, supply, and color mixing are out of scope.
Do not add ports.
Click Run to execute your code. Output will appear here.