Sparkle HDL

Build License

Write hardware in Lean 4. Prove it correct. Generate Verilog.

A type-safe hardware description language that brings dependent types and theorem proving to hardware design.

  • Circuit description. You write a circuit as a Lean function over Signals; it simulates cycle by cycle and #synthesizeVerilog emits SystemVerilog.
  • Source β†’ IR proof. For the circuit shapes the verified entry supports, #ved_u1 returns the synthesised IR module together with a kernel-checked theorem that the module computes what your declaration computes (the supported shapes: docs/VED.md). Unsupported circuits are refused, not guessed.
  • Reuse of the proof. The theorem is an ordinary Lean theorem about a fixed term. Another Lake project can depend on Sparkle at a pinned version and use it in its own proofs.

Version: 0.2.1 (the version of the package in lakefile.lean). Depend on the tag v0.2.1 once it exists, until then on the full commit SHA named in the release notes; v0.2.0 does not contain SparkleProof. Public API and compatibility: PublicAPI.md; changes since 0.2.0, migration and known limitations: docs/releases/0.2.1.md.

Three ways in

I want toStart here
Try itQuick Start below (clone, lake build, a smoke test), or the tutorial
Depend on it from my projectdocs/reference/How_To_Use.md: version pin, toolchain, C compiler, a Lake project that produces and consumes a proof; then PublicAPI.md for what you may rely on and docs/VED.md for what is supported
Extend / contributeCONTRIBUTING.md: the entrance for a bug fix, a proof extension, downstream compatibility, docs, or a new IP, and the checks each needs

Live docs & benchmarks: the project publishes three hosted pages at verilean.github.io/sparkle:

  • πŸ“˜ Tutorial (JupyterLite) β€” the multi-chapter beginner course, runnable in-browser via xeus-lean. (Known issue: some environments fail to boot the Lean kernel or load Sparkle; when that happens, read the rendered notebooks under docs/tutorial/Notebooks/ or use the Docker path in Quick Start below.)
  • πŸ”Ž API reference (doc-gen4) β€” fully cross-linked documentation for every public definition, generated from the source with cd docbuild && lake build Sparkle:docs.
  • πŸ“ˆ Benchmarks β€” CI-driven history of the RV32 JIT vs Verilator numbers: RV32 SoC Β· LiteX PicoRV32 Β· Multi-core (8-thread)

Quick Start: the multi-chapter tutorial walks from "hello counter" through Verilog generation, proofs, and FPGA bring-up. Run it in Docker, in your browser via xeus-lean's JupyterLite, or read the rendered notebooks directly on GitHub. For the full Signal DSL syntax, see docs/reference/SignalDSL_Syntax.md.

Try it in the browser: Sparkle plugs into xeus-lean's WASM kernel via the EXTRA_WASM_DIRS extension point. See scripts/wasm/ for the staging-builder script. #synthesizeVerilog, #showVerilog, and pure Signal.atTime simulation all work under WASM; the native JIT path (Sparkle.Core.JIT.compileAndLoad) is stubbed and only available from a native lake exe build.

What to read

You want toRead
Try Sparkle for the first timethe tutorial: setup, then chapters 1–5
Look up DSL syntax or a synthesis errorSignalDSL_Syntax.md, Troubleshooting_Synthesis.md
Depend on Sparkle and use a generated proof from another projectHow_To_Use.md, then PublicAPI.md
Get a machine-checked proof that a synthesised circuit matches its Lean source, where supported (VED)tutorial chapter 7c, then docs/VED.md (current support) and PublicAPI.md (what the theorem says). The research pages are a snapshot of one revision, for readers who want the measurements and the reasoning
Use an IP blockthe IP catalog
Check known problemsKnownIssues.md
Contribute or change CICONTRIBUTING.md, BuildAndCI.md

Everything else is listed in docs/README.md. The notes/ folder holds development work records; you do not need to read it.

The Sparkle Way: Verification-Driven Design

  1. Write a pure Lean spec β€” define behaviour as pure functions.
  2. Prove properties β€” safety, liveness, fairness via Lean's theorem prover.
  3. Implement via Signal DSL β€” express the same logic using Signal combinators.
  4. Generate Verilog β€” #synthesizeVerilog / #writeVerilogDesign emit SystemVerilog.

See docs/reference/Verification_Framework.md for patterns and a worked Round-Robin Arbiter example (10 formal proofs).

Verified Synthesis: a Proof for the Circuits It Supports

#synthesizeVerilog f trusts the compiler. The verified entries (#ved_u1, #ved_u1_deep, #ved_u1_packed, #ved_u2_hier, #ved_write_checked) synthesise f once and, in the same command, build a theorem that Lean's kernel checks: the module just returned computes what f computes. When no proof can be built, the entry refuses (VED U1 REFUSED f [stage]) and returns nothing.

import SparkleProof.Single
open Sparkle.Core.Domain Sparkle.Core.Signal

def delay8 (x : Signal defaultDomain (BitVec 8)) : Signal defaultDomain (BitVec 8) :=
  Signal.register 0#8 x

#ved_u1 delay8                 -- the module and the theorem delay8.ved_u1
#print axioms delay8.ved_u1    -- [propext, Classical.choice, Quot.sound]
#check delay8.ved_u1
-- delay8.ved_u1 : U1Stmt delay8.ved_contract delay8.ved_mod delay8

#check shows what was proved. delay8.ved_mod is the module synthesis returned, and delay8.ved_contract says which of its ports is x and which is the result. U1Stmt says that the module has the expected ports and widths. It also says that, run from its initial state with reset low, on any 8-bit input stream, the module's output at every cycle equals what delay8 computes (0 at cycle 0, then the input of the previous cycle). What #ved_u1 delay8 proves, and what it does not reads it part by part.

  • What the theorem covers: the returned module (Sparkle's IR), run from its declared initial state, under any admissible evaluation order of its netlist (every wire written before it is read): for every input whose values fit their bit widths, with reset held low, at every clock cycle. It is not a claim about an arbitrary starting state, or about the body in an order that has not been checked. With #ved_write_checked, the SystemVerilog file is written from that checked module.
  • What it does not cover: the optimiser that runs afterwards, the printed SystemVerilog text, timing, or a chip. Refused circuits have no claim.
  • How far it gets today: it is partial; the current matrix of supported shapes is docs/VED.md. On a fixed set of 327 commands the research snapshot (a past revision, named in the research README) measured 243 proved (real IP 168 of 220, regression circuits 75 of 107). Large arithmetic circuits (for example some elliptic-curve point operations), memories inside sub-modules and deeper hierarchies are still mostly refused. An unconditional compiler-correctness theorem for everything the compiler accepts is not finished (why).
  • Try it in this checkout: lake build SparkleProof.Single, then lake env lean docs/research/examples/Delay8.lean. From your own project: How_To_Use.md (the fixture it uses is run by CI).

What you may depend on: PublicAPI.md. The research pages (exact statement, results, the proof-friendly circuits tutorial, open problems) describe the snapshot revision named there; read them for the reasoning, not for the current support.

IP Catalog

Sparkle ships IP cores written in the Signal DSL, most with a pure Lean spec and a simulation or co-simulation test against it. The evidence differs per IP, and it is of three different kinds: properties of the pure spec (Lean theorems about a model), source→IR theorems (only for circuits the verified entries accept; see docs/VED.md), and JIT / co-simulation tests (they compare with a reference on chosen inputs and are not proofs). The full list, with the evidence recorded per IP, is docs/ip-catalog/; this section keeps a few representative entries per family.

Compute accelerators & CPUs

BitNet b1.58 (ternary-weight LLM inference accelerator, Lean proofs about its pure spec), YOLOv8n-WorldV2 (open-vocabulary detection, golden-value validation), RV32IMA SoC (boots Linux 6.6.0 on the JIT; Lean theorems about its model, co-sim tests), SV→Sparkle transpiler. All of them: docs/ip-catalog.

Networking stack (new β€” PR #66)

UART β†’ SLIP β†’ IPv4 β†’ TCP β†’ HTTP round trip, on Tang Nano 50K; lake exe usb-webserver-jit-test runs a GET request end to end in seconds. Layer breakdown, bring-up notes and sim entry points: docs/ip-catalog/Networking.md.

Control & estimation (new β€” PR #109)

PID, LQR, IIR biquads, Kalman/H∞ with Lean certificates over ℝ transported to the fixed-point datapath (Mathlib sidecar proofs/), iverilog and JIT co-sim. Control suite, tutorial Ch 12.

Bus & interconnect

AXI4-Lite / AXI4, PCIe TLP, CAN / CAN-FD, LIN / IΒ²C / SPI, SBUS / CRSF, MIL-STD-1553B, each with a test executable; see the list (e.g. AXI4-Lite).

Crypto & wallets

AES-GCM, SHA-2 / Keccak, Ed25519 / X25519, P-256 / secp256k1, hardware signers, an Ethereum wallet stack; byte-exact against NIST / RFC vectors in their tests. The list, ECDSA signing demo, policy-enforcing signer.

Security (TLS 1.3)

TLS 1.3 client and server (simulation), interop against OpenSSL fixtures: the list.

Zero-knowledge

Merkle tree / polynomial commitment, a mini-STARK verifier, the Goldilocks field (simulation): the list.

Video

H.264 baseline encoder + decoder with a hardware MP4 muxer.

Verified infrastructure

CDC infrastructure (lock-free multi-clock simulation, SPSC queue, parallel runner), and the Drone / Humanoid SoC status pages.


Why Sparkle?

-- Write this in Lean...
def counter {dom : DomainConfig} : Signal dom (BitVec 8) :=
  Signal.circuit do
    let count ← Signal.reg 0#8
    count <~ count + 1#8
    return count

#synthesizeVerilog counter
// ...and get this Verilog
module counter (
    input  logic clk,
    input  logic rst,
    output logic [7:0] out
);
    logic [7:0] count;

    always_ff @(posedge clk) begin
        if (rst)
            count <= 8'h00;
        else
            count <= count + 8'h01;
    end

    assign out = count;
endmodule

Three powerful ideas in one language:

  1. Simulate β€” cycle-accurate functional simulation with pure Lean functions.
  2. Synthesize β€” automatic compilation to clean, synthesizable SystemVerilog.
  3. Verify β€” formal correctness proofs using Lean's theorem prover.

The Sparkle Advantage: Logical AND Physical Safety

Chisel + FIRRTL solve many logical hardware bugs (latches, comb loops) but leave you fighting timing-closure with external linters. Sparkle gives you both out of the box:

  • Logical Safety β€” Signal enforces a strict DAG for combinational logic; feedback is only possible through explicit Signal.register / Signal.loop. Pattern-match exhaustiveness catches unhandled cases at compile time. Unintended latches are impossible by construction.
  • Physical / Timing Safety β€” a built-in DRC pass (inspired by the STARC guidelines) enforces registered outputs so Static Timing Analysis is predictable and critical paths don't cross module boundaries.
  • Readable Verilog β€” Sparkle's IR keeps a 1:1 structural correspondence with your Lean code. When the DRC flags a timing issue you can actually read the generated SV to fix it.

Quick Start

Prerequisites: a glibc β‰₯ 2.34 Linux (Ubuntu 22.04+, Debian 12+, Fedora 35+), macOS, or WSL2. Older systems (e.g. Ubuntu 20.04, glibc 2.31) fail during lake build with

.../bin/cadical: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found

β€” cadical is the SAT solver bundled with the Lean toolchain (used by bv_decide / omega), and it is linked against glibc 2.34. This is a Lean-toolchain requirement, not a Sparkle one; upgrade the OS (or use the Docker path in the tutorial) if you hit it.

git clone https://github.com/Verilean/sparkle.git
cd sparkle
lake build                                # ~5 min first time
lake env lean --run Examples/Counter.lean # smoke-test

A minimal register chain:

import Sparkle
open Sparkle.Core.Domain
open Sparkle.Core.Signal

-- Three-cycle delay line, polymorphic over clock domains.
def registerChain {dom : DomainConfig}
    (input : Signal dom (BitVec 8)) : Signal dom (BitVec 8) :=
  let d1 := Signal.register 0#8 input
  let d2 := Signal.register 0#8 d1
  Signal.register 0#8 d2

#synthesizeVerilog registerChain

For the full tour β€” VCD waveforms, JIT simulation, formal equivalence commands, clock-domain crossings, and the synthesizable subset of Lean β€” work through docs/tutorial/.

Key Features

  • Cycle-accurate simulation β€” the same semantics as the emitted Verilog, runnable from Lean with #eval and sample.
  • Automatic Verilog generation β€” #synthesizeVerilog handles clocks, resets, register inference, bit-width checking, and feedback-loop resolution.
  • Formal verification ready β€” bv_decide + simp + Temporal.lean (LTL) for safety/liveness/fairness proofs directly against Signal code.
  • One-line equivalence checks β€” #verify_eq, #verify_eq_at, #verify_eq_git auto-generate theorems and discharge them with bv_decide. See docs/tutorial/notebooks/ch07-equivalence.ipynb.
  • Signal DSL with imperative feel β€” Signal.circuit macro gives you <~ register assignment without losing the functional semantics.
  • Vector / array types β€” HWVector Ξ± n with compile-time-checked indexing for register files.
  • Memory primitives β€” Signal.memory generates synchronous-write / registered-read BRAM-style RAMs.
  • Technology library support β€” primitiveModule wraps vendor cells (SRAMs, PLLs, transceivers) into the type system.
  • JIT simulation β€” sim! / #sim compile to native C++ via dlopen for 10–100Γ— faster simulation than the Lean interpreter.
  • CDC-aware multi-domain simulation β€” runSim auto-selects the fastest backend (single-domain or lock-free SPSC queue between threads).
  • Temporal logic β€” LTL operators (always, eventually, next, Until) with induction principles, enabling cycle-skipping optimisation.

Each feature is exercised in the tutorial or one of the IPs; see the links in the IP Catalog above.

Examples

# Core simulation + Verilog generation
lake env lean --run Examples/Counter.lean
lake env lean --run Examples/LoopSynthesis.lean
lake env lean --run Examples/SimpleMemory.lean

# The 16-bit Sparkle-16 CPU (ALU / RegisterFile / Core / ISA proofs)
lake env lean --run Examples/Sparkle16/Core.lean
lake env lean --run Examples/Sparkle16/ISAProofTests.lean

# Clock-domain crossing demo
lake env lean --run Examples/CDC/MultiClockSim.lean

# RV32IMA SoC, BitNet, YOLOv8, H.264 β€” run via the test suite.
# On a fresh clone the suite writes verilator/generated_soc.sv and
# generated_soc_cppsim.h itself first (lake build IP.RV32.SoCVerilog).
lake test

# Verilator: build the SoC and boot firmware
cd verilator && make build && ./obj_dir/Vrv32i_soc ../firmware/firmware.hex 500000

Each IP has a dedicated getting-started recipe in its own doc (BitNet, RV32, H264, YOLOv8, CDC).

Documentation

  • Hosted (built by CI, always up-to-date with main):
  • Generate the API reference locally with doc-gen4:
cd docbuild                  # doc-gen4 lives in this sub-project, not in the root package
lake build Sparkle:docs      # the same command the main-branch CI runs
open .lake/build/doc/index.html

Pointers to the hand-written docs:

How It Works

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Lean Signal DSL β”‚   ===, &&&, |||, hw_cond, Coe
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
       β–Ό              β–Ό                  β–Ό                   β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Simulation  β”‚ β”‚ JIT (FFI)  β”‚  β”‚  Verilator   β”‚ β”‚#synthesizeVerilogβ”‚
β”‚  .atTime t  β”‚ β”‚ C++ dlopen β”‚  β”‚ .sv β†’ C++    β”‚ β”‚  Lean β†’ IR β†’ DRC β”‚
β”‚  ~5K cyc/s  β”‚ β”‚ ~13.0M c/s β”‚  β”‚ ~11.1M c/s   β”‚ β”‚  β†’ SystemVerilog β”‚
β”‚             β”‚ β”‚+oracle:1B+ β”‚  β”‚              β”‚ β”‚                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Core abstractions:

  1. Domain β€” clock domain configuration (period, edge, reset).
  2. Signal β€” stream-based hardware values, Signal d Ξ± β‰ˆ Nat β†’ Ξ±.
  3. BitPack β€” type class for hardware serialisation.
  4. Module / Circuit β€” IR for netlists.
  5. Compiler β€” automatic Lean β†’ IR translation via metaprogramming.

Type-safety example:

-- This won't compile β€” bit-width mismatch is a compile-time error.
def broken {dom : DomainConfig} : Signal dom (BitVec 8) :=
  Signal.register (0#16) (Signal.pure 0#16)  -- Error: expected BitVec 8

def fixed {dom : DomainConfig} : Signal dom (BitVec 8) :=
  let wide : Signal dom (BitVec 16) := Signal.register 0#16 (Signal.pure 0#16)
  wide.map (BitVec.extractLsb' 0 8 Β·)  -- βœ“ explicit truncation

Known Limitations

See docs/reference/Troubleshooting_Synthesis.md and docs/known-issues/KnownIssues.md for the current list of:

  • Imperative syntax limitations (<~ inside conditionals).
  • Pattern matching on tuples in synthesizable contexts.
  • if-then-else vs Signal.mux in Signal contexts.
  • Signal.loop feedback rules.
  • bv_decide hanging inside lake build on Lean 4.28 (interactive only).

Testing

lake test

The suite's RV32 flow tests check verilator/generated_soc.sv and generated_soc_cppsim.h. When they are missing (a fresh clone), the suite first runs lake build IP.RV32.SoCVerilog (then lake env lean IP/RV32/SoCVerilog.lean if the files are still missing) and fails with the command's output if that does not produce them. Older commits, including the research release snapshot 3af3889f, do not do this: there, run lake build IP.RV32.SoCVerilog before lake test.

Runs Signal simulation, Verilog generation, vector / memory ops, temporal logic, CPU ISA proofs, BitNet golden-value validation, RV32 firmware, H.264 pipelines, YOLOv8 primitives, CDC queue stress, and the Verilator co-simulation layer.

Comparison with Other HDLs

FeatureSparkleClashChiselVerilog
LanguageLean 4HaskellScalaVerilog
Type SystemDependent TypesStrongStrongWeak
SimulationBuilt-inBuilt-inBuilt-inExternal tools
Formal VerificationNative (Lean)ExternalExternalNone
Logical Safety (no latches / comb loops)By constructionPartialVia FIRRTLNone
Physical / Timing Safety (DRC)Built-inNoneNoneSpyGlass ($$$)
Generated Verilog Readability1:1 structuralReadableObfuscated (FIRRTL)N/A
Learning curveHighHighMediumLow
Proof integrationSeamlessSeparateSeparateN/A

Project Structure

sparkle/
β”œβ”€β”€ Sparkle/      # Core library (Signal DSL, IR, Compiler, Backend, Verification)
β”œβ”€β”€ SparkleProof/ # Public proof facade (SparkleProof.Core / .Single)
β”œβ”€β”€ IP/           # IP cores (BitNet, YOLOv8, RV32, Drone, Humanoid, Video, Bus)
β”œβ”€β”€ Examples/     # Runnable demos (Counter, Sparkle16 CPU, CDC, LoopSynthesis, …)
β”œβ”€β”€ Tests/        # LSpec test suites for everything above
β”œβ”€β”€ Tools/        # SVParser, verilog! / sim! macros, Signal DSL helpers
β”œβ”€β”€ verilator/    # Verilator co-simulation backend for the RV32IMA SoC
β”œβ”€β”€ firmware/     # RV32 firmware + OpenSBI + Linux device tree
β”œβ”€β”€ c_src/        # C FFI libraries (loop memoization, JIT dlopen)
β”œβ”€β”€ scripts/      # Tutorial syntax check + golden-value generators
β”œβ”€β”€ docs/         # Hand-written docs (Tutorial, per-IP, KnownIssues, BENCHMARK)
└── lakefile.lean # Build configuration

Contributing

Sparkle is an educational project demonstrating functional hardware description, dependent types for hardware, theorem proving for verification, and compiler construction / metaprogramming.

The entrances (bug fix, proof extension, downstream compatibility, docs, new IP) and the check each change needs are in CONTRIBUTING.md.

Contributions welcome β€” good first areas:

  • Standard IP (parameterised FIFO, N-way arbiter, TileLink / AXI4 interconnect) with a spec, a co-simulation test and, where you can, proofs.
  • FPGA tape-out flow examples.
  • Additional IR optimisation passes.
  • More tutorials and worked examples.

Hitting an unhelpful #synthesizeVerilog error?

The IR elaborator's error surface is still rough. Two messages in particular bury the real cause:

Cannot synthesise <name>: not inlinable and not a hardware module
Sub-module synthesis failed for <name> (tagged @[hardware_module])

Both are emitted from Sparkle/Compiler/Elab.lean:handleDefinitionUnfold where an inner MetaM exception is swallowed by a catch _. When this hits you, follow this workflow:

  1. Look at the error in context. If <name> is one of Sparkle.Core.runCircuitH, Bind.bind, Pure.pure, Sparkle.Core.Signal.bundle*, the elaborator's unfoldDefinition? peeled the surface def but choked on something inside your DSL body (typeclass projection, an Applicative lift, a multi-arg lambda). See docs/reference/Troubleshooting_Synthesis.md Β§"Synthesis Compiler Patterns" for the patterns the elaborator does accept β€” common rewrites are listed in Β§"Fix patterns".

  2. Get the real inner error. Temporarily change the two catch _ => clauses near Sparkle/Compiler/Elab.lean:1620 and :1631 to catch e => ... e.toMessageData.toString so the inner throwError propagates into the outer message. Most "not inlinable" failures resolve to something specific like a missing pattern-match arm, an unhandled operator, or a BitVec.zeroExtend-style call the IR doesn't speak. Revert the change before committing β€” leaving raw MessageData in the user-facing error breaks the existing test fixtures.

  3. Found a new pattern that fails? Add a one-liner to docs/reference/Troubleshooting_Synthesis.md under the appropriate "NOT supported" / "Fix patterns" bullet so the next contributor sees it before they re-derive the problem. Two recent examples of the kind of entry to add are "multi-arg user-defined function via f <$> a <*> b" (rewrite the body to use Signal-native operators directly) and "(fun v => 0#m ++ v ++ 0#n)" (split into a chain of ++).

  4. If the elaborator itself should learn this case, file a followup under docs/known-issues/TODO.md Β§"Compiler / IR" so the rough surface can be filed down rather than papered over. The shipped error today is the cap on how fast a new contributor can debug their first synthesisable circuit, so work that reduces it is high-leverage.

The Sparkle/IP/Net/CRC32.lean development is a worked example: the byte-feed engine first failed with the generic "Sub-module synthesis failed" message, the inner error revealed Cannot synthesise runCircuitH, and the fix turned out to be rewriting crc32Step <$> crc <*> byte (a user-defined 2-arg function lifted through Applicative) as a Signal-native chain of ^^^/&&&/>>>/++/-.

Roadmap

Completed phases live in docs/CHANGELOG.md.

Recently landed (details in the changelog):

  • Round-trip testing on production-grade CPUs β€” the XiangShan validation campaign (bench/xiangshan/): 99.95 % parseβ†’IRβ†’re-emit coverage on both MinimalConfig and the full Kunminghu DefaultConfig, three-way co-simulation (iverilog golden vs re-emitted RTL vs CSim JIT) clean on every runnable leaf module, and a CI gate that keeps it that way.
  • Continuous compile-speed & circuit-size monitoring β€” the CI gate budgets whole-corpus compile time (the O(NΒ²) blowups it was built to catch cost us a 37Γ— slowdown once) and gates an IR-complexity metric against committed baselines, alongside yosys formal equivalence.
  • Kernel-checked emission β€” #verify_emit: the SystemVerilog Sparkle emits for a circuit is parsed back and proven (bv_decide) equivalent to its source IR.
  • Parameterised (retained-dimension) support across all backends β€” symbolic widths in the IR with explicit specialization for Verilog / CSim / SMT / CUDA (community contribution, #124/#130).

Next up:

  • Simulation support for parameters β€” exercise retained-dimension designs directly in the simulators, beyond per-configuration specialization.
  • DRC enhancements β€” better diagnostics and faster turnaround; tutorial coverage for DRC and real-FPGA deployment flows.
  • Enhanced Z3 / SMT integration β€” k-induction, CHC/Spacer invariant discovery, and Lean-side re-certification on top of the BMC bridge (M1 landed; see docs/SmtBridge-design.md).
  • GPU-based simulation for AI circuits β€” systolic-array-scale designs on the within-instance CUDA backend.
  • Fluid-dynamics simulation β€” circuits for plasma control as a driving application.
  • Monad support for high-level synthesis β€” a synthesizable effect-structured layer above Signal.circuit do.
  • Transaction-level interfaces (SystemC-style TLM) and UVM support β€” verification interop with the mainstream ecosystem.
  • Verified Standard IP β€” parameterised FIFO, N-way arbiter, TileLink / full AXI4 (bursts, IDs) interconnect.
  • GPGPU / Vector Core β€” apply the VDD framework to highly concurrent, memory-bound accelerator architectures.
  • FPGA Tape-out Flow β€” end-to-end examples deploying Sparkle-generated Linux SoCs to physical FPGAs.

Author

Junji Hashimoto β€” Twitter / X: @junjihashimoto3

License

Apache License 2.0 β€” see LICENSE.

Acknowledgments

  • Inspired by Clash HDL β€” special thanks to Christiaan Baaij for encouragement and for sharing hard-won lessons from a decade of functional-HDL compiler engineering (compile-time scalability, compile-time evaluation under lazy semantics, name/hierarchy preservation down to the RTL), which directly shaped our continuous compile-speed and circuit-size monitoring.
  • The XiangShan open-source high-performance RISC-V processor project (MulanPSL-2.0) β€” its firtool-generated RTL is our production-scale validation corpus; the SystemVerilog front-end owes its current robustness to round-tripping all 2,048 files of the Kunminghu core.
  • Community contributors β€” among them Jing Xiong (parameterised / retained-dimension width support across all backends, #124/#130), xiangze (the CUDA batch-simulation backend that seeded the GPU work), and Mark Christiaens (the verified RV32 divider proof, the sub-module instance-duplication fix, and CI robustness work). Per-phase credits live in docs/CHANGELOG.md; the full picture is the contributor graph.
  • Built with Lean 4
  • Golden-reference cycle-accurate simulation via Verilator β€” used both as the CI co-sim reference and as the "if the JIT disagrees, the JIT is wrong" arbiter throughout the test suite.
  • In-browser Lean via xeus-lean and JupyterLite β€” powers the hosted tutorial notebooks.
  • Verilog toolchain integration via iverilog (round-trip checks) and Yosys (used in Ch 8 of the tutorial for equivalence checking / FPGA fit).

Community