PeakRDL-regblock

1.3.1 · active · verified Thu Apr 16

PeakRDL-regblock is a free and open-source control & status register (CSR) compiler. It translates SystemRDL register descriptions into synthesizable SystemVerilog RTL modules for hardware designs. The library is actively maintained, with a recent major release (1.0.0) in April 2025, and subsequent minor releases, currently at version 1.3.1, indicating a rapid release cadence.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to programmatically compile a simple SystemRDL description and then export it into a SystemVerilog register block using the `RegblockExporter`. It specifies an AXI4-Lite CPU interface and outputs the generated files to a directory named 'generated_regblock'. Alternatively, the primary method for most users is via the `peakrdl regblock` command-line tool.

import os
from systemrdl import RDLCompiler, RDLCompileError
from peakrdl_regblock import RegblockExporter
from peakrdl_regblock.cpuif import AXI4Lite

rdl_content = """
addrmap my_registers {
    reg { field { sw=rw; } my_field; } my_reg[2];
};
"""

output_dir = './generated_regblock'

if not os.path.exists(output_dir):
    os.makedirs(output_dir)

try:
    compiler = RDLCompiler()
    compiler.compile_string(rdl_content)
    root = compiler.top.get_child_by_name('my_registers')

    exporter = RegblockExporter()
    exporter.export(
        node=root,
        output_dir=output_dir,
        cpuif_cls=AXI4Lite,
        module_name='my_register_block'
    )
    print(f"Successfully generated SystemVerilog to {output_dir}")
except RDLCompileError as e:
    print(f"SystemRDL compilation failed: {e}")
except Exception as e:
    print(f"Regblock export failed: {e}")

view raw JSON →