Skip to content

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 splitting

Workspace Crates ​

CrateResponsibility
neo-diagUnified diagnostics, UTF-8 byte spans, relatedInformation labels, and ANSI CLI rendering
neo-syntaxUTF-8 lexer, error-recovering partial-order precedence parser, and AST
neo-z3Safe RAII wrapper over z3-sys providing symbolic integer/boolean expressions, solver scopes, and clog2 axioms
neo-workspaceSourceProvider abstraction (physical + in-memory LSP overlay), neo.toml manifests, import path resolution, and reverse-dependency tracking
neo-checkUnified symbolic type, bit-width, array/slice bounds, timing, clock-domain, single-assignment, exhaustiveness, and undriven-sink checker
neo-irVersioned post-monomorphization Concrete HW-IR (IrDesign, IrModule, HwType, Expr, Stmt), JSON serialization (--format ir), and structural verifier
neo-elabConcrete compile-time evaluator and monomorphizer lowering checked @top hierarchies into verified neo-ir
neo-svHuman-readable SystemVerilog emitter (--format sv) and Dart ROHD ExternalSystemVerilogModule stub generator (--format rohd-stub)
neo-firrtlFIRRTL 3.3.0 circuit emitter (--format firrtl) with partial-LValue bit splitting for CIRCT (firtool)
neo-cliUnified neo binary providing CLI commands (neo init, neo check, neo build) and the integrated LSP server (neo lsp)

Why a Symbolic + Concrete Architecture? ​

  1. 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, where invariants). Checking scales linearly with the codebase and guarantees that any valid instantiation is well-typed, in-bounds, latch-free, and timing/CDC-sound.
  2. Monomorphizing Elaborator (neo-elab): Starting from @top modules 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).
  3. Incremental LSP Support (neo lsp): neo-workspace caches 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.