The Vitis Unified IDE supports creating and building components using Python APIs. You can use the following Python APIs to build HLS components.
| Python API | Description | Python API Example |
|---|---|---|
create_hls_component
|
Create a HLS component |
hls_comp =
client.create_hls_component(name=<hls_comp_name>,cfg_file =
["hls_config.cfg"],template =
"empty_hls_component")
|
add_cfg_file
|
Add configuration file to the component |
hls_comp_cfg=client.add_cfg_file(cfg_file=<config_file_path.cfg>)
|
set_value
|
Sets the value of the key (directive) in a specific section of a configuration file. Overwrites earlier values. |
To set value in config file:
|
run
|
Runs a specified operation on the HLS component |
hls_comp=run(operation='SYNTHESIS')
Operation = SYNTHESIS
|
The following is the Python script to create and build a HLS component.
# Add package: Vitis Python CLI
import vitis
# Create a Vitis client object -
client = vitis.create_client()
# Set Vitis Workspace
client.set_workspace(path=<workspace_location>)
# Create HLS component
hls_comp = client.create_hls_component(name='HLS_comp',cfg_file = ["hls_config.cfg"],template = "empty_hls_component")
# Add Configuration File
hls_comp_cfg = client.add_config_file(cfg_file='/hls_config.cfg')
#Add values to the configuration file
hls_comp_cfg.set_value(key='part', value=part)
hls_comp_cfg.set_value(section='hls', key='clock', value='4')
hls_comp_cfg.set_value(section='hls', key='package.output.syn', value='1')
hls_comp_cfg.set_value(section='hls', key='package.output.format', value='xo')
......
# Build HLS component in Vitis Mode
hls_comp.run(operation="SYNTHESIS")
hls_comp.run(operation="PACKAGE")
After building the HLS component, find the output files with the
following
command.
workspace/HLS_comp/<kernel_name>/