Skip to content

Add option to configure IP version #851

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion hls4ml/templates/vivado/build_prj.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ if {$opt(validation)} {
if {$opt(export)} {
puts "***** EXPORT IP *****"
set time_start [clock clicks -milliseconds]
export_design -format ip_catalog
export_design -format ip_catalog -version $version
set time_end [clock clicks -milliseconds]
report_time "EXPORT IP" $time_start $time_end
}
Expand Down
25 changes: 24 additions & 1 deletion hls4ml/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,29 @@
import hls4ml


def create_config(output_dir='my-hls-test', project_name='myproject', backend='Vivado', **kwargs):
def create_config(output_dir='my-hls-test', project_name='myproject', backend='Vivado', version='1.0.0', **kwargs):
"""Create an initial configuration to guide the conversion process.

The resulting configuration will contain general information about the project (like project name and output directory)
as well as the backend-specific configuration (part numbers, clocks etc). Extra arguments of this function will be
passed to the backend's ``create_initial_config``. For the possible list of arguments, check the documentation of each
backend.

Args:
output_dir (str, optional): The output directory to which the generated project will be written.
Defaults to 'my-hls-test'.
project_name (str, optional): The name of the project, that will be used as a top-level function in HLS designs.
Defaults to 'myproject'.
backend (str, optional): The backend to use. Defaults to 'Vivado'.
version (str, optional): Optional string to version the generated project for backends that support it.
Defaults to '1.0.0'.

Raises:
Exception: Raised if unknown backend is specified.

Returns:
dict: The conversion configuration.
"""
backend_list = hls4ml.backends.get_available_backends()
if backend.lower() not in backend_list:
raise Exception(f'Unknown backend: {backend}')
Expand All @@ -18,6 +40,7 @@ def create_config(output_dir='my-hls-test', project_name='myproject', backend='V
config['OutputDir'] = output_dir
config['ProjectName'] = project_name
config['Backend'] = backend.name
config['Version'] = version
config.update(backend_config)

return config
Expand Down
2 changes: 2 additions & 0 deletions hls4ml/writer/vivado_accelerator_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,8 @@ def write_board_script(self, model):
f.write('set clock_period {}\n'.format(model.config.get_config_value('ClockPeriod')))
f.write('variable clock_uncertainty\n')
f.write('set clock_uncertainty {}\n'.format(model.config.get_config_value('ClockUncertainty', '12.5%')))
f.write('variable version\n')
f.write('set version "{}"\n'.format(model.config.get_config_value('Version', '1.0.0')))
if self.vivado_accelerator_config.get_interface() == 'axi_stream':
in_bit, out_bit = self.vivado_accelerator_config.get_io_bitwidth()
f.write(f'set bit_width_hls_output {in_bit}\n')
Expand Down
2 changes: 2 additions & 0 deletions hls4ml/writer/vivado_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,8 @@ def write_build_script(self, model):
f.write('set clock_period {}\n'.format(model.config.get_config_value('ClockPeriod')))
f.write('variable clock_uncertainty\n')
f.write('set clock_uncertainty {}\n'.format(model.config.get_config_value('ClockUncertainty', '12.5%')))
f.write('variable version\n')
f.write('set version "{}"\n'.format(model.config.get_config_value('Version', '1.0.0')))
f.close()

# build_prj.tcl
Expand Down