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

One kernel, as the parts an FPGA engineer integrates on chip, each generated by Forge and each checked against the
others: the hardware block, the AXI4-Stream interface around it, the bit-true C model 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 | `axis_top.v`: the kernel behind an AXI4-Stream slave (its inputs) and master (its result), back-pressure absorbed by an in-order buffer; `axis_timing.v`: axis_top with its clock port named `clk`, no logic of its own, what `make timing` routes for the wrapper |
| `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 -- the reference for anything that drives the stream |
| `float_ref/` | the float reference | the kernel's float64 C build, for your own comparison: never the reference for anything |

## The stream: axi4-stream, version 1

One clock (`aclk`), `aresetn` active low and synchronous. One transfer per vector: `s_axis_tdata` holds each input word
in ceil(W/8) bytes, least significant first, in the kernel's parameter order; `m_axis_tdata` holds the result the same
way, sign-extended. No TLAST, TKEEP, TSTRB or TUSER.

**The latency, for accepted transfers.** The kernel never stalls. The result of a transfer accepted on edge k (TVALID
and TREADY both high) may be taken from edge k + L + 1 -- the kernel's own L, whatever the consumer does, and one clock
for the buffer -- and leaves on the first edge from then on on which `m_axis_tready` is high and it is the oldest
result unsent: nothing is lost, duplicated or reordered. While the consumer keeps TREADY high, one transfer a clock;
under back-pressure the slave's TREADY falls only when the buffer could not hold every result already in flight.

## The commands

| command | records | establishes |
|---|---|---|
| `make` | build | every member builds: the RTL, the stream interface around it, the C model, the float reference |
| `make run` | execution | the RTL testbench and the float reference ran on the recorded inputs |
| `make check` | differential, interface_sim | the RTL's words lie within the certified bound of the exact value on the recorded inputs; the stream interface answers the bare RTL's words in order, with the latency above, under back-pressure, by the protocol |
| `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, and the wrapper's around it (interface/axis_timing.v), on the bench (Vivado) |
| `make model` | model | the C model returns the RTL's word on every input of the declared box, in simulation |
| `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. `hardware` is
NOT_APPLICABLE: no board drives the stream yet. Put the Forge tree on PYTHONPATH, under the Python in `python.lock`.
