hwt package

Subpackages

Submodules

hwt.code module

hwt.code_utils module

hwt.code_utils._HwIOToRtlSignal(obj)[source]
hwt.code_utils._connect_optional(src: HwIOBase, dst: HwIOBase, check_fn, dir_reverse)[source]
hwt.code_utils._mkOp(fn)[source]

Function to create variadic operator function

Parameters:

fn – function to perform binary operation

hwt.code_utils.connect_optional(src: HwIOBase, dst: HwIOBase, check_fn=<function <lambda>>)[source]

Connect interfaces and ignore all missing things

Parameters:

check_fn – filter function(hwIO0, hwIO1) which check if interfaces should be connected returns tuple (do_check, extra_connection_list)

hwt.code_utils.rename_signal(hwModule: HwModule, sig: RtlSignalBase | int | bool, name: str)[source]

Wrap signal or value in signal of specified name

Attention:

output signal is driven by new signal of a specified name this means that the assigning to a new signal does not drive a original signal

hwt.constants module

Commonly used constants during HW development.

class hwt.constants.NOT_SPECIFIED[source]

Bases: object

Constant which means that the thing is not specified

Used for optional arguments as a value which marks that the value of this argument was not specified on the place where we can not just use None

__init__()[source]

hwt.constraints module

hwt.doc_markers module

hwt.doc_markers.hwt_expr_producer(fn)[source]

Decorator which does not affect functionality. For documentation purposes it specifies that the function produces hwt expression.

hwt.doc_markers.hwt_stm_producer(fn)[source]

Decorator which does not affect functionality. For documentation purposes it specifies that the function produces hwt statement list.

hwt.doc_markers.internal(fn)[source]

Decorator which does not affect functionality but it is used as marker which tells that this object is not interesting for users and it is only used internally

hwt.hObjList module

class hwt.hObjList.HObjList(*args, **kwargs)[source]

Bases: list[T]

Regular list with some interface/unit methods delegated on items.

Main purpose of this class it let hwt.synthesizer.PropDeclrCollector.PropDeclrCollector know that this is not an regular python array and that items should be registered as HW objects.

Variables:
  • _name – name of the property on parent

  • _parent – parent HwModule/HwIO object

Note:

this object may be nested in HObjList instances but the parent and name will always corresponds to a HwModule/HwIO object, if there is any

Note:

hwt.synthesizer.PropDeclrCollector.PropDeclrCollector is used by hwt.hwIO.Interface and hwt.hwModule.HwModule

__init__(*args, **kwargs)[source]
_cleanRtlSignals(lockNonExternal=True)[source]
_getFullName() str[source]

get all name hierarchy separated by ‘.’

_getHdlName()[source]

Get name in HDL

_make_association(*args, **kwargs)[source]

Delegate _make_association on items

Note:

doc in _make_association()

_on_append(self_obj: Self, item: T, index: int)[source]
_updateHwParamsFrom(*args, **kwargs)[source]
Note:

doc in _updateHwParamsFrom()

append(item: T)[source]

Append object to the end of the list.

clear(*args, **kwargs)[source]

Remove all items from list.

extend(iterable: Iterable[T])[source]

Extend list by appending elements from the iterable.

insert(*args, **kwargs)[source]

Insert object before index.

pop(*args, **kwargs) T[source]

Remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove(*args, **kwargs)[source]

Remove first occurrence of value.

Raises ValueError if the value is not present.

reverse(*args, **kwargs)[source]

Reverse IN PLACE.

sort(*args, **kwargs)[source]

Sort the list in ascending order and return None.

The sort is in-place (i.e. the list itself is modified) and stable (i.e. the order of two equal elements is maintained).

If a key function is given, apply it once to each list item and sort them, ascending or descending, according to their function values.

The reverse flag can be set to sort in descending order.

hwt.hwIO module

hwt.hwModule module

hwt.hwParam module

class hwt.hwParam.HwParam(initval)[source]

Bases: object

Class used to mark object as a configuration of HDL module. ( The parameter instance will not appear on hwt.hwModule.HwModule instance, instead the value will appear. The parameter instance will be stored in ._hwParams property of HwModule/HwIO object)

Variables:
  • ~._initval – value of the parameter which should be used for initialization

  • ~._name – name of parameter on parent HwModule/HwIO instance

  • ~._parent – parent object instance

Attention:

the actual value is then store on parent object instance

__init__(initval)[source]
_hdlName
_initval
_name
_parent: PropDeclrCollector
get_hdl_type()[source]
get_hdl_value()[source]
get_value()[source]
set_value(v)[source]

hwt.mainBases module

class hwt.mainBases.HwIOBase[source]

Bases: object

Main base class for all interfaces

class hwt.mainBases.HwModuleBase[source]

Bases: object

Main base class for all units

class hwt.mainBases.RtlSignalBase[source]

Bases: Generic[T]

Main base class for all rtl signals

hwt.math module

hwt.math.addressAlignBestEffort(record_width: int, bus_data_width: int)[source]

Optionally extend the record width to be power of 2 and to consume smallest amount of memory possible.

hwt.math.hMax(a: HConst | RtlSignalBase | HwIOBase, b: HConst | RtlSignalBase | HwIOBase)[source]
hwt.math.hMin(a: HConst | RtlSignalBase | HwIOBase, b: HConst | RtlSignalBase | HwIOBase)[source]
hwt.math.inRange(n: int | HConst | RtlSignalBase | HwIOBase, start: int | HConst | RtlSignalBase | HwIOBase, end: int | HConst | RtlSignalBase | HwIOBase)[source]

Check if n is in range <start, end)

hwt.math.isPow2(num: int | float) bool[source]

Check if number or constant is power of two

hwt.math.log2ceil(x: int | float)[source]

Returns no of bits required to store x-1 for example x=8 returns 3

hwt.math.shiftIntArray(values: List[int | HBitsConst], item_width: int, shift: int)[source]
Parameters:
  • values – array of values which will be shifted as a whole

  • item_width – a bit length of a single item in array

  • shift – specifies how many bits the array should be shifted, << is a positive shift, >> is a negative shift

hwt.math.sizeof(_type: HdlType) int[source]

get size of type in bytes

hwt.math.toPow2Ceil(x: int)[source]

Get the smallest 2**N where 2**N >= x

hwt.math.toPow2Floor(n: int)[source]

Get the largest 2**N where 2**N <= x

hwt.mathAutoExt module

hwt.synth module