Scalar Type
Scalar Types.
- :any:
IntegerType - :any:
BitType - :any:
BoolType - :any:
RailType - :any:
UintType - :any:
SintType
IntegerType
Bases: AScalarType
Native Signed 32-Bit Integer.
Other Parameters:
| Name | Type | Description |
|---|---|---|
default |
int
|
Default Value. 0 by default. |
The width is fixed to 32.
Documentation defaults are empty by default:
import ucdp as u u.IntegerType().title u.IntegerType().descr u.IntegerType().comment
Example:
example = u.IntegerType() example IntegerType() example.width 32 example.default 0
Another Example:
example = u.IntegerType(default=8) example IntegerType(default=8) example.width 32 example.default 8
Selective Coverage Disable:
example = u.IntegerType() example IntegerType()
Range checking:
5 in IntegerType() True range(3, 10) in IntegerType() True 2**32 in IntegerType() False
Slicing:
u.IntegerType(default=31)['31:0'] IntegerType(default=31) u.IntegerType(default=31)['3:1'] UintType(3, default=7) u.IntegerType(default=31)['32:31'] Traceback (most recent call last): ... ValueError: Cannot slice bit(s) 32:31 from IntegerType(default=31) with dimension [31:0]
check
Check value for type.
Values are limited to 32-bit signed [-2147483648, 2147483647].
import ucdp as u example = u.IntegerType() example.check(0) 0 example.check(2147483647) 2147483647 example.check(2147483648) Traceback (most recent call last): ... ValueError: Value 2147483648 is not a 32-bit signed integer with range [-2147483648, 2147483647] example.check(-2147483648) -2147483648 example.check(-2147483649) Traceback (most recent call last): ... ValueError: Value -2147483649 is not a 32-bit signed integer with range [-2147483648, 2147483647]
get_hex
Return Hex Value.
import ucdp as u u.IntegerType(default=0x10FEC0DE).get_hex() Hex('0x10FEC0DE') u.IntegerType(default=0x10FEC0DE).get_hex(value=0xBEEF) Hex('0x0000BEEF') u.IntegerType().get_hex(value=9) Hex('0x00000009')
is_connectable
Check For Valid Connection To other.
Connections are only allowed to other :any:IntegerType.
The default and isolation value have no influence.
IntegerType().is_connectable(IntegerType()) True IntegerType(default=1).is_connectable(IntegerType(default=2)) True
BitType
Bases: AScalarType
Native Single Bit.
Other Parameters:
| Name | Type | Description |
|---|---|---|
default |
int
|
Default Value. 0 by default. |
The width is fixed to 1.
Example:
import ucdp as u example = u.BitType() example BitType() example.width 1 example.default 0
Another Example:
example = u.BitType(default=1) example BitType(default=1) example.width 1 example.default 1
Slicing:
u.BitType(default=1)[0] BitType(default=1) u.BitType(default=1)[32:31] Traceback (most recent call last): ... ValueError: Cannot slice bit(s) 32:31 from BitType(default=1)
check
staticmethod
Check value for type.
Values are limited to 0 and 1
import ucdp as u example = u.BitType() example.check(-1) Traceback (most recent call last): ... ValueError: Value -1 is not a single bit with range [0, 1] example.check(0) 0 example.check(1) 1 example.check(2) Traceback (most recent call last): ... ValueError: Value 2 is not a single bit with range [0, 1] example.check(False) 0 example.check(True) 1
get_hex
Return Hex Value.
import ucdp as u u.BitType().get_hex() Hex('0x0') u.BitType(default=1).get_hex() Hex('0x1') u.BitType().get_hex(value=1) Hex('0x1')
is_connectable
Check For Valid Connection To other.
Connections are only allowed to other :any:BitType.
The default and isolation value have no influence.
BitType().is_connectable(BitType()) True BitType(default=1).is_connectable(BitType(default=0)) True
A connection to an :any:UintType() of width is forbidden (requires a cast).
BitType().is_connectable(UintType(2)) False
BoolType
Bases: AScalarType
Native Boolean.
Other Parameters:
| Name | Type | Description |
|---|---|---|
default |
int
|
Default Value. 0 by default. |
The width is fixed to 1.
Example:
import ucdp as u example = u.BoolType() example BoolType() example.width 1 example.default 0
Another Example:
example = u.BoolType(default=True) example BoolType(default=True) example.width 1 example.default True
Slicing:
u.BoolType(default=True)[0] BoolType(default=True) u.BoolType()[32:31] Traceback (most recent call last): ... ValueError: Cannot slice bit(s) 32:31 from BoolType()
check
staticmethod
Check value for type.
Values are limited to 0 and 1
import ucdp as u example = u.BoolType() example.check(-1) Traceback (most recent call last): ... ValueError: Value -1 is not a boolean example.check(0) 0 example.check(1) 1 example.check(2) Traceback (most recent call last): ... ValueError: Value 2 is not a boolean example.check(False) 0 example.check(True) 1
get_hex
Return Hex Value.
import ucdp as u u.BoolType().get_hex() Hex('0x0') u.BoolType(default=True).get_hex() Hex('0x1') u.BoolType().get_hex(value=True) Hex('0x1')
is_connectable
Check For Valid Connection To other.
Connections are only allowed to other :any:BoolType.
The default and isolation value have no influence.
BoolType().is_connectable(BoolType()) True BoolType(default=True).is_connectable(BoolType(default=False)) True
A connection to an :any:UintType() is forbidden (requires a cast).
BoolType().is_connectable(UintType(1)) False
RailType
Bases: AScalarType
Voltage Rail.
Other Parameters:
| Name | Type | Description |
|---|---|---|
default |
int
|
Default Value. 0 by default. |
The width is fixed to 1.
Example:
import ucdp as u example = u.RailType() example RailType() example.width 1 example.default
Another Example:
example = u.RailType(default=1) example RailType(default=1) example.width 1 example.default 1
Slicing:
u.RailType(default=1)[0] RailType(default=1) u.RailType(default=1)[32:31] Traceback (most recent call last): ... ValueError: Cannot slice bit(s) 32:31 from RailType(default=1)
check
staticmethod
Check value for type.
Values are limited to 0 and 1
import ucdp as u example = u.RailType() example.check(-1) Traceback (most recent call last): ... ValueError: Value -1 is not a single bit with range [0, 1] example.check(0) 0 example.check(1) 1 example.check(2) Traceback (most recent call last): ... ValueError: Value 2 is not a single bit with range [0, 1] example.check(False) 0 example.check(True) 1
get_hex
Return Hex Value.
import ucdp as u u.RailType().get_hex() u.RailType(default=0).get_hex() Hex('0x0') u.RailType(default=1).get_hex() Hex('0x1') u.RailType().get_hex(value=1) Hex('0x1')
is_connectable
Check For Valid Connection To other.
Connections are only allowed to other :any:RailType.
The default and isolation value have no influence.
RailType().is_connectable(RailType()) True RailType(default=1).is_connectable(RailType(default=0)) True
A connection to an :any:BitType() is forbidden (requires a cast).
RailType().is_connectable(BitType()) False
UintType
Bases: AVecType
Vector With Unsigned Interpretation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
width |
int
|
Width in bits. |
required |
Other Parameters:
| Name | Type | Description |
|---|---|---|
default |
int
|
Default Value. 0 by default. |
Example:
import ucdp as u example = u.UintType(12) example UintType(12) example.width 12 example.default 0
Another Example:
example = u.UintType(16, default=8) example UintType(16, default=8) example.width 16 example.default 8
Selective Coverage Disable:
example = u.UintType(32) example UintType(32)
Slicing:
u.UintType(16, default=31)[15:0] UintType(16, default=31) u.UintType(16, default=31)[3:1] UintType(3, default=7) u.UintType(16, default=31)[16:15] Traceback (most recent call last): ... ValueError: Cannot slice bit(s) 16:15 from UintType(16, default=31)
check
Check value for type.
import ucdp as u example = u.UintType(8) example.check(0) 0 example.check(255) 255 example.check(256) Traceback (most recent call last): ... ValueError: Value 256 is not a 8-bit integer with range [0, 255] example.check(-1) Traceback (most recent call last): ... ValueError: Value -1 is not a 8-bit integer with range [0, 255]
get_hex
Return Hex Value.
import ucdp as u u.UintType(9).get_hex() Hex('0x000') u.UintType(9, default=0xFE).get_hex() Hex('0x0FE') u.UintType(9).get_hex(value=0xFE) Hex('0x0FE')
is_connectable
Check For Valid Connection To other.
Connections are only allowed to other :any:UintType of the same width.
The default and isolation value have no influence.
UintType(8).is_connectable(UintType(8)) True UintType(8).is_connectable(UintType(9)) False UintType(8, default=1).is_connectable(UintType(8, default=0)) True
A connection to an :any:BitType() is allowed, but :any:SintType() is forbidden (requires a cast).
UintType(1).is_connectable(BitType()) True UintType(1).is_connectable(SintType(1)) False
SintType
Bases: AVecType
Vector With Unsigned Interpretation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
width |
int
|
Width in bits. |
required |
Other Parameters:
| Name | Type | Description |
|---|---|---|
default |
int
|
Default Value. 0 by default. |
iso |
int
|
Isolation Value. Identical to default if omitted. |
Example:
import ucdp as u example = u.SintType(12) example SintType(12) example.width 12 example.default 0
Another Example:
example = u.SintType(16, default=8) example SintType(16, default=8) example.width 16 example.default 8
Slicing:
u.SintType(16, default=31)[15:0] SintType(16, default=31) u.SintType(16, default=31)[15:8] SintType(8) u.SintType(16, default=31)[3:1] UintType(3, default=7) u.SintType(16, default=31)[16:15] Traceback (most recent call last): ... ValueError: Cannot slice bit(s) 16:15 from SintType(16, default=31)
check
Check value for type.
import ucdp as u example = u.SintType(8) example.check(-128) -128 example.check(0) 0 example.check(127) 127 example.check(128) Traceback (most recent call last): ... ValueError: Value 128 is not a 8-bit signed integer with range [-128, 127] example.check(-129) Traceback (most recent call last): ... ValueError: Value -129 is not a 8-bit signed integer with range [-128, 127]
get_hex
Return Hex Value.
import ucdp as u u.SintType(9).get_hex() Hex('0x000') u.SintType(9, default=0xFE).get_hex() Hex('0x0FE') u.SintType(9, default=-20).get_hex() Hex('0x1EC') u.SintType(9).get_hex(value=0xFE) Hex('0x0FE')
is_connectable
Check For Valid Connection To other.
Connections are only allowed to other :any:SintType of the same width.
The default and isolation value have no influence.
SintType(8).is_connectable(SintType(8)) True SintType(8).is_connectable(SintType(9)) False SintType(8, default=1).is_connectable(SintType(8, default=0)) True
A connection to an :any:BitType() or :any:UintType() is forbidden (requires a cast).
SintType(1).is_connectable(BitType()) False SintType(1).is_connectable(UintType(1)) False