Importer
The SystemRDL Importer class provides some base utilities for constructing your own register model tree from an external source. For a more detailed walkthrough, see the Importing from JSON tutorial.
- class systemrdl.importer.RDLImporter(compiler: RDLCompiler)
Base class for external parsers to import data into the register model
- Parameters:
compiler (
RDLCompiler
) – Reference to compiler instance where the import is being performed.
- import_file(path: str) None
Importer entry point.
Extend this function to read the file and perform the import. Be sure to call
super().import_file(path)
- Parameters:
path (str) – Path to file
- add_child(parent: Component, child: Component) None
Add a child component instance to an existing parent definition or instance
New in version 1.16.
- assign_property(component: Component, prop_name: str, value: Any, src_ref: SourceRefBase | None = None) None
Assign a property to a component.
- Parameters:
prop_name (str) – Name of the SystemRDL property
value – Value to assign
src_ref (
SourceRefBase
) – Optionally provide a more detailed source reference object associated with this assignment
- register_root_component(definition: Component) None
Register a component definition with the root namespace so that it is visible to other compiled files.
- Parameters:
definition (
comp.Component
) – Component definition to register
- lookup_root_component(type_name: str) Component | None
Lookup a component definition from the root namespace. If the type name is not defined, returns
None
- compiler
Reference to the current compiler instance
- default_src_ref: SourceRefBase
Source reference used by default when not specified in importer model construction methods By default, this simply points to the file currently being imported, without any line offset information
- msg
Reference to the compiler message handler
Warning
This will be deprecated in a future release. See this page for more details: https://github.com/SystemRDL/systemrdl-compiler/issues/168
Create Definitions
New in version 1.16.
Use these methods to create a named definition, and instantiate one or more times using the methods described in the following section.
If type_name
is not specified, then an anonymous definition is created and
can therefore only be instantiated once.
- RDLImporter.create_field_definition(type_name: str | None = None, src_ref: SourceRefBase | None = None) Field
- Parameters:
type_name (str) –
src_ref (
SourceRefBase
) –
- Returns:
Component definition
- Return type:
Field
- RDLImporter.create_reg_definition(type_name: str | None = None, src_ref: SourceRefBase | None = None) Reg
- Parameters:
type_name (str) –
src_ref (
SourceRefBase
) –
- Returns:
Component definition
- Return type:
Reg
- RDLImporter.create_regfile_definition(type_name: str | None = None, src_ref: SourceRefBase | None = None) Regfile
- Parameters:
type_name (str) –
src_ref (
SourceRefBase
) –
- Returns:
Component definition
- Return type:
Regfile
- RDLImporter.create_addrmap_definition(type_name: str | None = None, src_ref: SourceRefBase | None = None) Addrmap
- Parameters:
type_name (str) –
src_ref (
SourceRefBase
) –
- Returns:
Component definition
- Return type:
Addrmap
- RDLImporter.create_mem_definition(type_name: str | None = None, src_ref: SourceRefBase | None = None) Mem
- Parameters:
type_name (str) –
src_ref (
SourceRefBase
) –
- Returns:
Component definition
- Return type:
Mem
Instantiate Definitions
New in version 1.16.
These methods take a component definition, and create an instance.
If given a named component definition, then an instantiated copy is returned. If the given component definition is anonymous, then it is converted to an instantiation in-place. Anonymous definitions can only be instantiated once.
To complete the instantiation, you must attach it to a valid parent component
using add_child()
.
- RDLImporter.instantiate_field(comp_def: Field, inst_name: str, bit_offset: int, bit_width: int, src_ref: SourceRefBase | None = None) Field
- Parameters:
comp_def (
comp.Field
) –inst_name (str) –
bit_offset (int) –
bit_width (int) –
src_ref (
SourceRefBase
) –
- Returns:
Component instance
- Return type:
Field
- RDLImporter.instantiate_reg(comp_def: Reg, inst_name: str, addr_offset: int, array_dimensions: List[int] | None = None, array_stride: int | None = None, src_ref: SourceRefBase | None = None) Reg
- Parameters:
comp_def (
comp.Reg
) –inst_name (str) –
addr_offset (int) –
array_dimensions (int) –
array_stride (int) –
src_ref (
SourceRefBase
) –
- Returns:
Component instance
- Return type:
Field
- RDLImporter.instantiate_regfile(comp_def: Regfile, inst_name: str, addr_offset: int, array_dimensions: List[int] | None = None, array_stride: int | None = None, src_ref: SourceRefBase | None = None) Regfile
- Parameters:
comp_def (
comp.Regfile
) –inst_name (str) –
addr_offset (int) –
array_dimensions (int) –
array_stride (int) –
src_ref (
SourceRefBase
) –
- Returns:
Component instance
- Return type:
Field
- RDLImporter.instantiate_addrmap(comp_def: Addrmap, inst_name: str, addr_offset: int, array_dimensions: List[int] | None = None, array_stride: int | None = None, src_ref: SourceRefBase | None = None) Addrmap
- Parameters:
comp_def (
comp.Addrmap
) –inst_name (str) –
addr_offset (int) –
array_dimensions (int) –
array_stride (int) –
src_ref (
SourceRefBase
) –
- Returns:
Component instance
- Return type:
Field
- RDLImporter.instantiate_mem(comp_def: Mem, inst_name: str, addr_offset: int, array_dimensions: List[int] | None = None, array_stride: int | None = None, src_ref: SourceRefBase | None = None) Mem
- Parameters:
comp_def (
comp.Mem
) –inst_name (str) –
addr_offset (int) –
array_dimensions (int) –
array_stride (int) –
src_ref (
SourceRefBase
) –
- Returns:
Component instance
- Return type:
Field