A code generator for creating Julia projects from SVD files.

This package is based on, but not a complete implementation of the specification. If you get an error or warning while using this package, please open an issue (with the SVD in question included, if possible).

Known not working:

  • Deriving registers/fields from registers/fields that are not direct siblings.
  • This is mostly because I don't have an example SVD making use of that feature.

Additionally, it's possible that some definitions generated by this package could have a bug; make sure to check the generated code for compliance with your SVD. Please do report any bugs discovered through this in an issue.


The main API of this package are generateProject and readSVD. Please check their respective docstrings for usage. In addition to these, the structs Device, Peripheral, Register, Field and CPU are also considered API. Their fieldnames are inspired by the names from the SVD specification.

Layout of generated packages

Packages generated by DeviceDefinitions.jl follow this structure (peripheral names exemplary):

├── Manifest.toml
├── Project.toml
└── src
    ├── peripherals
    │   ├── adc.jl
    │   ├── dma.jl
    │   ├── ...
    │   └── watchdog.jl
    ├── peripherals.jl
    ├── Name.jl
    └── SVD
        └── name.svd

The source SVD file is placed under src/SVD with its original name. When regenerating, only src/Name.jl, src/peripherals.jl and the src/peripherals directory will be deleted & regenerated. It is safe to add other directories to the project.

A single peripheral is stored in its own submodule, with each register of that peripheral also stored in its own subsubmodule. For example:


Control and data interface to ADC
module ADC

const baseAddress = Ptr{UInt16}(3141592)


ADC Control and Status
module CSMod

using MCUCommon: @regdef, Read, Write, ReadWrite, ReadWriteOnce
using ..ADC: baseAddress

const regAddress = baseAddress + 0x0000000000000000
@regdef struct CSStruct(regAddress)
const Reg = CSStruct


Description of Field A

# ... other fields of this register ...

end # register CS

# ... other registers ...

end # peripheral

To access the data of e.g. the CS register in peripheral ADC, use ADC.CSMod.Reg[], which will return a bitfield describing the register. To read a single field of that register, use ADC.CSMod.FieldA[]. Likewise, setting the register/field works through setindex! without indexing arguments.

Licensing of generated packages

Packages generated with DeviceDefinitions.jl are NOT licensed under the same license as DeviceDefinitions.jl and may be restricted through the license specified in the SVD used to generate the package.