A modern, Python-based Hardware Description Language (HDL) that compiles to SystemVerilog via CIRCT.
- π― Type-Safe: Strong typing with
Logic,Array,Struct, andUnion - π§ Composable: Types compose infinitely -
Reg[Array[4, Struct]]just works - π Pythonic: Modern Python with PEP 695 generics -
class Adder[WIDTH](Module) - β‘ Fast: CIRCT backend for rapid compilation
- π¬ Simulation: Built-in LLVM-based simulator with VCD output
- π¦ Clean: Predictable mapping to SystemVerilog
pip install elisionfrom elision import *
class Counter(Module):
clk: INPUT[Clock]
rst: INPUT[Reset]
out: OUTPUT[Logic[32]]
def build(self, io):
count = Reg[Logic[32]]()
with io.clk.posedge, io.rst.negedge:
count.next = count + 1
io.out = count
# Generate Mlir and Verilog
counter = Counter()
print(counter.mlir())
print(counter.verilog())
# Simulate
with counter.simulate() as sim:
print(sim.llvm_ir())
print(sim.machine_asm())
sim.io.rst = 0
sim.tick()
sim.io.rst = 1
for i in range(10):
sim.tick()
print(f"count = {sim.io.out}")class Adder[WIDTH](Module):
a: INPUT[Logic[WIDTH]]
b: INPUT[Logic[WIDTH]]
out: OUTPUT[Logic[WIDTH]]
def build(self, io):
io.out = io.a + io.b
# Use with different widths
adder8 = Adder[8]()
adder32 = Adder[32]()class Point[WIDTH](Struct):
x: Logic[WIDTH]
y: Logic[WIDTH]
def __add__(self, other):
return Point[WIDTH](
x=self.x + other.x,
y=self.y + other.y
)
class PointAdder[WIDTH](Module):
a: INPUT[Point[WIDTH]]
b: INPUT[Point[WIDTH]]
out: OUTPUT[Point[WIDTH]]
def build(self, io):
io.out = io.a + io.b
addr = PointAdder[8]()
print(addr.verilog()) - Logic[N] - N-bit vectors with full arithmetic/bitwise operations
- Array[N, T] - Fixed-size arrays of any type
- Struct - Composite types with named fields
- Union - Tagged unions for multiple views of data
- Reg[T] - Registers with
.nextassignment - Wire[T] - Forward-declared wires with
.assignproperty - Mux[T] - Type-safe multiplexers
- Map[W, T] - Combinational lookup tables
- Mem[N, T] - Synchronous memories with
.readand.writemethods - Fifo[N, T] - FIFO with
.pushand.popmethods
# Create register
reg = Reg[Logic[32]]()
# With initial value
reg = Reg[Logic[32]](init=42)
# With reset value
reg = Reg[Logic[32]](reset_value=0)
# Assign in clock context
with io.clk.posedge:
reg.next = reg + 1# Create wire
w = Wire[Logic[32]]()
# Use before assignment
io.out = w
# Assign later
w.assign = io.a + io.bresult = Mux[Logic[32]](sel, true_val, false_val)See the examples/ directory for a variety of hardware designs:
- RV32I: A complete RISC-V RV32I CPU implementation.
- DSP Components: DotProduct, Pipelined MAC, and FIR filters.
- Networking: CRC-32 generator and packet protocol inspectors.
- Systolic Array: Parallel matrix multiplication engine.
- Basics: ALU, state machines, counters, and logic gates.
- Types - Logic, Array, Struct, Union
- Primitives - Reg, Wire, Mux, Mem, Fifo
- Modules - Module definition and hierarchy
- Parameterization - Generic types and modules
- Simulation: Fast JIT-based simulation and VCD tracing.
elision/
βββ elision/
β βββ core/ # Module system
β βββ types/ # Type system (Logic, Array, Struct, Union)
β βββ primitives/ # Reg, Wire, Mux
β βββ simulation/ # LLVM-based simulator
β βββ utils/ # Type utilities and parameters
βββ examples/ # Example designs
βββ test/ # Tests
βββ docs/ # Documentation
βββ README.md
- Python 3.11+
- CIRCT (installed via pip)
- llvmlite
# Install in development mode
pip install -e ".[dev]"
# Run tests
python -m pytest test/
# Run specific test
python test/test_reg.py- Types compose infinitely - Any type can contain any other type
- Python-first - Use Python's features, don't fight them
- Predictable output - Clear mapping to SystemVerilog
- Fast compilation - CIRCT backend for speed
- Type safety - Catch errors at compile time, not simulation
Current focus:
- Core type system β
- Module system β
- Primitives (Reg, Wire, Mux, Map, Mem, Fifo) β
- Simulation β
- Documentation π§
- interfaces/protocols π§
- Fsm and Pipeline π§
- Standard library π§
Contributions welcome! Areas of interest:
- Documentation improvements
- Bug reports and fixes
- Example designs
MIT License - see LICENSE file for details
For questions, issues, or discussions, please open an issue on GitHub.
Note: This is a research/educational project. For production use, consider mature alternatives.