Improve Vivado/Vitis build flow, report generation, and VivadoAccelerator refactor - #1448
Improve Vivado/Vitis build flow, report generation, and VivadoAccelerator refactor#1448nghielme wants to merge 16 commits into
Conversation
…tis and Vivado builds Made-with: Cursor
- Introduced a new `statistics.tcl` script for parsing utilization, power, and timing reports into JSON format. - Updated existing TCL scripts for AXI Lite and AXI Stream designs to include the new statistics reporting functionality. - Refactored the `vivado_report.py` to utilize path templates for improved file handling and maintainability. Power reports has been added. - Modified `.gitignore` to exclude specific test files from version control.
- Updated the Vivado backend to generate build options in a separate `build_opt.tcl` file, improving maintainability and readability, as it happens for Vitis backend - Modified the `build_prj.tcl` to source the new `build_opt.tcl` for configuration settings. - Enhanced the CLI to accept a new `--fifo-opt` argument for FIFO optimization. - Adjusted the build scripts across various backends to ensure consistent handling of build options. - Added new templates for `build_opt.tcl` in both Vivado and Vivado Accelerator directories.
…n and organization - Updated `build_prj.tcl` for Vivado and Vitis to create a dedicated `vivado_reports` directory for RTL simulation JSON reports. - Enhanced the handling of compiler flags by introducing a `common_cflags` variable to fix an error with Vivado 2020.1. - Removed the deprecated `build_prj.tcl` for the Vivado Accelerator, streamlining the project structure. - Added a new bitfile generation block in `vivado_accelerator_writer.py`. The part concerning bitfile is now run inside the tcl file that is generated by Vivado backend and modified by VivadoAccelerator writer. This way it's possible to just run the tcl file to get the bitstream file, while previously the only way to invoke vivado bitstream generation was by calling `build(bitfile=1)`.
- Added parsing for dynamic and static power metrics in the `dump_statistics` procedure. - Updated JSON output to include new power statistics for improved reporting and analysis.
…_statistics` procedure and improve readability of the script.
… function defined in that file
When vsynth is enabled, pnr=True keeps the full flow through post_route; pnr=False stops after post_synth statistics and reports. CLI: hls4ml build --pnr with -l. Made-with: Cursor
_parse_implementation_report() assumed every cell is 'abs(pct%)', which is what Vivado's hierarchical utilization report writes. Reports produced by other flows carry the absolute count only, and int() then raises on the whole line. Add percentage_columns=True. With it False the parser reads plain integers and omits the '%' keys. The default preserves current behaviour for every existing caller. The per-metric assignments are folded into a column table while touching this, so the two column layouts (with and without URAM) no longer need four near-identical blocks.
| """Run HLS / optional Vivado flow. | ||
|
|
||
| Args: | ||
| pnr: If True (default) and ``vsynth`` is True, Vivado runs through place and route. |
There was a problem hiding this comment.
Isn't it set to default to False above?
There was a problem hiding this comment.
Yes, should be false by default
JanFSchulte
left a comment
There was a problem hiding this comment.
Overall very nice and close to ready for merge.
My main concern is that Claude found a few edge cases where not all required build_opts are set at all times. For example in hls4ml/utils/symbolic_utils.py, vsynth is not set, but expected when build_prj.tcl is written, resulting in tcl files that crash when invoking Vitis. Similarly, in test/build-prj.sh we should set pnr, even though that is guarded by the vsynth flag and not likely to trigger an issue. So it might be good to have a close look and make sure all flags are set everywhere, or have a system that sets good defaults in case any specific backend doesn't set all of them.
Description
This PR improves the Vivado and Vitis backend build flow, report generation, and consistency across backends.
Summary of changes
Build configuration
build_opt.tclfile for build options (similar to Vitis), improving maintainability.build_prj.tcltemplate. VivadoAccelerator now modifies the shared Vivadobuild_prj.tcland uses a single source. Bitfile generation is now integrated into the generated TCL script, so running the TCL file alone can produce the bitstream (previously requiredbuild(bitfile=1)).Report generation
rtl_sim_${project_name}_report.jsonwith latency, initiation interval, and transaction count from the cosim transaction file. Report is saved undervivado_reports/.statistics.tclfor parsing utilization, power, and timing reports into JSON. VivadoAccelerator design scripts (AXI Lite, AXI Stream) now use this shared procedure.vivado_synth.tcl'sdump_statisticsto includeXILINX_POWER_DYNAMICandXILINX_POWER_STATIC(previously only in the system-level report).vivado_report.pyto use path templates for improved file handling. Power reports have been added.common_cflags: Introducedcommon_cflagsinbuild_prj.tclto fix Vivado 2020.1 compatibility and ensure consistent compiler flags across synthesis and cosim.CLI and backend
--fifo-opt: New CLI argument for FIFO optimization.Type of change
Tests
Tests were run using the existing pytest suite with Vivado, Vitis, and VivadoAccelerator backends.
To reproduce:
Test Configuration:
Checklist
pre-commiton the files I edited or added.