Developing module by module
A design is a tree of modules – kernels, memories, the devices that put kernels on a bus, the systems that hold them. Developing it module by module means: run each module alone, verify it, measure its timing, and then compose – a parent’s behavior and timing follow from its children’s, checked once against the parent’s RTL. These pages are the practice; Free-running polynomial is it on one kernel, and Two kernels on a bus on a system of several.
A unit is any module in the tree
There is no unit class. Any HwModule in a design’s DUT tree can be built and run alone – a leaf
kernel, a memory, a composite of several. The unit tree is the module tree: a module’s children,
boundary and wiring are already declared by the module itself.
What runs is always an HwSystem: a simulation plus one named DUT.
The testbench is everything else in the simulation, derived, never listed. Each testbench participant
must have a lowering to the RTL testbench (its bfm_model()), so the same system runs in pysim and under
XSI.
The practice, a page each
- The harness –
harness(module): the module made the DUT of its own system, a stand-in per port chosen by the port’s type (streams, credit streams, memory-master ports), each with its RTL twin; a memory’s own harness; the scenario the module supplies,workload(kind). - Reading a harness’s recordings – what each stand-in records, where a pysim run and an RTL run put it, and the cycles each word arrived at and was accepted at.
- Hostile stand-ins –
StandInPolicyandadd_robustness_steps: the harness again with stalling sinks, held-off drivers, starved credit and late answers. - Calibrating in a harness – a module’s timed phases fitted in its harness and filed under its identity.
- Composing a parent – a parent’s pysim composed from its units’ records, checked against its RTL; incremental builds.
Table of contents
- The harness - harness(module) makes any module the DUT of its own HwSystem: a fresh copy of the module (its class and build parameters) on a new Simulation, with a stand-in at each port chosen by the port's type, each with an RTL twin. A stream input gets a StreamDriver (AxisMaster at RTL), a stream output a StreamSink (AxisSlave), a credit stream a CreditSink or CreditSource, and the module's memory-master ports (MMIFReadMaster, MMIFWriteMaster) one shared MemoryMod on a zero-latency crossbar (one FlatMemory arena at RTL, served to each m_axi bundle by AxiMmReadSlave or AxiMmWriteSlave). A memory's own slave port is harnessed by memory_harness and a scripted MmScript master. The scenario is the module's: workload(kind) returns {input port: bursts} and, under one memory port, the memory's initial image. The harness runs through the system flow with add_system_steps: mem_copy's harness matches pysim word for word at RTL and finishes at 2908 cycles (Vivado 2025.1).
-
Reading a harness's recordings - What a harness records and where. Each stream sink records vectors/
, the memory stand-in its final arena as vectors/mem: HwSystem.recordings(), compared word for word RTL against pysim. At RTL a sink's recording also has cycles.bin, the cycle each word arrived, and each stream input's driver records vectors/ _acc, every word the DUT accepted with the cycle it did (HwSystem.acceptances(), RTL only). In pysim the recordings are bundles under the scenario root and the sinks' words in memory (sysm.stand_ins[port].words). Through the system flow: /pysim_run and /xsi_run hold each run's vectors, /pysim_traces and /traces the gathered recordings, /compare.json the verdict. mem_copy's harness at RTL (Vivado 2025.1): 32 command words accepted, the last at cycle 2361; the last completion at 2908. - Hostile stand-ins - A polite testbench never shows that a module survives anything else. A StandInPolicy makes each of a harness's stand-ins misbehave as its protocol allows: a stream sink drops TREADY, a stream driver or credit source holds off its next word (never withdrawing one it presented), a credit sink holds its reports (starved credit), a scripted bus master takes its answers late. At RTL the stall is cycle by cycle, from a seeded hash shared with the C++ models; pysim approximates it per burst. add_robustness_steps adds the harness once per policy that touches its stand-ins, and each one's compare is the check: the RTL must still finish with exactly pysim's words. The memory stand-in is polite: the RTL AXI-MM slave models have no stall policy.
- Calibrating in a harness - A module's timing is declared as timed phases -- spans between handshakes at its own ports, with the features their durations depend on -- and calibrated in its harness. A module that declares timed phases and a calib_holdout gets a calibration workload for free: the harness of the same module on its workload('calib'), with the held-out feature values. add_calib_steps runs it traced at RTL and fits each span from the RTL's times and pysim's pairing, filing the fit in a ModuleStore under the module's identity (a digest of its structure, free of what its ports are bound to). A repeat finds the record and runs nothing; a changed module finds none and is calibrated again. A memory is calibrated from memory_harness with MemCalibStep.
- Composing a parent - Calibrate each unit's timed phases in its harness, then compose a system from them. A parent's pysim is composed from its units: each child loads the record its own harness filed, and nothing is fitted to the parent. The check is the parent's RTL -- the polynomial on a bus +1.8%, markov (a generator, a chain, a memory, on a bus) -0.9% (Vitis 2025.1). When a composition misses, the miss locates what is not yet modeled: markov's first was -8.8%, and comparing RTL probes against pysim found an uncalibrated memory, then a lead the chain's core needed. A parent's pysim runs after its units' calibrations (add_system_steps(..., after=[...]) or dag.require). Builds are incremental: change one unit and only it, and the systems holding it, do any work.