Skip to main content

rdlfmt

A formatter for SystemRDL 2.0, following the PeakRDL style guide.

Before:

addrmap top{
  reg {
      field{sw=rw;
    hw=r;} data[31:0];   // payload
  }ctrl @0x0;


  reg{field{sw=r;hw=w;}status[7:0];}stat@0x4;
};

After:

addrmap top {
    reg {
        field {
            sw = rw;
            hw = r;
        } data[31:0]; // payload
    } ctrl @ 0x0;

    reg {
        field {
            sw = r; hw = w;
        } status[7:0];
    } stat @ 0x4;
};

Install

A prebuilt binary, needing no toolchain of any kind:

curl --proto '=https' --tlsv1.2 -LsSf https://github.com/fischeti/rdlfmt/releases/latest/download/rdlfmt-installer.sh | sh

On Windows:

powershell -c "irm https://github.com/fischeti/rdlfmt/releases/latest/download/rdlfmt-installer.ps1 | iex"

From PyPI, which is convenient if you already manage peakrdl this way. The package is the Rust binary in a wheel, not a Python program, so it pulls in nothing else:

uv tool install rdlfmt

Or without installing at all:

uvx rdlfmt --check .

From crates.io, if you have a Rust toolchain:

cargo install rdlfmt

Or build from source (Rust 1.88+):

cargo build --release

As a PeakRDL plugin

Installed into the same environment as PeakRDL, the wheel also registers a peakrdl fmt subcommand:

uv tool install peakrdl-cli --with rdlfmt
peakrdl fmt --check .

Usage

Format a file, rewriting it in place — this is the default, and what you want most of the time:

rdlfmt regs.rdl

Format every .rdl file in a directory tree:

rdlfmt .

Check without writing anything. Exits 1 if any file is not formatted, which is the one for CI:

rdlfmt --check .

Same, but show what would change:

rdlfmt --diff regs.rdl

Write to stdout and leave the file alone:

rdlfmt --stdout regs.rdl

With no path at all, it reads stdin and writes stdout:

cat regs.rdl | rdlfmt

What it does

The style guide's rules, applied mechanically: four spaces per level and never tabs, opening brace on the same line as the statement it belongs to, closing brace on its own line followed by the instance name, spaces around assignment and expression operators, no space before the ; that follows a }.

Line breaks between statements are yours. rdlfmt neither forces one statement per line nor joins them, so grouping you put there on purpose survives — which is also how the style guide's sw/hw exception is accommodated without a special case. Note the two registers in the example above: the first one's properties stay split, the second's stay joined. Runs of blank lines collapse to one.

There is nothing to configure, deliberately. A formatter earns its value by ending arguments, not by relocating them into a config file.

Comments and preprocessor directives survive. The parser builds a lossless concrete syntax tree, so every byte of the input is present in the tree — a `ifdef or a trailing // comment is data to be placed, not noise to be dropped.

What it will not do

Format a file it did not fully understand. If the input has syntax errors, rdlfmt reports them and refuses, rather than reformatting a structure it had to guess at.

Change your code. Every result is verified before it is returned: the output is re-lexed and compared token by token against the input, and if anything but whitespace moved, the output is withheld and you get a bug report instead of a damaged file. That check is what makes rewriting files in place the default.

Library

The formatter is also a library:

let formatted = rdlfmt::format(source)?;

rdlfmt::syntax exposes the lexer and the CST underneath, if you want the tree rather than the text. Turn off default features to drop the CLI dependencies.

License

Dual-licensed under either of

at your option.

Download files

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

Source Distribution

rdlfmt-0.1.1.tar.gz (77.7 kB view details)

Uploaded Source

Built Distributions

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

rdlfmt-0.1.1-py3-none-win_amd64.whl (406.2 kB view details)

Uploaded Python 3Windows x86-64

rdlfmt-0.1.1-py3-none-musllinux_1_2_x86_64.whl (681.1 kB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

rdlfmt-0.1.1-py3-none-musllinux_1_2_aarch64.whl (661.5 kB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

rdlfmt-0.1.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (629.6 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

rdlfmt-0.1.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (609.5 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

rdlfmt-0.1.1-py3-none-macosx_11_0_arm64.whl (570.2 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

rdlfmt-0.1.1-py3-none-macosx_10_12_x86_64.whl (584.2 kB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file rdlfmt-0.1.1.tar.gz.

File metadata

  • Download URL: rdlfmt-0.1.1.tar.gz
  • Upload date:
  • Size: 77.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for rdlfmt-0.1.1.tar.gz
Algorithm Hash digest
SHA256 770db7dbb09e10cae8e3b98f61226f4ee4e79f462dd64ae5a0d10f37cc6bcc7a
MD5 174fac57672178c723ee0b7ca4b46aab
BLAKE2b-256 eb09791920ada88412e44d7e5396798ebdc461068028ac41a726bf775e9e1f09

See more details on using hashes here.

Provenance

The following attestation bundles were made for rdlfmt-0.1.1.tar.gz:

Publisher: publish-pypi.yml on fischeti/rdlfmt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rdlfmt-0.1.1-py3-none-win_amd64.whl.

File metadata

  • Download URL: rdlfmt-0.1.1-py3-none-win_amd64.whl
  • Upload date:
  • Size: 406.2 kB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for rdlfmt-0.1.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 d4639544944b8a722872e4a6f4590fa104580674daa2e361050336959aeb4146
MD5 4c27f25ad39f032656b22bb900c24935
BLAKE2b-256 741cb1e2830271bdf0c69588304063e71ecf435201d1706b69f959c38e7675f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for rdlfmt-0.1.1-py3-none-win_amd64.whl:

Publisher: publish-pypi.yml on fischeti/rdlfmt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rdlfmt-0.1.1-py3-none-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for rdlfmt-0.1.1-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2f256ccd0b38e6852432bba55514904f3b5f3f9630d2da378098e00877705583
MD5 7a84329cd07501e1ca1d2016a2e75c1c
BLAKE2b-256 5dc3dfc379e2d92b160e95925ca033bbb4ce07b60aa433056f4ec58f9aeacb2a

See more details on using hashes here.

Provenance

The following attestation bundles were made for rdlfmt-0.1.1-py3-none-musllinux_1_2_x86_64.whl:

Publisher: publish-pypi.yml on fischeti/rdlfmt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rdlfmt-0.1.1-py3-none-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for rdlfmt-0.1.1-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 a9ca6665438e6868e78d8c7a4cb0bd5eef081911346f2752333f4cfce37994f2
MD5 8bff8df4ebcf2371eca5aa2ff2fa5b11
BLAKE2b-256 b8b296714a03e19899714a9391ac324597438086826cf6ad0b4b1eb27c703c43

See more details on using hashes here.

Provenance

The following attestation bundles were made for rdlfmt-0.1.1-py3-none-musllinux_1_2_aarch64.whl:

Publisher: publish-pypi.yml on fischeti/rdlfmt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rdlfmt-0.1.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rdlfmt-0.1.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 613b256037887a87f4796ec0f76fd83a4dff3514e46ecc9fa580b27114108e46
MD5 2a7e4583f77d1e7803e51a38e974cb5d
BLAKE2b-256 285ad003760f5efabeaa84b7dac30cfbaa02f5220259b7382722abc14264be36

See more details on using hashes here.

Provenance

The following attestation bundles were made for rdlfmt-0.1.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish-pypi.yml on fischeti/rdlfmt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rdlfmt-0.1.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for rdlfmt-0.1.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5867be58b31d2a52fdd900ec6aefe1393b73e59c0b97c29754203279d4f1648a
MD5 81b9a9f2ce6db60b82b25cff62485dd0
BLAKE2b-256 3fb202a0c99ee6fe97ec26208d2a5bb3359ae3977ae2549070bd4034b5856175

See more details on using hashes here.

Provenance

The following attestation bundles were made for rdlfmt-0.1.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish-pypi.yml on fischeti/rdlfmt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rdlfmt-0.1.1-py3-none-macosx_11_0_arm64.whl.

File metadata

  • Download URL: rdlfmt-0.1.1-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 570.2 kB
  • Tags: Python 3, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for rdlfmt-0.1.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9a460a57f0c7f04f5966d87d473dac38359c15e068a9e4965e14558fac8db42d
MD5 2e4419633f31ab28dd0c8d89ae7de078
BLAKE2b-256 da83d7b9350dfbf6acc9e185b2ec869169105a7c7ce835b51215bd2fcb750f6c

See more details on using hashes here.

Provenance

The following attestation bundles were made for rdlfmt-0.1.1-py3-none-macosx_11_0_arm64.whl:

Publisher: publish-pypi.yml on fischeti/rdlfmt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rdlfmt-0.1.1-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for rdlfmt-0.1.1-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a478b3014636ba2831a5778387d638288c0350c71183c77e7e2590d0edbf6bda
MD5 b0b939f2d881dfa0bb95a5b58e5d00e8
BLAKE2b-256 b9d43f575dde2a8a83c6dde74aee08c43d93573128fbeadcc0e1cde716ba3647

See more details on using hashes here.

Provenance

The following attestation bundles were made for rdlfmt-0.1.1-py3-none-macosx_10_12_x86_64.whl:

Publisher: publish-pypi.yml on fischeti/rdlfmt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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