Skip to main content

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

Examples

License

Apache-2.0 — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

svdgen-0.1.0.tar.gz (53.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

svdgen-0.1.0-py3-none-any.whl (32.6 kB view details)

Uploaded Python 3

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

Hashes for svdgen-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f7a07122e6bcc5d4f89b8e2830fd3be33a9a45103d160d8d0fc8dbf8e13e713e
MD5 f9a9d89e7fbae2a008220a0e96a2b48e
BLAKE2b-256 2ea9e911bd990c4d57e1e8d93cc27bc0fbbd68ba3832307423b45fcd82da845a

See more details on using hashes here.

Provenance

The following attestation bundles were made for svdgen-0.1.0.tar.gz:

Publisher: ci.yml on captndo/svdgen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for svdgen-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 65ab5b2fb3a1cc930ca4fb8936b24f24a4ea4abfe806cedae18fa0e0129c205a
MD5 184cac07df2e9dcb6753d3e78b19efb8
BLAKE2b-256 a2df0e98a9d2ecef84bdc21794d9b68c40fe18ab429ea176d2eab9eca32ca197

See more details on using hashes here.

Provenance

The following attestation bundles were made for svdgen-0.1.0-py3-none-any.whl:

Publisher: ci.yml on captndo/svdgen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page