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)
- Entry Points: The elaborator finds all
@topmodules in the entry file (or the single module specified via--top <MODULE>). A@topmodule may take any number ofTimingparameters, 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)). - 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. - 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 bit0).Union/Option(T):[data (MSB), tag (LSB)].- Interface ports are flattened into
<intf>_<field>ports with appropriate directions.
- On-Demand
__defaultClock:- Modules that only contain combinational logic (
assign,comb) or only use explicit customClockports emit no__defaultClockport. - Modules using an implicit-clock
seq { ... },Reg(...), or instantiating a submodule that requires__defaultClockautomatically add and threadinput logic __defaultClock.
- Modules that only contain combinational logic (
- 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
assignstatements,always_combblocks (with latch-safe pre-initialization where needed for linters like Verilator-Wall), andalways_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 returning0for 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
Clockports and__defaultClockto FIRRTLClocktypes,seqblocks to registers, andcombblocks towhen/elsecombinational 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/addOutputbindings 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 ofStruct-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>.svfile 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.