Fix Zcmt JVT index calculation - #3451
Open
124107157-KV wants to merge 2 commits into
Open
Conversation
cainria
reviewed
Aug 11, 2026
cainria
left a comment
Member
There was a problem hiding this comment.
Thanks for the fix!
Should we add a new testbench or is there a way to trigger this issue with assembly code?
Contributor
Author
Thanks! Yes, it should be possible to trigger this with an assembly test. I found the existing Zcmt assembly tests under I’ll check whether I can adapt one of those to use index 64, which is the first value affected by this bug, and make the test self-checking so that an incorrect jump is detected. If that works cleanly, I can use the assembly regression instead of adding a separate decoder testbench. |
124107157-KV
force-pushed
the
fix/3442-zcmt-jvt-index
branch
from
August 12, 2026 14:28
e6a8a01 to
939e2b5
Compare
Use the complete eight-bit cm.jt/cm.jalt table index when calculating the JVT entry address. Add a focused zcmt_decoder regression covering the index-64 boundary and upper table indices. Fixes openhwgroup#3442
Replace the standalone zcmt_decoder testbench with a directed assembly regression using cm.jalt index 64. Register the test in the issue testlist and run it with RVZCMT enabled so the original six-bit calculation fails while the fixed eight-bit calculation passes.
124107157-KV
force-pushed
the
fix/3442-zcmt-jvt-index
branch
from
August 13, 2026 10:02
939e2b5 to
de119c6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why this PR is needed
This PR fixes the Zcmt JVT address calculation reported in #3442.
The Zcmt table-jump index is encoded in instruction bits
[9:2], providing an 8-bit index for 256 JVT entries. For RV32, the JVT entry address is calculated as:The current implementation uses only
instr_i[7:2]:This retains only six index bits. Therefore, indices 64–255 lose their upper two bits and alias entries 0–63.
This PR changes the address calculation to use the complete 8-bit index:
This is also consistent with the existing Zcmt instruction classification, which already uses
instr_i[9:2].For a JVT base of
0x80100000:0x0000x801000000x801000000x0fc0x801000fc0x801000fc0x1000x801001000x801000000x1fc0x801001fc0x801000fc0x2000x801002000x801000000x3fc0x801003fc0x801000fcIndex 64 is the first value that exposes the truncation bug. Its correct offset is
0x100, while the previous six-bit calculation wraps the index to zero and produces offset0x000.Changes
This PR:
core/zcmt_decoder.svto useinstr_i[9:2]for the JVT address calculation;zcmt_decoderVerilator regression;0,31,32,63,64,127,128, and255;verif/regress/issue-tests.sh;The values below 64 verify that the existing behavior before the truncation boundary remains unchanged.
Index 64 verifies the first affected boundary, while 127, 128, and 255 exercise the upper portion of the complete 8-bit index range.
Regression results
Before the fix
The regression passes through index 63 and fails at index 64:
The pre-fix regression exits with a non-zero status.
After the fix
The same regression passes across the tested 8-bit index range:
Validation
The final branch was validated with:
tb_zcmt_decoderregression;verible-verilog-format --verify core/zcmt_decoder.sv;verible-verilog-format --verify corev_apu/tb/tb_zcmt_decoder/hdl/tb.sv;git diff upstream/master...HEAD --check;upstream/master.The working tree is clean after validation.
Full repository CI will run on the pull request.
Scope and limitations
This PR intentionally addresses only the JVT index truncation reported in #3442.
It changes the JVT table-entry address calculation and adds focused regression coverage for that calculation.
It does not modify unrelated Zcmt control-flow behavior, cache-response handling, or the
TABLE_JUMPstate machine.No known limitation is introduced by the RTL change itself.
Fixes #3442