# A Forge system program on fpga-system/arty-a7-uart

One kernel, as the parts an FPGA engineer delivers together, each generated by Forge and each checked against the
others: the hardware block, the interface around it, the driver software that feeds it, and a float reference. The
kernel is the only certified thing here. Every other member is a deliverable that carries evidence of its own: tested,
never proved, never counted toward a verified figure. `program.json` names the kernel, every member, every identity
and the current evidence; `platform.json` is the platform's specification.

## The members

| directory | member | what it is |
|---|---|---|
| `rtl/` | the hardware block | a complete fpga/arty-a7 program: the kernel's Verilog and VHDL, its library closure, its own Makefile and evidence. It is the same program `eml-compile --platform fpga/arty-a7` makes, with the same identity |
| `interface/` | the interface | `hw_top.v`: the kernel behind the board's USB-UART (the bench wrapper), and `constraints.xdc`, the board's pins and clock |
| `driver_c/` | the C driver | a C99 library (`include/forge_link.h`, `include/forge_kernel.h`, `src/forge_link.c`) that turns values into the kernel's words, frames them, parses answers and drives the serial link (POSIX and Windows), and its command-line tool |
| `host_py/` | the Python host | `forge_link`: the same protocol in Python, the same command line (`python3 -m forge_link`), and `check`, which holds answers to the kernel's certificate |
| `model/` | the bit-true C model | `forge_model.h`, `libforge_model.a`: the kernel's words exactly as its RTL computes them, in ISO C99 with integers only and no clock, so firmware can be developed and tested without the board -- the glue generated from the record of `rtl/`'s top, and each library module's C twin. Never an accuracy oracle (that is the certificate's). A kernel it cannot carry has `REFUSED.txt` with the reason instead |
| `float_ref/` | the float reference | the kernel's float64 C build, for your own comparison: never the reference for anything |

## The protocol: forge-bench-uart, version 2

115200 baud, 8N1, one vector in flight. The host sends each input word as the W-bit two's-complement pattern in
ceil(W/8) bytes, least significant byte first, in the kernel's parameter order. The wrapper answers the result word
the same way (sign-extended), then the latency at the pin in 2 bytes, least significant first. A byte that arrives
while the wrapper is busy is dropped, so the host waits for each answer. Version 1 answered the word alone.

## The commands

| command | records | establishes |
|---|---|---|
| `make` | build | every member builds: the RTL, the interface around it, the C library and tool, the Python package, the float reference |
| `make run` | execution | the RTL testbench and the float reference ran on the recorded inputs, and the interface ran under simulation, fed the C driver's bytes through a simulated UART |
| `make check` | differential, encoding, interface_sim | the RTL's words lie within the certified bound of the exact value on the recorded inputs; both drivers encode and decode every word alike; the interface answers the bare RTL's words, bit for bit |
| `make synth` | synthesis | yosys maps the kernel, and the interface around it, to 7-series primitives |
| `make timing` | timing | the kernel's out-of-context timing on the bench (Vivado) |
| `make hardware` | hardware | on the bench: the bitstream, the programmed part and its timing in context, and the part's words through BOTH drivers, each equal to the simulation |
| `make model` | model | the C model returns the RTL's word on every input of the declared box, in simulation: each twin equals its module on every word, every sink of the real top (over recording stubs) equals the model's on every reachable tuple of its sources, and the whole model equals the whole RTL on every recorded input |
| `make reproduce` | reproduction | every member rebuilt twice, byte for byte, and compared with the record |

`platform.json`'s `establishes` holds the exact sentence each PASS proves, and nothing more. Every differential is
sampled: agreement on the inputs run, never universal equivalence. Put the Forge tree on PYTHONPATH, under the Python
in `python.lock`.
