Build System

Waveflow’s build system models the full path from a Python design to its Vitis HLS outputs as a directed acyclic graph of typed steps. Each step declares the named artifacts it consumes and produces — files on disk or in-memory Python objects — and the DAG wires dependencies automatically, runs steps in topological order, propagates failures, and skips steps whose outputs are already fresh. The result is a single Python pipeline that can carry a design from schema declaration through code generation, Python simulation, Vitis C-sim, C-synth, and report inspection, with incremental rebuilds and one source of truth for what gets built and why.

One flow, with a fork at the RTL rung

There is one build flow and one fidelity ladder. The front half is shared:

schema/codegen -> pysim golden -> csim -> csynth

The flow forks only at the final RTL-exercising rung, based on top execution model:

top kind RTL rung
single-kernel top (ap_ctrl_hs, register-map launched) Vitis cosim
composite free-running task-network top (ap_ctrl_none) XSI + BFM
a memory-mapped system: kernels, adaptors, crossbar, host XSI system simulation

That fork is two realizations of one flow, not two separate flows. A system then goes toward a board as IP, one per device, wired in a block design (IP packaging): a realization, not a verification rung.

Why it’s useful

  • One DAG, one command. dag.run(config) executes every step in the right order. No shell scripts, no make.
  • Mixed file / in-memory artifacts. A PySimStep can produce a Python object; a downstream ExtractPyTimingStep consumes it directly without serialising to disk.
  • Auto-wired dependencies. Steps declare consumes = [...] and produces = {...}; the DAG figures out who depends on whom. No manual dep_step.add_dependent(self) calls.
  • Incremental rebuilds. File freshness is checked by mtime; only stale steps re-run. force=True or force=["step_name"] overrides when needed.
  • Subgraph execution. dag.run(config, through="csim") runs everything required by csim and stops.
  • Introspectable. dag.info() / dag.describe() / dag.results_status() give machine- and human-readable views of the graph and freshness state.
  • Progress callbacks. on_step_begin / on_step_end hooks let CLIs print status without each step having to know about logging.

Topics

  • Core Components — BuildConfig, BuildArtifact, BuildStep, SourceStep, Buildable, BuildDag, plus the incremental-rebuild model.
  • Code Generation Steps — built-in steps that ship with Waveflow for generating C++ headers from Python schemas.
  • Python Simulation Pattern — recipe for writing a step that runs a SimPy simulation and produces in-memory or file artifacts.
  • Vitis Pattern — recipe for invoking Vitis HLS C-sim / C-synth and parsing the resulting reports.
  • Authoring run.tcl — the Vitis script shared by both single-kernel and composite flows.
  • XSI Build Rung — what XSI/xvlog/xelab/BFM mean and how the composite RTL rung runs end-to-end; also SvSimStep, for a hand-written SystemVerilog testbench with no HLS in it.
  • XSI System Simulation — a whole memory-mapped system at RTL, from the pysim system object: the generated top, the host as a hooked module, and the trace conformance gate.
  • IP Packaging and Block Design — a system packaged as Vivado IP, one per device, then wired in a validated block design from the same spec as the XSI system top: the two steps, the interfaces each IP declares, the address map, and the gates.
  • Software Threads — the host as threads, with one API in Python (SimPy) and C++ (fibers): the primitives side by side, writing a host’s C++ twin, and the gate that checks they agree.
  • BFM Testbenches — the framework’s AXI-MM / AXI-Stream models and their five-phase lifecycle, assembled from the testbench graph or by hand.
  • Sweeping a design — running the DAG at every point of a parameter grid to build a calibration corpus: ParamGrid, Stage, SweepRunner and sweep_cli.
  • Timing Events — where a build’s wall clock goes: every step, nested step, toolchain run, XSI phase and MCP call as a timing span; --timing, analyze_events, and what each fidelity costs.

Steps documented outside this section:

  • System resources — the steps add_system_steps adds after the RTL: kernel_resources, system_synth (SystemSynthStep, one Vivado synthesis of the system top), leaf_resources (LeafResourcesStep) and resource_report (ResourceReportStep).
  • A module realized as Verilog — GenRtlStep and GenWrapperStep, for a kernel beside hand-written RTL.
  • Code Generation Steps — the steps that copy the framework’s hand-written task bodies (MemStreamStep, the RF buffer steps, MemLockStep).

Quick example

A complete poly accelerator build, from schema to synthesis report, declared as one DAG:

from waveflow.build.build import BuildConfig, BuildDag, SourceStep

dag = BuildDag()
dag.add(SourceStep(artifact="poly_source", path="poly.py"))
dag.add(SourceStep(artifact="scenarios_source", path="scenarios.py"))

dag.add(ScenariosStep(name="scenarios"))                         # data/w<W>/<scenario>/{in,expected}
dag.add(ModelStep(name="py_model"))                              # the pure model, every scenario
dag.add(CheckStep(name="check_model", stage="model", ...))       # vs the expected responses
dag.add(PySimStep(name="py_sim"))                                # pysim: the timing model
dag.add(CheckStep(name="check_pysim", stage="pysim", ...))
dag.add(ExtractPyTimingStep(name="extract_py_timing_w32", word_bw=32))   # results/py_timing_w32.json
dag.add(HlsGenIncludeStep(name="gen_include"))                   # include/*.h
dag.add(SourcesStep(name="sources"))                             # hand-written C++ in place
dag.add(HlsCodegenStep(name="gen_kernel", comp_class=PolyAccel, ...))  # the kernel boundary
dag.add(CSimStep(name="csim"))                                   # Vitis C-sim, hand-written TB
dag.add(CheckStep(name="check_csim", stage="csim", ...))
dag.add(CSynthStep(name="csynth_w32", word_bw=32))               # Vitis C-synth + cosim
dag.add(InspectSynthStep(name="inspect_synth_w32", word_bw=32))  # parses csynth.xml
dag.add(CheckStep(name="check_cosim", stage="cosim", ...))
dag.add(ExtractCosimTimingStep(name="extract_cosim_timing_w32", top="poly", ...))
dag.add(ValidateTimingStep(name="validate_timing_w32", tolerance_cycles=20, ...))
# ... and the same five steps again for the 64-bit top, poly_bw64
dag.add(SummaryStep(name="summary"))                             # every check, one file

config = BuildConfig(root_dir=".", params={"clk_freq": 100e6})
dag.run(config, through="check_pysim")               # stop before Vitis
# or:
dag.run(config, through="summary")                    # the full build, every check

See examples/stream_inband/poly_build.py for the full working pipeline this snippet is drawn from.


Table of contents

  • Core Components - The reference for everything the build framework exports: BuildConfig, the file and object artifacts, BuildResult, BuildStep and Buildable, and the BuildDag that wires them. Read top to bottom for the conceptual order, ending with the incremental-rebuild model that decides which steps are skipped.
  • Code Generation Steps - The four built-in steps that turn Python schema definitions into the C++ a Vitis kernel compiles against: the stream helpers, the memory-manager headers, a header pair per DataSchema, and packed-array helpers per element type (a scalar or a `DataList` record). The dependency wiring among them is automatic, but the stream helpers must be added first.
  • Python Simulation Pattern - A recipe rather than a step: how to write the Python half of a build -- writing each scenario's stimulus and expected response, running a pure model and pysim on them, checking each stage against the expected responses, and extracting pysim's cycle estimate -- taken from the streaming polynomial example's poly_build.py. Waveflow ships no generic version because every design has its own scenarios, model and result format; the CLI is shared (run_dag_cli).
  • Vitis Pattern - The Vitis half of a build -- generate the headers and the kernel boundary, C-simulate every scenario with a hand-written testbench, check it against the expected responses, synthesize and co-simulate, inspect the synthesis report, and compare pysim's cycle estimate with cosim -- taken from the streaming polynomial example. The csim and csynth steps are a pattern to copy; the toolchain call, the csynth.xml parser and the cosim timing steps are framework pieces.
  • Authoring run.tcl - What is inside the run.tcl the Vitis steps invoke, which the pattern page treats as a black box. The core sequence from open_project to csim_design, csynth_design and the optional cosim_design, shared by single-kernel and composite projects alike.
  • XSI Build Rung - The RTL rung for when Vitis cosim is not the right path — notably free-running ap_ctrl_none task networks, which cosim refuses to run. Defines the terms first (xsim, xvlog, xelab, XSI, BFM, the .f manifest), then walks the flow from csynth through a simulator DLL driven cycle by cycle from C++ and compared against a golden.
  • XSI System Simulation - Simulating a whole memory-mapped system at RTL -- several csynth'd kernels behind their adaptors, AMD's crossbar, an on-chip memory, and a host -- from the pysim system object, with nothing restated. A system is HwSystem(sim, dut): the simulation holding every module, and the DUT, a DutTop tree of devices (each kernel with its views and the bus writers acting for it) and memories, which is the default cut. SystemTopSpec is the RTL top as data, walked from it; each device is a sub-top that renders and elaborates alone. add_system_steps(dag, sysm) puts csynth (one step per HLS top, fresh while its source stamp matches; build or check), the crossbar IP and the Verilog top (system_rtl), the scenario, pysim, the RTL run and the trace comparison on a BuildDag, and run_system_xsi(sysm) is the same as one call. It walks the graph to the Verilog top (crossbar slots, adaptors, stream nets, credit-link writers, interrupt outputs, tie-offs), generates the harness around the host's C++ twin (its threads on generated endpoints), runs it, and checks the host against pysim: both run one scenario file, every host endpoint records what crossed it, and the traces must be byte-identical; the cycle count is an exact gate of its own. Worked on mm_fir (618 / 611) and markov (1870).
  • Software threads - The host side of a system as software threads, with one API in Python and C++. A SwHost owns a bus master and interrupt inputs and runs SwThreads; in pysim a thread is a SimPy process (code between waits takes no time), and its C++ twin under XSI is a fiber, scheduled cooperatively so the run is deterministic. The primitive table side by side (interrupt waits, wait_any, compute, SwEvent / SwSemaphore / SwLock / SwQueue, the bus calls), how a C++ host is written (thread bodies on a generated _endpoints base -- no BFM, no addresses, no state machine), typed messages, settings as DynParams, the scheduler's ordering rules, and the trace gate that checks the two realizations agree.
  • IP Packaging and Block Design - A system packaged as Vivado IP, one per device: each device sub-top and the on-chip memory through ipx::package_project, from exactly the files the XSI gates compile, with their AXI interfaces inferred, their interrupt lines declared and the clock associated with every AXI interface; AMD's crossbar used as its .xci. One opt-in step, ip_package, on a system's DAG; each IP cached by content; what comes back read from each IP's own component.xml. Then a block design, block_design: the IPs and the crossbar instantiated and wired from the same spec as the XSI system top, every master's address map assigned at the crossbar's own windows, validate_bd_design as the gate, and the design read back against the system top. Worked on markov: four IPs, every link between them AXI4 or an interrupt.
  • BFM Testbenches - At the XSI rung a C++ testbench drives the generated RTL cycle by cycle. The bus models are framework code and the assembly is generated, so what you write is the scenario and the golden, in Python on either side of the run — never per-cycle bus code. Lists which model serves which port.
  • Sweeping a design - Running a design at every point of a parameter grid and keeping what the steps measured. Three pieces: ParamGrid is the points, in declaration order; SweepRunner runs them, owning resume, incremental save and per-point failure isolation, through one or more Stages; sweep_cli is the entry point. An example supplies its axes, its DAG factory and its platform — the parts that are about the design.
  • Timing Events - Where a build's wall clock goes. Every build step, nested step, toolchain run (vitis-run, vivado, each XSI phase) and MCP tool call is a timing span, nested the way the work is, appended to the project's .waveflow/events.jsonl and handed back to the caller. run_dag_cli --timing prints one build's tree; waveflow.events.analyze_events breaks a project's history down by category (synth, RTL sim, pysim) and gives per-step statistics -- what one pysim costs against one RTL simulation, for a person or an agent deciding how often each can be afforded.