Polynomial Accelerator
This example demonstrates an end-to-end PySilicon workflow for a small polynomial accelerator.
The key idea is that the interface is defined once in Python using PySilicon DataSchema classes, and that definition is then reused across software modeling, test-vector generation, and Vitis HLS integration.
With this flow, PySilicon helps reduce drift between Python reference code and hardware-facing C++ interfaces, while making it easier to validate the accelerator against a golden model.
In this example, we:
- Define the request and response schemas in Python using PySilicon
DataSchemaclasses - Auto-generate matching C++ headers for Vitis HLS, including serialization and deserialization support for the data schemas
- Build a Python golden model and generate binary test vectors
- Create a Vitis IP with AXI4-Streaming interfaces using the generated schema serialization logic
- Create a Vitis testbench that reads and writes test vectors produced by the Python golden model
- Run the Vitis testbench from Python using PySilicon
toolchainutilities - Compare the Vitis outputs against the Python reference
The full example files are in examples/poly.
The main runnable script is examples/poly/poly_demo.py.
Why this example matters
This example shows how PySilicon can be used to:
- Keep interface definitions consistent across Python and HLS code
- Reuse the same schema description for both modeling and hardware integration
- Generate reproducible test vectors from a Python golden model
- Validate hardware-oriented code against a software reference
- Move toward a more automated hardware/software co-design flow
Current limitations
This example demonstrates only part of the intended PySilicon workflow. Future versions will add:
- A Python golden model represented as a PySilicon
HwObjclass that defines AXI interfaces and interface actions - Auto-generation of the Vitis IP and Vitis testbench code from the
HwObjdescription
Polynomial Accelerator Protocol
This example implements a polynomial accelerator with the following protocol:
- The host writes polynomial coefficients to the accelerator’s AXI-Lite register map (a
VitisRegMap), then writesap_startto launch the kernel - The host sends a
PolyCmdHdr(cmd_type = DATA) containing the transaction ID and sample count over the input AXI-Stream - The host then streams
nsampinput values (x) - The accelerator returns a
PolyRespHdrechoing the transaction ID, then streamsnsampresult values (y) - When the host has no more work, it sends a
PolyCmdHdrwithcmd_type = ENDto break the kernel’s persistent loop cleanly - On error the kernel halts: it sets
halted = 1,error = <code>,tx_id = <offending txn>in the regmap and returns. The host re-launches the kernel via platform reset, then writesap_startagainFiles used in the example
- examples/poly/poly_demo.py drives the Python flow.
- examples/poly/poly.hpp declares the HLS interface and includes the generated schemas.
- examples/poly/poly.cpp implements the polynomial kernel.
- examples/poly/poly_tb.cpp reads vectors, calls the kernel, and writes outputs.
- examples/poly/run.tcl runs the Vitis C-simulation flow.
Go to Python flow