Background · Chapter 3
The RISC-Q architecture
RISC-Q gives each qubit a small RISC-V processor that never touches a sample. It writes registers, and the hardware next to the converters turns those writes into pulses on exactly the scheduled clock cycle. This chapter describes every part of that design as the simulator models it: cores, the address map, posted writes, channels and pulse tables, timed queues, sinks, the board hub and the host window.
This chapter assumes the vocabulary of chapter 2: batches, DACs and ADCs, carriers,
envelopes and demodulation. RISC-Q is an open-source design from the Wu Quantum Application System Group
(github.com/Wu-Quantum-Application-System-Group/RISC-Q).
Its QEC system paper is J. Liu, Y. Lee, Y. Xu, G. Huang and X. Wu, "A Scalable Open-Source QEC System with Sub-Microsecond
Decoding-Feedback Latency", arXiv:2603.16203 (2026). Where this chapter
names a document such as PutHub.md, it is a file of the RISC-Q repository that the model follows.
1One processor per qubit
If a control processor does not produce samples, what does it do?
In this section: the shape of a RISC-Q system and the path of one register write.
RISC-Q's README describes "a RISC-V–controlled SoC for superconducting-qubit control, written in SpinalHDL and targeting the AMD/Xilinx ZCU216 RFSoC board", with one RV32I core per qubit. Each core runs its own program from its own RAM. Next to the converters sit channels: a pulse generator for a DAC, an acquisition unit for an ADC, or a bank of digital lines. A core and its channels are joined by a pipelined link. Above all cores sits the board hub, through which cores share bits, meet at barriers and send each other words.
One pulse, in four events, shows the whole idea. In the feed-forward run of lesson A1 with the
measured bit set to 1, the conditioned x on qubit 2 is caused by one store on core q2 at batch 1,157. The write
reaches the channel q2.gate at batch 1,160 and is fired there. The pulse window opens at batch 1,239, and 6
batches later, at batch 1,245, the pulse is at the DAC port, from where the coax takes it to the qubit. Everything in between
is what this chapter explains: why the write arrives three batches after the store, why it waits 79 batches before the
window opens, and why the opening does not depend on when the write arrived.
2Cores
Each core executes RV32I, the 32-bit base integer instruction set of RISC-V, with the multiply-only Zmmul extension
(QControl/RiscQ/Rv32.lean, after RISC-Q docs/riscv/RISCV.md: single issue, in order). The model
has no CSRs, interrupts, compressed or atomic instructions; an unsupported word decodes to illegal and stops the
core with a fault frame. RAM starts at 0x80000000. The x6y3 build gives each core 8,192 words; the ion and atom
builds of the simulator give 16,384.
The model's core timing is a cost model, not a pipeline simulation: one batch per instruction, five more after a taken
branch or jump (an assumed upper bound from the stages in RISCV.md) and one more for a load or store
(LsuPlugin.md). This matters for how fast firmware runs, for example a decoder, but not for when pulses land, as
long as each write is issued early enough. That is the subject of chapter 4.
3The address map
How does a store instruction reach a pulse generator?
In this section: every register a core can read or write, with the RISC-Q source of each.
A core talks to the rest of the system only through loads and stores to fixed addresses. The table is from
docs/riscq-controller.md; the constants are in riscq/soc.mjs (MAP), after RISC-Q's
software/riscq/map.py.
| Register (core address) | Behavior | RISC-Q source |
|---|---|---|
time 0xBFF8 | Batch time. The core's copy lags the converter edge by the link | ControlMemMaps.scala |
timeCmp 0x4000, waitTimeCmp 0x4008 | A read of waitTimeCmp stalls the core until time + 3 ≥ timeCmp | ControlMemMaps.scala |
done 0x4010 | Sticky completion flag | ControlMemMaps.scala |
| Sinks from 0x4200, 0x20 apart | Readout result (res stalls until settled, real, imag) or an input-edge queue (pop, time, seq, count) | EventLink.scala |
board 0x4300, release 0x4320, mailboxes 0x4340 | Shared group words, barrier release time, unicast words | PutHub.scala |
| Put window from 0x10000, 0x10000 per node | Nodes 0–15 are the core's channels. Higher nodes reach the hub | map.py |
Channel: fire +0, freq +4, dcOffset +8, phaseOffset +0xC, entry i at (i+1)·16, startTime +0x4100 | 16-bit fields sit in bits 31:16 of the written word | PulseParamBuffer.scala |
| Host window from 0x40000000 | Write only. Results for the host | HostWindow.md |
The put window is divided into nodes of 0x10000 bytes. Node k starts at 0x10000 + k · 0x10000. Nodes
0–15 are the core's own channels in the order its build lists them. Nodes 16–19 are the four shared group words of the hub,
nodes 20–35 the sixteen barriers, and from node 36 on the mailboxes of other cores (GROUP_NODE0,
BARRIER_NODE0, INBOX_NODE0 in riscq/soc.mjs). So a store to 0x10000 fires
channel 0, and a store to 0x150000 arrives at barrier 0.
On the ring, each core's channels are listed gate, cz0, cz1, ro,
demod (where the qubit has two CZ partners). At which address does core q0 write to fire its cz1
channel? Answer in hexadecimal.
cz1 is channel 2, node 2: 0x10000 + 2 · 0x10000 = 0x30000. Its fire register is at offset
0, its startTime at 0x34100.4Posted writes and the link
A store into the put window is a posted write: the core sends it and goes on
without waiting for an answer. The PutBridge forwards it as one beat after a one-cycle acknowledgment, and the
PutLink carries it through L register stages, the link depth. A write therefore reaches its channel
1 + L batches after the store (PutBridge.md, PutLink.md). The x6y3 build has
link_pipe = 2, which is why the store at batch 1,157 above reaches q2.gate at batch 1,160. The ion and
atom builds of the simulator use a depth of 4.
Posted writes are what make the link cheap to pipeline. Because nothing waits for an answer, adding a register stage to meet the FPGA's timing costs one batch of latency and no throughput. The cost is that the core does not know when a write arrives, which the timed queues of section 6 make irrelevant. The link also carries traffic back: reports from channels to the core's sinks, and messages to and from the hub.
5Channels and pulse tables
What does a channel hold, and what does a fire do?
In this section: the three channel kinds, the register layout, firing, and the start-time register that advances by itself.
A channel is one of three kinds (riscq/soc.mjs, socSpec): pulse, which drives a DAC;
demod, which opens acquisition windows on an ADC; and dio, which drives and watches sixteen digital
lines. Each holds a register file (Buffer in Timing.lean): a start time, a carrier code, a DC offset, a
phase offset and a pulse table of slots entries, each with a phase, an
amplitude, an envelope address and a duration. The firmware fills the table once, at the start of the program; a calibrated
pulse is then just an index.
To play an entry, the firmware writes the start time to startTime and then the entry's index to
fire. A fire captures the current start time and the entry, hands both to
the timed queues, and then advances startTime by the entry's duration. Three theorems in
Timing.lean pin this behavior down:
| Theorem | Statement |
|---|---|
fire_captures_start | A fire schedules its entry at the buffer's current start time. |
fire_fire_contiguous | A second fire is scheduled exactly one duration after the first, with no time arithmetic in the control program. |
explicit_start_wins | Writing startTime after a fire discards the automatic advance. |
fire_preserves_table | A fire changes no table entry, so a slot can be fired repeatedly. |
decode_layout | startTime at 0x4100 and the fields of entry i at (i+1)·16 decode to the intended registers, provided the table ends below 0x4100. |
fire_fire_contiguous is what makes pulse trains cheap: firing the same channel twice plays two pulses back to back
without the firmware computing the second start time. The firmware this simulator generates writes the start time before every
fire anyway, because its pulses are rarely contiguous.
6Timed queues and leads
How can parameters that take different times to process all take effect on the same batch?
In this section: why each parameter of a pulse has its own pipeline latency, and how the queues hide it.
A pulse generator is a pipeline. The amplitude goes through a multiplier, the phase through a rotation, the envelope address through a memory read, the duration only through a gate. Each takes a different number of cycles from the moment the generator receives it to the moment it affects the output. If all four were applied at the start time, the pulse would begin with the right duration but the wrong amplitude for a few dozen samples.
RISC-Q solves this with one timed queue per parameter. A fired entry is pushed
into every queue 2 batches after its beat (PulseParamBuffer.md). Each queue releases its value at
startTime − lead, where lead is that parameter's own pipeline latency, so every parameter reaches the
output on the start time. The model derives the leads from the block latencies of PulseGenerator.md:
| Parameter | Path | Lead (batches) |
|---|---|---|
| Amplitude | carrier amplitude 27 + complex multiply 6 + gate 1 | 34 |
| Phase | carrier phase 28 + 6 + 1 | 35 |
| Carrier frequency | carrier frequency 29 + 6 + 1 | 36 |
| Lane phasors (16 lanes) | regeneration 16 + CORDIC 19 + 2, then phasor 8 + 6 + 1 | 52 |
| Envelope address | envelope reader 4 + 6 + 1 | 11 |
| Duration | gate 1 + 1 | 2 |
Theorem default_leads in Timing.lean proves that these formulas give exactly 34, 35, 36, 52, 11 and 2
for the default datapath; phase_is_slowest_fired_lead proves that phase is the slowest parameter of a fired pulse.
A queue cannot release an entry the instant it is pushed. The model follows RISC-Q's TimedQueue.scala (RegHead
implementation): an entry can pop no sooner than 3 batches after its push (FIFO write, head register, registered compare), and
consecutive pops of one queue are at least 2 batches apart. Each queue holds the build's queue depth plus one entry: 33 on the
x6y3 build (depth 32), 5 on the default depth of 4. After the generator, the samples cross an adder tree that combines the
channels sharing one DAC, plus 2 stages, to reach the DAC port (dac_pipe in map.py): 6 batches on the
ring, where several channels of one core share each DAC. That is the gap between the window opening at 1,239 and the pulse at
the port at 1,245.
7Sinks: results coming back
Information flows back to a core through sinks, core-local registers starting at
0x4200, one per reporting channel in channel order (sinkAddress in riscq/soc.mjs). There are
two kinds (EventLink.md):
- Result sink, for a demodulation channel. After the acquisition window and the 9-cycle readout decoder, the result is
reported up the link. A load of
resstalls the core until the result of the current window has settled, then returns the bit;realandimaghold the IQ point. The firmware readsreswith an ordinarylw, which simply takes longer. - FIFO sink, for a digital channel. Each change on the input lines becomes an event in a consume-on-read queue of depth 8,
read through
pop,time,seqandcount.
A report takes 3 + 2 + L + 1 batches to reach its sink: up to three puts, a merge, the link and the sink. This is an
assumed worst case of the stages EventLink.md describes, listed as such in docs/riscq-controller.md.
On the ring the measured result is in the measuring core 34 ns after the window closes; lesson E1
takes that interval apart.
8The board hub
How do cores that each drive one qubit coordinate a two-qubit gate or a feed-forward?
In this section: groups, barriers, mailboxes, and the one-message-per-batch arbiter that every core shares.
The hub (PutHub.md) offers three services, all reached by posted writes to put-window nodes above 15:
- Groups. Four shared 32-bit words. A core publishes one bit by writing
(slot << 1) | bitto a group node (publishinriscq/firmware.mjs). The hub updates the word and sends it to every core'sboardregister at0x4300 + 4·group. - Barriers. Sixteen counted barriers. A core arrives by writing the number of members to a barrier node, then reads
releaseat0x4320, which stalls until the last member has arrived. All members get the same release time, which becomes their common time base. - Mailboxes. Unicast words from one core to another, read at
0x4340onward.
The hub is a shared resource with a fixed throughput. Every message waits in a queue of depth 8 per core, and a round-robin arbiter passes one message per batch for the whole board. A message into a full queue is dropped and reported as a fault. A barrier arrival directly behind another for the same barrier waits one more batch. At link depth 4, a published bit reaches every core's board 23 batches after the store, as RISC-Q documents, plus any wait at the arbiter.
| Behavior | Value | Basis |
|---|---|---|
| Publish to every core's board | 23 batches at link depth 4, plus the wait at the arbiter | PutHub.md; conformance test |
| Hub throughput | 1 message per batch, whole board | PutHub.md |
| Queue per core | 8 messages | PutHub.md |
| 8 cores publish on the same batch | reach every board after 23 to 30 batches, in core order | riscq/limits.mjs, publishBurst, run for this chapter |
| 8 cores arrive at one barrier on the same batch | counted 2 batches apart; all hold the common time 37 batches after the arrival | riscq/limits.mjs, barrierFanIn, run for this chapter |
| Arbiter fairness | grants only a core with a message waiting, and grants one in every batch in which any core has one | proved: nextSource_waiting, nextSource_isSome in Soc.lean |
The hub arbiter follows the statements of PutHub.md, not an RTL trace, and the model starts the arbiter's round at
core 0, an assumption. One bit per message and one message per batch means the hub carries at most 500 bits per microsecond
at 500 MHz. Lessons B4 and E4 measure what that limit means for feed-forward
and for error-correction traffic.
Run the feed-forward program with the measured bit set to 1. How many messages does the hub pass in the whole run?
summary.hub.served): the three
active cores (q0, q1, q2) arrive at barrier 0 before the first segment and at barrier 1 before the conditioned gate, and q0
publishes the measured bit once. Open the control view in the workspace and
step through the hub's frames to see each one.A core writes a message to the hub while its queue of 8 is full. What does the model do?
- The store stalls the core until there is room.
- The message is dropped and the run reports a fault.
- The oldest message in the queue is overwritten.
- The hub passes two messages in that batch.
docs/riscq-controller.md). The limit sweeps show that eight cores publishing without pause overflow their
queues.9The host window
Results leave the controller through the host window at 0x40000000 (HostWindow.md). It is write
only: a core stores a word there and the host reads it later. The firmware this simulator generates writes every measured or
decoded bit to the host window at the same offset as its slot in the core's bit table (storeBit in
riscq/firmware.mjs), and the compiled Helios decoder writes each output line there. A run's summary lists every
host write with its batch, core and value.
10How close the model is to RISC-Q
Three firmware binaries from the RISC-Q repository run unmodified in the model and reproduce what RISC-Q's own RTL simulations
assert (tests/riscq-firmware.test.mjs): pulse_sched.elf opens one gate pulse on DAC 8 exactly at its
start time for six batches; xcore.elf gives two cores the same barrier time, delivers the word 0x77 to core 1's
mailbox and opens core 1's pulse at that time plus 1,024; host_window.elf writes its ramp, byte lanes and sentinel and
raises done. Three latencies are assumed rather than documented: the core's time lag, the report path and the
branch and bus penalties. Chapter 6 separates what is proved, tested and assumed.
What to remember
- Each qubit has an RV32I core with its own RAM. Cores write registers; channels next to the converters make the samples.
- A store into the put window is a posted write. It reaches its channel 1 + L batches later, without the core waiting.
- A channel holds a pulse table. Writing
startTimeand then an index tofireschedules that entry. - Timed queues release each parameter early by its own lead (34, 35, 36, 52, 11, 2 batches), so all land on the start time.
- Results come back to core-local sinks: a result register that stalls until settled, or an event queue of depth 8.
- The board hub gives shared bits, barriers and mailboxes, one message per batch for the whole board, eight queued per core.
- Results for the host go to the write-only host window at 0x40000000.