Python API

PeakRDL Python can be used from a python API to generate the python package. This approach may be useful if multiple operations need to be sequenced for example:

  • A build process that has multiple files dependencies

  • A build process that needs other IP-XACT inputs

  • A build process that will use other tools form the PeakRDL Suite, for example:

    • building HTML documentation with PeakRDL HTML

    • building UVM using PeakRDL UVM

Example

The following example shows the compiling an SystemRDL file and then generating the python register access layer using PeakRDL Python.

from systemrdl import RDLCompiler
from peakrdl_python.exporter import PythonExporter

# compile the systemRDL
rdlc = RDLCompiler()
rdlc.compile_file('basic.rdl')
spec = rdlc.elaborate(top_def_name='basic').top

# generate the python package register access layer
exporter = PythonExporter()
exporter.export(node=spec, path='generated_code')

PythonExporter

class peakrdl_python.exporter.PythonExporter(**kwargs)

PeakRDL Python Exporter class

Parameters:
  • user_template_dir (str) – Path to a directory where user-defined template overrides are stored.

  • user_template_context (dict) – Additional context variables to load into the template namespace.

__init__(**kwargs)
export(node: Node, path: str, asyncoutput: bool = False, skip_test_case_generation: bool = False, delete_existing_package_content: bool = True) List[str]

Generated Python Code and Testbench

Parameters:
  • node (str) – Top-level node to export. Can be the top-level RootNode or any internal AddrmapNode.

  • path (str) – Output package path.

  • asyncoutput (bool) – If set this builds a register model with async callbacks

  • skip_test_case_generation (bool) – skip generation the generation of the test cases

  • delete_existing_package_content (bool) – delete any python files in the package location, normally left over from previous operations

Returns:

modules that have been exported:

Return type:

List[str]