Commit graph

1801 commits

Author SHA1 Message Date
Greg Chadwick
adafa73ca8 [sw] Enable choice of -march= string for CoreMark 2020-07-10 13:49:19 +01:00
Dawid Zimonczyk
1dfddee5e6 Value passed to UVM set_timeout is calculated as 1000000000 basing on 1ns/1ps timescale.
But if you are using precompiled UVM it may be compiled with other timescale depending on compilation option used when it was compiled or tools default timescale value (uvm does not set timescale int the code).
In this case for us precompiled UVM timescale is 1ps/1ps - so UVM gets 1000000000 in set timeout but interprets it as ps. As a result timeout is 1000 times smaller that you expect. That is why we are getting timeouts.
It is hard to find perfect solution. One of them is to recompile the UVM with -timescale 1ns/ps (or whatever you will use for your design).
2020-07-10 10:56:03 +01:00
Dawid Zimonczyk
14f85d3ee3 update readme for Riviera-PRO 2020-07-10 10:29:24 +01:00
Dawid Zimonczyk
9208689c21 correct wrong assignment to enum 2020-07-09 18:12:28 +01:00
Philipp Wagner
4223803d22 Lint: Fix some line length warnings
AscentLint complains about lines longer than 100 characters, as seen in
the nightly lint reports. Fix some (all?) of them.
2020-07-09 13:42:33 +01:00
Philipp Wagner
d0923fa5d1 ibex_counter: Use always_ff
Fix a lint error reported by AscentLint:

```
E   ALWAYS_SPEC:   ibex_counter.sv:59   Edge triggered block may be more accurately modeled as always_ff                 New
```
2020-07-09 13:42:33 +01:00
Philipp Wagner
3d29e5174c Enforce lint of simple system in CI
The existing setup had a couple mixups in them which failed them to be
effective.
2020-07-07 16:21:48 +01:00
Philipp Wagner
85d0ce36cb Specify data type for all parameters in simple_system
Fixes a lint warning.
2020-07-07 16:21:48 +01:00
Philipp Wagner
f688c79565 Clarifications to the README of the simple system
* Mention the need to install `libelf-dev`. Thanks to Bert Pieters for
  reporting this.
* Guide users to install our Python dependencies, including fusesoc and
  edalize, from `python-requirements.txt`, to ensure they have the
  right version.
* Prefer ELF files for Verilator simulations. This makes it easier to
  use existing ELF files from another software build system.

Fixes #1019
2020-07-07 15:35:55 +01:00
Philipp Wagner
c476329608 Only include necessary LFSR primitive
We previously had a dependency on all primitives in Ibex, even though we
only depend on the LFSR primitive. Now that there's a more fine-grained
dependency available, we can use that.

This has the great benefit of restricting all lint tools to only the
code we're interested in, and not linting all primitives in OpenTitan
together with Ibex. This also helps tools like yosys, which aren't able
to parse all of OpenTitan's code yet.
2020-07-07 15:21:32 +01:00
Philipp Wagner
ee0a1cf2ce Update lowrisc_ip to lowRISC/opentitan@ebf4663b
Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
ebf4663b42a9d81d026db5821b5c8249d54f23a7

* [prim_lfsr] Fix description in core file for FPV (Philipp Wagner)
* [prim_lfsr] Factor out into a separate core file (Philipp Wagner)

Signed-off-by: Philipp Wagner <phw@lowrisc.org>
2020-07-07 15:21:32 +01:00
Udi
75dadb5aef [dv/ibex] Add two new interrupt/debug tests
As a result of lowRISC/opentitan#2405 and lowRISC/ibex#928 (reporting
that interrupts that came in while a load instruction was in the ID
stage caused some incorrect behavior in Ibex), this PR adds some new
directed interrupt and debug tests to check that the core behaves
properly during execution of each supported instruction when some
external irq/debug stimulus comes in.

To do this, we use the two new functions `decode_instr(...)` and
`decode_compressed_instr(...)` in `core_ibex_test_list.sv` to "decode"
every instruction that the `core_ibex_instr_monitor_if` sees in the ID
stage of the pipeline. Once the testbench decodes an instruction that
we have not seen before, it can then drive interrupt or debug stimulus
into the core.

Once any given instruction has been detected by the testbench (and
stimulus driven), it will no longer drive stimulus if this instruction
is seen in the decode pipeline (e.g. if we have previously detected a
`c.addi` instruction in the ID stage and have driven irq/debug stimulus,
we will no longer drive stimulus if we see another `c.addi` instruction,
no matter the operands). This is to avoid driving irq/debug stimulus
after every single instruction as this will add a huge unwanted amount
of simulation latency.

A few notes:

- We drive irq/debug stimulus into the core every time we see a
  `wfi` instruction, as otherwise we will timeout as the core waits
  infinitely for some stimulus from the outside world.
- We ignore some system-level instructions (ebreak/mret/dret) and
  illegal instructionsfor now, as driving stimulus during these
  instructions will result in a nested trap, which requires special
  handling.
- The interrupt agent was modified slightly to drive stimulus by
  default on the falling edge of the clock, so this way we can "catch"
  instructions that are in the ID pipeline for only a single cycle.
- The duration for which the testbench raises `debug_req_i` for the core
  is also increased to avoid edge cases where we lower the debug line
  too early (e.g. while long multicycle instructions like `div` are
  executing in the ID stage).
2020-07-06 17:50:59 -07:00
Pirmin Vogel
414ff7eeb0 [doc] Fix spelling of CoreMark
Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2020-07-06 12:30:02 +02:00
Rupert Swarbrick
d7284c2cbd Handle --help properly in simple_system top-level 2020-07-06 10:31:58 +01:00
Rupert Swarbrick
45d3790d40 Update lowrisc_ip to lowRISC/opentitan@9ac4f9c8
Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
9ac4f9c8b924b79eb7d3581b29346a612f705751

* Allow verilated top-levels to do work after a simulation completes
  (Rupert Swarbrick)
* Add some missing dependencies on lowrisc:prim:assert (Rupert
  Swarbrick)

Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
2020-07-06 10:31:58 +01:00
Philipp Wagner
f98ddabee1 Use the Xilinx primitives for the Arty board
Use Xilinx-specific implementations for primitives, such as RAM and the
clock gate (which will now be implemented using a BUFGCE macro, and no
longer with a latch).

Verified in Vivado synthesis to pick up the Xilinx primitive now.
2020-07-06 10:20:39 +01:00
Pirmin Vogel
ede658b92a [doc] Clarify that the supported version of the B extension is a draft
Support for this extension is not experimental (it's fully verified using
RISCV-DV) but the extension might change before being ratified.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2020-07-05 13:52:56 +02:00
Philipp Wagner
0335b69e26 Clean up Verilator sections in core files
- The "PINCONNECTEMPTY" waiver is part of our normal waiver file, no need
  to add it to the tool invocation.
- Recent versions of Verilator choose good defaults for MAKE_OPTS,
  passing it explicitly overrides the settings.
- All Verilator code is now lint clean, we can remove `-Wno-fatal`.
- FST traces are not much slower then VCD traces any more in recent
  Verilator versions, remove the respective comment.
- Align comment about the compile/sim time for tracing with other files
  and OpenTitan.
2020-07-03 17:54:41 +01:00
Philipp Wagner
9e3bec0dc6 Fix and waive Verilator lint errors in tb_cs_registers
Add a waiver for top-level parameters passed in through the command
line, and fix the use within the file.
2020-07-03 17:54:41 +01:00
Philipp Wagner
9bd09c0b74 Remove lowrisc:prim:clock_gating from shared core collections
The clock gating primitive is now a dependency of the
lowrisc:ibex:ibex_core file directly and only used in there, we can
remove it from the simulation or FPGA dependency collections.
2020-07-03 17:08:02 +01:00
Philipp Wagner
465ea2806c Add lint for ibex_simple_system to CI 2020-07-03 16:18:31 +01:00
Philipp Wagner
a10df87daa ibex_simple_system: Add lint target 2020-07-03 16:18:31 +01:00
Philipp Wagner
3bc105492f Simplify lint targets
The only core which needs lint waivers is ibex_core.core; it will then
inherit those waivers to other cores, such as ibex_core_tracing.core,
and higher-up users of these cores (such as the simple system).

Also remove the Verible lint configuration, which happens to be the
default by now. This fixes #736 by making it unnecessary.
2020-07-03 16:18:31 +01:00
Philipp Wagner
c436ea1b1b Remove unrelated files from lint in ibex_core_tracing
The lint target in ibex_core_tracing was used to also lint unrelated
files which are needed for some simulations (e.g. the simple system).
Remove them from there, as they really don't belong there.
2020-07-03 16:18:31 +01:00
Philipp Wagner
89e525ecc8 Add dependency on prim_clock_gating
Ibex depends on a clock gating primitive. This has always been the case;
previously, we have under-specified the dependency list by simply not
including this dependency. This is problematic not only because "IT'S
WRONG!", but also because it breaks self-contained targets, like
Verilator lint, which cannot run on ibex_core or ibex_core_tracing
without having a way to find the clock gating primitive.
2020-07-03 16:18:31 +01:00
Philipp Wagner
a126e4ce98 Fix Ibex description in core file
Ibex has moved on since these descriptions were written.
2020-07-03 16:18:31 +01:00
Philipp Wagner
dbc1f259af icache: Depend on prim_assert
The file ibex_icache.sv is using the assert macros, we need to depend on
them.
2020-07-03 16:18:31 +01:00
Rupert Swarbrick
006617f95a Fix SRAM initialisation for fpga/artya example
This now gets passed to the underlying primitive as a
parameter (instead of a define).
2020-07-03 16:06:48 +01:00
Rupert Swarbrick
7b6ba11a58 Drop SRAM_INIT_FILE from ibex_riscv_compliance.core
This no longer works anyway. It isn't needed for Verilator-based
simulations, and the RISCV compliance suite doesn't support any tool
but Verilator.
2020-07-03 16:06:48 +01:00
Rupert Swarbrick
a8cc0a9ef6 Get simple_system working for VCS
This should probably work for Riviera-PRO too, but that hasn't been
tested.
2020-07-03 15:42:39 +01:00
Rupert Swarbrick
8e9a621f67 Pass MemInitFile parameter from our ram_*p wrappers
Before we changed to vendoring in our RAM primitives from OpenTitan,
there was an SRAM_INIT_FILE define that you could stick in your core
file. That's now gone away, replaced by a parameter (MemInitFile). If
we want to plumb that in, we need to pass it properly through the
wrappers.
2020-07-03 15:42:39 +01:00
Philipp Wagner
711505a17b Update lowrisc_ip to lowRISC/opentitan@976d9b9c
Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
976d9b9c1f563173d9e4571c775b38e70cb1c5d4

* [lint] Add blanket waiver for DECLFILENAME with blackboxes (Philipp
  Wagner)
* [prim_ram_1p_scr] Add a memory scrambling draft implementation
  (Michael Schaffner)
* [prim_subst_perm] Add simple substitution/permutation network
  (Michael Schaffner)
* [dvsim] Fix for lowRISC/opentitan#2686 - missing else (Srikrishna
  Iyer)

Signed-off-by: Philipp Wagner <phw@lowrisc.org>
2020-07-03 15:39:30 +01:00
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