Skip to content

Repository files navigation

rdlfmt

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

Documentation

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;
};

Line breaks between statements are yours — note that the first register's properties stay split and the second's stay joined. There is nothing to configure, deliberately. See What it does.

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

Or, if you already manage peakrdl with a Python tool:

uv tool install rdlfmt

Installed alongside PeakRDL, the same wheel registers a peakrdl fmt subcommand. cargo install rdlfmt works too. See Installation for Windows, PyPI and building from source.

Usage

rdlfmt regs.rdl     # rewrite in place -- the default
rdlfmt .            # every .rdl file in the tree
rdlfmt --check .    # exit 1 if anything is unformatted; the one for CI
rdlfmt --diff .     # ...and show what would change
rdlfmt -            # filter stdin to stdout

That last one is what editors want: Editor integration has format-on-save recipes for Neovim, Vim, VS Code, Zed, Helix and Emacs. Full command line in Usage.

Library

The formatter is also a library:

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

rdlfmt::syntax exposes the lexer and the lossless CST underneath. API docs on docs.rs.

License

Dual-licensed under either of

at your option.

About

A formatter for SystemRDL

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Contributors

Languages