Commit graph

1719 commits

Author SHA1 Message Date
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
Rupert Swarbrick
8c11bd780c Update lowrisc_ip to lowRISC/opentitan@c91b50f3
This is manually squashed with a change to import dv_base_reg too, a
new module that was created by Weicai's "csr backdoor support" patch.
It's needed because it is a dependency of dv_lib.

Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
c91b50f357a76dae2ada104e397f6a91f72a33da

* [prim_ram*_adv] Update core files and add prim_util dependency
  (Michael Schaffner)
* [prim_ram*_adv] Implement Byte parity in prim_ram*_adv (Michael
  Schaffner)
* [dvsim] Run tests in "interleaved" order (Rupert Swarbrick)
* [dvsim] Remove unnecessary getattr/setattr calls from SimCfg.py
  (Rupert Swarbrick)
* [dv] Add support for multiple ral models (Srikrishna Iyer)
* [rtl] Fix prim flash dependency (Srikrishna Iyer)
* [prim_fifo_sync] Make FIFO output zero when empty (Noah Moroze)
* [dv] csr backdoor support (Weicai Yang)
* [prim] Add a "clog2 width" function (Philipp Wagner)
* [dvsim] Allow max-parallel to be set in the environment (Rupert
  Swarbrick)
* [dvsim] Fix --reseed argument (Rupert Swarbrick)
* [prim_ram/rom*_adv] Break out into individual core files (Michael
  Schaffner)
* [prim_rom] Align port naming with prim_ram* (Michael Schaffner)
* [dv] Allow a test to have "simple" timestamps (Rupert Swarbrick)
* [dvsim] Improve --help message (Rupert Swarbrick)
* [dvsim] Remove unused --local argument (Rupert Swarbrick)
* [dvsim] Small tidy-ups to mode selection in SimCfg.py (Rupert
  Swarbrick)
* [fpv] formal compile fix required by VC Formal (Cindy Chen)
* [dvsim] Fix error detection logic in Deploy.py (Rupert Swarbrick)

Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
2020-06-12 16:15:11 +01:00
Tom Roberts
d79eb58ae5 [rtl] Simplify I$ ECC error handling
- Remove the timing optimisations that delay the factoring-in of ecc
  errors into valid_o.
- Optimisations are probably unnecessary here due to the minimal logic
  hanging off valid_o, and the optimisations cause protocol checker
  violations.

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-06-12 14:04:30 +01:00
Greg Chadwick
066b91a076 [rtl] Use outer generate loop for latch RF
This matches the style used in the FF based register file. It gives each
register its own always block with a single enable rather than having
multiple registers with enables in a single always block.

Signed-off-by: Greg Chadwick <gac@lowrisc.org>
2020-06-12 12:05:48 +01:00
Tom Roberts
7207a04028 [doc] Add top-level status table
- Some basic info about a few possible design points and their
  area/perf/dv status

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-06-12 11:15:22 +01:00
Tom Roberts
b6a0275523 [configs] Add a maxperf config
Gives the option of a maximum performance configuration without PMP
enabled, which is more of an orthogonal security feature.

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-06-12 11:15:22 +01:00
Greg Chadwick
3c55a72d08 [rtl] Use gated clock for wb_stage and rf
Corrects a typo, ibex_wb_stage and ibex_register_file were being
supplied with the ungated clk.
2020-06-12 10:45:51 +01:00
Greg Chadwick
207cac3ced [rtl] Use generate loop in FF register file
By giving each register its own always_ff block clock gating is more
obvious to synthesis tools.

This also includes some minor naming tweaks to make use of the _q
convention for flops.
2020-06-12 10:31:54 +01:00
Tom Roberts
5ecaa11c63 [rtl] Fix writeback stage interrupt issue
- If an interrupt arrives at the same time as a load/store instruction
  is in ID stage, the interrupt must wait until load/store completes.
  Without the WB stage this happens naturally as the core stalls. With
  the WB stage, we need to allow the load/store to progress to the WB
  stage (and clear the ID stage) then hold back the interrupt until it
  completes.
- Also cleaned up some lsu related stalling terms and signal naming.

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-06-10 15:13:32 +01:00
Tom Roberts
78e8fb639d [rtl] Remove incorrect LSU assertion
- Protocol-wise data_err_i is notionally X when !data_rvalid_i
- In addition, the design does not appear to rely on the asserted
  behaviour
- Removing as it is firing in chip-level OT simulations

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-06-10 15:13:32 +01:00
Tom Roberts
b81c311481 [doc] Clarify fetch_enable_i meaning
Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-06-10 14:44:24 +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
Rupert Swarbrick
38eb68d3cf Add missing dependency on python3-bitstring to python-requirements 2020-06-08 16:45:29 +01:00
Tom Roberts
85ce3874eb [syn] Update path to prim_assert
- Also remove unsigned keyword stripping which is no longer required

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-06-08 11:20:09 +01:00
Tom Roberts
bfa531c039 [rtl] Move some assertions around
- Prevents errors due to empty generate blocks when passed through sv2v

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-06-08 11:20:09 +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
Eunchan Kim
3c35e44301 Fix Writeback stage lint errors
- unpacked array decending order
- unspecified generate block

Signed-off-by: Eunchan Kim <eunchan@opentitan.org>
2020-06-04 23:33:04 +01:00
Rupert Swarbrick
640a868293 Update lowrisc_ip to lowRISC/opentitan@d78da129
Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
d78da129c7f2b115ccabd1c3af199e0e5812f365

* [dv] Fix loop when waiting for end of run phase in dv_base_monitor
  (Rupert Swarbrick)
* [util] Remove docgen references (Tobias Wölfel)
* [dvsim] Small tidy-ups in dvsim.py command line parsing (Rupert
  Swarbrick)
* [dvsim] Tidy up wave dumping logic (Rupert Swarbrick)
* [dv/xbar] Add chip-level xbar support (Weicai Yang)
* [prim] Fix lint errors (Pirmin Vogel)
* [prim] Rework how primgen.py writes out parameter lists for
  instantiations (Pirmin Vogel)

Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
2020-06-04 16:26: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
Greg Chadwick
023d86d912 [sw] Fix typo in simple system exception handler
Signed-off-by: Greg Chadwick <gac@lowrisc.org>
2020-06-02 13:45:46 +01:00
Greg Chadwick
c0ae8ffb99 [rtl] Fix issue with ID/EX exceptions
When a potential exception occurs in ID/EX controller must wait for any
outstanding instruction in WB to complete before resolving it. The
instruction in WB may also have an exception which takes priority over
ID/EX.

Signed-off-by: Greg Chadwick <gac@lowrisc.org>
2020-06-02 13:45:46 +01:00
Greg Chadwick
833bdefe33 [rtl] Fix exception priority for writeback stage
With the writeback stage enabled the controller can see a load or store
error from the writeback stage whilst seeing some other fault/exception
from ID/EX (e.g. an instruction fetch error). The writeback stage fault
must take priority, however without the writeback stage the
priortisation changes.

This introduces more explicit prioritisation logic for faults/exceptions
and gives the correct prioritisation for configurations both with and
without a writeback stage.

Fixes #912

Signed-off-by: Greg Chadwick <gac@lowrisc.org>
2020-06-02 13:45:46 +01:00
Tom Roberts
ff5375db5c [rtl] Make speculative branch optional
- The speculative branch behaviour causes a performance degradation of
  around 3% in the max config. This change enables that behaviour only
  the maximum PMP config, which is where it is most needed for timing
  closure.

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-06-02 13:41:29 +01:00
Tom Roberts
f190e3abe4 [rtl] Fix PMP NA4 address matching
- Split out address matching into less than, greater than and equals to
  correctly match NAPOT, NA4 and TOR modes.
- Relates to #902

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-06-02 13:41:03 +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
Udi
f4366264e4 Update google_riscv-dv to google/riscv-dv@1ad73cc
Update code from upstream repository https://github.com/google/riscv-
dv to revision 1ad73cc43f8f84d93d49040f8b2928e74efdd854

* Fixes for ML tests (Udi Jonnalagadda)
* Add missing default case to pmp_config (google/riscv-dv#583)
  (udinator)
* various PMP exception handler fixes (google/riscv-dv#581) (udinator)
* convert handshake doc to rst format (google/riscv-dv#580) (udinator)
* Update coverage (google/riscv-dv#584) (weicaiyang)

Signed-off-by: Udi <udij@google.com>
2020-06-01 08:48:10 -07:00
Tom Roberts
4b01580a7b [rtl] prefetch buffer performance fix
- The prefetch buffer needs to know when space is available in the fetch
  FIFO to accept a new external request.
- This change updates that logic to look at what is in the FIFO and what
  is outstanding on the bus to decide when space is available rather
  than always assuming the maximum number of requests are outstanding.
- This improves the usage efficiency of the FIFO and fixes #574

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-06-01 08:59:51 +01:00
Rupert Swarbrick
059d3f324f Add missing Python dependency on premailer library
This dependency gets pulled in with dvsim.py since OpenTitan commit
1aff665d2, vendored in with Ibex commit 1bbcce0.
2020-05-29 10:29:03 +01:00
Dawid Zimonczyk
d51b50350f Add support for running Icache test with Riviera-PRO 2020-05-29 10:07:23 +01:00