Burst: a whole array through a port, one word per clock¶
Status: design, 2026-10-14. Nothing implemented, and not to be yet (Luciano):
the idea is recorded. The design is Luciano’s
(the burst block, a size register, a counter, an instruction that waits in
place); this note adds the refinements discussed on 2026-10-14 and the
timing measured before writing it. Since 2026-10-24 the burst is part of
a larger design, a memory for arrays with its own controller and MAC
(array-unit.md): the decisions on its instructions are
taken there. Marks: fact (read in the code),
measured, deduced (reasoned, to be checked in simulation).
1. The problem¶
A program that hands an array to a FIFO writes it word by word. Measured on the v7.1 compilers, an 8-int array to port 0 (2026-10-14):
form |
instructions per word |
code size |
|---|---|---|
|
8 ( |
fixed |
Dirac |
3 ( |
3 words per element |
the least the ISA allows ( |
2 |
2 words per element |
Fact: OUT p writes the accumulator, so with today’s instructions two
are needed per word. Unrolling (the Dirac form) costs program memory in
proportion to the array, which rules it out for large arrays (Luciano). The
Dirac form also has two defects of its own, independent of the burst: it
emits MLT 1 when the scalar is 1 (a cycle per word, and the multiplier is
synthesized for nothing), and out(p, |a⟩) without a scalar is a syntax
error.
The goal: one word per clock, code of fixed size, and the transfer stops by itself while the FIFO is full, without losing a word.
2. The design¶
A burst block in the core, generated only when the program uses its
instructions (pay only for what you use):
a size register, written by an instruction of its own;
a pointer (the counter), set to the array’s first address by a second instruction, which also computes, once, the end address (first + size);
a burst out instruction that waits in place, as
TOM/CADdo (fact:pc_selfincore.vmakes the fetch take the same address again), sending one word per clock until the pointer reaches the end;symmetric, a burst in instruction that fills an array from an input port, with the same registers.
Assembly, names to be chosen (three letters, as the mnemonic convention):
LOD 8 ; acc = size (a constant or a computed value)
BSZ ; burst: size <- acc
BPT main_a ; burst: pointer <- &a[0], end <- &a[0] + size
BOT 0 ; burst out: a[pointer] to port 0 while the port may take it; leaves at the end
Refinements over the first sketch, and why:
Size from the accumulator (like
SETwrites memory from it): serves a constant and a size computed at run time. The operand field stays free.End computed once, in
BPT: during the transfer the hardware only increments the pointer and compares it with the end. The adder is out of the per-word path.The stop condition from a register: “the next word is the last” registered one clock ahead, so the fetch path (
pc_self) gets a flip-flop, not a comparator. (Deduced; the critical path is measured, item 6.)The port is the operand of
BOT, as inOUT p; one-hotout_en[p]as today.
3. Timing of today’s OUT (measured)¶
Probe on a program LOD 5; SET a; OUT 0; LOD 7; OUT 0; LOD 9; OUT 1; LOD 11; OUT 0, values sampled at each rising edge (what the generated testbench
and a FIFO see), 2026-10-14:
edge |
PC |
decoder |
pin |
pin |
|---|---|---|---|---|
7 |
4 |
1 (the first |
00 |
5 |
8 |
5 |
0 |
01 |
5 |
9 |
6 |
1 |
00 |
7 |
10 |
7 |
0 |
01 |
7 |
12 |
9 |
0 |
10 |
9 |
14 |
11 |
0 |
01 |
11 |
Facts behind it (core.v, processor.v): out_en is the decoder’s
id_out_en through one register (io_ctrl: en_out <= out_en); the data
pin out is io_out = mem_data_out, the ALU output (ula_out), with no
register. Measured: the two are valid in the same clock, the one in
which the OUT is in the ALU stage; the consumer writes on the edge that
ends it. The generated testbench recorded 5, 7, 11 on port 0 and 9 on port
1, as written.
The burst must keep exactly this alignment. Deduced: it does if every
step of BOT does what LOD and OUT already do: the address pointer
goes to the data memory in the decode stage (as LOD’s operand does; the
memory is synchronous, the word comes back one clock later), the word
reaches the ALU stage and goes out through ula_out, and the decoder’s
enable goes through the same io_ctrl register. Checked in simulation
before anything else (step 1 of section 7). The input side has its own
alignment (req_in is not registered, the processor captures io_in at
the edge that ends the INN’s decode cycle, ula_in2_ctrl); BIN has to
be checked against it the same way, never assumed from BOT.
4. The full FIFO¶
A new input pin per output port, out_ok[p] (name to be chosen),
generated only with BOT p in the program. The top level ties it to the
FIFO: ~full of myFIFO, ~wrfull of myDCFIFO. While it is 0, BOT
waits in place: no out_en, the pointer holds.
Deduced, the trap: the decision to send word i+1 is taken in decode
while word i is still on its way (it is written one clock later). With a
plain ~full, a FIFO with one free place accepts the decision for two
words and the second is lost. Three ways out, to be chosen by measuring:
the top level gives “at least two free places” (
usedw/wrusedwagainstLENGTH - 2): no core logic, but each top level has to know it;the burst block counts the word in flight and stops one ahead: the rule lives in the core, the pin keeps the plain meaning “not full”;
myFIFO/myDCFIFOgain analmost_fulloutput with that meaning.
myDCFIFO’s wrfull is computed from a pointer synchronized from the
other clock: it can say full longer than needed (safe), never less
(deduced from the Gray-code design, docs/design/myfifo.md).
5. Open decisions¶
The accumulator. Fact: the ALU writes
raccevery clock, so aBOTbuilt fromLODsteps leaves the last word in the accumulator. Keep it so (document it; the compiler knows) or hold the accumulator during the burst (a multiplexer on the accumulator path, in every processor that uses the burst).Which rule against the full FIFO (section 4).
Interrupts. Fact: an interrupt during a
TOM/CADwait puts a pair out of step (toma-and-cade.mdsection 6). A#PRACArestart during a burst leaves part of the array sent; the same advice (do not interrupt during a burst) or a rule.Several bursts at once. One size/pointer pair serves one transfer at a time;
BOTends before the next instruction runs, so one pair is enough unless aBOTon one port must interleave with another. Assumed not needed.Names and opcodes. Fact: opcodes go up to 107 of 128 (7 bits). The new ones fit at the end of the table, so no opcode moves and an older
.asmkeeps its meaning; a new SAPHO is still needed for the new instructions (SAPHO and asmcomp from the same release, as since v5.5).The languages. C±:
out(p, a)with a whole array, or the Dirac formout(p, |a⟩)mapped to the burst (cmmcomp: Luciano’s code, diff first). C++: anout(p, array)overload in cppcomp. The size is the declared one, or a part of the array (out(p, a, n))?The old item 17 of TODO.md (filling and copying arrays faster; merged with the burst on 2026-10-18, Luciano: one block for both; its analysis is kept in issue #18) proposes an index register
Xwith post-increment. The burst pointer is that register plus an end and a wait in place. If both are built, they should be one block: the same pointer would give a fill at one word per clock (a burst store of the accumulator:mem[pointer] <= acc, waiting in place to the end) and the sequential loads of that item. Decide the instruction set with both in view, so thatBSZ/BPTare not designed twice.
5a. Checked, and holes still open (2026-10-14)¶
Checked: one word per clock is possible. A wait in place repeats the
instruction every clock with no bubble: the jump is decided in the cycle
the instruction leaves the instruction memory (toma-and-cade.md
section 5), and in the probe of section 3 @fim JMP fim shows PC 12 at
every edge.
Holes, to be closed before implementing:
The input side has the same one-word trap, reversed. A FIFO’s empty flag changes only after the read, so
BINcan decide to read the next word from a FIFO that is already empty and take garbage.myFIFOalready has analmost_emptyoutput; the margin rule of section 4 applies here too.The element type. Today
outof a float sends its raw bits (with a warning) andfoutconverts it to an int. A burst of a float array needs the same choice; the word goes through the ALU, so a conversion per word (F2I) is possible. Acompelement is two words.Size 0 and size 1. The registered “next is the last” flag must handle both: with size 0,
BOTsends nothing and does not wait.The compiler passes that drop and share data.
asm_reachremoves arrays nothing reads, andasm_sharelets variables whose lives do not overlap share a word. Both must countBPTas a read of the array (and, forBIN, a write of all of it), or the array is dropped or overwritten by another variable, silently. A small test passes; a large program breaks.OUTandBOTon one port. A plainOUTignoresout_ok, so a program mixing both on one port can still overflow the FIFO. Document it, or makeOUTwait onout_oktoo (a change to today’s behaviour, with its own pin cost).Simulation and its consumers. The generated testbench has to drive
out_ok/in_ok(tied to 1, or better a model FIFO that fills, to test the stop), and so do the Verilator harness, the mirror block AURORA reads (YANC_SIM_VIS) andgen_gtkw(the new pins in the view).
6. Cost, to be measured¶
Fact (method): the critical path is measured on the whole processor,
Scripts/hw/fmax.sh on sapho_all, never on the block alone. Here:
sapho_all without the burst must not change at all (the generate is off),
and a variant with BOT gives the new path: the pointer multiplexer into
the data-memory read address, and out_ok into the fetch. Area with
Scripts/hw/area.sh NOSHARE=1.
7. Steps¶
HDL: the
burstblock andBOT,BSZ,BPTbehind their generate; asmcomp knows the opcodes (isa.tsv,check_isa.py). A hand-written.asmtest with an 8-word array intomyFIFO: the timing of section 3 checked on the waveform, then a FIFO smaller than the array, with a slow reader, so thatout_okstops the burst; no word lost or repeated.The same into
myDCFIFOon two clocks.BINand its test (FIFO into an array, waiting on empty).fmax.shandarea.sh(section 6).C± (the diff to Luciano first), then C++; regress fixtures in both.
8. For the documentation (issue #40)¶
The new forms in the language chapters, and the pins
out_ok/in_okin “Several processors” (what to tie them to, the two-free-places rule if that is the one chosen).The instructions in the instruction reference (generated from
isa.tsv).What the accumulator holds after a burst, and that an interrupt during a burst leaves the array half sent.