AXI crossbar

Most designs with more than one memory-mapped master or slave have a crossbar between them: a host and a DMA engine sharing a memory, a host reaching several kernels’ register banks, a kernel writing another kernel’s queue. Waveflow has one in each backend:

  pysim RTL (XSI)
what AXIMMCrossBarIF (modeling) AMD’s axi_crossbar IP
from the Python design generate_axi_xbar(AxiXbarConfig(...)), which runs Vivado’s create_ip
decodes each slave’s range from assign_address_ranges each master-side slot’s range from the config

The RTL crossbar is the real IP, not a stand-in. It is the same core a board’s block design instantiates, so a cycle count measured through it in XSI is the cycle count the board will see. That matters because a crossbar is a contended resource: a stand-in’s arbitration and latency would be folded into every number measured through it.

Describing one

from waveflow.build.axi_xbar import AxiXbarConfig, AxiXbarRange

xbar = AxiXbarConfig(
    name="xbar_2x2", n_si=2,                         # two masters (slave-side, SI, ports)
    mi=[AxiXbarRange(0x0000_0000, 16),              # slave 0: 64 KB at 0x0000_0000
        AxiXbarRange(0x0001_0000, 16)],             # slave 1: 64 KB at 0x0001_0000
    data_width=64, addr_width=32, id_width=1,
)
field meaning
name the IP’s module name, and the cache key’s prefix
n_si number of masters, i.e. slave-side (SI) ports
mi one AxiXbarRange(base, addr_width) per slave: a 2**addr_width-byte window at base
data_width, addr_width, id_width the bus
part the FPGA part the IP is generated for (default xczu48dr-ffvg1517-2-e, the RFSoC 4x2’s)
mode "SAMD" (default): a true crossbar, different master/slave pairs transfer at once. "SASD": a shared bus, one transaction at a time, for the least area

Or generate it from the pysim crossbar. AxiXbarConfig.from_crossbar(xbar, name) gives one slot per slave bound to a pysim AXIMMCrossBarIF, at the base and size assign_address_ranges set — so a design writes each address once, in Python, and both backends decode it. A crossbar with one slave gets the unused second slot the IP needs. mm_fir builds both its topologies’ crossbars this way.

The config refuses what the IP would get wrong:

  • A window is at least 4 KB (addr_width >= 12) and aligned to its size. An AXI burst may not cross a 4 KB boundary, so a smaller window could split one.
  • No 1 × 1 crossbar. create_ip silently generates an inconsistent two-slave IP for it, whose simulation crashes. A design with one slave gives the crossbar a second, unused slot, as mm_fir does.

IDs. The crossbar puts the issuing master’s index in the ID it forwards, so every slave must echo AWID / ARID on BID / RID. With id_width = 1 and two masters, master k is ID k. A SASD crossbar has no slave-side ID ports at all – with one transaction in flight there is nothing to route by – and render_xbar_instance leaves them out.

Addresses. The crossbar forwards the full address. A slave that wants an offset into its own window masks it (the slave adaptor’s front does).

Generating it

from waveflow.build.axi_xbar import generate_axi_xbar

ip = generate_axi_xbar(xbar, out_dir / "ip")     # one Vivado batch run, cached by config
ip.module         # the module to instantiate
ip.sim_files      # what xvlog needs
ip.include_dirs

generate_axi_xbar runs create_ip in an in-memory Vivado project — about 30 seconds — and caches the result under a digest of the config, so a second call with the same config costs nothing. It needs Vivado. It does not restate the IP’s internal parameters (base IDs, connectivity masks, issue limits): those are computed by the IP’s own configuration logic, and a second copy of that logic here would be free to drift from the one a board design runs.

Putting it in an RTL top

axi_xbar.py has the pieces an RTL top needs, so the AXI port lists are generated rather than typed:

helper gives
axi_signals(data_width, addr_width, id_width) the AXI4 signal list, with widths and directions
axi_port_decls(prefix, signals, facing=...) port declarations for a top-level AXI port
axi_wire_decls(prefix, signals) wires for an AXI connection inside the top
render_xbar_instance(cfg, inst, si_prefixes, mi_prefixes) the crossbar instance, its SI ports joined to si_prefixes and its MI ports to mi_prefixes

render_system_top uses all of them to emit a complete system top from the pysim system – for mm_fir, one AXI port for the host, the crossbar, and the slave adaptor’s views on its master-side ports (the system_xsi step of mm_fir_build.py renders it).

Driving it from a testbench. A host on an SI port is a wfbfm::AxiMmMaster (in xsi_bfm.h): it issues bursts from a queue, one transaction at a time — or one read and one write at a time with overlap_rw — and records each one’s start and end cycle. Slaves behind it are the memory BFMs, or the slave adaptor. The C++ endpoints in xsi_mm_host.h sit on top of AxiMmMaster for a host reaching an adaptor.

What it costs, measured

Through the crossbar, at 100 MHz, with the crossbar as AxiXbarConfig generates it (test_axi_xbar_xsi.py):

transfer cycles, uncontended
write, 1 beat 7
write, 8 / 16 beats 17 / 21
read, 8 / 16 beats 12 / 20

About 5 cycles plus one per beat, and two bursts to one slave serialize whole. A read and a write can be in flight at the same time: the AXI read and write channels are independent, and the crossbar routes them in parallel.

Area, closure, and the other mode. xbar_profile measures every shape from 1x2 to 4x4, in both modes and at 32 and 64 bits: out-of-context synthesis, place and route at 250 MHz (synth_axi_xbar) and the latencies above under XSI. In short: every configuration closes at 250 MHz with at least 1.45 ns to spare; a 4x4 SAMD crossbar is about 1.2k (32-bit) to 1.7k (64-bit) LUTs and no BRAM; SASD is 2.3-2.6x smaller at 4x4 but serializes everything – four masters to four slaves take 80 cycles where SAMD takes 30 – and costs almost nothing when there is only one master or one slave. The measurements are records in a platform’s module store, under the crossbar’s content key (AxiXbarConfig.identity()).

Matching pysim to it

The pysim crossbar charges a fixed latency_init per transaction plus one cycle per word. Three settings make it agree with the RTL; all three were found by lining up each backend’s bus operations one by one (mm_fir):

setting on measured value what it models
latency_init AXIMMCrossBarIF 4 a request’s latency through the crossbar
latency_travel AXIMMCrossBarIF 2 how much of that is travel to the slave. A slave that serves one transaction at a time (the adaptor’s front) overlaps the next request’s travel with the current transaction; only the remaining cycles are charged while it is held.
max_outstanding the master (MMIFMaster) 1 one read and one write in flight per master, as AxiMmMaster with overlap_rw

The first two describe the crossbar. The third describes the master — and so does a fourth, issue_cycles, the host’s pacing between transactions (2 for the C++ testbench host). With all of them set, mm_fir’s pysim lands within 4.4% of RTL in both shapes. Every default reproduces the model from before these existed, so a design that sets none of them is unchanged.

At 250 MHz on xczu48dr

Measured with HLS masters rather than the testbench host (plans/bram_fullrate_port.md, Stage 4): MemRStream readers – csynth’d for xczu48dr at 4 ns, each requesting its next 16-beat burst ahead – on a crossbar as AxiXbarConfig.from_crossbar generates it (SAMD, five masters: a writer and up to four readers), reading a BRAM window behind the slave adaptor’s front. From the one-reader trace, on the handshake lines themselves (xsim 2025.1; waveflow.calib.fixtures.bram_window_contention.crossbar_latency):

setting measured how
latency_init 2 a request reaches the front’s AR 2 cycles after the reader presents it, uncontended
latency_travel 2 all of it: the request waits at the front’s port, not in the crossbar, while the front serves another
latency_read_return 1 every read beat reaches the reader 1 cycle after the front sends it (64 of 64 bursts)

With these and the window memory’s records (its timing and its 1-cycle turnaround), pysim reads each reader’s 1,024-word block within 0.41% of RTL with one reader and within 0.21% with two, three and four (tests/build/test_bram_window_contention_xsi.py). They differ from mm_fir’s (4, 2, 0): another crossbar shape (1 x 2 and 1 x 3), another master (the C++ host, one transaction at a time) and 100 MHz, and mm_fir’s latency_init carries the round trip its host sees.

No record type holds them yet. The crossbar’s own records are its area and closure (xbar_profile, under AxiXbarConfig.identity()); its latency is set per design, here as bram_window_contention.XBAR_SETTINGS. The record this calls for, proposed rather than built: a target="timing" record under the crossbar’s identity, kind: "xbar_latency", its payload {latency_init, latency_travel, latency_read_return} with the masters it was measured with ("hls_m_axi", "testbench_host") as its workload, which AXIMMCrossBarIF would load from a calib_dir as MemoryMod loads its timing (plans/interconnect_platform_model.md).

The part, and the platform

Do the numbers depend on the FPGA part? Not directly. The cycle counts above are the crossbar’s own logic as configured — its mode, its register slices, the clock — and XSI simulates that the same way for any part. They change when the configuration does: register slices added to meet timing on a slower part, a different clock, or a different interconnect altogether (a board design may use SmartConnect). So the numbers belong to an interconnect as built on a platform, not to a part.

That makes them platform-model data, like the fitted bus model a platform already carries for m_axi transfers to memory. Today a design sets them itself (mm_fir has XBAR_LATENCY, XBAR_TRAVEL = 4.0, 2.0 next to its host settings); moving them into the platform model, with a gate that measures them from the crossbar’s RTL, is planned in plans/interconnect_platform_model.md.

The master settings are not platform data: they describe the host — a single-threaded driver, a multi-threaded program, a DMA engine — and belong with whatever models it.

What is not built yet

  • The crossbar is not emitted by wrapper_gen from the module graph: an RTL top that needs one builds it (from the pysim crossbar, with from_crossbar), as mm_fir’s render_top does.
  • No SmartConnect, and no block design: the crossbar is generated standalone, for XSI and synthesis (plans/board_packaging.md plans a block design).
  • The crossbar’s measured latency is set per design, not resolved from a platform model – the records xbar_profile files are where it would come from (plans/interconnect_platform_model.md).
  • The pysim crossbar models SAMD only; a SASD crossbar’s whole-interconnect serialization is not modelled yet.