Commit graph

1819 commits

Author SHA1 Message Date
Tom Roberts
8934267c78 [rtl] Fix instr_valid_i exception issue
- The controller state machine could only progress to FLUSH to handle an
  exception if instr_valid_i was set
- When the exception comes from a load/store in the Writeback stage, and
  no new instruction has been driven into the ID stage, this could cause
  exception to be missed
- The instr_valid_i qualification is therefore removed from the state
  machine as all relevant signals inside that if block are already
  qualified by instr_valid_i anyway
- Fixes #849

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-05-15 11:13:20 +01:00
Tom Roberts
5fd3cad9a1 [config] Change default PMPNumRegions
Change default to 4 rather than 0. Makes no difference when PMPEnable==0
and gets rid of lint failures due to 0 array referencing (0 is an
unsupported value for this parameter).

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-05-15 11:12:31 +01:00
Tom Roberts
a5ae9f4995 [rtl] Add data-independent timing to multdiv_fast
- No early return on divide by zero

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-05-15 10:19:55 +01:00
Tom Roberts
d19189ba43 [rtl] data-independent execution for multdiv_slow
- Remove all early exit's from multiply and divide operations when in
  fixed time execution mode.

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-05-15 10:19:55 +01:00
Tom Roberts
0ba0ad5a43 [rtl] multdiv_slow general tidy-up
- Correct some typos and fix various lint / style guide issues
- No functional changes

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-05-15 10:19:55 +01:00
Greg Chadwick
10bc77ddcc [dv] Enable use of ibex configs in DV 2020-05-15 09:03:04 +01:00
Greg Chadwick
00b46d9abe [cfg] Add PMP parameters to ibex_config.yaml
Also renames configs as part of this as they start to get unweildy if
all features get described in the config name.
2020-05-15 09:03:04 +01:00
ganoam
9bd3350bb3 [bitmanip] Add sext.b/h instructions
This commit implements the Bit Manipulation Extension sign-extend
instructions: sext.b (sign-extend byte) and sext.h (sign-extend half
word).

The implementation is basically a one-liner, duplicating the msb of the
byte / half-word into the msb of the output register.

Signed-off-by: ganoam <gnoam@live.com>
2020-05-14 22:03:45 +02:00
ganoam
fac404a6f3 [bitmanip] Add ZBF instruction group
This commit implements the Bit Manipulation Extension ZBF instruction
group, which consists only of the one instruction bfp (bit-field
place).
This instruction places a field of length len < 16 from rs2 in rs1 at
offset off.

Architectureal details:
        The implementation works exactly the same as proposed by Claire
        Wolf in her reference implementation.
        1. bfp_mask = slo(o, len)
        2. bfp_result =
                (rs1 & ~(bfp_mask << off)) | (rs2 & bfp_mask) << off
                        ^------ shifter-^
        The existing shifter structure is shared for the indicated
        operation.

Impact on area:

        * When synthesizing without the B-extension, the 2 stage
        design seems to move the timing bottleneck, leading to
        optimizations which result in an area increase by 1 kGE,
        when synthesized with tight timing constraints. For the
        3 stage configuration there is no change.
        When synthesized with relaxed timing constraints there is no
        significant change in either configuration.

        * With the B-extension enabled, the area increase for tight
        timing constraints is 1.1-1.2 kGE. For relaxed timing
        constraints that is ~0.4kGE

Impact on timing: No significant impact.

Signed-off-by: ganoam <gnoam@live.com>
2020-05-14 21:34:49 +02:00
ganoam
0afd000a09 [bitmanip] Add ZBE Instruction Group
This commit implements the Bit Manipulation Extension ZBE instruction
group: bext (bit extract) and bdep (bit deposit).

Architectural details:
        * bext/bdep: A new butterfly and inverse butterfly network is
        implemented. The generation of its controlbits depend on a
        parallel prefix bitcount of the deposit / extract mask.

        * bitcounter: The path for bext / bdep instructions traverses
        the bit counter and the butterfly network, resulting in both a
        larger delay and area. To mitigate the bitcounter has been
        changed from a serial bit counter to a radix-2 tree structure.

        * grev/gorc: Zbp instructions general reverse and general
        or-combine have as of yet shared the shifters reversal
        structure. It has proven benefitial to area and timing to reuse
        the novel butterfly network instead

The butterfly network itself consumes ~3.5kGE and ~1.1kGE for synthesis
with tight and relaxed timing constraints respectively. Including the
optimizations of the bitcounter and grev/gorc, the overall change in
area consumption is +4.6kGE (+1.2kGE) and +3.3kGE (+1.1kGE) for
synthesis with tight (relaxed) timing constraints for 2- and 3-stage
configurations respectively. For tight timing constraints that is a
growth by around ~10%, for relaxed ~5%.

The impact on the maximum frequency is negligable.

Signed-off-by: ganoam <gnoam@live.com>
2020-05-14 16:43:19 +02:00
Rupert Swarbrick
dd12d97934 Print commands in core_ibex/Makefile when VERBOSE=1
See issue #852 for discussion.
2020-05-12 16:36:04 +01:00
Rupert Swarbrick
9e19d3ea63 Check for correct "high" bits in icache core protocol checker 2020-05-12 12:08:50 +01:00
Rupert Swarbrick
22b0609b4f Weaken some checks on cache in ibex_icache_core_protocol_checker
Once the cache has passed an error to the core, we now allow it to
wiggle its valid, addr, rdata, err and err_plus2 lines however it sees
fit until the core issues a new branch.

Since the core isn't allowed to assert ready until then, the values
will not be read and this won't matter.

This was exposed by

  make -C dv/uvm/icache/dv run SEED=1314810947 WAVES=1
2020-05-12 12:08:50 +01:00
Rupert Swarbrick
d51d970089 Fix assertion in ibex_icache_core_protocol_checker
This assertion is supposed to say "the core may not request more data
from the cache when there's no valid address".

Unfortunately, I'd represented "requesting more data" by req being
high, rather than ready being high. This is wrong: req is a signal
saying "the core isn't currently asleep". ready (of a ready/valid
pair) is the one I wanted.
2020-05-12 12:08:50 +01:00
Udi
4814b6776f Update google_riscv-dv to google/riscv-dv@162ea73
Update code from upstream repository https://github.com/google/riscv-
dv to revision 162ea7312d21ac0b8ae73669fb68bf284b68f851

* Add experimental python based generator (google/riscv-dv#567)
  (taoliug)
* Check return code for ovpsim (google/riscv-dv#566) (taoliug)
* fix bug in PMP handler routine (google/riscv-dv#562) (udinator)

Signed-off-by: Udi <udij@google.com>
2020-05-11 13:35:21 -07:00
Rupert Swarbrick
592b9fb793 Add an empty common_cov_excl.el
Our hjson-based logic for constructing VCS commands always passes
-elfile, but this doesn't work if the following list of arguments is
empty.

It seems difficult to figure out how to teach dvsim.py to do something
like "prepend X to Y if Y is nonempty", so let's just add an empty
file for now.
2020-05-11 17:40:24 +01:00
Rupert Swarbrick
ac7da2b274 Allow coverage collection in icache/dv/Makefile 2020-05-11 17:40:24 +01:00
Rupert Swarbrick
ff5c0c5823 Always assert ready in core driver for ICache UVM testbench
This works around a bug tracked in issue #850.
2020-05-11 16:28:48 +01:00
Tom Roberts
863fb56eb1 [dv/cs_registers] Remove .* binding
- Only specifying the signals that the TB cares about means people will
  no longer have to update this file every time the cs_regs port list
  changes

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-05-07 14:58:28 +01:00
Rupert Swarbrick
4f349a094e Specify "-xlrm uniq_prior_final" for VCS
As discussed in issue #845, this tells VCS to wait for signals to
settle in combinatorial blocks before checking uniqueness in
constructs like unique case.

Otherwise things like this can cause spurious warnings:

  always_comb b = ~in;

  always_comb c = in;

  always_comb begin
    unique case (1'b1)
      b: x = 1;
      c: x = 0;
      default: x = 0;  // not that it matters, but this won't happen
    endcase
  end

For example, on a falling edge of the in signal, if the processes are
executed in the order 1, 3, 2 then the unique case block will appear
to see both b and c true at the same time.
2020-05-07 10:22:01 +01:00
Udi
e1ec5b63f8 Update google_riscv-dv to google/riscv-dv@ace2805
Update code from upstream repository https://github.com/google/riscv-
dv to revision ace2805b63100f46c3dcd02b4fcf6a7184582110

* Fix vector instruction randomization (google/riscv-dv#560) (taoliug)
* Change generate_instr_stream to a virtual function (google/riscv-
  dv#559) (taoliug)
* fix bug with compressed ebreak generation (google/riscv-dv#557)
  (udinator)
* update PMP exception handlers to 'fix' config CSRs (google/riscv-
  dv#546) (udinator)
* Add bitmanip doc (google/riscv-dv#555) (weicaiyang)
* specify physical pmp addresses from cmdline (Udi Jonnalagadda)
* Fix branch hit coverage issue (google/riscv-dv#551) (taoliug)
* B extension coverage part2 (google/riscv-dv#548) (weicaiyang)
* B extension coverage part1 (google/riscv-dv#542) (weicaiyang)
* Fix typo in riscv_instr_test_lib (google/riscv-dv#545) (ANIL SHARMA)
* Add target rv64imcb (google/riscv-dv#543) (weicaiyang)

Signed-off-by: Udi <udij@google.com>
2020-05-07 01:23:20 -07:00
Udi
b72d263eac [dv] Manually update dvsim config files
Signed-off-by: Udi <udij@google.com>
2020-05-05 10:42:56 -07:00
Udi
7710947fe6 [dv] enable writeback stage and branch ALU
Signed-off-by: Udi <udij@google.com>
2020-05-05 09:09:33 -07:00
Tom Roberts
15ab023e25 [rtl] Stop regfile writeback for load errors
- A data or PMP error should stop the register file from being updated
- Fixes #832

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-05-05 09:26:55 +01:00
Tom Roberts
9451df2965 [prim] Split out primitives used by icache
- All primitives the icache uses are specified in distinct core files
  with names that match those existing (or about to exist) in OpenTitan
- When vendoring-in Ibex, none of those primitives need to be copied
  across, since OpenTitan will use its own versions
- Relates to lowRISC/opentitan/#1231

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-05-04 17:19:58 +01:00
Udi
7dafdf6456 [dv/fcov] Fix Ibex log parsing script
Signed-off-by: Udi <udij@google.com>
2020-05-04 02:28:06 -07:00
Rupert Swarbrick
717cb90aef Rework choosing new seeds in icache UVM memory model
The flow for a memory fetch is:

  1. Cache requests data for a memory address
  2. Agent spots the request, maybe signalling a PMP error
  3. Grant line goes high, at which point the request is granted.
  4. Sometime later (in-order pipeline), agent sends a response

Occasionally, we need to pick a new seed for the backing memory.
Before this patch, we picked these seeds at point (3).

Unfortunately this was wrong in the following case:

  1. We're switching from seed S0 to seed S1.
  2. The request is spotted with seed S0 and doesn't signal a PMP error
  3. The request is granted and we switch to seed S1.
  4. We respond with data from memory based on S1, with no memory
     error either

If S1 would have caused a PMP error, the resulting fetch (no error,
but data from S1) doesn't match any possible seed and the scoreboard
gets confused.

This patch changes to picking new seeds at (2) to solve the problem.
This isn't quite enough by itself, because if a request is granted on
a clock-edge, a new request address might appear and there isn't a
guaranteed ordering in the simulation between the new request and the
old grant (both things happen at the same time). To fix this, the
response sequence now maintains a queue of requests and their
corresponding seeds to make sure that all the checks for a fetch are
done with a single seed.

The patch also gets rid of the seed state in the memory model: it
turns out that this didn't really help: the scoreboard is always
asking "what would I get with this seed?" and now the sequence is
doing something similar.
2020-05-04 09:57:30 +01:00
Tom Roberts
c862f104af [rtl] icache error signalling fix
- Data valid should only be signalled when the current beat is
  signalling an error
- PMP errors for future beats can sneak in while waiting for the
  current beat

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-05-04 09:16:55 +01:00
Tom Roberts
5bcacb876d [rtl] Fix jump signal stuck high during stall
- Stalls due to preceding memory accesses in the WB stage shouldn't
  cause the jump signal to remain high.
- The jump signal being stuck high causes repeated memory accesses to
  the same address, and unnecessary stalling.
- Fixes lowRISC/opentitan#2099

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-05-04 08:28:59 +01:00
Pirmin Vogel
fd01562ff7 [doc] Minor fixes
Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2020-05-01 20:09:59 +02:00
Pirmin Vogel
3922b2582f [rtl] Rework generation and use of mult/div_sel/en
Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2020-05-01 17:29:59 +02:00
Pirmin Vogel
511c59db18 [rtl] Switch multdiv_en to multdiv_sel where possible
Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2020-05-01 17:29:59 +02:00
Rupert Swarbrick
439513ba68 Fixes to invalidation logic in icache core agent
Firstly, the pulse shouldn't be zero length (since that wouldn't
actually do anything).

Also, 1 time in 500 is too rare for either invalidations or "long
invalidations", I think, so this patch also increases how often we see
each.
2020-05-01 10:21:45 +01:00
Rupert Swarbrick
34098bc315 Increase length of icache tests
Now that we have a working framework, let's drive some more items
through (a bit more efficient than running more tests, and also less
skewed by the initial cache invalidation).
2020-05-01 10:21:45 +01:00
Rupert Swarbrick
f717c04ad1 Initial icache scoreboard
This correctly tracks fetch addresses and fetched data. It understands
changing memory seeds, errors, invalidations and enable/disable.

Most of the complexity is in checking whether a fetch got the right
answer, given the set of memory seeds that it might have used. This
isn't conceptually hard (use a local memory model; check each seed and
see whether it matches), but is a bit fiddly in practice. In
particular, a misaligned 4-byte load might actually correspond to two
different seeds: note the nested loops in check_compatible_2.

The general flow of these checks is:

     check_compatible
  -> check_compatible_<i>    (loop over plausible seeds)
  -> is_seed_compatible_<i>  (ask the memory what data to expect)
  -> is_fetch_compatible_<i> (compare seen/expected data)

Note that the check_compatible_<i> functions have a "chatty"
parameter. This is to help with debugging when something goes wrong:
if the check fails then the check_compatible function calls it again
with chatty=1, which dumps a list of the seeds we checked and why they
didn't match.

Other than the scoreboard itself, this patch also adds a "seed" field
to ibex_icache_mem_bus_item. This is used by the monitor to inform the
scoreboard when a new memory seed has been set. Obviously, this
doesn't correspond to any actual monitored signals, but we need some
sort of back channel, and this looked like a sensible way to do it.

The patch also stops reporting PMP responses to the scoreboard: it
turns out the scoreboard doesn't need to care about them, so we can
simplify things slightly this way.

At the moment, the scoreboard doesn't check that fetched data isn't
stored when the cache is disabled. You could see this by disabling the
cache, fetching from an address, enabling the cache and changing the
memory seed, and fetching from the address again. I think it would be
reasonably easy to make an imprecise version of the check, where a
seed gets discarded from the queue if its live period is completely
within a period where the cache was disabled, but I want to wait until
we've got some tests that actually get cache hits before I implement
this.

There's also a slight imprecision in the busy line check that needs
tightening up.

Both of these to-do items have TODO comments in the code.
2020-05-01 08:49:23 +01:00
Udi
be9af77b35 [dv] makefile:cov LSF arg fix
Signed-off-by: Udi <udij@google.com>
2020-04-29 14:41:25 -07:00
ganoam
a68923a404 [bitmanip] Add ZBP Instruction Group
This commit implements the Bit Manipulation Extension ZBP instruction
group: grev[i] (generalized reverse), gorc[i] (generalized or-combine)
and [un]shfl[i] (generalized shuffle) and all of their
pseudo-instructions.

Architectural details:
        * grev / gorc: The shifter structure features only a right
        shift structure. In order to perform a left shift therefore the
        operand needs to be reversed, shifted and reversed again. The
        architecture of the back-reversal is implemented in stages
        which are activated using the general reverse / orcombine
        operand, or a signal marking left-shifts.

        * shfl / unshfl: Also known as zip / unzip or interlace /
        uninterlace operation. These instructions are implemented
        in their own structure using a permutation networ of 6 stages.
        4 stages thereof implement the shuffle permutations. the first
        and last stage is the flip stage, which effectively reverse s
        the order of the inner stages, for unshuffle operations.

Signed-off-by: ganoam <gnoam@live.com>
2020-04-29 11:10:44 +02:00
Rupert Swarbrick
7919c7db3f Re-enable PMP/MEM errors in icache testbench
This reverts the top commit from PR #793, which is no longer
necessary (since our parent commit, which corrects the core's
behaviour).
2020-04-29 08:28:29 +01:00
Rupert Swarbrick
99471e5d25 Always branch after an error in icache UVM tests
If the cache returns an error to the core, the core must then issue a
branch before it tries to fetch again from the cache. This patch makes
this work by getting the core driver to respond with a (newly defined)
ibex_icache_core_rsp_item containing an error flag.
2020-04-29 08:28:29 +01:00
Rupert Swarbrick
272e35521c Fix UVM Makefiles to match updated dvsim from previous patch 2020-04-28 17:42:02 +01:00
Rupert Swarbrick
6a557b47ee Update dvsim to lowRISC/opentitan@1d17b122
Update code from subdir util/dvsim in upstream repository
https://github.com/lowRISC/opentitan to revision
1d17b1225d324c81da522c69317335a83edd5ddb

* [dvsim] PEP8 fixes in dvsim (Rupert Swarbrick)
* [dvsim] Fix PEP8 error and slightly tidy code in testplan_utils.py
  (Rupert Swarbrick)
* [dvsim] Correct bug in regression creation in dvsim's Modes.py
  (Rupert Swarbrick)
* [dv] Enable xcelium coverage publish (Weicai Yang)
* [tool/dvsim] Enable Xcelium coverage and clean up email arg (Cindy
  Chen)
* [dv] add send email option to dvsim.py (Cindy Chen)
* [util/dvsim] Convert time to UTC timezone (Eunchan Kim)
* [dvsim] Fix broken link of xbar testplan (Weicai Yang)
* [dvsim] Add CTRL-C support (Weicai Yang)
* [dvsim] Initial verible lint integration (Michael Schaffner)
* [dvsim] Add control of max job submission per second (Weicai Yang)
* [dv/tool] Add support to choose sub-cfgs (Cindy Chen)
* [dvsim] Enable coverage collection with Xcelium (Srikrishna Iyer)
* [dvsim] Update lint flow due to changes in synthesis (Michael
  Schaffner)
* [dvsim] Synthesis target integration (Michael Schaffner)
* [dvsim] Added fusesoc generator for RAL (Srikrishna Iyer)
* [dvsim] Fix summary table (Greg Chadwick)

Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
2020-04-28 17:42:02 +01:00
Rupert Swarbrick
39b6bdf2a3 Update dv_lib to lowRISC/opentitan@1d17b122
Update code from subdir hw/dv/sv/dv_lib in upstream repository
https://github.com/lowRISC/opentitan to revision
1d17b1225d324c81da522c69317335a83edd5ddb

* [dv] Add excl for rstmgr, pwrmgr and fix top-level csr test (Weicai
  Yang)
* [dv] Allow dv_lib-based sequences to have different RSP/REQ types
  (Rupert Swarbrick)
* [dv] Support WO, RO type for mem (Weicai Yang)
* [dv,sw] SW -> DV tb self-checking mechanism - SV (Srikrishna Iyer)
* [dv/top] Fix csr rw test (Cindy Chen)

Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
2020-04-28 09:06:00 +01:00
Rupert Swarbrick
3782d15b2d Don't fetch on the same cycle as a branch in the icache core agent
The actual core might signal ready at the same time as branching. If
it does so, it will ignore any data that comes back on that
cycle (since it's redirecting the fetch either way).

The test code monitor wasn't ignoring the fetch. In practice, this
doesn't usually matter, because the cache works correctly(!) and the
data is what we expect. However, it isn't quite right if we saw an
error on the previous cycle. In this case, the cache can carry on
responding with errors, which all gets a bit confusing, and also
confuses my prototype scoreboard.
2020-04-28 07:58:21 +01:00
Rupert Swarbrick
8f348d73d1 Fix scheduling for PMP errors in icache testbench
The previous approach didn't work because of possible ordering
problems that make it difficult to convert between "combinatorial
signals" and transactions.

When things are aligned with a clock edge, you solve this problem with
a clocking block (which, by default, guarantees to sample "just after"
the clock edge, once the signals have settled). Since this signal is
not aligned with a clock, we have to be a little more careful.

Before and after this patch, the code in the monitor is "eager" and
might send glitchy transactions through to the sequence, which ends up
passing the data back to the driver. This patch teaches the driver to
cope with that, by passing the address that caused a PMP error as part
of the memory response. Armed with that address, the driver can figure
out whether the error flag applies to what's currently on the bus, or
whether it's a few delta cycles behind, in which case it can safely
just drop the glitch.
2020-04-28 07:58:21 +01:00
Rupert Swarbrick
82337cf1a2 Delete stray debug print from ibex_icache_mem_resp_seq 2020-04-28 07:58:21 +01:00
Tom Roberts
36b05e2ebf [rtl/icache] Fix typo in ram req
Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-04-27 13:52:37 +01:00
Pirmin Vogel
8bd0423962 [dv] Enable verification of the Bitmanip Extension with OVPsim and Spike
This is related to lowRISC/ibex#703.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2020-04-27 09:51:57 +02:00
Rupert Swarbrick
9af4b3973c Add a monitor to the icache <-> mem interface in UVM testbench
This is enough to report transactions up to the scoreboard. At the
moment, there's nothing listening, but you can see them going through
with

    make run VERBOSITY=h

and then looking at the dumps in run.log.
2020-04-27 08:25:06 +01:00
Rupert Swarbrick
d7c90e519e Add SV assertions on icache <-> mem interface in UVM testbench
This adds SVA properties for the memory <-> cache interface. Rather
than pollute the actual interface, these are wrapped in their own
if ("ibex_icache_mem_protocol_checker").
2020-04-27 08:25:06 +01:00
Rupert Swarbrick
28fd68738f Add a monitor to the icache <-> core interface in UVM testbench
This is enough to report transactions up to the scoreboard. At the
moment, there's nothing listening, but you can see them going through
with

    make run VERBOSITY=h

and then looking at the dumps in run.log.
2020-04-27 08:16:22 +01:00