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.

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) → None
all() → Operator

Check if all bits are 1.

Return type:

Operator

Returns:

Value, out – 1 if all bits are set, 0 otherwise.

any() → Operator

Check if any bits are 1.

Return type:

Operator

Returns:

Value, out – 1 if any bits are set, 0 otherwise.

as_signed() → Operator

Conversion to signed.

Return type:

Operator

Returns:

Value, out – This Value reinterpreted as a signed integer.

as_unsigned() → Operator

Conversion to unsigned.

Return type:

Operator

Returns:

Value, out – This Value reinterpreted as a unsigned integer.

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.

Return type:

Value

Returns:

Part, out – Selected part of the Value

bool() → Operator

Conversion to boolean.

Return type:

Operator

Returns:

Value, out – 1 if any bits are set, 0 otherwise.

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

Assignment.

Parameters:

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

Return type:

Assign

Returns:

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

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

Implication.

Return type:

Operator

Returns:

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

matches(*patterns: int | str | EnumType) → 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.

Return type:

Value

Returns:

Value, out – 1 if any pattern matches the value, 0 otherwise.

rotate_left(amount: int) → Value

Rotate left by constant amount.

Parameters:

amount (int) – Amount to rotate by.

Return type:

Value

Returns:

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

rotate_right(amount: int) → Value

Rotate right by constant amount.

Parameters:

amount (int) – Amount to rotate by.

Return type:

Value

Returns:

Value, out – If the amount is positive, the input rotated right. Otherwise, the input rotated right.

shift_left(amount: int) → Value

Shift left by constant amount.

Parameters:

amount (int) – Amount to shift by.

Return type:

Value

Returns:

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

shift_right(amount: int) → Value

Shift right by constant amount.

Parameters:

amount (int) – Amount to shift by.

Return type:

Value

Returns:

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

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.

Return type:

Value

Returns:

Part, out – Selected part of the Value

xor() → Operator

Compute pairwise exclusive-or of every bit.

Return type:

Operator

Returns:

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