PeakRDL SystemRDL Exporter
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
-
ModuleNotFoundError: No module named 'peakrdl_systemrdl'
cause The `peakrdl-systemrdl` package is not installed in your current Python environment.fixInstall the package using pip: `pip install peakrdl-systemrdl`. -
ModuleNotFoundError: No module named 'peakrdl'
cause The `peakrdl` core library, which `peakrdl-systemrdl` is a plugin for, is not installed.fixInstall the `peakrdl` library: `pip install peakrdl`. -
AttributeError: module 'peakrdl_systemrdl' has no attribute 'SystemRDLConverter'
cause The `SystemRDLConverter` class was not directly exposed at the top-level package in very old versions (<0.2.0), or an incorrect import path is being used.fixEnsure you are using `from peakrdl_systemrdl import SystemRDLConverter`. If the error persists, upgrade to `peakrdl-systemrdl >= 0.2.0`. -
peakrdl.core.exception.RDLCompileError: ERROR: Invalid identifier: '<your_identifier>'
cause An identifier in your RDL source either conflicts with a SystemRDL keyword or there's an issue with external field instantiation, particularly in versions prior to 1.0.1.fixUpgrade to `peakrdl-systemrdl >= 1.0.1`. If the issue persists, review your RDL source for syntax errors or consider renaming identifiers that might clash with SystemRDL keywords.
Warnings
- breaking Python 3.6 support was officially dropped in version 1.0.0. Users on Python 3.6 or older must upgrade their Python environment to 3.7+ or remain on `peakrdl-systemrdl` < 1.0.0.
- gotcha To enable the command-line interface (CLI) functionality provided by `peakrdl-systemrdl`, you must install the library with the `[cli]` extra: `pip install peakrdl-systemrdl[cli]`.
- gotcha Identifiers in RDL models that happen to be SystemRDL keywords could lead to parsing errors in downstream tools due to improper escaping. Version 1.0.1 introduced keyword filtering to correctly escape such identifiers.
- gotcha Versions prior to 1.0.1 could generate an illegal external field instantiation in the resulting SystemRDL output, leading to invalid RDL files that fail to parse with other tools.
Install
-
pip install peakrdl-systemrdl -
pip install peakrdl-systemrdl[cli]
Imports
- SystemRDLConverter
from peakrdl_systemrdl.exporter import SystemRDLConverter
from peakrdl_systemrdl import SystemRDLConverter
Quickstart
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)