Hands-on experiments
Share two multiplications. I checked all 16 inputs for each of 136 unordered pairs, including equal pairs. Sharing saves an operation for 31 pairs against separate calculations. After iCE40 synthesis, (7,11) goes from 10 to 9 LUTs and from 1 to 4 carry cells. Both descriptions of (3,6) give 3 LUTs and 2 carries. After routing (7,11) on HX8K-CT256 I get 2.968 ns and 16 cells for the direct expression, 3.465 ns and 20 cells for sharing, on each of five seeds. Reference values AT.EX18.05 · Simulate
Reading an integer bit by bit
For an odd prime p, reading a bit b updates the remainder by r ← (2r+b) mod p. After the last bit this is x modulo p. For a fixed b the step is reversible because 2 is a unit modulo p. At p=2 the last bit gives the test directly.
I compute the remainder, mark divisibility in a counter and undo the remainder calculation. After processing the wheels I copy the counter-zero test to an output bit and reverse the work to clean the registers. Bennett established the general compute–copy–uncompute principle. My contribution is an inspectable sieve construction that reuses a remainder register. Bennett
Counting the work
With L input bits and m primes including two, my abstract model counts 4(m−1)L remainder updates. At L=83 and m=19 this is 5,976. The 12 logical work bits at that level exclude auxiliaries needed for gate decomposition. The simulator checks both initial output-bit values.
At level 67 one compilation uses 26,307,547 X, CNOT and Toffoli gates and 105 bits in total, including nine clean auxiliaries. It gives a baseline for testing a modular-addition synthesis including depth and connectivity. A physical mechanism for counting primes remains speculative. Gate accounting · Circuit starter kit
An arithmetic compilation
I use the explicit inverse of y=(2r+b) modulo odd p. If c is the parity of y XOR b, then r=⌊(y+cp)/2⌋. The circuit computes the image, copies it and cleans its work using the inverse. At 67 the recorded gate count falls from 26,307,547 to 2,250,827 while bit count rises from 105 to 192. The comparison is between two project constructions. Cuccaro’s adder supplies a specialised future baseline. XI.D08 gate counts · Cuccaro et al.
What makes a better sequence of transformations?
In XII I recover a modular step’s correction bit from output parity and the input bit. I replayed the circuit forwards and backwards on all 2,116 valid inputs at odd primes through 97. XII.D09 specifies valid residues and clean work bits. The reported cost counts abstract gates. Circuit · Cuccaro et al. on reversible addition
I open an FPGA research lead. I specify eight outputs for eight inputs before searching for a composition. With two fixed modular transformations the words 101101 and 00 give the same table. Two is the minimum word length in this library. Logic synthesis may already remove the difference between the descriptions. The next check compares their LUT counts and logic depth with a direct table on a fixed target. FPGA dossier and code · ABC, Berkeley
Two costs for a reversible step
At 67, XIII saves Toffoli gates at the cost of nine extra bits relative to the XII circuit. I provide both block-step implementations and a forward/inverse check on 1,170 inputs per implementation. FPGA LUT use after synthesis still needs measuring. Circuit · FPGA
Two LUTs for three descriptions modulo five
I apply constant digits 101101 or 00 and write a third implementation as a lookup table. For inputs 0 through 7 I require outputs 0, 4, 3, 2, 1, 5, 6, 7. With Yosys 0.71, ABC9 and an iCE40 HX target, I recover the table before and after synthesis in all three cases. The middle output bit is a wire. Each of the other output columns differs from every wire, every constant and the other column, even allowing free inversion. At least two single-output LUTs are therefore required. Synthesis meets this bound at depth one. This result concerns constant digits. Frequency, routing and energy remain to be measured. RTL, netlists and checker · Certificate · YosysHQ
For the reversible sieve I separately count logical gates. At 67, if X and CNOT cost one unit, the Cuccaro variant is cheaper under that criterion once a Toffoli weighs more than 119/22. I report the bit and depth costs separately and provide an adder and inverse test. Reversible cost dossier
When the six digits are circuit inputs
I supply the initial residue r and all six bits of word b. For r≤4 the output is (64r+b) modulo 5. Initial codes 5, 6 and 7 pass through for every b. This defines 512 input combinations. I check every one in Yosys before mapping and in a separate iCE40 cell interpreter afterwards.
I first compare six Horner steps with a direct table of all 512 values. With default iCE40 HX mapping, Horner uses 30 LUT4s and two carry cells at a structural depth of 11 cells. The table uses 124 LUT4s at depth seven. With only LUTs allowed, Horner maps to 23 LUTs at depth seven. Lookup remains at 124 and depth seven.
The periodicity of 2 modulo 5 suggests a third description. Writing b=16u+4v+w in two-bit groups gives the remainder of −r+u−v+w because 4≡−1 and 64≡−1. Adding 10 lets me correct over the range 3 through 16 for valid inputs. This signed form gives 25 LUTs at depth five with LUT-only mapping. In default mode it uses 22 LUTs and three carry cells, with at most five LUTs and seven cells on a path. The smallest and shallowest descriptions differ in this LUT-only pilot. These results concern Yosys 0.71/ABC9 mapping. Routed delay and global optimality remain open.
Architectures for constant remainders, including staged lookup designs, have been studied by Ugurdag and coauthors. I contribute a comparison with the same total function, area–depth measurements and six checkable netlists. RTL, netlists and checker · FPGA record · Ugurdag et al. on hardware division by small constants
Four circuits on the same FPGA
I compute (64r+b) modulo 5 for 0≤r<5 and 0≤b<64, returning r for the remaining three codes. The three pairs of bits in b have alternating weights modulo 5. I compare the resulting signed sum, six Horner steps, a full table and three small lookup stages reading two bits each. I verify all 512 inputs for every description, both synthesis modes and the function between the two register banks. An input sampled at edge t produces its output at edge t+1.
I fix Yosys 0.71, nextpnr 0.11.1, an iCE40 HX8K-CT256, the pin assignment and a 100 MHz target. With carry chains and block RAM disabled, I find 5.474 ns for signed pairs and 7.434 ns for Horner on every one of five seeds, a 26.4% delay reduction. The full table ranges from 7.763 to 8.218 ns, with a median of 8.190 ns. The three lookup stages take 9.436 ns on every seed. The lower delay costs area in this example. Signed pairs take 25 LUT4s and 36 placed logic cells including the registers, compared with 23 LUT4s and 34 cells for Horner. I provide the register-to-register paths from the router's delay model. Board measurements remain open. Measurements and synthesis files · Small constant division, Ugurdag et al. · nextpnr router
Direct remainder, carry chains and the move to eight bits
I add a Verilog description applying % 5 directly to the concatenated residue and input word. Residue codes 5 to 7 pass through. At eight bits the valid-state function is (256r+b) modulo 5. The coefficient of r changes from −1 to +1 and the four base-four digits have alternating signs. I check 512 inputs at six bits and 2,048 at eight bits for each circuit, including after mapping. I fix the HX8K-CT256, registers, pins within each width, a 100 MHz target and five seeds. I save 90 reports and reproduce the twenty timing controls from the earlier harness.
With standard carry-enabled mapping my six-bit medians are 5.950 ns for signed pairs, 11.074 ns for Horner and 19.691 ns for a direct remainder. At eight bits I obtain 7.049, 13.692 and 24.843 ns, using 47, 55 and 69 placed cells respectively. Three lookup stages at six bits take 9.436 ns and four at eight bits take 13.342 ns. At eight bits the staged lookup narrowly overtakes Horner under standard mapping and trails it with LUTs alone. At seed one in standard mapping the Horner path spends 8.232 ns in routing and 4.585 ns in logic. The staged version gives 8.330 and 4.165 ns in the same categories. Register contributions are also recorded. Allowing carries changes the area trade-off: at six bits signed pairs use 33 cells against 43 for Horner, while the LUT-only harness used 36 against 34. The router's timing model supplies these delays. Results and paths · Small constant division · nextpnr
An initial transfer to binary inference
I fix four threshold neurons, eight bipolar inputs and weights equal to −1 or +1. The dot product is twice the number of matching signs minus eight. I check the identity for all 65,536 pairs of eight-bit masks. I compare an unrolled signed sum with a match-count tree on every one of the 256 activations. With common registers and pins the median falls from 7.042 to 4.949 ns and occupancy from 128 to 41 cells over five HX8K seeds. Each circuit emits four decisions per cycle after filling. Weights and thresholds are fixed in the circuit. End-to-end inference still requires trained weights and measurements of memory, transfers and accuracy. FINN and FINN-R already implement quantized inference on FPGAs. My contribution here is the checkable harness and its target-specific result. Inference dossier · FINN · FINN-R
The reduction flag depends on its domain
For 0≤x,c<p I recover the reduction flag from y<c, where y=(x+c) mod p. I check 3,354 cases. At p=3 and c=1, x=0 and x=3 both produce y=1 with different flags. The supplied complete gate count at 67 remains above bitwise Horner.
My next test is to cost the extra information required to widen the domain. AT.D1 · Cuccaro et al., A new quantum ripple-carry addition circuit
A trained layer exposes a sharing-cost failure
I train four bipolar thresholds on 160 synthetic inputs. All four bits are correct together on 29 of 96 held-out inputs (304 correct bits out of 384). I verify three circuits on all 256 inputs. Across five HX8K routes each, median delay and cell count are 9.296 ns and 128 for signed sums, 5.593 ns and 43 for balanced popcount, and 7.742 ns and 58 for the partition chosen among 35. Minimising distinct counters fails to beat the reference.
I hard-wire the weights and launch eight input bits for four output bits. With common register banks, a 100 MHz parallel interface can issue one vector per cycle when the selected seed meets timing. The signed sum reaches 10.052 ns on one seed. In a half-duplex scenario that sends eight bits, waits one cycle and reads four bits, all three descriptions take thirteen cycles per vector. This is a calculated interface budget. Board throughput remains unmeasured. After interrupting the default router on the fourth signed-sum seed, I used router2 for all fifteen measurements. From the kit I run python apprendre.py --rebuild YOSYS NEXTPNR --export rebuilt.json to regenerate the reports.
My next test is to route several tied partitions and compare fan-out and depth. AT.H10 · Umuroglu et al., FINN
One bit to recover the original representative
I retain the sheet ⌊x/p⌋ for x in [0,2p). The pair ((x+c) mod p, sheet) is invertible for fixed c. Two preimages per residue require one extra bit. I check p = 3,5,7,11. For a separate fixed modular kernel I verify 2,048 inputs against its HX8K netlist and all 16,384 cases of its XOR lift. My compute-copy-uncompute construction uses two compute passes and three bit copies in this model.
I plan to decompose computation and uncomputation in the same gate library to measure depth and workspace. AT.D2 · Cuccaro et al., A new quantum ripple-carry addition circuit
Seven counters outperform two six-counter partitions on a frozen layer
I route three partitions of one binary layer on HX8K with five seeds each and check all 256 possible inputs. The two six-counter partitions give estimated median delays of 7.742 and 7.623 ns. The seven-counter partition gives 6.405 ns. The specialised reference achieves 5.593 ns and 43 cells against 57 for the seven-counter partition. Ports require eight input and four output bits. In my one-bit serial protocol a transaction takes thirteen cycles. These results describe place-and-route for a synthetic layer.
I plan to commit to a depth-based prediction before routing additional partitions with the same seeds. AT.H11 · Umuroglu et al., FINN
When cleaning copies adds a layer
For four mod-four residue predicates I compare signed-control gates. The sequential circuit takes four gates and four layers. Six clean ancillas enable parallel computation, but copying and cleanup bring the total to sixteen gates and five layers. I verify every input with zero initial workspace and outputs.
Measure placement and negative controls in a specified gate library. AT.D3 · Cuccaro et al., A new quantum ripple-carry addition circuit
Two partitions reverse the expected ranking
I predict depths eight and seven for six and seven counters. After synthesis I get seven and eight. Across five HX8K routing seeds the median delays are 6.685 and 7.686 ns. The specialised reference remains at 5.593 ns. Output quality is identical.
Test held-out weights and a cost fixed before routing, then measure on a board. AT.H12 · Umuroglu et al., FINN
Charging for negative controls
I take X, CNOT and positive-control Toffoli gates, with two inputs, four arbitrary targets and clean ancillas. The serial circuit visits the four polarities with four flips, minimal for this schedule, plus four Toffolis. The parallel version uses 24 gates on twelve wires in seven layers against eight gates on six wires in eight layers. I check 64 inputs per version and uncomputation.
I will compare under a coupling topology with explicit swap costs. AT.D4 · Cuccaro et al., A new quantum ripple-carry addition circuit
Changing weights while preserving the function up to symmetry
I complement all eight weight bits, retain thresholds and compare equivalent descriptions on HX8K across five seeds. I check all 256 outputs by conjugating the input. The minimum-counter partition uses six counters, 55 cells and a 7.686 ns median delay against 43 cells and 5.264 ns for popcount. My predicted gain fails. The transported evaluation retains 29/96 exact classes.
I will fix weights outside this symmetry and measure on a physical target when available. AT.H13 · Umuroglu et al., FINN
Restoring data on a line of gates
I fix a reversible two-input, four-output decoder and restore placement after every gate. On the line, serial and copy-based descriptions require 12 and 92 swaps for 8 and 24 logical gates. I check all 64 inputs, including initial output values and ancilla cleanup. I also apply the median gathering method of XX.D02.
Allow placement to persist between gates and check cost across the whole circuit. AT.D5 · Cuccaro et al., A new quantum ripple-carry addition circuit
Testing a prediction on different binary weights
I fix weights 01, 07, 3F, FF and four thresholds of two before five HX8K placements. The pairwise weight distances differ from the previous family. Both descriptions agree on all 256 logical outputs. Popcount wins on delay for all five seeds, median 6.209 ns and 46 cells versus 6.735 ns and 44 cells. These weights classify 9 of 96 held-out inputs correctly. I measure the circuit trade-off here.
Reserve trained weights meeting an accuracy target and measure end-to-end cost. AT.H14 · Umuroglu et al., FINN
Reproduce the experiment
In IX/src, run python reversible.py. Compare the checks with the modular update count and the gate-level compilation.
Download research files ↓