Types

Once compiled, SystemRDL types are mapped to Python types as follows:

SystemRDL Type

Python Type

longint unsigned

int

bit

int

boolean

bool

string

str

accesstype

AccessType

onreadtype

OnReadType

onwritetype

OnWriteType

addressingtype

AddressingType

precedencetype

PrecedenceType

intr property modifier

InterruptType

User-defined enum

UserEnum

User-defined struct

UserStruct

arrays

list

Component ref

Node if queried using Node.get_property() after design elaboration.

Prior to design elaboration, when pre-registring UDPs, component references are specified by their specific Component class, or the generic RefType object.

RHS property reference

PropertyReference


Built-in Enumeration Types

class systemrdl.rdltypes.builtin_enums.AccessType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
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, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
rclr = 1

Cleared on read

rset = 2

Set on read

ruser = 3

User-defined read side-effect

class systemrdl.rdltypes.builtin_enums.OnWriteType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
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, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
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, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
hw = 1

Hardware writes take precedence over software

sw = 2

Software writes take precedence over hardware

class systemrdl.rdltypes.builtin_enums.InterruptType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

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 of stickybit = 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: str | None, rdl_desc: str | None)

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 using isinstance(obj, UserEnum).

classmethod define_new(name: str, members: List[UserEnumMemberContainer], _parent_scope: Component | None = 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() Component | None

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: Markdown | None = None) str | None

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() str | None

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: str | None

Enum entry’s desc property

property rdl_name: str | None

Enum entry’s name property

systemrdl.rdltypes.user_enum.is_user_enum(t: Any) bool

Test if type t is a UserEnum

Note

Returns false if t is referencing a UserEnum value member


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 using isinstance(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: Component | None = 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() Component | None

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 a UserStruct


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 and name 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

Node object that represents the component instance from which the property is being referenced.

property width: int | None

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.