Skip to content

§ 5.5. System Description

A machine is a JSON file. ComputerSystem reads it and builds the circuit: every part, every bus, every connection, the outside pins. The C header the programs are compiled against is generated from that description and the devices' register metadata. Bus wiring and guest addresses therefore share the same configuration.

Component Description Structural Behavioral
ComputerSystem Parts and buses built from a system description Yes No (each part has its own forms)

Catalog: system.computer. Parameters: machine, the name of a built-in description (a file in systems/), or description, the JSON text itself. The games machine also accepts its options with machine (below).

The description

The reference machine, systems/games-machine.json, shortened:

{
  "schema": 1,
  "name": "games-machine",
  "parts": [
    {"name": "CORE",    "family": "rv32im.core.educational-five-stage"},
    {"name": "MEMORY",  "family": "memory.subsystem.32",
     "parameters": {"technology": "sram", "words": "65536", "caches": "none"}},
    {"name": "CONSOLE", "family": "device.console"},
    {"name": "TIMER",   "family": "device.timer", "parameters": {"divisor": "1", "frequency_hz": "0"}},
    {"name": "BUTTONS", "family": "device.buttons"},
    {"name": "DISPLAY", "family": "device.framebuffer",
     "parameters": {"width": "64", "height": "48", "storage_bytes": "4096"}}
  ],
  "buses": [
    {"name": "BUS", "width": 32,
     "masters": [{"name": "CPU_I", "port": "CORE.IMEM_", "access": "fetch"},
                 {"name": "CPU_D", "port": "CORE.DMEM_", "access": "data"}],
     "regions": [
       {"name": "RAM", "base": "0x00000000", "bytes": "0x40000", "execute": true,
        "targets": {"CPU_I": "MEMORY.I_", "CPU_D": "MEMORY.D_"}},
       {"name": "CONSOLE", "base": "0x10000000", "bytes": "0x100", "target": "CONSOLE"},
       {"name": "TIMER",   "base": "0x10001000", "bytes": "0x100", "target": "TIMER"},
       {"name": "BUTTONS", "base": "0x10002000", "bytes": "0x100", "target": "BUTTONS"},
       {"name": "DISPLAY", "base": "0x10003000", "bytes": "0x100", "target": "DISPLAY"},
       {"name": "VIDEO",   "base": "0x20000000", "bytes": "0x1000", "target": "DISPLAY.FB_"}]}
  ],
  "inputs":  [{"name": "ENABLE", "to": "CORE.ENABLE"},
              {"name": "TX_READY", "to": "CONSOLE.TX_READY"},
              {"name": "INPUT_VALID", "to": "BUTTONS.INPUT_VALID"}, "…"],
  "outputs": [{"name": "TX_VALID", "from": "CONSOLE.TX_VALID"},
              {"name": "HALTED", "from": "CORE.HALTED"}, "…"]
}
Section Meaning
parts Each part: a name, a catalog family, its parameters
buses Each bus: its masters (a part's port) and its windows (§ 5.2.2)
inputs, outputs The machine's own pins, each tied to one part pin
check_ports Optional boolean, default false: add a passive checker on every bus link and a PORT_VIOLATION output

A port is written PART.PREFIX: CORE.IMEM_ names the core's pins IMEM_REQ_VALID, IMEM_REQ_READY, …; CONSOLE alone names unprefixed pins.

Building rules

ComputerSystem does exactly this, in order:

  1. Add every part from the catalog, with the build profile's choice of structural or compact form.
  2. Add every bus (bus.interconnect.<width>) and connect each master's port and each target port.
  3. Connect the machine's inputs and outputs.
  4. Connect the machine's CLK and RST to every part and bus input named CLK or RST, or ending in _CLK or _RST. There is one clock.
  5. Check that every part input is driven; an unconnected input is an error that names it.

Before building, the description is checked: unique names, known parts and masters, aligned and non-overlapping windows, every master reaching some window, a fetch master reaching an executable one. The program loader writes an ELF into the first memory subsystem through the executable window at address 0, and refuses a program larger than that window.

Each bus also rejects a master reaching one target port through two windows; any number of masters may share a target port (the bus builds an arbiter tree, § 5.2.2). Target offsets are local unless local is false. Family parameters and pin widths/directions are checked when catalog parts and wires are built; merely parsing JSON does not establish that the circuit can be constructed.

Memory capacity and a bus window are distinct fields. The loader uses the smaller of the selected memory's capacity and its executable window at zero; an oversized window does not create additional storage. The first memory subsystem is main RAM, the first part with the pipeline-state capability is the observed CPU, and the first framebuffer is the captured display. This observation policy is for one CPU and one primary display, not a multicore or multi-display execution model. Reset entry must be zero.

C++ construction

#include "components/selection/BuiltinComponentCatalog.hpp"
#include "components/selection/FidelityPresets.hpp"
#include "system/SystemDescription.hpp"

auto build_led_machine() {
    const auto& catalog = circuit::builtinComponentCatalog();
    auto description = circuit::system::SystemDescription::parse(
        circuit::system::builtinSystemJson("games-machine-leds"));
    return catalog.createRoot(
        {"system.computer", "MACHINE", {{"description", description.toJson().dump()}}},
        circuit::fidelityPreset("visual", catalog));
}

Catalog construction builds the pins, internals, selected child fidelities and manifest. Driving reset/clock and loading a program are separate actions; creating a tree does not run it. std::make_shared<ComputerSystem> skips the component construction path and is not a substitute.

IO pins

Pin Direction Width Meaning
CLK, RST Input 1 each The machine's clock and reset
each inputs entry Input the part pin's width For the games machine: ENABLE, TX_READY, INPUT_VALID, INPUT_BUTTON, INPUT_DOWN
each outputs entry Output the part pin's width For the games machine: TX_VALID, TX_DATA, PRESENT, FRAME_SEQUENCE, HALTED, TRAPPED, TRAP_CAUSE, COMMIT_VALID
PORT_VIOLATION Output 1 Present only with check_ports; OR of the checkers' sticky flags

The machine also offers what the recorded runs observe: the core's architectural state and pending retirement, the main memory and video memory images, and a captured frame.

Adding a device

The LED machine (systems/games-machine-leds.json) is the games machine plus these lines, and nothing else:

"parts":   [ …, {"name": "LEDS", "family": "device.leds"} ],
"regions": [ …, {"name": "LEDS", "base": "0x10004000", "bytes": "0x100", "target": "LEDS"} ],
"outputs": [ …, {"name": "LEDS", "from": "LEDS.LEDS"} ]

The bus gains a route, the guest header gains LEDS_LEDS and LEDS_BLINK, and the machine gains a 16-bit LEDS output. § 5.6 runs a game on it.

This attaches an already implemented catalog family. Creating a new kind of hardware still requires its structural component, registration, contract tests and any compact equivalence proof; JSON does not supply the device's logic. No existing machine recipe needs to know which LED registers exist.

The guest header

system_header <machine> prints the C view of a machine. For the games machine (excerpt):

/* Generated from systems/games-machine.json by system_header; do not edit. */
#define RAM_BASE 0x00000000u
#define RAM_BYTES 0x00040000u
#define CONSOLE_BASE 0x10000000u
...
#define VIDEO_BASE 0x20000000u
#define VIDEO_BYTES 0x00001000u

/* BUTTONS (device.buttons) registers */
#define BUTTONS_LEVELS 0x10002000u /* read-only: Bit n: button n is held */
#define BUTTONS_LEVELS_OFFSET 0x000u
#define BUTTONS_HEAD 0x10002004u /* read-only: Oldest event: button in bits 4..0, bit 8 set for a press */
#define BUTTONS_HEAD_BUTTON_SHIFT 0u
#define BUTTONS_HEAD_BUTTON_MASK 0x1fu
#define BUTTONS_HEAD_DOWN (1u << 8)
...

Every window gets _BASE and _BYTES; every device register its address, offset and bit fields, from the device's register table. Addresses are the ones the core uses: for a device behind a bridge the generator follows the bridge. tools/rv32im/guest/system.h and system-leds.h are generated this way; GuestHeaderTest regenerates them and fails if a committed copy differs. The games' compiled programs did not change when their hard-coded addresses were replaced by these names.

Options of the games machine

machine=games-machine with any of these parameters changes the description before it is built:

Option Changes
caches=1 MEMORY.caches = default
memory=sram, ff or dram MEMORY.technology (default sram)
clock_period MEMORY.clock_period, for an SRAM or DRAM memory; the recorded runner passes the run's period
width, height, video_bytes DISPLAY geometry and storage; the VIDEO window to match
timer_divisor, timer_frequency_hz TIMER parameters
console_depth, button_depth Queue depths
bus=pipelined or single The pipelined bus of § 6.3.2 (default since 2026-11-13) on every bus, the memory's arbiter and the core's fetch, or chapter 5's one-request bus
multiplier=array or iterative The core's array multiplier (default) or the iterative one

Examples

Each built-in machine runs the same bring-up program on an 8 × 8 screen: it writes hello-device to the console, reads the timer's divisor and declared frequency, waits for a button, draws a red square with a green and a blue pixel, presents it, draws a white square in the column the button names, and presents again. Every instruction, data access, device read, frame and console byte is checked against the independent models of § 5.6. The scenarios open in Compact (the core, memory and devices in their compact forms; buses and bridges built from their parts).

Checkpoint What to look at
reset released RST falls; the core fetches from address 0
console: hello-device CONSOLE has sent the line; its queue drains one byte per cycle
press RIGHT The BUTTONS queue holds the event; LEVELS bit 1 is set
frame 1, frame 2 Select DISPLAY: the two pictures; FRAME_SEQUENCE counts them
halted HALTED is high after EBREAK

The program is the same on every machine, but every device access crosses that machine's buses, so the cycle counts differ (§ 5.7 compares them):

Scenario Machine What differs
computer-system games-machine One bus: the reference
computer-system-two-bus games-machine-two-bus Each device access crosses a second router: one more cycle
computer-system-registered-bridge games-machine-registered-bridge …and two bridge registers: three more cycles
computer-system-leds games-machine-leds The program also lights and blinks the LEDs
computer-system-checked games-machine-checked The two-bus machine with a checker on every link: the same cycles as two buses, since the checkers only watch

Open the one-bus machine

Two buses

games-machine-two-bus: expand SYSTEM_BUS and PERIPHERAL_BUS, joined by the pass-through BRIDGE. At console: hello-device, follow a console write from the core through SYSTEM_BUS, the bridge and PERIPHERAL_BUS.

Open the two-bus machine

Registered bridge

games-machine-registered-bridge: the same buses joined by a registered BRIDGE, which holds each request and each answer for one clock edge.

Open the registered-bridge machine

LED panel

games-machine-leds: the LEDS panel, added only through the description. The bring-up program, compiled against this machine's header, also lights the low eight LEDs and, before its second frame, sets BLINK to 2: select LEDS after frame 2 and step through cycles to see them blink, four cycles on and four off.

Open the LED machine

Port checkers

games-machine-checked: the two-bus machine with a CHECK_<BUS>_<LINK> observer on every bus link. PORT_VIOLATION stays low for the whole run; the runner checks it every cycle.

Open the checked machine

The structure, without a program

computer-system-structure builds the games machine with a 4 × 4 screen and runs no program: reset, then released with the core disabled, then one button event queued. It opens in Visual, where each device is drawn as its picture (screen, keys, console, timer) while the core, buses and memory stay structural, and it switches quickly between Logic, Compact and Visual to compare the parts.

All 4 recorded rows of ComputerSystemStructureScenarioTest, 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-visual-v1 / structural (d40d996d657bc2a7). Changing fidelity or the circuit can change these times.

Checkpointzero-based number · timeline label Timesimulator units CLKInput · 1 bit ENABLEInput · 1 bit INPUT_BUTTONInput · 5 bit INPUT_DOWNInput · 1 bit INPUT_VALIDInput · 1 bit RSTInput · 1 bit TX_READYInput · 1 bit COMMIT_VALIDExpected output · 1 bit FRAME_SEQUENCEExpected output · 32 bit HALTEDExpected output · 1 bit PRESENTExpected output · 1 bit TRAPPEDExpected output · 1 bit TRAP_CAUSEExpected output · 4 bit TX_DATAExpected output · 8 bit TX_VALIDExpected output · 1 bit
#0reset35 0 0 0x00 0 0 1 1 not checked 0x00000000 0 0 0 0x0 not checked 0
#1disabled46 0 0 0x00 0 0 0 1 not checked 0x00000000 0 0 0 0x0 not checked 0
#2queued-input62 1 0 0x01 1 1 0 1 not checked 0x00000000 0 0 0 0x0 not checked 0
#3held-disabled67 0 0 0x01 1 0 0 1 not checked 0x00000000 0 0 0 0x0 not checked 0

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 structure scenario

Source and tests

Description schema and validation, parts, links, loading and views, header address traversal, built-in machines.

Timing. ComputerSystem is a structural assembly with one clock. Its parts' delays compose into a machine-specific clock certificate; it has no whole-system compact model or default system delay table. The measured panel certifies the named configurations only. check_ports, arbitrary maps, other depths and memory technologies need their own certificate before using a shorter clock. Numeric execution checks use binary input traffic after reset.

Test Coverage
SystemDescriptionTest Round trip of the games machine, per-master visibility, rejected overlapping, misaligned, unknown and unreachable descriptions
GuestHeaderTest, GuestHeaderContentTest Committed headers equal generated ones; two-bus addresses follow the bridge
ComputerSystemTest and its variants The bring-up program on every memory configuration, both two-bus machines, wide and unsigned simulation times
ComputerSystemLockstepTest Repeated, quantum-split and fidelity-changed runs give identical results
ComputerSystemFaultTest Illegal instruction, fetch from a device, gaps, unmapped data, beyond video memory
ComputerSystemScenarioTest and the four variants The bring-up program on each machine, every check of § 5.6
ComputerSystemStructureScenarioTest The machine's structure: reset, disabled, one queued event