Commit graph

85 commits

Author SHA1 Message Date
Michael Schaffner
ae547c8d30 [top_pkg] Fix style lint warnings
Signed-off-by: Michael Schaffner <msf@google.com>
2020-06-22 20:52:15 +01:00
Rupert Swarbrick
96cf24a41a Add a stress_all_with_reset ICache test
This is like the stress_all test, picking other sequences at random
and running them back-to-back. The difference is in the reset
behaviour, where we randomly pull the reset line at unexpected times
to try to trigger any strange glitches this might cause.

This requires slight changes to the core and memory drivers, which
need to learn to stop and return early from the current item when they
see a reset.
2020-06-22 17:11:59 +01:00
Rupert Swarbrick
962fc8020c Invalidate in an ICache sequence after a change to mem_err_shift
When we chain sequences together, we are careful to pass seeds between
neighbouring sequences. However, I didn't think to check
mem_err_shift. Before this patch, you see problems if you have a
"caching" sequence followed by a "many_errors" sequence with no reset
and no change of seed and they both happen to pick the same address
range.

The problem is that if the data at address A is cached in the first
sequence, the icache will merrily return it when address A comes up in
the second. However, the change to mem_err_shift might mean that this
would cause a memory error if it hadn't been cached, causing the
scoreboard to get upset.

This patch ensures that we always start a sequence with an
invalidation if there was a previous sequence with a different value
of mem_err_shift.

To do this cleanly, the patch also moves some of the "grab the guts of
the old sequence and put it in the new one" logic from
ibex_icache_combo_vseq and into the underlying sequence classes. The
trick is that a sequence now has a handle to the previous sequence (if
there was one), and can use that to extract whatever information it
needs.
2020-06-22 17:11:59 +01:00
Rupert Swarbrick
e243ab2617 Fix ICache caching window test with combination sequences
This fixes several problems. Firstly, the window_reset function was
switching off tracking until it next saw busy_o go low, which is
correct at the start of time, but not what we want after we've
started. This patch splits that behaviour into a new tracking_reset
function (which calls window_reset). This is called on reset or
invalidate.

Secondly, this check was occasionally failing where we'd have an ECC
sequence (which should disable the check) immediately followed by a
caching sequence with similar addresses. If the window ended in the
caching sequence, we'd see a high fetch ratio and conclude that
something had gone wrong.

Now we clear the window completely whenever we fetch an instruction
when the check is disabled, which should avoid the problem (at worst,
you might get 1 instruction overlap, which is unlikely to matter).

Finally, we move the call to tracking_reset up to the end of the reset
sequence. It doesn't usually matter, but if there's a pending item
from the core monitor with busy = 0, we need to make sure that item
comes in before we set not_invalidating = 1. Otherwise, the scoreboard
incorrectly thinks it's seen the end of the invalidation
sequence (before it's even started) and starts tracking fetch ratios
too early.
2020-06-22 17:11:59 +01:00
Rupert Swarbrick
e7c9b52c36 Add ibex_icache_stress_all test
This runs sequences back-to-back, occasionally resetting between
sequences.

Because our virtual sequences are composed of several smaller
sequences, we have to stop them when the core sequence finishes (see
the calls to kill() in ibex_icache_base_vseq). We also have to make
sure that we don't drop items in the memory sequence, which can be
pre-empted as part of sending a response (see the peek/get code
there).

Finally, the memory sequence also has a current seed and a list of
pending grants: this patch has to copy those across between sequences
to make everything work correctly.
2020-06-22 17:11:59 +01:00
Rupert Swarbrick
41a4811a55 Tidy up properly after overriding class in ICache back_line_seq
This virtual sequence controls what sequence we use in the core agent
with a factory override. We need to make sure that we "tidy up" after
starting it, otherwise every sequence afterwards will use the wrong
core sequence.
2020-06-22 17:11:59 +01:00
Rupert Swarbrick
dc708427d0 Remove empty tasks from ibex_icache_base_vseq.sv
These aren't needed, so no reason to keep the scaffolding.
2020-06-22 17:11:59 +01:00
Rupert Swarbrick
0044ea35f9 Use dv_base_vseq's num_trans field rather than making our own 2020-06-22 17:11:59 +01:00
Rupert Swarbrick
a3b53c875c Control core sequence's transaction count from top in ICache tests
This will have no effect for now: we just move the "pick a number in
the range 800..1000" logic to the virtual sequence.

The reason to do this is for tests that combine sequences: we want to
be able to shorten each component sequence so that the combined test
isn't way longer than the original ones were.
2020-06-22 17:11:59 +01:00
Rupert Swarbrick
2c38d22d99 Remove ibex_icache_sanity_vseq
This derived from ibex_icache_base_vseq but didn't do any other
customisation. Let's just use the base vseq for the test.
2020-06-22 17:11:59 +01:00
Rupert Swarbrick
ad80b0b247 Configure ICache mem_error tests from the vseq (not a test class)
As with the ECC sequence, it turns out that you don't actually need
the separate test class for this, so this commit gets rid of it. The
advantage of doing this is that we can now chain this vseq with
others.
2020-06-22 17:11:59 +01:00
Rupert Swarbrick
b49f153a50 Pass mem_err_shift to the ICache memory model on each error check
This has no immediate effect, but it means that the memory agent's
config's "mem_err_shift" value can be changed in the middle of the
test, rather than being fixed in the build_phase.
2020-06-22 17:11:59 +01:00
Rupert Swarbrick
48febdc5d6 Configure ICache ECC tests just from the vseq (not a test class)
It turns out that you don't actually need the separate test class for
this, so this commit gets rid of it. The advantage of doing this is
that we can now chain this vseq with others.
2020-06-22 17:11:59 +01:00
Rupert Swarbrick
a247cd45e9 Add some basic protocol checking to the icache's RAM interface
Since we are binding in an interface anyway, we can add some SV
assertions to make sure nothing too strange is happening.

Note that they aren't as strong as you might expect: we don't check
that rdata isn't X, for example. This is because the cache makes
speculative reads, which it (hopefully) ignores if the data is
invalid.
2020-06-22 10:37:34 +01:00
Rupert Swarbrick
4a748eb522 Enable ICache ECC in the way dvsim.py requires
It seems that dvsim.py doesn't actually use fusesoc to do things like
pass parameters. Instead, we have to set the tool-specific options in
the hjson file by hand.

Fixes issue #964.
2020-06-22 09:25:03 +01:00
Rupert Swarbrick
37fd4236c8 Correct window_width calculation in ICache UVM scoreboard
If window_range_hi = 32'hfffffffe and window_range_lo =
32'h00000000 (quite possible if we wrap), we were overflowing the
32-bit int.

The other way to write this would be something like

    ((window_range_hi - window_range_lo) / 4 +
     (((window_range_hi - window_range_lo) & 3) != 0))

which avoids needing the extra bit, but that feels very
cumbersome.
2020-06-19 09:26:12 +01:00
Rupert Swarbrick
8fe04c6923 Fix ordering in ICache core monitor start-up
Unsurprisingly, if you only start monitoring for something after
finishing the run phase, you don't see it very often. Oops!
2020-06-19 09:26:12 +01:00
Rupert Swarbrick
2cd77e5739 Correct "cancelled_valid" sequence in ICache UVM core coverage
This is supposed to spot when the valid signal drops without a ready
signal from the core. This is only allowed to happen if the core sends
a branch. The previous sequence was bogus: it didn't work for
back-to-back accesses (because it required $rose(valid)) and it didn't
check that valid actually dropped (which doesn't always happen). The
new one is simpler, and correct!

Note that we still don't see coverage of the sequence. I'll fix that
in the next patch.
2020-06-19 09:26:12 +01:00
Rupert Swarbrick
f1543a13b4 Allow ready & branch in ICache UVM tests
This doesn't actually have any effect (since the branch has priority
over whether the core is ready), but it's possible in the spec, so we
should do it sometimes.
2020-06-19 09:26:12 +01:00
Rupert Swarbrick
36935dcbb0 Weight branches in icache tests to favour edges of address space
This hits some coverpoints that are defined at interface-level in the
core agent. The point is that you want to make sure address wrapping
works correctly (what's the next instruction after 0xfffffffe?).

Note that we now also constrain the base address to be even. This was
technically wrong before, but would only have been a problem if you
picked a base address of 0xffffffff (with a probability of 1 in 4
billion).
2020-06-19 09:26:12 +01:00
Rupert Swarbrick
356fb55f7e Increase priority of failure messages in ICache scoreboard
A few of these messages get printed out just before an error. It's
much more helpful for debugging if you see them with the default
verbosity. They only appear when something goes wrong, so let's just
turn them on.
2020-06-18 09:24:06 +01:00
Rupert Swarbrick
eaa74e963c Fix verbosity in ECC UVM driver
This should have been UVM_HIGH (which disables the messages most of
the time).
2020-06-18 09:24:06 +01:00
Rupert Swarbrick
b060d37d8d Add ECC agents to ICache DV plan document 2020-06-16 09:28:57 +01:00
Rupert Swarbrick
917572c2c1 Define an "ECC agent" for icache testing and a test that uses it
The agent controls an ibex_icache_ecc_if interface, which is bound
into each prim_badbit_ram_1p module. There's a ton of painful wiring
in the environment to create an agent for each of these interfaces and
connect everything up properly.

By default, these agents don't have associated sequences (so they
don't inject read errors). You can switch them on by setting
enable_ecc_errors on the top-level virtual sequence. The patch adds a
vseq to do so (ibex_icache_ecc_vseq).

Note that we don't currently collect any specific coverage for ECC
checks. We'll probably add some uarch functional coverage points,
which will pick it up in the future, or we'll also pick it up if the
cache gets an alert output.
2020-06-16 09:28:57 +01:00
Rupert Swarbrick
48fbea833f Add and use a 'badbit' RAM for ICache tests
This does nothing by default, just wrapping up a prim_generic_ram_1p.
But we can bind an interface into it to inject bit errors by forcing
the bad_bit_mask signal.

Note that the icache uses ECC RAMs in a reasonably unusual way (ORing
together inputs and outputs from its data RAMs), so we have to do this
ourselves, rather than piggy-backing on the implementation or testing
done for e.g. OpenTitan's prim_ram_1p_adv.
2020-06-16 09:28:57 +01:00
Rupert Swarbrick
8a145a9330 Enable ECC in ICache tests
Eventually we probably want to make this configurable but, for now,
enable it unconditionally.
2020-06-16 09:28:57 +01:00
Rupert Swarbrick
2569a63eb7 Drive the branch_spec line in ICache UVM tests
This signal already got driven (to 1) when signalling a branch with
the interface's branch_to task. This patch now drives the branch_spec
line occasionally even if we don't actually do a branch. (One cycle in
64, for now).
2020-06-16 09:19:30 +01:00
Rupert Swarbrick
ec6e08d1cf Simplify timestamps in ICache tests 2020-06-12 16:15:11 +01:00
Rupert Swarbrick
13135e2e70 Collect transaction functional coverage for ICache-Mem iface
This single covergroup was extracted from the icache
documentation (icache.rst).
2020-06-09 12:03:24 +01:00
Rupert Swarbrick
a581981271 Collect transaction functional coverage for ICache-Core iface
These cover points were extracted by reading down the icache
documentation (icache.rst). There aren't yet cover points to check
that the targets of the testplan were executed properly, nor are there
any uarch coverpoints (which would be bound into the design, rather
than the interface).

The rather elaborate flow of

   sequence -> function -> trigger -> task -> covergroup

for cancelled_valid_cg follows a skeleton described in Doug Smith, "A
Practical Look @ SystemVerilog Coverage" (slides from a Doulos
course). I'm not completely convinced it's worth the effort, but I
guess it shows how to extract information from a temporal sequence in
the interface and shove it in a covergroup properly via the monitor.
2020-06-09 12:03:24 +01:00
Rupert Swarbrick
7844ed105d Wire in the branch_spec signal properly in ICache testbench
This should have no functional change - it's still set iff branch is
set - but the logic now lies in the UVM code, rather than the
structural code in tb.sv.
2020-06-09 09:11:37 +01:00
Rupert Swarbrick
d0323618fe Add a "many_errors" icache test sequence 2020-06-08 16:58:34 +01:00
Rupert Swarbrick
a15ec69dbd Add backward_line icache test sequence
This turns out to be reasonably easy to plumb in: derive from the core
sequence base class, overriding its run_req method (once I've
remembered to make it virtual). Then pick the right core sequence by
adding a factory override in the vseq.
2020-06-08 16:54:01 +01:00
Rupert Swarbrick
de05509cb6 Add test to check that disabling doesn't invalidate the icache
This is an entry in the testplan. Renaming it to "oldval", because
suffixing every class name with "disable_without_invalidation" was
getting ridiculous.
2020-06-05 09:22:43 +01:00
Rupert Swarbrick
f53d5ac645 Add the "invalidation" icache test sequence
Also move the shared "run_opts" options to top-level in
ibex_icache_sim_cfg.hjson.
2020-06-05 09:22:43 +01:00
Rupert Swarbrick
a56f14e060 Handle a seed change that clears a PMP error in icache memory driver
When the existing code in drive_pmp() decided that an error needed
signalling, it waited until the request was dropped, or the address
changed, before clearing the PMP error.

This is fine, unless the memory seed is changed (by magical means!)
under our feet. The monitor spots a new request, but the driver needs
to know to clear the PMP error. This patch forcibly tells the driver
to drop the existing item if a new one comes in.
2020-06-04 08:09:51 +01:00
Rupert Swarbrick
608ad2dfbc Spot repeated requests with same address in ICache memory monitor
Without this, you get test failures if there are two back-to-back
branches to the same address that happen at the same time as a seed
update. The problem is that you only see one request transaction (with
the first seed), and the two memory responses both come back with the
first seed, when the second should have had the second seed.
2020-06-04 08:09:51 +01:00
Rupert Swarbrick
e79e6b58ca Make sure we don't see multi-way hits in icache testbench
One aspect of (i)cache design that I didn't know about before writing
test code for this block is the problem of multi-way hits. The icache,
as implemented, stores data to parallel ways and it's possible for a
fetch to match more than one way. The data from matching ways all gets
ORed together, which doesn't matter so long as it never
changes (because V | V == V for all V).

Of course, things go poorly if you have two different values, V and W,
at an address which are both stored in the cache. Then the result is V
| W, which isn't necessarily equal to either instruction.

Avoiding this needs priority encoders, which are rather large, so it
seems the usual approach is to disallow branching to modified code
before flushing the cache. This patch teaches the testbench to do this
properly.

Sadly, this means there's now a connection between the core agent and
the memory agent: the memory agent can no longer generate new seeds
whenever it pleases.
2020-06-04 08:09:51 +01:00
Rupert Swarbrick
2c195c591e Reorder check in icache scoreboard for more helpful error messages
The test is the same, but the reordering means that if we see an error
that we weren't expecting, we'll complain about that, rather than
about the instruction data itself.
2020-06-04 08:09:51 +01:00
Rupert Swarbrick
deb163c544 Add a "caching" sequence for ICache testing 2020-06-02 09:22:14 +01:00
Rupert Swarbrick
0577104c98 Track how well the icache caches tight loops in the scoreboard
In practice, this check will only trigger if you constrain your core
to fetch in a tight loop for a while and you don't invalidate the
cache very often.

The check has an assumption about the cache size (at least 1kB), but
that only has an effect on the tightness of the loop needed before we
do any checking.
2020-06-02 09:22:14 +01:00
Rupert Swarbrick
3f37114f5b Change how enable/disable is configured in ICache core sequence
This version allows us to force the cache to be always enabled, as
well as allowing us to force always disabled, as before.
2020-06-02 09:22:14 +01:00
Rupert Swarbrick
7f6543499a Move "enable" state into ICache core agent's sequence
This was in the driver, but that turns out to be a mistake if you want
to control the cache with "always on" as well as "always off".
2020-06-02 09:22:14 +01:00
Dawid Zimonczyk
d51b50350f Add support for running Icache test with Riviera-PRO 2020-05-29 10:07:23 +01:00
Tom Roberts
f26cc9bb58 [dv] Add missing signal to i$ tb
- Fixes #904
- Will need a future update to drive the new signal properly

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-05-27 11:31:02 +01:00
Tom Roberts
db149880bd [dv/icache] revert ff5c0c5
Ready valid dependency now resolved in rtl, see #850

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-05-26 09:29:36 +01:00
Tom Roberts
65b21c6741 [dv/icache] Add qualifications in protocol checker
The rdata driven by the cache is undefined when there is an error. There
are therefore no requirements on stability.

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-05-26 09:29:36 +01:00
Rupert Swarbrick
30fff2da79 Get rid of some duplication in ICache virtual sequences 2020-05-21 16:38:20 +01:00
Rupert Swarbrick
ab3ff7d57e Use control knobs rather than subclassing in ICache core sequences
This is a bit less verbose than what we had: we can just set the
control knobs in the virtual sequence rather than subclassing
everything.
2020-05-21 16:38:20 +01:00
Rupert Swarbrick
d750d3e53e Add passthru test for ICache
This test constrains the address range (giving the cache a chance to
do some caching), but leaves the cache disabled. Seed changes are more
frequent than usual, to give us a good chance to spot any caching that
shouldn't have happened.
2020-05-21 16:38:20 +01:00