A DML 1.4 compiler for QEMU device models, written in Rust.
qemu-dmlc parses DML (Device Modeling Language) 1.4 source files and generates QEMU device model code.
It currently supports:
- C backend generation (
.h+.c) - Rust backend skeleton generation (
.rs) - optional Rust integration artifact snippets (
Cargo.toml,meson.build,Kconfig)
- Device, bank, register, field, and group hierarchy
- Parameters (
param) with types and default values - Methods with C-like syntax
- Session and saved state declarations
- Templates with
isinheritance - C-like expressions and control flow
- Log statements
- Conditional compilation (
#if/#else)
- Full Simics runtime semantics (interfaces, hooks, ports, subdevices)
- Complete behavior lowering for complex Simics constructs
Notes:
- Rust skeleton generation includes compatibility parsing for several Simics-style
declarations (
connect,attribute,implement,event) to reduce parser failures, but these are not yet fully semantics-complete in the backend.
cargo build --releaseThe binary will be at target/release/qemu-dmlc.
# Parse and validate a DML file
./target/release/qemu-dmlc --parse-only device.dml
# Generate C output (default language)
./target/release/qemu-dmlc --lang c device.dml -o output
# -> output.h + output.c
# Generate Rust skeleton output
./target/release/qemu-dmlc --lang rust device.dml -o output
# -> output.rs
# Generate Rust skeleton + optional integration artifact snippets
./target/release/qemu-dmlc --lang rust --rust-artifacts device.dml -o output
# -> output.rs + output.Cargo.toml + output.meson.build.snippet + output.Kconfig.snippetqemu-dmlc/
├── src/
│ ├── lib.rs # Crate root
│ ├── main.rs # CLI entry point
│ ├── parser/
│ │ ├── grammar.pest # PEG grammar
│ │ └── mod.rs # Parser implementation
│ ├── ast/
│ │ └── mod.rs # AST type definitions
│ └── codegen/
│ ├── mod.rs # Public codegen API + dispatch
│ ├── ir.rs # Shared AST lowering/model
│ ├── c_backend.rs # C backend emitter
│ └── rust_backend.rs # Rust backend emitter
├── scripts/
│ └── test_dml.sh # Regression test script
├── test/
│ └── dml_sample/ # Test DML files
├── dml_qemu.ebnf # QEMU subset grammar (EBNF)
└── doc/
└── dml_formal_grammar.ebnf # Full DML 1.4 grammar
Run unit tests:
cargo testRun regression script (multi-mode):
# Parse-only regression
./scripts/test_dml.sh --modes parse -f feat/bank
# Parse + Rust generation regression
./scripts/test_dml.sh --modes parse,rust -f feat/bank -b ./target/debug/qemu-dmlc
# Rust generation + artifact emission regression
./scripts/test_dml.sh --modes rust-artifacts -f feat/bank/register_size_param -b ./target/debug/qemu-dmlc
# Rust regression excluding qemu_model samples
./scripts/test_dml.sh --modes rust --exclude-qemu-model -b ./target/debug/qemu-dmlc
# Rust regression excluding any path by regex
./scripts/test_dml.sh --modes rust --exclude 'device/qemu_model|feat/port' -b ./target/debug/qemu-dmlc- pest 2.7 — PEG parser generator
- clap 4 — CLI argument parsing
- miette 7 — Error reporting
- thiserror 2 — Error types
- tracing — Logging
- DML 1.4 Language Specification
- QEMU Device Models