OSS hardware description generation engine — parse CMSIS-SVD, patch, and render arbitrary text artifacts through templates.
Project description
svdgen
OSS hardware description generation engine — parse CMSIS-SVD, apply declarative patches, and render arbitrary text artifacts through Jinja templates.
SVD file → Parse → Normalize → Patch → Render → Write
Typical outputs: C register headers, Markdown documentation, Rust PAC fragments — anything expressible as text.
Installation
pip install svdgen
For development:
pip install -e ".[dev]"
Quick Start
1. Create svdgen.toml in your project:
[project]
name = "my-bsp"
[input]
svd = "STM32F407.svd"
[output]
dir = "generated"
[[targets]]
name = "c_headers"
template = "c_header/peripheral.h.j2"
output_path = "include/{{ peripheral.name | lower }}.h"
scope = "peripheral"
2. Generate:
svdgen generate
This parses the SVD, normalizes the model, renders one C header per peripheral, and writes them to generated/include/.
CLI
| Command | Description |
|---|---|
svdgen generate |
Run the full pipeline and write output files |
svdgen validate |
Validate config, inputs, and patches without writing files |
svdgen inspect [PERIPH[.REG[.FIELD]]] |
Inspect the normalized device model |
svdgen list peripherals|registers|fields|targets |
List model elements or configured targets |
svdgen export-model |
Export the full normalized model as JSON |
All commands accept --config / -c (default svdgen.toml), --dry-run, --verbose / -v, and --quiet / -q.
Patch Files
Patches are YAML files that modify the normalized model without editing the original SVD:
- target: "GPIOA.MODER"
set:
description: "GPIO port mode register (corrected)"
reset_value: 0xFFFFFFFF
- target: "GPIOA.MODER.MODE0"
rename: "MODER0"
- target: "GPIOB"
disable: true
Selectors are dot-separated paths: PERIPH, PERIPH.REG, or PERIPH.REG.FIELD.
Python API
import svdgen
config = svdgen.load_config("svdgen.toml")
result = svdgen.run(config)
# or step by step:
parse_result = svdgen.parse_svd("device.svd")
device = svdgen.normalize(parse_result)
patch_set = svdgen.load_patches("patches/fixups.yaml")
patched = svdgen.apply_patches(device, patch_set).device
Documentation
- User Guide — configuration reference, CLI reference, quick start
- Patch Files — YAML patch format, operations, cookbook
- Template Authoring — Jinja context, built-in filters, scope
- Python API Reference — programmatic usage
Examples
examples/svdgen.toml— minimal configexamples/stm32_project/— realistic multi-target project with patches and a custom template
License
Apache-2.0 — see LICENSE.
Project details
Release history Release notifications | RSS feed
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 svdgen-0.1.0.tar.gz.
File metadata
- Download URL: svdgen-0.1.0.tar.gz
- Upload date:
- Size: 53.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7a07122e6bcc5d4f89b8e2830fd3be33a9a45103d160d8d0fc8dbf8e13e713e
|
|
| MD5 |
f9a9d89e7fbae2a008220a0e96a2b48e
|
|
| BLAKE2b-256 |
2ea9e911bd990c4d57e1e8d93cc27bc0fbbd68ba3832307423b45fcd82da845a
|
Provenance
The following attestation bundles were made for svdgen-0.1.0.tar.gz:
Publisher:
ci.yml on captndo/svdgen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
svdgen-0.1.0.tar.gz -
Subject digest:
f7a07122e6bcc5d4f89b8e2830fd3be33a9a45103d160d8d0fc8dbf8e13e713e - Sigstore transparency entry: 1280548383
- Sigstore integration time:
-
Permalink:
captndo/svdgen@061f973288ec335b7ade36cae32ee9cfccd2b6d3 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/captndo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@061f973288ec335b7ade36cae32ee9cfccd2b6d3 -
Trigger Event:
push
-
Statement type:
File details
Details for the file svdgen-0.1.0-py3-none-any.whl.
File metadata
- Download URL: svdgen-0.1.0-py3-none-any.whl
- Upload date:
- Size: 32.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65ab5b2fb3a1cc930ca4fb8936b24f24a4ea4abfe806cedae18fa0e0129c205a
|
|
| MD5 |
184cac07df2e9dcb6753d3e78b19efb8
|
|
| BLAKE2b-256 |
a2df0e98a9d2ecef84bdc21794d9b68c40fe18ab429ea176d2eab9eca32ca197
|
Provenance
The following attestation bundles were made for svdgen-0.1.0-py3-none-any.whl:
Publisher:
ci.yml on captndo/svdgen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
svdgen-0.1.0-py3-none-any.whl -
Subject digest:
65ab5b2fb3a1cc930ca4fb8936b24f24a4ea4abfe806cedae18fa0e0129c205a - Sigstore transparency entry: 1280548387
- Sigstore integration time:
-
Permalink:
captndo/svdgen@061f973288ec335b7ade36cae32ee9cfccd2b6d3 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/captndo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@061f973288ec335b7ade36cae32ee9cfccd2b6d3 -
Trigger Event:
push
-
Statement type: