hls4ml.backends.libero package

Submodules

hls4ml.backends.libero.libero_backend module

class hls4ml.backends.libero.libero_backend.LiberoBackend

Bases: FPGABackend

build(model, reset=False, skip_preqs=True, sw_compile=True, hw=True, cosim=False, rtl_synth=False, fpga=False, **kwargs)

Build the model using Libero suite and SmartHLS compiler. Additional arguments passed to the function in form of <arg>=True will be passed as an argument to the shls command. See SmartHLS user guide for list of possible command line options.

Parameters:
  • model (ModelGraph) – Model to build

  • reset (bool, optional) – Clean up any existing files. Defaults to False.

  • skip_preqs (bool, optional) – Skip any prerequisite step that is outdated. Defaults to False.

  • sw_compile (bool, optional) – Compile the generated HLS in software. Defaults to True.

  • hw (bool, optional) – Compile the software to hardware, producing a set of Verilog HDL files. Defaults to True.

  • cosim (bool, optional) – Run co-simulation. Defaults to False.

  • rtl_synth (bool, optional) – Run RTL synthesis for resource results. This will take less time than fpga. Defaults to False.

  • fpga (bool, optional) – Synthesize the generated hardware to target FPGA. This runs RTL synthesis and place-and-route for resource and timing results. Defaults to False.

Raises:
  • Exception – Raised if the shls command has not been found

  • CalledProcessError – Raised if SmartHLS returns non-zero code for any of the commands executed

Returns:

Detailed report produced by SmartHLS.

Return type:

dict

compile(model)

Compile the generated project that can be linked into Python runtime.

Parameters:

model (ModelGraph) – Model to compile.

Raises:

Exception – If the project failed to compile

Returns:

Returns the name of the compiled library.

Return type:

string

create_initial_config(fpga_family='PolarFire', part='MPF300', board='hw_only', clock_period=5, io_type='io_parallel', smarthls_path=None, namespace=None, write_weights_txt=True, write_tar=False, **_)

Create initial configuration of the Libero backend.

Parameters:
  • fpga_family (str, optional) – The FPGA family to be used. Defaults to ‘PolarFire’.

  • part (str, optional) – The FPGA part to be used. Defaults to ‘MPF300’.

  • board (str, optional) – The target board. Defaults to ‘hw_only’.

  • clock_period (int, optional) – The clock period. Defaults to 5.

  • io_type (str, optional) – Type of implementation used. One of ‘io_parallel’ or ‘io_stream’. Defaults to ‘io_parallel’.

  • smarthls_path (str, optional) – Path to SmartHLS installation (part of Libero installation). For example: /opt/microchip/Libero_SoC_v2024.2/SmartHLS-2024.2/SmartHLS If None, installation path will be inferred from the location of shls binary. Defaults to None.

  • namespace (str, optional) – If defined, place all generated code within a namespace. Defaults to None.

  • write_weights_txt (bool, optional) – If True, writes weights to .txt files which speeds up compilation. Defaults to True.

  • write_tar (bool, optional) – If True, compresses the output directory into a .tar.gz file. Defaults to False.

Returns:

initial configuration.

Return type:

dict

get_default_flow()

The name of the default flow of the backend.

Default flow is used as the conversion target if the target flow has not been specified.

get_writer_flow()
init_base_layer(layer)
init_dense(layer)

hls4ml.backends.libero.libero_types module

class hls4ml.backends.libero.libero_types.LAPFixedPrecisionDefinition

Bases: PrecisionDefinition

definition_cpp()
class hls4ml.backends.libero.libero_types.LAPIntegerPrecisionDefinition

Bases: PrecisionDefinition

definition_cpp()
class hls4ml.backends.libero.libero_types.LAPTypeConverter

Bases: FPGAPrecisionConverter

class hls4ml.backends.libero.libero_types.LiberoArrayVariableConverter(type_converter)

Bases: ArrayVariableConverter

class hls4ml.backends.libero.libero_types.LiberoArrayVariableDefinition

Bases: VariableDefinition

definition_cpp(name_suffix='', as_reference=False)
class hls4ml.backends.libero.libero_types.LiberoInplaceArrayVariableConverter(type_converter)

Bases: ArrayVariableConverter

class hls4ml.backends.libero.libero_types.LiberoInplaceArrayVariableDefinition

Bases: VariableDefinition

definition_cpp()
class hls4ml.backends.libero.libero_types.LiberoInplaceStreamVariableConverter(type_converter)

Bases: InplaceStreamVariableConverter

class hls4ml.backends.libero.libero_types.LiberoInplaceStreamVariableDefinition

Bases: VariableDefinition

definition_cpp()
class hls4ml.backends.libero.libero_types.LiberoStreamVariableConverter(type_converter)

Bases: StreamVariableConverter

class hls4ml.backends.libero.libero_types.LiberoStreamVariableDefinition

Bases: VariableDefinition

definition_cpp(name_suffix='', as_reference=False)
class hls4ml.backends.libero.libero_types.LiberoStructWrapperVariableConverter(type_converter)

Bases: ArrayVariableConverter

class hls4ml.backends.libero.libero_types.LiberoStructWrapperVariableDefinition

Bases: VariableDefinition

definition_cpp(name_suffix='', as_reference=False, as_struct=False)

Module contents