Skip to content

§ 5.4.1. Registers

A device's registers are data: a register table. The same table builds the device's register front end and the guest header's #defines. The Markdown register maps on these pages describe those definitions; they are currently maintained by hand, rather than generated by the site build.

Component Description Structural Behavioral
DeviceRegisterPort<W> Takes one bus request, holds it, returns the answer the device gives Yes Yes (W = 32)
Register front end (RegisterFrontEnd<…>) Decode, access checks, read selection, write strobes, read-write storage Yes, inside each device Compiled with the device

Register tables

Each row is one 32-bit register at a word offset.

Field Meaning
name TX, STATUS, … ; the header calls it <DEVICE>_<NAME>
offset A multiple of 4, below 0x80
access One of the five kinds below
bits Significant width, 1–32; higher bits read as 0
value The constant of a setting; the current read-write registers all reset to zero
fields Optional named bits, for the header (BUTTONS_STATUS_VALID)
Access Read Write Example
read-only The value the core supplies ReadOnly (3) BUTTONS.COUNT
setting A constant fixed when the device is built ReadOnly (3) DISPLAY.WIDTH
read-write The stored value Stores it (it must fit the bits) LEDS.LEDS
write-only data Unsupported (4) Hands the value to the core (it must fit the bits) CONSOLE.TX
command Unsupported (4) Writing 1 acts once; 0 does nothing; anything else is Invalid (6) BUTTONS.POP

An offset with no register answers Range (2). A write whose value does not fit its register (or has unknown bits) answers Invalid (6) and changes nothing. These are checked in this order: no register, then read-only written, then write-only read, then the value.

5.4.1.1. DeviceRegisterPort<W>

IO pins

Catalog device.word.register-port.W supports W = 8, 16, 32; only W = 32 has a compact form. All register devices in this chapter use that width.

Pin Direction Width Meaning
CLK, RST Input 1 each Clock; reset discards a held request and answer
REQ_VALID, REQ_OP, REQ_ADDR, REQ_WRITE_DATA, REQ_WRITE_MASK, RSP_READY Input 1, 3, 32, W, W/8, 1 The bus side: requests
REQ_READY, RSP_VALID, RSP_READ_DATA, RSP_STATUS Output 1, 1, W, 3 The bus side: answers
ADDRESS Output 32 The held request's offset
IS_READ, IS_WRITE Output 1 each Its operation
WRITE_DATA, WRITE_MASK Output W, W/8 Its data and mask
READ_STROBE, WRITE_STROBE Output 1 each The one edge at which the access happens, only when its status is OK
BACK_STATUS, BACK_READ_DATA Input 3, W The device's answer for the held request
BACK_READY Input 1 Low delays a write (the device has no room)

Behavior

The port takes a request, checks the parts every register access shares (alignment to W/8, a known operation, a full or empty mask), and asks the device for its answer. At the execute edge it raises READ_STROBE or WRITE_STROBE once, samples BACK_STATUS and BACK_READ_DATA, and holds the answer until the bus takes it. Cycle by cycle: the accepting edge captures the request and lowers REQ_READY; in the next cycle the strobe is high and the answer is already on RSP_*, because the empty response buffer passes it straight through; the execute edge ends the strobe, and the buffer keeps the sampled answer until RSP_READY takes it. A read never has a side effect, so reading a queue's head twice gives the same event; side effects happen only through writes. A zero write mask does nothing; a partial mask is Invalid.

The shared validation priority is unknown operation/address → Invalid (6), unsupported operation → Unsupported (4), invalid write mask → Invalid (6), then misalignment → Alignment (1). Only if these pass does BACK_STATUS decide the result. A valid nonzero-mask write waits for BACK_READY; reads, errors and zero-mask writes do not. A zero-mask write can still report a register access error: side-effect-free does not mean every address is OK.

Reset drops a pending access and held answer. It suppresses admission and execution while asserted; it cannot undo a strobe the device already acted on. The response buffer samples a read once, so later changes in a counter or queue do not change a backpressured response. Strobes are qualified enables around the execute edge, not extra clocks.

Implementation

REQUEST validates and captures operation, offset, payload, mask and the shared status. CONTROL tracks pending/executed state and backend readiness. EXECUTE selects the final status, gates strobes and returns zero for a write or failed read. RESPONSE is the structural memory response buffer that holds sampled data/status until consumption. At W = 32 the compact port compiles these same gates with characterized storage.

Timing. Request fields must meet the capture edge; backend data/status must settle for execution. The buffer retains the sampled answer independently of later backend changes. Selected default 32-bit paths, with reset low:

Latest time each path can still change after its input (for a setup row: how long before the edge the input must be stable), proven on the gate-level form.

Pathunitticksembeddedpsdesktopps
Request address setup REQ_ADDR before CLK ↑19831578
Backend data setup BACK_READ_DATA before CLK ↑10435302
Edge to read response CLK ↑ → RSP_READ_DATA17799554
Backend readiness to write enable BACK_READY → WRITE_STROBE5252176

Examples

All 24 recorded rows of DeviceRegisterPortWidth32ScenarioTest, 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 BACK_READYInput · 1 bit BACK_READ_DATAInput · 32 bit BACK_STATUSInput · 3 bit 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 ADDRESSExpected output · 32 bit IS_READExpected output · 1 bit IS_WRITEExpected output · 1 bit READ_STROBEExpected output · 1 bit REQ_READYExpected output · 1 bit RSP_READ_DATAExpected output · 32 bit RSP_STATUSExpected output · 3 bit RSP_VALIDExpected output · 1 bit WRITE_DATAExpected output · 32 bit WRITE_MASKExpected output · 4 bit WRITE_STROBEExpected output · 1 bit
#0reset12 1 0x00000000 0x0 0 0x00000000 0x0 0 0x00000000 0x0 0 1 not checked not checked not checked not checked 0 not checked not checked 0 not checked not checked not checked
#1ready23 1 0x00000000 0x0 0 0x00000000 0x0 0 0x00000000 0x0 0 0 not checked not checked not checked not checked not checked not checked not checked 0 not checked not checked not checked
#2backend28 1 0x12345678 0x0 0 0x00000000 0x0 0 0x00000000 0x0 0 0 not checked not checked not checked 0 not checked not checked not checked not checked not checked not checked 0
#3read-accepted43 1 0x12345678 0x0 1 0x00000008 0x0 1 0x00000000 0x0 0 0 0x00000008 1 0 1 0 0x12345678 0x0 1 not checked not checked 0
#4read-held57 1 0x12345678 0x0 1 0x00000008 0x0 0 0x00000000 0x0 0 0 not checked not checked not checked 0 not checked 0x12345678 0x0 1 not checked not checked not checked
#5backend-changes62 1 0x00000000 0x0 0 0x00000008 0x0 0 0x00000000 0x0 0 0 not checked not checked not checked not checked not checked 0x12345678 not checked 1 not checked not checked not checked
#6read-taken77 1 0x00000000 0x0 1 0x00000008 0x0 0 0x00000000 0x0 1 0 not checked not checked not checked not checked 1 not checked not checked 0 not checked not checked not checked
#7write-waits113 0 0x00000000 0x0 1 0x00000004 0x1 1 0xCAFEF00D 0xF 0 0 0x00000004 not checked 1 not checked 0 not checked not checked not checked 0xCAFEF00D 0xF 0
#8write-still-waits121 0 0x00000000 0x0 1 0x00000004 0x1 0 0xCAFEF00D 0xF 0 0 not checked not checked not checked not checked not checked not checked not checked 0 not checked not checked 0
#9backend-ready130 1 0x00000000 0x0 0 0x00000004 0x1 0 0xCAFEF00D 0xF 0 0 not checked not checked not checked not checked not checked not checked 0x0 1 not checked not checked 1
#10write-answered142 1 0x00000000 0x0 1 0x00000004 0x1 0 0xCAFEF00D 0xF 0 0 not checked not checked not checked not checked not checked not checked 0x0 1 not checked not checked 0
#11write-taken158 1 0x00000000 0x0 1 0x00000004 0x1 0 0xCAFEF00D 0xF 1 0 not checked not checked not checked not checked 1 not checked not checked 0 not checked not checked not checked
#12empty-mask179 1 0x00000000 0x0 1 0x00000004 0x1 1 0xCAFEF00D 0x0 0 0 not checked not checked not checked not checked not checked not checked not checked not checked not checked not checked 0
#13empty-mask-answered193 1 0x00000000 0x0 1 0x00000004 0x1 0 0xCAFEF00D 0x0 0 0 not checked not checked not checked not checked not checked not checked 0x0 1 not checked not checked not checked
#14empty-mask-taken209 1 0x00000000 0x0 1 0x00000004 0x1 0 0xCAFEF00D 0x0 1 0 not checked not checked not checked not checked 1 not checked not checked 0 not checked not checked not checked
#15partial-mask240 1 0x00000000 0x0 1 0x00000004 0x1 1 0xCAFEF00D 0x3 0 0 not checked not checked not checked not checked not checked not checked not checked not checked not checked not checked 0
#16partial-mask-refused254 1 0x00000000 0x0 1 0x00000004 0x1 0 0xCAFEF00D 0x3 0 0 not checked not checked not checked not checked not checked not checked 0x6 1 not checked not checked not checked
#17partial-mask-taken270 1 0x00000000 0x0 1 0x00000004 0x1 0 0xCAFEF00D 0x3 1 0 not checked not checked not checked not checked 1 not checked not checked 0 not checked not checked not checked
#18unaligned299 1 0x00000000 0x0 1 0x00000001 0x0 1 0xCAFEF00D 0x3 0 0 not checked not checked not checked 0 not checked not checked not checked not checked not checked not checked not checked
#19unaligned-refused313 1 0x00000000 0x0 1 0x00000001 0x0 0 0xCAFEF00D 0x3 0 0 not checked not checked not checked not checked not checked not checked 0x1 1 not checked not checked not checked
#20unaligned-taken329 1 0x00000000 0x0 1 0x00000001 0x0 0 0xCAFEF00D 0x3 1 0 not checked not checked not checked not checked 1 not checked not checked 0 not checked not checked not checked
#21unknown-operation356 1 0x00000000 0x0 1 0x00000000 0x2 1 0xCAFEF00D 0x3 0 0 not checked not checked not checked 0 not checked not checked not checked not checked not checked not checked 0
#22unknown-refused370 1 0x00000000 0x0 1 0x00000000 0x2 0 0xCAFEF00D 0x3 0 0 not checked not checked not checked not checked not checked not checked 0x4 1 not checked not checked not checked
#23unknown-taken386 1 0x00000000 0x0 1 0x00000000 0x2 0 0xCAFEF00D 0x3 1 0 not checked not checked not checked not checked 1 not checked not checked 0 not checked not checked not checked

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.

Open the full visualizer

5.4.1.2. The register front end

IO pins

Pin Direction Width Meaning
ADDRESS, IS_WRITE, WRITE_DATA, WRITE_MASK, WRITE_STROBE Input 32, 1, 32, 4, 1 From the register port
READY Input 1 The device's write readiness, passed to BACK_READY
<NAME>_VALUE Input the register's bits Per read-only register: its value from the core
CLK, RST Input 1 each Only when the table has a read-write register
BACK_STATUS, BACK_READY, BACK_READ_DATA Output 3, 1, 32 To the register port
<NAME>_WRITE Output 1 Per writable register: the write strobe (a command's only with value 1)
<NAME> Output the register's bits Per read-write register: its stored value

Implementation

Four groups, in the order an access flows through them:

Part Built from the table
DECODE OFFSET_DECODE, one Decoder<n> on the word index (address bits 2 to n+1), enabled only when the byte bits and every higher bit are 0 — one decoder, not one 32-bit comparison per register. Its outputs are one SELECT_<NAME> line per register
CHECKS Two groups. PAYLOAD: DATA_KNOWN and, per writable register, no unknown bits and nothing above its width; BAD when the selected register's value does not fit. STATUS: the status as three-bit 2:1 selections in the order above, each on word gates (<CHOICE>_LOW = low & ~select, <CHOICE>_HIGH = high & select, <CHOICE> = their OR, all ANDGate<3>/ORGate<3>; the same per-bit gates and depth as a scalar mux); gives BACK_STATUS
WRITES Per writable register its strobe (SELECT_<NAME> AND WRITE_STROBE; a command also needs bit 0), and per read-write register its <NAME>_STATE, a Register<bits> written by that strobe
READS A chain of Mux<2,32>, READ_<NAME> for each readable register, from zero; gives BACK_READ_DATA

BACK_READY is READY passed straight through.

In a compact device the front end is compiled into a gate list with the rest of the device's groups.

The front end is a private group, not an independently selectable catalog family. Writable strobes rely on the register port's already-qualified WRITE_STROBE: driving this group directly bypasses those shared checks. The decoder checks the complete word offset, so an unmapped high address does not alias a low register. Tables reject duplicate or unaligned offsets, offsets at or above 0x80, duplicate names and widths outside 1–32. Command entries must have width 1. Current stored registers reset to zero; nonzero read-write reset values are not implemented by this builder.

REQ_OP, REQ_ADDR and a write mask containing X/Z are rejected by the port's known-bit checks. A selected writable payload with unknown bits is Invalid when the mask is nonzero. Read-only values may themselves contain unknown bits and are returned as data; they are not automatically an error. These rules do not establish equivalence for unknown clocks or handshake controls. The front end's compiled delay table is derived for its actual register list and is not a separately stored whole-device table.

Example: the console's table

Offset Register Access Bits Meaning
0x0 TX write-only data 8 Queue one byte for the host
0x4 STATUS read-only 1 Bit 0 ROOM: the queue has room
0x8 COUNT read-only 3 Bytes waiting

The word index needs two bits (offsets 0, 4, 8), so OFFSET_DECODE is a Decoder<2>. A read of 0x0 selects TX, a write-only register: status Unsupported. A write of 0x141 to TX does not fit 8 bits: Invalid. A read of 0xC: decoder output 3 has no register, so Range.

Source and tests

Register metadata, device tables, front-end builder, port circuit.

Test Coverage
DeviceRegisterPortWidth32Test Admission, held answers under backpressure, alignment, partial and zero masks, bursts, unknown fields, reset
ConsoleDeviceTest, TimerDeviceTest, ButtonDeviceTest, FramebufferDisplayTest, LedPanelTest Device-specific register, queue and payload checks; coverage differs by device (the LED panel in both forms)
GuestHeaderTest, GuestHeaderContentTest The generated headers equal the committed ones; addresses and bit fields

These are not an exhaustive generic read/write/status matrix for every register-table entry or a check that the Markdown maps are generated.