Skip to content

About

A protocol chip that won't start firmware whose timing it can't prove. Written in Hardcaml for Tiny Tapeout.

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Latest commit

 

History

2,400 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

the carrier board's surprised cat

protocol-emulator: proved on time, or it doesn't run

A small chip that bit-bangs protocols from firmware, and won't start any firmware whose timing it can't prove. Written in Hardcaml for Jane Street's protocol emulator ASIC competition, built on IHP CMOS5L through Tiny Tapeout, in 8 x 4 tiles at 48 MHz.

from firmware to silicon

Two small cores drive the pins from firmware, much like the RP2040's PIO. The difference is time. Each core has a 24-bit clock, a deadline register t and a period p. wait t+ releases on the exact cycle of the deadline and moves it on by one period, so a frame never drifts. A UART bit or an I2C hold time is a deadline written in the program, not a count of instructions you hope adds up.

A small kernel checks a certificate of each program's timing and refuses anything it can't check. The kernel is proved against the RTL. If it accepts a program, that program never misses a deadline on the chip, under the assumptions in Verification.

The chip runs that check itself. Before it lets an engine start, it walks the program against its certificate, and it refuses the start if the walk fails. If a deadline is ever missed anyway, the engine lets go of its pins and halts, and that is proved too. The chip also takes USB full speed packets off the pins into the data memory with their CRCs checked, and 10BASE-T frames when clocked at 40 or 50 MHz.

A timing bug is a compile error

This is the bit loop of test/uart_tx.asm, a UART transmitter at 16 cycles a bit. wait t+ holds until the deadline, then moves it on by one period.

bit:
    wait t+
    out pins, 1
    jmp x--, bit

Give its out 13 cycles of delay and the loop no longer fits in a period. The assembler says where, and the chip won't start a program whose certificate doesn't check.

$ dune exec -- bin/generate.exe assemble late.asm
late.asm: 3 of 3 deadline waits may be missed
  8  wait t+                      phase -13..?  slack ?..13  MAY MISS

Protocols it wasn't built for

The competition asks for flexibility first, so we tested on protocols we didn't choose. A public random beacon (drand round 33346612) drew six from sigrok's decoders, and an agent wrote each firmware blind from the pinned spec. All six were certified, though only three of the specs give limits that bind anything. Eight more were sealed as a SHA-256 on 2026-10-02 and opened on 2026-11-02. All eight were certified, two of them against specs with no binding limits. On the board seven pass and LIN passes in part, as nothing on the bench answers its header. Every result is on Flexibility, the ones that don't flatter us included.

At a glance

Source
Process IHP SG13CMOS5L through Tiny Tapeout, 8 x 4 tiles info.yaml, .github/workflows/gds.yaml
Clock 48 MHz info.yaml
Cores 2 cores, 3 IHP 512 x 16 SRAM macros: a program memory each and a data memory they share src/protocol_emulator.v
Pins 4 for the host's SPI, 5 in, 7 out, 8 bidirectional, and 8 wires between the cores info.yaml, src/isa.ml
Hardened 48,755 standard cells at 66.6% utilisation, setup slack +2.232 ns at the slow corner, hold slack +0.070 ns, precheck clean gds run 47405296904
Firmware 72 library firmwares the kernel accepts test/test_kernel.ml
Proved a program the kernel accepts never misses a deadline on each core's RTL, under the assumptions in Verification formal/phase_table.sby, formal/phase_table_affine.sby
Board the 8 x 4 RTL on an Icepi Zero (ECP5 FPGA), 42 recorded runs: 34 PASS, 6 learning runs, LIN in part and one FAIL, which is pico-examples' pio_i2c holding START too short. Each is listed under On the board. No silicon yet test/board/

Try it

No install: the playground runs the kernel in your browser. Paste firmware and it accepts or refuses it, and says why.

Run it on the real board

The bench is an Icepi Zero FPGA on my desk running the chip's RTL at 48 MHz. Open an issue with a waveform and it runs your job and answers there. Issue #2 sent two UART bytes at 1.846 Mbaud this way. The lab page checks a job in your browser and fills in the issue for you, and Run it on the board says what a job is and what comes back.

Docs

The site has the rest:

Contributing

Bug reports and pull requests are welcome. Getting started has the build. CI runs dune build @fmt, dune build @runtest and ruff check python/ demo/ test/, so run them before you open a pull request. Every OCaml module has an .mli. A change to the chip's Verilog starts a harden that takes hours, so say in the pull request if yours needs one.

About

A protocol chip that won't start firmware whose timing it can't prove. Written in Hardcaml for Tiny Tapeout.

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages