Skip to main content

Generate Header files from a SystemRDL register model

Project description

PeakRDL Raw Header

Generates a very basic header with addresses, sizes, and offsets from a SystemRDL file as a plugin to PeakRDL.

Currently supported formats:

Format Function
c Simple C header file
svh Simple SystemVerilog header file
svpkg Simple SystemVerilog package
ldh Linker script header (MEMORY + PROVIDE symbols)

Custom templates are also supported.

Installation

You can install the package via pip:

pip install peakrdl-rawheader

Or add it as a dependency in your pyproject.toml or requirements.txt e.g. with uv:

uv add peakrdl-rawheader

Usage

Example

Given the following SystemRDL input:

addrmap top {
    enum state {
        IDLE = 0;
        BUSY = 1;
    };

    reg status_reg {
        field {
            encode = state;
        } fld;
    };

    status_reg status[2];
};

The generated output will look like this:

C Header (c)

#define TOP_STATUS_BASE_ADDR(status_idx) (0x00000000 + (status_idx * 0x00000004))
#define TOP_STATUS_NUM 0x00000002
// ...
#define state__IDLE 0
#define state__BUSY 1

SystemVerilog Header (svh)

`define TOP_STATUS_BASE_ADDR(status_idx) (64'h0 + (status_idx * 64'h4))
`define TOP_STATUS_NUM 64'h2
// ...
`define STATE__IDLE 0
`define STATE__BUSY 1

SystemVerilog Package (svpkg)

function automatic longint unsigned TOP_STATUS_BASE_ADDR(input int unsigned status_idx);
    return 64'h0 + (status_idx * 64'h4);
endfunction
// ...
typedef enum logic [0:0] {
    IDLE = 1'd0,
    BUSY = 1'd1
} state_e;

Linker Header (ldh)

/* Memories */
MEMORY {
  top_array_0 (rw) : ORIGIN = 0x70000000, LENGTH = 0x00100000
  top_imem (rx) : ORIGIN = 0x00000000, LENGTH = 0x00001000
}

/* Registers */
PROVIDE(__top_status_0_base_addr__ = 0x00000000);
PROVIDE(__top_status_1_base_addr__ = 0x00000004);
PROVIDE(__top_status_num__ = 0x00000002);
PROVIDE(__top_status_stride__ = 0x00000004);

ldh supports selectively disabling either section:

  • --ldh-no-memory: skip MEMORY { ... } region emission
  • --ldh-no-symbols: skip PROVIDE(...) symbol emission

MEMORY attributes are derived from memory properties:

  • sw controls r/w
  • user-defined boolean executable controls x

Example UDP declaration in SystemRDL:

property executable {
  component = mem;
  type = boolean;
};

Releasing

Release instructions are documented in RELEASE.md.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

peakrdl_rawheader-0.2.4.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

peakrdl_rawheader-0.2.4-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file peakrdl_rawheader-0.2.4.tar.gz.

File metadata

  • Download URL: peakrdl_rawheader-0.2.4.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for peakrdl_rawheader-0.2.4.tar.gz
Algorithm Hash digest
SHA256 c5954a474bfc3f6cfc250853b37472a483802d2bc7d5aacdc04be43e72e9acfb
MD5 b1c1bc8a835ba22f93a1a7fda46fa83d
BLAKE2b-256 2689690014be2a5986918522b4619cd3ed0499d8e6086361dd1bbd0b053b44f2

See more details on using hashes here.

File details

Details for the file peakrdl_rawheader-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: peakrdl_rawheader-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for peakrdl_rawheader-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2350f36ba057a1179c6fee23c319f12ba929e79ed28c702c6787c1a4de569fea
MD5 7336a7d39194bb251281117e22b75449
BLAKE2b-256 bad7729e1d724fdccec33ebd80f6240c0182a365377596713f2ed8d05973e271

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page