Expressions
Expression Engine.
Expr
Op
BoolOp
SOp
SliceOp
ConstExpr
ConcatExpr
Concatenation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
items |
tuple[Expr, ...]
|
Expressions. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
type_ |
Type. |
Todo
- fix inherited_members / Attributes Types
ConcatExpr Examples
Example.
>>> import ucdp as u
>>> expr = u.ConcatExpr((
... u.ConstExpr(u.UintType(5, default=5)),
... u.ConstExpr(u.UintType(7, default=1)),
... u.ConstExpr(u.UintType(16, default=3)),
... ))
>>> expr
ConcatExpr((ConstExpr(UintType(5, default=5)), ... ConstExpr(UintType(16, default=3))))
>>> int(expr)
12325
TernaryExpr
TernaryExpr Expression.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cond |
BoolOp
|
BoolOp |
required |
one |
Expr
|
Expression |
required |
other |
Expr
|
Expression |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
type_ |
BaseScalarTypes
|
Type. |
TernaryExpr Examples
Example.
>>> import ucdp as u
>>> cond = u.Signal(u.UintType(2), 'if_s') == u.ConstExpr(UintType(2, default=1))
>>> one = u.Signal(u.UintType(16, default=10), 'one_s')
>>> other = u.Signal(u.UintType(16, default=20), 'other_s')
>>> expr = TernaryExpr(cond=cond, one=one, other=other)
>>> expr
TernaryExpr(BoolOp(Signal(UintType(2), 'if_s'), ... Signal(UintType(16, default=20), 'other_s'))
>>> int(expr)
20
>>> expr.type_
UintType(16, default=10)
Log2Expr
Ceiling Logarithm to base of 2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expr |
Expr
|
Expression |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
type_ |
BaseScalarTypes
|
Type. |
Log2Expr Examples
Example.
>>> import ucdp as u
>>> expr = u.Log2Expr(u.ConstExpr(u.UintType(5, default=5)))
>>> expr
Log2Expr(ConstExpr(UintType(5, default=5)))
>>> int(expr)
2
>>> expr.type_
UintType(5, default=5)
MinimumExpr
Smallest Value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
items |
tuple[Expr, ...]
|
Items |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
type_ |
BaseScalarTypes
|
Type. |
MinimumExpr Examples
Example.
>>> import ucdp as u
>>> expr = u.MinimumExpr((
... u.ConstExpr(u.UintType(5, default=5)),
... u.ConstExpr(u.UintType(7, default=1)),
... u.ConstExpr(u.UintType(16, default=3)),
... ))
>>> expr
MinimumExpr((ConstExpr(UintType(5, default=5)), ... ConstExpr(UintType(16, default=3))))
>>> int(expr)
1
>>> expr.type_
UintType(5, default=5)
MaximumExpr
Largest Value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
items |
tuple[Expr, ...]
|
Items |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
type_ |
BaseScalarTypes
|
Type. |
MaximumExpr Examples
Example.
>>> import ucdp as u
>>> expr = u.MaximumExpr((
... u.ConstExpr(u.UintType(5, default=5)),
... u.ConstExpr(u.UintType(7, default=1)),
... u.ConstExpr(u.UintType(16, default=3)),
... ))
>>> expr
MaximumExpr((ConstExpr(UintType(5, default=5)), ... ConstExpr(UintType(16, default=3))))
>>> int(expr)
5
>>> expr.type_
UintType(5, default=5)