Records

Warning

The Torii API reference is a work in progress and we are actively working on improving it, however it may be deficient or missing in places.

torii.hdl.rec.DIR_FANIN = Direction.FANIN

An alias for Direction.FANIN

torii.hdl.rec.DIR_FANOUT = Direction.FANOUT

An alias for Direction.FANOUT

torii.hdl.rec.DIR_NONE = Direction.NONE

An alias for Direction.NONE

class torii.hdl.rec.Direction(value)

Signal/Subsignal Direction

class torii.hdl.rec.Record(layout: LayoutFieldT | None = None, *, name: str | None = None, fields=None, src_loc_at: int = 0)
all() Operator

Check if all bits are 1.

Returns:

1 if all bits are set, 0 otherwise.

Return type:

Value, out

any() Operator

Check if any bits are 1.

Returns:

1 if any bits are set, 0 otherwise.

Return type:

Value, out

as_signed() Operator

Conversion to signed.

Returns:

This Value reinterpreted as a signed integer.

Return type:

Value, out

as_unsigned() Operator

Conversion to unsigned.

Returns:

This Value reinterpreted as a unsigned integer.

Return type:

Value, out

bit_select(offset: Value | int, width: int) Value

Part-select with bit granularity.

Selects a constant width but variable offset part of a Value, such that successive parts overlap by all but 1 bit.

Parameters:
  • offset (Value, int) – Index of first selected bit.

  • width (int) – Number of selected bits.

Returns:

Selected part of the Value

Return type:

Part, out

bool() Operator

Conversion to boolean.

Returns:

1 if any bits are set, 0 otherwise.

Return type:

Value, out

eq(value: Value | int | bool | EnumMeta | ValueCastable | ValueLike) Assign

Assignment.

Parameters:

value (Value, in) – Value to be assigned.

Returns:

Assignment statement that can be used in combinatorial or synchronous context.

Return type:

Assign

implies(conclusion: Value | int | bool | EnumMeta | ValueCastable | ValueLike) Operator

Implication.

Returns:

0 if premise is true and conclusion is not, 1 otherwise.

Return type:

Value, out

matches(*patterns: int | str | EnumMeta) Value

Pattern matching.

Matches against a set of patterns, which may be integers or bit strings, recognizing the same grammar as Case().

Parameters:

patterns (int, str, or Enum) – Patterns to match against.

Returns:

1 if any pattern matches the value, 0 otherwise.

Return type:

Value, out

rotate_left(amount: int) Value

Rotate left by constant amount.

Parameters:

amount (int) – Amount to rotate by.

Returns:

If the amount is positive, the input rotated left. Otherwise, the input rotated right.

Return type:

Value, out

rotate_right(amount: int) Value

Rotate right by constant amount.

Parameters:

amount (int) – Amount to rotate by.

Returns:

If the amount is positive, the input rotated right. Otherwise, the input rotated right.

Return type:

Value, out

shift_left(amount: int) Value

Shift left by constant amount.

Parameters:

amount (int) – Amount to shift by.

Returns:

If the amount is positive, the input shifted left. Otherwise, the input shifted right.

Return type:

Value, out

shift_right(amount: int) Value

Shift right by constant amount.

Parameters:

amount (int) – Amount to shift by.

Returns:

If the amount is positive, the input shifted right. Otherwise, the input shifted left.

Return type:

Value, out

word_select(offset: Value | int, width: int) Value

Part-select with word granularity.

Selects a constant width but variable offset part of a Value, such that successive parts do not overlap.

Parameters:
  • offset (Value, int) – Index of first selected word.

  • width (int) – Number of selected bits.

Returns:

Selected part of the Value

Return type:

Part, out

xor() Operator

Compute pairwise exclusive-or of every bit.

Returns:

1 if an odd number of bits are set, 0 if an even number of bits are set.

Return type:

Value, out