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;
};
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.
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 | shOr, if you already manage peakrdl with a Python tool:
uv tool install rdlfmtInstalled alongside PeakRDL, the same wheel
registers a peakrdl fmt subcommand. cargo install rdlfmt works too. See
Installation for
Windows, PyPI and building from source.
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 stdoutThat 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.
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.
Dual-licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.