$ show SystemRDL/PeakRDL
PeakRDL is a CLI toolchain for control/status register (CSR) generation centered around the SystemRDL 2.0 language. It compiles register descriptions from SystemRDL or imported formats (e.g., IP-XACT) and exports synthesizable SystemVerilog RTL, C headers, UVM register models, HTML documentation, and more. The architecture is a pluggable CLI: a core dispatcher loads subcommands (built-in: dump, globals, preprocess) and external exporter/importer plugins via setuptools entry points or TOML config. Input processing handles SystemRDL compilation, parameterized components, and element arrays. The codebase demonstrates strong Python engineering with modular configuration schema validation, argument file expansion with environment variable support, and a clean plugin discovery mechanism.
The LLM identified 3 files worth highlighting for reuse:
Provides a declarative schema validation framework for TOML configuration. Defines abstract schema classes (String, Integer, Array, FixedMapping, UserMapping, Path, etc.) with a normalize() function that converts shorthand representations into full objects. The extract() method validates and extracts typed data, handling defaults for optional keys. This component is self-contained (no internal PeakRDL imports), implements a non-trivial schema pattern, and could be reused for any project requiring structured, validated configuration files.
Implements argument file expansion for CLI tools. Supports comments (#), nested -f flags with cycle detection, environment variable substitution ($VAR and ${VAR}), and a ${{this_dir}} token that expands to the directory of the current argfile. The expand_tokens() and expand_argfile() functions are standalone and reusable in any CLI tool that wants to support argument files with environment variable interpolation.
A compatibility wrapper around importlib.metadata for discovering setuptools entry points. Provides a unified interface across Python 3.7+ (falling back to pkg_resources on older versions). Used to discover importer and exporter plugins. The logic is self-contained and demonstrates handling of Python version quirks, making it a reusable pattern for any plugin-based application.