pssfmt
A formatter for the Accellera Portable Test and Stimulus Standard.
$ pip install pssfmt
$ pssfmt -i src/pss/ # rewrite in place
$ pssfmt --check src/pss/ # exit 1 if anything would change
What it promises
The safety contract is the reason a team is willing to put a formatter in a pre-commit hook, and most formatters never write it down:
- It does not change your code. Output re-lexes to the same token sequence as the input — same types, same text — and comment text is preserved character for character.
- It converges. Formatting formatted code is a no-op.
- It fails safe. If either property is violated for a file,
pssfmtemits that file unchanged with a diagnostic. A formatter that is occasionally a no-op is survivable; one that occasionally corrupts is not.
The first two are enforced over the whole shared PSS test corpus: 92 files, of
which 64 are already byte-identical to what pssfmt would write, 28 are
reformatted, and none trip the fail-safe. Every one is idempotent.
What it formats
Declarations and their bodies and headers, extend blocks, import
statements, field declarations, expressions, constraints, activities, template
arguments, enum declarations, function prototypes and bodies, the statements
inside them, match, and exec bodies.
Everything else is reproduced exactly as you wrote it. That is the design
rather than a stage of it: a construct with no rule falls back to the formatter
that changes nothing, so an incomplete rule set cannot corrupt a file, and
adding a rule cannot make an unrelated construct worse. docs/status.rst lists
what is left and why each one is waiting on a decision rather than on code.
The canonical style is measured, not preferred — each rule is derived from
counts over that corpus, and docs/style.rst shows the count behind each one.
Escape hatches
// pssfmt off
bit[8] addr; // hand-aligned, and staying that way
bit[32] data;
// pssfmt on
Plus // pssfmt ignore for a single construct and a .pssfmtignore file for
whole paths. A formatter without an off-switch is not adopted in a codebase
with hand-aligned register tables, and PSS codebases have those.
Documentation
docs/ — built with Sphinx, and the build is a test rather than a courtesy.
- Using it — quickstart, the CLI, configuration, the style and its measurements, and project status
- Developing it — the pipeline architecture and the layout-engine reference
The layout engine (src/pssfmt/layout/) is a Wadler-style pretty printer: the
Layout IR, break propagation, fits/best line breaking, greedy Fill, and a
post-layout column alignment pass. It imports nothing — not pssfmt, not
pssparser — and a test enforces that rather than a convention, which is what
let it be built before the PSS front end existed and keeps it extractable.
Building from source
$ ivpm update # resolves the dev dependency set
$ ./packages/python/bin/pip install -e . --no-deps
$ ./packages/python/bin/python -m pytest
$ make -C docs html
ivpm installs the dependencies into packages/python; the editable install
is what puts pssfmt itself on the path.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pssfmt-0.1.0.tar.gz.
File metadata
- Download URL: pssfmt-0.1.0.tar.gz
- Upload date:
- Size: 257.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
147d6e5f623dbc0e5f28427542b8bd0ccaa3e73e177e40925222eeed2af901b4
|
|
| MD5 |
970bafdb12662dbdd5557873fb0e622f
|
|
| BLAKE2b-256 |
e045ca51831ccc47688bd8f5970a05f3d6b0d624b116bc2aff29faee11701ca2
|
File details
Details for the file pssfmt-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pssfmt-0.1.0-py3-none-any.whl
- Upload date:
- Size: 169.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce3c71360e113adb2fb90ab2ccbb43f961793cd3c65513b206f65487d1804910
|
|
| MD5 |
da78db18f45366339acff86de9698ce1
|
|
| BLAKE2b-256 |
2c58296565620c8bc1aa2892be2a294d834a6124b3368aa2875cdbc8903aaab0
|