Skip to content

PR: feat: CVA6 XIF exhaustive verification with Spike cross-validation #9#14

Merged
metasmile merged 23 commits into
mainfrom
9-cva6-xif-spike-channel
Jun 1, 2026
Merged

PR: feat: CVA6 XIF exhaustive verification with Spike cross-validation #9#14
metasmile merged 23 commits into
mainfrom
9-cva6-xif-spike-channel

Conversation

@metasmile

Copy link
Copy Markdown
Contributor

Summary

Exhaustive verification of the CVA6 CV-X-IF reference coprocessor encoding space, with Spike RISC-V simulation cross-validation. Adds the ev simulate subcommand for ISA simulation, the cross constraint type for cross-field mapping, and the RunSimulation capability trait for pluggable simulation backends.

Changes

Core engine

  • Cross constraint: Maps field_a values to allowed field_b value sets (funct3=0 -> funct7 in {2,6,8,32})
  • MAX_COMBINATIONS: Raised from 10M to 34M to support full 33M combination space
  • Fact payload: Changed from serde_json::Value to Vec<u8> blob (no embedded schema, ready for Nexus)
  • SV assertion: Replaced assert property with // synthesis translate_off + $error for Yosys compatibility

CVA6 XIF verification

  • Fixture: cva6_xif_ref.xif.yaml based on actual CVA6 verification suite encoding tables
  • 33.5 million raw combinations evaluated exhaustively in 32 seconds
  • 196,608 valid encodings identified
  • 100% match with Spike RISC-V simulation

Simulation channel

  • RunSimulation trait: Nexus-style capability trait for pluggable simulation backends
  • SpikeBackend: Batches valid encodings into ELF, runs under Spike + pk, parses results
  • MockSimBackend: Test/CI backend (no external tool required)
  • Backend selection: EV_SIM_BACKEND=mock|spike

CLI

  • ev verify — static constraint verification
  • ev simulate — ISA simulation verification
  • ev synth — SystemVerilog generation + Yosys synthesis
  • ev verify --json outputs Fact envelope (Vec<u8> payload)

CI and packaging

  • Dockerfile updated with RISC-V toolchain (Spike, pk, cross-compiler)
  • run.sh centralized all tests; CI runs bash run.sh

Test Results

71 passed, 1 ignored (33M combo fixture in --verify mode)

Related Issues

metasmile added 23 commits June 1, 2026 10:44
- funct3/funct7 mapping updated to match cvxif_custom_instr.sv:
  funct3=0: funct7∈{2,6,8} (ADD_MULTI, U_ADD, S_ADD)
  funct3=1: funct7=0 (CUS_ADD)
  funct3=2: funct7=96 (CUS_EXC)
- funct7 range extended to [0,127] to cover funct7=96
- Test expected value updated from 3072 to 2560
- 72 tests passing

Milestone 1 of #9
- synth/sim.rs: RunSimulation trait (Nexus-style capability interface)
  + SimulationResult, MockSimBackend
  + Optional capability traits: BatchCapable, ProfileCapable, CoverageCapable
- spike.rs: SpikeBackend implements RunSimulation
  + ELF batch generation, cross-compile, Spike execution, result parsing
- main.rs: resolve_sim_backend() with EV_SIM_BACKEND env var
  + default: MockSimBackend (no external tool needed)
  + EV_SIM_BACKEND=spike → SpikeBackend
- reporter.rs: hash_evaluations() for simulation result content IDs
- 73 tests passing, all CI checks clean
Problem: SpikeBackend's C harness had CVA6 funct3/funct7 encoding
hardcoded, making the backend non-generic.

Fix:
- generate_c_constraints() converts each ConstraintSpec to C code
- generate_c_constraint_expr() handles all 10 constraint types
  (range, even, eq, neq, lt, gt, le, ge, oneof, cross)
- All fields included in encoding array with field index macros
- get_spike_version() now respects EV_SPIKE_BIN env var
- 73 tests passing, clippy 0 warnings
- _idx closure was unused (all field references use direct format strings)
- _field_names parameter retained for future signature compatibility
- Yosys only supports SV 2005, assert property is SV 2012
- Changed to // synthesis translate_off +  pattern
- All constraint types updated (range, even, eq, neq, lt, gt, le, ge, oneof, cross)
- Tests updated to match new output format
- ev synth now works with Yosys for all fixture types
- ev verify --json → Fact { fact_type: "verification_result" }
- ev synth --json → Fact { fact_type: "synthesis_result" }
- ev simulate --json → Fact { fact_type: "simulation_result" }
- JsonReporter wraps VerificationReport in Fact payload
- SimulationResult implements From<&SimulationResult> for Fact
- Nexus FIH protocol compatible: same Fact type across all channels
- Data transfer layer ready for future Nexus integration
- 73 tests passing, clippy 0 warnings
Bug: Spike results indexed 0..valid_rows.len() but merge_results
used static_evaluations indices directly, causing all valid encodings
beyond the first 512 to be marked as 'no result'.

Fix:
- merge_results_with_indices maps Spike output indices back to
  original evaluation indices via valid_indices
- C harness uses setbuf(stdout, NULL) to prevent buffered output loss
- Verified: EV_SIM_BACKEND=spike on ssccs-poc Docker image
  → static=2560 passed, spike=2560 passed (identical)
- Debug artifacts removed
- Fix misleading doc comment on generate_c_source (not public)
- Use static const + const pointer in C code (correct const semantics)
- Avoid C warning: const int64_t* passed to int64_t*
- Fact.payload is now opaque Vec<u8> (not serde_json::Value)
- Consumers interpret based on fact_type (JSON, CBOR, binary)
- Tests decode payload via serde_json::from_slice for verification
- CLI tests updated to check fact envelope structure
- External tool JSON requirement handled by conversion layer
Coverage gap analysis between ev exhaustive and riscv-dv random approaches.
Documents complementary strengths and areas not yet modeled by ev.
- MAX_COMBINATIONS raised from 10M to 34M for 33M-combination space
- cva6_xif_ref.xif.yaml: rs1/rs2/rd range [0, 31] (full RV32GPR)
- 163,840 valid encodings (was 2,560 at [0,7])
- Spike simulation: 33M combos in 32s on M1 Max native
- Slow test marked #[ignore], run with -- --include-ignored
- 33M combinations exhaustive (was 262K)
- 196,608 valid encodings with full register range
- Spike simulation channel: 196,608/196,608 pass
- Fact payload as opaque blob (no embedded schema)
- CVA6 verification suite encoding reference
…ec sheet

- Replaces two outdated documents with one comprehensive reference
- Covers architecture, encoding, fixture model, constraints, results
- Updated comparison table with current figures (33.5M, 196K valid, 32s)
- No Korean remaining
- Spike from source (riscv-isa-sim)
- riscv-pk cross-compiled for RISC-V
- gcc-riscv64-linux-gnu with aliases
- Smoke test: ev simulate with mock backend in Docker build
- run.sh now includes 'ev simulate --target all_pass' in verify_fixtures
- cva6_xif_ref description updated (full register range, correct funct7)
- CI needs only 'bash run.sh' — all tests are centralized in run.sh
- EV_SIM_BACKEND=spike activates real Spike simulation in CI
- Use << 'EOF' heredoc for Python snippets (no quote escaping issues)
- Decode Vec<u8> payload before accessing fields
- cva6_xif_ref (33M combos) moved to --verify mode only
- Use command substitution () instead of heredoc for Python parsing
- Avoid pipe+heredoc conflict (heredoc eats stdin)
- json output: parse Fact payload and display Total/Passed/Failed
- simulate mock: display backend origin from Fact envelope
- cva6_xif_ref (33M combos) excluded from default run
@metasmile metasmile merged commit 29078c7 into main Jun 1, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CVA6 XIF exhaustive verification — Spike simulation channel

1 participant