Commit graph

460 commits

Author SHA1 Message Date
Udi
b72d263eac [dv] Manually update dvsim config files
Signed-off-by: Udi <udij@google.com>
2020-05-05 10:42:56 -07:00
Udi
7710947fe6 [dv] enable writeback stage and branch ALU
Signed-off-by: Udi <udij@google.com>
2020-05-05 09:09:33 -07:00
Udi
7dafdf6456 [dv/fcov] Fix Ibex log parsing script
Signed-off-by: Udi <udij@google.com>
2020-05-04 02:28:06 -07:00
Rupert Swarbrick
717cb90aef Rework choosing new seeds in icache UVM memory model
The flow for a memory fetch is:

  1. Cache requests data for a memory address
  2. Agent spots the request, maybe signalling a PMP error
  3. Grant line goes high, at which point the request is granted.
  4. Sometime later (in-order pipeline), agent sends a response

Occasionally, we need to pick a new seed for the backing memory.
Before this patch, we picked these seeds at point (3).

Unfortunately this was wrong in the following case:

  1. We're switching from seed S0 to seed S1.
  2. The request is spotted with seed S0 and doesn't signal a PMP error
  3. The request is granted and we switch to seed S1.
  4. We respond with data from memory based on S1, with no memory
     error either

If S1 would have caused a PMP error, the resulting fetch (no error,
but data from S1) doesn't match any possible seed and the scoreboard
gets confused.

This patch changes to picking new seeds at (2) to solve the problem.
This isn't quite enough by itself, because if a request is granted on
a clock-edge, a new request address might appear and there isn't a
guaranteed ordering in the simulation between the new request and the
old grant (both things happen at the same time). To fix this, the
response sequence now maintains a queue of requests and their
corresponding seeds to make sure that all the checks for a fetch are
done with a single seed.

The patch also gets rid of the seed state in the memory model: it
turns out that this didn't really help: the scoreboard is always
asking "what would I get with this seed?" and now the sequence is
doing something similar.
2020-05-04 09:57:30 +01:00
Rupert Swarbrick
439513ba68 Fixes to invalidation logic in icache core agent
Firstly, the pulse shouldn't be zero length (since that wouldn't
actually do anything).

Also, 1 time in 500 is too rare for either invalidations or "long
invalidations", I think, so this patch also increases how often we see
each.
2020-05-01 10:21:45 +01:00
Rupert Swarbrick
34098bc315 Increase length of icache tests
Now that we have a working framework, let's drive some more items
through (a bit more efficient than running more tests, and also less
skewed by the initial cache invalidation).
2020-05-01 10:21:45 +01:00
Rupert Swarbrick
f717c04ad1 Initial icache scoreboard
This correctly tracks fetch addresses and fetched data. It understands
changing memory seeds, errors, invalidations and enable/disable.

Most of the complexity is in checking whether a fetch got the right
answer, given the set of memory seeds that it might have used. This
isn't conceptually hard (use a local memory model; check each seed and
see whether it matches), but is a bit fiddly in practice. In
particular, a misaligned 4-byte load might actually correspond to two
different seeds: note the nested loops in check_compatible_2.

The general flow of these checks is:

     check_compatible
  -> check_compatible_<i>    (loop over plausible seeds)
  -> is_seed_compatible_<i>  (ask the memory what data to expect)
  -> is_fetch_compatible_<i> (compare seen/expected data)

Note that the check_compatible_<i> functions have a "chatty"
parameter. This is to help with debugging when something goes wrong:
if the check fails then the check_compatible function calls it again
with chatty=1, which dumps a list of the seeds we checked and why they
didn't match.

Other than the scoreboard itself, this patch also adds a "seed" field
to ibex_icache_mem_bus_item. This is used by the monitor to inform the
scoreboard when a new memory seed has been set. Obviously, this
doesn't correspond to any actual monitored signals, but we need some
sort of back channel, and this looked like a sensible way to do it.

The patch also stops reporting PMP responses to the scoreboard: it
turns out the scoreboard doesn't need to care about them, so we can
simplify things slightly this way.

At the moment, the scoreboard doesn't check that fetched data isn't
stored when the cache is disabled. You could see this by disabling the
cache, fetching from an address, enabling the cache and changing the
memory seed, and fetching from the address again. I think it would be
reasonably easy to make an imprecise version of the check, where a
seed gets discarded from the queue if its live period is completely
within a period where the cache was disabled, but I want to wait until
we've got some tests that actually get cache hits before I implement
this.

There's also a slight imprecision in the busy line check that needs
tightening up.

Both of these to-do items have TODO comments in the code.
2020-05-01 08:49:23 +01:00
Udi
be9af77b35 [dv] makefile:cov LSF arg fix
Signed-off-by: Udi <udij@google.com>
2020-04-29 14:41:25 -07:00
ganoam
a68923a404 [bitmanip] Add ZBP Instruction Group
This commit implements the Bit Manipulation Extension ZBP instruction
group: grev[i] (generalized reverse), gorc[i] (generalized or-combine)
and [un]shfl[i] (generalized shuffle) and all of their
pseudo-instructions.

Architectural details:
        * grev / gorc: The shifter structure features only a right
        shift structure. In order to perform a left shift therefore the
        operand needs to be reversed, shifted and reversed again. The
        architecture of the back-reversal is implemented in stages
        which are activated using the general reverse / orcombine
        operand, or a signal marking left-shifts.

        * shfl / unshfl: Also known as zip / unzip or interlace /
        uninterlace operation. These instructions are implemented
        in their own structure using a permutation networ of 6 stages.
        4 stages thereof implement the shuffle permutations. the first
        and last stage is the flip stage, which effectively reverse s
        the order of the inner stages, for unshuffle operations.

Signed-off-by: ganoam <gnoam@live.com>
2020-04-29 11:10:44 +02:00
Rupert Swarbrick
7919c7db3f Re-enable PMP/MEM errors in icache testbench
This reverts the top commit from PR #793, which is no longer
necessary (since our parent commit, which corrects the core's
behaviour).
2020-04-29 08:28:29 +01:00
Rupert Swarbrick
99471e5d25 Always branch after an error in icache UVM tests
If the cache returns an error to the core, the core must then issue a
branch before it tries to fetch again from the cache. This patch makes
this work by getting the core driver to respond with a (newly defined)
ibex_icache_core_rsp_item containing an error flag.
2020-04-29 08:28:29 +01:00
Rupert Swarbrick
272e35521c Fix UVM Makefiles to match updated dvsim from previous patch 2020-04-28 17:42:02 +01:00
Rupert Swarbrick
3782d15b2d Don't fetch on the same cycle as a branch in the icache core agent
The actual core might signal ready at the same time as branching. If
it does so, it will ignore any data that comes back on that
cycle (since it's redirecting the fetch either way).

The test code monitor wasn't ignoring the fetch. In practice, this
doesn't usually matter, because the cache works correctly(!) and the
data is what we expect. However, it isn't quite right if we saw an
error on the previous cycle. In this case, the cache can carry on
responding with errors, which all gets a bit confusing, and also
confuses my prototype scoreboard.
2020-04-28 07:58:21 +01:00
Rupert Swarbrick
8f348d73d1 Fix scheduling for PMP errors in icache testbench
The previous approach didn't work because of possible ordering
problems that make it difficult to convert between "combinatorial
signals" and transactions.

When things are aligned with a clock edge, you solve this problem with
a clocking block (which, by default, guarantees to sample "just after"
the clock edge, once the signals have settled). Since this signal is
not aligned with a clock, we have to be a little more careful.

Before and after this patch, the code in the monitor is "eager" and
might send glitchy transactions through to the sequence, which ends up
passing the data back to the driver. This patch teaches the driver to
cope with that, by passing the address that caused a PMP error as part
of the memory response. Armed with that address, the driver can figure
out whether the error flag applies to what's currently on the bus, or
whether it's a few delta cycles behind, in which case it can safely
just drop the glitch.
2020-04-28 07:58:21 +01:00
Rupert Swarbrick
82337cf1a2 Delete stray debug print from ibex_icache_mem_resp_seq 2020-04-28 07:58:21 +01:00
Pirmin Vogel
8bd0423962 [dv] Enable verification of the Bitmanip Extension with OVPsim and Spike
This is related to lowRISC/ibex#703.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2020-04-27 09:51:57 +02:00
Rupert Swarbrick
9af4b3973c Add a monitor to the icache <-> mem interface in UVM testbench
This is enough to report transactions up to the scoreboard. At the
moment, there's nothing listening, but you can see them going through
with

    make run VERBOSITY=h

and then looking at the dumps in run.log.
2020-04-27 08:25:06 +01:00
Rupert Swarbrick
d7c90e519e Add SV assertions on icache <-> mem interface in UVM testbench
This adds SVA properties for the memory <-> cache interface. Rather
than pollute the actual interface, these are wrapped in their own
if ("ibex_icache_mem_protocol_checker").
2020-04-27 08:25:06 +01:00
Rupert Swarbrick
28fd68738f Add a monitor to the icache <-> core interface in UVM testbench
This is enough to report transactions up to the scoreboard. At the
moment, there's nothing listening, but you can see them going through
with

    make run VERBOSITY=h

and then looking at the dumps in run.log.
2020-04-27 08:16:22 +01:00
Rupert Swarbrick
27604d466b Add SV assertions to icache <-> core interface in UVM testbench
This adds SVA properties for the cache <-> core interface. Rather than
pollute the actual interfaces, these are wrapped in their own
interface ("ibex_icache_core_protocol_checker").
2020-04-27 08:16:22 +01:00
Rupert Swarbrick
d67847e6b8 Add heartbeat tracking to ICache testbench
This pretty much follows various UVM tutorials, except that we use the
sequencers (ibex_icache_core_sequencer, ibex_icache_mem_sequencer) to
poke the heartbeat objection object if there is one.

Doing this means that we can dispense with the explicit test timeout
in the hjson file: the test will fail if there is no activity on
either interface for 2000 cycles (this number is chosen because the
longest "wait a bit" time is 1200 cycles in the core driver).
2020-04-27 07:56:02 +01:00
Udi
321a3d267f [dv] fix spurious LSF enabling
Signed-off-by: Udi <udij@google.com>
2020-04-23 15:15:41 -07:00
Rupert Swarbrick
cf33bfeae0 Temporarily disable PMP/MEM errors in icache testbench
This allows tests to run to completion. Unfortunately, the core agent
currently has a bug in how it handles errors (if a sequence item
terminates with an error and is followed by a 'req' sequence item, the
test hangs).

I'll fix that in a separate patch soon (and revert this commit), but
don't want the memory agent changes to depend on the fix.
2020-04-23 11:12:45 +01:00
Rupert Swarbrick
5cd874ea71 Initial memory agent for ICache UVM testbench
As with the core agent, this doesn't yet have any proper monitoring,
and the testbench has no scoreboard, so we're not actually checking
anything.

However, it *does* implement a slave agent which can respond to
instruction fetches from the icache. This runs a test to completion,
try:

   make -C dv/uvm/icache/dv run WAVES=1

Note that the timeout in the hjson file was too small, so this bumps
it to a larger value. A later patch will replace the timeout with a
heartbeat monitor, which should be much cleaner.

The exact dance for the UVM reactive slave is complicated. See
dv/uvm/icache/dv/ibex_icache_mem_agent/README.md for the details.
2020-04-23 11:12:45 +01:00
Udi
d0ea6fe449 [dv] update directory paths for riscv-dv coverage
Signed-off-by: Udi <udij@google.com>
2020-04-22 00:46:00 -07:00
Udi
b4e5d91842 [dv] fix PMP compile option, update basic pmp test
Signed-off-by: Udi <udij@google.com>
2020-04-18 15:02:01 -07:00
Dawid Zimonczyk
f8f68945c0 update yaml file for riviera 2020-04-17 09:05:21 -07:00
Rupert Swarbrick
5a188342e7 Add clocking blocks to the ibex_icache_core_agent
Since this agent doesn't currently do any monitoring (will be
addressed in a later patch), the monitor_cb clocking block doesn't do
very much at the moment.

The driver_cb clocking block *is* used, though. The input lines are just
those needed to drive things correctly (ready is needed to do
ready/valid signalling properly; err is needed to abort instruction
fetches and do a branch after an error).

I've marked the output signals as negedge: this doesn't really make
any difference to simulation results, since the design samples
everything on posedge, but makes it rather easier to read dumped
waves.
2020-04-17 09:15:08 +01:00
Rupert Swarbrick
bce473b1dc Fix variable names in icache scoreboard code 2020-04-17 09:15:08 +01:00
Rupert Swarbrick
a93fc88f6f Fix scratch-root in icache/dv/Makefile 2020-04-17 09:15:08 +01:00
Rupert Swarbrick
5c51bc7e4d Rename ibex_icache_agent -> ibex_icache_core_agent
There is more than one icache-specific agent that we need for the
icache testbench, so "ibex_icache_agent" isn't a very helpful name.
This commit was pretty much automated, except for a few spacing
cleanups, with commands like:

    git grep -l ibex_icache_agent | \
      xargs sed -i 's!ibex_icache_agent!ibex_icache_core_agent!g'

(and then rename the directory and files).
2020-04-15 10:52:04 +01:00
Rupert Swarbrick
38422a03bc Minimal code for the 'core agent' in icache UVM testbench
This fills in the sequencer, driver etc. to actually drive signals.
You can "run" a test with

  make -C dv/uvm/icache/dv run

This won't do anything useful (it will stop with a timeout) because
there is no memory agent yet.
2020-04-15 10:04:03 +01:00
Rupert Swarbrick
754a8f3d09 Add a simple Makefile to wrap running dvsim for icache tests
This patch also includes a hacky test timeout. We'll remove this (or
at least make it bigger) when we start actually running data through
the tests, but this is handy for now because it means simulations
finish without having to pkill them.
2020-04-15 10:04:03 +01:00
Udi
58c0e33334 [dv] fix timing issue in ebreakmu_test
Signed-off-by: Udi <udij@google.com>
2020-04-09 09:06:32 -07:00
Rupert Swarbrick
98046adfbc Initial icache testplan
This doesn't list all that many entries, possibly because the icache
doesn't really have many modes of operation (enabled/disabled;
invalidating).
2020-04-09 13:09:12 +01:00
Rupert Swarbrick
e1bb1ed82e Fill out an initial DV plan for the icache
This currently has quite a lot of TBD sections, but should hopefully
describe my plan for the UVM testing reasonably well.
2020-04-09 09:22:13 +01:00
Greg Chadwick
f73da9ef3b [dv] Remove IUS support
IUS lacks support for certain language features used in Ibex (such as
use of $clog2 in localparam definitions) so remove it as a simulator
that can be used by dv.
2020-04-08 18:17:34 +01:00
Udi
47678a855a [dv] Fix running on LSF
Signed-off-by: Udi <udij@google.com>
2020-04-08 09:21:09 -07:00
Greg Chadwick
1d2959e00a [dv] Record failure on log processing error
Previous to this change the entire process would die on an issue with
processing a single log. This alters it so this will just add to the
failure count with the error logged and the log processing continued to
its end.
2020-04-07 09:47:57 +01:00
Greg Chadwick
75148da58c [dv] Quit on UVM errors by default 2020-04-07 09:47:57 +01:00
Greg Chadwick
4f39160843 [dv] Define `UVM for DV sim compiles
Without `UVM defined assertion failures don't result in regression
failure as they do not produce UVM reports.
2020-04-03 11:18:13 +01:00
udinator
e1b3cd1842
[dv] fix DSim simulation command options (#760)
Signed-off-by: Udi <udij@google.com>
2020-04-02 09:35:40 -07:00
udinator
add91d544d
[dv] fix timing issue in single_step test (#749)
Signed-off-by: Udi <udij@google.com>
2020-03-31 11:59:01 -07:00
Rupert Swarbrick
f90877b766 Fix destination for dumped waves in dv/uvm
The previous code correctly dumped to "waves.fsdb" if you had Verdi
installed. Unfortunately, it dumped to the same file name if you
didn't, which was rather confusing.

This patch passes a "DUMP_BASE" environment variable, rather than
"DUMP_FILE", which doesn't include the extension. Then it appends the
correct extension at runtime in the TCL, when we tell VCS what sort of
dumping to do.

The code now also checks for all environment variables before reading
them, allowing defaults if they don't exist. The defaults might not be
what you want, but a syntax error at this point causes VCS to sit
waiting for terminal input (with no stdin!), which is kind of annoying.

I've also removed the copy-pasted Verdi documentation. Apart from
anything else, this is probably copyright, so we shouldn't have a copy
in the repo!
2020-03-31 09:28:25 +01:00
udinator
e92b51e188
[dv] move all SV interface includes into ibex_dv.f (#747)
Signed-off-by: Udi <udij@google.com>
2020-03-27 11:38:32 -07:00
udinator
f69c6fbabd
[dv] initial icache testbench (#711)
* [dv] add vendor .hjson files for dv tools

Signed-off-by: Udi Jonnalagadda <udij@google.com>

* Update common_ifs to lowRISC/opentitan@0d7f7ac7

Update code from subdir hw/dv/sv/common_ifs in upstream repository
https://github.com/lowRISC/opentitan to revision
0d7f7ac755d4e00811257027dd814edb2afca050

Signed-off-by: Udi Jonnalagadda <udij@google.com>

* Update csr_utils to lowRISC/opentitan@0d7f7ac7

Update code from subdir hw/dv/sv/csr_utils in upstream repository
https://github.com/lowRISC/opentitan to revision
0d7f7ac755d4e00811257027dd814edb2afca050

Signed-off-by: Udi Jonnalagadda <udij@google.com>

* Update dv_lib to lowRISC/opentitan@0d7f7ac7

Update code from subdir hw/dv/sv/dv_lib in upstream repository
https://github.com/lowRISC/opentitan to revision
0d7f7ac755d4e00811257027dd814edb2afca050

Signed-off-by: Udi Jonnalagadda <udij@google.com>

* Update dvsim to lowRISC/opentitan@0d7f7ac7

Update code from subdir util/dvsim in upstream repository
https://github.com/lowRISC/opentitan to revision
0d7f7ac755d4e00811257027dd814edb2afca050

Signed-off-by: Udi Jonnalagadda <udij@google.com>

* Update uvmdvgen to lowRISC/opentitan@0d7f7ac7

Update code from subdir util/uvmdvgen in upstream repository
https://github.com/lowRISC/opentitan to revision
0d7f7ac755d4e00811257027dd814edb2afca050

Signed-off-by: Udi Jonnalagadda <udij@google.com>

* Update dv_utils to lowRISC/opentitan@0d7f7ac7

Update code from subdir hw/dv/sv/dv_utils in upstream repository
https://github.com/lowRISC/opentitan to revision
0d7f7ac755d4e00811257027dd814edb2afca050

Signed-off-by: Udi Jonnalagadda <udij@google.com>

* [dv] initial icache testbench

Signed-off-by: Udi Jonnalagadda <udij@google.com>

* [dv] add top_pkg and its core file to icache/dv

Signed-off-by: Udi Jonnalagadda <udij@google.com>

* [dv] update ibex_core and ibex_icache corefile dependencies

Signed-off-by: Udi Jonnalagadda <udij@google.com>

* [dv] add .vpd support for wave-dumping

Signed-off-by: Udi Jonnalagadda <udij@google.com>
2020-03-27 11:02:47 -07:00
Udi
74816ae124 [dv] update mtvec alignment in Makefile
Signed-off-by: Udi <udij@google.com>
2020-03-27 09:52:01 +00:00
udinator
8aae0ba31a
[dv] remove return value from the compare() step (#732)
Signed-off-by: Udi <udij@google.com>
2020-03-25 15:01:16 -07:00
Rupert Swarbrick
e70213d0ef Fix incorrect indentation in sim.py 2020-03-25 14:13:43 +00:00
Dawid Zimonczyk
2bf6f5fca2 correct passing argument for sim_opts 2020-03-25 13:52:01 +00:00