Skip to content

[hardware] Qualify scalar responses by their return path - #539

Open
lionelZhaowy wants to merge 2 commits into
pulp-platform:mainfrom
lionelZhaowy:fix-scalar-response-qualification
Open

lionelZhaowy wants to merge 2 commits into
pulp-platform:mainfrom
lionelZhaowy:fix-scalar-response-qualification

Conversation

@lionelZhaowy

@lionelZhaowy lionelZhaowy commented Oct 26, 2026 •

Copy link
Copy Markdown

An unmasked mask comparison followed by vmv.x.s or vfmv.f.s can return the old mask operand instead of the requested vector element. The e32 regression computes +3.0 in v8, issues vmfeq.vv v10, v12, v14, and immediately extracts v8[0]. Main returns 0x00000000 instead of 0x40400000.

The sequencer can respond before MASKU releases the shared MaskB operand path. Its !use_vd condition also includes stores, allowing a response before address generation acknowledges them.

This patch selects the response path by opcode:

  • VMVXS/VFMVFS wait until MASKU releases MaskB.
  • VCPOP/VFIRST keep their dedicated result path. Their valid signal lasts one cycle, so they must not wait for mask-busy to clear.
  • Stores keep the existing address-generation response path.

The patch keeps the ready expression, interfaces, and parameters unchanged. The regression extends the existing scalar-move tests. It checks scalar values, comparison masks, stored data, and VCPOP/VFIRST results.

Validation

Base: 34bd3bc152421b4601a7bf3d6e8e91ffb545c99e, with unchanged locked dependencies. Configuration: official ara_tb, real CVA6 dispatcher, 2 lanes, VLEN=2048, VCS W-2024.09-SP1, and LLVM 20.1.0.

Same ELF for each RTL version Original RTL Patched RTL
vmvxs 2 failed checks, tohost=2 All 51 checks pass, tohost=0
vfmvfs 2 failed checks, tohost=2 All 46 checks pass, tohost=0

A read-only observer recorded two early scalar responses and three store responses before address acknowledgement in each original run. Each patched run exercised 40 cycles with scalar data valid while MASKU was busy. Early scalar responses and incorrect store responses were zero. Both dedicated-result instructions returned while MASKU was busy. No runtime assertions failed.

Only this configuration and these directed tests ran. The tests use fixed scalar registers to avoid #518 and clear mask tail bits. They do not use gather/compress or include #475. No full suite or synthesis ran.

Reproduce with the local VCS and LLVM tools

Build the PR tests once. Use the same ELFs with base and patched RTL, with a fresh simulation directory for each version. Keep the locked dependencies, including CVA6's pinned HPDcache submodule.

LLVM_ROOT names LLVM 20.1.0 with matching newlib/compiler-rt. SPIKE_ROOT supplies the ELF loader's fesvr headers. Local runs used host GCC 13.2.0.

make -C apps config=2_lanes LLVM_INSTALL_DIR="$LLVM_ROOT" \
  LLVM_FLAGS="--target=riscv64-unknown-elf --sysroot=$LLVM_ROOT/riscv64-unknown-elf -isystem $LLVM_ROOT/riscv64-unknown-elf/include -march=rv64gcv_zfh_zvfh -mabi=lp64d -mno-relax -fuse-ld=lld --rtlib=compiler-rt -L$LLVM_ROOT/riscv64-unknown-elf/lib" \
  LLVM_V_FLAGS="-fno-vectorize -fno-slp-vectorize -mno-implicit-float" \
  bin/rv64uv-ara-vmvxs bin/rv64uv-ara-vfmvfs

ARA_ROOT=$PWD
mkdir -p hardware/build/scalar-return-path
bender --local --git-submodules false script vcs \
  -t rtl -t cv64a6_imafdcv_sv39 \
  -t tech_cells_generic_include_tc_sram -t tech_cells_generic_include_tc_clk \
  -t exclude_first_pass_decoder -t ara_test -t cva6_test \
  -D NR_LANES=2 -D VLEN=2048 -D ARIANE_ACCELERATOR_PORT=1 \
  --vlogan-args="-full64 -assert svaext +v2k -timescale=1ns/1ps" \
  > hardware/build/scalar-return-path/compile.sh
cd hardware/build/scalar-return-path
bash compile.sh
vcs -full64 -sverilog -timescale=1ns/1ps -assert svaext -top ara_tb \
  "$ARA_ROOT/hardware/tb/dpi/elfloader.cc" \
  -CFLAGS "-I$SPIKE_ROOT/include" -o simv
timeout 600 ./simv +PRELOAD="$ARA_ROOT/apps/bin/rv64uv-ara-vmvxs"
timeout 600 ./simv +PRELOAD="$ARA_ROOT/apps/bin/rv64uv-ara-vfmvfs"

In these commands, timeout 600 sets the maximum runtime. It does not report elapsed time.

VCS returns process status 0 even for the original failures. Check every software result and Core Test *** SUCCESS *** (tohost = 0). The local measurements also used a read-only observer, which neither drives nor forces DUT signals.

Existing vmvxs shift-overflow and non-allocatable .comment warnings remain. The regression places e32 scalar moves before stores and e64 stores before scalar moves. This order exercises both response paths.

Changelog

Fixed

  • Qualify scalar responses by their return path to avoid early scalar moves and store acknowledgements.

Checklist

  • Automated tests pass (directed local tests pass, full CI pending)
  • Changelog updated
  • Code style guideline is observed

OpenAI Codex assisted with the patch, regression and description. The reported builds and simulations ran. No separate human review was performed.

The affected original tests (vmvxs and vfmvfs) and HelloWorld now pass through the official Verilator Make entry in all four configurations: 2/4/8/16 lanes. The applications use the locked LLVM 20.1.0/newlib sources, and Verilator is built from the locked commit 06263ec7. Each local run has a 10000000-cycle limit and finishes with tohost = 0, process exit 0 and no runtime assertion errors. The Make entry now accepts native simulator arguments so these runs can use that limit. License checks also pass. The RTL and dependency lock are unchanged by this test-entry update.

Wait for MASKU to release MaskB before acknowledging vector-to-scalar moves. Preserve the dedicated VCPOP/VFIRST result path and leave stores to the address-generation response path.

Exercise scalar extraction while a comparison is pending, stores sharing the response window, and dedicated mask results in the existing scalar-move tests.

This branch has not been deployed

No deployments
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.

1 participant