Commit graph

688 commits

Author SHA1 Message Date
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
Udi
5be84f0f04 [dv/ibex] Update riscv_core_setting to match latest version of riscv-dv 2020-06-19 14:45:55 -07: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
Tom Roberts
a2194a723b [dv] Fix DUT probe IF paths
- The testbench probes signals that are unqualified by instr_valid
- This causes events to trigger due to instructions that are not
  actually executed, leading to false timeout failures
- Note this fix alone doesn't eliminate such failures due to another
  issue which will be addressed separately

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-06-16 10:59:57 +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
Bert Pieters
632ebcfe86 [ibex/dv] add Questa support
Signed-off-by: Bert Pieters <bert.pieters@gmail.com>
2020-06-15 11:06:21 +01:00
Rupert Swarbrick
ec6e08d1cf Simplify timestamps in ICache tests 2020-06-12 16:15:11 +01:00
Udi
976e7edcda [ibex/dv] Add several PMP tests
Signed-off-by: Udi <udij@google.com>
2020-06-09 12:52:10 -07: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
Tom Roberts
8332f7de9d [rtl] Rewrite perf counters to be Yosys compatible
- Yosys doesn't like unpacked array partial slicing
- Instantiate counters individually instead

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-06-08 11:20:09 +01:00
Rupert Swarbrick
33ad42debb Spelling fix: seperate -> separate 2020-06-05 11:37:37 +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
7e1852024a [DV] Tie test_en_i to zero
- test_en_i is a DFT feature that shouldn't be enabled for normal
  runtime testing
- Only really affects the clock gate in the design, but is needed for
  running tests with the latch-based register file

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-05-27 11:34:47 +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
Philipp Wagner
8b42024cd5 Use vendored-in primitives from OpenTitan
Instead of using copies of primitives from OpenTitan, vendor the files
in directly from OpenTitan, and use them.

Benefits:

- Less potential for diverging code between OpenTitan and Ibex, causing
  problems when importing Ibex into OT.

- Use of the abstract primitives instead of the generic ones. The
  abstract primitives are replaced during synthesis time with
  target-dependent implementations. For simulation, nothing changes. For
  synthesis for a given target technology (e.g. a specific ASIC or FPGA
  technology), the primitives system can be instructed to choose
  optimized versions (if available).

  This is most relevant for the icache, which hard-coded the generic
  SRAM primitive before. This primitive is always implemented as
  registers. By using the abstract primitive (prim_ram_1p) instead, the
  RAMs can be replaced with memory-compiler-generated ones if necessary.

There are no real draw-backs, but a couple points to be aware of:

- Our ram_1p and ram_2p implementations are kept as wrapper around the
  primitives, since their interface deviates slightly from the one in
  prim_ram*. This also includes a rather unfortunate naming confusion
  around rvalid, which means "read data valid" in the OpenTitan advanced
  RAM primitives (prim_ram_1p_adv for example), but means "ack" in
  PULP-derived IP and in our bus implementation.

- The core_ibex UVM DV doesn't use FuseSoC to generate its file list,
  but uses a hard-coded list in `ibex_files.f` instead. Since the
  dynamic primitives system requires the use of FuseSoC we need to
  provide a stop-gap until this file is removed. Issue #893 tracks
  progress on that.

- Dynamic primitives depend no a not-yet-merged feature of FuseSoC
  (https://github.com/olofk/fusesoc/pull/391). We depend on the same
  functionality in OpenTitan and have instructed users to use a patched
  branch of FuseSoC for a long time through `python-requirements.txt`,
  so no action is needed for users which are either successfully
  interacting with the OpenTitan source code, or have followed our
  instructions. All other users will see a reasonably descriptive error
  message during a FuseSoC run.

- This commit is massive, but there are no good ways to split it into
  bisectable, yet small, chunks. I'm sorry. Reviewers can safely ignore
  all code in `vendor/lowrisc_ip`, it's an import from OpenTitan.

- The check_tool_requirements tooling isn't easily vendor-able from
  OpenTitan at the moment. I've filed
  https://github.com/lowRISC/opentitan/issues/2309 to get that sorted.

- The LFSR primitive doesn't have a own core file, forcing us to include
  the catch-all `lowrisc:prim:all` core. I've filed
  https://github.com/lowRISC/opentitan/issues/2310 to get that sorted.
2020-05-27 10:23:15 +01:00
Philipp Wagner
3f4e706062 Move Verilator simutil upstream to OpenTitan
https://github.com/lowRISC/opentitan/pull/2311 added the Verilator
memutils to OpenTitan as upstream. This commit is the second part of the
story, removing the code from the Ibex repository, and vendoring it back
in from OpenTitan.

This also superseded #844, which has now been included through
OpenTitan.
2020-05-27 10:23:15 +01:00
Tudor Timi
c5b5c7164f Add wave dumping to Xcelium simulation setup 2020-05-26 19:57:54 +01:00
Tudor Timi
3d796ee2aa Fix non-standard usage of '" operator 2020-05-26 19:57:54 +01:00
Tudor Timi
8c6395a257 Add Xcelium simulation setup 2020-05-26 19:57:54 +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
Tobias Wölfel
4e7b981911 [rtl] Add RVFI IXL interface
Following the RISC-V Formal Interface (RVFI) specification the output is
added to set the value of MXL/SXL/UXL of the current privilege level.
2020-05-25 16:47:25 +01:00
ganoam
66687e927c [bitmanip] Add ZBR instruction group
This commit implements the Bit Manipulation Extension ZBR instruction
group: crc32[c].[bhw].

CRC-32 (CRC-32/ISO-HDLC) and CRC-32C (CRC-32/ISCSI) are directly
implemented. The CRC operation solves the following equation using
binary polynomial arithmetic:

rev(rd)(x) = rev(rs1)(x) * x**n mod {1, P}(x),

where {1,P}(x) denotes the crc polynomial. Using barret reduction one
can write this as

rd = (rs1 >> n) ^ rev(rev( (rs1 << (32-1)) cx rev(mu)) cx P)
                      ^-- cycle 0--------------------^
     ^-- cycle 1 ------------------------------------------^

Where cx denotes carry-less multiplication and mu = polydiv(x**64,
{1,P}), omitting the MSB (bit 32).

The implementation increases area consumption by ~0.6kGE for synthesis
with relaxed timing constraints. With tight timing constraints that is
~1.6kGE. There is no significant impact on frequency.

Signed-off-by: ganoam <gnoam@live.com>
2020-05-22 17:21:03 +02:00