retro-silicon

Components

debug/trace

A trace buffer, the last 2^AW entries a system records, to read back after it stops

Sim passing Sim: passing (3 passed). Used by Nintendo Entertainment System. Source.

BoardStateRun
Sipeed Tang Console 138Kstale2026-10-25, at f2536e6

Verified: the latest run on that board of a system using it passed every test, and the component hasn't changed since. Stale: it has changed since that run.

README

A trace buffer for the test shell: the last 2^AW entries a system records, such as one for each CPU cycle, kept in block RAM to read back after the system stops. A test that fails shows what the system did just before it stopped, cycle by cycle, where a trace CRC only shows that something differed.

Module trace_buffer.

Ports

PortDirWidthMeaning
clk, rstin1Clock; synchronous reset, which empties it and sets count to 0
en, datain1, WRecord an entry
set, set_countin1, 32Load count and empty it
countout32The next entry’s number
filledoutAW+1Valid entries, up to 2^AW
raddr, rdatain, outAW, WRing index; the entry there, a clock later

Parameters

ParameterDefaultMeaning
W32Entry width, a multiple of 8
AW102^AW entries

Status

Sim test (AW = 4), against a software model: bursts of entries, some far longer than the buffer, with sets and resets between. After each burst every valid entry reads back at its ring index, and count and filled match. The test caught two planted bugs: a set that leaves old entries valid, and filled counting past the depth.

In systems/nes, it holds each CPU cycle’s bus (4 bytes, the same as the trace CRC). In the sim, the last 1024 cycles of nestest, stopped at cycle 5,000 and at 26,554, match nestest.log: an opcode fetch at each instruction’s PC and cycle, and no others.