Commit graph

1676 commits

Author SHA1 Message Date
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
Philipp Wagner
45567667f1 [CI] Install wheel for easier package installation
... and to get around warnings when using pip without wheel being
present. No functional change expected.
2020-05-27 10:23:15 +01:00
Philipp Wagner
72f0ead9f7 [CI] Add dependency on pyyaml
Pyyaml is needed for primgen (coming next), and for ibex_config.py.
Install it through python-requirements.txt. This requires,
unfortunately, an uninstallation of the distribution-provided version
first (otherwise pip cannot install it).
2020-05-27 10:23:15 +01:00
Philipp Wagner
b1222719de Fix deprecation warning in ibex_config.py
Fix a deprecation, to be removed in Python 3.10.

See https://docs.python.org/3/library/collections.html:
"Deprecated since version 3.3, will be removed in version 3.10: Moved
Collections Abstract Base Classes to the collections.abc module. For
backwards compatibility, they continue to be visible in this module
through Python 3.9."
2020-05-27 08:58:48 +01:00
Tudor Timi
817ce4aea5 Add '.gitignore' entry for file generated by Xcelium 2020-05-26 19:57:54 +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
Rupert Swarbrick
c011fda40e Update lowrisc_ip to lowRISC/opentitan@249b4c31
Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
249b4c316cd6626d13e17edd8a52ca60c004af96

Since we deleted the lock file in the previous commit, this has no
shortlog, but note that the remote SHA matches that in the grandparent
commit (so we haven't missed anything).

Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
2020-05-26 16:41:48 +01:00
Rupert Swarbrick
93dd719a54 Merge vendor scripts for opentitan imports
This combines the existing vendor files to use the new mapping
functionality added to the vendoring tool.
2020-05-26 16:41:48 +01:00
Rupert Swarbrick
1bbcce07ca Update opentitan vendor imports to lowRISC/opentitan@249b4c31
This commit was generated by running

    for hj in $(grep -l opentitan vendor/*.vendor.hjson); do
      $opentitan/util/vendor.py -U -c $hj
    done

and then squashing together all the resulting commits. It will be
followed by a patch that combines these vendor.hjson files (using the
vendor tool's new "mapping" functionality), but we need a patch first
to get everything in sync before squashing together.

Individual commit messages below:

*****

Update common_ifs to lowRISC/opentitan@249b4c31

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

* [dv] This fixes a padctrl reset issue in the chip level tb (Michael
  Schaffner)

*****

Update csr_utils to lowRISC/opentitan@249b4c31

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

* [dv] csr_excl_item printed msg cleanup (Srikrishna Iyer)
* [dv] Fix top-level mem test (Weicai Yang)
* [doc] Fix typo in CSR exclusions (Michael Schaffner)
* [dv] Fix failures in test csr_mem_rw_with_rand_reset (Weicai Yang)

*****

Update dv_lib to lowRISC/opentitan@249b4c31

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

* [dv/chip] fix csr_hw_reset X assertion issue (Cindy Chen)
* [dv] Use phase_ready_to_end to handle end of test (Weicai Yang)
* [dv] Fix failures in test csr_mem_rw_with_rand_reset (Weicai Yang)

*****

Update dv_utils to lowRISC/opentitan@249b4c31

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

* [dv] Use uvm_config_db to control tlul_assert (Weicai Yang)
* [dv] Add begin...end around if statement in macro (Weicai Yang)
* [dv] Fix timeout due to too many non-blocking TL accesses (Weicai
  Yang)
* [spi_device/dv] Add interrupt seq (Weicai Yang)

*****

Update dvsim to lowRISC/opentitan@249b4c31

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

* [dvsim] Enable round-trip of env variables into log (Philipp Wagner)
* [dvsim] Support for running pre-built SW tests (Srikrishna Iyer)
* [dvsim] Print what cmd is executed in the log (Srikrishna Iyer)
* [dvsim] Specify encoding of opened files as UTF-8 (Philipp Wagner)
* [dvsim] Simplify factory methods for FlowCfg (Rupert Swarbrick)
* [dvsim] small fix on css style (Cindy Chen)
* [dvsim] support css format for email (Cindy Chen)
* [doc] Rename Hardware -> Development Stages (Sam Elliott)

*****

Update uvmdvgen to lowRISC/opentitan@249b4c31

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

* [uvmdvgen] Minor env gen fix (Srikrishna Iyer)
* [doc] Rename Hardware -> Development Stages (Sam Elliott)
* [dv] Use uvm_config_db to control tlul_assert (Weicai Yang)
* [uvmdvgen] Automate checklist gen, fixes (Srikrishna Iyer)
* [doc] Unify dashboard, manual spec table (Srikrishna Iyer)
* [dvsim] Added fusesoc generator for RAL (Srikrishna Iyer)
2020-05-26 16:41:48 +01:00
Tom Roberts
12b39476c0 [rtl] Add speculative branch signal
- Drive a speculative version of the branch signal into the IF stage to
  drive address muxing
- The speculative signal is the same as the regular branch signal but
  assumes all conditional branches are taken
- This breaks the timing path from branch condition calculation into
  address muxing (and therefore PMP error calculation)
- When the branch is not taken, any external request we might otherwise
  have made is suppressed
- This has a minor performance cost (0.8% without I$, ~0% with I$)

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-05-26 09:41:37 +01:00
Tom Roberts
b4d952e297 [assertions] Tweak xprop assertion qualifiers
- Tighten up enable conditions to stop properties firing when there is
  an instruction fetch error

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-05-26 09:33:50 +01:00
Tom Roberts
99c740e504 [rtl] Prevent xprop from fetch fifo
- data can be X when an error is output
- prevent X getting into the valid and address signals

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-05-26 09:33:50 +01:00
Tom Roberts
344279906f [rtl] Fix PMP address matching
- For TOR matching, match should be range_low <= addr < range_high
- Adapt masking so TOR matching can still be reused for NAPOT matching
- Relates to #864

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-05-26 09:33:50 +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
Tom Roberts
84c5373c27 [rtl] Various small icache bugfixes
- Remove any ready -> valid dependency by allowing the skid buffer to
  accept data when the core is not ready
- Tighten-up behaviour around invalidations and cache enable/disable
- Remove xprop through output_compressed from invalid data when driving errors
- Make behaviour more consistent where speculative requests return
  different data/error conditions to existing cache hit

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-05-26 09:29:36 +01:00
Tobias Wölfel
46fab41f5b [rtl] Remove redundant assignment 2020-05-25 16:47:25 +01:00
Tobias Wölfel
d1854e8cb5 [rtl] Update RVFI order
Use the stage value which contains the last value.
2020-05-25 16:47:25 +01:00
Tobias Wölfel
12f4f3b9ae [rtl] Forward register data with status
Instead of accessing the signals via the module instance, use the
signals connected to the output port of the module.

Only set the values for RS1/2 if they are used.

Without this addition an instruction without a valid encoding for a
register would reuse invalid data as the address of the register.
Certain checks require that the data must match the register content if
the address is non-zero.

Reuse the signal from the instruction decoder to set the registers to
non-zero values only if the instruction contains a valid encoding for
the register.
2020-05-25 16:47:25 +01:00
Tobias Wölfel
f45b3eca99 [rtl] Set RVFI program counter
The next program counter is not always the program counter of the
fetched instruction. When updating the counter, the actual next
instruction is given by the branch target.
2020-05-25 16:47:25 +01:00
Tobias Wölfel
8779bcd1db [formal] Create Ibex Verilog source
Provide a process to create a single Verilog source of Ibex for
riscv-formal.
Option to enable writeback stage.
2020-05-25 16:47:25 +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
Philipp Wagner
42eee90cf8 Make RAM size configurable in compliance test system
Switch from hardcoding 64 kB in two places to a fixed parameter.
2020-05-22 14:33:11 +01:00
Philipp Wagner
9d976c7ab7 Use prim_generic_ram_1p in ram_1p
ram_1p is almost a copy of the single-port RAM primitive we have in
OpenTitan, called prim_ram_1p, with its generic implementation
prim_generic_ram_1p. Instead of having a copy of that file in Ibex,
consistently use the OpenTitan one.

Unfortunately, ram_1p has slightly different semantics around some
signals, especially rvalid. This commit adjusts the meanings of the
signals for now, since I don't have a way to test the Arty board
which also uses this primitive (together with the compliance test
suite). With the testing in the compliance suite I'm reasonably certain
that the Arty board will work as well.
2020-05-22 14:33:11 +01:00
Stefan Wallentowitz
8b8327d820 [dv] Change performance counter access to DPI
DPI access is suggested and more generic than Verilator direct signal
access. This changes the access to the performance counters from the
Verilator testbench to use DPI instead of directly accessing the
array.

Signed-off-by: Stefan Wallentowitz <stefan.wallentowitz@hm.edu>
2020-05-21 20:34:26 +01:00
Stefan Wallentowitz
b2dded5c27 Change simple system core file to provide default files
To allow other modules to reference the simple system, it must provide
default files. In particular this is useful in DV settings where bind
is used.

Signed-off-by: Stefan Wallentowitz <stefan.wallentowitz@hm.edu>
2020-05-21 20:17:30 +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
Udi
ec42eb4409 Update google_riscv-dv to google/riscv-dv@7b38e54
Update code from upstream repository https://github.com/google/riscv-
dv to revision 7b38e54c5e833f147edc03717b3fd711be923026

* add cmdline configuration of mstatus.mprv (Udi Jonnalagadda)
* Add Xcelium support (google/riscv-dv#579) (Tudor Timi)

Signed-off-by: Udi <udij@google.com>
2020-05-21 08:28:58 -07:00
Tom Roberts
d5ee96fff6 [rtl] Add dummy instruction insertion
- Adds a new module in the IF stage to inject dummy instructions into
  the pipeline
- Control / frequency of insertion is governed by configuration CSRs
- Extra CSR added to allow reseed of the internal LFSR useed for
  randomizing insertion
- Extra logic added to the register file to make dummy instruction
  writebacks look like real intructions (via the zero register)

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-05-21 13:58:01 +01:00
Dawid Zimonczyk
5c7cdfe14e added missing cmp_opts to Riviera compilation options 2020-05-20 15:34:57 +01:00
Greg Chadwick
5b97c26510 [syn] Add more Ibex parameters to flow
Can now control writeback stage inclusion, bitmanip extension and
multiplier implementation.
2020-05-20 12:08:10 +01:00
Greg Chadwick
2cfb5e8d78 [syn] Add STA util for investigating feedthroughs 2020-05-20 12:08:10 +01:00
Rupert Swarbrick
e3fe0c5032 Search backwards for grant seeds in icache memory model
The code before this patch maintained a mailbox, where it would add an
item for each request it saw, and then pop items off until finding the
right address whenever it saw a grant.

Most of the time, you might expect to see a sequence like this:

    request 100
    grant   100
    request 104
    grant   104
    request 108
    grant   108

This scheme is also resilient when glitches (to do with the
delta-cycle scheduling in the simulator) mean you actually see
something like:

    request 999
    request 100
    grant   100
    request 104
    grant   104
    ...

However, there's another source of "mismatch" possible too: the cache
can change the request address if the request hasn't been granted (as
opposed to a ready/valid interface, where this sort of tomfoolery is
not allowed!).

When the cache is branching all over the place, as in the sanity
sequence, this doesn't really matter. But if the branch destinations
are constrained, as in the passthru sequence, you can see things like
this:

    request 100     (1)
    request 120     (2)
    request 100     (3)
    grant   100     (4)
    request 104
    grant   104
    ...

Note that the mailbox has two entries for address 100 when searching
at point (4). This might be ok, but will cause failures if we get a
new seed at (2) or (3).

This patch replaces the mailbox with a queue. New requests get
inserted at the end, as before, but grants search from the end, rather
than the start. This means that when we get to (4) in the example
above, we'll pick the latest seed (and duplicate entries disappear
quickly).
2020-05-19 10:31:27 +01:00