Types
Once compiled, SystemRDL types are mapped to Python types as follows:
SystemRDL Type |
Python Type |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
User-defined |
|
User-defined |
|
arrays |
|
Component |
Prior to design elaboration, when pre-registring UDPs, component references
are specified by their specific |
RHS property reference |
Built-in Enumeration Types
- class systemrdl.rdltypes.builtin_enums.AccessType(value)
An enumeration.
- na = 1
Not Accessible
- r = 3
Read-only
- rw = 2
Readable and writable
- rw1 = 5
Readable and writable. After a reset occurs, can only be written once.
- w = 4
Write-only
- w1 = 6
Write-only. After a reset occurs, can only be written once.
- class systemrdl.rdltypes.builtin_enums.OnReadType(value)
An enumeration.
- rclr = 1
Cleared on read
- rset = 2
Set on read
- ruser = 3
User-defined read side-effect
- class systemrdl.rdltypes.builtin_enums.OnWriteType(value)
An enumeration.
- wclr = 7
All bits are cleared on write
- woclr = 2
Bitwise write one to clear
- woset = 1
Bitwise write one to set
- wot = 3
Bitwise write one to toggle
- wset = 8
All bits are set on write
- wuser = 9
Write modification is user-defined
- wzc = 5
Bitwise write zero to clear
- wzs = 4
Bitwise write zero to set
- wzt = 6
Bitwise write zero to toggle
- class systemrdl.rdltypes.builtin_enums.AddressingType(value)
An enumeration.
- compact = 1
Components are packed tightly together
- fullalign = 3
Same as regalign, except arrays are aligned to their entire size
- regalign = 2
Components are packed so each component’s start address is a multiple of its size
- class systemrdl.rdltypes.builtin_enums.PrecedenceType(value)
An enumeration.
- hw = 1
Hardware writes take precedence over software
- sw = 2
Software writes take precedence over hardware
- class systemrdl.rdltypes.builtin_enums.InterruptType(value)
A field’s interrupt type is set when using an RDL interrupt property modifier:
field f { negedge intr; };
The modifier is stored in the internal “intr type” property. (note the intentional space in the name)
It can be fetched the same way as other properties:
intr_type = my_field_node.get_property('intr type')
Note
The
nonsticky
interrupt type is intentionally omitted from this enumeration since it is not really a distinct interrupt type. Its use in SystemRDL implies an assignment ofstickybit = false
.- bothedge = 4
Interrupt on any transition
- level = 1
Interrupt when asserted and maintained
- negedge = 3
Interrupt on high-to-low transition
- posedge = 2
Interrupt on low-to-high transition
Enumerations
- class systemrdl.rdltypes.user_enum.UserEnum(name: str, value: int, rdl_name: Optional[str], rdl_desc: Optional[str])
All user-defined enum types are extended from this class and can be identified using
issubclass(obj, UserEnum)
. Enum members are instances of this class and can be identified usingisinstance(obj, UserEnum)
.- classmethod define_new(name: str, members: List[UserEnumMemberContainer], _parent_scope: Optional[Component] = None) Type[UserEnum]
Define a new UserEnum class
- Parameters
name (str) – Name of the enum type
members (UserEnumMemberContainer) – List of enum members
New in version 1.24.
- classmethod get_parent_scope() Optional[Component]
Returns reference to parent component that contains this type definition.
- classmethod get_scope_path(scope_separator: str = '::') str
Generate a string that represents this enum’s declaration namespace scope.
- Parameters
scope_separator (str) – Override the separator between namespace scopes
- property type_name: str
The type name of the struct as declared in RDL.
New in version 1.25.
- property members: Dict[str, UserEnum]
Returns a mapping of member name->value.
New in version 1.25.
- get_html_desc(markdown_inst: Optional[Markdown] = None) Optional[str]
Translates the enum’s ‘desc’ property into HTML.
Any RDLFormatCode tags used are converted to HTML. The text is also fed through a Markdown processor.
The additional Markdown processing allows designers the choice to use a more modern lightweight markup language as an alternative to SystemRDL’s “RDLFormatCode”.
- Parameters
markdown_inst (
markdown.Markdown
) – Override the class instance of the Markdown processor. See the Markdown module for more details.- Returns
HTML formatted string. If enum entry does not have a description, returns
None
- Return type
str or None
Changed in version 1.6: Added
markdown_inst
option.
- get_html_name() Optional[str]
Translates the enum’s ‘name’ property into HTML.
Any RDLFormatCode tags used are converted to HTML.
- Returns
HTML formatted string. If enum entry does not have an explicitly set name, returns
None
- Return type
str or None
New in version 1.8.
- property rdl_desc: Optional[str]
Enum entry’s
desc
property
- property rdl_name: Optional[str]
Enum entry’s
name
property
Structures
- class systemrdl.rdltypes.user_struct.UserStruct(values: Dict[str, Any])
All user-defined struct types are extended from this class and can be identified using
issubclass(obj, UserStruct)
. Once assigned a value, the class is constructed and is identified usingisinstance(obj, UserStruct)
.Values of struct members are accessed as read-only object attributes.
For example, the following RDL struct literal:
struct my_struct { longint foo; longint bar; }; ... my_struct_prop = my_struct'{foo:42, bar:123};
… can be queried in Python as follows:
prop = node.get_property('my_struct_prop') foo = prop.foo bar = getattr(prop, "bar")
Or UserStruct members names can be accessed as a mapping:
for member_name, value in prop.members.items(): ...
Create an instance of the struct
values is a dictionary of {member_name : value}
- classmethod define_new(name: str, members: Dict[str, PreElabRDLType], is_abstract: bool = False, _parent_scope: Optional[Component] = None) Type[UserStruct]
Define a new struct type derived from the current type.
- Parameters
name (str) – Name of the struct type
members ({member_name : type}) – Dictionary of struct member types.
is_abstract (bool) – If set, marks the struct as abstract.
- property type_name: str
The type name of the struct as declared in RDL.
New in version 1.24.
- classmethod get_parent_scope() Optional[Component]
Returns reference to parent component that contains this type definition.
- classmethod get_scope_path(scope_separator: str = '::') str
Generate a string that represents this enum’s declaration namespace scope.
- Parameters
scope_separator (str) – Override the separator between namespace scopes
- property members: Dict[str, Any]
Get a dictionary of struct members
New in version 1.24.
- systemrdl.rdltypes.user_struct.is_user_struct(t: Any) bool
Test if type
t
is aUserStruct
References
- class systemrdl.rdltypes.references.PropertyReference(src_ref: SourceRefBase, env: RDLEnvironment, comp_ref: ComponentRef)
Base class for all property references used in RHS of an expression.
The PropertyReference object represents the expression’s reference target. Details of the reference can be determined using its
node
andname
variables.For example, the following property assignment:
reg { ... fieldX->next = fieldY->intr; } my_reg;
… can be queried as follows:
fieldX = my_reg.get_child_by_name("fieldX") fieldY = my_reg.get_child_by_name("fieldY") next_prop = fieldX.get_property('next') print(next_prop.node == fieldY) # prints: True print(next_prop.name) # prints: "intr"
- property name: str
Name of the property being referenced
- node
Node object that represents the component instance from which the property is being referenced.
- property width: Optional[int]
Get the equivalent width of the property reference.
Returns None if reference doesn’t have a specifically defined width
New in version 1.21.
- class systemrdl.rdltypes.references.RefType
This class it not a true RDL type, but rather an object that represents all possible RHS references that can be made. This represents all possible component references, as well as RHS property references.
This is used primarily when pre-registering a UDP that has the generic ‘ref’ datatype.
New in version 1.25.