Skip to content

Array Type

Array Type.

ArrayType

Bases: ACompositeType, Light

Array of itemtype.

Parameters:

Name Type Description Default
itemtype AType

Element Type.

required
depth int

depth.

required

Example:

import ucdp as u mem = u.ArrayType(u.UintType(16), 10) mem ArrayType(UintType(16), 10)

Arrays can be nested and combined with all other types.

class BusType(u.AStructType): ... def _build(self) -> None: ... self._add('data', u.UintType(8)) ... self._add('valid', u.BitType()) ... self._add('accept', u.BitType(), orientation=u.BWD)

structmatrix = u.ArrayType(u.ArrayType(BusType(), 10), 22) structmatrix ArrayType(ArrayType(BusType(), 10), 22)

Slicing:

structmatrix.slice_ Slice('0:21') structmatrix[0:15] ArrayType(ArrayType(BusType(), 10), 16) structmatrix[3] ArrayType(BusType(), 10) structmatrix[3][] BusType()

slice_ property

slice_

Get Slice of Matrix.

bits property

bits

Size in Bits.

is_connectable

is_connectable(other)

Check For Valid Connection To other.

Connections are only allowed to other :any:ArrayType of the same depth and type.

from ucdp import ArrayType, UintType, SintType ArrayType(UintType(8), 8).is_connectable(ArrayType(UintType(8), 8)) True ArrayType(UintType(8), 8).is_connectable(ArrayType(UintType(8), 9)) False ArrayType(UintType(8), 8).is_connectable(ArrayType(SintType(8), 8)) False