XSI system simulation
A single free-running kernel is driven at RTL by BFMs on its ports (XSI Build Rung,
BFM testbenches). A system is more: several csynth’d kernels, each reached through a
memory-mapped adaptor, AMD’s crossbar between them, perhaps an on-chip
memory, and a host program that drives it all over the bus. The pysim system object already holds
every fact about that system — its StreamIFs, crossbar bindings, adaptor views and IrqIF lines —
so the RTL simulation is derived from it rather than written:
| piece | comes from | framework call |
|---|---|---|
| the Verilog top | a walk of the pysim graph, cut at a set of modules | SystemTopSpec.from_system, .render_verilog() |
| the crossbar IP | the pysim crossbar’s ranges | generate_axi_xbar(spec.xbar, ...) |
| the host’s C++ | its threads, in a header beside the example (Software threads) | (hand-written, once) |
| the host’s endpoints | the wired host: each endpoint’s view, address and interrupt | render_host_endpoints_h |
the harness and main |
the host’s ports, bound to the top’s ports | system_tb_spec, render_system_tb |
| all of the above, built and run | the system object | add_system_steps(dag, sysm, ...) (a build DAG), or run_system_xsi(sysm, ...) |
The two worked cases are mm_fir (one kernel, a register bank and three queues, two adaptor shapes) and markov (two kernels joined by a routed credit stream, four bus masters, a shared BRAM).
The system: HwSystem
Every system flow takes a system object, an
HwSystem (waveflow.hw.hw_system): a Simulation holding every
module and interface, and the one root module that is synthesized, the DUT. Build the modules on
one simulation, wire them, and name the DUT:
from waveflow.hw.hw_system import DutTop, HwSystem
def markov_system(jobs, link="mm", ...) -> HwSystem:
sim = Simulation()
... # kernels, memory, host; devices; crossbar; links
dut = DutTop.of("markov_dut", sim, comps=[gen_dev, chain_dev, mem], ifs=[xbar, u_link])
sysm = HwSystem(sim, dut, run_until=host.done, check=lambda s: host.results,
fresh=lambda: markov_system(jobs, link, ...))
sysm.gen, sysm.chain, sysm.xbar, sysm.u_link = gen, chain, xbar, u_link # for tests and probes
return sysm
The constructor checks the rules, each a refusal naming what to fix: the DUT is a SimObj of this
simulation and a root (a sub-module’s own harness takes a fresh copy of it), every testbench
participant can be lowered to the RTL testbench (a bfm_model(), an xsi_model() or a C++ twin), and no
DUT boundary port is bound to nothing. The rest of the arguments describe the run:
| argument | what it is | markov’s |
|---|---|---|
run_until |
the event that ends a pysim run that never runs out of events | the host’s done |
check |
(system) -> Any, what run() returns |
the host’s results |
fresh |
() -> HwSystem, an unrun copy, for a second pysim pass (a calibration’s) |
the same call again |
inputs, n_cycles |
a system with no software host: what the testbench plays, and the RTL run’s bound | (the host writes its scenario) |
calibration |
() -> CalibWorkload, the workload that calibrates the design’s timed phases |
|
sources |
data files (or directories) the scenario, the check or the golden read, absolute or relative to the builder’s file, so the build’s freshness follows them |
What the flows then use:
| member | what it is | markov’s |
|---|---|---|
sim |
the Simulation holding every module and interface of the graph |
the kernels, memory, host, crossbar and links |
dut() |
the default DUT: the root of the tree of what is synthesized | markov_dut: gen_dev, chain_dev, mem, with xbar and u_link as its links |
participants() |
the testbench, derived: every root outside the DUT | [host] |
run() |
write the scenario, simulate the whole graph in pysim to run_until, return check’s value |
the host’s results |
cut() |
the DUT as a list, each device’s kernel then each memory: what inside= takes |
[gen, chain, mem] |
elements() |
every module and interface of the graph |
A flow given an object that is not a HwSystem refuses it by naming this contract. A system written
before this form subclasses HwSystem and implements dut() and run() itself; the flows take both.
harness(module) builds the same object around one module, with generated
stand-ins as its testbench.
The DUT is a tree. build_mm_device returns each kernel’s device, a composite module
(MmSlaveDevice) holding the kernel, its views and its adaptor. Binding a routed credit stream adds
each of its bus writers to the device of the kernel it acts for. DutTop holds the devices and the
on-chip memories, and the interfaces between them.
DUT and testbench are roles, not kinds. Everything outside the DUT tree is the testbench: here
only the host. dut() is the cut a build takes when it is given none. A build may draw another one
with inside=, and the same module is then DUT in one build and testbench in another. Nothing about
the module changes. The design cut is the same rule for a single
kernel. The tree is also the unit structure everything after simulation uses: each device is one
sub-top of the Verilog, one unit to synthesize, and one IP to package.
Building the markov system walks one system from its modules to its DUT tree.
A system around one graph: GraphSystem
The older form for a system with a single kernel: a composite holding the kernel and the testbench
participants around it, cut by a subclass. GraphSystem is the HwSystem for that case. A subclass
states only what is its own, and the base derives the rest:
| a subclass states | the base derives |
|---|---|
graph(): build and return the graph |
sim, from the graph |
dut_modules(g): the modules inside the default cut |
dut(), a DutTop of them; clk, the DUT’s clock; data_width, its widest boundary port |
write_inputs(root): the scenario’s inputs |
write_scenario: the inputs, then vectors/run.json (the graph’s n_cycles), then every participant that reads or records a bundle anchored at root |
check() (optional): the golden on a pysim run |
run(): pysim, to the graph’s run_until when it has one, then check() |
A recording that pysim cannot match by construction is marked on its participant in graph()
(recording_check = "example"), and the example checks it instead of compare.
examples/state_toy, the RF components’ worked material (the examples/rf_* directories outside
the curated set) and the FFT wrappers still take this form. The curated examples that used it –
mem_copy, the interleaver,
fir_block, bram_access,
the RF loopback, the shot transmitter
and receiver – now build their modules directly and name the
kernel as the DUT, HwSystem(sim, dut). The composite’s wiring became a function of the simulation
(wire_<example>(sim, ...)), which the composite and the system share.
The system top: SystemTopSpec
What it is
A SystemTopSpec is the RTL top of a system, as data. It is a frozen dataclass in
waveflow/build/system_top.py, derived from the pysim system
by walking its graph. It is the middle of three layers, each derived from the one before:
| layer | what it is | markov’s |
|---|---|---|
| the pysim system | the Python object you write and simulate: kernels, interfaces, crossbar, host | markov_system(jobs) |
| the spec | the RTL top as data: every instance, slot, net and port, cut at a set of modules | SystemTopSpec, top markov_top |
| the Verilog | text rendered from the spec | markov_top.v |
Everything about the top is decided when the spec is built, and the spec can be queried before anything is rendered or synthesized. The Verilog is then a pure function of it.
Constructing it
From the system object, not yet run:
from waveflow.build.system_top import SystemTopSpec
sysm = markov_system(jobs, link="mm")
spec = SystemTopSpec.from_system(sysm, top="markov_top")
from_system takes the system’s default cut, HwSystem.cut(): the kernels and
memories of its DUT tree, the same cut add_system_steps takes. It finds the bus and
the host by their roles: the bus is the DUT tree’s link that realizes as bus IP (the crossbar’s
rtl_config), and the host is the bus master on it whose owner is outside the DUT. The underlying walk is the function system_top_spec(xbar, inside, ...),
which takes the crossbar directly. from_system calls it, and code that already holds the crossbar
can call it too.
Parameters
| parameter | default | meaning |
|---|---|---|
sysm |
(required) | the system object, not yet run. It must hold one crossbar and one software host |
inside |
sysm.cut() |
the modules synthesized into the top: kernels (FreeRunMods with a csynth’d module) and on-chip memories (MemoryMod). See the cut |
top |
the DUT’s name (markov_dut); for a subclass, its name in snake case |
the Verilog module name of the system top; the sub-tops are named <top>_<device> |
xbar_name |
xbar_<top> |
the crossbar IP’s module name |
id_width |
enough bits to route every crossbar master | the crossbar’s AXI ID width |
The cut is a set
inside names what is synthesized into the top. Everything that belongs to those modules comes
along: each kernel’s device (the views and adaptor build_mm_device built), and the two bus writers
of a routed credit stream between two inside kernels. Everything else on the graph is a BFM beside
the top, and an endpoint bound to nothing inside the set becomes a top port: the host’s bus master
becomes an AXI4 slave group s<k>_axi, and an interrupt line whose sink is outside becomes an output
irq_<view>.
What the walk emits, element by element:
| graph element | emitted |
|---|---|
| a csynth’d kernel | an instance of its module; pins from the same TopSpec its csynth top was built from |
| a crossbar master inside the cut | an SI slot on internal wires |
| a crossbar master outside the cut | a top AXI4 slave port group |
| a crossbar slave | an MI slot: one view, an adaptor’s views, or an on-chip memory as a BRAM window |
a StreamIF between two of them |
stream nets, named after the channel, the bus width or the link’s if it is wider (stream widths); a deep link between two kernels gets an mm_sync_fifo (a view’s link is the view’s FIFO) |
| a routed credit stream | its two writers (mm_writer_gen), each target from the address map |
an IrqIF leaving the cut |
a top output |
The tie-off rules live once, in system_top.py: a kernel’s
m_axi pointers are offset=off, so a bus address is the address (a kernel that still has an
s_axi_control slave has its inputs tied low –
why offset=off); an m_axi pin
the crossbar lacks tied low or left open; a Vitis master’s one-bit IDs against the crossbar’s wider ones;
a stream input nothing drives (TLAST low, TKEEP/TSTRB all ones); padded crossbar slots answering
nothing.
Stream widths
A stream net is the bus width, or its link’s width if that is wider (system_top.net_width: the
pysim StreamIF.bitwidth, rounded up to bytes as Vitis rounds TDATA). A link at or below the bus width
keeps a bus-width net, on which a narrower kernel port takes the low bits and its other bits are driven
- A wider link – a 512-bit sample stream on a 128-bit system – gets a net of its own width: its wires,
its FIFO (
W= the width + 1, TLAST beside the data), its TKEEP / TSTRB ties and, when it leaves the cut, the top’s port and the testbench model, which takes its width from the participant (anAxisMasterof 8 chunks a beat beside 2 on the 128-bit ports).
A kernel’s stream ports are the bus width in its csynth top unless its class sets
endpoint_port_widths (each port its endpoint’s width). So the walk refuses, by the link’s name, what
would not meet at RTL: a kernel port on a wide link that is not the link’s width, a port wider than its
net, and a view on a wide link (a view’s leaf is the bus width). Gated without tools by
tests/build/test_system_top_width.py, and at RTL by examples/bram_ring/wide_ring.py (xsim 2025.1,
tests/examples/test_wide_ring_xsi.py).
Generating the Verilog
verilog = spec.render_verilog() # one string: the whole <top>.v
verilog = spec.render_verilog(probes=timing_probes(sysm)) # with timing-probe outputs
The text is one file holding a module per device and memory (the sub-tops), then the system
top that instantiates them beside the crossbar. probes maps a name to a probe on a pysim endpoint
(beat(sysm.gen.s_cmd), last(...), stall(...)). Each becomes an output probe_<name> of the
top, computed in the module that holds its net. render_verilog is the method form of the function
render_system_top(spec, probes). On a build DAG the system_top step writes this text to
<work>/<top>.v (system_rtl).
One device (or the memory) can also be rendered alone:
verilog = spec.render_sub_verilog("gen") # markov_top_gen, as a file of its own
leaves, kernels = spec.sources_of("gen") # its compile list: leaf sources, csynth'd modules
The module is exactly the one the whole file holds for it. Its ports are AXI4 groups, interrupt lines
and probes, so it needs nothing around it. elaborate_sub_top(spec, "gen", root=..., work_dir=...)
(waveflow/build/system_xsi.py) compiles and elaborates it with only its own sources, and an XSI gate
runs that for every markov and mm_fir sub-top. A per-device synthesis or an IP is built from this
unit.
Reading it
| field / method | answers |
|---|---|
kernels |
each csynth’d module in the top (KernelRtl): its module name, instance, ports, and the pysim module it realizes |
modules |
the csynth’d modules, each once: whose RTL a workspace compiles |
si, host_axi |
each crossbar master slot. A master outside the cut (the host) is a top port s<k>_axi; one inside is a wire si<k>_axi |
mi |
each crossbar slave slot (MiSlot): a view, an adaptor’s views, the memory, or a padded stub |
nets |
each stream link (StreamNet): its FIFO depth, the side-channel facts its tie-offs follow, and which sub-top drives and reads it |
irqs |
the interrupt lines leaving the cut, as top outputs irq_<view> |
subs |
the devices and the memory, each a sub-top (SubTop) |
instances() |
the inventory: every RTL instance (RtlInstance) with its module, parameters, sources, identity, owning pysim object, sub-top and path |
leaf_sources() |
the hand-written leaves the top uses, each once: its compile list |
probe_expr(p), probe_home(p) |
a timing probe named by a pysim endpoint, resolved to a Verilog expression and to the module it is computed in |
spec.modules # ('markov_gen', 'markov_chain', 'mm_queue_writer_64_128', 'mm_credit_writer_64')
[s.inst for s in spec.subs] # ['u_gen_sub', 'u_chain_sub', 'u_mem_sub']
len(spec.instances()) # 15
Every consumer reads the same spec. None of them re-walks the graph or parses the Verilog:
| consumer | reads the spec for |
|---|---|
render_verilog / render_system_top |
the Verilog itself |
system_tb_spec, render_system_tb |
the XSI harness: which host model binds to which top port |
system_synth (System resources) |
joining Vivado’s per-instance report to the inventory, by path |
estimate_system |
pricing each instance from the record store |
measure_instances (rtl_ooc) |
the leaves to synthesize out of context |
So the inventory and the rendered top cannot disagree (a test checks that every inventory instance is
rendered exactly once, in the module its sub names). On a build DAG, the system_rtl step holds the
spec as .spec, and the later steps read it from there. A single composite kernel has the same
arrangement one level down: composite_top_spec returns its TopSpec.
Devices: the top’s sub-tops
The top is not flat. Every instance is in one of three places, and each device and each memory
is rendered as its own Verilog module (a sub-top) that the system top instantiates. The places are the
system’s own DUT tree (HwSystem.dut()): build_mm_device returns each device as a composite holding its
kernel, views and adaptor, so the walk reads a kernel’s device off the tree rather than inferring it.
| place | holds | in markov |
|---|---|---|
| a device, one per kernel inside the cut | the kernel, its views or adaptor (front and leaves), the bus writers that act for it, and any FIFO between them | u_gen_sub: MarkovGen, its adaptor’s front and two views, the forward writer and its FIFO. u_chain_sub: MarkovChain, its front and two views, the credit writer |
| the memory | its front, BRAM window and RAM | u_mem_sub |
| the system top | the crossbar, padded MI slots, and any stream link whose ends are in two different devices | u_xbar |
Where a bus writer goes. A writer acts for the kernel whose stream feeds it. A routed credit
stream’s forward writer carries the sender’s data, so it sits in the sender’s device. Its credit
writer returns the receiver’s credit, so it sits in the receiver’s device. Neither sits with the
crossbar. MmCreditStreamIF makes that placement itself, when it is bound: it adds each writer, and the
stream feeding it, to the device of the kernel it acts for. Move a writer to another device and the
sub-tops follow the tree.
What crosses a sub-top’s boundary is clock, reset, its AXI4 slots (its MI slot as a slave and each of
its masters’ SI slots), its interrupt lines and its timing probes. In a memory-mapped system nothing
else crosses: every link between devices goes over the bus. A sub-top’s ports are named for the nets
they carry, so every instance name, net name and tie-off is what a flat top would have had, and each
instance’s hierarchical name is spec.instances()[i].path (u_gen_sub/u_u_fwd_wr). A probe on a net
inside a device is computed there and passed up as a port; a probe on a bus master’s SI is computed in
the top.
The same modules serve every consumer of the top: XSI simulates them, system_synth
synthesizes them globally (its per-instance report reads one level deeper, under each sub-top), and a
per-device synthesis or IP packaging reads one sub-top at a time
(plans/ip_packaging_routes.md).
The host is a hooked module
A kernel has two realizations joined by a hook — its Python model, and the HLS body kernel_task()
names. A host is the same: a SwHost whose threads run as SimPy processes in pysim, and a C++ class of
the same threads – in a header beside the example – that cpp_model / cpp_header name. The C++
is the program only: it derives from a generated <Host>_endpoints that declares every endpoint
on its view, with its interrupt, and runs on the software-thread runtime, where each thread is a fiber
and every bus call blocks. Software threads is the full API, side by side with Python;
A host is a hooked module is the hook.
The harness runs until the host’s done() – every thread finished – says it has everything it asked
for (Harness::run_until). That completion is the measured cycle count; the host reports it, with
every bus operation it issued.
Running it: the system on a build DAG
A system’s whole flow – from its generated sources to the trace gate – is one
BuildDag, and everything after the example’s own code generation is framework:
codegen ──> csynth ──> system_rtl ──┐
├──> system_xsi ──┐
scenario ──┬────────────────────────┘ ├──> compare
└──> pysim ────────────────────────────────┘
from waveflow.build.build import BuildDag
from waveflow.build.system_dag import add_system_steps
dag = BuildDag()
dag.add(MarkovCodegenStep(name="codegen")) # the example's: headers, kernel tops, writer tops, .tcl
add_system_steps(dag, markov_system(jobs, link="mm"), work_dir="xsi_work", top="markov_top")
add_system_steps takes the system object – not yet run –
finds the crossbar and the SwHost among the simulation’s objects, takes the default cut (each kernel
whose device is a crossbar slave, then each memory on it; inside= overrides), and adds the six
framework steps below. top defaults to the DUT’s name (a subclass: its name in snake case,
MarkovSystem -> markov_system) and xbar_name to xbar_<top>. An example’s script hands the DAG to
run_dag_cli, so it gets --through <step>, --status, --force and --force-step for free.
csynth
One inner step per HLS top the cut instantiates (spec.modules): the kernels and the bus writers a
routed credit stream brings. The top is the rebuild unit, since Vitis has no incremental csynth and
each top is its own project. A top is fresh while its source stamp matches. The stamp records the
content of the sources csynth read, written beside the project
(rtl_digest). So a codegen that rewrites include/ and
gen/ with identical bytes re-runs no csynth, and neither does a git checkout that restores
identical files. A project with no stamp falls back to comparing mtimes, never to “clean”. Today the
stamp covers all of include/ and src/, so an edit there re-runs every top; an edit to one top’s
gen/<top>.cpp re-runs that top only.
Build or check – the synth parameter decides who may run the toolchain:
synth="build"(the CLI default): a stale or missing top is synthesized, then stamped;synth="check"(the gate tests,run_system_xsi): a stale or missing top fails the step, naming the top and the source that changed. A gate never hides a 40-second csynth, and never runs against RTL built from other sources.
One exception, opt-in: with WAVEFLOW_RESYNTH=1 in the environment, synth="check" builds a stale
top instead of failing. It exists for one run – after a framework header that every example copies into
include/ changes (streamutils_hls.h, the array utils), which makes every stamp stale at once:
WAVEFLOW_RESYNTH=1 pytest -m xsi re-synthesizes and gates in one pass.
The other steps: fresh while nothing they read changed
The system’s own steps (scenario, pysim, system_rtl, system_xsi, compare, and a calibration) are
fresh while one digest of what they read is the one they last succeeded with
(freshness). The digest covers:
- the DUT’s structure and the testbench participants’ knobs (bundles, policies);
- the design’s Python: the source of every class in the system, of the functions it was given
(
inputs,check,fresh, …) and of the module that built it, with every module of the design they import – so a change to a testbench setting, the check or a helper is seen even when the scenario’s bytes do not move; and the framework itself; - the testbench’s C++ twins beside the design (
BfmModel.header), and the data files the system declares (HwSystem(sources=...)); - the scenario;
- for the steps that read RTL, the source stamps of the system’s tops;
- for pysim, the calibration records its modules load, each module’s own, found by its identity.
So in a build of several systems – a design and each of its units in its own harness – a unit nobody
changed does no work. Change one unit’s build parameter and only that unit’s csynth, harness and
calibration re-run, with every system that holds it: markov’s generator at a new draw interval
re-synthesizes one of five tops and re-runs the generator’s harness and the full system, while the
chain core’s and the memory’s harnesses skip (tests/examples/test_incremental_units.py). A parent’s
pysim runs after its units’ calibrations (add_system_steps(..., after=...), or dag.require), so its
estimate is composed from the records they just filed. codegen still regenerates every time: it is
Python only, and csynth decides by content.
system_rtl
The rest of the system’s Verilog, after csynth, as an inner DAG:
xbar_ip– the crossbar IP, generated by Vivado’screate_ipfrom the pysim crossbar’s ranges, and cached by its configuration under<work_dir>/ip/;system_top– the Verilog top (render_system_top), with the timing probes if any, written to<work>/<top>.v: one file holding each device’s sub-top module, then the system top.
It also writes <work>/rtl.json, the manifest of every Verilog file the top compiles – the IP’s
simulation files, the framework’s adaptor and memory leaves (waveflow/build/rtl/), each csynth’d
module’s files, the top – and the IP’s include directories. That is all system_xsi reads of it.
csynth and system_rtl together are everything that makes Verilog: --through system_rtl builds all
of a system’s RTL without simulating it.
scenario
The host writes its scenario bundle (SwHost.write_scenario) to <work>/scenario/. It is its own step
because pysim and the RTL run must read the same file (the conformance gate below).
pysim
The same system object, run in pysim from that scenario. Every host endpoint’s trace goes to
<work>/pysim_traces/ and the run’s length in host clock cycles to <work>/pysim.json. Needs no
toolchain: --through pysim is the whole software side, with no Vivado.
golden
GoldenStep: pysim’s recordings against the system’s golden -> <work>/golden.json (the mismatches; empty: pass),
burst for burst and word for word, so the framing is checked with the values. Added after pysim only
when the system states a golden (HwSystem.golden_outputs,
{recording: [burst words]}, given as HwSystem(..., golden=...)). A
harness states one when its module has golden(kind): what each
output port records for workload(kind), as PolyKernel.golden does in
examples/stream_kernel/stream_kernel.py. A
hostile stand-in policy changes when words move, not which, so the harness under each policy has the
step too. A mismatch fails the step and names the recording, the burst and the first differing word
(golden_mismatches); --through golden checks pysim
against the golden with no Vivado. The step always runs: the golden is Python the system digest does
not cover.
system_xsi
The system at RTL under a testbench, itself an inner DAG:
harness: each testbench participant’s C++ twin (and a host’s generated endpoints) bound to the top’s ports (system_tb_spec,render_system_tb);xsi_run:xvlog/xelabbuild the RTL thatrtl.jsonlists,g++builds the testbench, and the run executes. With a host, its report is parsed into<work>/report.jsonand its traces land in<work>/traces/. Without one, the run starts from a fresh copy of the scenario (<work>/xsi_run/), and what the participants recorded is gathered into<work>/traces/.
Tracing (add_system_steps(..., trace=True)). The run also elaborates a second top whose
$dumpvars dumps each kernel’s scope at level 1 inside the system top: the kernel’s ports, and for a
wrapped kernel the wrapper’s wires to its memories. It writes <work>/<top>_trace.vcd, and
<work>/hazards.json, each wrapped kernel’s hazard manifest with the scope its nets live under.
waveflow.utils.bram_trace resolves names under that scope, so a waveform check reads a system run
as it read a kernel run. SystemTopSpec.scope_of(kernel) gives a kernel’s scope for any other
reader.
compare
What the testbench recorded, RTL against pysim -> <work>/compare.json (the mismatches; empty:
pass). With a host, every endpoint’s trace is compared file for file. Without one, every recording
is compared on its words: each sink’s out_bundle, each memory’s dump_segs. A participant whose
recording pysim cannot match by construction says so (recording_check = "example"), and the
example checks it instead. A mismatch fails the step and names the recording, the participant that
records it, and the first word that differs.
Freshness: a hook each step answers late
BuildDag’s own rule is mtimes plus a cascade: a step runs when its outputs are older than its inputs
or when anything upstream ran. Both are wrong for csynth, whose inputs codegen rewrites every run,
usually with the same bytes. So a step may answer for itself:
class BuildStep:
def is_fresh(self, config, paths) -> bool | None: # None (default): the mtime rule
The DAG asks it just before the step would run – after its upstream ran – and skips the step when
it says True, even if the cascade marked it. Downstream steps then see it as not having run, so the
cascade stops there. False runs it. --force / --force-step still win, and --status asks the hook
too. In a system DAG only csynth answers by content. codegen, system_rtl, scenario, pysim,
system_xsi and compare always answer False: each reads Python and C++ the DAG cannot see, and each takes seconds.
Reading a run back, and run_system_xsi
system_xsi.load_run(<work>) reads report.json, pysim.json and compare.json back into an
XsiRun: the output, done, cycles, polls, nops, the bus ops, the workspace, scenario and trace
paths, pysim_cycles and trace_mismatches.
from waveflow.build.system_xsi import run_system_xsi
run = run_system_xsi(markov_system(jobs, link="mm"), work_dir, top="markov_top")
run.cycles, run.trace_mismatches # 1951, []
run_system_xsi is the same DAG as a one-call wrapper:
csynth in check mode, through compare (compare_pysim=False: through
system_xsi only), read back with load_run. probes= adds timing probes. A second
system in the same DAG is add_system_steps(..., prefix="<name>_"): its steps and artifacts are
prefixed, and a top an earlier system’s csynth builds is shared, as mm_fir’s two topologies share one
codegen and one csynth.
One scenario, and the conformance gate
Nothing static can show that a C++ host behaves like its Python twin. So the two are held together the way kernels are — by a gate on data:
- One scenario. What the host sends comes from a file both realizations read (a burst bundle the
Python host writes,
write_scenario). A scenario baked into the C++ would be a second copy, and there would be nothing to compare. - Every host endpoint records what crossed it, on both sides: each packet a queue writer sent, each
config committed, the words each read took, each status read, each region read back from memory
(
BusReader/MmBusReader). One burst bundle per endpoint. - The gate: for the same scenario, each endpoint’s trace is byte-identical between the pysim run and the RTL run. Per endpoint, not globally — the interleaving across endpoints is timing, and pysim is loosely timed. The RTL cycle count is an exact gate of its own.
Because the data comes back as traces, the checks are Python: decode the response and status traces
with their schemas and compare against the scenario. Where the C++ must act on a field (which job a
response answers), it reads the generated struct by name – qresp.get<MkvResp>().tx_id.
Timing probes
Once a system runs, render_system_top(spec, probes) adds one-bit probe outputs a testbench samples
every cycle. A probe names the pysim object it watches — beat(sysm.gen.s_cmd),
stall(sysm.fir.m_out), last(ep), beat(writer.m_mem, "AW") — and the spec resolves it to the
top’s net or crossbar slot (spec.probe_expr), so no one has to know what the walk named a net.
system_tb_spec(..., probes=names) adds a ProbePin per probe to the harness.
What it does not do yet
- An off-chip memory — a
FlatMemoryBFM beside the top, as mem_copy’s — and a BRAM window shared with a kernel are refused with a named error rather than wired. system_tb_specbinds host ports that are crossbar masters or interrupt sinks; a host that also streams straight into a kernel is not resolved.- The writer tops’ code generation is still each example’s
codegen(onewrite_writer_projectcall per writer), though the csynth set is derived from the cut; a writer the example forgot fails csynth with its missing.tcl. - The source stamp is coarse: it hashes all of
include/andsrc/, so a body edit re-synthesizes every top, not only the one that includes it. - AXI4-Lite /
HostActivatedDUTs remain out of reach at RTL (BFM_DUALS["axilite_slave"]).
Source of truth: waveflow/build/system_dag.py,
waveflow/build/system_top.py,
waveflow/build/xsi/xsi_mm_host.h,
waveflow/hw/mm_host.py (the Python traces);
tests/build/test_system_dag.py, tests/build/test_system_top.py, tests/build/test_xsi_system_top.py, and the gates
tests/examples/test_mm_fir_xsi.py, tests/examples/test_markov_xsi.py.