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

RHS property reference

PropertyReference


Built-in Enumeration Types

class systemrdl.rdltypes.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.OnReadType(value)

An enumeration.

rclr = 1

Cleared on read

rset = 2

Set on read

ruser = 3

User-defined read side-effect

class systemrdl.rdltypes.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.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.PrecedenceType(value)

An enumeration.

hw = 1

Hardware writes take precedence over software

sw = 2

Software writes take precedence over hardware

class systemrdl.rdltypes.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 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.UserEnum(value)

All user-defined enumerations are based on this class.

UserEnum types can be identified using: is_user_enum()

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.

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 rdl_desc: Optional[str]

Enum entry’s desc property

property rdl_name: Optional[str]

Enum entry’s name property

systemrdl.rdltypes.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.UserStruct(values: Dict[str, Any])

All user-defined structs are based on this class.

UserStruct types can be identified using: is_user_struct()

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")

If necessary, a list of a UserStruct’s member names can be accessed by:

member_names = prop._members.keys()

Create an instance of the struct

values is a dictionary of {member_name : value}

classmethod define_new(name: str, members: Dict[str, Union[Type[Union[int, bool, str, BuiltinEnum, UserEnum, UserStruct, PropertyReference, Component]], ArrayPlaceholder]], is_abstract: bool = False) 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.

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

systemrdl.rdltypes.is_user_struct(t: Any) bool

Test if type t is a UserStruct


Property Reference

class systemrdl.rdltypes.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 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.