This guide will help you set up and start using the Shoumei RTL framework.
A complete build infrastructure scaffold for formally verified hardware design:
✅ LEAN 4 Project - DSL, semantics, theorems, and code generators (stubbed) ✅ Chisel 7.x Project - Scala build configuration with modern Chisel ✅ Bootstrap Script - Automatic installation of elan, LEAN, and dependencies ✅ Build Orchestration - Makefile for end-to-end pipeline ✅ Verification Infrastructure - LEC script (stubbed, waiting for ABC) ✅ Example Circuit - Full adder defined in DSL
make setupOr directly:
python3 bootstrap.pyThis will (all without requiring sudo/system packages):
- Verify Python 3.11+
- Install
uv(Python package manager) to~/.local/bin - Install
elan(LEAN toolchain manager) to~/.elan/bin - Install LEAN 4.15.0 via elan
- Install
coursier(Scala toolchain manager) to~/.local/bin - Install
sbtand Scala toolchain to~/.local/share/coursier/bin
make lean
# or directly: lake buildExpected output: Build succeeds with warnings about sorry (stubbed proofs).
Note: The Makefile now checks for required tools and provides helpful error messages if they're missing.
provable-rtl/
├── bootstrap.py # Environment setup script
├── lean-toolchain # LEAN version (v4.15.0)
├── lakefile.lean # Lake build configuration
├── Makefile # Top-level build orchestration
│
├── lean/Shoumei/ # LEAN source code
│ ├── DSL.lean # Hardware DSL (Wire, Gate, Circuit)
│ ├── Semantics.lean # Operational semantics (stubbed)
│ ├── Theorems.lean # Proven properties (stubbed)
│ ├── Codegen/
│ │ ├── Common.lean # Shared utilities
│ │ ├── SystemVerilog.lean # SV generator (stubbed)
│ │ └── Chisel.lean # Chisel generator (stubbed)
│ └── Examples/
│ └── Adder.lean # Full adder circuit
│
├── chisel/ # Chisel/Scala project
│ ├── build.sbt # sbt configuration (Chisel 7.0.0)
│ ├── project/
│ │ └── build.properties # sbt version (1.10.5)
│ └── src/main/scala/
│ ├── Main.scala # Entry point for compilation
│ └── generated/ # Generated Chisel code goes here
│
├── output/ # Generated artifacts
│ ├── sv-from-lean/ # SystemVerilog from LEAN
│ └── sv-from-chisel/ # SystemVerilog from Chisel
│
├── verification/
│ └── run-lec.sh # Equivalence checking script
│
└── examples/
└── adder/
└── README.md # Full adder documentation
# Build LEAN code
make lean
# Generate code (TODO: not yet implemented)
make codegen
# Compile Chisel to SystemVerilog
make chisel
# Run logical equivalence checking
make lec
# Run entire pipeline
make all
# Clean all generated files
make clean
# Show help
make help- LEAN build system - All modules compile successfully
- Bootstrap script - Automates environment setup
- Project structure - Complete directory layout
- Build orchestration - Makefile coordinates all steps
- Verification scaffold - LEC script ready (waiting for ABC)
-
DSL Semantics (
Semantics.lean)evalGate- Evaluate individual gatesevalCircuit- Evaluate complete circuits- Currently use
sorryplaceholders
-
Code Generators (
Codegen/SystemVerilog.lean,Codegen/Chisel.lean)- Generate from circuit structure (currently hardcoded templates)
- Need to traverse gates and produce actual code
-
Theorems (
Theorems.lean)- Commutativity, associativity proofs
- Code generator correctness proofs
- Currently use
sorryplaceholders
-
Code Generation Executable
- Need to add Lake executable target
- Wire up code generators to file I/O
- Generate actual .sv and .scala files
-
Logical Equivalence Checking
- Install ABC:
yay -S abc-git(Arch) or build from source - Implement actual miter and SAT checking
- Install ABC:
File: lean/Shoumei/Semantics.lean
Replace sorry in evalGate:
def evalGate (g : Gate) (env : Env) : Bool :=
match g.gateType with
| GateType.AND =>
(env g.inputs[0]!) && (env g.inputs[1]!)
| GateType.OR =>
(env g.inputs[0]!) || (env g.inputs[1]!)
| GateType.NOT =>
!(env g.inputs[0]!)
| GateType.XOR =>
(env g.inputs[0]!) != (env g.inputs[1]!)File: lean/Shoumei/Semantics.lean
Implement topological evaluation in evalCircuit.
File: lean/Shoumei/Codegen/SystemVerilog.lean
Generate actual Verilog from circuit structure instead of hardcoded template.
File: lean/Shoumei/Codegen/Chisel.lean
Generate actual Chisel from circuit structure.
File: lakefile.lean
Add:
lean_exe codegen where
root := `Shoumei.Examples.Adder
supportInterpreter := trueThen create IO functions to write generated code to files.
# Arch Linux
sudo pacman -S sbt
# Then test
cd chisel && sbt compile
cd chisel && sbt run# Arch Linux
yay -S abc-git
# Then test
./verification/run-lec.sh output/sv-from-lean output/sv-from-chiselFile: lean/Shoumei/Theorems.lean
Replace sorry with actual proofs.
The full adder circuit is defined in lean/Shoumei/Examples/Adder.lean:
def fullAdderCircuit : Circuit :=
{ name := "FullAdder"
inputs := [a, b, cin]
outputs := [sum, cout]
gates := [
Gate.mkXOR a b ab_xor,
Gate.mkXOR ab_xor cin sum,
Gate.mkAND a b ab_and,
Gate.mkAND cin ab_xor cin_ab,
Gate.mkOR ab_and cin_ab cout
]
}See examples/adder/README.md for full documentation.
- Python 3.11+ - For bootstrap script
- elan - LEAN toolchain manager (installed by bootstrap.py)
- LEAN 4.15.0 - Installed via elan
- sbt 1.10+ - For Chisel compilation
- Scala 3.3.4 - Installed automatically by sbt
- ABC - For logical equivalence checking
- Chisel 7.0.0 - Installed automatically by sbt
# Add elan to PATH
export PATH="$HOME/.elan/bin:$PATH"
# Or restart your shell after running bootstrap.pyInstall sbt manually:
- Arch:
sudo pacman -S sbt - Ubuntu: https://www.scala-sbt.org/download.html
Expected! These are stubbed proofs. Replace with actual implementations.
Expected! These are in stubbed code generators that will use variables later.
The scaffold is complete and ready for development. Pick any stubbed component and start implementing!
Priority areas:
- Semantics (enables testing)
- Code generators (enables verification)
- Theorems (proves correctness)
See LICENSE file.