Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
138 commits
Select commit Hold shift + click to select a range
3922260
add vitisUnified backend and its writer
Tanawin1701d Jul 12, 2025
6ac2b71
add vitis unified template
Tanawin1701d Aug 14, 2025
cfc92d5
add dma wrapper access
Tanawin1701d Aug 15, 2025
f570c3f
extract writer class + add gmem wrapper
Tanawin1701d Aug 15, 2025
1169bf4
extract writer class + add gmem wrapper
Tanawin1701d Aug 15, 2025
a772aeb
fix store value override
Tanawin1701d Aug 15, 2025
235bc2d
draft write_hls initialization
Tanawin1701d Aug 15, 2025
2c5a6e8
fix import bug at VitisUnifiedwriter
Tanawin1701d Aug 15, 2025
fd4f3d6
add project generation and .h file generation
Tanawin1701d Aug 15, 2025
5913c9c
fix generation bug in unified workspace
Tanawin1701d Aug 16, 2025
8304a20
fix new gmem wrapper to get data and send data at wrong index
Tanawin1701d Aug 16, 2025
b979ec0
add auto platform linker script
Tanawin1701d Aug 16, 2025
926f412
add initiat config parameter for io buffer and platform path
Tanawin1701d Aug 16, 2025
b516a96
modifying build function for vitis unified
Tanawin1701d Aug 16, 2025
3f6d224
update build function for vitis unified
Tanawin1701d Aug 17, 2025
19e0af9
add bridge simulation
Tanawin1701d Aug 17, 2025
32d079b
add bridge script and move a bit bridge generator
Tanawin1701d Aug 17, 2025
9237af5
change build script permission and refactoring cosim writing
Tanawin1701d Aug 17, 2025
bd6a384
add cosim testbench + fix namming in gmem
Tanawin1701d Aug 17, 2025
c1b95c9
fix wrapper mismatch io bug and testing the bridge simulation
Tanawin1701d Aug 17, 2025
6e37f3c
add .bit file for full flow
Tanawin1701d Aug 18, 2025
f64b50d
add python generator for the system
Tanawin1701d Aug 18, 2025
3f465ab
clean some code
Tanawin1701d Aug 19, 2025
86d64d5
add base ip for magic architecture and add axi warpper
Tanawin1701d Aug 19, 2025
c69fcf6
convert meta gen into class
Tanawin1701d Aug 19, 2025
b508473
refractor vitisUnified backend to be a multiple subclass and build ax…
Tanawin1701d Aug 19, 2025
548a8f0
divert tot use mg and add mgs group generator
Tanawin1701d Aug 20, 2025
abf830f
add sub-writer override for vitis unified/unified partial
Tanawin1701d Aug 20, 2025
485c1c8
register backend and writer
Tanawin1701d Aug 20, 2025
d78a50d
fix minor missing syntax
Tanawin1701d Aug 20, 2025
d23e591
fix wrap_gen syntax bug + add include ap_axi_sdata.h for wrapgen + ad…
Tanawin1701d Aug 20, 2025
6cce4ea
add magic streamer generator and auto invoker
Tanawin1701d Aug 20, 2025
7d99de6
add icap wraper and magic seq
Tanawin1701d Aug 21, 2025
c1e2419
add project builder tcl file copy
Tanawin1701d Aug 22, 2025
ccd3d2a
integrating the zcu102 synthesis code
Tanawin1701d Aug 23, 2025
b982b21
add connection between block
Tanawin1701d Aug 23, 2025
0b3debc
drafting the automatically magic streamer linker
Tanawin1701d Aug 24, 2025
d4220c4
add new refactor magic streamer controller
Tanawin1701d Aug 25, 2025
e81078a
add start converter for class MgsModel
Tanawin1701d Aug 25, 2025
05cc849
fix mgs model syntax bug
Tanawin1701d Aug 25, 2025
fe9fe8b
fix syntax generation for vitisUnified partialbackend
Tanawin1701d Aug 25, 2025
7b1b12b
send magic streamer manager to writer
Tanawin1701d Aug 25, 2025
b2f2238
specify io signal meta-data to tcl file for each configuration
Tanawin1701d Aug 25, 2025
654724a
add build for stitcher
Tanawin1701d Aug 25, 2025
95148d8
update vivado project stitcher script
Tanawin1701d Aug 25, 2025
3de0444
delete vitis Unified partial after merge the co-reactor
Tanawin1701d Aug 26, 2025
3e1314c
delete vitis Unified partial template
Tanawin1701d Aug 26, 2025
e367146
fix bridge gen top function name change
Tanawin1701d Aug 26, 2025
ac04d40
clean vitis config: test using bridge test and it pass
Tanawin1701d Aug 26, 2025
dfbbc3d
add to check accept only io stream
Tanawin1701d Aug 26, 2025
04d0e6d
add bridge gen to support both float and double input
Tanawin1701d Aug 26, 2025
b77e22f
fix size getting bug in cosim
Tanawin1701d Aug 26, 2025
e14f2c6
fix config to gen two kernel hardware cfg for csim and csim
Tanawin1701d Aug 26, 2025
6a357cb
fix cosimulation bug from segment fault buffer size and invalid resul…
Tanawin1701d Aug 27, 2025
5e87503
add fifo-flag in hls compile kernel
Tanawin1701d Aug 27, 2025
0525079
push fifo
Tanawin1701d Aug 28, 2025
671c1ae
upgrade new wrapper
Tanawin1701d Aug 28, 2025
f5189b9
upgrade the parameter of cosim and bridge sim
Tanawin1701d Aug 28, 2025
2d83c57
fix missing wrap problem
Tanawin1701d Aug 28, 2025
fbf1dee
fix missing wrap problem
Tanawin1701d Aug 29, 2025
1ece84e
update the driver and testing
Tanawin1701d Aug 29, 2025
143ae14
push ready to test code and its example driver
Tanawin1701d Aug 29, 2025
7097f63
delete polute file and unconment the compile
Tanawin1701d Aug 29, 2025
48e49d4
remove debug print on multigraph
Tanawin1701d Aug 29, 2025
d588181
change xpfm default Path
Tanawin1701d Aug 29, 2025
b2ee0e3
revert the multigraph modification because it is not relate to this b…
Tanawin1701d Aug 29, 2025
b17d2b2
get the code out that not related to vitisUnified backend
Tanawin1701d Aug 29, 2025
3f6a37e
update code to precommit style
Tanawin1701d Sep 2, 2025
48d7500
fix vitisConfig missign (after refactor) add comment
Tanawin1701d Sep 2, 2025
0feaf32
fix ciricular import again
Tanawin1701d Sep 2, 2025
c2e5209
add bridge sim for axi stream
Tanawin1701d Feb 10, 2026
3970b21
fix support fifo-op, driver_gen, auto_link for axi stream
Tanawin1701d Feb 12, 2026
ac34e21
update driver template for both axis and axim
Tanawin1701d Feb 13, 2026
a62044f
refactor the generated file naming
Tanawin1701d Feb 13, 2026
611b8d8
pass test both axi_stream and axi_master/ add dedicated example ipynb
Tanawin1701d Feb 13, 2026
e22ac46
clean code/ cut out unused argument/ use pytest
Tanawin1701d Feb 14, 2026
e982ed1
Merge upstream main into VitisUnifiedClean
nghielme Feb 17, 2026
5bdf2c1
Finalize Vitis Unified backend cleanup and naming alignment after syn…
nghielme Feb 17, 2026
0ebb669
pre-commit changes
nghielme Feb 17, 2026
8347f39
pre-commit changes
nghielme Feb 17, 2026
c858411
Enhance Vitis Unified backend with support for new board configuratio…
nghielme Feb 19, 2026
98a67b1
pre-commit changes
nghielme Feb 19, 2026
cec7297
pre-commit changes
nghielme Feb 19, 2026
7f7d32c
Minor fix on .gitignore
nghielme Feb 19, 2026
e540553
Merge pull request #1 from nghielme/vitis-unified-pr
Tanawin1701d Feb 21, 2026
28dc178
Merge branch 'main' into VitisUnifiedClean
nghielme Feb 23, 2026
f70d574
add main driver to wrap the IP's driver and make the IP's driver shared
Tanawin1701d Feb 25, 2026
a8b736f
Merge remote-tracking branch 'origin/VitisUnifiedClean' into VitisUni…
Tanawin1701d Feb 25, 2026
86e7211
restructure the template repository
Tanawin1701d Feb 26, 2026
d69d15e
restructure a supported_boards.json
Tanawin1701d Feb 26, 2026
4dbc6b3
fix return execution's profile
Tanawin1701d Feb 26, 2026
0e9a32c
fix axi master driver variable mismatch and precomit for wrapper fix
Tanawin1701d Feb 27, 2026
b52af9c
add last packet checking to axi_stream
Tanawin1701d Feb 27, 2026
8fcae7a
fix axi_stream bug from missing tkeep
Tanawin1701d Feb 27, 2026
193508b
fix tlast signal tracking bug
Tanawin1701d Feb 27, 2026
bd5951a
update tlast stream and stream driver
Tanawin1701d Feb 28, 2026
36b4947
fix axi stream driver performance bug
Tanawin1701d Feb 28, 2026
a45f5e4
unified the IP driver and NN driver wrapper
Tanawin1701d Mar 1, 2026
4a27208
fix vitis unified driver generation error
Tanawin1701d Mar 2, 2026
57ce9c4
modify axi_stream wrapper to support multiple queries without tlast s…
Tanawin1701d Mar 2, 2026
74302f5
copy driver for zcu102
Tanawin1701d Mar 2, 2026
5978625
aggreagate the axi_stream loop to ensure there is no bubble time from…
Tanawin1701d Mar 2, 2026
0a8c6d3
fix vitis unified compute bug and add performance tracker to the system
Tanawin1701d Mar 5, 2026
ad7c66f
delete tlast stream parameter
Tanawin1701d Mar 5, 2026
f1f1c76
Merge branch 'main' into VitisUnifiedClean
nghielme Mar 10, 2026
9e86b42
Added updated script for creating board design for KV260 with Vivado …
lolbraa Mar 20, 2026
57d7a2d
enable FIFO sizing configuration and add sanity checks to Vitis Unifi…
Tanawin1701d Apr 22, 2026
4bf6624
Passing -force when creating Vivado project to overwrite existing pro…
lolbraa Apr 24, 2026
79dc505
Fixed part for board kv260, extracted from Vivado part list. Tested w…
lolbraa May 7, 2026
31ceb59
fix: add set -e to link_system.sh to propagate v++ errors
gflengas May 12, 2026
781a3e5
feat: add vitis_fifo_sizing flag to build() for experimental FIFO sizing
gflengas May 12, 2026
1947b41
feat: copy Vitis Unified reports to final_reports
gflengas May 13, 2026
a26b52d
Merge pull request #2 from lolbraa/VitisUnifiedClean
Tanawin1701d Aug 13, 2026
017744e
[pre-commit.ci] auto fixes from pre-commit hooks
pre-commit-ci[bot] Aug 13, 2026
a3049a9
Merge branch 'main' into VitisUnifiedClean
JanFSchulte Aug 13, 2026
b612ae1
Merge pull request #3 from gflengas/fix-link-system-error-handling
Tanawin1701d Aug 20, 2026
f938fb5
enable FIFO sizing configuration and add sanity checks to Vitis Unifi…
Tanawin1701d Apr 22, 2026
2c867f7
fix: add set -e to link_system.sh to propagate v++ errors
gflengas May 12, 2026
98ab06f
feat: add vitis_fifo_sizing flag to build() for experimental FIFO sizing
gflengas May 12, 2026
fa60d34
feat: copy Vitis Unified reports to final_reports
gflengas May 13, 2026
4945634
Merge remote-tracking branch 'origin/VitisUnifiedClean_fix_cosim&leng…
Tanawin1701d Aug 20, 2026
1f29985
[fix] correct: guard optional HLS report copies in link_system.sh
Tanawin1701d Aug 20, 2026
900bf7c
[pre-commit.ci] auto fixes from pre-commit hooks
pre-commit-ci[bot] Aug 20, 2026
afdc54c
Merge branch 'main' into VitisUnifiedClean
JanFSchulte Aug 20, 2026
eed1a54
Fix Vitis Unified stream buffer depths
gflengas Aug 13, 2026
4fa5308
Fix Vitis Unified clock propagation
gflengas Aug 13, 2026
7487469
Merge pull request #4 from gflengas/fix-vitis-unified-buffer-depths-a…
Tanawin1701d Aug 23, 2026
516eeec
[fix] correct: VitisUnified I/O validation and GIE disable value
Tanawin1701d Aug 23, 2026
f8b3be3
fix: run Vitis Unified synthesis tests in CI
gflengas Aug 14, 2026
af5579d
[fix] VitisUnified: multi-port AXI-master driver
Tanawin1701d Aug 25, 2026
5786aba
Merge pull request #5 from gflengas/fix-vitis-unified-ci-tests-upstream
Tanawin1701d Aug 25, 2026
621bdb3
fix: bind Vitis tools to CI project directory
gflengas Aug 25, 2026
e493113
test: skip multi-I/O bitstream generation by default
gflengas Aug 25, 2026
8e75979
Merge pull request #6 from gflengas/fix-vitis-unified-ci-project-bind
Tanawin1701d Aug 26, 2026
ed844a1
[docs] add VitisUnified backend documentation
Tanawin1701d Aug 27, 2026
ed2373e
Merge branch 'main' into VitisUnifiedClean
JanFSchulte Aug 28, 2026
213b35a
docs: update tutorial links and platform setup instructions in VitisU…
Tanawin1701d Aug 29, 2026
b133acb
fix: make ap_axi_sdata.h exclusive to VitisUnified backend
Tanawin1701d Sep 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ recursive-include hls4ml *.py
recursive-include hls4ml/contrib *
global-exclude .git .gitmodules .gitlab-ci.yml *.pyc
include hls4ml/backends/vivado_accelerator/supported_boards.json
include hls4ml/backends/vitis_unified/supported_boards.json
167 changes: 167 additions & 0 deletions docs/backend/vitis_unified.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
============
VitisUnified
============

The **VitisUnified** backend provides an end-to-end workflow for AMD SoC boards, from an ML model to a design that is ready to deploy on `PYNQ <http://pynq.io/>`_. It is inherited from the :doc:`Vitis <vitis>` backend. We use the new Vitis Unified software, which can automatically link the HLS kernel to the system hardware. The current version supports only SoC boards with a PYNQ Python driver.

Currently ``hls4ml`` officially supports the following boards and tool versions:

* `zcu102 <https://www.xilinx.com/products/boards-and-kits/ek-u1-zcu102-g.html>`_ (Vitis and Vivado 2023.2)
* `kv260 <https://www.xilinx.com/products/som/kria/kv260-vision-starter-kit.html>`_ (Vitis and Vivado 2023.2 and 2025.2)

If you use another board, another Vivado version, or want to optimize the system design for your own workload, you can build your own platform. The steps are covered in the platform setup tutorial in the accelerator backend section of the `hls4ml-tutorial <https://github.com/fastmachinelearning/hls4ml-tutorial>`_ repository.


System Flow
===========

The figure below shows the flow of the backend, from the generated HLS files to the files that are ready to ship to the board.

.. image:: ../img/vitis_unified_flow.png
:width: 450px
:align: center
:alt: Vitis Unified backend system flow


.. _vitis_unified_axi_modes:

AXI interface modes
===================

The backend supports two ways to move data between the PS and the kernel, selected with ``axi_mode``.
In both modes the CPU controls the kernel through AXI-Lite and receives an interrupt when the kernel is done.

``axi_master`` (default)
The kernel reads its input and writes its output in DDR by itself through an AXI master port.
The driver allocates one DDR buffer per model input and output, so models with several inputs or outputs are supported.

.. image:: ../img/vitis_unified_axi_master.png
:width: 450px
:align: center
:alt: axi_master mode

``axi_stream``
The kernel has one AXI-Stream input and one AXI-Stream output. An AXI DMA in the platform moves the data between DDR and the kernel.
Only models with one input and one output are supported.

.. image:: ../img/vitis_unified_axi_stream.png
:width: 450px
:align: center
:alt: axi_stream mode

Configuration options
=====================

The options below are passed as keyword arguments to the converter (for example ``convert_from_keras_model``).
They are stored under ``VitisUnifiedConfig`` in the model configuration.

.. list-table::
:header-rows: 1
:widths: 30 18 52

* - Option
- Default
- Description
* - ``board``
- ``zcu102``
- | Target board.
| It selects the FPGA part, the platform, and the Python driver template.
| The current version only supports the boards in ``supported_boards.json`` (``zcu102`` and ``kv260``).
* - ``part``
- from board
- | FPGA part name.
| If not given, it is taken from the board entry in ``supported_boards.json``.
| If the board is not in the list and no part is given, the zcu102 part is used.
* - ``clock_period``
- ``5``
- | Kernel clock period in ns.
| The same clock is used when the kernel is linked to the platform.
* - ``clock_uncertainty``
- ``12.5%``
- | Clock uncertainty passed to Vitis HLS.
* - ``io_type``
- ``io_stream``
- | hls4ml I/O type of the model.
| The current version only supports ``io_stream``.
* - ``axi_mode``
- ``axi_master``
- | Interface between the PS and the kernel: ``axi_master`` or ``axi_stream``.
| See :ref:`AXI interface modes <vitis_unified_axi_modes>`.
* - ``driver``
- ``python``
- | Type of driver generated for the board.
| The current version only supports ``python`` (PYNQ).
* - ``input_type``
- ``float``
- | Data type of the model input on the AXI interface.
| The current version only supports ``float`` and ``double``.
| The PYNQ driver uses the matching NumPy type.
* - ``output_type``
- ``float``
- | Data type of the model output on the AXI interface.
| The current version only supports ``float`` and ``double``.
| It must be the same as ``input_type``.
* - ``in_stream_buf_size``
- ``128``
- | Depth of the FIFO between the wrapper input (AXI master read or AXI-Stream) and the HLS model.
| Used in both AXI modes.
* - ``out_stream_buf_size``
- ``128``
- | Depth of the FIFO between the HLS model and the wrapper output (AXI master write or AXI-Stream).
| Used in both AXI modes.

Example:

.. code-block:: Python

hls_model = hls4ml.converters.convert_from_keras_model(model,
hls_config=config,
output_dir='hls4ml_prj_unified',
backend='VitisUnified',
board='kv260',
axi_mode='axi_stream',
clock_period=10,
in_stream_buf_size=256,
out_stream_buf_size=256)


Output directory layout
-----------------------

.. code-block:: text

<output_dir>/
├── firmware/ HLS sources: model, AXI wrapper, weights
├── tb_data/ testbench input and reference output
├── myproject_test.cpp C testbench
├── <project_name>_bridge.cpp bridge used by hls_model.predict()
├── build_lib.sh builds the shared library for predict()
├── hls4ml_config.yml
├── hls_kernel_config_csim.cfg Vitis HLS config for csynth, package, and csim
├── hls_kernel_config_cosim.cfg Vitis HLS config for cosim
├── hls_kernel_config.cfg copy of the config used by the last step
├── fifo_depths.json with FIFO depth optimization only
├── <step>_stdout.log, <step>_stderr.log with log_to_stdout=False only
├── vitis_workspace/
│ ├── <project_name>/
│ │ ├── vitis-comp.json Vitis Unified component
│ │ └── vitis_unified_project/ hls/, logs/, reports/, <project_name>_axi_*.xo
│ ├── system_link/
│ │ ├── link_system.cfg, link_system.sh
│ │ ├── <project_name>.xclbin link output (bitfile=True)
│ │ └── _x/ Vivado project of the system link
│ └── <board>/
│ ├── tcl_scripts/ create_xsa.tcl, platform tcl, output/<board>_*.xsa
│ └── python_drivers/ driver templates
├── export/
│ ├── system.bit bitstream (bitfile=True)
│ ├── system.hwh hardware handoff (bitfile=True)
│ └── axi_master_driver.py or axi_stream_driver.py
└── final_reports/ timing, utilization, power, link summary, hls_compile.rpt

Tutorial
========

A step-by-step tutorial with notebooks is available in the accelerator backend section of the
`hls4ml-tutorial <https://github.com/fastmachinelearning/hls4ml-tutorial>`_ repository.
It covers prediction, C simulation, co-simulation, FIFO depth optimization, bitstream generation, and how to build your own platform.
Binary file added docs/img/vitis_unified_axi_master.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/vitis_unified_axi_stream.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/vitis_unified_flow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

backend/vitis
backend/accelerator
backend/vitis_unified
backend/oneapi
backend/catapult
backend/quartus
Expand Down
3 changes: 3 additions & 0 deletions hls4ml/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@
from hls4ml.backends.coyote.coyote_backend import CoyoteBackend
from hls4ml.backends.xls.xls_backend import XLSBackend

from hls4ml.backends.vitis_unified.vitis_unified_backend import VitisUnifiedBackend # isort: skip


def _register_builtin_backends():
register_backend('Vivado', VivadoBackend)
register_backend('VivadoAccelerator', VivadoAcceleratorBackend)
register_backend('Vitis', VitisBackend)
register_backend('VitisUnified', VitisUnifiedBackend)
register_backend('Quartus', QuartusBackend)
register_backend('Catapult', CatapultBackend)
register_backend('SymbolicExpression', SymbolicExpressionBackend)
Expand Down
114 changes: 114 additions & 0 deletions hls4ml/backends/vitis_unified/passes/fifo_depth_optimization.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# we inherit it from vitis
import re
import zipfile

from hls4ml.backends.vitis.passes.fifo_depth_optimization import (
generate_depths_file,
initialize_large_fifos,
set_optimized_fifo_depths,
)
from hls4ml.model.optimizer.optimizer import ConfigurableOptimizerPass, ModelOptimizerPass


def get_vitis_optimized_fifo_depths(model, cus_hls_prj_path=None):
"""Parse the files generated by the co-simulation to retrieve the optimized depths for the FIFOs.
Attention, only the FIFOs between the layers are profiled!

Args:
model (ModelGraph): The model to which FIFO depth optimization is applied.

Returns:
Dict[str, int]: A dictionary that contains the FIFO names as keys and the optimized depths as values.
"""
# channel.zip is generated after the co-simulation and contains the chan_status*.csv files
# in the chan_status*.csv files the max depth achieved during co-simulation can be found at the last (4th) line

if cus_hls_prj_path is None:
cus_hls_prj_path = model.config.get_output_dir() + '/' + model.config.get_project_name() + '/_prj/solution1'

path_to_zip_file = cus_hls_prj_path + '/.autopilot/db/channel_depth_info/'

with zipfile.ZipFile(f'{path_to_zip_file}channel.zip', 'r') as zip_ref:
zip_ref.extractall(path_to_zip_file)

# the channel_info.csv file contains the mapping of each fifo name (i.e layer4_out_U) to the respective
# chan_status*.csv file
names_file_path = cus_hls_prj_path + '/.autopilot/db/channel_info.csv'

csv_fifo_depth_files = {}
with open(names_file_path) as names_file:
for line in names_file:
slitted_line = line.split(',')
if len(slitted_line[0]) == 0:
continue
layer_name = slitted_line[1]
csv_file_name = slitted_line[3][:-1]
csv_fifo_depth_files[layer_name] = csv_file_name

optmized_fifo_depths = {}
for layer_name, file_name in csv_fifo_depth_files.items():
with open(path_to_zip_file + file_name) as chan_status_file:
lines = chan_status_file.readlines()
cleaned_layer_name = re.sub(r'(_i)?_U$', '', layer_name)
optmized_fifo_depths[cleaned_layer_name] = int(
lines[-1]
) # remove "_i_U" (axis) or "_U" (axim) from the layer name
# string and keep the last line of the file that contains the max depth

return optmized_fifo_depths


def execute_cosim_to_profile_fifos(model):
model.write()
model.build(
reset=False,
csim=False,
synth=True,
cosim=True,
vsynth=False,
fifo_opt=True,
bitfile=False,
log_to_stdout=False,
)


class FifoDepthOptimization(ConfigurableOptimizerPass, ModelOptimizerPass):
def __init__(self):
self.profiling_fifo_depth = 100_000

def transform(self, model):
"""Perform FIFO depth optimization between the FIFOs of all layers to reduce resource utilization as the
initial FIFOs set by hls4ml might be larger than required. At the end of the optimization the FIFOs will
have the largest depths achieved during co-simulation without causing any deadlocks between the layers
(producer-consumer), thus no additional delays between the layers. In some cases, this optimization
might lead to bigger FIFOs than initially set by the hls4ml tool in order to prevent deadlocks.

Args:
model (ModelGraph): The model to which FIFO depth optimization is applied.

Raises:
ValueError: If the FIFO depth for profiling provided by the user is not a non-negative integer.
RuntimeError: If the IO type is not set to "io_stream".

Returns:
bool: The execution state of the Optimizer Pass
"""

if not isinstance(self.profiling_fifo_depth, int) or self.profiling_fifo_depth <= 0:
raise ValueError('The FIFO depth for profiling (profiling_fifo_depth variable) must be a non-negative integer.')

# check axi-stream or io-stream
if not (model.config.get_config_value('IOType') == 'io_stream'):
raise RuntimeError('To use this optimization you have to set `IOType` field to `io_stream` in the HLS config.')

hlsPrjPath = model.config.backend.writer.get_vitis_hls_exec_dir(model)

initial_fifo_depths = initialize_large_fifos(model, self.profiling_fifo_depth)
execute_cosim_to_profile_fifos(model)
optimized_fifo_depths = get_vitis_optimized_fifo_depths(model, cus_hls_prj_path=hlsPrjPath + '/hls')
generate_depths_file(model, initial_fifo_depths, optimized_fifo_depths)
set_optimized_fifo_depths(model, optimized_fifo_depths)

print('FIFO optimization completed')

return False
31 changes: 31 additions & 0 deletions hls4ml/backends/vitis_unified/supported_boards.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"zcu102": {
"part": "xczu9eg-ffvb1156-2-e",
"axi_master": {
"platform_file": "base_platforms/xilinx_zcu102_base_202320_1/xilinx_zcu102_base_202320_1.xpfm",
"python_driver": "axi_master_driver.py",
"c_drivers": ""
},
"axi_stream": {
"platform_generator_tcl": "zcu102/tcl_scripts/create_xsa.tcl",
"platform_output": "zcu102/tcl_scripts/output/zcu102_axi_stream_platform.xsa",
"python_driver": "axi_stream_driver.py",
"c_drivers": ""
}
},
"kv260": {
"part": "xck26-sfvc784-2LV-c",
"axi_master": {
"platform_generator_tcl": "kv260/tcl_scripts/create_xsa.tcl",
"platform_output": "kv260/tcl_scripts/output/kv260_axi_all_platform.xsa",
"python_driver": "axi_master_driver.py",
"c_drivers": ""
},
"axi_stream": {
"platform_generator_tcl": "kv260/tcl_scripts/create_xsa.tcl",
"platform_output": "kv260/tcl_scripts/output/kv260_axi_all_platform.xsa",
"python_driver": "axi_stream_driver.py",
"c_drivers": ""
}
}
}
Loading