Skip to content

Improve Vivado/Vitis build flow, report generation, and VivadoAccelerator refactor - #1448

Open
nghielme wants to merge 16 commits into
fastmachinelearning:mainfrom
nghielme:vivado-based-report-pr
Open

Improve Vivado/Vitis build flow, report generation, and VivadoAccelerator refactor#1448
nghielme wants to merge 16 commits into
fastmachinelearning:mainfrom
nghielme:vivado-based-report-pr

Conversation

@nghielme

@nghielme nghielme commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

Description

This PR improves the Vivado and Vitis backend build flow, report generation, and consistency across backends.

Summary of changes

Build configuration

  • TCL configuration files: Vivado backend now uses a separate build_opt.tcl file for build options (similar to Vitis), improving maintainability.
  • VivadoAccelerator refactor: Removed the deprecated standalone build_prj.tcl template. VivadoAccelerator now modifies the shared Vivado build_prj.tcl and 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 required build(bitfile=1)).

Report generation

  • RTL simulation JSON report: Added automatic generation of rtl_sim_${project_name}_report.json with latency, initiation interval, and transaction count from the cosim transaction file. Report is saved under vivado_reports/.
  • Shared statistics parsing: Introduced statistics.tcl for parsing utilization, power, and timing reports into JSON. VivadoAccelerator design scripts (AXI Lite, AXI Stream) now use this shared procedure.
  • Power report parity: Extended vivado_synth.tcl's dump_statistics to include XILINX_POWER_DYNAMIC and XILINX_POWER_STATIC (previously only in the system-level report).
  • Report path templates: Refactored vivado_report.py to use path templates for improved file handling. Power reports have been added.
  • common_cflags: Introduced common_cflags in build_prj.tcl to 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.
  • VivadoAccelerator backend: Now delegates build to the Vivado backend instead of duplicating logic.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Documentation update
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • A new research paper code implementation
  • Other (Specify)

Tests

Tests were run using the existing pytest suite with Vivado, Vitis, and VivadoAccelerator backends.

To reproduce:

cd test/pytest
RUN_SYNTHESIS=true pytest test_keras_api.py -v -k "activations" --tb=short

Test Configuration:

  • Vivado: 2020.1
  • Vitis: 2024.1
  • VivadoAccelerator: Vivado 2020.1

Checklist

  • I have read the guidelines for contributing.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have installed and run pre-commit on the files I edited or added.
  • I have added tests that prove my fix is effective or that my feature works.

nghielme added 8 commits March 2, 2026 19:11
- 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.
@nghielme nghielme added the please test Trigger testing by creating local PR branch label Mar 5, 2026
@JanFSchulte JanFSchulte added please test Trigger testing by creating local PR branch and removed please test Trigger testing by creating local PR branch labels Mar 6, 2026
@JanFSchulte JanFSchulte added please test Trigger testing by creating local PR branch and removed please test Trigger testing by creating local PR branch labels Mar 6, 2026
nghielme added 4 commits May 1, 2026 01:23
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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it set to default to False above?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, should be false by default

@JanFSchulte JanFSchulte removed the please test Trigger testing by creating local PR branch label Jul 24, 2026
@JanFSchulte JanFSchulte added the please test Trigger testing by creating local PR branch label Jul 24, 2026

@JanFSchulte JanFSchulte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

please test Trigger testing by creating local PR branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants