Commit graph

1769 commits

Author SHA1 Message Date
Philipp Wagner
bf5dd7ec15 Icache: It's not a draft any more
The Icache might not be fully perfect, but it's certainly not a draft
any more.
2020-07-03 14:39:48 +01:00
Philipp Wagner
6ca325fa70 Remove outdated documentation
By now, ibex depends not only on the a clock gating cell, but also on
assert macros and a LFSR; there will be more to come. This removed piece
of documentation was from the early days, when only a clock gating cell
was to be provided (and we didn't ship one).

Today, users need to either use FuseSoC, or run fusesoc on the simple
system and "harvest" the resulting files if they want to copy-paste Ibex
into their build system. That's not ideal, but not something we can very
easily fix -- so let's remove the outdated documentation first to at
least reduce the confusion.
2020-07-03 14:25:24 +01:00
Philipp Wagner
b807879aca CI: Show exact command to run Verilator lint
The options were missing, leading to an incomplete command, which makes
it hard to reproduce lint failures locally.
2020-07-03 13:24:17 +01:00
Philipp Wagner
18db64f6fa CI: Enable Verible lint for all configs 2020-07-03 13:24:17 +01:00
Philipp Wagner
df634b9459 CI: use the new binary name of Verible
They switched to new binary names, use these names (the old ones are
still around for backwards-compat, but deprecated).
2020-07-03 13:24:17 +01:00
Philipp Wagner
4ee8b24409 Add a waiver file for Verible lint
The waiver files currently don't support comments, and require the
"empty" regex; bugs have been filed to get that resolved upstream.

But beyond that, waivers are now functional.
2020-07-03 13:24:17 +01:00
Philipp Wagner
67e7417749 Fix Verible lint issues
Fix all remaining issues reported by Verible lint.

It turns out that #965 undid some of the fixes in `ibex_alu.sv`
that were done in #980 around the `SHUFFLE_*`/`FLIP_*` signals.
2020-07-03 12:20:32 +01:00
Rupert Swarbrick
fb2a17a5a4 Add some formal cover properties for ICache
Also (and probably more interestingly) put in the tooling framework to
drive sby in the two different modes.
2020-07-02 15:19:11 +01:00
Rupert Swarbrick
4a20bc4e0d Add an ICacheECC parameter to ICache formal flow
Satisfyingly the formal checks go through with no changes.
2020-07-02 15:19:11 +01:00
Rupert Swarbrick
49c9113d03 Formal protocol checking for icache <-> core interface
This turns out to be quite complicated, because the icache has a lot
of different counters that all track addresses or fill buffer state.
For an inductive proof to go through, you need to make the relations
between them explicit, which takes lots of assertions.

All of the signals defined in the formal_tb are prefixed with 'f_'.
This isn't strictly necessary, but it makes it much easier to see what
came from the design (since we are "bound in", our ports don't have _o
or _i suffixes).

We add a couple of protocol assumptions:

ICache <-> Core:

  - Branch target addresses are half-word aligned
  - The branch_spec signal is driven if branch is

ICache <-> Memory:

  - The bus doesn't respond unless there is an outstanding request
  - The bus doesn't grant more than 4 billion outstanding requests(!)

There's also some protocol state tracking:

  - f_addr_valid tracks whether the ICache currently has an
    architectural address. It goes high with branch_i (which gives the
    cache an address) and goes low when the cache completes a
    transaction with err_o set (since the data is bad, there's no
    notion of a "next address").

  - f_reqs_on_bus tracks the number of requests currently outstanding
    on the bus. This is used for the ICache <-> Memory assumptions
    above. We have some internal assertions that check this equals the
    sum of the "ext" counters minus the sum of the "rvd" counters.

With these assumptions, we can prove:

  - Once asserted, valid_o stays high until a transaction is completed
    by ready_i or until branch_i is asserted (which cancels the
    transaction).

  - While the transaction is pending, addr_o remains stable.

  - While the transaction is pending, err_o remains stable and, if
    err_o is asserted, so does err_plus2_o.

  - While the transaction is pending, if err_o and err_plus2_o are
    high then bottom 16 bits of the returned instruction data imply an
    uncompressed instruction.

  - While the transaction is pending, if err_o is low then the bottom
    16 bits of the returned instruction remain stable.

  - While the transaction is pending, if err_o is low and the bottom
    16 bits of the returned instruction imply an uncompressed
    instruction then the top 16 bits of the returned instruction
    remain stable.
2020-07-02 15:19:11 +01:00
Rupert Swarbrick
ee1ca61fe4 A simple formal flow for the ICache based on SymbiYosys
To get this working, you need a corresponding patch in Edalize, which
adds SymbiYosys as an EDA tool.

At the moment, this proves a couple of simple bus assertions. Later
patches will add more.

There are currently some rough edges to this flow:

  (1) We use a hacky pre_build hook to run sv2v and edit the files in
      the work tree. Among other problems, this means that the any
      failure messages that come out of sby have bogus line numbers.

  (2) Since we haven't yet got bind support in Yosys, we have to
      include a fragment from the design itself.
2020-07-02 15:19:11 +01:00
Rupert Swarbrick
e4dbe46597 Move riscv-formal code into formal/riscv-formal
This leaves a space in the naming hierarchy for other formal tooling,
like the Yosys flow I'm working on.
2020-07-02 15:19:11 +01:00
Philipp Wagner
40a52ab8b4 [doc] Add bitmanip spec to introduction page
We list all specifications we implement, even optional ones. Add
Bitmanip there as well.

Fixes #966
2020-07-02 15:03:50 +01:00
Philipp Wagner
15d378555f [CI] Update Verible version
Verible is still experimental, but having a newer version in CI helps us
to make use of some of its newer features as we move forward (such as
waivers).
2020-07-02 11:57:09 +01:00
Rupert Swarbrick
f35a407906 Update lowrisc_ip to lowRISC/opentitan@5cae0cf1
Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
5cae0cf1fac783e0d0df8c8597bf65322a696a56

* Allow different assertion "backends" in prim_assert.sv (Rupert
  Swarbrick)
* [prim_prince/doc] Update documentation (Michael Schaffner)
* [prim_prince] Add option to instantiate a registers half-way
  (Michael Schaffner)
* [prim_cipher_pkg] Reuse sbox4_8bit to build wider sbox layers
  (Michael Schaffner)
* [dv/prim] add PRESENT testbench (Udi Jonnalagadda)
* [uvmdvgen] Scoreboard update. (Srikrishna Iyer)
* [flash_ctrl dv] Fix V1 tests (Srikrishna Iyer)
* [prim_cipher_pkg] Replicate common subfunctions for other widths
  (Michael Schaffner)
* [prim/present] fix PRESENT decryption bugs (Udi Jonnalagadda)
* [prim/present] fix some PRESENT encryption bugs (Udi Jonnalagadda)
* [dv] Add get_mem DPI function to Verilator simutil (Stefan
  Wallentowitz)
* [lint/entropy_src] Add the entropy source to the lint regression
  (Michael Schaffner)
* [style-lint] Fix some common style lint warnings (Michael Schaffner)
* first set of security checks added to D2 checklist (Scott Johnson)
* [fpv/tooling] add FPV class extension in dvsim (Cindy Chen)
* [dvsim/lint] Minor fixes for printout issues and result parser
  status (Michael Schaffner)
* [syn] Print detailed messages to .md if publication is disabled
  (Michael Schaffner)
* [prim_util] Do not use $clog2() in Xcelium (Philipp Wagner)
* [prim] Update ResetValue parameter in prim_flop_2sync (Timothy Chen)
* Modified some command-line arguments for DSim (Aimee Sutton)
* [prim_util] Make prim_util a package (Philipp Wagner)
* [dv] Move mem checking to scb (Weicai Yang)
* [lint] Make PINCONNECTEMPTY Verilator waiver common (Philipp Wagner)
* [prim] - Fix generic flash enum reference (Timothy Chen)
* [prim_ram_*adv] Mark cfg port as unused (Philipp Wagner)
* [prim_fifo_sync] Use vbits() for simpler code (Philipp Wagner)
* [prim_flash] Add reset to held_part (Eunchan Kim)
* [lint] Add more lint waivers (Philipp Wagner)
* [dv] Add random backdoor for csr_hw_reset (Weicai Yang)
* [dv] Add set_freq_khz in clk_rst_if (Weicai Yang)
* [prim] Close GAPI file handle in primgen (Philipp Wagner)
* [fpv/prim_packer] fix CI failure due to index out of bound (Cindy
  Chen)
* [prim_arbiter_*] Propagate parameter changes (Michael Schaffner)
* [prim_arbiter_tree] Fix incorrect arbitration behavior (Michael
  Schaffner)
* [prim_arbiter_ppc] Add more FPV fairness checks (Michael Schaffner)
* [prim_ram*] Add an assertion that checks wmask consistency (Michael
  Schaffner)
* [memutil] Increase max memory width to 256bit (Tom Roberts)
* [flash] - Add flash info page support (Timothy Chen)

Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
2020-07-01 14:54:13 +01:00
ganoam
1aa4d5a32b [bitmanip] Optimizations and Parametrization
This commit contains some final optimizations regarding the bit
manipulation extension as well as the parametrization into a balanced
version and a full performance version.

Balanced Version:
        * Supports ZBB, ZBS, ZBF and ZBT extensions
        * Dual cycle instructions:
          ror[i], rol, cmov, cmix fsl, fsr[i]
        * Everything else completes in a single cycle.

Full Version:
        * Supports all 32b sub extensions.
        * Dual cycle instructions:
          ror[i], rol, cmov, cmix fsl, fsr[i], crc32[c], bext, bdep
        * Everything else completes in a single cycle.

Notable Changes:
        * bext/bdep are now multi-cycle: Sharing additional register
          with multiplier module
        * grev/gorc instructions are implemented in separate structures
          rather than sharing the shifter or butterfly network.
        * Speed up decision on using rs1 or rs3 for alu_operand_a by
          introducing single-bit register, to identify ternary
          instructions in their first cycle.
        * Introduce enumerated parameter to chose bit manipulation
          implementation

Signed-off-by: ganoam <gnoam@live.com>
2020-06-26 14:43:24 +02:00
Tom Roberts
71b3474781 [rtl] Fix icache xprop issue
- invalidate all ways on a tag error to prevent xprop from the data
  error signal and reduce the likelyhood of multi-way allocations

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-06-25 09:46:35 +01:00
Xiang Wang
684d4205bf Prevent writing CSR_SECURESEED to get the seed of dummy instruction
Although CSR_SECURESEED is unreadable, an attacker can write a new seed,
which brings convenience to the attack. This patch is used to XOR the
historical seed, so that even if the attacker writes a new value to
CSR_SECURESEED , he cannot know the value of the seed.

Signed-off-by: Xiang Wang <merle@hardenedlinux.org>
2020-06-23 11:48:33 +01:00
Michael Schaffner
ae547c8d30 [top_pkg] Fix style lint warnings
Signed-off-by: Michael Schaffner <msf@google.com>
2020-06-22 20:52:15 +01:00
Udi
1f26d93267 [ibex/dv] Add clocking blocks to Ibex interfaces
This PR adds clocking blocks to all major Ibex interfaces and updates
all corresponding interface accesses to use these clocking blocks.

A few notes:

- `ibex_mem_intf` has two driver clocking blocks, one for host side and
  one for device side.
  This is because our Ibex testbench currently provides both host and
  device agents for both I/D interfaces (of course we only use the
  reactive device agents in the main testbench).
- `csr_if` and `dut_if` only have one clocking block each, as all
  signals in each will only be either sampled or driven, never both.
- Some utility tasks have been added to some interfaces to wait for a
  specified number of clock cycles.
2020-06-22 12:07:40 -07:00
Rupert Swarbrick
96cf24a41a Add a stress_all_with_reset ICache test
This is like the stress_all test, picking other sequences at random
and running them back-to-back. The difference is in the reset
behaviour, where we randomly pull the reset line at unexpected times
to try to trigger any strange glitches this might cause.

This requires slight changes to the core and memory drivers, which
need to learn to stop and return early from the current item when they
see a reset.
2020-06-22 17:11:59 +01:00
Rupert Swarbrick
962fc8020c Invalidate in an ICache sequence after a change to mem_err_shift
When we chain sequences together, we are careful to pass seeds between
neighbouring sequences. However, I didn't think to check
mem_err_shift. Before this patch, you see problems if you have a
"caching" sequence followed by a "many_errors" sequence with no reset
and no change of seed and they both happen to pick the same address
range.

The problem is that if the data at address A is cached in the first
sequence, the icache will merrily return it when address A comes up in
the second. However, the change to mem_err_shift might mean that this
would cause a memory error if it hadn't been cached, causing the
scoreboard to get upset.

This patch ensures that we always start a sequence with an
invalidation if there was a previous sequence with a different value
of mem_err_shift.

To do this cleanly, the patch also moves some of the "grab the guts of
the old sequence and put it in the new one" logic from
ibex_icache_combo_vseq and into the underlying sequence classes. The
trick is that a sequence now has a handle to the previous sequence (if
there was one), and can use that to extract whatever information it
needs.
2020-06-22 17:11:59 +01:00
Rupert Swarbrick
e243ab2617 Fix ICache caching window test with combination sequences
This fixes several problems. Firstly, the window_reset function was
switching off tracking until it next saw busy_o go low, which is
correct at the start of time, but not what we want after we've
started. This patch splits that behaviour into a new tracking_reset
function (which calls window_reset). This is called on reset or
invalidate.

Secondly, this check was occasionally failing where we'd have an ECC
sequence (which should disable the check) immediately followed by a
caching sequence with similar addresses. If the window ended in the
caching sequence, we'd see a high fetch ratio and conclude that
something had gone wrong.

Now we clear the window completely whenever we fetch an instruction
when the check is disabled, which should avoid the problem (at worst,
you might get 1 instruction overlap, which is unlikely to matter).

Finally, we move the call to tracking_reset up to the end of the reset
sequence. It doesn't usually matter, but if there's a pending item
from the core monitor with busy = 0, we need to make sure that item
comes in before we set not_invalidating = 1. Otherwise, the scoreboard
incorrectly thinks it's seen the end of the invalidation
sequence (before it's even started) and starts tracking fetch ratios
too early.
2020-06-22 17:11:59 +01:00
Rupert Swarbrick
e7c9b52c36 Add ibex_icache_stress_all test
This runs sequences back-to-back, occasionally resetting between
sequences.

Because our virtual sequences are composed of several smaller
sequences, we have to stop them when the core sequence finishes (see
the calls to kill() in ibex_icache_base_vseq). We also have to make
sure that we don't drop items in the memory sequence, which can be
pre-empted as part of sending a response (see the peek/get code
there).

Finally, the memory sequence also has a current seed and a list of
pending grants: this patch has to copy those across between sequences
to make everything work correctly.
2020-06-22 17:11:59 +01:00
Rupert Swarbrick
41a4811a55 Tidy up properly after overriding class in ICache back_line_seq
This virtual sequence controls what sequence we use in the core agent
with a factory override. We need to make sure that we "tidy up" after
starting it, otherwise every sequence afterwards will use the wrong
core sequence.
2020-06-22 17:11:59 +01:00
Rupert Swarbrick
dc708427d0 Remove empty tasks from ibex_icache_base_vseq.sv
These aren't needed, so no reason to keep the scaffolding.
2020-06-22 17:11:59 +01:00
Rupert Swarbrick
0044ea35f9 Use dv_base_vseq's num_trans field rather than making our own 2020-06-22 17:11:59 +01:00
Rupert Swarbrick
a3b53c875c Control core sequence's transaction count from top in ICache tests
This will have no effect for now: we just move the "pick a number in
the range 800..1000" logic to the virtual sequence.

The reason to do this is for tests that combine sequences: we want to
be able to shorten each component sequence so that the combined test
isn't way longer than the original ones were.
2020-06-22 17:11:59 +01:00
Rupert Swarbrick
2c38d22d99 Remove ibex_icache_sanity_vseq
This derived from ibex_icache_base_vseq but didn't do any other
customisation. Let's just use the base vseq for the test.
2020-06-22 17:11:59 +01:00
Rupert Swarbrick
ad80b0b247 Configure ICache mem_error tests from the vseq (not a test class)
As with the ECC sequence, 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
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
Bert Pieters
fdfdcc0467 [rtl] disable clock between reset and fetch_enable_i
Fixes lowRISC#957

Signed-off-by: Bert Pieters <bert.pieters@gmail.com>
2020-06-22 13:25:39 +02: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
NilsGraf
f9badaf073 Update lec_sv2v.sh 2020-06-19 17:08:39 -07:00
NilsGraf
31d797162c Update lec_sv2v.sh 2020-06-19 17:08:39 -07:00
NilsGraf
7bb64842ba Update lec_sv2v.do 2020-06-19 17:08:39 -07:00
Nils Graf
c453436b75 Add LEC script to formally verify sv2v translation 2020-06-19 17:08:39 -07: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
Udi
e8a71c8ac8 Update google_riscv-dv to google/riscv-dv@6cf6b4f
Update code from upstream repository https://github.com/google/riscv-
dv to revision 6cf6b4f389272d8ff5e2b397af43ac6c0dfba2e2

* Update init value for floating point reg (google/riscv-dv#615)
  (weicaiyang)
* temporarily comment out 4 vector instructions to re-enable coverage
  flow (google/riscv-dv#616) (udinator)
* Fix vector load/store instruction encoding (google/riscv-dv#614)
  (taoliug)
* Add user_init.s to allow custom initialization routine
  (google/riscv-dv#613) (taoliug)
* Fix vector extension config register initialization (google/riscv-
  dv#610) (taoliug)
* Add floating point coverage part2 (google/riscv-dv#600) (weicaiyang)
* Add MAX LMUL configure (google/riscv-dv#609) (taoliug)
* Fix vector unit strided load/store instruction stream name
  (google/riscv-dv#608) (taoliug)
* Update pygen source files (google/riscv-dv#602) (ANIL SHARMA)
* Add vector strided load/store test (google/riscv-dv#601) (taoliug)
* make <main> 4-byte aligned when enabling PMP (google/riscv-dv#596)
  (udinator)
* Fix ius compilation issue (google/riscv-dv#599) (taoliug)
* Integrate Andes's vector extension work to upstream (google/riscv-
  dv#598) (taoliug)
* Fix kernal setcion  PTE setting issue (google/riscv-dv#594)
  (taoliug)
* Add flake8 check for pygen (google/riscv-dv#589) (Hai Hoang Dang)
* Fix MPRV setting issue, it's causing problem for exception handling
  with virtual address translation on (google/riscv-dv#593) (taoliug)
* Fix VSETVL generation issue (google/riscv-dv#591) (taoliug)
* Fix jump instruction stream label issue (google/riscv-dv#590)
  (taoliug)
* Add pygen_src files (aneels3)

Signed-off-by: Udi <udij@google.com>
2020-06-18 11:05:30 -07:00
Philipp Wagner
b302b6da92 Fix documentation markup for tracer
The unordered list wasn't rendered properly due to a missing empty line
before it. Purely editorial change.
2020-06-18 15:40:54 +01:00
Bert Pieters
4eece98875 [rtl] Remove use of `define in decoder
Fixes #30

Signed-off-by: Bert Pieters <bert.pieters@gmail.com>
2020-06-18 15:38:05 +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