hls4ml.backends.xls package

Submodules

hls4ml.backends.xls.xls_backend module

class hls4ml.backends.xls.xls_backend.XLSBackend

Bases: FPGABackend

build(model: ModelGraph, reset: bool | None = None) Path

Generates the RTL (SystemVerilog or Verilog) code.

Parameters:
  • model (ModelGraph) – the hls4ml model.

  • reset (bool) – the reset synthesis option

compile(model: ModelGraph) None

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(part='xcu250-figd2104-2L-e', clock_period=5, clock_uncertainty='12.5%', io_type='io_parallel', write_tar=False, xls_codegen_flags=None, **kwargs) dict[str, Any]

Create an initial configuration of the XLS backend.

Parameters:
  • part (str, optional) – The FPGA part to be used. Defaults to ‘xcvu13p-flga2577-2-e’.

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

  • clock_uncertainty (str, optional) – The clock uncertainty. Defaults to 12.5%.

  • io_type (str, optional) – Type of implementation used. Only ‘io_parallel’ is currently supported.

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

  • xls_codegen_flags (dict, optional) – Flags to pass to the XLS codegen. Defaults to None.

Returns:

initial configuration.

Return type:

dict

get_default_flow() str

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.

static get_top_function(model: ModelGraph, x) tuple[Callable, None]
get_writer_flow() str

hls4ml.backends.xls.xls_layer_util module

hls4ml.backends.xls.xls_layer_util.xls_bias(node: Layer) XLSWeightVariableDefinition | None
hls4ml.backends.xls.xls_layer_util.xls_extra_func_args(node: Layer) list[XLSConstDefinition]
hls4ml.backends.xls.xls_layer_util.xls_extra_func_params(node: Layer) list[XLSConstDefinition]
hls4ml.backends.xls.xls_layer_util.xls_func_call(node: Layer) XLSFunctionCallDefinition
hls4ml.backends.xls.xls_layer_util.xls_func_name(node: Layer) XLSQualifiedName
hls4ml.backends.xls.xls_layer_util.xls_input_variables(node: Layer) list[XLSTensorVariableDefinition]
hls4ml.backends.xls.xls_layer_util.xls_min_input_rank(node: Layer) int

Minimally required rank of the input tensor. Input tensor can have a higher rank if it consists of multiple batches. NB: in the case of multiple input variables, the rank is determined by the first input variable.

hls4ml.backends.xls.xls_layer_util.xls_module_name(node: Layer) str
hls4ml.backends.xls.xls_layer_util.xls_weights(node: Layer) XLSWeightVariableDefinition | None
hls4ml.backends.xls.xls_layer_util.xls_weights_definitions(node: Layer) list[XLSConstDefinition]
hls4ml.backends.xls.xls_layer_util.xls_weights_key(node: Layer) str

hls4ml.backends.xls.xls_types module

class hls4ml.backends.xls.xls_types.XLSArrayDefinition(element_type, shape, data)

Bases: XLSDefinitionBase

xls_definition() str
class hls4ml.backends.xls.xls_types.XLSArrayTypeDefinition(element_type, shape)

Bases: XLSDefinitionBase

inner_type()

Returns: type of arr[0]

property rank
xls_definition()
class hls4ml.backends.xls.xls_types.XLSConstDefinition(name, value, type=None)

Bases: XLSDefinitionBase

xls_definition() str
class hls4ml.backends.xls.xls_types.XLSDefinitionBase

Bases: object

xls_definition() str
class hls4ml.backends.xls.xls_types.XLSFixedPointArrayDefinition(precision: XLSFixedPointPrecisionDefinitionBase, shape, data)

Bases: XLSDefinitionBase

xls_definition() str
class hls4ml.backends.xls.xls_types.XLSFixedPointDefinition(significand, precision: XLSFixedPointPrecisionDefinitionBase)

Bases: XLSDefinitionBase

classmethod from_float(value, precision: XLSFixedPointPrecisionDefinitionBase)
classmethod max_value(precision)
classmethod min_value(precision)
xls_definition() str
class hls4ml.backends.xls.xls_types.XLSFixedPointExponentPrecisionDefinition(width, signed)

Bases: XLSFixedPointPrecisionDefinitionBase

property xls_binary_exponent: int
class hls4ml.backends.xls.xls_types.XLSFixedPointFixedPrecisionDefinition(width, signed)

Bases: XLSFixedPointPrecisionDefinitionBase

property xls_binary_exponent: int
class hls4ml.backends.xls.xls_types.XLSFixedPointIntegerPrecisionDefinition(width, signed)

Bases: XLSFixedPointPrecisionDefinitionBase

property xls_binary_exponent: int
class hls4ml.backends.xls.xls_types.XLSFixedPointPrecisionDefinitionBase(width, signed)

Bases: XLSDefinitionBase, PrecisionType

property significand_type: XLSIntegerPrecisionDefinition
property xls_binary_exponent: int
xls_definition() str
property xls_num_bits: int

Number of bits for DSLX FixedPoint representation for the given precision. Note that FixedPoint is always a signed type, so we add an extra bit when converting from unsigned.

property xls_rounding_mode: RoundingMode
property xls_saturation_mode: SaturationMode
class hls4ml.backends.xls.xls_types.XLSFixedPointXnorPrecisionDefinition(width, signed)

Bases: XLSFixedPointPrecisionDefinitionBase

property xls_binary_exponent: int
class hls4ml.backends.xls.xls_types.XLSFunctionCallDefinition(name, params=None, args=None)

Bases: XLSDefinitionBase

property namespace
xls_definition()
class hls4ml.backends.xls.xls_types.XLSIntegerPrecisionDefinition(width, signed: bool)

Bases: XLSDefinitionBase

xls_definition() str
class hls4ml.backends.xls.xls_types.XLSInterfaceVarConverter(type_converter)

Bases: XLSVarConverter

convert(var)
class hls4ml.backends.xls.xls_types.XLSLookupTableDefinition(name: str, input_precision: XLSFixedPointPrecisionDefinitionBase, output_precision: XLSFixedPointPrecisionDefinitionBase, x_min, log2_step, raw_table)

Bases: XLSDefinitionBase

xls_definition(indent=None)
xls_definitions() list[XLSConstDefinition]
class hls4ml.backends.xls.xls_types.XLSPrecisionConverter

Bases: FPGAPrecisionConverter

class hls4ml.backends.xls.xls_types.XLSQualifiedName(name: str, module_name: str | None = None)

Bases: XLSDefinitionBase

xls_definition() str
class hls4ml.backends.xls.xls_types.XLSTensorVariableDefinition

Bases: XLSDefinitionBase

property xls_binary_exponent
xls_definition() str
xls_definitions() list
property xls_dims
property xls_name
property xls_name_camel
property xls_name_upper
property xls_num_bits
property xls_overflow_mode
property xls_rounding_mode
xls_type_alias(rank=None)
property xls_type_alias_bits
class hls4ml.backends.xls.xls_types.XLSTypeAliasDefinition(name, type)

Bases: XLSDefinitionBase

xls_definition()
class hls4ml.backends.xls.xls_types.XLSTypeConverter(precision_converter)

Bases: object

convert(atype)
class hls4ml.backends.xls.xls_types.XLSVarConverter(type_converter)

Bases: object

convert(var)
class hls4ml.backends.xls.xls_types.XLSWeightVarConverter(type_converter)

Bases: object

convert(weight_var, node: Layer, weights_key: str)
class hls4ml.backends.xls.xls_types.XLSWeightVariableDefinition

Bases: object

get_xls_const_definition(node: Layer, weights_key: str) XLSConstDefinition
property xls_name
hls4ml.backends.xls.xls_types.float_to_significand(x: floating[Any] | ndarray[tuple[int, ...], dtype[floating[Any]]], precision: XLSFixedPointPrecisionDefinitionBase) integer[Any] | ndarray[tuple[int, ...], dtype[integer[Any]]]

Convert floating point value to fixed point significand.

Returns: x * 2^precision.fractional

hls4ml.backends.xls.xls_types.sN(width)
hls4ml.backends.xls.xls_types.shape_tuple(shape)
hls4ml.backends.xls.xls_types.uN(width)
hls4ml.backends.xls.xls_types.xls_shape_str(shape)
hls4ml.backends.xls.xls_types.xls_str(x) str

Module contents