Skip to content
masc-ucscPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

lhdsuite

Real-design correctness tests and benchmarks for LiveHD: compilation, synthesis, simulation, logical equivalence checking (LEC), and formal verification. The scripts in bench/ also serve as examples of each flow.

Source trees

Designs use three source directories:

Directory Purpose
verilog/ Original RTL, either written in Verilog/SystemVerilog or generated from Chisel. This is the reference design.
pyrope/ Pyrope automatically generated by LiveHD from the reference RTL. This preserves the translator's output as a baseline.
pyrope2/ An agent-evolved version of pyrope/, rewritten for clarity and idiomatic Pyrope.

In pyrope2/, anything internal may change as long as top-level module compatibility is preserved. Agents may rename or replace internal modules, redesign their interfaces, reorganize files and hierarchy, and change data representations or implementation structure. Preserve the public top-level module name, ports, supported configuration, and externally observable behavior, including cycle timing and reset behavior. Check equivalence against the reference RTL; a bounded pass or an inconclusive result is not an unbounded proof.

Generation is automatic, but refreshing the checked-in pyrope/ baseline is an explicit maintenance step. Benchmark runs use scratch directories and do not rewrite it. Keep agent cleanup in pyrope2/; the files selected by each core's BUILD determine which version a benchmark consumes.

Except for pyrope2/ and the match* tests, Pyrope design sources are generated. When generated code is wrong, fix the generation defect and refresh the affected files in pyrope/, checking them against the reference RTL.

The tests in verif, should run with both pyrope/ and pyrope2/

Designs

Design Scope
dino Dual-issue RISC-V CPU, top PipelinedDualIssueCPU.
minion Multithreaded RISC-V core with vector/tensor units, top minion_top.
cva6 Whole OpenHW CVA6 core in Pyrope, top cva6.
picorv32 YosysHQ PicoRV32 under the parameter-pinning picorv32_top wrapper.
bitcoin LogikBench SHA256d proof-of-work miner (16 lanes of secworks sha256_core) under the parameter-pinning bitcoin_top wrapper; pyrope/ is a hand-cleaned loop-based translation.
ibex lowRISC Ibex (RV32IMC) under the parameter-pinning ibex_suite_top wrapper.
matched_filter Configurable streaming matched filter, 64 taps by default.
mixed_soc Shared SoC: 12 Rockets, four BOOMs and one full 16×16 Gemmini on a 6×3 mesh. Imported Pyrope designs with custom glue and matched Pyrope/Verilator concurrent-core simulation (36,000 cycles; other CPUs park with WFI); also a 388M-cell modeled floorplan.
xs_* XiangShan blocks sharing xiangshan/Backend/: ALU, ROB, rename table, divider, execution block, and backend.

CVA6's local verilog/ contains only a cache tag-comparator cone. Its benchmarks use the whole Pyrope core and omit Verilog and cross-language LEC scenarios. Formal checks target the integer ALU. See the CVA6 generation recipe for the full-core source.

Setup

Install Bazelisk; .bazelversion selects Bazel. LiveHD and its C++ dependencies are built from source. MODULE.bazel pins LiveHD to one commit of github.com/masc-ucsc/livehd (a git_override); it does NOT use the sibling ../livehd checkout. To test a local checkout instead, pass --override_module=livehd=/path/to/livehd (e.g. =../livehd). Builds default to -c opt; use -c dbg for compiler debugging.

Synthesis maps to and times with asap7 (RVT, FF corner): the merged Liberty in tech/asap7, checked in gzipped, so no PDK install is needed. The harness decompresses it into the test's work dir, passes it to lhd explicitly (synth.liberty), and records asap7-rvt-ff-<sha256 prefix> as the PDK version. Each core's timing constraints live next to its sources in <core>/synth/*.sdc (the sdc field in bench/defs.bzl): a 1 GHz clock (numbers are in ps, the Liberty's unit), 20% IO delays, and the reset as a false path (cut at the reset ports and, where the design has one, at the reset synchronizer).

Verilator is optional. Install it for the comparison scenarios; set VERILATOR to override discovery. These scenarios skip when it is absent.

Running

bazel test //bench:dino_compile_verilog --test_output=all  # one scenario
bazel test //bench:dino                                  # one core
bazel test //...                                         # all tests; can take hours
bazel run //bench:show                                   # last recorded results
bazel run //bench:show -- --core minion --no-cmds          # compact, one core

Targets follow //bench:<core>_<scenario>. Available scenarios depend on the core's sources and drivers; bench/defs.bzl is authoritative. Tests carry core_<name> tags and run exclusively to keep timings isolated. Run one synthesis job at a time.

Scenario Checks or measures
compile_verilog, compile_pyrope, compile_pyrope2 Front-end compilation and throughput. compile_pyrope2 (cores with a maintained pyrope2/ tree: dino, picorv32, matched_filter) runs the same flow over that tree.
compile_pyrope_parallel Separate compilation through an import-aware generated Makefile.
compile_incremental Compilation across cold, comment-only, and semantic edits.
synth, synth_incremental Mapping time, reuse, gate count, area, and timing with asap7 under the core's SDC. Minion also runs a flat-mapping comparison.
synth_lec_synth, synth_lec_flat Synthesized netlist equivalence, including reuse after a comment edit; flat is Minion-only.
sim_verilog, sim_pyrope, sim_pyrope2, sim_verilator Simulation with checked output values; host compilation and execution are timed separately. sim_pyrope2 is sim_pyrope over <core>/pyrope2 with the same driver, gates and cycle count. The lhd sim legs run lhd's default backend (LLVM since livehd 98a7e7c44; METRIC sim_backend_llvm records which).
sim_incremental Native simulator build reuse across edits. Each image must match a caches-off build in execution. The older sim_incremental_llvm target is an alias. The three Gemmini meshes also provide sim_incremental_pyrope2 to exercise a MAC edit in the loop-based designs. A query of internal mesh state must change across the edit and match the fresh build. Both scenarios report how many DUT objects have identical bytes and paths across the edit.
lec, lec_bug, lec_incremental Cross-language equivalence, injected-bug detection, and proof-cache reuse (the cache gate applies only under a proof LEC_EFFORT; sampled presets never cache).
verify, verify_bug, verify_temporal, verify_incremental Formal sidecar properties, mutant refutation, sequential properties, and reuse where supported.

All synthesis scenarios and bench/matrix.sh pass --set synth.memory=macro: memories, including register files, stay native rather than expanding into flops and logic. Reported gate counts and standard-cell area exclude those memory blocks; the QoR report's memories table records their dimensions and realization. This does not select or characterize SRAM macros. The rocket benchmark maps RocketTile (core, L1 caches and PTW), not the standalone Rocket module.

Logs contain exact CMD lines and METRIC <name> <value> <unit> records. //bench:show summarizes existing logs; run tests first. Detailed step logs and metrics.jsonl are under bazel-testlogs/bench/<target>/test.outputs/. Add --test_env=BENCH_VERBOSE=1 to include full step logs in test output.

Translation checks in verif/ regenerate into scratch space:

bazel test //verif:genprp_dino  # Verilog -> Pyrope, then LEC against the original
bazel test //verif:v2v_dino     # Verilog -> Pyrope -> Verilog, then LEC

These correctness tests also run under //....

Yosys+ABC QoR comparison

bench/yosys_compare.py synthesizes each core's Verilog with both lhd synth and a Yosys+ABC recipe modeled on ORFS's asap7 flow (yosys-slang front end, synth -flatten, the asap7 adder and latch maps, dfflibmap, ABC with ORFS's abc_speed.script, -D from the SDC clock, ORFS's dont_use list). Both runs use the same asap7 Liberty and the core's SDC. Both netlists are then timed by one OpenSTA script inside openroad: ideal clocks, no wire load, no placement. It reports setup slack/TNS, cell count, sequential cells and Liberty area. Inferred memories become flops on both sides (synth.memory=flops), unlike the bench's synth.memory=macro, which has no Yosys equivalent. lhd's Verilog netlist writes constant wiring as always_comb, so the script first folds that wiring structurally with Yosys (no remapping or merging). A netlist that still holds generic logic after that is reported as not timed. The run is outside bazel and resumable; --resta re-times finished cores without resynthesizing. cva6 is skipped because its verilog/ is only a cone. Tool paths are explicit arguments (see the script's docstring).

Incremental checks

Incremental flows share a work directory across a cold run, an unchanged or comment-only run, and a semantic edit. Some flows add a separate warm pass. tests/comment1/ contains comment-only overlays; tests/bug1/ contains intentional bugs that LEC or formal verification must detect.

Measure reuse by saved work and elapsed time, not cache-hit counts alone. Simulation output assertions and strict proof gates remain enabled.

Some incremental LEC targets accept a timeout without refutation under the existing owner policy. Minion and Backend currently pass through that path; their pass status does not establish equivalence. Strict proof checks still reject incomplete verdicts.

The parallel build publishes a LNAST library for each dependency and lowers the complete hardware graph at the selected root. This checks input-dependent one-hot obligations in their actual caller context. A strict monolithic compile and exact structural identity check validate the assembled library outside the measured build interval. This recipe omits the unused isolated hardware graphs included in older parallel-build measurements.

Known-failing scenarios

These are previously reported failures, not a fresh status report for the selected LiveHD checkout. Re-run the relevant target to establish its status.

Targets Previously reported limitation
//bench:picorv32_lec, picorv32_lec_bug A six-cycle bounded result misses behavior beyond reset and cannot establish equivalence or detect the mutant.
//bench:bitcoin_compile_pyrope_parallel A comb whose rolled loop writes bit-slices of a mut carry fails upass.tolg (unresolved reference 'le') when imported pre-lowered through ln:; the same source compiles whole. Reproducer in bitcoin/README.md.
//bench:bitcoin_lec_bug At 16 lanes the sampling LEC needs about 141 s to refute the busy mutant, past the 120 s budget (TIMEOUT-time, 0 vectors). With formal.timeout=600 it is REFUTED-cex. It refuted inside the budget at 4 lanes.
//bench:ibex_lec_bug Sampling LEC from reset reaches no misaligned load/store within the 120 s budget, so the unaligned-address mutant is not detected (TIMEOUT-time). ibex_lec passes only as TESTED-sampled.
//bench:minion_lec, minion_lec_incremental, minion_synth_lec_synth Unresolved state, memory, and hierarchical proof obligations.
//bench:xs_rob_lec_incremental RenameBuffer and Rob remain inconclusive in unbounded equivalence; 10 of 12 definitions prove within the configured budget.
//bench:xs_rob_synth_incremental ABC cold, warm, and edit reuse checks pass, but all four downstream timing analyses fail with std::bad_alloc at roughly 560 GiB peak memory.
//bench:xs_backend_synth_incremental Warm ABC mapping reaches only 1.48× speedup versus the required 2× (10,604 hits / 1,166 misses). Full and cold timing analyses fail with std::bad_alloc at roughly 545 GiB peak memory.
//bench:cva6_synth_incremental Downstream timing analysis fails with std::bad_alloc after ABC maps the large design; the full run reaches roughly 548 GiB peak memory.
//bench:xs_exu_synth_incremental Expensive reuse-ineligible regions prevent the comment-only ABC map from meeting the required 2× speedup.
//bench:gemmini16_synth, gemmini16_synth_incremental The bit-blasted 64x512 accumulator memory region (cgen_memory_65rd_64wr_*) takes 1,779 s in ABC against the 900 s per-region limit (color-time-oversize, TIMEOUT-time at mapping). The 8x8's 64x256 memory fits.
//verif:genprp_minion Slang driver-order failure during generation.
//verif:genprp_xs_enqentry_4 Excessive front-end memory use.
//verif:genprp_xs_tracebuffer Combinational cycle in generated Pyrope.

Keep these checks live. Fix compiler defects in LiveHD; fix harness defects in the suite. Preserve the expected simulation data and proof requirements. CVA6 now executes the whole-core program with its architectural gate intact; see the external RTL comparison for reproduction and proof limits.

Adding or maintaining a core

A core's BUILD exposes verilog, verilog_filelist, pyrope, pyrope_top, sim, verif, and tests filegroups. Add its configuration to CORES in bench/defs.bzl and instantiate core_benches in bench/BUILD.

The configuration names the top, verification unit, source flags, simulation drivers, and supported scenarios. The verification unit and injected edits must be reachable from the selected top. Shared scripts read the CORE_* contract in bench/common.sh; keep design-specific settings in CORES. See AGENTS.md for maintenance conventions.

Comparing the four simulators

bench/simcmp.sh [--core minion] [--lhd PATH] builds Verilator and lhd sim (Verilog, Pyrope, Pyrope2) once and prints build times, the two-point-fit cycles/s and each simulator's marker line in one table. It needs no bazel, so it can run against a frozen copy of lhd and its sibling lhd_simrt while ../livehd is being rebuilt. A testbench's cycles parameter has a range (dino's is U20), so keep --factor * --cycles inside it.

Native simulator checkout

The simulator benchmarks require LiveHD's lhd_simrt binary beside lhd. While the published LiveHD dependency predates the native runtime, use the sibling checkout, for example bazel test --override_module=livehd=../livehd //bench:mixed_soc_sim_pyrope. lhd sim --setup-only compiles the native objects. To run a prepared image, use lhd_simrt WORK/sim +cycles=36000.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages