DOCS / LITTLEBIT

Project #3: LittleBit × Taalas on a Colorlight i9

Research date for everything below: 2026-11-21, unless a line says otherwise.

A small neural network on the Colorlight i9, with its weights compressed to well under one bit each and built into the FPGA's logic as constants. It measures what hardwiring low-bit weights buys and what it costs, on a network small enough to check image by image. Nothing is built yet. It needs no parts beyond the i9 and an extension board, already ordered for the digitizer (lab/sourcing.toml), and a USB-A port to power them (scope.md, "Known part issues").

What it is for

The point is a chip that runs SocialJax and Concordia as efficiently as possible, to simulate social conflict and solve it before it happens, and local AI companions in a humanoid robot. Safety first, and security at the hardware level is very important. (Jon, 2026-11-21.)

What the two run, read from their sources:

Hardwired weights are constants of the circuit. A chip built this way runs a network that is already trained: new weights are a new bitstream on the i9, or a new chip in silicon, and training stays on a computer. So this step tests the inference half: how accuracy, logic and clock speed move as the bits per weight fall. How much a chip with hardwired signs could still learn, by changing only its scales, is a first experiment of its own ("Training with the signs fixed"). Whether what it finds carries from a 234,752-weight network to the ones above is unknown until a later step runs one of them.

What "as efficiently as possible" is measured by (Jon, 2026-11-23): beating GPUs on cost for multi-agent simulations with trained agents, the price of a game step with the game and its policy running ("The goal: cheaper than a GPU per game step", below).

That is the half the chip is for. Running SocialJax here means running simulations with agents already trained: the chip runs their fixed policies, and training them stays on a GPU (Jon, 2026-11-23). SocialJax's agents learn by reinforcement learning, which changes the policy with every update, and hardwired weights can't follow that.

This step drives nothing but a serial port and an LED. What safety first means for a robot is not written yet. The rule Tentzhen has so far is the bench's: hard limits live in hardware an AI cannot reconfigure (vision.md, principle 5).

Security at the hardware level. Jon names OpenTitan, more for the physical companion (2026-11-21): "Open source silicon root of trust" (lowRISC/opentitan at 3cc49775, Apache-2.0), written in SystemVerilog. Its tops are Earl Grey, Darjeeling and English Breakfast, and its FPGA builds are Earl Grey's for the CW340 board and English Breakfast's for the CW305 (hw/top_*/chip_*_cw3*.core). Whether any of its tops fits the i9's LFE5U-45F is not checked, and it is not part of this step. Tentzhen already has a research track for keys in a TROPIC01 secure element (roadmap.md), and the mesh names an SE050 for its own board (mesh.md); whether one part serves the bench, the mesh and the companion is not weighed. Hardwired weights have one property of their own here: in silicon they cannot change without a new chip, while on the i9 they change with the bitstream.

Where this came from

Jon's spec of 2026-11-21, "LittleBit × Taalas on a Colorlight i9 — Project Spec", written in a Claude session and brought in the same day. The research questions, the network, the checks, the experiments and the phases are its. Changed here: the languages follow CLAUDE.md; it builds in this repo, not a repo of its own; a board run is a measurement record; loading the board follows the lab-target rules; the spec's open question about the extension board is answered from this repo; and two bits-per-weight figures, the clock count, the image rate and the preloaded-image count are worked out again. Phase 5 and research question 5 come from a second Claude session's answer that Jon brought the same day ("so would i do openroad after the i9?"), kept where its sources were read: LibreLane's repo and Tiny Tapeout's site.

Research questions

  1. Quality vs. bits: how does test accuracy fall as the factor rank r, and so the bits per weight, drops, for a fixed network shape?
  2. Same memory, bigger model: at an equal weight-bit budget, does a wider network at very low bits beat a narrower one at higher bits?
  3. Hardwired vs. stored: for the same weights, how do LUTs, block RAM, maximum clock and latency compare when the weights are logic constants (Variant A) and when they are read from block RAM (Variant B)?
  4. Hardware fit: how many binary weights fit in the LFE5U-45F when hardwired, and what runs out first: LUTs, routing or timing?
  5. FPGA vs. silicon: per weight bit, how much area and how many cells does a hardwired layer take when laid out as a chip, against the LUTs it takes on the i9?

Out of scope for this step: LLMs, making a chip (Phase 5 lays one out; making one is a stretch goal), and training on the FPGA. Training runs in PyTorch on a computer; the FPGA only runs inference.

Hardware

The design fits one LFE5U-45F and leaves about 30 % of its LUTs free for routing and timing.

resourcethe LFE5U-45F hasbudgetused for
LUT4s44k≤ 30,000Variant A's weight ROMs, adders, control, UART
block RAM (EBR)108 × 18 kbit, 1,944 kbit≤ 80 blocksVariant B's weights, the input image and activation buffers
18 × 18 multipliers72≤ 32scale vectors and requantization only
clocka 25 MHz oscillator50 MHz from the ECP5's PLL50 MHz first; higher in E12

The chip's figures are Lattice's (FPGA-DS-02012 3.4, Table 1.1; the PDF's sha256 26570f8b…, read 2026-11-21). The chip is the i9 v7.2's LFE5U-45F-6BG381C (scope.md, "Architecture"), so nextpnr takes --45k --package CABGA381 --speed 6. On arrival its JTAG IDCODE tells it from its siblings without reading the marking: 0x41112043 (builds/digitizer/v1.toml, walkthrough).

The board is the i9 on any of the three extension boards (scope.md, "One i9, three extension boards"), with nothing wired to the headers. Jon has two i9s, each in an extension board of its own: Jon's #1 and #2, here i9-1 and i9-2 (2026-11-22). The serial a load logs is the extension board's probe's, not the i9's, so each i9 stays in its own extension board:

unitits probe's serialport on the lab computerIDCODE
i9-107000001006000573800001256313848a5a5a5a597969908COM30x41112043, LFE5U-45: lab log seq 9 of 2026-11-22
i9-207000001005400333800001256313848a5a5a5a597969908COM40x41112043, LFE5U-45: seq 10

Gate 0 ran on i9-1: its loads, seq 2 and 4, name i9-1's probe. Gate 0's records name the part and its revision, not the unit.

i9-2 has run the same blinky bitstream from SRAM (seq 11), with only its own board plugged in. Jon saw its green LED blink about once a second (seq 12). It wasn't blinking before the load, as Jon reported afterwards (seq 13). So the blink began with the load. Gate 0's blinky used a power cycle as its control; this one uses before and after. What i9-2's flash holds is unknown.

The PLL at 50 MHz. Gate 0 ran at 25 MHz from the oscillator. The design will run at 50 MHz from the ECP5's PLL (the table above). So before the layer engine, Gate 0's echo and blinky ran on i9-2 from the PLL at 50 MHz (gateware/bringup/pll_echo.py, 2026-11-23). The PLL's dividers are the ones Project Trellis's ecppll -i 25 -o 50 gives: 25 MHz, times 2, from a 600 MHz VCO.

the resultlab log, 2026-11-23
before the loadthe 25 MHz blinky, and no echo at 115,200 baudseq 14, 15
after it, at 115,200 baudall 282 bytes back, in order, twiceseq 17, 19
after it, at 57,600 baud, the rate it would echo at from 25 MHzthe first byte back already wrongseq 18
the LED, by eyeabout once a second, not once every 2 sseq 20

So the PLL locks, and the design runs near 50 MHz: measured, 2026-11-23-i9-pll-echo. How near isn't measured. Echoing at 115,200 baud only shows the clock is close enough for the UART. nextpnr derives the 50 MHz constraint from the PLL's dividers by itself, and puts the routed design's limit at 155.50 MHz. That is its timing model's figure, not a measurement. That the PLL refuses dividers outside ecppll's ranges is tested (gateware/cores/tests/test_ecp5_pll.py). So is the echo at 50 MHz and its divisor, 434, in cocotb without the PLL, which Verilator has no model of (uart_echo_at_50_mhz_sends_back_every_byte_at_115200_baud).

One layer on the board. r16's first layer, 784 → 256 at rank 16, ran on i9-2 on the layer engine at 50 MHz from the PLL (gateware/bringup/littlebit_layer.py, 2026-11-23). It answered every input exactly as the golden model computes it: every y, and every z, the int32 before the shift and clamp, of all 256 outputs. That is measured, 2026-11-23-i9-littlebit-layer:

inputsanswered exactly as the golden modellab log, 2026-11-23
before the load (the PLL echo)1 framenone: it came back as an echoseq 21, 22
the test vectors for the layer66seq 24
MNIST's first 1,000 test images, shifted as the network shifts them1,0001,000, in 180.0 sseq 25

The computer sends a frame, 0xA5 and the layer's 784 input bytes. The design answers 0x5A and, for each output, y and z, 1,281 bytes: 180 ms an input at 115,200 baud, the serial link's time, not the engine's. A frame left part way is dropped after 100 ms of silence. cargo run -p tentzhen-littlebit -- layer <port> (vectors | mnist <count>) is the computer's side (crates/littlebit/src/board.rs). In cocotb, without the PLL and at a UART divisor of 8, the same design answers two frames as the golden model does and drops a part one (gateware/bringup/tests/test_littlebit_layer.py). Built, it takes 6,422 of nextpnr's logic cells, 2 DP16KD blocks for the outputs' FIFO, and closes at 55.99 MHz; the weights stay logic, as the Yosys log shows (littlebit_layer.layer.fifo.storage is the only memory it maps to block RAM). This is one layer, not check 3, which takes the whole network's scores and digit.

Load with one board on USB. openFPGALoader 1.2.0 can't choose between two identical CMSIS-DAP v1 probes:

That is what 1.2.0 did here, and what its source at master does (src/cmsisDAP.cpp, read 2026-11-22). So a load is made with only its own board plugged in. The serial it logs is the one openFPGALoader reports opening.

The board uses:

The balls are LiteX's for the i9 v7.2 (litex-boards at 53dc2ed0, litex_boards/platforms/colorlight_i5.py, _io_v7_2). An Amaranth platform for the i9 exists in Muse Lab's own repo, src/amaranth_boards/colorlight_i9_r7_2.py (wuxx/Colorlight-FPGA-Projects at 016e5889, Apache-2.0): the chip, the 25 MHz clock on P3, the LED on L2, and the headers, with the UART's balls on its P5 connector and no UART resource of its own. Its comment says "Some of these still need verifying". Upstream amaranth-boards has no i9 (at f270d210). Ours, gateware/boards/colorlight_i9.py, has the clock, the LED and the UART. On our board the clock and the LED are measured (2026-11-22-i9-blinky), and so is the UART, TX on J17 and RX on H18 (2026-11-22-i9-uart-echo).

Loading the board is a flash. Loading code into a board counts as flashing it, into SRAM too (lab/targets.toml). The i9 is not a lab target, so until a person lists it, every load needs a person's approval in the session, and every load is logged as a firmware.flash.

Languages and layout

piecelanguagewhere
training and the rank sweepPython, PyTorch: the exception CLAUDE.md names for itmodels/littlebit/
SocialJax's Clean Up and its trained policy, played on the computerPython, JAX, as SocialJax is written: CLAUDE.md's exception for it. behaviour.py only reads their outputs, so it is outside the exception, and stays Python until it is written in Rustmodels/cleanup/
the weight export and the integer golden modelRustcrates/littlebit
Clean Up's golden model, so far JAX's random numbersRustcrates/cleanup
the layer engine, the output layer, the weight-ROM generator, the whole networkAmaranthgateware/cores/littlebit.py
a layer as a hardwired kernel, a window a clockAmaranthgateware/cores/littlebit_kernel.py
the UARTAmaranthgateware/cores/uart.py
the top level: the network behind the UARTAmaranthgateware/littlebit/network.py
tests of the gatewarecocotb on Verilator, run by pytestgateware/cores/tests/ and gateware/littlebit/tests/
the host: sends inputs, compares answersRust, tentzhen-littlebit's commandscrates/littlebit

Each directory is made when its first real file arrives (roadmap.md, Phase 0).

The pieces meet at one file: the exported weights (signs, scales, shifts and biases) as JSON, models/littlebit/runs/<run>/integer.json. The golden model and the ROM generator both read it, so they cannot read different weights. The golden model also writes out the intermediate vectors and scores that the cocotb tests compare against.

The export is in Rust, not Python, although it's part of the model work (2026-11-22). It needs no PyTorch, only a run's committed weights and the training images. In Rust, the Quality Gate re-runs it and fails if the committed file differs (r16_integer_json_is_what_the_exporter_writes). It also measures each layer's latent shift with the golden model's own arithmetic, so the two can't disagree about it.

Why these for this project: in Amaranth, the ROM generator is Python that builds the circuit from the JSON, with no Verilog text to template; Rust makes every integer widening explicit and stops a test on an overflow, which is what "integer-exact" asks of the golden model; and the host writes the lab log and the records, which are Rust already.

Toolchain: Yosys, nextpnr-ecp5, Project Trellis, Verilator, cocotb and Amaranth, pinned with the rest (roadmap.md, Phase 0), plus PyTorch and openFPGALoader. Until that pinned toolchain exists, training runs in models/littlebit/'s uv environment: Python 3.12.15, PyTorch 2.15.0 (its CUDA 13.2 build on Windows and Linux) and NumPy 2.5.5, every package pinned by its uv.lock, and every_python_dependency_is_pinned holds the pins it names. Amaranth's ECP5 platform runs Yosys, nextpnr-ecp5 and ecppack itself (amaranth at 90449f1e, amaranth/vendor/_lattice.py). nextpnr's --report writes a "timing and utilization report in JSON format" (nextpnr at 15b77f5f, common/kernel/command.cc), the source of each run's LUT, EBR and Fmax figures. MNIST is fetched and checked against a pinned sha256; its terms are not read, so it is not committed. Phase 5 adds LibreLane, "ASIC implementation flow infrastructure, successor to OpenLane" (Apache-2.0, librelane/librelane at 8494d4fe), whose README recommends installing it with Nix; Tiny Tapeout's local-hardening guide runs it in Docker (TinyTapeout/tinytapeout_www at ce1fff22). It runs on GitHub's computers, in LibreLane's Docker image, as Tiny Tapeout's GDS action does, with the version and the action pinned, not on the lab computer (Jon, 2026-11-21; prior-art.md, "A chip's layout").

Model

The baseline is a 784 → 256 → 128 → 10 MLP on MNIST, 234,752 weights. The two hidden layers use LittleBit-style factorized binary weights. The output layer stays dense int8: it has 1,280 weights.

Layer math. Each LittleBit layer replaces its weight matrix W (out × in) with two binary factors and three scale vectors:

y = h \odot \Big( U_s \big( \ell \odot ( V_s^{\top} ( g \odot x ) ) \big) \Big) + b, \qquad U_s \in \{\pm 1\}^{\text{out} \times r},\; V_s \in \{\pm 1\}^{\text{in} \times r}

g (length in), ℓ (length r) and h (length out) are learned scales; b is a bias. Multiplying by U_s or V_s is only addition and subtraction.

Bit accounting. Every run reports both numbers, because at this size the scales are a real share of the budget:

\text{sign bpw} = \frac{r\,(\text{in} + \text{out})}{\text{in} \cdot \text{out}}, \qquad \text{total bpw} = \frac{r\,(\text{in} + \text{out}) + 8\,(\text{in} + \text{out} + r)}{\text{in} \cdot \text{out}}

The 8 is for 8-bit scales; it changes if the export uses 16-bit ones. It is the paper's Eq. 16 without the residual path, and with 8 bits a scale where the paper's are FP16, 16 bits each (arXiv 2506.13771v5, Appendix D). Neither counts the bias, an int32 per output: 8,192 bits on layer 1, about as many as its signs at r = 8.

Rank sweep for layer 1 (784 → 256, 200,704 weights):

rank rsign bitssign bpwtotal bpw, 8-bit scales
44,1600.0210.062
88,3200.0410.083
1616,6400.0830.125
3233,2800.1660.209
6466,5600.3320.376

tested: the_littlebit_bit_counts_follow_from_the_formula recomputes this table from the formula, and the experiments' bits-per-weight column from it, E3's binary row too. Layer 2 (256 → 128) uses the same r. The baselines have the same shape: dense FP32, dense int8, and plain binary weights (1 bit per weight, one scale per output).

Training recipe (Jon's spec):

  1. Train the FP32 MLP (Adam, learning rate 1e-3, cosine decay, about 20 epochs) and record its accuracy as the ceiling.
  2. Start each LittleBit layer from its FP32 weights: a truncated SVD to rank r, the signs of the factors become U_s and V_s, and the magnitudes are folded into g, ℓ and h. The paper's Dual-SVID does it this way: a rank-1 approximation of |U′| gives h and one latent scale, one of |V′| gives g and another, and ℓ starts as their element-wise product (arXiv 2506.13771v5, section 3.2, Eqs. 6–8).
  3. Fine-tune with quantization-aware training: sign() in the forward pass, and a straight-through estimator in the backward pass (the gradient passed where |w| ≤ 1). About 20 epochs. The paper instead uses SmoothSign ("backward gradient: tanh(kx), k = 100"), reporting it better than the straight-through estimator, and distils from the full-precision model as teacher (section 4.1, Appendix B.2).
  4. Fake-quantize activations to uint8 during training (ReLU, then a per-layer power-of-two scale), so that the trained model matches the integer hardware.
  5. Optional, after the core sweep: the paper's Residual Compensation, which splits the same bit budget into two lower-rank paths, the second started on what the first leaves (section 3.3). Measure whether two paths beat one at the same bits.

The paper's code (SamsungLabs/LittleBit at 42d658b) is under CC BY-NC 4.0, for non-commercial use only, so Tentzhen writes its layer from the paper and copies none of that code.

The first LittleBit run, r = 16 (models/littlebit/littlebit.py and train_rank.py, 2026-11-22). It runs steps 2–4 from E1's committed weights. Whatever the recipe and the paper leave open was chosen before the run:

The run gets 9,713 of the 10,000 test images right, 97.13 %, which is 1.18 points under E1. It also gets 58,798 of the 60,000 training images. Both counts are tested by r16_scores_what_its_summary_says, which re-scores the committed weights (models/littlebit/runs/r16) with the signs and the uint8 grid in its own f32 arithmetic. Three runs gave the same weights, byte for byte, in about 50 s each on the lab computer's GPU (each summary's seconds).

Before any fine-tuning, the network as Dual-SVID started it got 4,710 test images right. That is PyTorch's count in the summary, and no test re-checks it. In the summary's curve, the test count moved between 9,418 and 9,686 over the first 19 epochs, and rose as the learning rate fell to 0. Whether a smaller learning rate or the paper's distillation would do better is unknown. A run that chooses between them should choose on images held out of the training set, not on the test images.

The baselines, E2 and E3 (models/littlebit/train_baseline.py, 2026-11-23). They follow r16's recipe in everything but the hidden layers, so a baseline and a LittleBit run differ only there. Each starts from E1's committed weights, with pixels as ⌊p / 2⌋ / 128, uint8 activations whose exponents are fixed before training, E1's training settings and a dense output layer. What differs was chosen before the runs:

runtest images right, floatintegerthe same digit, float and integertraining images right, floatactivation exponents
E2, int89,835 (98.35 %)9,833 (98.33 %)9,99260,000−4, −3
E3, binary9,824 (98.24 %)9,824 (98.24 %)9,99160,000−4, −4

These counts are tested. e2_scores_what_its_summary_says and e3_scores_what_its_summary_says re-score the committed weights in f32 (models/littlebit/runs/e2 and e3), and e2_and_e3_integer_are_within_half_a_point_of_float exports them as integers and scores them. So check 1 holds for both: E2 loses 2 images to its int8 weights, and E3 loses none in all, though its integer and float models pick different digits on 9 images. Two runs of each gave the same weights, byte for byte, in 24 s (E2) and 38 s (E3) on the lab computer's GPU.

A baseline runs on the computer only, so its integer network is not written to a file. The test exports it from the committed weights as it scores it (export::baseline in crates/littlebit). E2's hidden weights land on a grid of 2^−7, and E3's scales on one of 2^−9.

What the counts show:

Each started where its summary says, before fine-tuning: E2 at 9,828 test images right, E3 at 8,535. Those are PyTorch's counts, and no test re-checks them.

The rest of the rank sweep, E4, E5, E7 and E8 (models/littlebit/train_rank.py, 2026-11-23). These are r16's run at r = 4, 8, 32 and 64, with nothing else changed, each exported as r16 is:

runrtest images right, floatintegerthe same digit, float and integertraining images right, float / integerlatents saturated, test imagesactivation exponents
E448,802 (88.02 %)8,791 (87.91 %)9,93252,869 / 52,8501−5, −5
E589,464 (94.64 %)9,463 (94.63 %)9,97457,036 / 57,0180−5, −5
E6169,713 (97.13 %)9,717 (97.17 %)9,98058,798 / 58,8090−5, −4
E7329,772 (97.72 %)9,776 (97.76 %)9,99359,602 / 59,5970−5, −5
E8649,814 (98.14 %)9,815 (98.15 %)9,99359,887 / 59,8860−4, −5

tested: the_sweep_scores_what_its_summaries_say re-scores each run's committed weights in f32 (models/littlebit/runs/r4, r8, r32 and r64). the_sweep_s_integer_json_is_what_the_exporter_writes and the_sweep_s_integer_is_within_half_a_point_of_float check the exports and their counts. E6's row is r16's, from the tests above. Two runs at each rank gave the same weights, byte for byte, in about a minute each.

What the counts show:

Before fine-tuning, Dual-SVID's starts got 2,906, 4,164, 5,282 and 5,303 test images right at r = 4, 8, 32 and 64. Those are PyTorch's counts, and no test re-checks them.

E10, the wider network (models/littlebit/e1_fp32.py and train_rank.py, 2026-11-23). Research question 2 asks whether, at the same weight bits, a wider network at fewer bits a weight beats a narrower one at more. E10 is the 784 → 1024 → 512 → 10 MLP, made LittleBit as the sweep's are, at the rank whose hidden layers hold E7's bits. What "the same weight bits" means was fixed before training: the two hidden layers' bits, signs and 8-bit scales, as "Bit accounting" counts them. r = 9 is the largest rank whose hidden layers hold no more than E7's:

runwidthsrsign bits8-bit scalesthe hidden layers' bitsthe output layer's int8 weights
E7784 → 256 → 128 → 103245,56811,90457,47210,240
E10784 → 1024 → 512 → 10930,09626,89656,99240,960
E10's shape at r = 10784 → 1024 → 512 → 101033,44026,91260,35240,960

tested: the_littlebit_bit_counts_follow_from_the_formula recomputes this table from the widths, and e10_weights_are_the_ones_their_summaries_name recomputes E10's and E7's hidden-layer bits from their committed runs. The output layer can't be held to E7's. It stays dense int8, and with 512 inputs its weights alone hold 30,720 bits more than E7's, more than the hidden layers could give up. So E10 holds more bits in all, and the budget is the hidden layers'. Neither counts the biases.

E10 needs a start of its own shape, as the sweep starts from E1. E10's start is that MLP, dense in FP32, trained as E1 was (e1_fp32.py, given the widths). E10 is r16's run on it at r = 9, with nothing else changed (train_rank.py, given the start), and it is exported as r16 is:

runtest images right, floatintegerthe same digit, float and integertraining images right, float / integerlatents saturated, test imagesactivation exponents
E10's start, dense FP329,856 (98.56 %)——60,000 / ———
E10, r = 99,555 (95.55 %)9,546 (95.46 %)9,97657,827 / 57,8030−5, −5
E7, r = 329,772 (97.72 %)9,776 (97.76 %)9,99359,602 / 59,5970−5, −5

tested: e10_scores_what_its_summaries_say, e10_integer_json_is_what_the_exporter_writes and e10_integer_is_within_half_a_point_of_float (models/littlebit/runs/e10-start and e10). Two runs of each gave the same weights, byte for byte, in 17 s for the start and 55 s for E10. Moving the shape out of the two scripts left E1, r16 and E2 as they were: run again, each gave its committed weights, byte for byte.

What it answers, for research question 2:

That is one recipe at one seed, without the paper's distillation or residual compensation, at one budget. Whether a wider network would win with them, or at a larger budget, is unknown. Before fine-tuning, E10's Dual-SVID start got 4,849 test images right, PyTorch's count, which no test re-checks.

Fixed-point formats, fixed at export and the same in the golden model and the gateware:

Every right shift is arithmetic, so it rounds toward minus infinity, and nothing rounds to nearest while the network runs. The exporter rounds to nearest only once, when it turns the float weights into integers. The golden model follows these steps in crates/littlebit/src/integer.rs, and a_littlebit_layer_computes_what_its_steps_say works one small layer by hand against it.

How the exporter chooses each value (crates/littlebit/src/export.rs):

A layer's exponents add up to that grid, and Network::parse refuses a file where they don't (an_integer_network_refuses_what_does_not_fit). At r = 16, layer 1's add up to −5:

The 33-bit ℓ product is wider than one of the ECP5's 18 × 18 multipliers takes. How the gateware forms it is Phase 2's to decide.

Hardware architecture

The design is time-multiplexed: each LittleBit layer takes one input per clock and updates all its accumulators at once. That keeps the adders small. Between runs at one rank only the weight ROMs, the thing being studied, change; a new rank also changes how many accumulators the V stage has.

flowchart LR
  uin["UART in<br/>784 pixels"] --> l1["layer 1<br/>784 → 256"] --> l2["layer 2<br/>256 → 128"] --> out["output layer<br/>128 → 10, int8"] --> am["argmax<br/>digit to UART"]

Layers 1 and 2 each get a LittleBit engine of their own, so they run as a pipeline. The output layer uses 10 multipliers at once, one per digit: each input, one a clock, is multiplied by its column of the weights and added into 10 accumulators that start from the biases. Then the argmax reads the 10 scores one a clock and keeps the first of the highest, as the golden model does (DenseEngine and LittleBitNetwork in gateware/cores/littlebit.py). One engine:

flowchart LR
  g["scale by g<br/>1 multiplier"] --> v["add/sub by V<br/>r accumulators"] --> l["scale by ℓ<br/>r values"] --> u["add/sub by U<br/>one per output"] --> h["× h, + b<br/>ReLU, clamp"]
  vrom[("V weight ROM<br/>in × r sign bits")] --> v
  urom[("U weight ROM<br/>r × out sign bits")] --> u

The two weight ROMs are what the experiments change. In Variant A they are logic constants generated from the trained weights; in Variant B the same bits sit in block RAM.

Per-layer schedule (r = rank), as the engine runs it (gateware/cores/littlebit.py):

  1. Scale by g, then add or subtract by V: one input per clock for in clocks, and one more. Each input's row of V (r sign bits) adds it into, or subtracts it from, r accumulators.
  2. Scale by ℓ: one latent per clock for r clocks, each shifted, saturated to int16 and kept.
  3. Add or subtract by U, scale by h, add the bias, ReLU, clamp to uint8: one output per clock for out clocks. Each clock reads one row of U (r sign bits) and sums the r latents by it in one adder tree, then one multiplier scales the sum.

The plan first had stage 2 read U's columns and update out accumulators at once. Synthesized for r16's first layer, those 256 accumulators came to 18,778 LUT4s and 3,106 carry cells (Yosys, OSS CAD Suite 2026-11-21, 2026-11-23): more than both layers' budget. Summing each output's r latents in stage 3 instead brought the layer to 5,973 of nextpnr's logic cells. Each stage also keeps its values for a clock between reading a ROM and the arithmetic after it. Without those registers, nextpnr's first routes of the two layers reached 40.72 and 44.80 MHz, short of 50.

Clocks per image. The engine takes in + r + out + 1 clocks a vector, and its last output comes 2 clocks after that. With inputs back to back, that is tested: 1,057 clocks for r16's layer 1 and 401 for its layer 2 (littlebit_engine_computes_r16_layer_1_as_the_golden_model_does, littlebit_engine_computes_r16_layer_2_as_the_golden_model_does). Run one after another, the three layers would take 1,554 + 2r clocks. The network overlaps them instead. Each engine hands its outputs to the next as it makes them, one a clock, and the next takes them as they come:

That makes 1,187 + 2r clocks from the first pixel to the digit: 1,219 at r = 16, 24.4 µs at 50 MHz. It is tested as both the design's cycle counter and the test count it (littlebit_network_scores_r16s_test_vectors_as_the_golden_model_does). The spec estimated 1,550 + 4r. On the board the counter reported 1,219 for each of the 1,006 images it was sent, measured, 2026-11-23-i9-littlebit-network. At exactly 50 MHz that is 24.38 µs, or 41,017 images a second if the link kept up. The PLL's clock is measured only as close enough to 50 MHz for the UART at 115,200 baud (2026-11-23-i9-pll-echo), not to how many places.

The serial link sets the pace. At 115,200 baud and 10 bits a byte (8N1, assumed), the 785-byte request takes 68.1 ms and the 46-byte reply 4.0 ms: at most 13.9 images a second, however fast the network is. So each run reports two speeds, compute from the cycle counter and end to end. End to end, the board run managed 13.73 images a second, 1,000 images in 72.8 s, measured, 2026-11-23-i9-littlebit-network. The DAPLink's top baud rate is unknown.

For a throughput test that leaves the link out, the spec preloaded 512 test images into block RAM. They do not fit: 512 images take 401,408 bytes, and all 108 blocks hold 248,832 (1,944 kbit), so fewer than 318 images would fit with nothing else in block RAM. The i9's 8 MB of SDRAM (scope.md) or its 8 MB W25Q64 flash (the Amaranth platform above) hold 512, behind a controller this design does not have yet.

UART protocol

directionbytescontents
computer → FPGA1 + 784header 0xA5, then 784 uint8 pixels as MNIST stores them; the FPGA shifts them
FPGA → computer1 + 40 + 1 + 4header 0x5A, 10 int32 scores (little-endian), the argmax digit, the cycle count (uint32, little-endian)

The top level, gateware/littlebit/network.py, keeps a frame's pixels in a FIFO until the last one arrives. Then it feeds them to the network back to back, so the cycle count covers the network alone, not the serial link. A frame left part way is dropped after 100 ms of silence, as the one layer's was. In cocotb, without the PLL and at a UART divisor of 8, it answers two frames as the golden model does, each in 1,219 clocks, and drops a part one (gateware/littlebit/tests/test_network_over_uart.py). cargo run -p tentzhen-littlebit -- network <port> (vectors | mnist <count>) is the computer's side (crates/littlebit/src/board.rs): it sends each image as a frame, checks each answer's scores and digit against the golden model's, and reports the clocks the network counted.

Variant A and Variant B in Amaranth

What the engines cost. nextpnr's report for each of r16's two engines alone, at 50 MHz (OSS CAD Suite 2026-11-21, seed 1; python -m gateware.cores.littlebit writes one as Verilog, 2026-11-23):

r16logic cells (TRELLIS_COMB)flip-flops18 × 18 multipliersblock RAMFmax after routing
layer 1, 784 → 2565,9731,0935058.64 MHz
layer 2, 256 → 1284,2361,0555060.12 MHz

Those are the toolchain's figures, trusted with it (trusted-base.toml, fpga-toolchain), and the engines alone, with no UART, output layer or top level. Together they take 10,209 of the 30,000 cells Gate 2 allows. The spec estimated layer 1's U-stage accumulators at a few thousand LUTs, and the hardwired ROMs at about 1,000–1,500.

What the whole network costs. The board's design: r16's two engines, its output layer, the argmax, the cycle counter, the pixel FIFO, the UART, the blinky and the PLL (python -m gateware.littlebit.network <build-dir>, OSS CAD Suite 2026-11-21, 2026-11-23). nextpnr reports:

r16, the board's designlogic cells (TRELLIS_COMB)flip-flops18 × 18 multipliersblock RAMFmax after routing
littlebit_network12,6403,050201 DP16KD55.63 MHz

That is within Gate 2's 30,000 at 50 MHz, trusted with the toolchain (fpga-toolchain). The one DP16KD is the pixel FIFO. The Yosys log maps one memory to block RAM, littlebit_network.network.pixels.storage, so the weights stay logic. The bitstream's sha256 is 754c51aef2aabe3598296aacbada86a962afd274002b39c0ab929c387d52047b. Rebuilt from main at 34dedf8, it came out the same, byte for byte, and that is the bitstream check 3 ran on (Verification, "Check 3 passes at r = 16").

What each rank costs. Each rank of the sweep is the same board design built from its own integer network (python -m gateware.littlebit.network <build-dir> models/littlebit/runs/r<r>/integer.json, OSS CAD Suite 2026-11-21, 2026-11-23). r16, built the same way on this branch, came out as the bitstream above, byte for byte. nextpnr reports:

runrlogic cells (TRELLIS_COMB)flip-flops18 × 18 multipliersblock RAMFmax after routingbitstream's sha256
E446,8891,616181 DP16KD55.27 MHzed3d189e…
E588,9392,086201 DP16KD50.06 MHzb41e697e…
E61612,6403,050201 DP16KD55.63 MHz754c51ae…
E73220,1724,973201 DP16KD50.43 MHz1b92ff46…
E86435,1398,815201 DP16KD49.55 MHz, short of 50none to load

These are the toolchain's figures, trusted with it (fpga-toolchain). None of these bitstreams but r16's has been loaded onto a board. What they show:

The clocks an image are the cocotb test's: each rank's network scores its six test images as its golden model does, in 1,187 + 2r clocks, which is 1,195, 1,203, 1,251 and 1,315 (littlebit_network_scores_the_sweep_s_test_vectors_as_the_golden_model_does). That test runs r16's six images through each network. Only r16 has run all 10,000 MNIST test images in cocotb (check 2) and 1,000 on the board (check 3).

E11, the largest rank that fits (2026-11-23). "Fits" means the whole board design places, routes and closes at 50 MHz in nextpnr, at its default seed, as the experiments table has it. How to search was fixed before the first build:

  1. Raise r from 32, which fit, in steps of 8, to the first rank that doesn't.
  2. Then bisect between the last that fit and the first that didn't, down to a step of 1.
  3. Train each rank tried as the sweep's were, export it, check it, and build it once.

r = 56 was built alongside 40 and 48, before the bisection. It isn't part of the search, and its build didn't finish. nextpnr's router was still running 32 minutes in, and was stopped. For comparison, r = 64's whole build took 11 minutes alone, while r = 56 shared the computer with other builds for part of its time. Whether r = 56 routes at this seed is unknown. Its accuracy is in the sweep's tests: 9,794 test images right as integers, 9,795 in float.

rtest images right, integer (float)logic cellsflip-flopsFmax after routing
329,776 (9,772)20,1724,97350.43 MHzfits (E7)
409,771 (9,771)23,9155,93651.34 MHzfits
489,791 (9,792)27,2666,89549.11 MHzmisses 50 MHz
449,803 (9,803)25,4296,41747.35 MHzmisses
429,795 (9,796)24,9346,17450.29 MHzfits: E11
439,805 (9,802)25,3266,29649.68 MHzmisses

The rows are in the order the search built them. Each design took 20 of the 18 × 18 multipliers and 1 DP16KD, the pixel FIFO, and each routed. So E11 is r = 42: the largest rank this search found that fits, with r = 43 the smallest that doesn't. r = 42's bitstream is e55ea4b7…, and no board has run it. The test counts are tested, by the sweep's tests above, which take in every rank committed here. The build figures are nextpnr's, trusted (fpga-toolchain).

What it answers:

Like the sweep's, the search ranks are committed (models/littlebit/runs/r40 to r56) and held by the same tests. r = 42 also has a network case in the test vectors, and cocotb runs it like the sweep's: 1,271 clocks an image (littlebit_network_scores_the_sweep_s_test_vectors_as_the_golden_model_does).

E9, the weights in block RAM (2026-11-23). E9 is E6's network, r16's integer.json, in Variant B: every table an engine keeps a row of is in block RAM ("Variant A and Variant B in Amaranth", above). It is built as E6 is, with --variant B (OSS CAD Suite 2026-11-21). nextpnr reports both, built from the same commit:

r16, the board's designlogic cells (TRELLIS_COMB)flip-flops18 × 18 multipliersblock RAMFmax after routingclocks an imagebitstream's sha256
E6, Variant A12,6403,050201 DP16KD55.63 MHz1,219754c51ae…
E9, Variant B7,4003,0802014 DP16KD54.35 MHz1,2192f70c963…

The 14 blocks are the pixel FIFO, one for each of the hidden layers' 10 tables, and 3 for the output layer's weights, whose rows are 80 bits wide. The Yosys log maps all 11 tables' memories to block RAM, each via $__DP16KD_ or via $__PDPW16KD_. A second build of E9 gave the same bitstream, byte for byte. Adding Variant B left Variant A's design as it was: built again from this commit, E6 gave the bitstream above, byte for byte. Its RTLIL, the file Yosys reads, is the same as before but for its notes of source lines, and so is r = 42's.

The clocks are cocotb's. In both variants, r16 scores its six test images as the golden model does, in 1,219 clocks each. Variant B also does so on MNIST's first 1,000 test images, and each hidden layer computes as the golden model does, as does the convolution, with its gaps (littlebit_network_scores_r16s_test_vectors_as_the_golden_model_does, littlebit_network_scores_mnist_test_images_as_the_golden_model_does, and the layer tests). The build figures are nextpnr's, trusted (fpga-toolchain). No board has run E9.

What it answers, for research question 3, at r = 16:

Two builds came before this one:

E12, the highest clock that closes (2026-11-23). E12 is E6, r16 in Variant A, at a clock above 50 MHz. "Closes" means what "fits" meant for E11: the whole board design places, routes and meets its clock in nextpnr, at its default seed. The PLL makes only some clocks from the 25 MHz oscillator: 25 MHz × CLKFB / CLKI, with the PFD and VCO in range. From 50 to 80 MHz, it makes 15 whole numbers of hertz, rising from 50 in steps of 3.125 MHz or less. ecppll's dividers for each are in gateware/bringup/pll_echo.py (ECPPLL), and each gives its clock exactly (test_each_clock_s_ecppll_dividers_give_it). How to search was fixed before the first build: build at each clock, rising from 53.125 MHz, and stop after two misses in a row. E12 is the highest that closed. Each was built with --clock-mhz (OSS CAD Suite 2026-11-21), and nextpnr took the PLL's clock as its target ("Derived frequency constraint", in its log):

clocklogic cells (TRELLIS_COMB)flip-flopsFmax after routing
53.125 MHz12,6353,05057.96 MHzcloses
55 MHz12,6483,05058.35 MHzcloses
56.25 MHz12,6463,05058.21 MHzcloses
59.375 MHz12,6323,05259.78 MHzcloses: E12
60 MHz12,7033,05252.93 MHzmisses
62.5 MHz12,6293,05255.25 MHzmisses

Each took 20 of the multipliers and 1 DP16KD, the pixel FIFO, and each routed. E12's bitstream is 13ee59f5…, and a second build gave it byte for byte. At 50 MHz the design is still E6's: its RTLIL is the same as before but for its notes of source lines. The build figures are nextpnr's, trusted (fpga-toolchain). No board has run E12, or any clock but 50 MHz.

What it shows:

E10 on the board's design (2026-11-23). E10, the wider network at E7's bits ("E10, the wider network", in Model), is built as the sweep's ranks are, from its own integer network (python -m gateware.littlebit.network <build-dir> models/littlebit/runs/e10/integer.json, OSS CAD Suite 2026-11-21). nextpnr reports, beside E7:

runwidthsrlogic cells (TRELLIS_COMB)flip-flops18 × 18 multipliersblock RAMFmax after routingclocks an imagebitstream's sha256
E7784 → 256 → 128 → 103220,1724,973201 DP16KD50.43 MHz1,2511b92ff46…
E10784 → 1024 → 512 → 10917,4552,258201 DP16KD53.52 MHz2,357c7fc7532…

The build figures are nextpnr's, trusted (fpga-toolchain), and a second build of E10 gave the same bitstream, byte for byte. The clocks are cocotb's: E10 scores r16's six test images as its golden model does, in 2,357 clocks each (littlebit_network_scores_the_sweep_s_test_vectors_as_the_golden_model_does). That is 784 + 1 + 9 + 3 for layer 1, 1,024 + 1 + 9 + 3 for layer 2 and 512 + 1 + 10 for the output layer, as the network's schedule counts them (Clocks per image, above). No board has run E10.

So at E7's bits, E10 fits the board, in 2,717 fewer cells and at a faster clock than E7. It takes 1,106 more clocks an image, 47.1 µs at 50 MHz, or 21,213 images a second. It gets 230 fewer test images right.

Verification

Every stage must match the integer golden model bit for bit; accuracy is compared only at the step from float to integer. Four models, three checks:

checkcomparespasses whenits grade
1. quantization gapthe PyTorch float model vs. the Rust integer golden modelaccuracy drops ≤ 0.5 points on the 10,000 MNIST test imagestested
2. the gatewarethe golden model vs. Verilator, through cocotball 10 scores identical on all 10,000 test imagestested
3. the boardthe golden model vs. the i9 over UARTthe same digit and scores on at least 1,000 imagesmeasured

Check 1 passes at r = 16 (2026-11-22). Run from models/littlebit/runs/r16/integer.json, the integer golden model gets 9,717 of the 10,000 test images right. That is 4 more than the float model's 9,713, not fewer, and the two pick the same digit on 9,980 of the images. On the training images the integer model gets 58,809 right, against the float model's 58,798. Both are tested, by r16_integer_is_within_half_a_point_of_float and r16_integer_saturates_no_latent_on_the_training_images. So 8-bit scales were enough at this rank.

Check 2 passes at r = 16 (2026-11-23). On Verilator, the network's gateware (LittleBitNetwork) scored all 10,000 MNIST test images exactly as the golden model does: every one of the 10 scores, and the digit. Each image took 1,219 clocks. That is tested, by littlebit_network_scores_mnist_test_images_as_the_golden_model_does, which the Quality Gate runs on every commit. In the gate it takes 356 s of real time for the 10,000 images. With nextpnr's 12,640 logic cells at 55.63 MHz (What the whole network costs), Gate 2 passes.

Check 3 passes at r = 16 (2026-11-23). On i9-2, at 50 MHz from the PLL, the whole network (gateware/littlebit/network.py) scored MNIST's first 1,000 test images exactly as the golden model does: every one of the 10 scores, and the digit. The network counted 1,219 clocks for every image. That is measured, 2026-11-23-i9-littlebit-network, so Gate 3 passes:

imagesscored exactly as the golden modellab log, 2026-11-23
before the load (r16's first layer), the network's test vectors6 framesnone: the host command refused image 1's answer, which started 0x01seq 26
the network's test vectors for r1666, 1,219 clocks eachseq 28
MNIST's first 1,000 test images, as MNIST stores them1,0001,000, 1,219 clocks each, in 72.8 sseq 29

974 of the board's 1,000 digits are MNIST's labels. The golden model gets the same 974 by construction, since the scores are identical. Which bytes the host command read before the load is unknown: the layer design answers 1,281 bytes a frame, and the command reads 46.

What each figure of a run rests on: its accuracy is computed on the host, so tested at best; its LUTs, EBR blocks and Fmax are nextpnr's, trusted with the toolchain (trusted-base.toml, fpga-toolchain); its images per second and cycle counts are measured. Each board run is a measurement record, lab/records/<id>.toml (CLAUDE.md, "Conventions"), in place of the spec's results/runs.csv. The record's gateware hash covers the weights in both variants, since both are inside the bitstream.

The golden model

cocotb tests

On the board: the host command sends each image, reads back the 10 scores and the argmax, and logs any mismatch with the image's index. It also times round trips, for images per second.

Grading a training run (decided by Claude at Jon's request, 2026-11-22). A run's weights and summary are committed, in models/littlebit/runs/<run>/: weights.f32, every parameter as little-endian float32, and summary.json, what was run and what it scored, with the weights' sha256. A Rust test in crates/littlebit re-scores the committed weights with its own arithmetic and checks the summary's counts, on MNIST the Quality Gate fetches and the test refuses unless each file is its pin (models/littlebit/mnist.toml). The gate does not retrain: GitHub's runners have no GPU, and a GPU's and a CPU's float products differ, so a retrain there would grade another model. Weights are committed because a grade must be re-checkable, and because rebuilding a run's bitstream needs them. They are small: E1's are 0.9 MB, and the largest, E10's dense start's, 5.3 MB. Gateware tests stay cocotb, as the language policy has them, and a cocotb test is a referent as a Rust test is, named gateware <name>: a_code_referent_names_code_that_exists finds them, and the Quality Gate runs them on Verilator from OSS CAD Suite's Linux build of 2026-11-21, the lab computer's day. A Rust test wrapping cocotb's results would only add a layer.

Milestones

Six phases, in order. Each ends on a gate that passes before the next starts. There are no dates. Phase 0 may run beside Phase 1: it needs only the board and the toolchain.

  1. Phase 0, bring-up. The toolchain (Open questions), the i9's Amaranth platform, a blinky, then a UART echo at 115,200 baud, each load approved and logged. Gate 0: the LED blinks, and bytes from the computer echo back.
  2. Phase 1, the model on the computer. Train E1–E3 and the LittleBit sweep; write the golden model and the exporter. Gate 1: check 1 at r = 16, the integer model within 0.5 points of float. Check 1 passed on 2026-11-22 (Verification). E2 and E3 ran on 2026-11-23 (Model, "The baselines, E2 and E3"), and so did the sweep's other ranks, 4, 8, 32 and 64 ("The rest of the rank sweep").
  3. Phase 2, gateware and simulation. The weight-ROM generator, the layer engine and the top level; cocotb on Verilator. Gate 2: check 2, bit-exact on all 10,000 test images, and at most 30,000 LUTs at 50 MHz in nextpnr's report. The network's first board run waits for this gate. Two smaller board runs come before it, by Jon's choice (2026-11-22). The first is the PLL at 50 MHz, done (The board). The second is one layer from the engine, checked against the golden model: r16's first layer, done (The board, "One layer on the board"). Gate 2 passed at r = 16 on 2026-11-23 (Verification, "Check 2 passes at r = 16").
  4. Phase 3, on the board. Load E6 (r = 16, Variant A), run the host command, read the cycle counts. Gate 3: check 3, 1,000 images identical to the golden model. Gate 3 passed at r = 16 on 2026-11-23 (Verification, "Check 3 passes at r = 16").
  5. Phase 4, experiments and write-up. Run E1–E12, fill the results table, plot accuracy vs. bits per weight and LUTs vs. bits. Gate 4: the table is full, and both plots are made. Gate 4 passed on 2026-11-23 (Experiments, "The two plots").
  6. Phase 5, a chip's layout, with no chip made. The largest hardwired LittleBit layer that fits one Tiny Tapeout tile, laid out with LibreLane. Its Classic flow takes Verilog, which Amaranth emits, and runs Yosys's synthesis and OpenROAD's placement and routing (librelane/flows/classic.py) for a standard-cell process (sky130A in its README's example). The ECP5's own blocks go: no PLL, block RAM or multipliers, so it is Variant A only, and the cocotb layer test runs against the Verilog it lays out. A tile is "about 160x100 um", "enough for about 1000 digital logic gates" (Tiny Tapeout's FAQ, of its runs TT04 to TT10; a sky130A tile is now 161.00 × 111.52 µm, prior-art.md, "A chip's layout"), with 8 inputs, 8 outputs and 8 bidirectional pins besides the clock and reset (same FAQ), so the layer takes its inputs a few bits at a time. It costs nothing. Its figures rest on LibreLane, OpenROAD and the process kit, which trusted-base.toml does not list yet. Gate 5: LibreLane finishes the layer with its own checks passing, and its cells and area per weight bit stand beside the i9's LUTs per weight bit (research question 5).

Gate 0's echo goes through the same DAPLink serial port as the bench's Phase 1 "hello" over UART (roadmap.md), so whichever runs first settles those pins for both. Gate 0 ran first (2026-11-22-i9-uart-echo).

First steps

Experiments

Twelve runs answer research questions 1–4: E1–E3 set the baselines, E4–E8 sweep the rank, E9 compares hardwired and stored, and E10–E12 test the budget and the fit. Question 5 is Phase 5's. Each cell fills as its run finishes, from the run's record or test.

runmodel (784 → 256 → 128 → 10 unless noted)variantlayer-1 total bpwinteger test acc (%)LUTsEBR blocksFmax (MHz)images/sstatus
E1FP32 dense (the ceiling)computer only3298.31 (float)————done
E2int8 densecomputer only898.33 (float 98.35)————done
E3binary dense, one scale per outputcomputer only1.01098.24 (float 98.24)————done
E4LittleBit r = 4A, hardwired0.06287.91 (float 88.02)6,8891 (the pixel FIFO)55.271,195 clocks each, 41,841 at 50 MHzbuilt; not run on the board
E5LittleBit r = 8A, hardwired0.08394.63 (float 94.64)8,9391 (the pixel FIFO)50.061,203 clocks each, 41,563 at 50 MHzbuilt; not run on the board
E6LittleBit r = 16A, hardwired0.12597.17 (float 97.13)12,6401 (the pixel FIFO)55.6313.73 end to end; 1,219 clocks each, 41,017 at 50 MHzGate 3 passed
E7LittleBit r = 32A, hardwired0.20997.76 (float 97.72)20,1721 (the pixel FIFO)50.431,251 clocks each, 39,968 at 50 MHzbuilt; not run on the board
E8LittleBit r = 64A, hardwired0.37698.15 (float 98.14)35,1391 (the pixel FIFO)49.55, short of 501,315 clocks each; 50 MHz not metover the cell budget, and short of 50 MHz
E9LittleBit r = 16B, block RAM0.12597.17 (float 97.13): E6's integer network7,40014 (13 for the weights, 1 the pixel FIFO)54.351,219 clocks each, 41,017 at 50 MHzbuilt; not run on the board
E10LittleBit r = 9, wider: 784 → 1024 → 512 → 10, its hidden layers' bits within E7'sA, hardwired0.03895.46 (float 95.55)17,4551 (the pixel FIFO)53.522,357 clocks each, 21,213 at 50 MHzbuilt; not run on the board
E11LittleBit r = 42, the largest fit: r raised until place-and-route or 50 MHz failsA, hardwired0.26197.95 (float 97.96)24,9341 (the pixel FIFO)50.291,271 clocks each, 39,339 at 50 MHzbuilt; not run on the board
E12clock push: E6, LittleBit r = 16, at the highest clock that passes, 59.375 MHzA, hardwired0.12597.17 (float 97.13)12,6321 (the pixel FIFO)59.78, clocked at 59.3751,219 clocks each, 48,708 at 59.375 MHzbuilt; not run on the board

A dash marks a figure that a computer-only run doesn't have. E3's 1.010 bits a weight are its signs and one 8-bit scale per output, (784 × 256 + 8 × 256) / (784 × 256). Like the LittleBit formula, it counts no bias, and no power-of-two exponent.

The table's accuracies are what the runs get: each integer network as the golden model scores it, and each float run's count, from its summary, on the 10,000 test images (tested, the_experiments_table_s_accuracies_are_what_the_runs_get). Its LUTs, EBR blocks and Fmax are nextpnr's, trusted (fpga-toolchain). Its clocks an image are cocotb's, and the images a second beside them are worked out from those clocks at the clock named. E6's 13.73 images a second end to end is the one measured on a board (2026-11-23-i9-littlebit-network).

The two plots (2026-11-23), drawn from this table by cargo run -p tentzhen-littlebit -- plots (crates/littlebit/src/plots.rs). the_plots_are_what_the_experiments_table_draws fails if either file is not what the table draws. Each image's description lists every value it plots, and the table above gives them too.

Test accuracy against layer 1's total bits per weight, E1 to E8

Logic cells against the sign bits hardwired, Variant A, E4 to E8 and E11

Training with the signs fixed

Jon asked whether this helps training as well as inference (2026-11-23). Hardwired weights can't be trained where they are: in Variant A, a new weight is a new bitstream. But a LittleBit layer keeps its magnitudes apart from its signs, in the scale vectors g, ℓ and h. A chip could keep those, the biases and the output layer in registers or block RAM, and its signs in logic. At r = 16 that is 3,130 values beside 22,784 signs. This experiment asks how much such a chip could learn by changing only those (models/littlebit/train_frozen.py, 2026-11-23).

All of it was fixed before the first run. Each run starts from r16 as committed and keeps r16's activation exponents, as the hardware's shifts are fixed. It trains by r16's recipe, unchanged. There are three tasks:

There are four regimes, by what may train:

tasknothing trainedthe output layerthe scales, signs fixedeverythingsigns flipped by "everything", of 22,784
MNIST9,7139,7309,7319,7071,978
MNIST, inverted1088,7719,0249,5263,392
Fashion-MNIST3407,2698,3018,6674,813

The figures are test images right, of 10,000, in float. They are PyTorch's counts on the GPU, and unknown: the runs are not committed, and no test re-checks them. Two runs of each gave the same weights, byte for byte, in 22 to 54 s each. Untrained, the script's r16 is the committed one: its weights' sha256 is r16's, and it gets r16's 9,713.

What it shows:

What it doesn't show:

After MNIST: Clean Up's policy

The first real objective after MNIST passes Gate 3 is SocialJax's Clean Up policy hardwired into the i9, and its convolutions come early, not when that step starts (Jon, 2026-11-22). The game runs on the computer: each step it sends an agent's 11 × 11 × 19 observation over the UART, the i9 gives the 9 actions' scores, and the computer draws an action from them and plays it. The plan had the i9 pick the action itself, but the trained policy taking its most likely action never scores ("The float baseline", below). Agents on the i9 and on the computer can share a game. The check is MNIST's: the hardwired policy gives the golden model's 9 scores on every observation, and its game score stands beside the float policy's.

The policy as SocialJax builds it (algorithms/utils/networks.py at 18e2171). Flax's convolutions default to stride 1 and "same" padding (google/flax at v0.10.7, the version SocialJax pins, flax/linen/linear.py), so the grid stays 11 × 11 through all three:

layerkernelchannels inchannels outpositionsweightsMACs per decision
conv 15 × 5193212115,2001,839,200
conv 23 × 332321219,2161,115,136
conv 33 × 332321219,2161,115,136
dense1 × 13,872641247,808247,808
actor 11 × 1646414,0964,096
actor 21 × 16491576576
total286,1124,321,952

tested: the_clean_up_policy_counts_follow_from_its_shapes recomputes the table from its shapes, and the two bit rates below. Biases, 233 more, are left out, as the MNIST counts leave them out.

What it means for the plan:

The float baseline (models/cleanup/, 2026-11-23). This is SocialJax's own trained policy playing Clean Up on the computer, the figure the hardwired policy is to stand beside.

how an agent actsgamesreturn, mean (sd)the actions taken most
drawn from the policy, as SocialJax plays it100524.2 (211.6)up 41 %, zap_clean 24 %
the policy's most likely action1000.0 in every gamezap_clean 71 %; up never
uniformly at random1004.0 (17.0)each about 11 %

A game's return is its 7 agents' rewards summed over its 1,000 steps. Out of 700,000 actions in each mode, the policy's most likely one was up none of the time, and zap_clean 497,680 times. These are play.py's figures, and unknown: its output is not committed, and no test re-checks it, since the game runs in JAX and nothing in Rust plays it. A second run of each mode gave the same returns, game by game.

What it means for the plan:

JAX's random numbers, in Rust (crates/cleanup, 2026-11-23). For a hardwired game to be checked against SocialJax's step for step, its golden model has to draw the random numbers JAX draws, and then the gateware the golden model's. So that comes first. JAX 0.6.2 draws with Threefry-2x32, 20 rounds of 32-bit adds, rotations and exclusive-ors (jax/_src/prng.py), which is cheap in LUTs and needs no multiplier. Its layout is the one JAX calls "partitionable", the default since 0.5.0 (jax/_src/config.py), and SocialJax doesn't change it: nothing at 18e2171 sets JAX's PRNG options. In this layout the i-th number drawn from a key is the hash of the counter i.

The biggest risk is accuracy at very low rank. If r ≤ 8 collapses, the project still answers its questions, with r = 16–64 as the low end.

riskeffectfallback
accuracy collapses at low rE4–E5 unusablereport it as a finding; add residual compensation; keep r ≥ 16
the float and integer models differ by more than 0.5 pointscheck 1 failsfake-quantize more stages in training; widen the scales to 16 bits
hardwired ROMs blow up the LUT count or the routingE7–E8 don't fitmove layer 1 to Variant B; hardwire only layer 2
timing fails at 50 MHzthe board runs unreliablypipeline the accumulator adds; drop to 25 MHz for correctness runs
wrong balls for the clock, LED or UARTnothing works on the boardGate 0, a blinky and an echo, before the network
Yosys folds or duplicates ROM logic unexpectedlyVariant A's figures misleadread the post-synthesis LUT breakdown; synthesize one layer alone and compare

The goal: cheaper than a GPU per game step

Jon, 2026-11-23: "the goal is to beat gpus at cost for this exact type of ml, basically solving societal conflict before it actually happens irl". That means multi-agent simulations run with agents already trained. The order: first match JAX, then "eventually build a system that is completely optimized for the fpga/an asiic". So the measure is cost per game step, the hardware's price over its life plus its energy, with the game and its trained policy both running. Speed alone isn't the measure.

The bar on the GPU (models/cleanup/bench.py, 2026-11-24, 00:20 to 00:23 UTC). This is SocialJax's Clean Up on the lab computer's RTX 4070 Ti: driver 621.01, WSL2's Ubuntu 24.04, JAX 0.6.2 with its CUDA 12 build (the cuda extra in models/cleanup/pyproject.toml).

games at oncerandom moves, game steps a secondwith the policy, game steps a secondboard watts, with the policymillijoules a game step, with the policy
14,041 (3,369 to 5,376)4,330 (4,264 to 4,412)5913.6
1658,957 (50,112 to 68,037)45,937 (32,205 to 48,048)922.29
256430,364 (429,806 to 430,713)164,390 (164,183 to 164,724)2331.42
1,024613,662 (612,195 to 616,270)177,885 (177,616 to 178,549)2551.44

Idle, with JAX loaded, the board drew 27 W. With random moves at 1,024 games it drew 160 W, 0.26 mJ a game step. These are bench.py's figures, and unknown: no record or test holds them. An earlier run, timed once a row, gave 179,348 game steps a second with the policy at 1,024 games, and 620,407 with random moves. new-melting-pot (YoungMoolahBaby/new-melting-pot) measured about 630,000 random game steps a second at 1,024 games on the same card, on JAX 0.12.

What it means for the plan:

The plan. Each step is a PR, and its claims carry their grades.

  1. Match JAX. First JAX's random numbers in Rust (crates/cleanup). Then:

    • Clean Up's game in Rust, step for step against trajectories SocialJax plays.
    • The integer policy: LittleBit on the convolutions and the dense layer, playing as the float policy does ("Whether a student plays as the teacher does"). Its draw is defined so that the chip and the golden model both make it exactly, with a JAX copy that matches them.
    • The game and the policy in gateware, checked in cocotb against the golden model, then on the i9.

    One cheap early check: synthesize conv 1 with the real policy's signs and read nextpnr's LUTs and clock, to replace the guess of a LUT a weight with a figure.

  2. Measure the cost a game step on both. The i9's power on the bench, the GPU's as above, and what each cost.

  3. Build for the FPGA or an ASIC. Shape the game and the policy for the hardware, judged by whether it plays as the trained agents do ("Whether a student plays as the teacher does") rather than bit for bit against JAX.

What exists already (searched 2026-11-23; prior-art.md, "Simulations in hardware"):

Not found:

How small the policy can get

The compression sweep, 2026-11-24. Smaller students are trained to act as SocialJax's policy does, and each is scored by playing the game. This was moved ahead of the game's golden model because it is the biggest lever on cost: what a move computes sets the hardware for everything after it (Jon, 2026-11-24, agreeing the order).

How it was run. The bar, set before the first run: a student keeps the policy's score if its mean return is at least 90 % of the teacher's on the same games. That bar has since been replaced: a student must play as the teacher does, not only score as it does, and under the new bar none of these students does ("Whether a student plays as the teacher does", below).

Every LittleBit student keeps the 9 logits' layer in float: 576 multiply-adds and 576 weights. Activations are float throughout; the integer form is the next step. The difference is each student's return less the teacher's, game by game on the same seeds, with its standard error.

studentconvolutionsLittleBita move computesit holdsreturnof the teacherdifferencekeeps it
teacher32, 32, 32—4,321,952 multiply-adds286,112 weights479.4
t3232, 32, 32—4,321,952 multiply-adds286,112 weights483.6101 %+4.2 ± 8.2yes
w1616, 16, 16—1,605,744 multiply-adds140,784 weights446.293 %−33.1 ± 7.8yes
w88, 8, 8—665,816 multiply-adds71,576 weights453.395 %−26.1 ± 7.6yes
w44, 4, 4—300,396 multiply-adds37,836 weights435.991 %−43.4 ± 7.7not settled: 0.6 standard errors over the bar
dense-r1632, 32, 32the dense layer, r = 164,074,144 multiply-adds and 62,976 sign additions38,304 weights and 62,976 sign bits466.797 %−12.7 ± 8.1yes
dense-r432, 32, 32the dense layer, r = 44,074,144 multiply-adds and 15,744 sign additions38,304 weights and 15,744 sign bits461.696 %−17.8 ± 8.1yes
all-r16, all-r8, all-r432, 32, 32every layer, from the teacher——0.0 in every game0 %no: never trained
all-r16-fresh32, 32, 32every layer, r = 16, fresh2,285,616 sign additions, 148,691 scalings83,376 sign bits, 5,291 scales413.886 %−65.5 ± 7.9no
all-r4-fresh32, 32, 32every layer, r = 4, fresh571,404 sign additions, 144,311 scalings20,844 sign bits, 5,231 scales390.481 %−89.0 ± 7.3no
w8-all-r88, 8, 8every layer, r = 8631,704 sign additions, 81,883 scalings14,424 sign bits, 1,843 scales386.681 %−92.7 ± 7.5no
w8-all-r48, 8, 8every layer, r = 4315,852 sign additions, 80,423 scalings7,212 sign bits, 1,823 scales386.981 %−92.5 ± 7.3no
w8, DAgger8, 8, 8—665,816 multiply-adds71,576 weights525.4110 %+46.0 ± 8.1yes
w8-all-r4, DAgger8, 8, 8every layer, r = 4315,852 sign additions, 80,423 scalings7,212 sign bits, 1,823 scales468.698 %−10.8 ± 7.7yes
all-r16-fresh, DAgger32, 32, 32every layer, r = 162,285,616 sign additions, 148,691 scalings83,376 sign bits, 5,291 scales469.198 %−10.2 ± 7.7yes

From one training run to the next. The two DAgger students that matter most were trained again from seeds 1 and 2, on the same data. The seed sets both the starting weights and the order of the batches. (A first retrain at seed 0 gave the same held-out KL to 4 digits, so it showed only that training repeats, as new-melting-pot pointed out.)

student, with DAggerseed 0seed 1seed 2against the teacher, game by game
w8525.4517.5512.9+46.0 ± 8.1, +38.1 ± 8.5, +33.5 ± 8.5
w8-all-r4468.6446.3488.7−10.8 ± 7.7, −33.1 ± 7.5, +9.3 ± 7.9

So w8 outscores its teacher in all three runs, each by at least 3.9 standard errors. w8-all-r4 keeps 93 to 102 % and clears the bar in all three, the closest by 2.1 standard errors. Its score moves about twice as far between runs as w8's.

How these are known:

What it means for the plan:

Whether a student plays as the teacher does

The integer form of w8-all-r4 changed the bar. Started from w8-all-r4's DAgger student and calibrated, untrained, it scored 737 a game, 152 % of the teacher. It got there by playing another game. 5.8 of its 7 players do a tenth of the cleaning or more, against the teacher's 4.0; they zap 1.7 times as often; and the river holds 18 % less dirt. The chip is to simulate the agents it was given, so a student that scores higher by acting differently is a different agent. So the bar from here: a student must play as the teacher does, measure by measure, and its score is one measure of 30 (Jon, 2026-11-24, agreeing to the recommendation).

How it is measured.

The held-out KL and the same top action are distill.py's, on the last 5 % of a student's training observations. For a DAgger student those are the end of its own games, not the teacher's, so its figures are on other observations than the rest's. "Where it misses" counts the measures missed of each kind:

w8-all-r4's DAgger student at seed 0 was trained twice, the second time with the same held-out KL to 4 digits. Its two rows differ by 2 measures, which shows how much the count moves on its own.

studentstarted frommeasures that match, of 30returnheld-out KL, natssame top actionwhere it misses
teacher, seeds 1,000 to 1,999—the reference485.5———
teacher, seeds 3,000 to 3,999—30480.0———
t32the teacher30484.50.00199.5 %—
t32-freshfresh27471.30.12583.7 %apples 1; beams 1; actions 1
w16fresh6442.40.13182.0 %return; apples 5; beams 5; zaps 2; the town 3; actions 8
w8fresh18453.70.13780.9 %return; apples 3; beams 3; the town 1; actions 4
w4fresh19429.50.14980.2 %return; apples 6; beams 2; actions 2
dense-r16the teacher23464.00.12784.9 %beams 1; zaps 1; the town 1; actions 4
dense-r4the teacher24457.60.14981.6 %return; apples 1; beams 1; zaps 1; actions 2
all-r16-freshfresh3410.20.16079.3 %return; apples 5; beams 6; zaps 2; the town 4; actions 9
all-r4-freshfresh11392.90.18278.8 %return; apples 6; beams 6; zaps 1; the town 1; actions 4
w8-all-r8fresh14388.80.17477.1 %return; apples 5; beams 1; zaps 1; the town 1; actions 7
w8-all-r4fresh3385.70.20077.3 %return; apples 6; beams 7; zaps 1; the town 3; actions 9
w8, DAgger, seed 0fresh16523.90.13882.5 %return; apples 6; beams 2; the town 1; actions 4
w8, DAgger, seed 1fresh14520.90.16381.7 %return; apples 6; beams 3; the town 3; actions 3
w8, DAgger, seed 2fresh16516.70.14682.2 %return; apples 6; beams 3; actions 4
w8-all-r4, DAgger, seed 0fresh13473.60.24474.3 %apples 3; beams 3; zaps 1; the town 2; actions 8
w8-all-r4, DAgger, seed 0 againfresh11471.70.24474.3 %apples 3; beams 4; zaps 1; the town 3; actions 8
w8-all-r4, DAgger, seed 1fresh15454.30.25573.5 %return; apples 3; beams 3; the town 1; actions 7
w8-all-r4, DAgger, seed 2fresh7490.10.24875.1 %apples 5; beams 6; zaps 2; the town 2; actions 8
all-r16-fresh, DAggerfresh8467.30.10285.8 %apples 3; beams 7; zaps 2; the town 2; actions 8
w8-all-r4, integer, calibrated onlyw8-all-r4, DAgger, seed 0 again1737.10.38669.7 %return; apples 7; beams 7; zaps 2; the town 3; actions 9
w8-all-r4, integer, trained 20 epochsw8-all-r4, DAgger, seed 0 again14440.80.23176.2 %return; apples 4; beams 4; zaps 1; the town 1; actions 5

What it showed.

How these are known: unknown. These are rollouts.py's, behaviour.py's and distill.py's figures, one run each, and no test re-checks them. The entropies, the counts across students, the sharpened students and their KLs come from throwaway scripts. They are kept with the students' files in D:\tentzhen-data\cleanup\scripts\, outside the repo.

What it means for the plan:

A recipe that makes a faithful student

The next step was to fix the recipe on the teacher's own shape before shrinking it (Jon, 2026-11-24). Each student below starts fresh and is scored on the behaviour bar on both sets of seeds. The scoring seeds stay apart from every training seed:

distill.py now keeps the recorded observations in the computer's memory and moves each batch to the GPU as it is used, since 500 games' are 8.2 GB. The change is meant to move only where the observations wait, not which batches are drawn or the arithmetic on them. Nothing checks that a run matches one from before it.

The held-out KL is on the last 5 % of the training observations. With 500 games, that is the last 25 of the teacher's first 100; with 100, the last 5.

Every student trained at the same rate, 0.001, falling to 0 on a cosine, in batches of 4,096, from seed 0. The KLs are those of the last epoch.

studentgames trained onepochsa move computesit holdsKL, training, then held outsame top action, held outmeasures that match, seeds 1,000 on, then 3,000 onreturn, both
t32-fresh100204,321,952 multiply-adds286,112 weights0.079, 0.12583.7 %27, not played471.3
t32-fresh1001004,321,952 multiply-adds286,112 weights0.042, 0.10186.6 %30, 28499.9, 494.0
t32-fresh500204,321,952 multiply-adds286,112 weights0.052, 0.05789.7 %30, 30492.8, 487.7
w850020665,816 multiply-adds71,576 weights0.076, 0.08187.7 %30, 30476.5, 468.4
w450020300,396 multiply-adds37,836 weights0.092, 0.09386.4 %27, 26475.3, 462.1
w8-dense-r450020603,864 multiply-adds, 4,128 sign additions and 1,036 scalings9,624 weights, 4,128 sign bits and 1,036 scales0.106, 0.10284.8 %16, 19463.1, 457.6
w8-all-r850020576 multiply-adds, 631,704 sign additions and 81,883 scalings576 weights, 14,424 sign bits and 1,843 scales0.126, 0.11483.5 %3, 2530.9, 535.4
w8-all-r450020576 multiply-adds, 315,852 sign additions and 80,423 scalings576 weights, 7,212 sign bits and 1,823 scales0.139, 0.12782.2 %11, 10483.8, 478.8

The teacher's returns on the two sets of seeds are 485.5 and 480.0. w8-dense-r4 is w8 with LittleBit on the dense layer alone, which holds 61,952 of w8's 71,576 weights.

What it showed:

How these are known: unknown. These are distill.py's, rollouts.py's and behaviour.py's figures, one training run each, and no test re-checks them. The entropies and the table are throwaway scripts'. They are in D:\tentzhen-data\cleanup\scripts\, where recipe_table.py reads each student's summary.json and its behaviour records.

What it means for the plan:

Longer training, and one step of DAgger

The recipe's next step was to train the LittleBit students longer, then to run DAgger on the 500 games. Each run below is the recipe above with one change:

studentgames trained onepochsKL, training, then held outsame top action, held outmeasures that match, seeds 1,000 on, then 3,000 onreturn, both
w8-dense-r4500200.106, 0.10284.8 %16, 19463.1, 457.6
w8-dense-r45001000.088, 0.08686.7 %30, 28491.3, 473.6
w8-dense-r45003000.081, 0.08287.2 %22, 23482.1, 472.9
w8-all-r4500200.139, 0.12782.2 %11, 10483.8, 478.8
w8-all-r45001000.134, 0.11883.6 %25, 22471.9, 472.5
w8-all-r45003000.120, 0.11483.8 %25, 24486.2, 477.7
w8-all-r4, DAgger500, and 100 of its own1000.139, 0.20175.4 %16, 16433.4, 424.4

The 20-epoch rows are the recipe's, from the table above. The DAgger student's held-out observations are the last 30 of its own 100 games, states the student reached rather than the teacher. So its held-out KL can't be compared with the others'.

What it showed:

How these are known: unknown. These are distill.py's, rollouts.py's and behaviour.py's figures, one training run each, and no test re-checks them. The action probabilities on the teacher's states come from a throwaway script, shares_on_teacher.py. It is in D:\tentzhen-data\cleanup\scripts\, with recipe_table.py, which makes the table, and the runs' recipe.sh and dagger.sh.

The training needs more compute

Jon stopped the training here (2026-11-24). Doing it seriously takes a lot more compute than this one GPU, so the next step is getting that compute.

What a run costs on this computer, by distill.py's own clock, and unknown: no run's output is committed. The computer has one RTX 4070 Ti (12 GB), and 32 GB of memory.

runtime
one student, 100 epochs on 500 games1,083 and 1,158 seconds, about 19 minutes
w8-dense-r4, 300 epochs2,349 seconds
w8-all-r4, 300 epochs7,677 seconds
DAgger's 600 games, 100 epochs2,581 seconds
scoring one student on 2,000 games, the same GPU through WSL1 to 6 minutes

At 300 epochs, w8-all-r4's epochs took 2.2 times as long as at 100. Other work ran on the computer at the same time, and why it slowed is unknown.

What limits it:

Both limits are arithmetic on the times and sizes above.

Where more compute could come from: GPUs rented by the hour, research-compute programs, or a bigger GPU here. None has been looked into yet, and spending on any of them is Jon's decision. Once there is more compute, distill.py would run several students side by side, and read the games from disk so the data can grow.

The gateware does not wait for the training. conv2's and conv3's kernels take w8-all-r4's shape, and new weights change only their values.

What w8-all-r4 costs on the i9, as the engine stands

Each of w8-all-r4's five LittleBit layers was built as the MNIST layers' engine (gateware/cores/littlebit.py, "Hardware architecture"), with its own real signs and int8 scales, then sized by Yosys and nextpnr. It is the shape's cost, not a chosen student's: none plays as the teacher does yet. The student is w8-all-r4's integer form, trained 20 epochs.

layerin → outrVariant A: logic cells, flip-flops, multipliersFmaxVariant B: logic cells, block RAMsFmaxclocks a move
conv15 × 5 × 19 = 475 → 841,488, 332, 461.45 MHz866, 562.69 MHz59,048
conv23 × 3 × 8 = 72 → 84938, 326, 459.13 MHz823, 558.46 MHz10,285
conv372 → 84934, 325, 460.63 MHz828, 555.41 MHz10,285
dense11 × 11 × 8 = 968 → 6442,260, 351, 457.48 MHz888, 556.04 MHz1,037
actor64 → 6441,047, 330, 464.16 MHz811, 561.10 MHz133
all five6,667, 1,664, 204,216, 2580,788

The cells, flip-flops, multipliers, block RAMs and clock are nextpnr's figures, trusted with the toolchain (trusted-base.toml, fpga-toolchain). The clocks are the engine's: a vector takes inputs + rank + outputs + 1 clocks, given an input every clock. That is tested for MNIST's layers (gateware/cores/tests/test_littlebit.py), and here each conv layer runs it once at each of the grid's 121 positions. The 9 logits' layer, the windows fed to the convolutions, the sampler and the game are not counted.

What it means:

A hardwired kernel for conv1

The engine reads each scale from a table and multiplies by it, one input a clock. The hardwired kernel, WindowKernel (gateware/cores/littlebit_kernel.py), makes every integer of the layer a constant of the circuit and takes a whole window each clock. It computes what the golden model computes, as the engine does.

That it matches the golden model is tested (littlebit_kernel_computes_each_window_of_clean_up_conv1_as_the_golden_model_does). The test uses a new case of the test vectors, clean-up-conv1 (crates/littlebit/src/vectors.rs): a made-up layer of conv1's shape on an 11 × 11 grid of an observation's values. Its 121 windows go in back to back, then with gaps. Every y and z must be the golden model's, at the kernel's latency, with registers after every level and after every 2. Another test checks that the kernel makes no multiply and no memory (test_littlebit_kernel_multiplies_nothing).

Each build is the kernel in Alone, which loads a window a bit a clock through 825 flip-flops and shifts the outputs out through 64 more. Then Yosys's synth_ecp5 and nextpnr-ecp5 size it, as the engines were, for the LFE5U-45 in its CABGA381 package, speed 6, at 50 MHz, seed 1, with OSS CAD Suite 2026-11-21. w8-all-r4's integers are the section above's, for sizing only. The made-up layer is clean-up-conv1, so its builds can be made again from the repo alone: python -m gateware.cores.littlebit_kernel gateware/cores/tests/littlebit_vectors.json 3 <out.v> rows alone <every>.

conv1 asadds between registerslatencylogic cellsflip-flopsmultipliersblock RAMsFmaxclocks a move
the engine, Variant A, w8-all-r4's integers1,4883324061.45 MHz59,048
the kernel, w8-all-r4's integers1215,7855,99000153.92 MHz121
the kernel, w8-all-r4's integers2126,0113,81400117.73 MHz121
the kernel, the made-up layer1217,2747,38900160.72 MHz121
the kernel, the made-up layer2127,7484,68400105.22 MHz121

The cells, flip-flops, multipliers, block RAMs and clock are nextpnr's figures, trusted with the toolchain (trusted-base.toml, fpga-toolchain). The kernel's include Alone's 889 flip-flops. Its clocks a move are its 121 windows, one a clock. The script that built them is synth_kernel.sh, in D:\tentzhen-data\cleanup\scripts\.

What it means:

Open questions

Stretch goals

What exists already

Searched 2026-11-21 (prior-art.md, "Hardwired neural networks"). Networks built into an FPGA's logic are well trodden on Xilinx parts with vendor tools. With open tools on an ECP5, the closest is pocket-bnn, a binary network with its weights as constants on an ECP5-85F. No project found puts LittleBit-style low-rank binary factors on an FPGA, and none compares one network's weights hardwired and in block RAM. On the i9 itself, ecp5-inference runs a small int8 language model from stored weights. In silicon, a logic-gate network on Tiny Tapeout classifies MNIST in "10K logic gates".

For the goal of running simulations more cheaply than a GPU, searched 2026-11-23 (prior-art.md, "Simulations in hardware"): environments in HDL and whole single-agent games on FPGAs exist, and so does a JAX environment matched exactly outside JAX, in C++. A multi-agent social dilemma on one chip with its policy, matched bit for bit with JAX, was not found ("The goal", above).

Written in docs/littlebit.md, on main; this page is made from it.