§ 5.4.7. LED Panel¶
Sixteen lights. The LED panel is the example of a device that is added to a machine without changing any other part: its register table is two rows, its core is a counter, and it joins a machine through four lines of the machine's description (§ 5.5).
| Component | Description | Structural | Behavioral |
|---|---|---|---|
LedPanel |
Two read-write registers, a blink counter, 16 LED pins | Yes | Yes |
Catalog: device.leds; no parameters.
IO pins¶
| Pin | Direction | Width | Meaning |
|---|---|---|---|
CLK, RST |
Input | 1 each | Clock; reset of the device's state |
REQ_VALID, REQ_OP, REQ_ADDR, REQ_WRITE_DATA, REQ_WRITE_MASK, RSP_READY |
Input | 1, 3, 32, 32, 4, 1 | Register requests (offsets in the device's window) |
REQ_READY, RSP_VALID, RSP_READ_DATA, RSP_STATUS |
Output | 1, 1, 32, 3 | Register answers |
LEDS |
Output | 16 | Bit n: LED n is lit |
Registers¶
| Offset | Register | Access | Bits | Meaning |
|---|---|---|---|---|
0x0 |
LEDS |
read-write | 16 | Bit n: LED n is on |
0x4 |
BLINK |
read-write | 5 | 0: steady; k: lit LEDs blink, on and off for 2^k cycles each |
Behavior¶
LEDS shows the LEDS register, gated by the blink phase: with BLINK
= k > 0, the lit LEDs show while bit k of a free-running cycle counter is 0.
Both registers reset to 0 (dark, steady). A value wider than its register is
refused (Invalid) and changes nothing.
Reads of the LEDS register return the programmed mask even during the dark half of a blink; the output pins are the phase-gated view. BLINK accepts 0–31. The counter runs continuously, and writing LEDS or BLINK does not restart its phase, so a newly enabled blink can start partway through its on/off interval. Reset clears the two registers and counter. There is no interrupt, brightness control or independent clock per light.
Example¶
| Program | LEDS pins |
|---|---|
io_write(LEDS_LEDS, 0x0f0f) |
0x0f0f |
io_write(LEDS_BLINK, 2) |
0x0f0f for 4 cycles, 0x0000 for 4 cycles, … |
io_write(LEDS_BLINK, 0) |
0x0f0f |
io_write(LEDS_LEDS, 0x10000) |
unchanged; the store answers Invalid and the core traps |
Implementation¶
| Part | Contents |
|---|---|
PORT |
DeviceRegisterPort<32> |
REGISTERS |
The front end, storing LEDS (16 bits) and BLINK (5 bits) |
BLINK_COUNTER |
ClockedCounter<32>, always enabled |
LIGHTS |
PHASE, a Mux<32,1> picking counter bit BLINK; one ANDGate<16> masking LEDS |
The compact form compiles the same groups, as for the other devices.
Timing. An accepted register write takes effect at the execution edge; the visible pins then settle through the phase selection and output mask. With nonzero BLINK they can also change on later counter edges without a new bus access. The front end and LIGHTS group derive delays when built, and the counter/port use their characterized forms. There is no stored whole-panel table. Invalid or unknown register payloads follow the shared front-end rules; equivalence tests exercise binary controls after reset.
Visual abstraction¶
A compact or collapsed panel is drawn as a row of sixteen lights at the selected time.
Examples¶
The scenario lights 0x0F0F, reads it back, is refused a value wider than
16 bits, and sets BLINK to 2. The next eight cycles show the pins: four
cycles lit, four dark (the counter keeps running from reset, so the first
interval can be shorter). Writing BLINK = 0 makes the pins steady again.
All 21 recorded rows of LedPanelScenarioTest, in checkpoint order. Outputs are test expectations verified against the simulation. Time is the absolute settled checkpoint time in simulator units, not milliseconds or CPU cycles.
Default scenario profile: fidelity-logic-v1 / structural (3c048584c5332bb2). Changing fidelity or the circuit can change these times.
| Checkpointzero-based number · timeline label | Timesimulator units | CLKInput · 1 bit |
REQ_ADDRInput · 32 bit |
REQ_OPInput · 3 bit |
REQ_VALIDInput · 1 bit |
REQ_WRITE_DATAInput · 32 bit |
REQ_WRITE_MASKInput · 4 bit |
RSP_READYInput · 1 bit |
RSTInput · 1 bit |
LEDSExpected output · 16 bit |
REQ_READYExpected output · 1 bit |
RSP_READ_DATAExpected output · 32 bit |
RSP_STATUSExpected output · 3 bit |
RSP_VALIDExpected output · 1 bit |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
#0reset | 25 | 0 |
0x00000000 |
0x0 |
0 |
0x00000000 |
0x0 |
0 |
1 |
not checked | 0 |
not checked | not checked | 0 |
#1ready | 36 | 0 |
0x00000000 |
0x0 |
0 |
0x00000000 |
0x0 |
0 |
0 |
not checked | not checked | not checked | not checked | 0 |
#2dark | 37 | 0 |
0x00000000 |
0x0 |
0 |
0x00000000 |
0x0 |
0 |
0 |
0x0000 |
not checked | not checked | not checked | not checked |
#3light-some | 298 | 0 |
0x00000000 |
0x1 |
0 |
0x00000F0F |
0xF |
0 |
0 |
not checked | not checked | not checked | 0x0 |
1 |
#4lit | 344 | 0 |
0x00000000 |
0x1 |
0 |
0x00000F0F |
0xF |
0 |
0 |
0x0F0F |
not checked | not checked | not checked | not checked |
#5read-back | 598 | 0 |
0x00000000 |
0x0 |
0 |
0x00000000 |
0xF |
0 |
0 |
not checked | not checked | 0x00000F0F |
0x0 |
1 |
#6too-wide | 905 | 0 |
0x00000000 |
0x1 |
0 |
0x00010000 |
0xF |
0 |
0 |
not checked | not checked | not checked | 0x6 |
1 |
#7blink-off | 1208 | 0 |
0x00000004 |
0x0 |
0 |
0x00000000 |
0xF |
0 |
0 |
not checked | not checked | 0x00000000 |
0x0 |
1 |
#8blink-set | 1441 | 0 |
0x00000004 |
0x1 |
0 |
0x00000002 |
0xF |
0 |
0 |
not checked | not checked | not checked | 0x0 |
1 |
#9blink-read-back | 1662 | 0 |
0x00000004 |
0x0 |
0 |
0x00000000 |
0xF |
0 |
0 |
not checked | not checked | 0x00000002 |
0x0 |
1 |
#10blink-1-on | 1702 | 1 |
0x00000004 |
0x0 |
0 |
0x00000000 |
0xF |
0 |
0 |
0x0F0F |
not checked | not checked | not checked | not checked |
#11blink-2-off | 1722 | 1 |
0x00000004 |
0x0 |
0 |
0x00000000 |
0xF |
0 |
0 |
0x0000 |
not checked | not checked | not checked | not checked |
#12blink-3-off | 1732 | 1 |
0x00000004 |
0x0 |
0 |
0x00000000 |
0xF |
0 |
0 |
0x0000 |
not checked | not checked | not checked | not checked |
#13blink-4-off | 1744 | 1 |
0x00000004 |
0x0 |
0 |
0x00000000 |
0xF |
0 |
0 |
0x0000 |
not checked | not checked | not checked | not checked |
#14blink-5-off | 1758 | 1 |
0x00000004 |
0x0 |
0 |
0x00000000 |
0xF |
0 |
0 |
0x0000 |
not checked | not checked | not checked | not checked |
#15blink-6-on | 1778 | 1 |
0x00000004 |
0x0 |
0 |
0x00000000 |
0xF |
0 |
0 |
0x0F0F |
not checked | not checked | not checked | not checked |
#16blink-7-on | 1788 | 1 |
0x00000004 |
0x0 |
0 |
0x00000000 |
0xF |
0 |
0 |
0x0F0F |
not checked | not checked | not checked | not checked |
#17blink-8-on | 1798 | 1 |
0x00000004 |
0x0 |
0 |
0x00000000 |
0xF |
0 |
0 |
0x0F0F |
not checked | not checked | not checked | not checked |
#18steady-again | 2052 | 0 |
0x00000004 |
0x1 |
0 |
0x00000000 |
0xF |
0 |
0 |
not checked | not checked | not checked | 0x0 |
1 |
#19steady | 2098 | 0 |
0x00000004 |
0x1 |
0 |
0x00000000 |
0xF |
0 |
0 |
0x0F0F |
not checked | not checked | not checked | not checked |
#20no-register | 2365 | 0 |
0x00000008 |
0x0 |
0 |
0x00000000 |
0xF |
0 |
0 |
not checked | not checked | not checked | 0x2 |
1 |
Scroll within the table for all rows and pins. Buses use hexadecimal; values containing X/Z use MSB-first binary. Inputs show the declared values in effect at each checkpoint, including retained inputs. Sequential tests also replay preparation changes between checkpoints, such as lowering the clock. Use the matching checkpoint label in the simulation below.
Source and tests¶
Panel circuit and compact composition, register definitions, panel tests and scenario.
| Test | Coverage |
|---|---|
LedPanelTest |
Write and read back, refused wide value, blink duty, steady, Range and Alignment, both forms |
LedPanelScenarioTest |
The recorded example |
GameSnakeLedsScenarioTest, ComputerSystemLedsScenarioTest |
Programs that drive the panel, its pins checked at every frame (§ 5.6, § 5.5) |