Compiler#
- class systemrdl.RDLCompiler(**kwargs: Any)#
RDLCompiler constructor.
- Parameters:
message_printer (
MessagePrinter) – Override the default message printerwarning_flags (int) – Flags to enable warnings. See Warnings for more details.
error_flags (int) – Same as
warning_flagsbut promote them to errors instead.dedent_desc (bool) –
Automatically remove any common indentation from multi-line
descproperties.Set to True by default.
extended_dpa_type_names (bool) –
Enable extended type name generation that accounts for dynamic property assignments augmenting the type.
Set to True by default.
See Extended Type Name Generation for more details.
perl_safe_opcodes (List[str]) –
Perl preprocessor commands are executed within a Perl Safe compartment to prevent malicious code execution.
The default set of Perl opcodes allowed should be sufficient for most applications, however this option is exposed in the rare case it is necessary to override the opcode list in order to make an exception.
Default value:
[ ':base_core', ':base_mem', ':base_loop', ':base_orig', ':base_math', ':base_thread', ':filesys_read', ':sys_db', ':load', 'sort', 'tied', 'pack', 'unpack', 'reset' ]
versionchanged: (..) – 1.8: Added
dedent_descoption.versionchanged: – 1.9: Added
extended_dpa_type_namesoption.versionchanged: – 1.10: Added
perl_safe_opcodesoption.
- compile_file(path: str, incl_search_paths: List[str] | None = None, defines: Dict[str, str] | None = None) FileInfo#
Parse & compile a single file and append it to RDLCompiler’s root namespace.
If any exceptions (
RDLCompileErroror other) occur during compilation, then the RDLCompiler object should be discarded.- Parameters:
path (str) – Path to an RDL source file
incl_search_paths (List[str]) –
List of additional paths to search to resolve includes. If unset, defaults to an empty list.
Relative include paths are resolved in the following order:
Search each path specified in
incl_search_paths.Path relative to the source file performing the include.
defines (Dict[str, str]) – Dictionary of pre-defined verilog macros where the key is the macro name, and the value is the macro text.
- Raises:
RDLCompileError – If any fatal compile error is encountered.
- Returns:
File info object
- Return type:
FileInfo
Changed in version 1.20: Returns a
FileInfoobject instead ofNone
- elaborate(top_def_name: str | None = None, inst_name: str | None = None, parameters: Dict[str, RDLValue] | None = None) RootNode#
Elaborates the design for the given top-level addrmap component.
During elaboration, the following occurs:
An instance of the
$rootmeta-component is created.The addrmap component specified by
top_def_nameis instantiated as a child of$root.Expressions, parameters, and inferred address/field placements are elaborated.
Validation checks are performed.
If a design contains multiple root-level addrmaps,
elaborate()can be called multiple times in order to elaborate each individually.If any exceptions (
RDLCompileErroror other) occur during elaboration, then the RDLCompiler object should be discarded.- Parameters:
top_def_name (str) –
Explicitly choose which addrmap in the root namespace will be the top-level component.
If unset, The last addrmap defined will be chosen.
inst_name (str) – Overrides the top-component’s instantiated name. By default, instantiated name is the same as
top_def_nameparameters (dict) – Dictionary of parameter overrides for the top component instance.
- Raises:
RDLCompileError – If any fatal elaboration error is encountered
- Returns:
Elaborated root meta-component’s Node object.
- Return type:
- eval(expression: str) RDLValue#
Evaluate an RDL expression string and return its compiled value. This function is provided as a helper to simplify overriding top-level parameters during elaboration.
- Parameters:
expression (str) – This string is parsed and evaluated as a SystemRDL expression. Any references used in the expression are resolved using the current contents of the root namespace.
- Raises:
ValueError – If any parse or evaluation error occurs.
Added in version 1.8.
- list_udps() List[str]#
List all user-defined properties encountered by the compiler.
Added in version 1.12.
- msg#
Reference to the compiler’s
MessageHandlerobjectWarning
This will be deprecated in a future release. See this page for more details: SystemRDL/systemrdl-compiler#168
- preprocess_file(path: str, incl_search_paths: List[str] | None = None, defines: Dict[str, str] | None = None) FileInfo#
Preprocess a single file without compiling it.
- Parameters:
path (str) – Path to an RDL source file
incl_search_paths (List[str]) –
List of additional paths to search to resolve includes. If unset, defaults to an empty list.
Relative include paths are resolved in the following order:
Search each path specified in
incl_search_paths.Path relative to the source file performing the include.
defines (Dict[str, str]) – Dictionary of pre-defined verilog macros where the key is the macro name, and the value is the macro text.
- Raises:
RDLCompileError – If any fatal preprocessing error is encountered.
- Returns:
File info object
- Return type:
FileInfo
Added in version 1.20.
- register_udp(definition_cls: Type[UDPDefinition], soft: bool = True) None#
Pre-register a User Defined Property into the compiler.
- Parameters:
definition_cls (
systemrdl.udp.UDPDefinition) – Reference to the container class that defines your new UDP.soft (bool) – Override to False to register the UDP as a hard definition.
Added in version 1.25.