Skip to content

§ 5.4.6. Display

A screen: pixel memory the program draws into, and a register to show a finished frame. Pixels are one byte each in RGB332 (3 bits red, 3 green, 2 blue).

Component Description Structural Behavioral
FramebufferDisplay Pixel memory on its own port, six control registers Yes Yes

Catalog: device.framebuffer.

Parameter Default Values
width 4 1–4096 pixels
height 4 1–4096 pixels, with width × height ≤ 262144
storage_bytes 0 0: the next power of two covering the surface; otherwise a power of two in 4–262144 covering it

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
FB_REQ_VALID, FB_REQ_OP, FB_REQ_ADDR, FB_REQ_WRITE_DATA, FB_REQ_WRITE_MASK, FB_RSP_READY Input 1, 3, 32, 32, 4, 1 Pixel memory requests (byte masks allowed)
FB_REQ_READY, FB_RSP_VALID, FB_RSP_READ_DATA, FB_RSP_STATUS Output 1, 1, 32, 3 Pixel memory answers
FB_CLK, FB_RST Input 1 each Pixel memory clock and reset (the system clock)
PRESENT Output 1 A frame is presented at this edge
FRAME_SEQUENCE Output 32 Frames presented since reset

Registers

Offset Register Access Bits Meaning
0x00 WIDTH setting 32 Visible pixels per row
0x04 HEIGHT setting 32 Visible rows
0x08 STRIDE setting 32 Bytes from one row to the next (= width)
0x0C FORMAT setting 32 1: RGB332
0x10 FRAME_SEQUENCE read-only 32 Frames presented
0x14 PRESENT command 1 Show the current pixel memory as a new frame

Behavior

The pixel at (x, y) is byte y × STRIDE + x of pixel memory, which the machine places at VIDEO_BASE. Drawing changes memory only; writing 1 to PRESENT marks a finished frame: FRAME_SEQUENCE increments and the recording captures the settled pixels. Reset clears the control state and keeps the pixels.

PRESENT is the qualified command strobe, not a host refresh timer. Writing 0 does not present; writing a value other than 0 or 1 is Invalid. Each successful command increments the sequence once modulo 2^32, even if no pixel changed. There is one pixel store, with no back buffer, scanout engine or automatic vertical refresh. Capture observes that store when the command is recorded.

For RGB332, bits 7..5 are red, 4..2 green and 1..0 blue. Within a little-endian 32-bit memory word, mask bit n updates byte n; an aligned write with all four mask bits updates four consecutive pixels. Storage padding beyond width * height is addressable but is not displayed. Access past storage capacity returns Range; the control-register port instead requires a full or empty mask. Standalone callers must drive FB_CLK/FB_RST as well as CLK/RST; ComputerSystem connects both to its one clock and reset.

#include "platform.h"

void draw_pixel_example(uint32_t x, uint32_t y, uint8_t color) {
    if (x >= io_read(DISPLAY_WIDTH) || y >= io_read(DISPLAY_HEIGHT)) return;
    const uint32_t stride = io_read(DISPLAY_STRIDE);
    io_write8(VIDEO_BASE + y * stride + x, color);
    present(); // platform helper: fence, PRESENT = 1, fence
}

Implementation

The structural form shows the grouped circuit. The compact form runs compiled versions of the same groups with characterized storage, register and queue models; control delays come from the structural groups. Contract tests compare both forms; the visual preset selects the compact form.

Part Contents
PORT DeviceRegisterPort<32> for the control registers
REGISTERS The front end; the geometry and format are constants
FRAME_COUNTER A Register<32> and an adder, stepped by PRESENT_WRITE
PIXELS A flip-flop memory endpoint (§ 3); the scalable native device above 512 bytes

Timing. Register execution, frame-count storage and pixel-memory transactions use their respective gate-proven timing; the composed display does not add a whole-device delay. A PRESENT snapshot is a settled observation, not proof that an earlier unacknowledged pixel write completed. Software orders writes before the command. Register payloads with unknown bits are rejected for nonzero-mask commands; unknown pixel values remain observable as unknown data rather than being replaced with a guessed color. Binary geometry and clock/handshake inputs after reset are the game-run boundary.

Visual abstraction

A compact or collapsed display is drawn as its pixel surface at the selected time; selecting it opens a preview in the inspector. Scrubbing reads recorded pixel history and never runs the program.

Examples

The scenario reads the four settings of a 4 × 4 display, then draws a picture one word (one row of four pixels) at a time: a red frame around a green middle. present shows it as frame 1. A byte-masked write then turns the pixel at (1, 1) blue without touching the rest of its row, and frame 2 is presented. An access past the 16-byte pixel store is refused (Range), as is a write to the read-only WIDTH setting.

All 20 recorded rows of FramebufferDisplayScenarioTest, 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 FB_CLKInput · 1 bit FB_REQ_ADDRInput · 32 bit FB_REQ_OPInput · 3 bit FB_REQ_VALIDInput · 1 bit FB_REQ_WRITE_DATAInput · 32 bit FB_REQ_WRITE_MASKInput · 4 bit FB_RSP_READYInput · 1 bit FB_RSTInput · 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 FB_REQ_READYExpected output · 1 bit FB_RSP_READ_DATAExpected output · 32 bit FB_RSP_STATUSExpected output · 3 bit FB_RSP_VALIDExpected output · 1 bit FRAME_SEQUENCEExpected output · 32 bit PRESENTExpected output · 1 bit REQ_READYExpected output · 1 bit RSP_READ_DATAExpected output · 32 bit RSP_STATUSExpected output · 3 bit RSP_VALIDExpected output · 1 bit
#0reset34 0 0 0x00000000 0x0 0 0x00000000 0x0 0 1 0x00000000 0x0 0 0x00000000 0x0 0 1 0 not checked not checked 0 not checked not checked 0 not checked not checked 0
#1ready45 0 0 0x00000000 0x0 0 0x00000000 0x0 0 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 0
#2width156 0 0 0x00000000 0x0 0 0x00000000 0x0 0 0 0x00000000 0x0 0 0x00000000 0xF 0 0 not checked not checked not checked not checked not checked not checked not checked 0x00000004 0x0 1
#3height290 0 0 0x00000000 0x0 0 0x00000000 0x0 0 0 0x00000004 0x0 0 0x00000000 0xF 0 0 not checked not checked not checked not checked not checked not checked not checked 0x00000004 0x0 1
#4stride443 0 0 0x00000000 0x0 0 0x00000000 0x0 0 0 0x00000008 0x0 0 0x00000000 0xF 0 0 not checked not checked not checked not checked not checked not checked not checked 0x00000004 0x0 1
#5format-rgb332582 0 0 0x00000000 0x0 0 0x00000000 0x0 0 0 0x0000000C 0x0 0 0x00000000 0xF 0 0 not checked not checked not checked not checked not checked not checked not checked 0x00000001 0x0 1
#6no-frames-yet720 0 0 0x00000000 0x0 0 0x00000000 0x0 0 0 0x00000010 0x0 0 0x00000000 0xF 0 0 not checked not checked not checked not checked not checked not checked not checked 0x00000000 0x0 1
#7row-0-red851 0 0 0x00000000 0x1 0 0xE0E0E0E0 0xF 0 0 0x00000010 0x0 0 0x00000000 0xF 0 0 not checked not checked 0x0 1 not checked not checked not checked not checked not checked not checked
#8row-1-red-green979 0 0 0x00000004 0x1 0 0xE01C1CE0 0xF 0 0 0x00000010 0x0 0 0x00000000 0xF 0 0 not checked not checked 0x0 1 not checked not checked not checked not checked not checked not checked
#9row-2-red-green1107 0 0 0x00000008 0x1 0 0xE01C1CE0 0xF 0 0 0x00000010 0x0 0 0x00000000 0xF 0 0 not checked not checked 0x0 1 not checked not checked not checked not checked not checked not checked
#10row-3-red1235 0 0 0x0000000C 0x1 0 0xE0E0E0E0 0xF 0 0 0x00000010 0x0 0 0x00000000 0xF 0 0 not checked not checked 0x0 1 not checked not checked not checked not checked not checked not checked
#11read-row-11369 0 0 0x00000004 0x0 0 0x00000000 0xF 0 0 0x00000010 0x0 0 0x00000000 0xF 0 0 not checked 0xE01C1CE0 0x0 1 not checked not checked not checked not checked not checked not checked
#12present1519 0 0 0x00000004 0x0 0 0x00000000 0xF 0 0 0x00000014 0x1 0 0x00000001 0xF 0 0 not checked not checked not checked not checked not checked not checked not checked not checked 0x0 1
#13frame-11546 0 0 0x00000004 0x0 0 0x00000000 0xF 0 0 0x00000014 0x1 0 0x00000001 0xF 0 0 not checked not checked not checked not checked 0x00000001 0 not checked not checked not checked not checked
#14pixel-1-1-blue1651 0 0 0x00000004 0x1 0 0x00000300 0x2 0 0 0x00000014 0x1 0 0x00000001 0xF 0 0 not checked not checked 0x0 1 not checked not checked not checked not checked not checked not checked
#15read-row-1-again1785 0 0 0x00000004 0x0 0 0x00000000 0xF 0 0 0x00000014 0x1 0 0x00000001 0xF 0 0 not checked 0xE01C03E0 0x0 1 not checked not checked not checked not checked not checked not checked
#16present-again1917 0 0 0x00000004 0x0 0 0x00000000 0xF 0 0 0x00000014 0x1 0 0x00000001 0xF 0 0 not checked not checked not checked not checked not checked not checked not checked not checked 0x0 1
#17frame-sequence-22071 0 0 0x00000004 0x0 0 0x00000000 0xF 0 0 0x00000010 0x0 0 0x00000000 0xF 0 0 not checked not checked not checked not checked not checked not checked not checked 0x00000002 0x0 1
#18past-storage2215 0 0 0x00000010 0x0 0 0x00000000 0xF 0 0 0x00000010 0x0 0 0x00000000 0xF 0 0 not checked not checked 0x2 1 not checked not checked not checked not checked not checked not checked
#19width-read-only2364 0 0 0x00000010 0x0 0 0x00000000 0xF 0 0 0x00000000 0x1 0 0x00000008 0xF 0 0 not checked not checked not checked not checked not checked not checked not checked not checked 0x3 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.

Open the full visualizer

Source and tests

Parameters and bounds, display and memory wiring, register definitions, verification.

Test Coverage
FramebufferDisplayTest Geometry registers and parameters, storage sizes, pixel reads and writes, present and sequence, 64×48, 128×96, 320×200 and 97×65 surfaces (compact form)
FramebufferDisplayScenarioTest The recorded example, structural and compact forms compared