Skip to content

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 ​

  • UInt parameters are assumed >= 0; Pos parameters are assumed >= 1 and checked at every call site (argument_invariant_error).
  • where clauses on module, struct, union, and interface declarations are assumed inside the body (rejecting contradictory clauses via unsatisfiable_where_clause) and proved at every instantiation site (argument_invariant_error, with related span pointing to the invariant).
  • UInt subtraction checks a >= b (uint_underflow); / and % check b >= 1 (division_by_zero).
  • clog2(n) requires n >= 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 than 0 or 1 (invalid_bit_string).
  • Sized constants (v#w, n.toBits(w), n.toInt(w)) reject values that exceed (or cannot be proved to fit in) w bits (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] verifies 0 <= i < len symbolically (index_out_of_bounds).
  • Dynamic arr.select(idx) verifies len >= 1 and idx has width clog2(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 comb blocks, every branch of an if, case, or match must assign the exact same set of targets, if must have an else (inconsistent_conditional_assignments), and reading a signal before writing it in the same block is rejected (comb_read_before_write).
  • Inside seq blocks, else is optional (unassigned registers hold their previous value), while seq-local logic signals act as combinational temporaries (defaulting to 0 when written conditionally).
  • Nested logic blocks (assign/comb/seq inside one another) are rejected (nested_logic_block), and unused #[...] logic-function captures emit unused_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 <- Dynamic assignments.
  • Rejects cross-domain reads (clock_domain_mismatch) and writes (seq_block_clock_mismatch). See Timing & Clock Domains.

6. match and case Exhaustiveness ​

  • match on a union or Option(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).
  • case on an Enum, Bits(w), or Int(w) checks full coverage (all enum variants, or all 2^w values when w <= 8; wider/symbolic widths require _) (non_exhaustive_case).
  • Non-fatal case warnings:
    • duplicate_case_arm: Duplicate constant pattern (with related span to the first arm).
    • unreachable_wildcard: _ arm when all enum variants or 2^w values 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 CodeMeaning
undriven_outputModule output port is never assigned
undriven_interface_fieldAssignable field on a module interface is neither assigned nor connected via connect(...)
undriven_submodule_inputInput port or assignable interface field on an instantiated submodule is never driven
undriven_logicLocal 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 pub visibility (private_import with 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 reports solver_unknown rather than silently accepting an unproven design.