Repository navigation
Conversation
When an invalidate arrived while the icache was already waiting for a scrambling key, the testbench fetched a second key. That fetch could land in the middle of the icache's invalidation sweep. The RAMs reject writes while a key is being fetched, so some tags were not cleared and later read back as ECC errors. Fetch a key only when the icache asks for one, as ibex_top does. Signed-off-by: Kulan Palanichamy <kulan.palanichamy@opentitan.org>
The ECC assertions in the RAM interface passed rst_n where ASSERT expects an active-high reset, so they were off while the icache ran. Pass !rst_n. The icache checks data ECC only in the way that hit, so expect a data error only when the single way that hit is corrupted. A corrupted tag still gives an error on every lookup. A new check allows no error that the testbench did not inject. Data errors in a line held in two ways stay unchecked. Declare the read data as inputs of the unused clocking block. Signed-off-by: Kulan Palanichamy <kulan.palanichamy@opentitan.org>
The same line can be allocated to two icache ways. On a lookup that hits both, the icache ORed their data before the ECC check. A clean copy could then hide an error in the other copy, and two corrupted copies could merge into a valid codeword with a wrong instruction. Read only the lowest matching way, so the checked data is one way's data, as on a normal hit. A data error still invalidates every matching way. Update icache.rst to match. Signed-off-by: Kulan Palanichamy <kulan.palanichamy@opentitan.org>
|
The RTL fix looks correct; restoring the old RTL makes the new test fail as expected. Please also include |
TagValidChk_A and DataValidChk_A wrap their conditions in always. Each assertion already starts an attempt on every clock. With always, attempts remain pending until failure, reset, or the end of simulation. VCS reports no successful attempts for these checks. Remove always so each enabled clock checks the condition once and records a success when it holds. A mismatch still fails on that clock. Signed-off-by: Kulan Palanichamy <kulan.palanichamy@opentitan.org>
DataErrChk_A skipped lookups that hit in more than one way. Require an error when the lowest matching way has an injected data error, and cover that case. Include tb.ram_if in VCS assertion coverage. Add ecc_back_line: back_line with more ECC errors, so that they land on lines held in two ways. It starts with an invalidation to vary the memory seed, since the initial seed makes fetches near address zero fail. It restores the settings it changes, also when it is killed. Add it to the stress sequences and the smoke regression. Signed-off-by: Kulan Palanichamy <kulan.palanichamy@opentitan.org>
There was a problem hiding this comment.
Thanks for the change, @kulan-pal!
I focused on the RTL change, which LGTM! Once the review from @bonnie-banks123 is addressed, we can merge this.
d06b65f to
c5d901d
Compare
|
Thanks, the VCS report now includes |
andreaskurth
left a comment
There was a problem hiding this comment.
Thanks @kulan-pal! Reading a single way is a clean fix, and the new sequence exercises the duplicate-way case well. I only have minor DV suggestions; the RTL looks good to me. Details inline.
| // The DUT flags an ECC error on a valid lookup that reads a corrupted tag in any way, or corrupted | ||
| // data in the way it reads from: the lowest way that hit. An error for a corrupted copy in another | ||
| // matching way is allowed but not required. | ||
| logic [IC_NUM_WAYS-1:0] tag_err_inj, data_err_inj, read_way; | ||
| logic ecc_err_allowed; | ||
| assign tag_err_inj = (enable_ecc_errors && (& ic_tag_rvalid)) ? tag_sel_line : '0; | ||
| assign data_err_inj = (enable_ecc_errors && (& ic_data_rvalid)) ? data_sel_line : '0; | ||
| assign read_way = tag_match & (~tag_match + 1'b1); | ||
| assign ecc_err_allowed = lookup_valid && ((|tag_err_inj) || (|(data_err_inj & tag_match))); |
There was a problem hiding this comment.
With the RTL change, the DUT can no longer flag an error for corrupted data in a matching way that it doesn't read. Should ecc_err_allowed use read_way instead of tag_match, so that NoUnexpectedErrChk_A enforces this? A return to merging the ways would then also fail when the corruption is only in the way that isn't read.
| // The DUT flags an ECC error on a valid lookup that reads a corrupted tag in any way, or corrupted | |
| // data in the way it reads from: the lowest way that hit. An error for a corrupted copy in another | |
| // matching way is allowed but not required. | |
| logic [IC_NUM_WAYS-1:0] tag_err_inj, data_err_inj, read_way; | |
| logic ecc_err_allowed; | |
| assign tag_err_inj = (enable_ecc_errors && (& ic_tag_rvalid)) ? tag_sel_line : '0; | |
| assign data_err_inj = (enable_ecc_errors && (& ic_data_rvalid)) ? data_sel_line : '0; | |
| assign read_way = tag_match & (~tag_match + 1'b1); | |
| assign ecc_err_allowed = lookup_valid && ((|tag_err_inj) || (|(data_err_inj & tag_match))); | |
| // The DUT flags an ECC error on a valid lookup that reads a corrupted tag in any way, or corrupted | |
| // data in the way it reads from: the lowest way that hit. Corrupted data in another matching way is | |
| // not read, so it must not cause an error. | |
| logic [IC_NUM_WAYS-1:0] tag_err_inj, data_err_inj, read_way; | |
| logic ecc_err_allowed; | |
| assign tag_err_inj = (enable_ecc_errors && (& ic_tag_rvalid)) ? tag_sel_line : '0; | |
| assign data_err_inj = (enable_ecc_errors && (& ic_data_rvalid)) ? data_sel_line : '0; | |
| assign read_way = tag_match & (~tag_match + 1'b1); | |
| assign ecc_err_allowed = lookup_valid && ((|tag_err_inj) || (|(data_err_inj & read_way))); |
| second way. Check that an error in the way the cache reads from | ||
| is reported. An error for a corrupted copy in another matching | ||
| way is allowed but not required.''' |
There was a problem hiding this comment.
If ecc_err_allowed is tightened (see ibex_icache_ram_if.sv), this would change to:
| second way. Check that an error in the way the cache reads from | |
| is reported. An error for a corrupted copy in another matching | |
| way is allowed but not required.''' | |
| second way. Check that an error in the way the cache reads from | |
| is reported, and that a corrupted copy in another matching way, | |
| which the cache doesn't read, causes no error.''' |
| // Add the bench's own coverage config to the common ones | ||
| { | ||
| name: default_vcs_cov_cfg_file | ||
| value: "-cm_hier {dv_root}/tools/vcs/cover.cfg+{dv_root}/tools/vcs/common_cov_excl.cfg+{proj_root}/dv/uvm/icache/dv/ibex_icache_cover.cfg" |
There was a problem hiding this comment.
This repeats the common default from vendor/lowrisc_ip/dv/tools/dvsim/common_sim_cfg.hjson. Could you add a note that the first two files must stay in sync with it? Otherwise the bench silently keeps the old list if the vendored default changes.
Without the RTL change in this PR, the new
ecc_back_linetest fails on most of the tested seeds:The icache can hold the same line in two ways when the core branches into a line that is still being fetched. A
lookup that hits both ways ORs their data before the ECC check. A clean copy can then hide corruption in the other
copy. Two corrupted copies can also merge into a valid codeword for a wrong instruction, which is returned without
an error.
This PR reads only the lowest matching way, so the ECC check sees one copy. A data error still invalidates every
matching way. Data in the other ways is not checked, as already happens for ways that miss.
I saw no material area change in a Yosys synthesis of
ibex_corewith theopentitanconfig. The added selectionlogic was off the critical path in that run, which excludes the register file and the lockstep copy.
The testbench now requires an error when the selected way holds injected data corruption. The new sequence
exercises this on duplicate hits. The VCS coverage config now includes the RAM interface's assertions. A separate
commit drops a redundant
alwaysfrom two valid-bit checks there, so their passes are counted.Depends on #2515. The first two commits are from that PR.
I ran all icache tests through dvsim on VCS U-2023.03-SP2 with the default testbench parameters and random seeds.
All passed except one
stress_all_with_resetrun, which hit the reset race fixed in #2516. The new test failed on17 of 20 seeds without the RTL change and passed on all 20 with it. Lint passed on the six CI configs. I did not
run Xcelium.
AI disclosure (CLA §9): written with help from Claude Code and reviewed with OpenAI Codex; I have reviewed and understood every change and take full responsibility for it.