FPGA
Upduino 3.1 and iCESugar-Pro demos, place and route, timing reports
1 Demo target
The demo target is the Upduino 3.1 (iCE40UP5K-SG48), a low-cost board with an onboard 12 MHz oscillator and 8 MB PSRAM. The whole toolchain is open source: Yosys for synthesis, nextpnr-ice40 for place and route, icepack for the bitstream, and icetime for timing analysis.
The demo top module registers the decode on the board clock, so the one-cycle latency and the timing closure are measurable with a real clock:
| Signal | Source | Destination |
|---|---|---|
clk |
pin 20, onboard 12 MHz oscillator | global clock |
code[15:0] |
GPIO switch module | decoder input |
i[4:0], m[4:0], f[4:0] |
decoder output | LED groups |
led_valid |
~valid, range check |
onboard green LED (negative logic, lights on valid code points) |
Pin constraints are verified against the Upduino v3.1 reference PCF from the icestudio project.
2 Place and route flow
synth_demo.ys -> out/tagma_demo_top.json (Yosys, iCE40)
nextpnr-ice40 -> out/tagma_demo_top.asc (place and route, --freq 12)
icepack -> out/tagma_demo_top.bin (bitstream)
icetime -> reports/icetime.txt (timing report)
3 Timing results
| Metric | shift-subtract (naive) | multiply-shift (current) |
|---|---|---|
| ICESTORM_LC | 177 / 5280 (3%) | 255 / 5280 (4%) |
| SB_IO | 33 / 39 | 33 / 39 |
| SB_GB | 1 / 8 | 1 / 8 |
| Logic levels | 72 | 33 |
| Critical path | 115.90 ns | 59.55 ns |
| Fmax | 8.63 MHz | 16.79 MHz |
The multiply-shift version closes the 12 MHz board clock with margin.
4 Second target: iCESugar-Pro (ECP5)
The same RTL builds for the iCESugar-Pro v1.3, an ECP5 LFE5U-25F-6BG256C in a DDR SODIMM module with a 25 MHz crystal. The second device is not there to beat the iCE40 figures. It is there to check that the demo’s realization is board data rather than a one-board artifact.
| Aspect | Upduino 3.1 | iCESugar-Pro v1.3 |
|---|---|---|
| Device | iCE40UP5K-SG48 | ECP5 LFE5U-25F-6BG256C |
| Synthesis | synth_ice40 |
synth_ecp5 |
| Place and route | nextpnr-ice40 --up5k --package sg48 |
nextpnr-ecp5 --25k --package CABGA256 --speed 6 |
| Packing | icepack |
ecppack |
| Constraints | PCF | LPF |
| Clock | 12 MHz | 25 MHz |
| Logic | 255 ICESTORM_LC / 5280 | 49 TRELLIS_COMB and 16 TRELLIS_FF / 24,288 |
| I/O | 33 SB_IO / 39 | 33 TRELLIS_IO / 197 |
| Multipliers | not reported | 4 MULT18X18D / 28 |
| Critical path | 59.55 ns | 22.28 ns |
| Fmax | 16.79 MHz | not reported |
The two critical-path figures are not the same quantity. On the iCE40, icetime reports the whole placed critical path. On the ECP5, nextpnr-ecp5 reports the worst cross-domain path, input to register, because the design has no register-to-register path to constrain. They are two device results, recorded as such.
Three board facts decide the constraints. A bank takes one IO standard and nextpnr rejects a mix, so the RGB LED bank at 2.5V holds the only header pin that can use it, and that pin plus the validity pin are LVCMOS25 while everything else is LVCMOS33. Header labels come from the board’s pin map. The code inputs are pulled up, so an unwired header reads 0xFFFF, which is invalid, and a switch closes to GND to clear a bit.
The demo drives led_valid on ball A12, which is the blue channel of the onboard RGB LED and lights on a high level. That is the opposite of the Upduino’s negative-logic LED, so the polarity is a top-level parameter instead of a fixed inversion.
The colours come from the vendor schematic, where three diodes carry the channel pins to three balls. The vendor README lists the same balls as {A11, A12, B11}, an order that reads like red, green, blue and is not.
| Ball | Diode and pins | Channel |
|---|---|---|
| A11 | D303, G- G+ |
green |
| A12 | D301, B- B+ |
blue |
| B11 | D302, R- R+ |
red |
The streaming designs name their LED signals by function and constrain them by ball, so a later correction to the colour mapping cannot change what a build drives.
The module and its Ext-Board each carry a debugger, and only the module’s iCELink reaches the ECP5, which is the USB-C port on the module in Figure 1. The Ext-Board’s DAPLink answers the CMSIS-DAP handshake and returns 0xffffffff for every JTAG IDCODE, so the carrier’s ports program nothing on the FPGA. The programming path and the wiring table are in hw/boards/icesugar_pro/README.md.
5 Streaming pipeline
The demo and the streaming design answer different questions. The demo takes one code point from pins and reports a decode, which is the N=1 case. A pipelined decoder takes one code point per clock and never idles, which is the case where a hardware realization can be fed by a stream instead of by a caller. tagma_decoder_pipe keeps the arithmetic and the constants of the combinational unit and splits it at the multiplier boundary.
| Stage | Work |
|---|---|
| 0 | offset = code - 0xAC00 |
| 1 | j = (q4 * 9363) >> 16 |
| 2 | i = (j * 781) >> 14 |
| 3 | m = j - 21 * i, f = offset - 28 * j |
The two large constants have no shift-and-add form, so they keep a multiplier each. The two small ones do: 21 = 16 + 4 + 1 and 28 = 32 - 4. Putting the remainders in their own stage therefore replaces two multipliers with adder trees, which shortens the path and removes two MULT18X18D.
The offset subtraction has a stage of its own because at three stages it was 1.2 ns of the 7.8 ns path into the first multiplier, and a register costs less than that. Latency is four clocks and throughput is one code point per clock. make sim-pipe drives the valid range continuously for four sweeps and compares every emitted triple against the combinational decoder, which the other channels already pin at 11,172 of 11,172 points. An exact match at every cycle after the fill carries that evidence to the pipeline.
PASS: 44689 outputs checked over 44693 clocks, 4 full sweeps of the valid space, one code point per clock
Place and route reports a clock for this design, which the demo could not produce. tagma_pipe_top sources its code from a counter, so its paths run register to register.
| Metric | Pipeline alone | Self-check build |
|---|---|---|
| Clock | 25 MHz board oscillator | 40 MHz from the 25 MHz oscillator |
| Fmax, register to register | 148.77 MHz | 56.62 MHz |
| Fmax, reference path | not present | 51.96 MHz |
| TRELLIS_COMB | 51 | 187 |
| TRELLIS_FF | 72 | 181 |
| MULT18X18D | 2 | 6 |
| Bitstream | 582,369 bytes | 582,369 bytes |
The critical path is now stage 1: the counter into the offset subtract, into the multiply by 9363, into j_q, at 7.82 ns. The multiplier’s 3.93 ns of logic plus the routing around it is the floor for this shape. Registering the offset subtract as its own stage would leave about 6.5 ns, roughly 154 MHz, for a fourth stage and one more clock of latency, which is not a good exchange at the rates this board can supply.
A bitstream that drives unwired header pins proves only that it programmed, so the streaming build carries its own check. tagma_pipe_check_top runs the pipeline and the combinational reference from one counter, delays the reference by the pipeline depth, and compares the two triples at every clock. A mismatch latches an indication that stays lit, so a dark error channel after minutes of running is the observation that the two agree at one code point per clock on the device.
| Signal | Ball | Meaning |
|---|---|---|
led_clk |
A11 | blinks at 2.4 Hz while the fast clock runs |
led_err |
A12 | lights and latches on any mismatch |
led_swept |
B11 | lights once 2^28 clocks have been compared |
The third indication is a rate reading rather than a completion flag, because the comparison saturates and never clears. 2^28 clocks is 6.71 s at 40 MHz and 10.74 s at 25 MHz, so the interval between configuration and that channel lighting separates the two clocks with a stopwatch and no instrument. The PLL is set to 40 MHz rather than the 50 MHz it can also produce because the reference decoder sits in the same clock domain: its path measures 19.2 ns, which is 7.6 percent of margin at 50 MHz and about 30 percent at 40 MHz. The stages that raised the pipeline to 148.77 MHz did not move that path, because the reference is what binds in this build.
The first build of the check compared against 28'hFFFFFF, six hex digits against a 28-bit register. The comparison type-checked and the design built, but the count saturated at 2^24 clocks and the readout fired after 0.42 s instead of 6.71 s. A literal and a register that disagree in width still compare, so an elapsed-time claim has to be checked against the constant rather than against the declared width.
6 Verification read through the debugger
The verdict and the PLL rate were read over the programming cable.
The PLL rate is a build parameter, which makes the pipeline’s 148.77 MHz estimate something the die can answer.
| Build | Timing | pin_match |
Measured clock |
|---|---|---|---|
| 40 MHz | PASS | 1 | 40.00 MHz, 40.06 MHz |
| 100 MHz | PASS | 1 | 100.16 MHz, 99.90 MHz |
| 120 MHz | PASS | 1 | 120.10 MHz, 120.02 MHz |
| 125 MHz | PASS | 1 | 124.97 MHz, 124.91 MHz |
| 140 MHz | PASS | 1 | 139.90 MHz, 139.99 MHz |
| 150 MHz | rejected, 145.99 MHz (FAIL at 150.01 MHz) |
not built | not run |
Every row was measured on the four-stage build, and each reports the clock from two dividers that count different things.
Every rate that builds also reproduces the tagma_core checksum on the die, so the fastest verified point is 140 million code points per second. At 150 MHz nextpnr-ecp5 refuses the build and the flow stops rather than programming a design that would run out of time. The image’s own ceiling is 145.99 MHz against the pipeline’s 148.77, and both critical paths are the same multiply, so the difference is 0.13 ns of routing rather than anything the checksum adds.
An indicator that can only show one value proves nothing, so the same flow was built with a deliberately wrong constant. It reads zero, and the correct constant reads one, which is what makes the pass above a comparison that ran.
The floor is the multiplier. Both the timing-only top and the verification image report the same critical path, the multiply by 9363, with 4.45 ns of logic and about 2.3 ns of routing on either side, and no register can divide a multiplier. Going faster would need the DSP block’s internal pipeline registers, which means instantiating an ECP5 primitive in RTL that also has to synthesise for the iCE40, or a shift-and-add tree instead of the multiply. Neither is worth it for a decoder that already verifies at 140 MHz on this board.
The limit is the rate at the top. Nothing above 140 MHz is verified, because the image will not build at 150 MHz, and the external switch and LED wiring is still a separate step.
7 Volume verification
The designs above check the primitive against its own anchors. A second question is whether the values a store actually wrote are coordinates, which is the check a deployment needs and the primitive alone cannot answer. hw/rtl/demo/tagma_volume_verify_top.v reads the coordinate values of a volume’s identifiers from a ROM, one 16-bit value a line, and closes a verdict on the die.
Each value drives the pipelined decoder, and the pack it reports is accumulated as (i << 10) | (m << 5) | f. A value at or above 11,172 is counted and kept out of the sum. The pass ends when every ROM entry has been seen, and pin_match is set only when the accumulator equals the EXPECTED constant the flow supplies and the invalid count is zero. The flow refuses to build without that constant, because a default would read as a pass.
The host computes the same sum with integer division. The die takes the pack from the decoder, whose divisions are multiplications by fixed reciprocals, so the two agree on the packing rather than on the arithmetic. On the 25F the design is 355 combinational cells, 214 registers, 8 of 56 DP16KD and 2 of 28 MULT18X18D.
The demonstration hands the die a set of the format’s own values: one per valid offset, 11,172 of them, in order. One value moved to 11,172, the first value the range does not hold, clears the match and the light turns red. The alphabet’s own values clear it green. The run is recorded with the console beside the board, so the two are read at the same second.
The recorded run is hw/demo/fpga-icesugarpro-alphabet in this repository, and the same video is at pub-06bcfdd98bd94801a748fa2ff0382400.r2.dev/demo/fpga-icesugarpro-alphabet/20261115-101948.mp4.
The top is kept under demo/ beside the other demonstration tops. What it establishes is a property of the format rather than of this board: an address is a pack of three axes, and a device that can add can check a store’s addresses without the store.
8 Per-value verification
A sum answers one question and loses the rest. It cannot say which coordinate was wrong, and two packs that trade value leave the total untouched, so a set whose two addresses are exchanged and a set whose addresses are correct read the same to it. hw/rtl/tagma_anchor_verify_top.v closes that gap by comparing one line at a time.
The ROM is an anchor file rather than a list of values: each line carries the offset it names in [28:15] and the pack tagma_core computed for it in [14:0]. The die decodes the code point that offset names, and compares the pack its own pipeline reports with the pack the line already carries. pin_match is set only when a full pass closes with no disagreement, so a single wrong value is the same size as eleven thousand.
Two files are cut from the anchors for the demonstration: the file the reference wrote, and the same lines with the packs at two offsets exchanged. Both carry the sum 065BEA26. The host prints that number twice, once from each file, and the die then refuses the exchanged file and accepts the other. The exchange is the case the sum image above cannot see, so the two images together say what either alone cannot.
The recorded run is hw/demo/fpga-icesugarpro-exact in this repository, and the same video is at pub-06bcfdd98bd94801a748fa2ff0382400.r2.dev/demo/fpga-icesugarpro-exact/20261115-114545.mp4.
At 40 MHz the image is 478 LUT4, 275 registers, 26 of 56 DP16KD and 2 of 28 MULT18X18D, and the longest path closes at 95.27 MHz.
The ROM depth is the address space rather than the line count, and that is not a preference. A depth of 11,172, which is not a power of two, was mapped into 18 DP16KD blocks holding 9,216 words of 18 bits, so every line past the shortfall was compared against nothing and the image refused the file it should have accepted. At a depth of 16,384 the same file maps into 26 blocks and the verdict is 1. The failure is silent and reads as a genuine refusal, which is why the depth is stated in the source and the reason is written beside it. make sim-anchor gates the same comparison in simulation, so the 11,172 line file answers as it should before an image is built from it.