Skip to content

Elaboration & Backends ​

When neo check reports zero errors, neo build runs the monomorphizing elaborator (neo-elab), validates the resulting Concrete HW-IR (neo-ir), and invokes the selected target backend.

Monomorphizing Elaboration (neo-elab) ​

  1. Entry Points: The elaborator finds all @top modules in the entry file (or the single module specified via --top <MODULE>). A @top module may take any number of Timing parameters, and no other parameter types (such as @top module Top, @top module Top(t: Timing), or @top module Dual(t_a: Timing, t_b: Timing)).
  2. Specialization & Caching: Every module instantiation mod u = Sub(arg0, arg1, ...) evaluates its compile-time arguments concretely and caches the resulting IR module keyed by (file_id, item_idx, concrete_args). Identical specializations share a single generated module definition; distinct parameter sets receive deterministic mangled names.
  3. Type Flattening (LSB-First): Composite types (Struct, Tuple, Array, Union, Option) are lowered to concrete packed bit vectors with well-defined bit slices:
    • Struct, Tuple, Array: LSB-first (field_0 / .0 / [0] at bit 0).
    • Union / Option(T): [data (MSB), tag (LSB)].
    • Interface ports are flattened into <intf>_<field> ports with appropriate directions.
  4. On-Demand __defaultClock:
    • Modules that only contain combinational logic (assign, comb) or only use explicit custom Clock ports emit no __defaultClock port.
    • Modules using an implicit-clock seq { ... }, Reg(...), or instantiating a submodule that requires __defaultClock automatically add and thread input logic __defaultClock.
  5. Zero-Width Elision: Bits(0), Int(0), and empty aggregates (width == 0) are cleanly elided during emission without invalid [0:-1] declarations.

Versioned Concrete HW-IR (--format ir) ​

The elaborator produces an IrDesign (currently schema version 1) and runs verify_design to guarantee structural invariants (valid signal/module references, matching widths, valid slice bounds, and well-formed clock edges) before any backend runs.

Passing --format ir serializes this verified IR to pretty-printed JSON (.neo.ir.json), enabling external analysis tools, custom passes, or reproducible golden testing.

SystemVerilog Backend (--format sv) ​

neo-sv emits clean, human-readable, synthesizable IEEE 1800-2012/2017 SystemVerilog:

  • Preserves module hierarchy, port names, and local signal names (sanitizing any reserved SystemVerilog/FIRRTL keywords).
  • Emits assign statements, always_comb blocks (with latch-safe pre-initialization where needed for linters like Verilator -Wall), and always_ff @(posedge <clk>) blocks.
  • Translates signed comparisons (.slt, .slte, .sgt, .sgte) and arithmetic right shift (>>>) using $signed(...).
  • Translates Array.select(idx) into bounds-safe multiplexing returning 0 for out-of-range indices when array length is not a power of two.

FIRRTL 3.3.0 Backend (--format firrtl) ​

neo-firrtl emits FIRRTL 3.3.0 (.fir) directly consumable by CIRCT's firtool:

  • Uses partial-LValue bit splitting (neo-firrtl::split) to cleanly lower partial struct-field, tuple-element, array-element, and bit-slice assignments into valid FIRRTL whole-signal connections.
  • Maps Neo Clock ports and __defaultClock to FIRRTL Clock types, seq blocks to registers, and comb blocks to when/else combinational logic.

Dart ROHD Stubs (--format rohd-stub) ​

For teams using Intel's ROHD for simulation or system integration, --format rohd-stub generates Dart ExternalSystemVerilogModule wrapper classes (.rohd.dart) for every @top module:

  • Adds matching addInput / addOutput bindings with exact bit widths and Dart output getters.
  • Includes doc comments documenting the exact LSB-first bit layout of every port.
  • Generates helper classes (<Struct>Helper.pack<Struct>(...)) for LSB-first packing of Struct-typed ports in Dart.

CLI Build Options ​

  • --top <MODULE>: Elaborate a specific module in the entry file as the top module (overriding @top).
  • --split-files: With --format sv --out <DIR>, emit one <Module>.sv file per elaborated module.
  • --message-format json: Emit newline-delimited JSON diagnostics for CI and tooling integration.
  • --deny-warnings: Fail with a non-zero exit code if any warnings are emitted.
  • --z3-timeout <MS> / --z3-rlimit <N>: Tune per-query Z3 solver limits.