.. image:: graphics/banner.png :alt: Banner image Introduction ============ This package implements OpenTitan regtool hjson import and export functionality for the PeakRDL toolchain. This involves the ability to translate between a SystemRDL register model and `OpenTitan hjson format `_. The two formats might not be completelly compatible between each other. The goal of the project is to ease migration from one format to another and allow reusing the tools from another toolchain. Installing ---------- Install by cloning the repo first .. code-block:: bash git clone https://github.com/Risto97/PeakRDL-opentitan.git cd PeakRDL-opentitan pip install -e . Quick Start ----------- Exporting to OpenTitan hjson ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Below is a simple example that shows how to convert a SystemRDL register model into OpenTitan hjson file for regtool. .. code-block:: python :emphasize-lines: 3, 13-14, 16 import sys from systemrdl import RDLCompiler, RDLCompileError from peakrdl_opentitan import OpenTitanExporter, Standard rdlc = RDLCompiler() try: rdlc.compile_file("path/to/my.rdl") root = rdlc.elaborate() except RDLCompileError: sys.exit(1) exporter = OpenTitanExporter( ) exporter.export(root, "path/to/output.hjson") Another option is using PeakRDL CLI `tool `_. .. code-block:: bash peakrdl opentitan -o Importing OpenTitan hjson ^^^^^^^^^^^^^^^^^^^^^^^^^ Below is a simple example of how to import an OpenTitan hjson definition into the register model. .. code-block:: python :emphasize-lines: 3, 6, 9 import sys from systemrdl import RDLCompiler, RDLCompileError from peakrdl_opentitan import OpenTitanImporter rdlc = RDLCompiler() importer = OpenTitanImporter(rdlc) try: importer.import_file("path/to/opentitan_ip.hjson") rdlc.compile_file("path/to/my.rdl") root = rdlc.elaborate() except RDLCompileError: sys.exit(1) Another option is using PeakRDL CLI `tool `_. This way the output SystemRDL file will be written instead. .. code-block:: bash peakrdl systemrdl -o Links ----- - `Source repository `_ - `Release Notes `_ - `Issue tracker `_ .. toctree:: :hidden: self importer exporter