PeakRDL-IPXACT

3.5.0 · active · verified Wed Apr 15

PeakRDL-IPXACT is a plugin for the systemrdl-compiler library, enabling the import and export of IP-XACT XML files to and from the SystemRDL register model. It provides functionality to parse IP-XACT descriptions into an RDL model and serialize an RDL model back into IP-XACT. The current version is 3.5.0, with a release cadence that includes frequent bug fixes and occasional minor feature updates.

Warnings

Install

Imports

Quickstart

This example demonstrates how to create a simple RDL model, compile it, export it to an IP-XACT XML file, and then import that XML file back into an RDL model using PeakRDL-IPXACT's `IPXACTExporter` and `IPXACTImporter` classes. The example uses temporary files to ensure it's self-contained and runnable.

import os
import tempfile
from pathlib import Path
from systemrdl.core import RDLCompiler
from systemrdl.ipxact.exporter import IPXACTExporter
from systemrdl.ipxact.importer import IPXACTImporter

# Create a temporary directory for test files
with tempfile.TemporaryDirectory() as tmpdir:
    tmp_path = Path(tmpdir)

    # 1. Create a dummy RDL file
    rdl_content = """
    addrmap my_block {
        reg my_reg {
            field { sw=r; hw=w; } my_field[3:0] = 4'h0;
        } @0x0;
    };
    """
    rdl_file = tmp_path / "example.rdl"
    rdl_file.write_text(rdl_content)
    print(f"Created RDL file: {rdl_file}")

    # 2. Compile the RDL file
    compiler = RDLCompiler()
    compiler.compile_file(str(rdl_file))
    root_component = compiler.top
    print(f"Compiled RDL, top component: {root_component.get_path()}")

    # 3. Export to IP-XACT XML
    exported_xml_file = tmp_path / "exported_ipxact.xml"
    exporter = IPXACTExporter()
    exporter.export(root_component, str(exported_xml_file))
    print(f"Exported to IP-XACT XML: {exported_xml_file}")

    # 4. Import the IP-XACT XML
    importer = IPXACTImporter()
    imported_component = importer.import_file(str(exported_xml_file))
    print(f"\nImported IP-XACT component name: {imported_component.name}")
    print(f"Accessing imported register: {imported_component.registers[0].name}")

print("Quickstart example completed successfully.")

view raw JSON →