PeakRDL SystemRDL Exporter

1.0.1 · active · verified Thu Apr 16

PeakRDL-systemrdl is a plugin for the PeakRDL compiler that allows users to export an in-memory register model to a SystemRDL file. It currently supports version 1.0.1 and generally releases new versions based on new features, bug fixes, or compatibility updates with the main PeakRDL library.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `peakrdl-systemrdl` as an exporter plugin for the `PeakRDL` compiler. It compiles a simple RDL string into an in-memory model and then exports it to a `.systemrdl` file. Ensure `peakrdl` is also installed (e.g., `pip install peakrdl`).

import peakrdl
from peakrdl_systemrdl import SystemRDLConverter
from pathlib import Path
import os

# Create a simple RDL content string for demonstration
rdl_content = """
addrmap my_block {
    reg { 
        field { hw = r; sw = w; reset = 0; accesswidth = 32; } my_field[32];
    } my_reg;
}
"""

# Initialize the PeakRDL compiler
compiler = peakrdl.RDLCompiler()

# Compile the RDL content from a string (or a file: compiler.compile(Path("my_design.rdl")))
compiler.compile_string(rdl_content, "my_design.rdl")

# Define the output path for the SystemRDL file
output_path = Path("my_design.systemrdl")

# Export the compiled RDL model using the SystemRDLConverter
compiler.export(SystemRDLConverter, output_path)

print(f"RDL model successfully exported to {output_path.name}")

# Optional: Clean up the generated file
# os.remove(output_path)

view raw JSON →