Compiler Architecture
Neo is implemented as a modular Rust compiler and Language Server workspace. Rather than embedding hardware generation inside a general-purpose host language (where compile-time errors and elaboration-time errors are split across two phases), Neo provides a single unified pipeline that verifies parameterized designs symbolically before elaborating them to concrete hardware.
Compilation Pipeline
.neo source files + neo.toml
│
├─▶ neo-syntax UTF-8 lexer, partial-order precedence parser, AST
├─▶ neo-workspace Manifest discovery, module-path resolution, incremental dep graph
├─▶ neo-check Unified symbolic Z3 frontend (types, widths, bounds, timing, CDC,
│ assignability, exhaustiveness, undriven sinks)
│
▼ (only if zero errors)
├─▶ neo-elab Compile-time evaluator & monomorphizing elaborator
├─▶ neo-ir Versioned Concrete HW-IR (schema v1) + structural IR verifier
│
▼
├─▶ neo-sv Synthesizable IEEE 1800-2012/2017 SystemVerilog + Dart ROHD stubs
└─▶ neo-firrtl FIRRTL 3.3.0 emitter (for CIRCT / firtool) with partial-LValue splittingWorkspace Crates
| Crate | Responsibility |
|---|---|
neo-diag | Unified diagnostics, UTF-8 byte spans, relatedInformation labels, and ANSI CLI rendering |
neo-syntax | UTF-8 lexer, error-recovering partial-order precedence parser, and AST |
neo-z3 | Safe RAII wrapper over z3-sys providing symbolic integer/boolean expressions, solver scopes, and clog2 axioms |
neo-workspace | SourceProvider abstraction (physical + in-memory LSP overlay), neo.toml manifests, import path resolution, and reverse-dependency tracking |
neo-check | Unified symbolic type, bit-width, array/slice bounds, timing, clock-domain, single-assignment, exhaustiveness, and undriven-sink checker |
neo-ir | Versioned post-monomorphization Concrete HW-IR (IrDesign, IrModule, HwType, Expr, Stmt), JSON serialization (--format ir), and structural verifier |
neo-elab | Concrete compile-time evaluator and monomorphizer lowering checked @top hierarchies into verified neo-ir |
neo-sv | Human-readable SystemVerilog emitter (--format sv) and Dart ROHD ExternalSystemVerilogModule stub generator (--format rohd-stub) |
neo-firrtl | FIRRTL 3.3.0 circuit emitter (--format firrtl) with partial-LValue bit splitting for CIRCT (firtool) |
neo-cli | Unified neo binary providing CLI commands (neo init, neo check, neo build) and the integrated LSP server (neo lsp) |
Why a Symbolic + Concrete Architecture?
- Symbolic Frontend (
neo-check): Every module, struct, union, and interface is checked once in topological file order by instantiating its parameters as symbolic Z3 constants constrained by their types (UInt >= 0,Pos >= 1,whereinvariants). Checking scales linearly with the codebase and guarantees that any valid instantiation is well-typed, in-bounds, latch-free, and timing/CDC-sound. - Monomorphizing Elaborator (
neo-elab): Starting from@topmodules in the entry file, the elaborator evaluates all compile-time parameters concretely, caches specializations by(file, item, concrete_args), flattens aggregate types with deterministic LSB-first layouts, and emits verified Concrete HW-IR (neo-ir). - Incremental LSP Support (
neo lsp):neo-workspacecaches parsed ASTs by content hash and tracks forward/reverse file dependencies so the LSP server can quickly re-check edited files and their transitive dependents while serving live diagnostics, hover info, definitions, references, symbols, and completions.
See Symbolic Validator and Elaboration & Backends for details on each stage.