7.2.5 Miscellaneous modeling support functions

bin( num [, width])
Returns a bit string representation. If the optional width is provided, and if it is larger than the width of the default representation, the bit string is padded with the sign bit.

This function complements the standard Python conversion functions hex and oct. A binary string representation is often useful in hardware design.

concat( base [, arg ...])
Returns an intbv object formed by concatenating the arguments.

The following argument types are supported: intbv objects with a defined bit width, bool objects, signals of the previous objects, and bit strings. All these objects have a defined bit width. The first argument base is special as it doesn't need to have a defined bit width. In addition to the previously mentioned objects, unsized intbv, int and long objects are supported, as well as signals of such objects.

downrange( high [, low=0])
Generates a downward range list of integers.

This function is modeled after the standard range function, but works in the downward direction. The returned interval is half-open, with the high index not included. low is optional and defaults to zero. This function is especially useful in conjunction with the intbv class, that also works with downward indexing.

enum( arg [, arg ...][, encoding='binary'])
Returns an enumeration type.

The arguments should be string literals that represent the desired names of the enumeration type attributes. The returned type should be assigned to a type name. For example:

t_EnumType = enum('ATTR_NAME_1', 'ATTR_NAME_2', ...)
The enumeration type identifiers are available as attributes of the type name, for example: t_EnumType.ATTR_NAME_1

The optional keyword argument encoding specifies the encoding scheme used in Verilog output. The available encodings are 'binary', 'one_hot', and 'one_cold'.

instances( )
Looks up all MyHDL instances in the local name space and returns them in a list.

About this document