Commit graph

1713 commits

Author SHA1 Message Date
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
Philipp Wagner
b95ff21c28 Update lowrisc_ip to lowRISC/opentitan@3f35d4e4
Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
3f35d4e42757aeed3f9699d7965f20af41d9d36f

* [dv] Initial flash_ctrl DV testbench (Srikrishna Iyer)
* [dv] Cleanup Xcelium warning: unconnected port (Srikrishna Iyer)
* [dv] Cleanup Xcelium warning: default arg (Srikrishna Iyer)
* [dv] Clean up for phase_read_to_end (Weicai Yang)
* [DV] Remove urandom from task port (Dawid Zimonczyk)
* [doc] Update lint commands in readme (Michael Schaffner)
* [dv] Refactor watchdog_ok_to_end (Srikrishna Iyer)

Signed-off-by: Philipp Wagner <phw@lowrisc.org>
2020-05-29 10:03:26 +01:00
Philipp Wagner
dd39ec0c91 Optimize use of RAM primitive in icache
The RAM primitive provides a way to specify the granularity of the write
mask (wmask) signal, which can be used to select an appropriate
implementation (e.g. a SRAM with only byte selects, or no subselects at
all).
2020-05-27 11:38:33 +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