Symbolic Validator
Neo's frontend (neo-check) performs unified symbolic verification powered by Z3. Every enum, struct, union, interface, and module is checked independently in topological file order using symbolic parameter values and solver scopes (push/pop).
If a module passes neo check with zero errors, every valid instantiation of its parameters is verified to be well-typed, in-bounds, latch-free, single-assigned, and timing/CDC-sound.
Verification Checks
1. Parameter Invariants & Checked Arithmetic
UIntparameters are assumed>= 0;Posparameters are assumed>= 1and checked at every call site (argument_invariant_error).whereclauses onmodule,struct,union, andinterfacedeclarations are assumed inside the body (rejecting contradictory clauses viaunsatisfiable_where_clause) and proved at every instantiation site (argument_invariant_error, with related span pointing to the invariant).UIntsubtraction checksa >= b(uint_underflow);/and%checkb >= 1(division_by_zero).clog2(n)requiresn >= 1(invalid_argument) and asserts Z3 ground axioms (n <= 2^clog2(n), monotonicity, exact small values) so downstream width proofs succeed automatically.
2. Types, Widths & Strict 2-State Literals
- All operators, assignments, function arguments, and struct/union/tuple/array constructors are strictly type-checked using Z3 for symbolic widths (
type_mismatch). - Bit-string literals
"..."reject any character other than0or1(invalid_bit_string). - Sized constants (
v#w,n.toBits(w),n.toInt(w)) reject values that exceed (or cannot be proved to fit in)wbits (truncated_constant/possible_truncated_constant). - Hardware
Int(w)division/and modulo%reject constant zero divisors (division_by_zero). .castTo(T)verifies equal total bit width via Z3.- Struct getters reject direct and mutual recursion cycles (
recursive_getter), recursive type/module definitions are rejected (recursive_type,recursive_module), enum declarations validate non-emptiness (empty_enum), unique discriminants (duplicate_enum_value), and 64-bit bounds (enum_value_out_of_range), and user declarations cannot shadow__defaultClock(reserved_identifier).
3. Array & Bit-Select Bounds
- Static array indexing
arr[i]verifies0 <= i < lensymbolically (index_out_of_bounds). - Dynamic
arr.select(idx)verifieslen >= 1andidxhas widthclog2(len). - Bit selections
x{hi:lo}verify all indices lie within[0, width - 1](select_out_of_bounds).
4. Single Assignment & Latch Prevention
- Each hardware location (whole signal, struct field, tuple element, array element, or bit slice) may be assigned at most once (
multi_assignment), with Z3 verifying disjointness of symbolic array indices and bit ranges. - Inside
combblocks, every branch of anif,case, ormatchmust assign the exact same set of targets,ifmust have anelse(inconsistent_conditional_assignments), and reading a signal before writing it in the same block is rejected (comb_read_before_write). - Inside
seqblocks,elseis optional (unassigned registers hold their previous value), whileseq-locallogicsignals act as combinational temporaries (defaulting to0when written conditionally). - Nested logic blocks (
assign/comb/seqinside one another) are rejected (nested_logic_block), and unused#[...]logic-function captures emitunused_logic_fn_assign.
5. Timing & Clock-Domain Crossing (CDC)
- Verifies assignment timing compatibility in the lattice
Constant <= SingleCycle(t, off, clk) <= Dynamic(clk)(timing_mismatch). - Rejects
SingleCycle <- Dynamicassignments. - Rejects cross-domain reads (
clock_domain_mismatch) and writes (seq_block_clock_mismatch). See Timing & Clock Domains.
6. match and case Exhaustiveness
matchon aunionorOption(T)requires all variants to be covered unless a_wildcard is present (non_exhaustive_match), rejects duplicate variant arms (duplicate_match_arm), rejects multiple wildcards (multiple_default_cases), and checks payload binding arity (union_variant_no_data).caseon anEnum,Bits(w), orInt(w)checks full coverage (all enum variants, or all2^wvalues whenw <= 8; wider/symbolic widths require_) (non_exhaustive_case).- Non-fatal
casewarnings:duplicate_case_arm: Duplicate constant pattern (with related span to the first arm).unreachable_wildcard:_arm when all enum variants or2^wvalues are already covered.non_trailing_wildcard:_arm placed before the final arm.
7. Undriven-Sink Warnings
At module exit (and block exit for uninitialized locals), Neo emits warnings for any hardware sink that is never driven:
| Warning Code | Meaning |
|---|---|
undriven_output | Module output port is never assigned |
undriven_interface_field | Assignable field on a module interface is neither assigned nor connected via connect(...) |
undriven_submodule_input | Input port or assignable interface field on an instantiated submodule is never driven |
undriven_logic | Local logic wire declared without an initializer is never assigned |
8. Interface Connectivity & Visibility
connect(a, b)checks matching interface kind and Z3-equal arguments (connect_type_mismatch), opposite effective directions (connect_same_direction), and single-assignment of all connected fields.- Imports enforce
pubvisibility (private_importwith related declaration span), symbol existence (unknown_import), duplicate names (duplicate_declaration), and acyclic module graphs. - If Z3 cannot decide a symbolic constraint within its timeout (default
2000 ms), Neo reportssolver_unknownrather than silently accepting an unproven design.