Compare commits

..

855 commits

Author SHA1 Message Date
Andreas Kurth
594ea976c9 [dv] Plan test for DM accesses in debug mode
Signed-off-by: Andreas Kurth <adk@lowrisc.org>
2025-04-03 08:48:00 +00:00
Hao
2678654820 fix: Illegal instruction display message
When encountering certain illegal compressed instructions, incorrect instruction information was displayed. Now, illegal instructions can be printed correctly.
2025-03-26 15:46:21 +00:00
Marno van der Maas
6e466c1504 Verification should be done with ibex_cosim branch
This resolves comment: https://github.com/lowRISC/riscv-isa-sim/pull/25#issuecomment-2655147799
2025-02-26 11:05:04 +00:00
Gary Guo
9e99ec79e2 [ci] switch CI runner from Ubuntu 20.04 to 22.04
Signed-off-by: Gary Guo <gary.guo@lowrisc.org>
2025-02-19 17:15:26 +00:00
Gary Guo
eba210965a [ci] update verible version to match OT
Signed-off-by: Gary Guo <gary.guo@lowrisc.org>
2025-02-19 17:15:26 +00:00
Gary Guo
fa40368300 [ci] remove Azure Pipelines magic commands
Signed-off-by: Gary Guo <gary.guo@lowrisc.org>
2025-02-19 17:15:26 +00:00
Greg Chadwick
60fbb6ba2f [cosim] Update comment on set_mip in Cosim interface
The concept of pre and post MIP values was introduced a while ago but
the comments in the interface weren't updated to explain what they are.
2025-02-18 16:56:40 +00:00
Greg Chadwick
d53035bf64 [rtl] Remove low utility assertions
This removes several assertions from `ibex_controller`. They aimed to
ensure that controller behaviour was correct on exception behaviour
(e.g. ensuring that a pending interrupt will actually trigger an
interrupt). However they've proved to be flaky and hard to maintain with
multiple edge cases needing to be accounted for.

The co-simulation checking in functional verification will catch the
same issues these assertions catch. The assertions (when working
correctly) would cause a failure directly when the bug happens which
makes debugging easier. However they've added significant effort in
regression triage due to their many false failures so it's not worth the
maintenance burden.

Within formal they don't really add any value now we have the full
end-to-end formal flow.
2025-02-18 16:49:01 +00:00
Greg Chadwick
0f27580cf6 [rtl] Flush pipe on all CSR modifications
This fixes #2193, an issue that meant bit clears in PMP related CSRs
didn't immediately apply to an instruction already in the fetch stage
due to a lack of a pipeline flush.

With this change the pipeline will flush in that scenario, fixing the
issue. It now flushes the pipeline on all CSR modifications as this
makes the pipeline more resliant against similar issues in the future
(where the list of CSRs to flush on should have been updated but
wasn't).
2025-02-17 14:47:28 +00:00
Greg Chadwick
e66df4d49a [rtl] Read csr_addr direct from instruction
Previously the ibex_cs_registers module received the CSR address via the
operand muxes. This has been observed to cause timing issues in some
cases. The CSR address is always read from the same bits of the
instruction so there's no need to go via the operand muxes. With this
change the relevant instruction bits are fed straight out of the decoder
and into the ibex_cs_registers module.
2025-02-17 14:47:28 +00:00
Rupert Swarbrick
78739562ce [ibex_core] Fix assertion when SecureIbex is false
This assertion wasn't quite correct if SecureIbex is false because it
was checking for the magic IbexMuBiOn value instead of just looking at
the bottom bit.

Fixes #2249.
2025-01-24 12:49:45 +00:00
Rupert Swarbrick
cecf4fd2df [ibex_register_file_fpga] Drop two confusing comments
These were noticed by someone responding to issue #2230. I think the
author's original logic was to point out that there's a path from e.g.
raddr_a_i to rdata_a_o which doesn't depend on any clock, so is
"asynchronous".

But that's the same in the other modes and also for the other register
file implementations, which don't have analogous comments.

Drop these ones.
2025-01-23 19:27:35 +00:00
Katharina
591c3812f9 Fix typo in comment in ibex_id_stage.sv 2025-01-16 19:17:50 +00:00
Robert Schilling
5da1679f36 [ibex_tracer] Use static variables in always/final blocks
Signed-off-by: Robert Schilling <rschilling@rivosinc.com>
2025-01-10 13:17:17 +00:00
Rupert Swarbrick
4d722d3308 [rtl] Drive oh_raddr_*_err if RdataMuxCheck=0
These errors aren't detected or reported if the mux is disabled, but
the RTL didn't actually drive them at all.
2025-01-07 09:38:11 +00:00
Priyanshu Mishra
8f4c75c5e4 Update core_ibex_pmp_fcov_if.sv 2024-12-20 12:09:26 +00:00
Andreas Kurth
a05d4d825c [rtl,pmp] Allow all accesses to Debug Module in debug mode
The RISC-V Debug Specification (current release 1.0.0-rc4) in Section
A.2 states that the PMP must not disallow accesses to addresses of the
Debug Module when the hart is in debug mode, regardless of how the PMP
is configured.  This commit changes the PMP accordingly.

Signed-off-by: Andreas Kurth <adk@lowrisc.org>
2024-12-19 10:42:48 +00:00
Andreas Kurth
8b82e89719 [controller] Add assertion on pipeline flush when entering debug mode
Signed-off-by: Andreas Kurth <adk@lowrisc.org>
2024-12-19 10:42:48 +00:00
Marno van der Maas
88d27a0944 ibex_pcounts: resolve uninitialize warning
Although the current code isn't wrong as far as I can tell, it would be
better to initialize the lognest_name_length variable when it is
declared to avoid a build warning with older Verilator versions.
2024-12-18 16:05:47 +00:00
Pascal Nasahl
667fd20d2e [rtl] Fix non-DSP reset in ibex_counter
When targeting Xilinx FPGAs, we utilize a DSP for counters
with a width of less than 49-bit. In this case, a sync. reset
is needed. However, currently, there is a bug in the RTL
where also a sync. reset is used for the non-DSP counters
on the FPGA.

Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
2024-12-06 14:55:01 +00:00
Pascal Nasahl
0945aa84c6 Revert "[rtl] Fix counter reset value on FPGA"
This reverts commit 54985d21b0.
2024-12-04 00:06:01 +00:00
Pascal Nasahl
54985d21b0 [rtl] Fix counter reset value on FPGA
If the counter width is >= 49, we do not use a DSP on the FPGA.
Then, we should use an asynchronous reset to initialize the counter.

This bug was detected when enabling the lockstep for the CW340. A
lockstep mismatch happend as the mcycle counters of the main and
shadow core did not match due to this bug.

Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
2024-11-29 10:43:32 +00:00
Gary Guo
d2d55ed348 [ci] remove Azure Pipelines
We have been using GitHub Actions for some time now, both for public CI
and private CI, and it seems to be functioning well.

Signed-off-by: Gary Guo <gary.guo@lowrisc.org>
2024-11-22 16:45:05 +00:00
Pascal Nasahl
84232a5bfa [rtl] Fix zero value in FPGA RF
We should use `WordZeroVal` instead of `0` for reads from register `x0` in the
FPGA register file.

This bug was discovered when enabling the `RegFileECC` parameter. When this is
enabled, the core performs ECC checks, expecting that `WordZeroVal` is returned
for `x0`. Else, we get a major alert.

Fixes lowRISC/opentitan#25146

Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
2024-11-18 13:35:35 +00:00
Marno van der Maas
f0f6bfd79a Block diagram: make feature text readable
White text on the dark red should be more readable than the black.
2024-11-12 12:49:41 +00:00
Marno van der Maas
496e06f659 Block diagram: fixes and improved looks
- Move background to its own layer
- Make font sizes consistent
- Fix icache and pc background
  Previously the background was morphed around the text, this makes it a
  background again.
- Remove redundant rectangle
  The instruction memory interface had two rectangles, one black and one
  purple. I removed the purple one that was bleeding through in the
  corners.
- Instruction fetch alignment
  The Instruction fetch block was not the same height and was not top
  aligned with the other blocks.
- Align text with boxes
  This essentially aligns all the text insides the blocks
- Standardize lines as 0.265mm
  The lines between blocks and the ones making the triangular shapes were
  mostly 0.265mm with a few exceptions.
- Stroke width of block outlines same
  Made all the stroke widths for all the blocks 0.5mm. I've made the outer
  box a nice round 1.0mm.
- Use lowRISC colors
  E0384F for the background (including the start of the gradient)
  A21F4F for the outside line
- Alignment of in/out arrows
  Many of these arrows were not aligned, this improves that alignment.
- Add white background to instr inf
  Instruction memory interface lost its white background when the purple
  outline was removed. This commits adds it back in.
- Use Liberation Sans everywhere
  Exo 2 is not supported natively in browsers and there was no easy way to
  embed fonts in SVG where Inkscape knew about it.
- Fade to white, not transparent
- PMP check font is now smaller
- Add background to debug request input
- Make text under prefetcher bigger so it is rendered on GitHub
- Execute text is now its own block so that it is rendered on GitHub
2024-11-11 15:31:55 +00:00
Harry Callahan
fb49826c16 [dv] Cleanup some code in the compile_tb.py module
Add comments, and move some variable declarations around to be closer to their use.

Signed-off-by: Harry Callahan <hcallahan@lowrisc.org>
2024-10-01 15:21:40 +00:00
Harry Callahan
8e77bb39d5 [dv] Tweak ISS linker arg construction for Xcelium
The previous code here was a bit too hacky, so implement a solution that
directly follows the suggestion in the Cadence support article.
An example was also added to make it clear what this transformation is
achieving.

Add some more typehints, and cleanup names.

Signed-off-by: Harry Callahan <hcallahan@lowrisc.org>
2024-10-01 15:21:40 +00:00
Robert Schilling
f92d599e00 [pmp] Use top-level straps for PMP reset values
By using top-level straps for the PMP reset configuration its
easier to implement different reset configurations if there are
multiple Ibex cores in the system.

Signed-off-by: Robert Schilling <rschilling@rivosinc.com>
2024-09-23 10:28:57 +00:00
Elliot Baptist
4ed20f4ac3 Update more documentation links 2024-09-19 08:57:07 +00:00
Elliot Baptist
6a33f69ccb Update verification_stages.rst OT links 2024-09-18 12:58:20 +00:00
Pascal Nasahl
2617c43c0a [rtl] Fix wrong address in latch RF
This commit fixes a typo that used the wrong read address (raddr_b
instead of raddr_a) for port A.

Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
2024-09-17 14:25:27 +00:00
lingscale
53888bcdf4 [rtl] fix a typo. 2024-08-28 10:19:17 +00:00
lingscale
0cd79187b6 [doc] fix a typo. 2024-08-28 10:17:28 +00:00
Gary Guo
03ba286570 Fix icache regression failure on VCS
It appears that VCS require expression after `iff` to be wrapped inside
parenthesis otherwise it will complain about syntax error.

This should fix the weekly VCS regression.

Signed-off-by: Gary Guo <gary.guo@lowrisc.org>
2024-08-26 14:44:27 +00:00
Greg Chadwick
38c0709391 [rtl] Remove ECC related data_rdata_i -> instr_X_o feedthroughs
Prior to this commit an ECC failure on the incoming data memory response
factored directly into the outputs for the instruction memory
interfaces. This existed due to a desire to take an NMI on an ECC
failure as soon as possible but causes timing issues so it has been
altered.

Now rather than directly raise the NMI the same cycle the assertion of
'irq_nm_int' is delayed by a cycle which breaks the feedthrough path.
2024-08-23 20:31:14 +00:00
Greg Chadwick
3937e484da Add SECURITY.md 2024-07-16 14:05:47 +00:00
Greg Chadwick
96a1c02ba0 [dv] Increase iterations and instructions in riscv_rf_intg_test
This enables more scenarios begin stimulated per regression run around
RF ECC errors.
2024-07-15 22:02:06 +01:00
Greg Chadwick
6ac0ddc46e [dv] Alter riscv_rf_intg_test to cover more scenarios
Previously the riscv_rf_intg_test skipped certain scenarios where an ECC
error from the register file should trigger an alert. This change stops
it from skipping those scenarios.
2024-07-15 22:02:06 +01:00
Greg Chadwick
9e4a950aa6 [rtl] Fix logic for generating ECC related alerts
Under certain circumstances Ibex ignored the ECC check from the register
file when it should not have. This fixes the issue.

Fixes #2188
2024-07-15 22:02:06 +01:00
Greg Chadwick
668233699d [dv] Add spurious responses to memory agent
A spurious response is one that isn't associated with any on-going
request. With this new feature the memory agent can generate them
randomly when the interface is idle (i.e. there are no outstanding
requests).
2024-07-04 22:51:30 +00:00
Pascal Nasahl
0e0f27ad14 [dv] Add riscv_ram_intg_test
This test injects a fault into different MuBi encoded signals within
the prim_ram_1p_scr and prim_ram_1p_adv and checks whether a fatal
alert is triggered.

I have excluded the addr_match signal from FI as its encoding
is not directly checked. If the signal was a MuBi True, a
fault into it is treated by the mubi4_and_hi as a False.
If the signal was a MuBi False, a fault into it is treated
by the mubi4_and_hi also as a False. Hence, no address
collision occurs and the holding register is not returned.

This PR is based on #2182 and closes #2173.

Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
2024-07-04 10:58:40 +00:00
Greg Chadwick
3384bf4c42 [cosim] Clang lint fix 2024-07-03 15:31:44 +00:00
Greg Chadwick
e1f2df24d0 [ci] Bump co-sim version 2024-07-03 15:31:44 +00:00
Greg Chadwick
470b39a2a2 [dv] Output warning message on problematic MIP changes
When an interrupt is raised the Ibex controller will move from the
DECODE state to the IRQ_TAKEN state when it chooses to handle the
interrupt. When in IRQ_TAKEN it's possible for the interrupt state to
change again which aborts the interrupt entry. This leads to mis-matches
against cosim.

This change adds a warning to flag up cases where this has occurred to
enable quick triage of failures related to this scenario.
2024-07-03 15:31:44 +00:00
Greg Chadwick
65a7231a29 [cosim] Correctly deal with checking top of range memory accesses
The cosimulation environment does not know if a memory access from spike
is due to an instruction fetch or a data memory access. It uses a
heuristic to differentiate the two. Any access between the PC and the PC
+ 8 is considered an instruction fetch.

This heuristic did not correctly handle addresses at the top of the
range where the PC + 8 calculation overflows. This commit fixes the top
of range handling.
2024-07-03 15:31:44 +00:00
Greg Chadwick
e784d27464 [dv] Update testbench to use new 'pre_val' MIP
The 'pre_val' MIP addresses the scenario where MIP changes as an
instruction is excuting, this means a CSR instruction can observe a
different MIP from the one that decides whether or not that instruction
will be interrupted.
2024-07-03 15:31:44 +00:00
Greg Chadwick
3964804815 [dv] Fix model mismatches in cases where an access crosses PMP regions
Where an access is unaligned Ibex splits it into two transactions, each
of which undergoes a PMP check. It is possible for the first half to
fail a PMP check and the second to succeed and hence produce a request
on the memory interface.

In Spike it accesses memory byte by byte and if it encounters a PMP
error for a particular byte it won't try any further bytes.

This results in a mis-match between Ibex and spike when an unaligned
transaction is split across two PMP regions, one of which allows the
access and the other doesn't. Ibex generates a transaction and spike
doesn't producing an error.

This adds a fixup into the co-simulation environment. It detects when we
have an access that fails PMP that is misaligned. Where this has
resulted in Ibex producing a memory request that spike would not we
remove it from the list of memory requests to check after checking that
the request passes PMP within spike.
2024-07-03 15:31:44 +00:00
Greg Chadwick
89f4d86719 [dv] Fix exception_stall_instr_cross illegal bins 2024-07-03 15:31:44 +00:00
Greg Chadwick
2c132113c0 [dv] Add riscv_rf_ctrl_intg_test
This tests new hardening added to the register file around read and
write control signals.
2024-07-03 14:21:10 +00:00
Gary Guo
e2b721d488 [ci] update private CI 2024-07-01 16:15:41 +00:00
Greg Chadwick
1449ed5ea8 [dv] Add cover points for memory interface behaviour 2024-06-21 11:18:41 +00:00
Greg Chadwick
604ba343bb [dv] Fix race condition in ibex_mem_intf_agent
Previous code working with clocking blocks synced to the raw clock
event. Instead they should sync to the clocking block event. This
ensures the values being read are the latest values rather than a cycle
old.

In particular for ibex_mem_intf_agent this meant it was unable to
produce a single cycle response to any memory transaction. With this fix
these are now observed.
2024-06-21 11:18:41 +00:00
James Wainwright
d97a0b4a98 [doc] Fix C++ style guide link in README
Signed-off-by: James Wainwright <james.wainwright@lowrisc.org>
2024-06-16 22:13:01 +00:00
Pascal Nasahl
d019dccb4b [dv] Remove phase argument from collect_trans
This commit applies the patch from lowRISC/opentitan@18b0ced to the Ibex
repository.

Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
2024-06-06 21:36:55 +01:00
Pascal Nasahl
957529c4bd [dv] Add mubi and prim_count pkg to DV environment
With the latest update in vendor/lowrisc_ip, two additional packages
need to be imported.

Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
2024-06-06 21:36:55 +01:00
Pascal Nasahl
21da9b3c7e Update lowrisc_ip to lowRISC/opentitan@d268f271f4
Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
d268f271f4f75aeb8f3bf9624a497ae5bfb9c47e

* [rtl] MuBi encoding of iCache memory ctrl signals (Pascal Nasahl)
* [sram_ctrl] Add readback feature (Pascal Nasahl)
* [fpv] Tweak report headers to match Jasper version (Rupert
  Swarbrick)
* [prim_pad_wrapper,rtl] Change input enable to active-high (Andreas
  Kurth)
* [hmac/rtl] Wait for digest of complete block when stopping (Martin
  Velay)
* [prim_sha2_pad,rtl] Signal msg feed complete also when stopping
  (Andreas Kurth)
* [prim_sha2_pad,rtl] Go to idle (without padding) when told to stop
  (Andreas Kurth)
* [prim_sha2_pad,rtl] Refactor comparison on tx_count and msg len into
  signal (Andreas Kurth)
* [prim_sha2_pad,rtl] Fix setting of digest mode when continuing
  (Andreas Kurth)
* [hmac/prim_2,rtl] Do not clear redundant digest values (Ghada
  Dessouky)
* [prim,fpv] Tweak how a parameter gets used in some assertions
  (Rupert Swarbrick)
* [prim,fpv] Fix trivial lint warning in prim_fifo_sync_assert_fpv
  (Rupert Swarbrick)
* [prim,rtl] Fix trivial lint warning in prim_fifo_sync (Rupert
  Swarbrick)
* Launcher Modification (Youming Lu)
* [top_earlgrey,pinmux] Add input disable attribute for non-manual
  pads (Andreas Kurth)
* [dv] Add more prints to bit bash sequence (Rupert Swarbrick)
* [ipgen,flash_ctrl] Fix core files (Guillermo Maturana)
* [prim,rtl] Avoid unnecessary check in prim_esc_receiver.sv (Rupert
  Swarbrick)
* [prim,fpv] Use PossibleActions param in prim_esc_receiver (Rupert
  Swarbrick)
* [prim_diff_decode] Use `prim_xnor2` to detect integrity issue
  (Andreas Kurth)
* [prim] Fix typo'd loop increment (James Wainwright)
* [hmac/prim_sha2,rtl] Implement SW error for invalid HMAC config
  (Ghada Dessouky)
* [rom] Remove real and fake key targets. (Miguel Osorio)
* [prim_sha2,rtl/dv] Fix secret value wiping (Ghada Dessouky)
* [prim,rtl,fpv] Fix typo in assertion in prim_alert_receiver (Rupert
  Swarbrick)
* [fpv,prim] Drop prim_count_expected_failure.hjson (Rupert Swarbrick)
* [fpv,prim] Generalise from DecrNeverTrue to listing possible actions
  (Rupert Swarbrick)
* [prim,fpv] Correct assertions for commit_i input (Rupert Swarbrick)
* [prim,fpv] Rephrase some "backwards" assertions in prim_count
  (Rupert Swarbrick)
* [prim,fpv] Properly "waive" some unreachable prim_count assertions
  (Rupert Swarbrick)
* [prim,fpv] Fix width of FPV variable in prim_arbiter_ppc.sv (Rupert
  Swarbrick)
* [prim,fpv] Rephrase prim_count error assertions (Rupert Swarbrick)
* [prim,fpv] Fix port list in prim_count_tb (Rupert Swarbrick)
* [prim_ram_1p_scr] Align documentation with actual implementation
  (Pirmin Vogel)
* [prim, rom_ctrl] Increase number of PRINCE rounds for improved
  security (Pirmin Vogel)
* [prim,fpv] Make file structure slightly clearer (Rupert Swarbrick)
* [prim,fpv] Shorten a variable name (prim_hier -> hier) (Rupert
  Swarbrick)
* [prim,fpv] Tidy up and document some FPV macros (Rupert Swarbrick)
* [dvsim,lint] Fix bug in duplicate detection in lint parser (Rupert
  Swarbrick)
* [rtl,comments] Fix some comments (Guillermo Maturana)
* [dv,prim] Clarification of reset behavior (Adrian Lees)
* [ast] Add dependency in fileset_partner to select correct ast_pkg
  (Sharon Topaz)
* [prim,fpv] Only allow unconstrained counters in prim_count FPV
  (Rupert Swarbrick)
* [dvsim] Split and rename Modes.py (Rupert Swarbrick)
* [prim,dv] Tweak ASSERT_FINAL to be a no-op if FPV enabled (Rupert
  Swarbrick)
* [prim,tlul,rtl] Explicitly cast a "1" to specific number of bits
  (Rupert Swarbrick)
* [dvsim] Fix plurals in type names in Modes.py (Rupert Swarbrick)
* [dvsim] Move find_mode and find_and_merge_modes out of Modes class
  (Rupert Swarbrick)
* [dvsim] Die more cleanly on an invalid use of merge_mode (Rupert
  Swarbrick)
* [dvsim] Get rid of "mname" field in Modes.py (Rupert Swarbrick)
* [dvsim] Simplify named attribute lookup in Modes.py (Rupert
  Swarbrick)
* [dvsim] Get rid of pretty print magic in Modes.py (Rupert Swarbrick)
* [dvsim] Strengthen typing and simplify printing for modes in SimCfg
  (Rupert Swarbrick)
* [dvsim] Slightly tidy up SimCfg._print_list (Rupert Swarbrick)
* [dvsim] Get rid of an unused dictionary in OneShotCfg.py (Rupert
  Swarbrick)
* Add the project name to the copyright header (Michael Munday)
* Fix or waive Python lint errors and warnings (Pirmin Vogel)
* Remove trailing whitespaces (Pirmin Vogel)
* [dv,mem_bkdr] Fix handling of multiple tiles in sram (Guillermo
  Maturana)
* [hmac] Coding style and minor fixes (Ghada Dessouky)
* [dv] Remove phase argument from monitor's collect_trans (Rupert
  Swarbrick)
* [prim_fifo_sync_cnt] Minor code cleanup (Andreas Kurth)
* [dv,mem_bkdr] Fix digest calculation for hw_cfg0 (Guillermo
  Maturana)
* [prim_fifo_sync_cnt] Fix signedness of Depth parameter (Andreas
  Kurth)
* [prim_fifo_sync] Keep wraparound pointers contained within
  `prim_fifo_sync_cnt` (Andreas Kurth)
* [prim_fifo_sync] Move pointer and depth calculation to
  `prim_fifo_sync_cnt` (Andreas Kurth)
* [prim_fifo_sync] Remove out-commented RTL code (Andreas Kurth)
* [prim_fifo_sync_cnt] Improve module and parameter documentation
  (Andreas Kurth)
* [lint] Demote licence warning in AscentLint parser (Rupert
  Swarbrick)
* Revert "[dv] Remove phase argument from monitor's collect_trans"
  (Rupert Swarbrick)
* [dv] Fix parameter types in dv_base_mubi_cov.sv (Rupert Swarbrick)
* [dv] Remove phase argument from monitor's collect_trans (Rupert
  Swarbrick)
* [dv, xcelium] Use detachable reports to avoid CORS (Elliot Baptist)
* [otp_ctrl] Add fuse for late debug enable mechanism (Michael
  Schaffner)
* [prim] Add support for MuBi's up to 32bit (Michael Schaffner)
* [otp_ctrl] Increase Hamming distance in OTP commands (Michael
  Schaffner)
* [dv] Add checks to set_freq_*hz (Rupert Swarbrick)
* [dv] Fix more timeout comments with wrong units (Elliot Baptist)
* Make .core files pass FuseSoC 2 schema validator (Olof Kindgren)
* [dvsim] Run deepcopy to work around memory usage bug (Rupert
  Swarbrick)
* [dvsim] Make global_val handling a bit clearer (Rupert Swarbrick)
* [prim_sha2,rtl] Add key_length type and change type encodings (Ghada
  Dessouky)
* [dv,sram_ctrl] Fix a few failing tests (Guillermo Maturana)
* [topgen] Add field to specify status IRQ default behavior (Michael
  Schaffner)
* [dv] Update clear_all_interrupts to support status type (Michael
  Schaffner)

Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
2024-06-06 21:36:55 +01:00
Pascal Nasahl
5cea5d65c3 [rtl] Add error port to iCache
This commit adds the error port to the iCache which was introduced
with lowRISC/opentitan#23292.

Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
2024-06-06 21:36:55 +01:00
Pascal Nasahl
0b0b01006c [rtl] Update RAM ports inside ibex_top
This commit updates the RAM ports inside ibex_top to reflect recent
changes introduced with lowRISC/opentitan#23212 (SRAM readback mode).

Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
2024-06-06 21:36:55 +01:00
Greg Chadwick
5977d4e3a0 [rtl] Guard against false memory responses for secure configurations
With this change all memory responses are only acted on if Ibex is
expecting them for all secure configurations. Previously an error
response that was injected onto the bus would trigger an exception that
shouldn't occur (in particular breaking the functioning of the multiply
state machine). In addition for configurations without the writeback
stage an injected load data response could trigger an incorrect write to
the register file.

This is only applied to the secure configurations, non-secure
configurations assume correct adherence to the bus protocol meaning a
response will only be seen if a request is outstanding.
2024-06-04 10:00:34 +00:00
Marno van der Maas
b94364ab58 Expand the coverage plan after a review 2024-05-30 15:40:13 +00:00
Pirmin Vogel
eea2bf0c1c [rtl] Expose ICacheScrNumPrinceRoundsHalf parameter
This parameter allows integrators controlling the number of PRINCE
half rounds in the scrambled ICache SRAM primitives, e.g., to balance
timing impact and security guarantees.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2024-05-02 19:39:48 +00:00
James Wainwright
c1139477dc Add missing copyright headers
Signed-off-by: James Wainwright <james.wainwright@lowrisc.org>
2024-03-28 08:41:30 +00:00
Rupert Swarbrick
621b89969a [simple_system] Bump C++ version in core files
This sets the C++ standard that's being used for a compiler that's
building a Verilator simulation. Recent versions of Verilator (since
5.020) require the compiler to be in C++14 mode, so passing -std=c++11
breaks the build with them.

Looking at history, -std=c++14 has been supported since GCC
6.1 (released in 2016), so I don't think this argument is going to
cause any tooling problems.
2024-03-27 17:48:25 +00:00
Marno van der Maas
d0e87cd9f0 Keep to patch numbering convention
Newer patches should have higher number to ensure patch ordering.
2024-03-26 18:47:15 +00:00
Gary Guo
39f28bae44 [ci] Add missing sudo in CI
We are switching to use non-root GitHub action runners, which need
sudo for global package installation.

Signed-off-by: Gary Guo <gary.guo@lowrisc.org>
2024-03-15 17:46:01 +00:00
Greg Chadwick
eb668b064b [dv] Output VCS simulation log to file
The DV flow is expecting log files to be produced with a particular file
name, without it the reporting mechanisms do not work correctly. This
adds VCS log output to a named rather rather than just capturing stdout.
2024-03-07 15:20:43 +00:00
Greg Chadwick
926a9865d9 [dv] Add flag needed to allow force under VCS
Tests targetting security features make use of force to corrupt values.
Under VCS this requires building with a particular flag.
2024-03-07 15:20:43 +00:00
Greg Chadwick
6bdbcfabf2 [dv] Fix use of plusargs
Previously some $value$plusargs calls weren't explictly specifying a
format for a number to read from the plusarg. Under some simulators this
is acceptable under others it generates an error.
2024-03-07 15:20:43 +00:00
Greg Chadwick
5db718c153 [fcov] Fix illegal bins related to stall types
An instruction stall on a FENCE.I had been mistakenly placed in an
illegal bin. A FENCE.I acts much like a branch or jump so can produce
instruction stalls just as those instructions can.
2024-03-07 15:20:43 +00:00
Greg Chadwick
15945049b2 [dv] Handle missing paths when producing regression log
It's possible for a TestRunResult to contain an entry that has a path to
a build/run artifact but for that to be None rather than an actual path.
This causes the collect_results.py script to fail.

With this change such paths will be described as 'MISSING' in the
regression log instead.
2024-03-07 15:20:43 +00:00
Greg Chadwick
63fa98537e [dv] Only run SecureIbex relevant tests for SecureIbex configs 2024-03-07 15:20:43 +00:00
Greg Chadwick
55e2f40bb4 [dv] Fix regression for non PMP configs
Programs generated from RISC-V were exiting early in configs that don't
have PMP
2024-03-07 15:20:43 +00:00
Greg Chadwick
cb885df346 [dv] Fix path for vcs.tcl for wave dumping 2024-03-07 15:20:43 +00:00
Greg Chadwick
77ebbf729d [dv, cov] Log coverage merge stdout for VCS
Additionally update metadata with the appropriate coverage merge log
information.
2024-03-07 15:20:43 +00:00
Greg Chadwick
126f9c3450 [cosim] Fix SIGSEGV in ~SpikeCosim
When SpikeCosim is getting destructed a SIGSEGV was observed on CentOS
7. The root cause hasn't been identified other than it relates to the
deletion of `isa_parser_t`, potentially some kind of use after free
error.

This is an (optional) hacky workaround that simply never deletes the
`isa_parser_t` pointer in SpikeCosim. As in practise this occurs at the
end of simulation when the process is terminating the memory leak is of
little consequence.

Longer term this issue should be investigated and properly fixed.
2024-03-07 15:20:43 +00:00
Greg Chadwick
e00db7d2e4 [dv] Skip SVG generation in DV flow if svg module is missing 2024-03-07 15:20:43 +00:00
Greg Chadwick
ca25f3013b [dv] Flow modifications for CentOS 7 for testbench compile
Fixes two issues observed on CentOS 7 during testbench compile
 - pkg-config doesn't behave properly when it receives multiple flags
 - riscv-fesvr library needs to be included in build
2024-03-07 15:20:43 +00:00
Marno van der Maas
d8cbab0db2 Require Pydantic 2 or above
We need Pydantic 2 or higher to use the `field_validator` functionality
used in Ibex DV.
2024-03-01 11:19:07 +00:00
Greg Chadwick
27dd6b2e06 [rtl] Update use of prim_count following port changes
The latest version of `prim_count` from OpenTitan introduces a
`commit_i` input. To retain the behaviour of the previous `prim_count`
this should be set to a constant 1.

The `cnt_next_o` output has been renamed to `cnt_after_commit_o`.
2024-03-01 10:18:25 +00:00
Greg Chadwick
71683aa595 Update lowrisc_ip to lowRISC/opentitan@e0c4026501
Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
e0c40265019aa0c74e6903d3b3a144c48a3815ec

* [prim/lint] Fix long line lint error in prim_intr_hw (Alexander
  Williams)
* [csr_seq_lib] Avoid slicing a queue (Rupert Swarbrick)
* [dv] Make mem_model's compare_byte function less chatty (Rupert
  Swarbrick)
* [doc,prim] Improve comments in prim_intr_hw (Harry Callahan)
* [dvsim] Format FormalCfg code. (Miguel Osorio)
* [dvsim] Add results_server dependency to FormalCfg (Miguel Osorio)
* [prim_sha2] Add `hash_running_o` (Andreas Kurth)
* [prim_sha2] Add `hash_continue_i` (Andreas Kurth)
* [prim_sha2] Make digest writable from input while disabled (Andreas
  Kurth)
* [dv,random_reset] Enhance handling of random resets (Guillermo
  Maturana)
* [dv] Change implementation of special mubi access modes (Michael
  Schaffner)
* [dv,cov_merge] Do serial coverage merge for vcs (Guillermo Maturana)
* [dv/csr_utils] Change csr_peek to return the peeked value (Rupert
  Swarbrick)
* [dv/csr_utils] Expand a documentation comment in csr_peek (Rupert
  Swarbrick)
* [dv/csr_utils] Simplify HDL path checking in csr_peek (Rupert
  Swarbrick)
* [dv/csr_utils] Use DV_CHECK to simplify code structure in csr_peek
  (Rupert Swarbrick)
* [dv/csr_utils] Fix a seeming typo in csr_peek (Rupert Swarbrick)
* [dv/csr_utils] Change `csr_peek` to function (Andreas Kurth)
* [prim] Fix lint error in shadow register subreg primitive (Pirmin
  Vogel)
* [otp_ctrl] Add second HW_CFG partition (Michael Schaffner)
* [primgen] Fix parameters in a primgen template (Rupert Swarbrick)
* [prim] Avoid unnecessary Impl parameter in prim_onehot_check (Rupert
  Swarbrick)
* [hw,prim,sha2] Fix syntax error in waiver file (Robert Schilling)
* [prim_sha2,rtl] prim_sha2 minor RTL and styling fixes (Ghada
  Dessouky)
* [prim_sha2,rtl] Add RTL implementation + update core + lint waivers
  (Ghada Dessouky)
* [otp_ctrl] Remove entropy_src chicken switches (Michael Schaffner)
* [dv] Correct direct prediction of regwen (Michael Schaffner)
* [clkmgr] Restructure division clock feedback (Michael Schaffner)
* Revert "[edn] Move prim_edn_req out of prim" (Rupert Swarbrick)
* [rtl, prim] Add 'commit' functionality to prim_count (Greg Chadwick)
* [prim] Fix up 1r1w cores (Alexander Williams)
* [prim] Add two-port memory ECC wrappers (Michael Schaffner)
* [prim] Add two-port memory implementation (Michael Schaffner)
* [prim] Make copies of dual port memory files (Michael Schaffner)
* [otp_ctrl] Add support for multiple HW_CFG partitions (Michael
  Schaffner)
* [otp_ctrl] Add option to disable integrity on a partition (Michael
  Schaffner)
* [dv] Enhance RAL model with clearable mubi types (Michael Schaffner)

Signed-off-by: Greg Chadwick <gac@lowrisc.org>
2024-03-01 10:18:25 +00:00
Adrian Lees
5a8a1a9993 [tracer] Fix reporting of load/store data
Modify tracer to use the appropriate read/write masks when logging
load/store traffic from the Load Store Unit.

Signed-off-by: Adrian Lees <a.lees@lowrisc.org>
2024-02-17 20:43:01 +00:00
Adrian Lees
ea1a208f8d [bus] Return error if decode fails
Return an error signal to the host if an address request
does not match any device.
Previously a decode failure would match against the first
device, which in the Ibex Demo System happens to be
the SRAM.
2024-02-15 18:11:54 +00:00
Luís Marques
14c2b3f7ab Update old cpuctrl CSR name in cs_registers.rst
The commit 70186c57 renamed the CSR `cpuctrl` to `cpuctrlsts` but did
not update the table in `doc/03_reference/cs_registers.rst`. Fix that.
2024-02-12 10:04:25 +00:00
Greg Chadwick
1774cbbbe3 Update benchmarks README to better explain how to try different configs 2024-02-05 21:02:42 +00:00
Greg Chadwick
bd248343cc Enable the icache in coremark
When executed on a configuration without an icache the enable is safe
but has no effect.
2024-02-05 21:02:42 +00:00
Greg Chadwick
2de873c9bb Add icache_enable function to simple_system_common.h 2024-02-05 21:02:42 +00:00
Gary Guo
4f96e5446b Fix stale merge commit issue in private CI 2024-02-05 15:08:55 +00:00
Greg Chadwick
7049d4d4d7 [doc] Require sphinx version >= 7.0
The previous ~= 4.2 was failing build on readthedocs
2024-01-31 16:30:19 +00:00
Pascal Nasahl
8ec0c6f18e [rtl] Harden lockstep enable against FI
Currently, the dual-core lockstep FI mitigation is enabled/disabled
using a single bit.
For transient bit-flips, this is not problematic, as one bit-flip
into this signal and one bit into the Ibex is required to threaten
the security of the system.

However, a permanent stuck-at-0 fault could disable the lockstep
completely by targeting this signal. Then, only a single, additional
fault (transient or permanent) is required.

This PR enhances the FI resilience of the Ibex lockstep by encoding
this single bit into a ibex_mubi_t signal, i.e., a 4-bit multi-bit
signal.

Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
2024-01-23 09:14:45 +00:00
Pascal Nasahl
b6d8b9f075 Update verilator version
To be consistent between projects, this PR updates the Verilator
version to 4.210, which is also used by OpenTitan. The reason for
this change is that in #2129 Verilator linting issues occured
that did not occur in OpenTitan.

Closes #2131.

Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
2024-01-19 17:04:40 +00:00
Michael Schaffner
56413ecf10 [icache] Disable S&P diffusion layer in memory scrambling
Signed-off-by: Michael Schaffner <msf@opentitan.org>
2024-01-19 03:24:48 +00:00
Michael Schaffner
94a7446277 Update lowrisc_ip to lowRISC/opentitan@4cf2479b8e
Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
4cf2479b8e6c9b68b9fe1adba202443d3dbe3ff3

* [prim_trivium] Allow dynamically disabling the lockup protection
  (Pirmin Vogel)
* [scrambling] Add reference to RFC issue (Michael Schaffner)
* [edn] Move prim_edn_req out of prim (Rupert Swarbrick)
* [reggen] Remove the devmode input (Michael Schaffner)
* [prim, rom_ctrl] Remove S&P layer from data scrambling (Michael
  Schaffner)
* [prim] Fix typo in Trivium/Bivium stream cipher primitives (Pirmin
  Vogel)
* [prim] Add scratch Verilator testbench for Trivium/Bivium primitives
  (Pirmin Vogel)
* [prim] Add Trivium/Bivium stream cipher primitives (Pirmin Vogel)
* [chip,dv] update makefile for real_key rom test (Jaedon Kim)
* [dvsim] cast self.seed to 'int' (Jaedon Kim)
* [dvsim] Change systemverilog seed to 32 bits (Hakim Filali)
* [dv] Specialize dv_spinwait_* documentation comments (Rupert
  Swarbrick)

Signed-off-by: Michael Schaffner <msf@opentitan.org>
2024-01-19 03:24:48 +00:00
Sᴜᴘᴇʀ Lᴇᴇ
123d46b4d6 [dv] Fix paths in merge_cov.py 2024-01-11 15:00:52 +00:00
Michael Munday
577a50095f Add NOTICE file
Add a NOTICE file containing some information about the project.

Signed-off-by: Michael Munday <mike.munday@lowrisc.org>
2024-01-10 15:37:44 +00:00
Harry Callahan
03946d8dcc Tweak questa timescale argument
Signed-off-by: Harry Callahan <hcallahan@lowrisc.org>
2024-01-08 11:03:10 +00:00
Harry Callahan
7d0cab583c Fixup the questa build/sim command templates in rtl_simulation.yaml
We do not actively use or test these commands and tools, so they probably broke
some time ago.

Signed-off-by: Harry Callahan <hcallahan@lowrisc.org>
2024-01-08 11:03:10 +00:00
Gary Guo
c9f4a32963 [ci] introduce GitHub actions based private CI
The private CI works by using workflow dispatch to trigger a CI on
another repository.

Pending status checks are created before calling the dispatch to
indicate their queued status before they are picked up in private CI,
and also serves to block merge group from success.

Signed-off-by: Gary Guo <gary.guo@lowrisc.org>
2024-01-05 15:50:18 +00:00
Pascal Nasahl
35bbdb7be3 [rtl] Fix FI vulnerability in RF
As described in #20715, a single fault-induced bit-flip inside the
register file could change which of the register file value is
provided to Ibex.

This PR fixes this issue by (i) encoding raddr_a/b to one-hot
encoded signals, (ii) checking these signals for faults, and
(iii) using an one-hot encoded MUX to select which register file
value is forwarded to rdata_a/b.

Area increases by ~1% (Yosys + Nangate45 synthesis).

I conducted a formal fault injection verification at the Yosys
netlist to ensure that the issue really is fixed.

Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
2024-01-04 15:26:32 +00:00
Pascal Nasahl
d56143d03b [doc] Update cosim version
Currently, the verification documentation recommends to using
ibex-cosim-v0.3. However, this version of spike causes some
compilation issues on my side:
"class "processor_t" has no member "set_mhpm_counter_num"
when calling "make" in dv/uvm/core_ibex/.
This issue occurs when using the latest pre-build lowrisc toolchain
"20231205-1" or "20230427-1".

When using ibex-cosim-v0.5 DV works.

Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
2024-01-03 16:00:47 +00:00
Gary Guo
df88055aa3 [util] Update check_tool_requirements.py
`distutils` is deprecated and will generate warnings when used.
Replace it with packaging.version instead.

pip3 command line invocation is replaced with importlib.metadata,
which removes dependency on pip3 being present.

Signed-off-by: Gary Guo <gary.guo@lowrisc.org>
2024-01-02 17:01:33 +00:00
James Wainwright
38da151a25 [ci] Run CI in merge queue and not master
This change updates the GitHub actions workflows to run on PR updates
and within the GitHub merge queue, but not on the push to the master
branch.

Because we use merge queues, the re-run for the master branch would be
redundant.

Signed-off-by: James Wainwright <james.wainwright@lowrisc.org>
2023-12-15 12:09:37 +00:00
Gary Guo
1c5da195b6 [CI] change pr_lint to run on pull_request instead of target
Signed-off-by: Gary Guo <gary.guo@lowrisc.org>
2023-12-15 11:06:48 +00:00
Gary Guo
33a1740dd2 [CI] add GitHub action version of the CI
Signed-off-by: Gary Guo <gary.guo@lowrisc.org>
2023-12-15 11:06:48 +00:00
Rupert Swarbrick
d097c918f5 [rtl] Avoid name collision in ibex_pmp.sv
Recent versions of Verilator complain about the code that was there
because the csr_pmp_cfg argument clashes with a name in ibex_core.sv.

What's more, they mean different things! In ibex_core.sv, it was the
PMP configuration for the entire core. In the functions, it's the PMP
configuration for a single region. This patch adds a "region_" prefix
to the names, which fixes both the Verilator warning and my confusion!
2023-12-05 15:18:40 +00:00
Rupert Swarbrick
c37edf5095 [dv] Fix performance counter printing in simple system
This will avoid printing out a load of spurious zeros if the Ibex
config doesn't enable the corresponding counter.
2023-11-24 20:23:49 +00:00
Rupert Swarbrick
e5dac43844 Fix spelling of separator 2023-11-24 20:23:49 +00:00
Rupert Swarbrick
508c4a29fb [doc] Describe counters more explicitly in simple_system README 2023-11-24 17:29:21 +00:00
Rupert Swarbrick
7647e9a03d Update lowrisc_ip to lowRISC/opentitan@e6a0e9a136
Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
e6a0e9a1363d33789283ea6ba3c4d94d41f2dee5

* [dvsim] fix seed in json report (Gary Guo)
* [prim_prince,rtl] Split data_state array into two pieces (Rupert
  Swarbrick)
* [prim_prince] Move the split_var verilator hint to prim_cipher.vlt
  (Rupert Swarbrick)
* [bazel] Use the new rules for building ROMs (Chris Frantz)
* [hw,rtl,prim] Switch AND/OR for Mubi W1S/W1C (Robert Schilling)
* [util] Error out if secure_prng seed is less than 256 bits (Vladimir
  Rozic)
* [dv] Update dv_sim to support sram new targets (Miguel Osorio)
* [flash_ctrl,dv] update expected double bit error set (Jaedon Kim)
* [bazel] Update the binary/test rules for building ROMs (Chris
  Frantz)
* [bazel] Prepare `dvsim` to work with the new rules (Chris Frantz)
* [mubi,gen] Fix comments (Guillermo Maturana)
* [reggen] Add mubi support SWAccess that sets/clears a reg (Robert
  Schilling)
* [doc] Fixing a few typos in xoshiro PRNG documentation (Vladimir
  Rozic)
* [doc] Testplan's are now generated as markdown. (Hugo McNally)
* [bazel,dvsim] Prevent dvsim from (trying to) copy irrelevant files
  (Amaury Pouly)
* [doc] Moved badges over to using hosted images (Hugo McNally)
* [doc] Fixed links to the getting started section. (Hugo McNally)
* [dvsim] Avoid checking for gsutil when we just need gcloud (Rupert
  Swarbrick)
* [dvsim] Simplify the code that copies files up to GCP (Rupert
  Swarbrick)
* [dvsim] Use new results_server methods to list cleanly (Rupert
  Swarbrick)
* [dvsim] Wrap logic to move "latest" directory into results_server.py
  (Rupert Swarbrick)
* [dvsim] Add an object representing connections to results server
  (Rupert Swarbrick)
* [dv/cov] Fix coverage handling in some common items (Guillermo
  Maturana)
* [prim] Convert prim_clock_div to abtract (Alexander Williams)
* [dv/top-level] Fix sram data integrity error injection (Guillermo
  Maturana)
* [tools,vcs] Make flops use the sampled value of data to avoid races
  (Guillermo Maturana)
* [prim lfsr] Replace randomize() calls with $urandom in prim_lfsr_tb
  (Vladimir Rozic)
* [doc] Update LFSR coeffs descriprion. (Vladimir Rozic)
* [prim_lfsr] Remove redundant list of LFSR_COEFF (Vladimir Rozic)
* [dv/top-level] Harden chip_sw_data_integrity_escalation (Guillermo
  Maturana)
* [otbn,dv] Wait more carefully for secure wipes in vseqs (Rupert
  Swarbrick)
* [doc,report] Fix the dvsim report links to the testplans (Harry
  Callahan)
* [doc] Add the block-dashboards to the primative page (Harry
  Callahan)
* [prim_subreg] Fix RC access corner case (Michael Schaffner)
* [prim_lc_dec] Fix Xcelium compile error (Michael Schaffner)
* [misc] Use lc_tx_t testing functions at endpoints (Michael
  Schaffner)

Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
2023-11-24 17:27:25 +00:00
Rupert Swarbrick
20cc063cdc [dv] Add an extra key to common_project_cfg.hjson
The keys in this file get incorporated into the FlowCfg object that
represents a simulation or similar. Adding a spurious key won't cause
any problems, but we actually need it for the next commit, which grabs
the current version of dvsim from OpenTitan. That version of dvsim
expects the "book" key to have been set in common_project_cfg.hjson.

Splitting the two commits like this should make it a bit more obvious
where things have come from.
2023-11-24 17:27:25 +00:00
Rupert Swarbrick
fe84d64d79 [verilator] Slight refactor in ibex_tracer to avoid BLKSEQ warning
The existing code wanted to open file_handle as a trace file if
necessary and then use it on that clock cycle. So it (sensibly) used a
blocking assignment.

Verilator now warns about blocking assignments to globals in
"sequential logic processes" (the always_ff that is driving
everything). This is sort of easy to fix: just use an "always" block!

This commit looks slightly more involved because I've changed things
to pass the file handle to printbuffer_dumpline as an argument. It
makes the state update (where we open the file handle) a little easier
to follow.
2023-11-22 09:46:03 +00:00
Rupert Swarbrick
20183012f7 [verilator] Waive MULTIDRIVEN warning in ibex_tracer.sv
Fixes #2091.
2023-11-22 09:46:03 +00:00
Michael Schaffner
bac72d96ec [ibex_pmp/lint] Declare functions before using them
Signed-off-by: Michael Schaffner <msf@opentitan.org>
2023-10-19 07:58:30 +00:00
Greg Chadwick
97c0a7231a Update google_riscv-dv to chipsalliance/riscv-dv@71666eb
Update code from upstream repository
https://github.com/chipsalliance/riscv-dv to revision
71666ebacd69266b1abb7cdbad5e1897ce5884e6

* Fixes to support RV32 (Maciej Kurc)
* Extend CI matrix (Eryk Szpotanski)
* Add pyflow test (Grzegorz Placzek)
* Allow the CI to run from any branch and any PR (Maciej Kurc)
* [pmp] Remove MSECCFG reads from trap handler when Smepmp is disabled
  (Marno van der Maas)

Signed-off-by: Greg Chadwick <gac@lowrisc.org>
2023-10-03 13:42:54 +00:00
Greg Chadwick
883acc2bfc [dv,vendor] Pin bitstring version to fix gen_csr_test.py
The gen_csr_test.py script provided by RISC-V DV doesn't work with
version 4.0 and upwards of the bitstring library. This patch pins it to
3.1.9 to avoid the issue.
2023-10-03 13:42:54 +00:00
Greg Chadwick
99fb7be1be [dv] Fix ibex_cmd.py
With the latest versions of all python packages in
python-requirements.txt ibex_cmd.py was seeing a run-time type error.
Data from a YAML file that had previously always been a string could now
be an int as well. This alters the code to allow the int to work.
2023-10-03 13:42:54 +00:00
Rupert Swarbrick
dccad9e6a3 Port directed_test_schema.py to recent versions of Pydantic 2023-08-31 08:34:17 +00:00
Rupert Swarbrick
fddb2fc3a3 [doc] Bump minimum Verilator version
It turns out that we use split_var in the code, which was added in
version 4.030 (and several bugs were fixed in following versions).
Change the minimum required version to match what we're using in
CI (and presumably works!)

This was triggered by issue #2080.
2023-08-31 08:33:04 +00:00
Rupert Swarbrick
eb95f74a5a Tweak ibex_cmd.py to fail more cleanly
This shouldn't change the behaviour when it works. On a failure, we
now print out a bit more about what's going on.

When asked to do something impossible now, I think the output is a bit
clearer. For example, if you try to run riscv_bitmanip_full_test with
an OpenTitan configuration (which doesn't have full bitmanip), the
warning message is now:

    WARNING:ibex_cmd:Rejecting test: riscv_bitmanip_full_test. It specifies rtl_params of ['ibex_pkg::RV32BFull'], which doesn't contain the expected 'ibex_pkg::RV32BOTEarlGrey'.

(The following stuff that appears is a bit messy, but at least the
first line is now clearer!)
2023-08-31 08:32:36 +00:00
Rupert Swarbrick
3c895f89a6 Remove (empty) Verible waiver file
The recent versions of Verible that I've tried die when they are given
an empty waiver file. The error message is "Fatal error: Broken waiver
config handle". I can't see a way to add a comment ("// No waiver" or
similar), so I think the best way to keep everything alive is to
delete the empty file.
2023-08-30 14:41:19 +00:00
Marno van der Maas
db6257b44a [doc] Fix background of Icache block
The background of the Icache block was a not-well-fitted path that was
causing the background to seep through. This commit updates that
background to more tightly align with the lines and letters.
2023-08-30 09:37:05 +00:00
Marno van der Maas
3a2cc6ae8c [doc] Fix background in block diagram
The background was originally a gradient background on the right
together with a solid background on the left. This caused some
distortion on closer inspection. This commit changes it to have one
background that is a gradient from left to right.
2023-08-30 09:37:05 +00:00
James Wainwright
1eb0beafa5 [ci] Consolidate Verible linting workflow into one stage
Running the verible linter and adding review comments to the pull
request previously had to be done in two stages:

1. Triggered on the pull request - prepare config and waiver files as
   artifacts.
2. Running on the repo's HEAD - run Verible and add review comments.

This was required because Actions running in the context of the pull
request did not have write permissions to add comments to pull requests.

This is now possible with the `pull_request_target` event, which
triggers when pull requests change, but runs in the context of the
repo's HEAD and has the permissions to create comments.

See lowRISC/ibex#1427 and
chipsalliance/verible-linter-action#31 for details.

Signed-off-by: James Wainwright <james.wainwright@lowrisc.org>
2023-08-04 08:53:47 +00:00
Marno van der Maas
06df66452f [credits] Add names of recent contributors 2023-08-02 08:08:56 +00:00
Marno van der Maas
f60d03b6b0 Update google_riscv-dv to chipsalliance/riscv-dv@08b1206
Update code from upstream repository
https://github.com/chipsalliance/riscv-dv to revision
08b12066b34c9728f706e45098ba502a36d7ca59

Signed-off-by: Marno van der Maas <mvdmaas+git@lowrisc.org>
2023-07-18 08:40:01 +00:00
Marno van der Maas
44ed214caa [vendor] Use new RISCV-DV URL 2023-07-18 08:40:01 +00:00
Marno van der Maas
18c6053fcf [dv,doc] Point reference to lowRISC branch 2023-07-18 08:34:09 +00:00
Marno van der Maas
e791ed49f3 Update riscv-isa-sim to lowrisc/riscv-isa-sim@a4b823a1
Update code from upstream repository https://github.com/lowrisc/riscv-
isa-sim to revision a4b823a1c7a260b532e1aa41b4d929e9634a7222

* Remove personal paths from Makefile (Marno van der Maas)
* Remove trailing whitespace (Marno van der Maas)

Signed-off-by: Marno van der Maas <mvdmaas+git@lowrisc.org>
2023-07-18 08:34:09 +00:00
Marno van der Maas
5a485db97b Update riscv-isa-sim to lowrisc/riscv-isa-sim@a7c5d5d8
Update code from upstream repository https://github.com/lowrisc/riscv-
isa-sim to revision a7c5d5d830e4095aa86580579efc46335fbc2f80

Signed-off-by: Marno van der Maas <mvdmaas+git@lowrisc.org>
2023-07-18 08:34:09 +00:00
Marno van der Maas
e87e31acfa [vendor] Use lowRISC repo for vendoring 2023-07-18 08:34:09 +00:00
Katharina
0264bcf2d4 Update README.md
Describe how to produce a VCD trace file.
2023-07-14 14:43:16 +00:00
Rupert Swarbrick
a0c5f5e4d3 Remove initialisation for sim_finish in simulator_ctrl.sv
This initialisation causes Xcelium to complain about multiple drivers
for the variable. Which is rather confusing, but we don't actually
need to initialise it: the variable will be X at the start of time, so
the logic that stops the simulation if it gets big won't fire until
after reset anyway.
2023-07-13 11:49:47 +00:00
Rupert Swarbrick
ce552f2e27 Use correct width for 1-bit inputs in ibex_simple_system.sv
Not a big deal, but this silences a warning from some simulators.
2023-07-13 11:49:47 +00:00
Rupert Swarbrick
9f83cbd2b4 Use named constant for default RAM behaviour
The ibex_top_tracing module takes a ram_cfg_i for something to pass
through to the RAM. Use the named zero (RAM_1P_CFG_DEFAULT) instead of
building it by hand: now we get the right width.
2023-07-13 11:49:47 +00:00
Marno van der Maas
7139313ad3 [vendor] Minor alignment improvement 2023-07-06 07:55:47 +00:00
Marno van der Maas
d33fc90375 [dv] Move DVSIM data structures
This is copied from OpenTitan 0bda971

Co-authored-by: Gary Guo <gary.guo@lowrisc.org>
2023-07-06 07:55:47 +00:00
Marno van der Maas
a1d5d49d10 [dv] Add common_ifs_pkg.sv to DV files 2023-07-06 07:55:47 +00:00
Marno van der Maas
2b1e3de746 Update lowrisc_ip to lowRISC/opentitan@0deeaa99e
Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
0deeaa99e5760ee4f5c0a08e5fc1670509d22744

* [dv] Fix extension parsing in memutil (Gary Guo)
* [dv,vcs] add an option to override debug_region vcs flag (Sharon
  Topaz)
* [bazel,dvsim] fix airgapped cquery bug (Tim Trippel)
* [prim_present/dv] Only test relevant configs and improve coverage
  (Michael Schaffner)
* [prim_lfsr/dv] Add tests to improve coverage (Michael Schaffner)
* [gpio/dv] Add second build mode for CDC prims (Michael Schaffner)
* bugFix sim_cfg.hjson.tpl (skfwe wang)
* [verilator] Add optional argument for trace file path (Alexander
  Williams)
* [dv] Fix multibit bug in interrupt test register prediction (Michael
  Schaffner)
* [dvsim] update sim.mk to accomodate OTP images under hw/ (Tim
  Trippel)
* [doc] Remove defunct sectionContent macros (James Wainwright)
* [util/uvmdvgen] Fix links in HW checklist template (Andreas Kurth)
* [governance] Add `SEC_CM_SCOPED` to D1 Checklist (Andreas Kurth)
* [dv/otp_ctrl] Fix cdc issue (Cindy Chen)
* [dvsim] add custom wavefile option (Jaedon Kim)
* [kmac,dv] fix regression - kmac_err (Jaedon Kim)
* [dv/clk_rst_if] Avoid freeze due to rst undriven (Guillermo
  Maturana)
* [top-level,clk_rst] Create separate clk_rst_if for xbar mode
  (Guillermo Maturana)
* [chip,dv] update flash_wrtie mappping (Jaedon Kim)
* [chip_tb] Integrate usbdpi into chip tb (Adrian Lees)
* [dv/cdc] Enable CDC in four more IPs (Guillermo Maturana)
* [dv/prim_alert] Enable CDC instrumentation (Guillermo Maturana)
* [dv/prim] Enable CDC instrumentation for some prims (Guillermo
  Maturana)
* [prim/rtl] Define `WITHIN_MARGIN` macro (Andreas Kurth)
* Remove out-of-date "mode" in dvsim (Rupert Swarbrick)
* [dv] Define `ASSERT_AT_RESET_AND_FINAL` macro (Andreas Kurth)
* [dv] Define `ASSERT_AT_RESET` macro (Andreas Kurth)
* [usb_diff_rx] Model pull-up behavior (Michael Schaffner)
* [doc] Fix `that that` typo (Douglas Reis)
* [doc] Fix `the the` typo (Douglas Reis)
* [doc] Fixed broken file links (Hugo McNally)
* [doc] Fixed links between books (Hugo McNally)
* [doc] Fixed some broken links to external sites (Hugo McNally)
* [doc] fixed links into github repos (Hugo McNally)
* [doc] removed link to private repo (Hugo McNally)
* [doc] Add DVSim design doc and glossary (Miguel Osorio)
* [doc] Add new DVSim README (Miguel Osorio)
* [doc] Move dvsim test planner into dvsim/doc (Miguel Osorio)
* Add function called by dvsim publish to trigger a website rebuild
  (Harry Callahan)
* [hw,dv_utils] Fix macro substitution issue with Xcelium (Raviteja
  Chatta)
* [bazel,dvsim] enable passing `--data-perm` flag through dvsim/bazel
  (Timothy Trippel)
* [doc] Updated documentation to reference the new build script. (Hugo
  McNally)
* [doc] Update simulation results link (Raviteja Chatta)
* [flash_ctrl] update `IPoly` parameter in flash scrambler (Timothy
  Trippel)
* [dvsim] Removed depreciated Universal Newline flag (Hugo McNally)
* [doc] Replace wavejson shortcodes with code-blocks (Hugo McNally)
* [doc] Rewrite most frontmatters to Markdown titles (Hugo McNally)
* [doc] Manually changed remaining hugo links (Hugo McNally)
* [doc] Replaced Hugo links with standard markdown (Hugo McNally)
* [doc] Created two initial mdbooks for new layout (Hugo McNally)
* [doc mv] `util/` doc files moved for new layout. (Hugo McNally)
* [doc mv] `hw/` doc files moved for new layout. (Hugo McNally)
* [doc mv] hw/ip* doc files moved for new layout. (Hugo McNally)
* [dv/verilator] Get '-c' flag of Verilator simulator working (Raphael
  Isemann)
* [lint,prim_generic] Turn off unused Verilator lint in clock buf
  (Marno van der Maas)
* [dv/util/sungrid] Fix issue when running sungrid in parallel (Eitan
  Shapira)
* [dv/common] Fix xelium enum type issue (Cindy Chen)
* [dvsim] Disable automatic timeout in gui mode (Cindy Chen)
* [dvsim] Publish json results if available (Andreas Kurth)
* [dvsim] Write json report to file (Andreas Kurth)
* [dvsim] Generate json from run results (Andreas Kurth)
* [dvsim] Add method to convert unit of JobTime (Andreas Kurth)
* [dvsim] Add option to disable normalization of JobTime (Andreas
  Kurth)
* [dvsim] Store coverage summary also in dict (Andreas Kurth)
* [doc] Improve various titles (Marno van der Maas)
* [doc] Added missing title headers (Marno van der Maas)
* [doc] Add TODO to empty stubs (Marno van der Maas)
* Add missing dependencies (Wojciech Sipak)
* [dv] Add build options after file list (Sharon Topaz)
* [rtl/prim] Fix prim_alert_receiver SVA for CDC (Guillermo Maturana)
* [dv] Make prim_secded_* toggle coverage 100% (Weicai Yang)
* [dv] Exclude prim_secdec_* in coverage collection (Weicai Yang)
* [secded/fpv] Remove data input assumption (Michael Schaffner)
* [fpv/prim_count] Add expected failure hjson (Cindy Chen)
* [dv, rv_dm] Fix scoreboard (Srikrishna Iyer)
* [dv, dv_macros] Expand DV_CLOCK_CONSTRAINT range (Srikrishna Iyer)
* [dv, dv_base_reg] Add `get_mask_from_fields` function (Srikrishna
  Iyer)
* [dv/xprop] Enable per-IP xprop configuration file (Guillermo
  Maturana)
* [dv] Change alert_test to run with default build mode (Weicai Yang)
* [dv,dvsim] Add run timeout multiplier option (Guillermo Maturana)
* [dv/shadowed_reg] Reduce a env_cfg variable (Cindy Chen)
* [dvsim] do not print status if `--interactive` (Eli Kim)
* [dvsim] Add unlimited timeout (Eli Kim)
* Revert "[dvsim] Add descriptions to timeout" (Eli Kim)
* [dvsim] Fix flake8 lint error (Eli Kim)
* [dvsim] Launch subprocess interactively (Eli Kim)
* [dvsim] Add `--interactive` argument (Eli Kim)
* [dvsim] Better dashboard result for parameterized blocks (Weicai
  Yang)
* create the log in a correct way (Sharon Topaz)
* Sungrid input from command file instead of command line (Sharon
  Topaz)
* [chip dv] Fix compile time warnings - Xcelium (Srikrishna Iyer)
* [dv] Clean up TODOs in csr_utils (Weicai Yang)
* [dv] Clean TODOs in mem_bkdr_* (Weicai Yang)
* [chip dv] Fix compile warnings in RTL and DV (Srikrishna Iyer)
* [dv] Resolve/clean up more TODOs (Weicai Yang)
* [dvsim] Add descriptions to timeout (Eli Kim)
* [fpv] Clean up strong property in simulation (Cindy Chen)
* [dv/xprop] Change code to be more xprop-friendly (Guillermo
  Maturana)
* [dv] Clean up TODOs in dv_lib (Weicai Yang)
* [chip dv] Implement the E2E JTAG debug and inject tests (Srikrishna
  Iyer)
* [dv, util] Add read_vmem function (Srikrishna Iyer)
* [dv str_utils_pkg] Add more string util methods (Srikrishna Iyer)
* [dv] Move sw_symbol_get_addr_size to dv_utils_pkg (Srikrishna Iyer)
* [dv, sim.mk] Copy elf file without .bin suffix (Srikrishna Iyer)
* [dv] Resolve TODOs in cip_macros (Weicai Yang)
* [prim_sparse_fsm_flop] Make DV statement x-prop safe (Michael
  Schaffner)
* [dv/cov] Exclude coverage of dv-only code (Guillermo Maturana)
* [dv/chip] Disable alert ping scb default check (Cindy Chen)
* [dv] ensure RAM ELF file gets copied to the rundir (Timothy Trippel)
* [dv] Use build seed to regenerate LC encoding for each build
  (Michael Schaffner)
* [dv/coverage_cfg] Remove coverage of prim_onehot_check (Guillermo
  Maturana)
* [prim] Add sync_req_ack based async FIFO (Michael Schaffner)
* [prim] Add RZ protocol to prim_sync_reqack* (Michael Schaffner)
* [dvsim] Move empty pattern list to common (Eli Kim)
* [prim] Reset assertion improvement (Canberk Topal)
* [prim_mubi*_sync] Remove explicit mux prim to improve coverage
  (Michael Schaffner)
* [fpv] Support build_pass_pattern in OneShotCfg (Cindy Chen)
* [dv] Increase MAX_CYCLE to 30 in sec_cm SVA (Weicai Yang)
* [dv_macros] Kill live assertions when disabling in `DV_ASSERT_CTRL`
  (Andreas Kurth)
* [dv, csr_utils_pkg] Add user frontdoor mechanism on all CSR methods
  (Srikrishna Iyer)
* [dv/chip] Support exclude certain alert injections in all_escalation
  test (Cindy Chen)
* [dv, csr_utils_pkg] Fix csr_read for field accesses (Srikrishna
  Iyer)
* [prim-cdc-rand-delay] Fix bug due to dv macro (Srikrishna Iyer)
* [verilator] Simulate GPIOs with weak pull up/down. (Chris Frantz)
* [dv,bazel] only copy over an ELF file if one exists (Timothy
  Trippel)
* [chip,dv,i2c] en_monitor update for top_earlgrey (Jaedon Kim)

Signed-off-by: Marno van der Maas <mvdmaas+git@lowrisc.org>
2023-07-06 07:55:47 +00:00
Marno van der Maas
bfe2c2f3c0 [vendor] Patch updated based on OpenTitan/36a2d3c 2023-07-06 07:55:47 +00:00
Greg Chadwick
96988c6ba0 [doc] Fix documented mstatus reset value
Fixes #2054
2023-07-04 09:21:18 +00:00
Greg Chadwick
4a75efde87 [ci] Constrain pydantic version to under v2.0
CI breakages are observed with v2.0
2023-07-04 09:21:18 +00:00
Greg Chadwick
fbd070cf58 [dv] New directed test to cover some scenarios with U-mode execution
This directly stimulates cases where U-mode execution is attempted
against locked regions (and a region with no permissions).
2023-06-23 07:50:22 +00:00
Greg Chadwick
4e17587213 [dv] Fix SET_PMP_CFG macro used by directed tests
For some region numbers it would perform additional spurious writes to
the pmpcfg CSRs
2023-06-23 07:50:22 +00:00
Greg Chadwick
a7845832a2 [dv,fcov] Add additional illegal bins to PMP fcov 2023-06-22 11:00:26 +00:00
Greg Chadwick
4fe6d89ed3 [dv, fcov] Increase iterations of riscv_mem_intg_error_test
This helps hit more coverage more reliably in particular for the
priv_mode_irq_cross cross coverage.

A better fix would adjust riscv_mem_intg_error_test to utilize U mode
more but it's a quick test for run so this suffices for now.
2023-06-22 10:15:49 +00:00
Rupert Swarbrick
97df7a5b10 Use correct format string for $value$plusargs
Not doing so causes VCS to spit out a warning message. The intention
seems to be that the initial call to $value$plusargs will evaluate to
true and will put the value that was assigned into the
disable_pmp_exception_handler variable, which then gets checked.
2023-05-26 10:58:20 +00:00
Rupert Swarbrick
b94ed2813d Reorder classes in ibex_debug_triggers_overrides.sv
The previous version doesn't make sense if you read the classes in
exactly the order they are defined in the file. It turns out that this
is what VCS did: oops! Fortunately, the fix is pretty trivial: declare
the classes the other way around.
2023-05-26 10:58:20 +00:00
Rupert Swarbrick
4118f97595 Express some coverpoint crosses in an equivalent way
The previous code caused VCS to complain that the "with" clause didn't
use any of the constituent coverpoints. I *think* that VCS wasn't
understanding that cp_interrupt_taken[5:4] does indeed depend on
cp_interrupt_taken (concentrating on core_ibex_fcov_if for
concreteness).

Fortunately, the check is easy to express a different way. There, we
were just asking that the top two bits are zero. Another way to say
that is "if I shift everything else off the bottom, the result is
zero". So we say it that way.
2023-05-26 10:58:20 +00:00
Rupert Swarbrick
1985c767a2 Drop an import from inside of a class
This causes VCS to spit out an error because it's not technically
allowed in SystemVerilog. The only things that we needed to import
seems to have been the CSR_MHPMCOUNTER3* names. We can just refer to
them explicitly.
2023-05-26 10:58:20 +00:00
Rupert Swarbrick
3b34f803f5 Re-export imported symbols from ibex_mem_intf_pkg
Other code tries to pick up things like DATA_WIDTH through this agent
package, that it imports. That doesn't seem unreasonable, but VCS
complains because we're not re-exporting it here.
2023-05-26 10:58:20 +00:00
Rupert Swarbrick
1e0adfce68 Bump Spike minimum version
Some code we've got in Ibex uses some stuff we added to Spike last
October. That, in turn, is now tagged in our riscv-isa-sim repository
as ibex-cosim-v0.5. Update the version requirement here to match.
2023-05-26 10:57:41 +00:00
Rupert Swarbrick
a31c0431b6 Correct type in scripts_lib.py's run_one
It seems that typeguard now spots if env happens to be None. We can
just relax things: we're only using env by passing it through to
subprocess.run, which handles a None env in the expected way.
2023-05-17 13:09:59 +00:00
Greg Chadwick
1084ac118e [dv] Add asserts to check alerts for memory integrity failures 2023-05-15 13:51:06 +00:00
Rupert Swarbrick
7a685b2224 Drop a double entry in rtl_simulation.yaml
We ended up with the Unicode fix twice because of two colliding PR
merges. We only need one copy of the -CFLAGS argument, and VCS
generates a rather strange message about an unknown argument if you
use it twice. Fortunately, it's easy to fix once you've worked out how
to get the system to print out what it's doing.
2023-05-15 08:42:06 +00:00
Greg Chadwick
10d4c97a0f [ci] Add missing dependency and fix RTD config
Cairo libraries are required for a python dependency.
New RTD config introduced to fix build errors introduced by new urllib.
We need to ensure the docs a built on a modern ubuntu with a
sufficiently new python (see
https://github.com/readthedocs/readthedocs.org/issues/10290).
2023-05-10 12:40:05 +00:00
Greg Chadwick
1120e8ddbf [dv] Improve interrupt signalling to cosim
Previously any changes in interrupt state or debug requests were
strictly associated with retired instructions. This causes cosim
mismatches where a lower priority interrupt occurs in time before a
higher priority interrupt or debug request but between instruction
fetches/retirements so both the low and high priority interrupts are
signalled with the instruction retirement.

This introduces a way for the RVFI to signal an interrupt has occurred
that isn't associated with an instruction retirement to allow the cosim
to see the seperation in time between different interrupts and debug
requests and hence model behaviour correctly.
2023-04-27 12:04:22 +00:00
Greg Chadwick
e587f20d44 [rtl] Increase minimum delay for IRQ assertion in new sequence library
An IRQ asserting then deasserting when not explictly cleared by an
interrupt handler can lead to RTL/cosim mismatches in some cases.
Increasing the delay here minimises those instances.
2023-04-27 12:04:22 +00:00
Greg Chadwick
54040df15c [doc] Update RVFI extension information 2023-04-27 12:04:22 +00:00
Greg Chadwick
6bd50a97cb [dv] Improve coverage of priv_mode_irq_cross
This allows mie to be randomly enabled/disabled in memory integrity
error tests. It also corrects the illegal bins.
2023-04-25 15:14:31 +00:00
Greg Chadwick
5e3474c9da Remove TODOs
- rvfi_trap now correctly handled for writeback
 - issue created to track coverpoint for pmpcfg reserved bits writes.
 - flush pipe on debug CSR writes is reasonable
2023-04-25 14:23:34 +00:00
Greg Chadwick
033abfc09f [dv] Double fault detector should sample with clocking block 2023-04-18 16:49:41 +00:00
Saad Khalid
6e4352af10 Fixed capture info for spike cosim in case of multiple interrupts
Signed-off-by: Saad Khalid <saad.khalid@lowrisc.org>
2023-04-13 17:30:33 +00:00
Stefan Wallentowitz
443a058f56 [util] Ignore Verilator stderr in version check
With funny CI environments, the locale might not be set properly, making perl complain. The version check will fail then. I believe it is sufficient to check for the tool version, stderr can be ignored safely, if I am not missing something.
2023-04-13 16:35:21 +00:00
Greg Chadwick
e58a9ff792 [rtl] Add missing `include to ibex_if_stage
The include is needed for a FCOV related macro. Lack of this include can
cause issues in some simulators.
2023-04-11 14:22:05 +00:00
Andreas Kurth
93c8e92c0d [sw/simple_system] Declare pcount_enable function as inline
The `pcount_enable` function can be used to selectively enable
performance counters only for a specific code segment.  For example:
```c
pcount_enable(0);
pcount_reset();
pcount_enable(1);
/* code to be measured */
pcount_enable(0);
```

The `pcount_enable` function consists of a single CSR instruction, so
the overhead and thus the impact on the measurement is potentially low.
When the function is called, however, many instructions have to be
executed in addition to the single CSR instruction, which influences
measurements.

This commit moves the `pcount_enable` function to the
`simple_system_common.h` header file and declares it as `inline` (and
`static`, to prevent link-time collisions when the header file is
included in multiple compilation units).  This helps the compiler inline
the function even without LTO.

Signed-off-by: Andreas Kurth <adk@lowrisc.org>
2023-03-17 13:04:37 +00:00
Greg Chadwick
2c8ee8c6b9 [ci] Specify typeguard version
The latest v3 is producing CI failures, pin to compatible with 2.13 for
now to fix this.
2023-03-17 12:20:13 +00:00
Saad Khalid
0623fdbbd8 Removed some uncoverable fcov when
* mml is low
* region is unlocked
execution would be permitted in m-mode
2023-03-16 13:13:31 +00:00
Greg Chadwick
d13a180d14 [doc] Remove misleading sentence above block diagram
The block diagram now represents both the 2 and 3 stage Ibex
configurations.
2023-03-14 11:16:41 +00:00
Greg Chadwick
9f6fedb05d [doc] Link to nightly regression results from docs 2023-03-14 10:36:29 +00:00
Greg Chadwick
7600de9633 [doc] Fix link typos 2023-03-14 10:36:29 +00:00
Greg Chadwick
b7859139c1 [dv] Summary svg tweaks
- Use white text for the names
 - Set correct height
2023-03-10 17:41:44 +00:00
Greg Chadwick
970a48e031 Update verification status in README 2023-03-10 17:41:44 +00:00
Greg Chadwick
438d07d3c2 Add Ibex nightly regression results to README 2023-03-10 17:41:44 +00:00
Flavien Solt
43aeda171d Avoid explicit module names references to signals
This allows changing the module names without breaking the sim flow.
2023-03-10 14:47:17 +00:00
Greg Chadwick
94f9f16c07 [dv] Refactor reporting and add additional reports
New reports provide HTML, dvsim compatible json and an SVG summary
dashboard.
2023-03-03 18:24:58 +00:00
Greg Chadwick
381fc845ba [rtl] Fix MISA X bit for balanced bitmanip config
All RV32B configs include non-ratified sub-extensions so the 'X' bit
MISA must be set for all of them.
2023-03-02 10:15:34 +00:00
Saad Khalid
8efaef8dc1 added U-mode accesses in pmp_mseccfg directed test 2023-02-28 09:59:05 +00:00
Saad Khalid
e5fc3a6bab * Added a directed test for mseccfg.mml 1 and transitions of PMP permissions
* Added a header file for common macros useful for directed tests
* Added license header and description for empty test
2023-02-28 09:59:05 +00:00
Saad Khalid
5693d7da32 added brief readme for directed test flow 2023-02-21 14:19:01 +00:00
Saad Khalid
47be427752 added exclude files, patch dir and updated riscv-arch-test vendored repo 2023-02-21 14:19:01 +00:00
Saad Khalid
6543a90a5b fixed patch file for riscv-arch-tests by removing the diff from excluded files 2023-02-21 14:19:01 +00:00
Saad Khalid
9ca5a77028 used mapping instead of exclude in riscv-isa-sim vendoring 2023-02-21 14:19:01 +00:00
Saad Khalid
2c8c00ec55 excluding env submodule in vendored riscv-tests as riscv-test-env is vendored separately 2023-02-21 14:19:01 +00:00
Saad Khalid
f0d303f0ac updated the patch for riscv-test-env 2023-02-21 14:19:01 +00:00
Saad Khalid
b179be4351 removed redundant files in riscv-isa-sim repo through vendor exclude 2023-02-21 14:19:01 +00:00
Saad Khalid
68d2740e9a removing the directed tests readme for now 2023-02-21 14:19:01 +00:00
Saad Khalid
43a533f4f2 added readme for generating directed testlist 2023-02-21 14:19:01 +00:00
Saad Khalid
2ea7e64341 updated directed testlist and script for generating it 2023-02-21 14:19:01 +00:00
Saad Khalid
2c1b3c91fd updated vendored riscv-test-env repo 2023-02-21 14:19:01 +00:00
Saad Khalid
95c388ba90 added a script for populating testlist 2023-02-21 14:19:01 +00:00
Saad Khalid
26717c8989 deleted redundant files 2023-02-21 14:19:01 +00:00
Saad Khalid
bfcaa25ee1 updated riscv-isa-sim fork 2023-02-21 14:19:01 +00:00
Saad Khalid
8626131ca6 updating riscv-isa-sim vendored repo 2023-02-21 14:19:01 +00:00
Saad Khalid
4c2a406590 added patch for xlen for riscv-arch-tests 2023-02-21 14:19:01 +00:00
Saad Khalid
539316365f excluding some not useful at the moment large files 2023-02-21 14:19:01 +00:00
Saad Khalid
b3733f9a05 vendoring riscv-isa-sim for ePMP directed tests 2023-02-21 14:19:01 +00:00
Saad Khalid
b52c1c79df vendoring riscv-arch-tests 2023-02-21 14:19:01 +00:00
Greg Chadwick
45b7272ee5 [doc] Drop EXPERIMENTAL for verified features
Many things were marked as 'EXPERIMENTAL' where that is no longer the
case. This brings things up to date.
2023-02-17 12:24:06 +00:00
Greg Chadwick
4c903d1033 [doc] Add Genus to list of known good tools 2023-02-17 12:24:06 +00:00
Greg Chadwick
ed423491eb [doc] Update getting started guide
Includes extra information in the integration guide that is linked from
the getting started guide.
2023-02-17 12:24:06 +00:00
Greg Chadwick
9280b92b1f [doc] Move register file and identity CSR info to integration page 2023-02-17 12:24:06 +00:00
Greg Chadwick
4a4c9bbb5d [doc] Update examples 2023-02-17 12:24:06 +00:00
Greg Chadwick
4c3c11d448 [doc] Add documentation on Ibex configuration 2023-02-17 12:24:06 +00:00
Greg Chadwick
08dda90484 [doc] Add verification overview 2023-02-17 12:24:06 +00:00
Greg Chadwick
a95b86ccc3 Update ePMP references
Smepmp is now a ratified specification at v1.0, these are updates to
reflect that.
2023-02-17 12:24:06 +00:00
Greg Chadwick
77cd6e4dda [doc] Remove area result specifics from Ibex overview
Area consumed varies by configuration and will change as the Ibex RTL
changes. So reporting area numbers within documentation is not
sensible.
2023-02-17 12:24:06 +00:00
Greg Chadwick
91d641cebf [doc] Move to newer Sphinx version 2023-02-17 12:24:06 +00:00
Greg Chadwick
ac245b394f Remove FPGA example
Now ibex-demo-system is available the FPGA example in the Ibex
repository has less use and risks causing confusion so remove it
entirely.
2023-02-17 12:24:06 +00:00
Saad Khalid
b4ae5bbb30 Override misa and mtvec CSRs to match Ibex
* misa is hardwired in Ibex
* mtvec has a mask such that it is 256 byte aligned and always vectored
2023-02-09 15:53:41 +00:00
Harry Callahan
4a48b3c08d Move 'clean' to top-level makefile
So you can type 'make clean' instead of 'make GOAL=clean'
2023-02-08 13:05:59 +00:00
Saad Khalid
10f4fad3e8 updated comment since directed test use the same flow 2023-02-08 13:05:59 +00:00
Saad Khalid
c00e3198e3 added license headers 2023-02-08 13:05:59 +00:00
Saad Khalid
72e9bcd488 vendored riscv test env for common macro files 2023-02-08 13:05:59 +00:00
Saad Khalid
d51437bcf9 added ibex specific macros 2023-02-08 13:05:59 +00:00
Saad Khalid
9534627463 vendored riscv-tests 2023-02-08 13:05:59 +00:00
Harry Callahan
15da9f9753 Add 'all_directed' and 'all_riscvdv' as special TEST targets
Running the Makefile dv flow with TEST=all_directed or TEST=all_riscvdv will
run all of the tests from either source of tests.
2023-02-08 13:05:59 +00:00
Harry Callahan
afef45d78e Add missing copyright messages / licenses 2023-02-08 13:05:59 +00:00
Saad Khalid
ce53589e11 Add pydantic schema + common configs for directed tests
This commit introduces the use of a pydantic model to validate the
data used to define directed tests. 'pydantic' is a python data validation
and settings management library which allows for structured data to be
checked against 'pydantic models'. In this case, we define a 'model' for
how we expect the directed-test yaml to look, including fields and datatypes,
and then validate that the imported file matches this expectation.
In effect, it allows the checking of the data to be seperated from its use.

dv/uvm/core_ibex/scripts/directed_test_schema.py defines the pydantic model,
and provides a function 'import_model()' to check the file-contents and
return a valid dictionary of the structured data.
2023-02-08 13:05:59 +00:00
Saad Khalid
2a852685cb added description for directed pmp test 2023-02-08 13:05:59 +00:00
Saad Khalid
552836cf4a Directed test flow
* First implementation of a directed_test framework, which aims to re-use as much
as possible from the existing riscvdv generation
* Fixed directed test flow to cleanly end the test
* clang-format is off for assembly header files
2023-02-08 13:05:59 +00:00
Andreas Kurth
911a6735b9 [rtl/dv] Add assertions for icache scramble keys
This commit adds two assertions in `ibex_top` to ensure that the
scramble key is correctly applied to the icache scrambled memory
primitives.  Those assertions previously existed in the module that
instantiated Ibex in OpenTitan, but the reference into the generate
loops was problematic for some EDA tools; see lowRISC/opentitan#17155.

Additionally, the assertions previously used the input scramble key
(`scramble_key_i`) even though they tolerated a delay after which the
input scramble key was not necessarily valid anymore (i.e.,
`scramble_key_valid_i` could go low and `scramble_key_i` could take any
value).  This mistake has been corrected by sampling the input scramble
key for the assertions when it is valid and using the sampled value in
the comparison of the assertions.  This problem surfaced in the DV
environment of Ibex (but not in OpenTitan), where multiple tests
(including `riscv_rand_instr_test`, `riscv_mem_error_test`, and
`riscv_multiple_interrupt_test`) failed; these tests now pass.

Signed-off-by: Andreas Kurth <adk@lowrisc.org>
2023-01-31 17:59:50 +01:00
Greg Chadwick
b1ac975c1e Update README to refer to ibex-demo-system 2023-01-27 13:57:50 +00:00
Canberk Topal
87dfd07f98 [doc] Update block diagram
Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2023-01-23 13:55:01 +00:00
Pirmin Vogel
f8dd3d8d3e [python-requirements] Pin setuptools version to < 66.0.0
Starting with setuptools version 66.0.0, legacy package version names
such as 0.23ubuntu1 are no longer supported. Since some of our
Python dependencies use this format, we pin the setuptools version to
the last version before this change. This unblocks CI and gives us time
to upgrade/rebase our dependencies.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2023-01-17 14:56:48 +01:00
Pirmin Vogel
590d196e62 [rtl] Improve FI hardening around data_rvalid_i
Previously, it was possible to glitch data_rvalid_i at the interconnect
level and if the data integrity bits happened to be valid, Ibex would
write the current data_rdata_i into the register file even if it wasn't
doing a load. Since the glitch is inserted at the interconnect level,
both the main and the shadow core are affected equally.

This commit changes the WB stage to only forward the LSU write enable,
which is generated from data_rvalid_i, when Ibex is actually waiting for
an interconnect response for a load instruction. This substantially
narrows down the window for attacks at the interconnect level.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2023-01-16 18:53:17 +01:00
Guillermo Maturana
ec32fb1a64 [rtl] Change code to be more xprop-friendly
Xprop is a simulation feature that improves the SV semantics when
conditions contain 'X values. Change RTL or DV code to enable more xprop
instrumentation.

This addresses lowRISC/opentitan#16791 and some of
lowRISC/opentitan#16723.

Signed-off-by: Guillermo Maturana <maturana@google.com>
2022-12-22 10:09:06 +01:00
Greg Chadwick
9a65bc1f0d [doc] Fixes and clarifications for exceptions and interrupts 2022-11-29 19:21:08 +00:00
Greg Chadwick
9696b80c88 [doc] Add V2/V2S checklists and declare V2S 2022-11-18 20:37:13 +00:00
Greg Chadwick
156acc0d0b [dv] Add more code coverage waivers 2022-11-18 17:18:24 +00:00
Greg Chadwick
011ebb347a [dv] Add new test to help hit pmp_wr_exec_region cross 2022-11-18 17:18:04 +00:00
Greg Chadwick
99c8a7ce00 [fcov] Add coverage for making PMP regions executable. 2022-11-18 17:18:04 +00:00
Greg Chadwick
bf0397f37a [dv] Add instruction stream to toggle Ibex specific features
It randomly writes to fields of cpuctrlsts to enable and disable data
independent timing, dummy instruction insertion and the icache. This is
used in riscv_debug_basic_test and riscv_single_interrupt_test to see
interrupts and debug requests when dummy instruction insertion and data
independent timing is enabled.
2022-11-18 14:06:53 +00:00
Greg Chadwick
4cd79ed2b1 Update google_riscv-dv to google/riscv-dv@68ab823
Update code from upstream repository https://github.com/google/riscv-
dv to revision 68ab8230c52ec66b393c04394aef4d6082ee53b4

* [pmp] Ensure MML PMP configurations don't dominate. (Greg Chadwick)
* [pmp] Add option to constrain addresses to stay in 32-bit space
  (Greg Chadwick)
* randomizing mstatus.MIE when priv mode is lower than machine (Saad
  Khalid)

Signed-off-by: Greg Chadwick <gac@lowrisc.org>
2022-11-18 10:21:28 +00:00
Greg Chadwick
3b61634e29 [dv] Add coverage waivers 2022-11-17 14:51:20 -08:00
Greg Chadwick
2de84f6128 [dv] Coverage flow fixes 2022-11-17 14:51:20 -08:00
Greg Chadwick
e2f9fed856 [dv] Increase timeout on riscv_debug_triggers_test 2022-11-17 18:24:41 +00:00
Greg Chadwick
bc4a4df9b8 [dv] Add pass on timeout option
This is used in riscv_pmp_full_random_test as some executions of that
test run very slowly. These are still valuable so the timeout is used to
ensure they don't take too long but still result in a pass.
2022-11-17 18:24:41 +00:00
Greg Chadwick
4c875b5bd2 [dv,ci] Add tests for data independent timing and dummy instructions 2022-11-17 18:20:57 +00:00
Greg Chadwick
10f56505c8 [ci] Add script for running directed co-sim tests
This helps reduce repetition in the CI yaml in preparation for adding
more directed tests.

This is a very basic script and will be replaced by a more complete
system at a later point.
2022-11-17 18:20:57 +00:00
Greg Chadwick
957349e9a7 [fcov] Add missing security related coverpoints
Also introduces using `DV_FCOV_EXPR_SEEN for some existing coverpoints
where appropriate.
2022-11-17 18:20:50 +00:00
Greg Chadwick
eeede2d98b [doc] Add security countermeasure to coverpoint mapping
Some missing coverpoints were identified in this process which have been
added to the coverage plan.
2022-11-17 18:20:50 +00:00
Greg Chadwick
fff1ebbc2a Update lowrisc_ip to lowRISC/opentitan@34de51f3a
Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
34de51f3a39717f636e5f447a628632ec8c31837

* [rdc] Add `waves` option to RDC flow. (Eli Kim)
* [dv] add ability to backdoor load second flash bank (Timothy
  Trippel)
* [entropy_src/dv] No backpressure on AST RNG agent (Martin Lueker-
  Boden)
* [prim_sync_reqack_data] Add check flag to better capture async
  resets (Michael Schaffner)
* [prim] Adjust reset assertion (Timothy Chen)
* [rstmgr] Update reset info since ndm_reset is now a hardware reset
  (Timothy Chen)
* [dv/edn] Allow randomly select a EDN endpoint to enable (Cindy Chen)
* [rom_e2e] add rom_e2e_shutdown_output to DV (Timothy Trippel)
* [chip dv] Fix chip_sw_rom_ctrl_integrity_check test (Srikrishna
  Iyer)
* [prim] Add hardened rectifying lc_tx OR/AND functions (Michael
  Schaffner)
* [dvsim] pass OTP image seeds to Bazel build (Timothy Trippel)
* [tools/dvsim] Remove old cdc plusargs from common_sim_cfg (Guillermo
  Maturana)
* [prim] Add an internal check flag (Timothy Chen)

Signed-off-by: Greg Chadwick <gac@lowrisc.org>
2022-11-17 17:33:09 +00:00
Greg Chadwick
21b1420cc4 [dv] Alter cov_merge.tcl patch so icache coverage collection works
cov_merge.tcl has been patched so the Ibex regression can pass through
coverage directories via a file. However this breaks dvsim based flows,
in particular the icache coverage merge.

This patch checks to see if the file is provided, if not it uses the
original merge method that's compatible with dvsim.
2022-11-17 17:33:09 +00:00
Greg Chadwick
6b3e0e7914 [dv, icache] Add functional coverage 2022-11-17 17:33:09 +00:00
Greg Chadwick
ef6219b0ad [doc] Add coverage plan to ICache dv documentation 2022-11-17 17:33:09 +00:00
Greg Chadwick
726eb97a88 [rtl] Flush pipe on MSECCFG CSR write
Without this an instruction executed immediately after the MSECCFG write
doesn't have the new MSECCFG setup applied to its execute permission.
2022-11-17 15:16:33 +00:00
Greg Chadwick
fb32236a3f [dv] Add direct instruction stream to hit pmp boundary cross coverage
The new instruction stream randomly chooses a NAPOT PMP region and emits
a store or load which will cross the boundary of that region at either
the top or the bottom.
2022-11-16 12:52:33 +00:00
Greg Chadwick
c48ca23c40 [dv] Various fcov fixes and tweaks 2022-11-16 12:52:33 +00:00
Greg Chadwick
581f5d45da [lint] Minor lint fixes 2022-11-15 16:11:20 -08:00
Greg Chadwick
3d13c6ccd8 [dv] Fixup coverage collection to match OT dvsim flow 2022-11-15 20:27:16 +00:00
Greg Chadwick
d8b00f0b17 [fpv] Only include double fault prediction logic where RVFI exists 2022-11-15 19:21:56 +00:00
Greg Chadwick
b736680ddb [dv] Add assertions checking double_fault_seen_o 2022-11-14 16:49:23 +00:00
Greg Chadwick
ddf56b3603 [dv] Add debug_mode to rvfi_ext
This indicates if debug mode was active when the instruction was
executed in ID/EX.
2022-11-14 16:49:23 +00:00
Greg Chadwick
abe1ab03e6 [dv] Don't set rvfi_trap when executing ebreak into debug
This aids the implementation of the double fault detector checker (as an
ebreak into debug doesn't sync the seen_sync_exec flag).
2022-11-14 16:49:23 +00:00
Greg Chadwick
8e852d285a [dv] Fix iside error notification to cosim
When a writeback exception occurs when the instruction in ID/EX has seen
an instruction fetch error we need to ensure that error doesn't get
notified to cosim. This requires watching for a writeback exception and
removing the latest iside error from the queue if needed.
2022-11-14 16:49:06 +00:00
Greg Chadwick
b399c7c8c4 [fpv] Fix linting issues in oustanding access tracking logic
This refactors the code to avoid a -1 index access that caused no issues
in functional verification but caused lint errors and is problematic for
formal tools.

Fixes #1799
2022-11-14 11:07:49 +00:00
Greg Chadwick
c9dc225135 [fpv] Add asserts to check crash dump connectivity 2022-11-14 09:13:59 +00:00
Greg Chadwick
eb82c0da14 Update google_riscv-dv to google/riscv-dv@d7c50c1
Update code from upstream repository https://github.com/google/riscv-
dv to revision d7c50c1eb9abe85bd6673878fe2e98489cf5f07e

* Fix `update_src_regs` for ZBB (Greg Chadwick)
* Sample bitmanip instruction coverage (Greg Chadwick)
* Fix for issue google/riscv-dv#826, illegal rs1 in C_JALR (Henrik
  Fegran)

Signed-off-by: Greg Chadwick <gac@lowrisc.org>
2022-11-14 09:11:50 +00:00
Greg Chadwick
c07414e8f6 [rtl] Fix zbs bitmanip instruction tracer output
They only have 5 bit immediates so use the shift form for I format
decode.
2022-11-14 09:11:08 +00:00
Saad Khalid
94f9517287 [dv] fixed uvm check for mstatus.MPIE when interrupt is nmi
Signed-off-by: Saad Khalid <saad.khalid@lowrisc.org>
2022-11-10 17:23:22 +00:00
Marno van der Maas
1c720e51b2 [dv,pmp] Put test done/fail sections before main for PMP tests 2022-11-09 09:24:51 +00:00
Saad Khalid
2c15b96a35 [dv] added functional coverpoints
Coverpoints for priv modes with interrupts and mstatus.MIE, and with exceptions.
Also, fixed a checker for scenarios when interrupt is taken from lower priv modes.

Signed-off-by: Saad Khalid <saad.khalid@lowrisc.org>
2022-11-08 09:17:45 +00:00
Canberk Topal
56268c675a [dv] Generate random writes in custom CSRs
This commit adds random custom CSR writes to debug_single_step_test
and riscv_mem_error_test.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-11-07 18:42:41 +00:00
Andreas Kurth
dd0063e394 [dv] Add coverage for debug requests and interrupts while executing a dummy instruction
Signed-off-by: Andreas Kurth <adk@lowrisc.org>
2022-11-07 18:42:41 +00:00
Andreas Kurth
550c9b2903 [dv] Add coverpoints for dummy instructions in each stage
Signed-off-by: Andreas Kurth <adk@lowrisc.org>
2022-11-07 18:42:41 +00:00
Canberk Topal
1ba7a3af38 [dv] V2S Coverage Implementation
This commit adds coverpoints and crosses for security countermeasures
implemented in the design.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-11-07 18:42:41 +00:00
Greg Chadwick
7592bb9478 [dv] Disable bad integrity on uninit accesses for mem error tests 2022-11-07 16:24:48 +00:00
Greg Chadwick
346eacb46c [cosim] Add write suppress support
When Ibex does a load that receives data with bad integrity it
suppresses the write to the destination register. The implements
matching functionality for cosim.
2022-11-07 16:24:48 +00:00
Canberk Topal
7de5674a1e Fixup RVFI connection for pc_wdata
Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-11-07 16:24:48 +00:00
Canberk Topal
715292ce55 [cosim] Cosim integration of internal NMI
This commit is mainly an extension to cosim environment to drive the newly
introduced state variable `nmi_int` in Spike.

This commit
 - Extends RVFI interface by a single bit (ext_nmi_int)
 - Configures cosim to set nmi_int inside Spike

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-11-07 16:24:48 +00:00
Canberk Topal
12ae6b2478 [ibex,dv] Add new test for memory integrity errors
This test picks between inserting an integrity error or a bus error
to the response in the case of a memory request from Ibex. Introduces
a control knob `enable_mem_intg_err` which can control the rate of
having integrity errors per request.

This commit also disables checking for double fault alerts in the
scoreboard because they're expected to be seen while simulating and
they don't cause infinite loop problems because every time a memory
response is requested the error causing part is just randomized.
That means Ibex trying to execute same instruction again would have
a chance to succeed this time.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-11-07 16:24:48 +00:00
Greg Chadwick
bb959c7181 [dv] Add probe and wait functionality for traps 2022-11-07 16:24:48 +00:00
Greg Chadwick
042c12abd0 [dv] Add custom test done functionality
This enables tests to implement custom test completion handling
2022-11-07 16:24:48 +00:00
Greg Chadwick
4b88ee9571 [dv] Set rdata on write response in sequence not driver
This enables the sequence to corrupt the integrity on write responses
should it choose to.  Previously the driver would always produce correct
integrity.
2022-11-07 16:24:48 +00:00
Canberk Topal
2d03fc8b73 Fix-up new_seq_lib to start after stopping
Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-11-07 16:24:48 +00:00
Canberk Topal
fdcf3ccede [dv] Don't inject mem errors at test_control_addr
This will prevent seeing mismatches right at the end of our test.
Before this change, mem_error_test could inject error at the store
instruction in which we finish up the test, resulting with mismatches
with Spike and Ibex on the instructions after finishing.

Also do the same prevention for signature_addr as well, since we also
don't want to corrupt that memory transaction too.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-11-07 16:24:48 +00:00
Canberk Topal
377e7da8e7 [ibex,dv] Switch to new sequence for memory errors
Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-11-07 16:24:48 +00:00
Canberk Topal
bd8bee8a72 [dv] Don't set sync_exc_seen in Debug Mode
Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-11-07 10:13:56 +00:00
Andreas Kurth
7b0921e14c [dv] Add test glitching icache data or tag
This commit addresses the integrity part of #1759 by verifying that a
glitch on the data or tag response from the instruction cache raises a
minor alert by the core (if the data/tag returned from the cache is used
by the core).

Signed-off-by: Andreas Kurth <adk@lowrisc.org>
2022-11-04 16:28:08 +01:00
Andreas Kurth
85cc254b46 [dv] Create signal probe functions in core_ibex_dut_probe_if
These functions are alternatives to `uvm_hdl_read()` when that function
is not available (e.g., when signals are otherwise optimized away such
as when not dumping waves) and the probe functions are apparently much
faster than `uvm_hdl_read()`, which seems to be implemented as foreign
function.

Signed-off-by: Andreas Kurth <adk@lowrisc.org>
2022-11-04 16:28:08 +01:00
Andreas Kurth
92c8c31c5b [dv] Add icache signals to core_ibex_dut_probe_if
Signed-off-by: Andreas Kurth <adk@lowrisc.org>
2022-11-04 16:28:08 +01:00
Andreas Kurth
66b3ed1ac1 [dv] Add test glitching register file read data
This commit addresses the integrity checking part of #1756 by verifying
that a glitch on the data read from the register file raises a major
alert by the core (if the data read from the register file is used by
the core).

Signed-off-by: Andreas Kurth <adk@lowrisc.org>
2022-11-04 16:00:44 +01:00
Andreas Kurth
be9a97e237 [dv] Create signal probe functions in core_ibex_dut_probe_if
These functions are alternatives to `uvm_hdl_read()` when that function
is not available (e.g., when signals are otherwise optimized away such
as when not dumping waves) and the probe functions are apparently much
faster than `uvm_hdl_read()`, which seems to be implemented as foreign
function.

Signed-off-by: Andreas Kurth <adk@lowrisc.org>
2022-11-04 16:00:44 +01:00
Andreas Kurth
173387e1c7 [dv] Add RF signals to core_ibex_dut_probe_if
Signed-off-by: Andreas Kurth <adk@lowrisc.org>
2022-11-04 16:00:44 +01:00
Andreas Kurth
e9a866ef55 Update lowrisc_ip to lowRISC/opentitan@affb06d8d
Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
affb06d8de0973bfdc271a6aa4b5ed7dc0b575bb

* [dv] Add `wait_clks_or_rst` to `clk_rst_if` (Andreas Kurth)
* [dv/cdc] Use cycle based CDC instrumentation (Guillermo Maturana)
* [dv/prim_edn_req] Check data valid (Cindy Chen)
* [rtl, chip dv] Coverage exclusions for pinmux / padring (Srikrishna
  Iyer)
* [dv] Enhance probe function macro (Srikrishna Iyer)
* [dv] enable loading `opentitan_flash_binary` images in DV (Timothy
  Trippel)
* [prim_diff_decode] Update SVAs to make them compatible with sim CDC
  (Michael Schaffner)
* [prim-lfsr] Fix DefaultSeedLocal compile scope (Srikrishna Iyer)
* [dv] Update dv_base_reg_field to handle status interrupts (Weicai
  Yang)
* [dvsim] fix bindgen error in nightlies (Timothy Trippel)
* feat(prim): Add Status Interrupt type to `prim_intr_hw` (Eli Kim)
* [dv/shadow_reg] Add coverplan for shadow reg (Cindy Chen)
* [dv/shadow_reg] Add shadow reg fcov (Cindy Chen)
* [dv/chip] Skip creating dv_base_reg coverage (Cindy Chen)
* [chip, dv] Remove a testpoint - tl_intg_err (Weicai Yang)
* [dv/top] Add option to automatically set rom_exec_en (Timothy Chen)
* [dv] Use positive check in DV_CHECK* macros (Srikrishna Iyer)
* [top/dv] Add plusargs to clear secret partitions (Michael Schaffner)
* [dv/prim] Disable coverage for unused logic (Guillermo Maturana)
* [dv] Add a global end-of-test signaling for RTL (Srikrishna Iyer)
* [dv] Properly remove coverage on CDC rand delay module (Srikrishna
  Iyer)
* [prim_sync_reqack] Disable reset checks by default, enable inside
  OTBN (Pirmin Vogel)
* [prim_sync_reqack] Modify/extend SVAs with respect to reset (Pirmin
  Vogel)
* [dv/clkmgr] Add exclusions and coverage pragmas (Guillermo Maturana)
* [prim] Simplify defensive coding (Timothy Chen)
* [prim_mubi] Fix sampling issue in MUBI sync assertions (Michael
  Schaffner)
* [rtl/prim] Fix some prim_esc_receiver SVAs (Guillermo Maturana)
* refactor(prim): rst_sync to have scanchain (Eli Kim)
* [unr] Use elite license (Cindy Chen)
* feat(prim): prim_rst_sync (Eli Kim)
* refactor(dvsim): Remove `verdi` checker (Eli Kim)
* [mubi/lc] Relax transient SVA checks (Michael Schaffner)
* [fpv] fix random seed syntax error (Cindy)
* [doc] Fix typos in //hw/lint and //hw/top_earlgrey (Dan McArdle)
* [doc] Fix typos in //hw/ip (Dan McArdle)
* [doc] Fix trailing whitespace before editing Markdown (Dan McArdle)
* [dv/shadow_reg] Update comment (Cindy Chen)
* [dv] Add macro `DV_CHECK_Q_EQ` (Weicai Yang)
* [fpv/pwrmgr] Add assertions to check escalation (Cindy Chen)
* [dv] Fix clk_rst_if limitation (Srikrishna Iyer)
* [dv, pins_if] Add disconnect() method (Srikrishna Iyer)
* SunGrid launcher support (Sharon Topaz)
* [chip dv] Fix errors due to use of invalid HIER macros (Srikrishna
  Iyer)
* [dv, clk_rst_if] Expand instance name in context (Srikrishna Iyer)
* [dv] pins_if improvement (Srikrishna Iyer)
* [CDC/PRIM] Updated prim_fifo_sync and prim_fifo_async to avoid CDC
  in rdata (Joshua Park)
* Fix various typos in Markdown files (Dan McArdle)
* [dvsim] Promote xcelium warning ENUMERR to an error (Michael
  Schaffner)
* [dvsim] Install a SIGTERM handler (Srikrishna Iyer)
* [flash_ctrl,dv] Enable random device param for all tests (Jaedon
  Kim)
* [prim] Patch up design to help with coverage (Timothy Chen)
* [flash_ctrl] Use comportable channels for alerts emanating from
  prim_flash (Michael Schaffner)
* [doc, prim] doc update for new prim library (Joshua Park)
* [otp_ctrl] Use comportable channels for alerts emanating from
  prim_otp (Michael Schaffner)
* [dv] Replace wait_timeout with DV_WAIT_TIMEOUT (Weicai Yang)
* [prim_lfsr] Initial block label (Srikrishna Iyer)
* [dv/top] Regression triage (Timothy Chen)
* [prim_lfsr] Enable randomization of initial seed (Srikrishna Iyer)
* [dv] Fix timeout log (Weicai Yang)

Signed-off-by: Andreas Kurth <adk@lowrisc.org>
2022-11-04 15:21:14 +01:00
Andreas Kurth
46dad5edc1 [dv] Compile dv_assert.sv before prim_util_pkg.sv
This is necessary because after the upcoming update of `lowrisc_ip`,
`prim_util_pkg` will depend on `INC_ASSERT`, which is defined in
`dv_assert.sv`.

Signed-off-by: Andreas Kurth <adk@lowrisc.org>
2022-11-04 15:21:14 +01:00
Greg Chadwick
ef43917dec [dv] Fix random data on uninit accesses
Previously the memory model writes didn't work correctly leaving an
incoherent view of memory.
2022-11-04 13:51:38 +00:00
Greg Chadwick
455dbe30f1 [dv] Add missing isolation forks 2022-11-04 12:17:19 +00:00
Andreas Kurth
120607f4f2 [xlm] Enable access to signals without dumping waves
The `-access rw` option allows Xcelium to access signals in the design
(e.g., with `uvm_hdl_read` or `uvm_hdl_force`) without having to dump
waves (which substantially increases the run time).  See [1] for the
background discussion.

[1]: https://github.com/lowRISC/ibex/pull/1879#issuecomment-1300216022

Signed-off-by: Andreas Kurth <adk@lowrisc.org>
2022-11-03 11:18:30 +01:00
Andreas Kurth
e5a6c9f38c [doc] Add RF write enable glitch detection
This resolves #1893.

Signed-off-by: Andreas Kurth <adk@lowrisc.org>
2022-11-03 10:31:03 +01:00
Harry Callahan
31cc8e0b5a Increase iterations for PMP tests to improve coverage 2022-11-02 10:41:02 +00:00
Harry Callahan
dda18c155f Apply lowrisc-ip patch 2022-11-02 10:40:49 +00:00
Harry Callahan
4e524a52bf Add patch for lowrisc_ip 2022-11-02 10:40:49 +00:00
Harry Callahan
f6ebb47274 Applied riscv-dv patch 2022-11-02 10:40:49 +00:00
Harry Callahan
f628f47ef5 Add patch for riscv-dv 2022-11-02 10:40:49 +00:00
Harry Callahan
34341fdc67 Merge coverage using db's in a file
Tidy up merge_cov.py to use metadata / pathlib

The 'imc' tool can accept a list of coverage databases as arguments on the
command line, or a '-runfile' argument can point to a file containing a list of
the databases, one entry per line.
Switch to use the file-method, as too many iterations leads to exceeding the
maximium length of arguments to the shell.
2022-11-02 10:40:49 +00:00
Harry Callahan
9086afe3ac Move tests to their own directory, out/run/tests
Make it easier to find the coverage / regr.log file
2022-11-02 10:40:49 +00:00
Harry Callahan
78bdc9b334 Cleanup check_logs.py, remove redundant cosim_trace check 2022-11-02 10:40:49 +00:00
Andreas Kurth
63be01b608 [dv] Add test glitching PC
This commit addresses #1755 by verifying that a glitch on the PC of Ibex
raises an internal major alert in the core.

Signed-off-by: Andreas Kurth <adk@lowrisc.org>
2022-11-02 09:50:30 +01:00
Andreas Kurth
2f7ff0cbf8 [dv] Add assert control for NoAlertsTriggered
Signed-off-by: Andreas Kurth <adk@lowrisc.org>
2022-11-02 09:50:30 +01:00
Canberk Topal
c145ac3985 [dv] Add a matching NA4 in pmp_full_random_test
Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-11-01 15:36:20 +00:00
Canberk Topal
614f716498 [dv] Randomize MPRV in pmp_full_random_test
Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-11-01 15:36:20 +00:00
Canberk Topal
d92f3be687 [dv] Add directed instruction for random MSECCFG
This commit adds a directed instruction stream to riscv_pmp_full_random_test
To inject random writes to MSECCFG register.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-11-01 15:36:20 +00:00
Greg Chadwick
b278e5b267 [dv] Fix riscv_mem_error_test
Memory errors trigger the same exception as PMP failures. For this test
we simply need to return to the failing instructions rather than the
more complex handling from the PMP exception handler.
2022-10-31 18:03:43 +00:00
Greg Chadwick
4dca23383a [dv] Access CPUCTRLSTS and SECURESEED in riscv_rand_instr_test 2022-10-31 18:03:43 +00:00
Greg Chadwick
cb01156154 [cov] Add illegal bin for misaligned data accesses 2022-10-31 18:03:43 +00:00
Greg Chadwick
ad584baa9a [rtl] Fix dummy instructions
Previously there was a single dummy_instr_id_o signal from ibex_core
which the register file used to determine if it could write to the zero
register (which reads as zero always for real instructions). However a
write occurs in the writeback stage so this signal was not asserted
correctly.

This adds a dummy_instr_wb_o signal to control the write to zero
register. dummy_instr_id_o remains as it's still employed for register
reads for dummy instructions.
2022-10-31 17:42:12 +00:00
Harry Callahan
3dee4621c8 Rework reset handling for UVM env
Move the handling of resets to the routine core_ibex_base_test::handle_reset,
which sequences the resets of different testbench components to ensure that
everything comes back up in the right sequence after a reset stimulus.
2022-10-31 17:32:32 +00:00
Harry Callahan
3e3940aa78 Break-out load_binary_to_mem for ISS and DUT seperately 2022-10-31 17:32:32 +00:00
Greg Chadwick
e63bb13d0a [ci] Bump cosim version to latest
This integrates in the ebreak behaviour changes in spike
2022-10-31 16:46:55 +00:00
Greg Chadwick
980f73b047 [cosim] Fixup ebreak behaviour
When DCSR is set such that ebreak will enter debug mode we were getting
cosim mismatches. This was because Ibex produces the ebreak on the RVFI
interface and spike effectively skips right over it and executes the
first instruction of the debug handler immediately. Traps have similar
but not identical behaviour so we need a special case in the step
function to handle this.
2022-10-31 16:15:09 +00:00
Harry Callahan
d59ed9ab38 Increase delay between irq stimulus for nested_interrupt_test 2022-10-31 16:11:03 +00:00
Harry Callahan
36d0d3089d Bump up timeout for irq_stimulus to accomodate fetch_enable changes
The recent change to add the fetch_enable sequence in to every regression
can very-rarely cause the 3000 cycle timeout for the irq_stimulus check to fail.
This only happens with a large randomized length of the fetch being disabled,
and long latency for memory accesses.
Increase this timeout.
2022-10-31 16:06:57 +00:00
Harry Callahan
b06fb42ab8 Change defaults for bad_intg on uninit accesses for Dmem/Imem
Imem : never create bad_intg on uninit access
Dmem : by default, enable bad_intg on uninit access. Plusarg to change behaviour.
2022-10-31 16:06:57 +00:00
Harry Callahan
352f83fc74 Add new uvm test to hit hardware breakpoints coverpoints
Overrides some riscv-dv classes to create a custom debug_rom for this test,
which is used to setup the breakpoint registers.
I have found it difficult to get stimulus of this hardware feature without
a more directed test. Improvements or ideas are welcome here.

Test-specific timeout of 5min within which I see >90% pass rate.
2022-10-31 16:06:57 +00:00
Harry Callahan
a670743bde Redefine ECALL handler to no-longer jump to 'write_tohost:'
This prevents the simulation from entering an infinite loop which it can no
longer detect and terminate from.
2022-10-31 16:06:57 +00:00
Harry Callahan
1a9ab8bd82 Generate test_done: and test_fail: sections using handshake mechanism
Adding this behaviour to ibex_asm_program_gen allows all test to benefit
from the option of jumping directly to these label. Previously, ECALL was
used to provide a single path to this code.
2022-10-31 16:06:57 +00:00
Greg Chadwick
eca86aef03 [rtl] Fix id_exception_o signal
Previously it was asserted when an instruction in ID would cause an
exception but an earlier instruction in WB also causes an exception
which takes priority.

This didn't cause a functional bug as the `id_exception_o` signal was
used in a single place ORed with `wb_exception_o`. However it was
confusing behaviour and could cause killed instructions to appear on the
RVFI causing false cosim mismatches.
2022-10-31 14:29:59 +00:00
Harry Callahan
0c0626ebbf Update google_riscv-dv to google/riscv-dv@be9c75f
Update code from upstream repository https://github.com/google/riscv-
dv to revision be9c75fe6911504c0e6e9b89dc2a7766e367c500

* Reserve one extra word when pushing GPRs to kernel stack (Harry
  Callahan)
* Store user-stack-pointer on kernel stack when pushing/popping GPRs
  (Harry Callahan)

Signed-off-by: Harry Callahan <hcallahan@lowrisc.org>
2022-10-28 17:33:53 +01:00
Canberk Topal
179b776dfb [dv,fcov] MPRV Effect Cross improvements
Removed unnecessary autogenerated bins with using iff more effectively.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-10-28 17:25:45 +01:00
Canberk Topal
2c8ff3b6d8 Extend illegal bin for None config in M-Mode
It is illegal to see an execution/read/write denied while in Machine
mode if MML is disabled. Add this combination to our illegal bin list.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-10-28 17:25:45 +01:00
Greg Chadwick
ed927be387 [cov] Remove ignored_csrs coverpoints
These related to unimplemented CSRs. These are already captured by one
of the illegal instruction categories.
2022-10-28 11:59:58 +01:00
Greg Chadwick
727f920c9a [cov] Add waived CSRs IGNORED_CSRS
It has been agreed we are waiving coverage of accessing these CSRs for
V2. They may be removed from list later. See
https://github.com/lowRISC/ibex/issues/1795
2022-10-28 11:59:58 +01:00
Greg Chadwick
57e691507d [cov] Fix debug_wfi_cross
It was triggered only on the debug wakeup actually occurring, so in
particular would never capture debug activity around entering sleep. Now
it just considers if there's something that would trigger debug wakeup.
2022-10-28 11:59:58 +01:00
Greg Chadwick
5e77ccc51a [cov] Add some illegal bins related to instruction categories 2022-10-28 11:59:58 +01:00
Greg Chadwick
bb92ea6df4 [cov] Remove pointless cross
This cross wasn't much use as many of the transitions it was crossing
with instruction types only occur when the pipeline is empty (so there's
no instruction type to check).

The remaining interesting cases are already covered by other crosses
(e.g. `debug_if_entry_instr_cross` and `pipe_flush_instr_cross`).

Also adds an assertion to check the pipe is empty when we transition to
IRQ_TAKEN (we need this condition to hold to ensure we don't need extra
coverage for instruction types on this transition).
2022-10-28 11:59:58 +01:00
Greg Chadwick
2f9fd69ec4 [rtl] Remove unused transition in ibex_controller FSM
When in the FLUSH state we cannot have `csr_pipe_flush` set as it
depends upon `instr_executing` being set (within `ibex_id_stage`) and
that is only set in the DECODE stage.
2022-10-28 11:59:58 +01:00
Marno van der Maas
5f5a70fca9 Tweak regressions around PMP, allow for double_faults, uninit_accesses
Add 180s timeout for pmp_full_random tests (this sees a reasonable pass-rate)

Tweaked to latest api for double_fault detector

Squashed changes from Marno's ongoing work:
[pmp] Adjust full random PMP to use random memory addresses
[pmp] Enable double fault detecter for MML read only test
[dv,pmp] Add double fault pass flag
[dv,pmp] Different parameters for pmp full random test
2022-10-27 15:01:23 +01:00
Greg Chadwick
bbda68a0df [dv] Disable bad integrity on uninitialised memory for selected tests
From an initial triage and test regression run these tests benefit from
this.
2022-10-26 22:08:32 +01:00
Greg Chadwick
1d4cf9b207 [dv] Add single step over exception coverpoint 2022-10-26 12:13:19 +01:00
Greg Chadwick
bfe71faf5f [dv] Remove cp_insn_trigger_exception coverpoint
This coverpoint does not make sense. The hardware breakpoint is
triggered as the instruction moves into the ID/EX stage so it never has
a chance to take an exception (it effectively never begins executing).
2022-10-26 12:13:19 +01:00
Greg Chadwick
1851e86113 [rtl] Fix ebreak debug cause
We should only indicate an ebreak debug cause if an ebreak leads to a
debug entry (otherwise when single stepping over an ebreak that traps to
an exception we incorrectly enter debug mode with an ebreak cause).
2022-10-26 12:13:19 +01:00
Harry Callahan
659dc458f2 Fix bug in passing cosim_agent handle to the data_intf_seq
The handle was passed before the cosim was constructed, so when it came to use
the handle it caused a null pointer exception.
2022-10-25 16:07:57 +01:00
Harry Callahan
639f563a47 Update google_riscv-dv to google/riscv-dv@ada58fc
Update code from upstream repository https://github.com/google/riscv-
dv to revision ada58fc57a6bc1265e6c261b0f468a79c946a640

* [pmp] Fix plusarg detection for MML and MMWP (Marno van der Maas)
* [pmp] Add missing line return (Marno van der Maas)
* [pmp] Improve formatting of PMP addresses for debug (Marno van der
  Maas)
* [pmp] Add a register for loop counter in PMP traps instead of
  mscratch (Marno van der Maas)
* [pmp] Add illegal TOR and NAPOT address mode constraints (Marno van
  der Maas)
* [pmp] Try to skip instruction if no PMP match and in MMWP (Marno van
  der Maas)
* [pmp] Store and load faults caused by locked PMP regions now skip to
  next instruction (Marno van der Maas)
* [pmp] Check for MML before modifying PMP entry in trap handler
  (Marno van der Maas)
* [pmp] Allow already configured addresses to be overwritten with
  plusargs (Marno van der Maas)
* [pmp] Use kernel_inst_end for end of code entry (Marno van der Maas)
* [pmp] Add end of kernel stack to stack entry (Marno van der Maas)
* [pmp] Put signature and stack in last PMP entries (Marno van der
  Maas)

Signed-off-by: Harry Callahan <hcallahan@lowrisc.org>
2022-10-25 16:07:33 +01:00
Pirmin Vogel
28935490c2 [rtl] Protect core_busy_o with a multi-bit encoding
This commit protects the core_busy_o signal using a multi-bit encoding
to reduce the chances of an adversary for glitching this signal to low,
thereby putting the core to sleep and e.g. not handling an alert.

Without this commit, the glitch would only be detected once both the
main core and the shadow core wake up again and the comparison of the
core_busy_o signals continues.

This resolves lowRISC/Ibex#1827.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2022-10-25 12:52:01 +02:00
Greg Chadwick
f385d4d6b1 [dv] Add cpuctrlsts writes to riscv_rand_instr_test
This will have the effect of randomly enabling/disabling

 - The ICache
 - Dummy instruction insertion
 - Data independent timing
2022-10-22 20:30:49 +01:00
Greg Chadwick
a0fe5ea3b7 [dv] Fix RVFI stage valid logic
Previously if a dummy instruction entered the pipeline whilst it
wouldn't make RVFI stage 0 valid, it would make RVFI stage 1 valid.

Now stage 1 can only become valid if stage 0 was valid.
2022-10-22 20:30:49 +01:00
Greg Chadwick
4effc487e0 [cosim] Implement double fault detection
This adds an implementation of the double_fault_seen and sync_exc_seen
fields in cpuctrlsts.
2022-10-22 20:30:49 +01:00
Harry Callahan
e38f534ac2 Add wall-clock timeout within rtl simulation to gracefully end
Use a DPI call to unix 'date' to implement a wall-clock timeout entirely within
a simulation. This allows the UVM environment to gracefully end when the
threshold is reached, and for things like logs and coverage databases to be
generated correctly.
Previously, a process-level timeout was used, which gave the running simulation
no time to commit any logs/databases to disk before ending. Hence we would not
gather any coverage from timed-out tests.

A plusarg 'test_timeout_s' can be specified to each test to set the timeout. The
default timeout is 1800s.
2022-10-21 17:22:09 +01:00
Harry Callahan
0b2a7c4f4e Add mechanism for test-specific timeout
Adding the key 'timeout_s' to the testlist.yaml file for each test
now sets the timeout for all iterations of that test. Value in seconds.

e.g.
Set all iterations of the pmp_full_random test to have a 10s timeout.
```
- test: riscv_pmp_full_random_test
  timeout_s: 10
```
2022-10-21 17:22:09 +01:00
Harry Callahan
a44d9827d7 Fixup mem_intf seq to update cosim mem on DMEM uninit accesses
Give the sequence a handle to the cosim_agent, upon which it can call a method
to update the cosim memory model directly.
This required a small restructure of the mem_intf packages to prevent a circular dependency.
2022-10-21 17:13:18 +01:00
Harry Callahan
ee0fd38e7d Change ibex_mem_intf_response_seq to handle uninit memory differently
Reading uninit DMEM returns a random value.
Reading uninit IMEM returns returns {2{C.unimp}}.

Inserting intg errors upon uninit accesses is now gated with a plusarg
"+enable_bad_intg_on_uninit_access=1"

Fix missing update of the rtl mem_model when returning random data.
2022-10-21 17:13:18 +01:00
Marno van der Maas
a376f85f26 [lint] Shellcheck bash scripts in repo 2022-10-21 14:52:42 +01:00
Andreas Kurth
ce536ae476 [rtl] Assert that dummy instructions only write R0
Signed-off-by: Andreas Kurth <adk@lowrisc.org>
2022-10-19 10:50:01 +01:00
Marno van der Maas
73e46b4fc7 [fcov,pmp] Illegal PMP write coverpoints check dside request error not low 2022-10-19 10:20:32 +01:00
Canberk Topal
33f1d0a702 Update google_riscv-dv to google/riscv-dv@e0eae9e
Update code from upstream repository https://github.com/google/riscv-
dv to revision e0eae9e0ca69770c519c82c48421005f65521eac

* [sv] Explicit type casting for VCS compability (Canberk Topal)

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-10-17 11:00:35 +01:00
Canberk Topal
c02a3d1662 [vcs] Fix Ibex DV runs for VCS
Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-10-17 11:00:35 +01:00
Harry Callahan
bece44f4d6 Change double_fault detector to on by default, fatal error if triggered
Add a plusargs "+is_double_fault_detected_fatal" to the top-level cfg,
which is set to 1 by default.

Set the default for the "+enable_double_fault_detector" to 1.
2022-10-17 10:37:04 +01:00
Harry Callahan
b214fa1c72 Add a double_fault detector to core_ibex uvm environment
Add a new scoreboard component to the core_ibex uvm environment, which contains
a double_fault detector task. This uses the top-level output
'double_fault_seen_o' to count the number of total and consecutive double_faults
seen with a test. A helper task allows the base_test to wait upon each of these
counters reaching the configured thresholds, and then to end the test early with
a passing result.

The default thresholds are 100 for consecutive faults, and 1000 for total faults.

The double_fault detector is disabled by default.
A plusarg '+enable_double_fault_detector=1' enables the checker.

This commit enables it for only the 'pmp_full_random_test', as that is a useful
test candidate to begin with.
2022-10-17 10:37:04 +01:00
Greg Chadwick
083fe2a54f [dv] Use fetch enable sequence by default
This sequence randomly toggles the fetch enable.
2022-10-16 17:17:15 +01:00
Greg Chadwick
7feffd566f [dv] Increase various timeouts
When the fetch enable sequence is employed in some tests these timeouts
are hit. Increasing them allows these tests to pass.
2022-10-16 17:17:15 +01:00
Greg Chadwick
12952cfe13 [dv] fetch_enable_seq tweaks
Previously the time over which fetch enable was disabled was randomized
at the start of the sequence and kept constant throught. Now it is
randomized for every `send_req`.

Stop generating FetchEnableOn as a possible fetch_enable value to set
and use the SecureIbex parameter to decide if full randomisation off all
of the non FetchEnableOn MUBI values if needed or we just always switch
between FetchEnableOn/FetchEnableOff

Tweaks the default min/max delay values for how long fetch remains
disabled.
2022-10-16 17:17:15 +01:00
Greg Chadwick
27907d1d4a [rtl] Immediately stop execution when fetch disabled
Previously `fetch_enable_i` only controlled the request going into the
instruction fetch stage.  Due to buffering in the prefetch queue and
icache when this request is dropped it's possible for multiple
instructions to still be available for the ID/EX stage to consume. So
when `fetch_enable_i` was set to off you would get a 'soft stop'. Some
finite number of instructions may still execute and Ibex would come to
an eventual halt.

Now `fetch_enable_i` also gates the instruction moving between the fetch
stage and the ID/EX stage. This gives a 'hard stop' where once fetch is
disabled Ibex comes to an immediate halt.
2022-10-16 17:17:15 +01:00
Harry Callahan
75a93dbed0 Fixup signal used when checking for ebreak cause 2022-10-14 18:44:02 +01:00
Canberk Topal
f2c1d6dc9d [rtl] Change how we record debug causes
This commit changes when we cath the debug causes. Since debug_cause_o
only gets latched when `csr_save_cause_o` is high, it would work if
we change the cause with a mux that is connected to the input signals.

Resolves #1772

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-10-14 18:44:02 +01:00
Greg Chadwick
298c8789da [rtl/dv] Bring back data integrity check on write responses
Previously Ibex signalled a major alert on an integrity error (where
incoming read data doesn't match its integrity bits) for both read and
write responses. This was removed as the data part of a response to a
write is ignored.

This brings it back in a more measured way. This provides a little extra
fault injection hardening as an attacker glitching the memory bus will
generate an alert on both read and write responses.
2022-10-14 18:22:58 +01:00
Greg Chadwick
d7ce082779 [dv] Remove riscv_perf_counter_test
This test doesn't actually check the performance counters, it just runs
a random instruction test and dumps the performance counters at the end
for some final checking. That checking does not exist. The test is
currently broken as well so just remove it as it adds nothing to the
regression.
2022-10-14 12:59:20 +01:00
Greg Chadwick
511a3516a6 [dv] Remove CPUCTRLSTS from riscv_csr_test
Bit 8 of this CSR cannot be predicted by the CSR test generator leading
to test failures. Remove it from the test for now until this is
addressed.
2022-10-14 12:59:20 +01:00
Greg Chadwick
48733e23ec [rtl] Ignore MIE bit in U mode 2022-10-13 17:30:05 +01:00
Greg Chadwick
48789dd095 [rtl] Don't take interrupts when single stepping
Fixes #1814
2022-10-13 17:30:05 +01:00
Harry Callahan
25d81afef6 Update google_riscv-dv to google/riscv-dv@c6acc18
Update code from upstream repository https://github.com/google/riscv-
dv to revision c6acc1897429f5245cc89b2ecee2e3eefdefd18d

* Add plusarg to enable ECALL insn in main randomized body (Harry
  Callahan)

Signed-off-by: Harry Callahan <hcallahan@lowrisc.org>
2022-10-11 17:42:23 +01:00
Marno van der Maas
4608df4606 [dv] Shellcheck prettify script
Signed-off-by: Marno van der Maas <mvdmaas+git@lowrisc.org>
2022-10-11 17:08:46 +01:00
Marno van der Maas
322ab3a285 [dv] Shellcheck objdump script and check for RISCV_TOOLCHAIN variable
Signed-off-by: Marno van der Maas <mvdmaas+git@lowrisc.org>
2022-10-11 17:08:46 +01:00
Canberk Topal
7c28d3caf3 [ci] Update IBEX_COSIM_VERSION to latest
Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-10-11 15:52:42 +01:00
Canberk Topal
e27deb1015 [dv] Add MHPM Counter number param to SpikeCosim
This commit adds another field in SpikeCosim class so that Spike
can hardcode the correct event registers.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-10-11 15:52:42 +01:00
Marno van der Maas
08115056f9 [doc] Add NAPOT address mode to coverage plan 2022-10-10 13:46:17 +01:00
Marno van der Maas
671b924f66 [pmp] Add coverpoints for large NAPOT regions 2022-10-10 13:46:17 +01:00
Greg Chadwick
574d993dcd [ci] Switch to downloading verilator from GCP bucket
Previously it was sourced from the OpenSUSE build service. This has
produced some reliability issues. Downloading pre-built binaries from a
GCP bucket should improve things.
2022-10-07 13:34:07 +01:00
Greg Chadwick
b57c9a4349 [ci] Switch to using Ubuntu 20 LTS azure agent
The Ubuntu 18 LTS image has been deprecated by Azure so we need to
switch to a new version.
2022-10-07 13:34:07 +01:00
Harry Callahan
3c11ef10b9 single_step test : only drive debug_req_i after stepping finishes
This addresses a current testbench issue where asserting debug_req_i close to
when single_stepping over an instruction causes an incorrect 'cause' to be
recorded within DCSR.
2022-10-06 17:52:36 +01:00
Harry Callahan
377382fb78 Single step debugging test changes for fcov
This builds upon the cosimulation environment to allow us to rip-out all the
existing checking from the test, and instead focus on generating good stimulus
to hit all our coverage points.
Make use of the riscv-dv changes to insert ecall into the main test body, now
that we have a different mechanism for ending the test.
Allow illegal instructions, csr instructions, ebreak, etc. which the previous
brittle checking paradigms could not handle.
2022-10-06 17:52:36 +01:00
Marno van der Maas
7ab2571bea [if,pmp] Check second bit instead of third for instruction alignment
Signed-off-by: Marno van der Maas <mvdmaas+git@lowrisc.org>
2022-10-06 10:23:01 +01:00
Harry Callahan
0e396d5944 Change failure modes and add comments with more clarifying details 2022-10-05 17:00:31 +01:00
Harry Callahan
3650e08e4e Record test failure due to timeout in regr.log
This commit adds a new field to the trr (test-run-result) structured data
that records the failure_mode of a testcase. If the test failed due to a
timeout, print a small addendum {T} to each log-line in the summary.

eg.

23.33% PASS 7 PASSED, 23 FAILED
riscv_debug_basic_test.21259:                     PASS
riscv_debug_basic_test.21260:                     FAILED {T}
riscv_debug_basic_test.21261:                     PASS
riscv_debug_basic_test.21262:                     FAILED {T}
riscv_debug_basic_test.21263:                     FAILED {T}
riscv_debug_instr_test.21259:                     FAILED {T}
riscv_debug_instr_test.21260:                     FAILED {T}
riscv_debug_instr_test.21261:                     FAILED {T}
riscv_debug_instr_test.21262:                     PASS
riscv_debug_instr_test.21263:                     FAILED {T}
riscv_dret_test.21259:                            FAILED
riscv_dret_test.21260:                            FAILED
riscv_dret_test.21261:                            FAILED {T}
2022-10-05 17:00:31 +01:00
Harry Callahan
ee7854fd3a Update docs for (s/ms)context 2022-10-05 16:59:12 +01:00
Harry Callahan
836bd67531 Update SCONTEXT address, add MSCONTEXT csr to match riscv_debug 1.0
Observing the spec change:
RISC-V Debug Support Version 1.0.0-STABLE
1.2.1.4 New Features from 0.13 to 1.0
> 8. Move scontext, renaming original to mscontext, and create hcontext. #535

MSCONTEXT is a backwards-compatible alias to SCONTEXT
In Ibex, SCONTEXT is a read-only zero register. Hence MSCONTEXT has the same behaviour.
2022-10-05 16:59:12 +01:00
Marno van der Maas
1cdd403564 [formal] Remove build infrastructure for instruction cache assertions 2022-10-04 13:59:39 +01:00
Marno van der Maas
ab350c4604 [formal] Remove build infrastructure for data independent timing 2022-10-04 13:59:39 +01:00
Marno van der Maas
fce41ff4d3 [riscv-formal] Removing unsupported and broken feature 2022-10-04 13:59:39 +01:00
Marno van der Maas
43dc5e8572 [formal] Added missing prim secded package 2022-10-04 09:35:13 +01:00
Marno van der Maas
3943a4eca3 [pmp] Remove off mode from pmp_*_mode_cross coverpoints 2022-09-30 11:05:00 +01:00
Greg Chadwick
1313104bad [ci] Fix pmp_smoke_test
It was renamed pmp_smoke_test from pmp_exception_test in the software
build but not the actual test run
2022-09-30 09:41:07 +01:00
Greg Chadwick
4084dc4a46 [cosim] Fix spike cosim instruction count
The count wasn't being initialised in the constructor and should be of
type 'unsigned int'.
2022-09-30 09:41:07 +01:00
Greg Chadwick
a788593842 [cosim] Pass Ibex config through for verilator cosim 2022-09-30 09:41:07 +01:00
Greg Chadwick
7b1be3354d [rtl] Don't cache instructions in debug mode
RISC-V debug modules may utilise dynamically changing code. Don't cache
any instructions in debug mode to correctly support this.

Fixes #1472
2022-09-27 10:12:09 +01:00
Greg Chadwick
163ed7ec9b [rtl] Switch FF RF to use unpacked arrays
Previously it had two packed dimensions. In general we prefer the use of
unpacked arrays for this kind of usage. In particular this had an impact
on trace viewing in GTKWave, the two dimensions were flattened into a
single large bus which made determining individual register values
tricky.
2022-09-27 09:59:09 +01:00
Greg Chadwick
d35ff67df6 [dv] Fix timeout issues
core_ibex_directed_test has a 'disable fork' that was killing processes
that were running sequences. Another part of the testbench waits for
those sequences to finish. When this 'disable fork' happens too early
the sequences are killed before they finish so the testbench never
terminated and times out. Instead ensure the sequences have finished
before doing the 'disable fork'.
2022-09-27 09:12:54 +01:00
Greg Chadwick
70186c57ae [rtl] Add ic_scr_key_valid field to CPUCTRL (renamed CPUCTRLSTS)
The ic_scr_key_valid field indicates whether the ICache scrambling key
is valid.

CPUCTRL is also renamed CPUCTRLSTS as it contains both control and
status bits.
2022-09-22 16:17:31 +01:00
Greg Chadwick
06fece4640 [cosim] Pass SecureIbex and ICache paramters through to cosim 2022-09-22 16:17:31 +01:00
Greg Chadwick
02ccf9e5d0 [ci] Bump cosim version for privilege spec updates 2022-09-07 17:31:41 +01:00
Greg Chadwick
cd8bb4608f [doc] Bump privileged spec version to v1.12 2022-09-07 17:31:41 +01:00
Greg Chadwick
1c5e6b10f5 [rtl] Remove/reword comments referring to specific specifications
Referring to specific parts of a specific version of the specification
can be brittle as all of these references need to be updated when we
shift specification versions. It's also redundant it should be generally
understood Ibex implements the RISC-V specifications and many lines
could have comments that point to the part of the specification they are
implementing. Rather than having a few of these for no particular reason
easier to just remove them all.
2022-09-07 17:31:41 +01:00
Greg Chadwick
423264ce5f [rtl] Clear mprv on mret to non M-mode
This is specification change between the v1.11 and v1.12 privileged
architectures. Previously mprv wasn't altered on mret. Now if returning
to a privilege level other than M mode mprv must be cleared.
2022-09-07 17:31:41 +01:00
Greg Chadwick
1d0344eb89 [rtl, dv] Add new CSRs for latest priviledged spec
This adds the following CSRs to support the v1.12 priviledged spec.

 - MSTATUSH
 - MCONFIGPTR
 - MENVCFG
 - MENVCFGH

MCONFIGPTR is read only and has its value provided by a ibex_pkg
parameter CSR_MCONFIGPTR_VALUE which is set to 0. Implementors can alter
this value if needed.

All the other CSRs ignore writes and read as 0.
2022-09-07 17:31:41 +01:00
Greg Chadwick
c30f7f98bd [dv] Prevent PMP setup for riscv_mem_error_test
RISCV-DV by default sets up some PMP regions. This leads to PMP failures
within riscv_mem_error_test which it isn't expecting. Suppress the PMP
setup to prevent this issue.
2022-09-06 16:52:24 +01:00
Greg Chadwick
494438dc4e Update google_riscv-dv to google/riscv-dv@9c2b007
Update code from upstream repository https://github.com/google/riscv-
dv to revision 9c2b007eea5baed25dc9b4c3181c2f328f98a2af

* [pmp] Add knob to suppress PMP setup code (Greg Chadwick)

Signed-off-by: Greg Chadwick <gac@lowrisc.org>
2022-09-06 16:52:24 +01:00
Greg Chadwick
056cb44ff7 [dv] Increase generated CSR instructions in riscv_rand_instr_test
This employs new RISC-V DV functionality to better stimulate reads and
writes for various CSRs in the random instruction test.
2022-08-30 13:12:11 +01:00
Greg Chadwick
95e0947e77 [cosim] Fix various CSR mismatches
This sets the initial values of a few CSRs in spike to match Ibex. It
also adds an mcause fixup so we get WARL behaviour matching Ibex.
2022-08-30 13:12:11 +01:00
Greg Chadwick
080ad8df96 [dv, cosim] Fix mcycle setting
Spike has a hack that decrements mcycle/minstret when written.
Previously this was not handled correctly by cosim. As we can only write
32 bits at a time two writes must be used and incremented to counteract
the decrementing handled carefully.
2022-08-30 13:12:11 +01:00
Greg Chadwick
28a352b602 [ci] Move to latest spike cosim version 2022-08-30 13:12:11 +01:00
Greg Chadwick
7c37648b06 [dv] Improve riscv_core_setting.sv template
This now takes into account more configuration options allow DV to run
successfully across more configs.
2022-08-30 11:53:14 +01:00
Greg Chadwick
3d76300686 [dv] Add makefile step for generating core config file from template
The prior system of using a patch to alter the riscv_dv_setting.sv file
has been removed and replaced with a mako templating based approach.

Fixes #1787
2022-08-30 11:53:14 +01:00
Greg Chadwick
9c4e4bdf6a [ci] Download cosim from lowRISC GCP bucket 2022-08-30 11:29:29 +01:00
Greg Chadwick
cfef9ef7bb [rtl] Integrity errors only relevant to loads
Previously ECC checks would occur on read data seen for both loads and
stores. The data response has no meaning for a write so should be
ignored.
2022-08-30 10:04:38 +01:00
Greg Chadwick
8653927bbd [dv] Drive read data/integrity to X for write response
Fixes #1727
2022-08-30 10:04:38 +01:00
Michael Schaffner
37745c5c72 [lint] Make case statements unique case
Signed-off-by: Michael Schaffner <msf@google.com>
2022-08-24 15:33:38 -07:00
Michael Schaffner
9e3989f205 [dvsim] Make sure results_html_name key is defined
Signed-off-by: Michael Schaffner <msf@google.com>
2022-08-24 14:42:02 -07:00
Michael Schaffner
e8783c711e [testplan] Align milestone/stage terminology
Signed-off-by: Michael Schaffner <msf@google.com>
2022-08-24 14:42:02 -07:00
Michael Schaffner
bbde00d174 Update lowrisc_ip to lowRISC/opentitan@d1be61ba8
Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
d1be61ba88a145e882df4e7c7a47f78bcf2371f8

* [testplanner] Replace IP milestone terminology with development
  stage (Michael Schaffner)
* [doc] Replace IP milestone terminology with development stage
  (Michael Schaffner)
* [prim] Fix missing case from prim_reg_cdc_arb assert (Timothy Chen)
* [tools/dv] Remove set_fsm_reset_scoring coverage directive from
  common.ccf (Steve Nelson)
* [dv] Exclude FSM transitions that can only happen on reset (Weicai
  Yang)
* [chip dv] Fixes for chip level falures (Srikrishna Iyer)
* [dv, mem_bkdr_util] Add system base addr (Srikrishna Iyer)
* Switch to run-time options instead (Timothy Chen)
* [dvsim] Fix coverage upload URL (Michael Schaffner)
* [prim] Tweak code slightly to avoid UNR entries (Timothy Chen)
* [prim] Add () to s_eventually (Timothy Chen)
* [dvsim] Add python workaround for shutil (Michael Schaffner)
* [dvsim] Make sure odir is of type Path (Michael Schaffner)
* [dvsim] Fix bug causing error in existing odirs (Canberk Topal)
* [prim] More refactoring to remove UNR generation (Timothy Chen)
* [dvsim] Fix flake8 lint warnings (Michael Schaffner)
* [dvsim] Align local and server path structure (Michael Schaffner)
* [dvsim] Remove support for email report (Michael Schaffner)
* [dvsim/doc] Place summary results into separate hierarchy (Michael
  Schaffner)
* [dvsim/utils] Fix a typo (Michael Schaffner)
* [dvsim] Default report folder name to 'latest' (Michael Schaffner)
* [dvsim] Use relative links on summary page (Michael Schaffner)
* [xcelium warning] Cleanup unexpected semicolon warning (Srikrishna
  Iyer)
* [dv/mem_bkdr] Fix digest update (Timothy Chen)
* [dvsim] Handle same test added twice via `-i` (Srikrishna Iyer)
* [lint] Fix shellcheck errors in hw (Miles Dai)
* [sw/silicon_creator] Rename mask_rom to rom (Alphan Ulusoy)
* [spi_device/dv] Fix payload check (Weicai Yang)
* [dvsvim] ensure ELF file with proper ext gets copied to `run_dir`
  (Timothy Trippel)
* [prim] Assertion update for prim_reg_cdc (Timothy Chen)
* [prim_lfsr dv] Designate a primary build (Srikrishna Iyer)
* [dv] Increase stress tests run time limit to 3h (Weicai Yang)
* [dvsim] Fix run timeout override in hjson (Srikrishna Iyer)
* [dv/cov] Exclude some prim modules from detailed coverage (Guillermo
  Maturana)
* [prim,dv] Reg CDC hardware request fix (Canberk Topal)
* [prim] Add more lint waivers (Michael Schaffner)
* [dvsim] Add support for specifying primary_build_mode (Srikrishna
  Iyer)
* [dv] Add some VCS coverage options (Srikrishna Iyer)
* feat(kmac): Add FI attack protection on packer pos (Eunchan Kim)
* [dv] small fix at mem_model (Weicai Yang)
* [dvsim] enable manufacturer tests to run in DV sim (Timothy Trippel)
* [dvsim] Fix errors due to test duplication (Srikrishna Iyer)
* [pad_wrapper] Do not model keeper (Michael Schaffner)
* [lint] Fix several SAME_NAME_TYPE errors (Michael Schaffner)
* [flash_ctrl] Lint fix (Michael Schaffner)
* [dvsim] Include error message cotext (Srikrishna Iyer)

Signed-off-by: Michael Schaffner <msf@google.com>
2022-08-24 14:42:02 -07:00
Greg Chadwick
7b4b780c7e [dv] Double timeout for an RTL run in regression flow
This takes it from 15 to 30 minutes
2022-08-23 13:35:51 +01:00
Marno van der Maas
d77dd501c9 [dv,pmp] Minor fixes to PMP full random test
- Increase iterations to 20 because double faults are less likely.
- Remove restriction on MPRV randomization.

Signed-off-by: Marno van der Maas <mvdmaas+git@lowrisc.org>
2022-08-22 09:55:31 +01:00
Marno van der Maas
4990aa2684 Update google_riscv-dv to google/riscv-dv@68e3bca
Update code from upstream repository https://github.com/google/riscv-
dv to revision 68e3bcac7293ac79067f0d8196bb973bd7c889cf

* [pmp] Remove restriction on using NAPOT when granularity = 0 (Marno
  van der Maas)
* [pmp] Add PMP entries for data in case of MML or MMWP (Marno van der
  Maas)
* [pmp] Add already_configured flag to skip address in PMP routine
  (Marno van der Maas)
* [pmp] Fix constraint and CSR write test in MML mode (Marno van der
  Maas)
* [pmp] Use random address instead of offset for full random test
  (Marno van der Maas)
* [pmp] Allow specifying address zero in `+pmp_region_%0d` (Marno van
  der Maas)
* [pmp] Randomizing entry for instructions for PMP randomization
  (Marno van der Maas)
* [lint] Remove trailing whitespace (Marno van der Maas)
* Tweak CSR constraints for more even read/write distribution (Greg
  Chadwick)
* [lint] Replace tabs with spaces (Marno van der Maas)
* [pmp] No PMP exception handler when no PMP support (Greg Chadwick)
* Expand CSR instruction constraint functionality (Greg Chadwick)
* Refactor CSR instruction into their own class (Greg Chadwick)

Signed-off-by: Marno van der Maas <mvdmaas+git@lowrisc.org>
2022-08-22 09:55:31 +01:00
Marno van der Maas
2669260aa0 [dv] Stop write PMP CSR routine when using full randomization 2022-08-22 09:55:31 +01:00
Harry Callahan
90daca9765 Bring back +disable_cosim to instead de-escalate fatal to info 2022-08-19 14:45:28 +01:00
Harry Callahan
d5c7b1be02 Remove the final cosim flags from core_ibex uvm environment
We are running with cosim by default now, and no longer support COSIM=0. Hence
this option and all downstream conditional paths are no longer required.
2022-08-19 14:45:28 +01:00
Harry Callahan
781f8445d8 Change method to locate ibex root to relative paths
I had used git to identify the repo root previously but this obviously does not
work with vendoring.
2022-08-19 11:45:52 +01:00
Marno van der Maas
f2f77a3cac [dv] Use lowRISC IP dir from imports instead of re-deriving it
Signed-off-by: Marno van der Maas <mvdmaas+git@lowrisc.org>
2022-08-19 11:45:52 +01:00
Marno van der Maas
6cb528f8ce [dv] Made dedicated gitignore file and add coverage files 2022-08-19 11:39:49 +01:00
Greg Chadwick
a646737d4d [rtl] Cannot add M mode executable PMP regions when MML = 1
A rule that allows M mode execution (either M mode only or shared M/U
mode) cannot be added when MML is set, unless RLB is also set.

Fixes #1740
2022-08-18 15:45:27 +01:00
Greg Chadwick
2ff233726d [dv] Add sim selection to icache make file 2022-08-18 14:51:23 +01:00
Greg Chadwick
1affeff527 [ci] Fix co-sim install
Due to a failure of mirror syncing the co-sim package cannot be
installed. This downloads it directly from the master server and
installs it manually.
2022-08-18 14:12:09 +01:00
Greg Chadwick
32801e8d12 [dv] Add MCAUSE and MSTATUS to the riscv_csr_test
With the new WARL functionality for the RISCV-DV CSR test generator we
can bring back these CSRs into the test.

Fixes #1663
2022-08-18 13:16:55 +01:00
Marno van der Maas
97ccca7f27 Made values of mcause 32 bits 2022-08-18 13:16:21 +01:00
Harry Callahan
261e9eb3b9 Fix isinstance error with Union types 2022-08-16 14:41:12 +01:00
Harry Callahan
7c8465f9c5 Switch to using pathlib3x to get backported features 2022-08-16 14:41:12 +01:00
Harry Callahan
bb15ce4378 Fix using built-in types as type hints not supported before Python 3.9
This could be reverted later if the required version changes.
2022-08-16 14:41:12 +01:00
Harry Callahan
111d84f549 core_ibex dv build system refactor
As well as completely removing the existing non-cosim flow, this commit
significantly refactors the build system to be less reliant on the makefile.

While we still use the Makefile, it is relegated to only providing scheduling
and dependency calculations between the different build steps.
This is possible by moving all of the build metadata into a file on-disk, which
is populated at the start of a new regression, then read and written to by the
different scripts executing the build. Each build step only needs to be passed
the location of this metadata at the top-level, and it can then import all
the information it requires to calculate and perform the next build stage.

This allows better observability into the build, as it is trivial to add new
data to this file, which is also provided as a human-readable yaml version.
It should also allow easier integration into different build systems, as the
dependency on Make is much weaker.

The file metadata.py and test_run_result.py contain the definitions for
these metadata objects. metadata.py defines an object for the whole
regression, while test_run_result.py defines objects for each individual test
performed.

The file riscvdv_interface.py has been created to better isolate the interface
with that project.
The file setup_imports.py has been created to centralize the importing of
python modules from other projects (riscvdv/ot_lowrisc_ip etc.).
Existing python code has been tidied to better conform to PEP8 standard
formatting, and to be more python in general such as using pathlib.Path.
2022-08-16 14:41:12 +01:00
Greg Chadwick
2f8dfa9dfe [dv] Reduce riscv_pmp_full_random_test iterations
We're seeing many timeouts in this test. This is causing issues for the
nightly regression. Keep the test in so we're aware of any major issues
with it but with far fewer timeouts to help keep the regression healthy.
We'll revisit the required iterations once we've sorted out the issues
with the test.
2022-08-12 17:22:04 +01:00
Greg Chadwick
db1eced0ee [rtl] Make PMP CSRs illegal in non PMP configurations
The previous behaviour was also acceptable but this matches spike.
2022-08-12 15:13:46 +01:00
Greg Chadwick
7e9eef2cf9 [cosim] Pass PMP configuration through to spike 2022-08-11 17:43:34 +01:00
Greg Chadwick
8282a0d244 [rtl] Fix MaxOutstandingDSideAccessesCorrect assertion 2022-08-11 15:44:41 +01:00
Greg Chadwick
4acc27b7ab [rtl, icache] Rework invalidation logic
This refactors the invalidation control logic into an explicit state
machine. The top-level icache_invalid_o signal is also removed.
Replaced with an explicit scramble key request instead.

This has all been done to better deal with corner cases around a new
invalidation being requested whilst another is still going on.
Previously there was a bug wher an invalidation request in the final
cycle of an ongoing invalidation didn't restart the invalidation but did
rotate the scrambling key producing an ECC failure and an alert.
2022-08-11 09:21:51 +01:00
Greg Chadwick
f2c09fe34a [ci] Move to spike-ibex-v0.4 2022-08-10 15:25:36 +01:00
Harry Callahan
3c1502c979 Add special-case signature for test_done in riscv_csr_test
This test is generated differently to all the others, as it exclusively uses a
python script.
The easiest way to make this work with the new test_done signature address is to
detect it as a special case and pass it the new address. The handshaking is only
used for ending the test, so the original address does not matter.
2022-08-10 14:00:41 +01:00
Harry Callahan
b8c6a343cb Change test_done mechanism to use riscvdv handshake, not ecall
Use the address (signature_addr - 0x4) for a TEST_PASS handshake.
Create new mem_seq_item subscriber port for test_done functionality.

By creating a new, distinct port and subscribing to all incoming memory items,
the existing wait_for_mem_txn() can be used with minor modifications to be
able to choose the port to wait on as an argument to the task.

Because the wait_for_mem_txn() implementation currently uses get() to pop the
latest item from the item_collected queue, having two different forked processes
that both await on this queue is not possible. The simplest solution is to
create a new, seperate port which also subscribes to the sequence_items
broadcast by the mem_if monitor.

Signed-off-by: Harry Callahan <hcallahan@lowrisc.org>
2022-08-10 14:00:41 +01:00
Greg Chadwick
e53a02ab31 [rtl] Alter some CSR WARL behaviour to match spike
The following changes are made:

- For unimplemented counters corresponding bits in MCOUNTINHIBIT read as
0 not 1
- For MHPMEVENTx we start at x = 3 with the first bit set (0-2
MHPMEVENTx CSRs do not exist)
- When writing an invalid privilege mode to MSTATUS.MPP/DCSR.PRV default
to U rather than M mode.

These new behaviours remain spec compliant and match spike.
2022-08-09 21:15:09 +01:00
Greg Chadwick
19d12ee3a7 [rtl] Fix MISA
Initially the 'B' bit was going to be used to indicate the presence of
the bit-manipulation extension. Now that has been seperated into
multiple smaller extensions the 'B' MISA bit isn't being used and
remains a reserved bit that should read as 0.

For the RV32B configurations where we implement non ratified
bit-manipulation extensions we must set the 'X' bit.

These changes matche the behaviour of spike.
2022-08-09 21:15:09 +01:00
Canberk Topal
ae76c62623 [dv,cosim] Add memory region to match UVM env
This extends our memory range to be between 0 and
0xFFFF_FFFF. This is needed because in the case of
no match between UVM memory model and spike memory
model, we see a mismatch.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-08-09 12:19:56 +03:00
Michael Schaffner
4975c7fa4b [lint] Minor fixes
Signed-off-by: Michael Schaffner <msf@google.com>
2022-08-05 12:25:36 -07:00
Marno van der Maas
0e5bedfff3 [dv,prim] Fix build and assert errors for vendored prim changes
After vendoring the new changes to the prim IP:
- Reorder `ibex_dv.f` to reflect the dependency on `prim_assert.sv`
- Disable assertion for register file prim onehot check.

Signed-off-by: Marno van der Maas <mvdmaas+git@lowrisc.org>
2022-08-05 18:00:25 +01:00
Marno van der Maas
90a81a3cc7 Update lowrisc_ip to lowRISC/opentitan@f9e667550
Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
f9e6675507fdd81e0b0dd3481c0a4bca634f322d

* [ralgen] Minor correction in alias-file passing mechanism (Michael
  Schaffner)
* [entropy_src/dv] Track FW_OV FIFO exceptions (Martin Lueker-Boden)
* [dv/clkmgr] Fix reset handling (Guillermo Maturana)
* [flash_ctrl] Add generic registers for the flash wrapper (Michael
  Schaffner)
* [fpv/prim_onehot_check] Fix prim_onehot_check compile error (Cindy
  Chen)
* [dvsim] Minor cleanup of job_runtime updates (Srikrishna Iyer)
* [chip/dv] replace wait with DV_WAIT (Weicai Yang)
* [dv] Add DV_WAIT macro (Weicai Yang)
* [dvsim] Display max CPU time in regression result (Cindy Chen)
* [dv, xcelium] Indicate SVA-disabled hierarchies (Srikrishna Iyer)
* [dv, xcelium] Update switches, sim finishi (Srikrishna Iyer)
* [utils,dvsim] Add wall-clock timeout feature (Guillermo Maturana)
* [prim_count] This reworks the primitive to make it more generic
  (Michael Schaffner)
* [dvsim] remove unecessary `sw_build_dir` parameter (Timothy Trippel)
* [dvsim] use Bazel labels for SW images (Timothy Trippel)
* [entropy_src/dv] Refactor entropy_src_rng_vseq (Martin Lueker-Boden)
* [dv, waves] Improve wave dumping (Srikrishna Iyer)
* [dv/kmac] Fix EDN timeout assertion failures (Cindy Chen)
* [doc] Move style guides into a separate section (Miguel Osorio)
* [spi_device/dv] Enable testing SFDP command (Weicai Yang)
* [doc] Unlist dangling pages from menus. (Miguel Osorio)
* [doc] Add DV intermediate sections (Miguel Osorio)
* [doc] Skip markdown templates from the build (Miguel Osorio)
* [dv/verilator] Fix numeric base of simulation statistics (Andreas
  Kurth)
* [dvsim] Make email.html filename more descriptive (Srikrishna Iyer)
* [csrng/dv] Add deposit to force states when disabled (Steve Nelson)
* fix(rdc): typo (Eunchan Kim)
* fix(rdc): Include NEW violations only to report (Eunchan Kim)
* [dvsim] Add support for SW (bazel) build opts (Srikrishna Iyer)
* fix(cdc): Parse NEW violations only (Eunchan Kim)
* feat(rdc): Add Meridian RDC log parser (Eunchan Kim)
* feat(rdc): Add Meridian RDC flow to dvsim (Eunchan Kim)
* [dv/cip_base] Add checking in stress_all_with_rand_reset seq (Cindy
  Chen)
* [clkmgr/prim] Make frequency measurement disable more robust
  (Timothy Chen)
* [prim/lint] Update waivers (Michael Schaffner)
* [doc] Update D2 checklist (Michael Schaffner)
* [clang-format] Format all covered files (Alexander Williams)
* [dvsim] Indicate what is currently running (Srikrishna Iyer)
* [doc] Fix trailing whitespace on md files. (Miguel Osorio)
* [doc] Remove README.md files from hw,utils folders (Miguel Osorio)
* [tools/dv] Modify common.ccf file for proper expression coverage
  (Steve Nelson)
* [prim_edn_req] Accumulate repetition errors until the data is
  consumed (Pirmin Vogel)
* [chip dv] Cleanup task invoked in func warning (Srikrishna Iyer)
* [topgen] Pass alias register paths into topgen for top RAL
  generation (Michael Schaffner)
* [dv] Split debug_access opt to another hjson variable for override
  (Weicai Yang)
* [dv] Fix ping exclusion (Weicai Yang)
* [prim] update register CDC scheme (Timothy Chen)
* [dv] Add assertion to check reg_we onehot error leads to a fatal
  alert (Weicai Yang)
* [sw,tests] Test flash_ctrl init and scramble (Dave Williams)
* [PRIM] new clock mux to prevent a glitch (Joshua Park)
* [dv] Add prim_cdc_rand_delay exclusion in cover_reg_top (Weicai
  Yang)
* [prim] Add additional qualification to the trigger (Timothy Chen)
* [prim] Add description to parameters (Timothy Chen)
* [sw,tests] Add -f option to copy in sim.mk (Dave Williams)
* [top/spi_device] constraint and clock updates (Timothy Chen)
* [dv] Update xcelium coverage config file (Weicai Yang)
* fix(prim): High memory usage of Assertion (Eunchan Kim)
* [top,dv] rv_dm agent update (Jaedon Kim)
* [dv] Enable reg_wr_check test for all blocks (Weicai Yang)
* [dv] Update tl testplan for reg write enable check (Weicai Yang)
* Refixed 12236 to a more rubust solution (Rasmus Madsen)
* [fpv/alert_handler] Add sec_cm FPV testbench for alert_handler
  (Cindy Chen)
* [dv,ralgen] revert `ralgen.py` to use relative file paths (Timothy
  Trippel)
* [dv,ralgen] update `ralgen.py` to use git paths over relative
  (Timothy Trippel)
* doc(prim): Specify ICEBOX for prim_packer (Eunchan Kim)
* [bazel,dvsim] update dvsim.py to use Bazel to build SW (Timothy
  Trippel)
* [prim] Added generic xnor2 (Arnon Sharlin)
* [flash_ctrl/prim_flash] Add parameters to tweak module latency
  (Timothy Chen)
* [prim_assert] Fix ASSERT_FPV_LINEAR_FSM (Guillermo Maturana)
* [chip,rstmgr,dv] regression fix rstmgr_alert_info test (Jaedon Kim)
* [dv/tool] Collect csr assertion cov (Cindy Chen)
* [otp_ctrl] Add generic registers for prim_otp_wrapper (Michael
  Schaffner)
* [dvsim] Use leaf most field if conflict rather than Exception
  (Eunchan Kim)
* [regtool] Extend UVM backend to support alias definitions (Michael
  Schaffner)
* [fvp/pwrmgr] Pwrmgr fsm error (Cindy Chen)
* [dvsim] Revert lowRISC/opentitan#12761 to build SW with meson
  (Timothy Trippel)
* [bazel,dvsim] update dvsim.py to use Bazel to build SW (Timothy
  Trippel)
* [prim] removed unused files (Timothy Chen)
* [flash_ctrl] Harden FIFO pointers (Timothy Chen)
* [dv] Remove TB_LINT_PASS in all IP checklists (Weicai Yang)
* [dv/flash_ctrl] Temp fix flash_ctrl regression compile error (Cindy
  Chen)
* fix(prim): Lint fix for line length (Eunchan Kim)
* fix(prim): Lint warning for `err_o` (Eunchan Kim)
* [dv] Fix Xcelium toggle collection (Weicai Yang)
* [hw/ip] Add extra prim_fifo_sync port (Timothy Chen)
* [prim/fifo] Add option to harden prim fifo pointers (Timothy Chen)
* [dv_base_reg] Extend search by name functions (Michael Schaffner)
* [fpv/lc_ctrl] Add gating conditions for sec_cm assertions (Cindy
  Chen)
* [primgen] Sort the parameters (Weicai Yang)
* [python] flake8 lint cleanups (Michael Schaffner)
* [prim_subreg] Remove anchor bufs since they are not needed (Michael
  Schaffner)
* [dv] Add `-xprop=mmsopt` run-opt for VCS (Weicai Yang)
* [dv] Temporarily remove CDC assertions (Weicai Yang)
* [hw/dv] further updated dv flow to now score systemverilog tasks and
  functions (Rasmus Madsen)
* [dv/chip] Fix bit_bash timeout error (Cindy Chen)
* [flash_ctrl] Allow fixed priority arbiter (Timothy Chen)
* [prim_assert] Minor rewording in comment (Michael Schaffner)
* [dv/xcelium] 1 attempt of cleaning up the coverage files (Rasmus
  Madsen)
* [dvsim] revert lowRISC/opentitan#12319 to fix CI (Timothy Trippel)
* [primgen] Sort the parameters to ensure stable order (Weicai Yang)
* [prim] Fix python style (Weicai Yang)
* [bazel] update dvsim.py to build ROMs with bazel (Timothy Trippel)
* [dvsim] Correct argparse usage statement and help (Drew Macrae)
* [prim_assert] Fix assertion include order (Michael Schaffner)
* [ast] Lint fixes and waiver updates (Michael Schaffner)
* [prim/lc_ctrl] Create a common assertion macro for linear FSM check
  (Michael Schaffner)
* [dv/csr_utils] Clean up mem_rd/wr print out message (Cindy Chen)
* [doc] Update D3 checklist per RFC (Michael Schaffner)
* [prim_dom_and_2share] Allow re-use of intermediate results for
  remasking (Pirmin Vogel)
* [prim_dom_and_2share] Add parameter to enable full/optional
  pipelining (Pirmin Vogel)
* [dv/vcs] Update cdc exclusion keyword (Cindy Chen)
* [prim] Add a duplicated prim_arbiter instance (Timothy Chen)
* [dv/cdc assertion] Temp remove CDC assertion cov collection in VCS
  (Cindy Chen)
* [prim_onehot_check] Rework lint fix (Michael Schaffner)
* [mubi/lc_ctrl] Change MUBI / lc_tx_t encodings (Michael Schaffner)
* [dv] Update xcelium cover.ccf to only enable coverage for dut
  (Weicai Yang)
* [dv/xcelium] Fix Xcelium nightly regression error (Cindy Chen)
* [prim_onehot_mux] Add lint waivers (Michael Schaffner)
* [prim_lc_sender] Add waiver (Michael Schaffner)
* [prim_mubi] Make sure waiver file is listed in core file (Michael
  Schaffner)
* [tlul_fifo_async] Move waiver to correct file and remove old waivers
  (Michael Schaffner)
* [prim_blanker] Remove prim_and2 waiver file (Michael Schaffner)
* [prim_packer] Lint fixes (Michael Schaffner)
* [prim_secded] Add lint waiver file (Michael Schaffner)
* [dv/cov] Exclude CDC module from collecting coverage (Cindy Chen)
* [reggen] Add spurious WE check to autogen'd regfile (Michael
  Schaffner)
* [prim_reg_we_check] Add spurious CSR write checker (Michael
  Schaffner)
* [prim_onehot_check] Add option for permissive en_i checks (Michael
  Schaffner)
* [tools/dv] updated UNR flow to support xcelium/jg (Rasmus Madsen)
* [prim] Add dv_macros missing dependency (Timothy Chen)
* [top, dv] Fix ext clk plusarg (Weicai Yang)
* [dv/build_seed] Fix build_seed (Cindy Chen)
* [clkmgr] Correct the disable condition (Timothy Chen)
* [flash, dv] Fix RMA test backdoor symbol overwrite (Weicai Yang)
* [top, dv] Fix rom backdoor symbol overwrite (Weicai Yang)
* [flash_ctrl] Add checks for unexpected acks (Timothy Chen)
* [prim_present] Add Verilator lint waiver (Michael Schaffner)
* [xcelium] Pass cov_merge_db_dir through to cov_report.tcl (Rupert
  Swarbrick)
* [dv/build_seed] Fix build seed errors (Cindy Chen)
* [prim_mubi] Add assertion to check that the values are complementary
  (Michael Schaffner)

Signed-off-by: Marno van der Maas <mvdmaas+git@lowrisc.org>
2022-08-05 18:00:25 +01:00
Marno van der Maas
5b15f7aad1 [vendor] Update patch file based on upstream OpenTitan 2022-08-05 18:00:25 +01:00
Canberk Topal
46404cf86f [rtl] Flush controller in PMP CSR write ops
As Greg pointed out:

When we have an instruction in ID/EX that writes a PMP register that
update gets written to the CSR the same cycle the next instruction
moves from IF to ID/EX with it's PMP check done with the old value.

The solution is to flush the pipeline when we get a PMP CSR write.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-08-05 15:50:42 +03:00
Harry Callahan
23806e2ad7 Fix incorrect debug_cause priority against riscv-debug 1.0.0-STABLE
The relevant page [Debug Spec v1.0.0-STABLE, p.53] gives the following
priorities for resolving multiple concurrent reasons for entering debug mode....

DCSR.cause : Explains why Debug Mode was entered.

When there are multiple reasons to enter Debug Mode in a single cycle,
hardware should set cause to the cause with the highest priority.
1: An ebreak instruction was executed.                        (priority 3)
2: A Trigger Module trigger fired with action=1.              (priority 4)
3: The debugger requested entry to Debug Mode using haltreq.  (priority 1)
4: The hart single stepped because step was set.              (priority 0, lowest)
5: The hart halted directly out of reset due to resethaltreq. (priority 2)
   It is also acceptable to report 3 when this happens.
6: The hart halted because it’s part of a halt group.         (priority 5, highest)
   Harts may report 3 for this cause instead.

Other values are reserved for future use.
2022-08-05 12:03:36 +01:00
Marno van der Maas
c4a97e05f5 [dv] Locking PMP regions in disable all regions tests 2022-08-03 15:06:03 +01:00
Marno van der Maas
cd5d957b3a [dv] Ignoring log files generated by Cadence tools
Signed-off-by: Marno van der Maas <mvdmaas+git@lowrisc.org>
2022-08-03 15:06:03 +01:00
Marno van der Maas
a97f384759 [dv] Allowing DV to disable PMP based on Ibex config
Added a patch for riscv_core_setting.sv, which is applied for the small
and experimental-branch-predictor configs.

Signed-off-by: Marno van der Maas <mvdmaas+git@lowrisc.org>

fixup
2022-08-03 15:06:03 +01:00
Marno van der Maas
5120fdadcc [dv] Add README for Ibex DV
Signed-off-by: Marno van der Maas <mvdmaas+git@lowrisc.org>
2022-08-03 15:06:03 +01:00
Marno van der Maas
ef86c30341 [dv] Write ePMP tests and enable ePMP in DV
- Enable epmp in riscv_core_settings.sv
- Bump CI and Spike version in `ci/vars.yml`
- Enable full random PMP test
- Create tests for machine mode lockdown (MML)
  - Code execute only, rest read/write
  - All regions execute only
  - All regions read only
- Create test for machine mode whitelist policy (MMWP)
- Create test for rule lock bypass (RLB)

Signed-off-by: Marno van der Maas <mvdmaas+git@lowrisc.org>
2022-08-03 15:06:03 +01:00
Marno van der Maas
b98efe7cbe Update google_riscv-dv to google/riscv-dv@808fb16
Update code from upstream repository https://github.com/google/riscv-
dv to revision 808fb162d66de5dd0dd2b45fd0b8d1fb1bf170f6

* [scripts] Improve WARL support in gen_csr_test (Greg Chadwick)
* [scripts] Refactor gen_csr_test (Greg Chadwick)
* Allow for WFI in User Mode (Canberk Topal)
* [Smepmp] Fixes `gen_pmp_instr` when MML and MMWP are enabled (Marno
  van der Maas)
* Fix typo in mseccfg_reg_t class (aneels3)
* Fix google/riscv-dv#819 (aneels3)
* lib.py, launch process in new session to fix timeout issue (Yannick
  Casamatta)

Signed-off-by: Marno van der Maas <mvdmaas+git@lowrisc.org>
2022-08-03 15:06:03 +01:00
Marno van der Maas
7f1bdcd5a2 [vendor] Remove patch that has been upstreamed 2022-08-03 15:06:03 +01:00
Canberk Topal
b5820b32c6 [dv,testlist] Enable irq_timer, allow WFI in Umode
This commit sets two different riscv-dv knob to make sure we hit
some holes in our coverpoints.

Activating `enable_timer_irq` for everytime we enable other
interrupts makes sure that we respond to it just like we respond
to other interrupts.

Setting tw=0 makes it so that we would allow WFI in user mode. We
were already randomizing it but for some certain tests, we actually
want to be in a sleep state, which wouldn't happen if tw=0 in user
mode.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-08-03 13:37:52 +01:00
Canberk Topal
cc55c47c37 [dv,core_ibex] Add push_pull agent for Scramble IF
This allows us to actually use Icache in our tests beecause
before this commit key_valid was tied to 0 which means everytime
we receive a FENCE.I instruction, we wouldn't be able to successfully
flag inval_done. Which means we weren't probably using ICache correctly.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-08-03 11:10:28 +01:00
Canberk Topal
e242ef07ad [rtl] Deny no-match X access in M-Mode while MML=1
In ePMP spec, it specifies as:

```
Executing code with Machine mode privileges is only possible from memory
regions with a matching Mmode-only rule or a locked Shared-Region rule
with executable privileges. Executing code from a region without a
matching rule or with a matching S/U-mode-only rule is denied.
```

This change provides that.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-08-03 10:59:40 +01:00
Greg Chadwick
e93452e502 [dv] Make Xcelium wave dumping includes unpacked arrays
In various places within Ibex we use unpacked arrays. We weren't dumping
these in Xcelium.
2022-08-02 15:57:12 +01:00
Canberk Topal
ae399e6454 [dv,fcov] IRQ and NMI detection fixes for fcov
This commit makes sure that different IRQs are collected in a single
`fcov_irqs` bus correctly. Also changes nmi_taken coverpoint to catch
interrupt taken case for NMI types from the same bus.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-08-02 10:16:08 +01:00
Greg Chadwick
6dc0683773 [dv] Fix IbexDataRPayloadX assertion
Some aspects of the memory response are only relevant to reads. This
introduces outstanding request tracking so we know which outstanding
requests are reads and applies X checks appropriately.

Fixes #1645
2022-07-26 16:58:30 +01:00
Canberk Topal
7bae3b7ba3 [dv,fcov] Fix cp_mem_raw_hz implementation
This commit fixes how we catch an instruction at WB stage. Before this fix
we were effectively checking opcode of decoded instruction instead.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-07-26 09:54:59 +01:00
Greg Chadwick
6518cb6db6 [dv] Add option to ignore cosim log to testlist
The riscv_csr_test does not use cosim but was failing due to lack of a
cosim log. This option skips the stage of pass/fail determination that
looks for that log.
2022-07-26 09:22:00 +01:00
Greg Chadwick
5fe158e222 [dv] Fix csr_description file
This adds a couple of missing fields to cpuctrl and comments out mcause.
mcause will be added back once RISC-V DV has been updated to support
WARL fields properly.
2022-07-26 09:22:00 +01:00
Greg Chadwick
c2a7af870a [dv] Pass end_signature_addr to generate test step
The CSR test generation needs to know end_signature_addr. Previously
this wasn't being passed to the test generator so CSR tests just looped
forever.
2022-07-26 09:22:00 +01:00
Harry Callahan
83ac7a94d2 Don't check MCAUSE[31] in debug_mode to identify sync/async trap
Interrupts are disabled in Debug Mode (Sdext 4.1.2), and simultaneously
registers, including MCAUSE, are not updated by exceptions (Sdext 4.1.3),
so reading MCAUSE[31] after an exception (eg. invalid instruction) in
debug_mode may still report the previous cause (which could be an interrupt).
2022-07-25 22:27:47 +01:00
Harry Callahan
8beddf5e8a Rework spike_cosim::step() to handle exception on 1st ISR instr
Seperate concerns so the flow of stepping spike and checking against
the ibex RVFI data is clearer. One 'step' of either system produces
different amounts of progress, and this conditional-checking-and-stepping
is needed to tie up the flows.
2022-07-25 22:27:47 +01:00
Canberk Topal
1e613cc7f4 [cosim,dv] Add support to set mcount registers
Extends RVFI connections further to include 30 mhpmcounterX registers.
Sets them up before every cosim step to let Spike know their real values.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-07-25 08:51:31 +01:00
Canberk Topal
a6c182e7be [dv,test] Fix race condition to catch ecall
We already have a clocking block inside dut_if. This commit uses it
to avoid a race condition that happens when `instr_valid_i` goes high
while `ecall_insn_i` goes low.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-07-22 19:26:40 +03:00
Canberk Topal
d84cd116c2 [dv,test] Enable FENCE.I instruction generation
Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-07-22 19:26:40 +03:00
Canberk Topal
ec7706cc9f [dv,fcov] Fix collecting non-waking IRQs in WFI
We were not being able to hit the bin because in order to do that
we needed to have a posedge clk when the condition happened. Now,
we are latching the condition to register it after we wake up from
sleep.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-07-22 19:26:40 +03:00
Greg Chadwick
50d183fc1b [ci] Add pmp_smoke_test cosim run to CI 2022-07-21 15:55:59 +01:00
Greg Chadwick
bb6427d276 [examples/sw] Add a pmp smoke test 2022-07-21 15:55:59 +01:00
Greg Chadwick
f8b6d468c3 [util] Add query functionality to ibex_config.py 2022-07-21 15:55:59 +01:00
Canberk Topal
dfca76f386 [dv,fcov] Implement Misaligned Mem Error coverage
Adds some signal to the load store unit to catch when we have the
fetch error signals from both first and second part of the misaligned
load/store access cases.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-07-21 01:02:15 +03:00
Greg Chadwick
1ea89a423b [dv] Fix traps in simple system cosim
Previously any traps seen on RVFI were skipped over. This was old
behaviour. With the latest cosim setup traps must be passed to the
`step` function.
2022-07-19 16:44:53 +01:00
Marno van der Maas
51f1141335 [lint] Point to correct Verible rules for lint workflow
Signed-off-by: Marno van der Maas <mvdmaas+git@lowrisc.org>
2022-07-19 11:03:09 +01:00
Harry Callahan
42d92c7c9b Create riscv_assorted_traps_interrupts_debug_test
Signed-off-by: Harry Callahan <hcallahan@lowrisc.org>
2022-07-15 14:09:36 +01:00
Harry Callahan
5bba52713f Fix randomize bug, add assertion for cnt != 0 2022-07-15 12:45:42 +01:00
Harry Callahan
806989a745 Commenting UVM testbench code, tidy formatting, minor refactoring
- Adds comments for quicker explanation of test and library functionality
- Refactor types and naming of control knob signals for clarity
- Move constraints from MEMBER to CLASS for more flexibility
- Add missing license header

Signed-off-by: Harry Callahan <hcallahan@lowrisc.org>
2022-07-15 12:45:42 +01:00
Marno van der Maas
3459d7f8df [lint] Remove whitespace from non-vendored source files
Signed-off-by: Marno van der Maas <mvdmaas+git@lowrisc.org>
2022-07-14 15:59:34 +01:00
Canberk Topal
7ba6667f32 [dv] Check privilege after DRET
Timing fix for dret_test and modelling controller behaviour for FLUSH transition.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-07-12 18:02:02 +03:00
Greg Chadwick
ab510f8acf [dv/doc] Tweaks/fixes to functional coverage
This fixes up some minor issues in the functional coverage plan and
implemented cover points
2022-07-11 12:10:55 +01:00
Canberk Topal
5c49fad9a2 [fcov] Adding debug related functional coverage
Includes coverpoints for:

- Hardware trigger point matches
- Debug simple step entrance in controller
- Seeing different insns while single stepping

Also updates on coverage plan to fill up missing mentions of
coverpoints/crosses

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-06-29 16:02:53 +03:00
Timothy Chen
31531f7325 Update crash dump to contain mtval
- mtval is a bit more useful for double fault situations
  as on the second exception we can still "remember" the
  data address and PC of the first exception.

Signed-off-by: Timothy Chen <timothytim@google.com>
2022-06-16 07:58:19 -07:00
Harry Callahan
81590d86c2 Fix multi-line string formatting in $sformatf for uvm_fatal macro
Before the change the indentation of the second line would be printed as spaces
in the fatal message.
2022-06-09 16:34:08 +01:00
Harry Callahan
15230d2c86 Subprocess timeout feature
Sometimes spike does not terminate when you might expect.
This is a bit of a hack to get CI dailies to fail in a reasonable time.
2022-06-09 16:33:56 +01:00
Pirmin Vogel
f71b23ddf8 Update google_riscv-dv to google/riscv-dv@0b2b3d6
Update code from upstream repository https://github.com/google/riscv-
dv to revision 0b2b3d65ce8fdff4de8974d1f328a90d6c1db5dd

* [epmp] Add support for mseccfg CSR (Pirmin Vogel)

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2022-06-09 09:00:42 +02:00
Rupert Swarbrick
9b68b5ef14 [dv,core_ibex] Allow instructions near the top of initialised IMEM
If you call the read() function on the memory model with an
uninitialised word, it generates a UVM error.

This is reasonable for data memory (where we never want to read
something without an architectural value) but is not reasonable for
IMEM, where Ibex runs ahead. Squash the error in this case, but force
bad integrity for the fetch to make sure we see something explode.
2022-06-01 14:02:45 +01:00
Canberk Topal
c253bd76a9 [dv] PMP related functional coverage points
Adding MSECCFG CSR related functionality also some write checks etc.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-06-01 13:25:09 +01:00
Canberk Topal
ea4e9383db [syn] Use sv2v for prim_generic_buf
Convert `prim_generic_buf` to Verilog as well.
Also, replace 'prim_buf' with 'prim_generic_buf' whenever we see a
`prim_buf` in a generated Verilog file.

Fixes #1557

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-06-01 11:24:19 +01:00
Pirmin Vogel
e1f614887e Update spike_cosim.cc to be able to build against newer Spike versions
This works with versions ibex-cosim-v0.2 and ibex-cosim-v0.3. The latter
version is required to support the mseccfg CSR added with ePMP.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2022-06-01 00:50:49 +02:00
Canberk Topal
57d810e7fe [fcov] Implementing interrupts section of covplan
Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-05-30 15:56:05 +01:00
Canberk Topal
97a949df02 [doc] Update coverage plan to point crosses/cp's
Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-05-25 13:37:30 +01:00
Canberk Topal
3b2e792a53 [fcov] Cross for Decoded Insn and Controller FSM
Bins are defined specifically for interested cases implied in coverage
plan.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-05-25 13:37:30 +01:00
Canberk Topal
1ad55daf96 [dv] Randomize mstatus.mprv properly
Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-05-25 13:37:30 +01:00
Canberk Topal
c2f5fea8a9 [fcov] MPRV with Load/Store and RAW Hazard
Added in functional coverage interface

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-05-25 13:37:30 +01:00
Canberk Topal
51bcae432b [rtl] PMP Logic Refactoring
This makes use of functions in a way that enables us to use `priv_lvl`
dependent logic in the DV environment.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-05-25 13:37:30 +01:00
Canberk Topal
46f1f69209 [rtl] Remove unused clk/rst_n in PMP module
Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-05-25 13:37:30 +01:00
Canberk Topal
04ce927a74 [fcov] Add various coverage points
Mostly related to WFI, but also double fault and icache enable

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-05-25 13:37:30 +01:00
Canberk Topal
f21b6545ac [fcov] CSR related coverage points
Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-05-25 13:37:30 +01:00
Canberk Topal
11002708ea xlm support for PMP coverage groups
Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-05-25 13:37:30 +01:00
Pirmin Vogel
223f7cd25b Update google_riscv-dv to google/riscv-dv@cc4b870
Update code from upstream repository https://github.com/google/riscv-
dv to revision cc4b87057cb38c91cb0c2ecb065e38281df7aa97

* Fix google/riscv-dv#857 (aneels3)
* [euvm] Fixed a typo in the README file (Puneet Goel)
* [euvm] updated the README file (Puneet Goel)
* [euvm] Moved euvm specific README to euvm folder (Puneet Goel)
* [euvm] ported some SV updates (Puneet Goel)
* [euvm] Fixed generated ASM code indentation (Puneet Goel)
* Add support for RV64IMC instr coverage (aneels3)
* Add register definitions for privilege spec 1.12 and debug spec
  1.0.0 (Henrik Fegran)
* Updated README note for EUVM (Puneet Goel)
* Use current date in output folder name (Puneet Goel)
* Try to create output file folder if it does not exist (Puneet Goel)
* Added a readme for EUVM port (Puneet Goel)
* Allow providing a randomization seed from command line (Puneet Goel)
* Make merging of directed instruction streams scalable (Puneet Goel)
* Create and use new class riscv_prog_instr_stream (Puneet Goel)
* Added and used append and prepend functions for instr_list (Puneet
  Goel)
* Added new targets and tests (Puneet Goel)
* Expose riscv instruction classes in the riscv gen package (Puneet
  Goel)
* Use mixin templates to create RISCV instruction classes (Puneet
  Goel)
* Fix a bug in asm section tag generation (Puneet Goel)
* EUVM upgrade for bitmanip (Puneet Goel)
* Use new clog2 implemented in esdl.data.bvec module (Puneet Goel)
* Add debug and clean targets to Makefile (Puneet Goel)
* Use Queue functions in place of array concatenation (Puneet Goel)
* Misc fixes after review (Puneet Goel)
* Fix broken run.py script (Puneet Goel)
* Use more verbose naming in main function in the test (Puneet Goel)
* Removed some redundant code comments (Puneet Goel)
* Allow verbosity and instr count specification from make run command
  (Puneet Goel)
* Handle riscv_loop_instr confliting constraint in post_randomize
  (Puneet Goel)
* Use variable names that do not conflict with outers (Puneet Goel)
* Use constraint in place of Constraint (Puneet Goel)
* Fixed a typo where '-' was getting printed in place of ' ' (Puneet
  Goel)
* Pick urandom from new location -- esdl.base.rand (Puneet Goel)
* Fixed an issue where newline character was not getting added to some
  instructions (Puneet Goel)
* Fixed an issue with sup program generation (Puneet Goel)
* Added EUVM riscv_instr_base_test (Puneet Goel)
* Added EUVM riscv_instr_register module (Puneet Goel)
* Moved EUVM files to euvm folder (Puneet Goel)
* Add makefile command to to run a test (Puneet Goel)
* Cast return value from ceil to integer (Puneet Goel)
* Miscelleneous fixes (Puneet Goel)
* Fixed some issues in riscv_loop_instr (Puneet Goel)
* Use variable for setting rand_mode (Puneet Goel)
* Use false in place of '0' for bools (Puneet Goel)
* Added build makefile (Puneet Goel)
* misc fixes (Puneet Goel)
* Added riscv instruction definitions (Puneet Goel)
* Added euvm module riscv_instr_registry (Puneet Goel)
* Added euvm module riscv_data_page_gen (Puneet Goel)
* Added euvm module riscv_privileged_common_seq (Puneet Goel)
* Added euvm module riscv_debug_rom_gen (Puneet Goel)
* Use urandom!bool in place of inappropriately named function toss
  (Puneet Goel)
* Added euvm module riscv_illegal_instr (Puneet Goel)
* Added euvm module riscv_asm_program_gen (Puneet Goel)
* Use esdl.rand: toss instead os uniform(0, 2) (Puneet Goel)
* Fixed randomization of avail_regs in euvm module riscv_instr_stream
  (Puneet Goel)
* Use esdl.rand: shuffle instead of randomShuffle (Puneet Goel)
* Added euvm module riscv_directed_instr_lib (Puneet Goel)
* added euvm module riscv_load_store_instr_lib (Puneet Goel)
* urandom has moved to package esdl.rand (Puneet Goel)
* Added euvm module riscv_instr_sequence (Puneet Goel)
* Added euvm module riscv_amo_instr_lib (Puneet Goel)
* Added euvm module riscv_instr_stream (Puneet Goel)
* A small fix in riscv_pmp_cfg module (Puneet Goel)
* Added euvm module riscv_loop_instr (Puneet Goel)
* Added euvm module riscv_pseudo_instr (Puneet Goel)
* Added euvm module riscv_vector_instr (Puneet Goel)
* Added euvm module riscv_floating_point_instr (Puneet Goel)
* Added euvm module riscv_b_instr (Puneet Goel)
* Added euvm module isa/riscv_compressed_instr (Puneet Goel)
* Added euvm module isa/riscv_amo_instr (Puneet Goel)
* Added euvm module isa/riscv_instr (Puneet Goel)
* Added euvm module riscv_callstack_gen (Puneet Goel)
* Added euvm module riscv_page_table_list (Puneet Goel)
* Used ranged switch case statements where required (Puneet Goel)
* Added euvm module riscv_privil_reg (Puneet Goel)
* Add @UVM_DEFAULT uda on the class members where required (Puneet
  Goel)
* Added euvm module riscv_reg (Puneet Goel)
* Added euvm module riscv_pmp_cfg (Puneet Goel)
* Added euvm module riscv_vector_cfg (Puneet Goel)
* Added euvm module riscv_page_table_exception_cfg (Puneet Goel)
* Added euvm module riscv_page_table_entry (Puneet Goel)
* Added euvm module riscv_page_table (Puneet Goel)
* Added riscv_core_setting module (Puneet Goel)
* Added new file riscv_instr_gen_config (Puneet Goel)
* Fixed some module imports (Puneet Goel)
* Added new file riscv_signature_pkg (Puneet Goel)
* Added D port of riscv_instr_pkg (Puneet Goel)

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2022-05-24 18:57:25 +02:00
Harry Callahan
c5567e8f66 Change makefile default simulator for core_ibex dv to xcelium 2022-05-23 17:24:12 +01:00
nedguthrie
fe157648a6 Fix formatting if IcacheScramble Description 2022-05-20 20:29:04 +01:00
Rupert Swarbrick
6efb4b1597 Dump riscv-dv generation messages to a log file
I was previously just dumping them to /dev/null because the
code always worked but... predictably I was wrong! Write them
somewhere more useful for debug.
2022-05-19 17:34:41 +01:00
Rupert Swarbrick
efd289dc17 [core_ibex] Disable waves by default
This seems like something you'd want to enable explicitly, to avoid
filling up a disk on a big run.
2022-05-17 12:04:26 +01:00
Rupert Swarbrick
09d2dd2306 Update ISA strings from Xbitmanip to XZb*
This allows us to model stuff more closely. This depends on Spike
version ibex-cosim-v0.2 (which is rebased onto a master branch commit
supporting these more specific ISA strings).
2022-05-13 09:47:00 +01:00
Pirmin Vogel
05f3b205c5 [doc] Add missing PKG_CONFIG_PATH now required for Ibex DV
Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2022-05-13 10:33:00 +02:00
Harry Callahan
832259401e Add warning when cosim is disabled by a plusarg
May aid in debugging
2022-05-12 11:01:36 +01:00
Harry Callahan
ef3549a2d3 Add pre_abort callback to cosim scoreboard for proper cleanup 2022-05-12 11:01:36 +01:00
Greg Chadwick
a0adf60d0b [dv] Fix bitmanip test building 2022-05-12 10:42:15 +01:00
Harry Callahan
0c38b203dd Run core_ibex dv with cosim by default 2022-05-11 15:46:46 +01:00
Harry Callahan
36129a2cb1 Modify existing comparison scripts to process cosim trace
Don't yet tear out the old logfile-comparision code, add a new path for the
cosim flow.

This uses the existing riscv-dv functions to parse the cosim logfile, as it is
fundamentally still generated by spike so should be checked for errors.
2022-05-11 15:46:46 +01:00
jamesrbailey
361f2ddedf Update ibex_top.sv
Adding conditional to instantiate non-scrambling instruction cache memories when ICacheScramble parameter is not set.
2022-05-04 14:40:00 +01:00
Karol Gugala
73a0586944 Sim: simple_system: pass MHPMCounterNum to core
Signed-off-by: Karol Gugala <kgugala@antmicro.com>
2022-05-02 10:12:44 +01:00
Harry Callahan
e34bb4d92f Construct compile-tb cmds to link against ISS for cosim
This is a continuation of PR's #1613 and #1575 work.

If cosim in enabled, we need to pass the appropriate flags to the eda tool for
it to link against the precompiled ISS when building the testbench.
This commit assembles the appropriate flags using pkg-config to query the
SPIKE_ISS build, then uses the scripts_lib.subst_vars() method to populate the
templated commands in the yaml.

The eda tools have different requirements for consuming the flags, so massage
them into the appropriate shape on the python side.
2022-04-29 11:13:21 +01:00
Harry Callahan
345dd6644b Fix variable-checking in makefile 2022-04-29 11:13:21 +01:00
Harry Callahan
d4c945622e Replace concatenation with mask operations
Make Xcelium happy
Add leading zero for readability (Addresses PR comment)
2022-04-29 11:13:21 +01:00
Rupert Swarbrick
42ce56b6b6 [dv] Simplify instructions for how to use Spike with cosim
This depends on Spike version ibex-cosim-v0.2 (which exposes the
various library headers with pkg-config, making configuration much
easier).
2022-04-29 11:13:21 +01:00
Canberk Topal
394a0d2160 Updating parameters for OpenTitan option
Updated the parameters with respect to top_earlgrey.hjson in OpenTitan
repository. For other builds, kept the previously undeclared parameters
as their default values.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-04-28 15:14:42 +01:00
Rupert Swarbrick
2f28987916 Remove some unused variables from core_ibex Makefile 2022-04-28 13:52:07 +01:00
Rupert Swarbrick
26f824b907 Infer PMP config from Ibex config in core_ibex scripts 2022-04-28 13:52:07 +01:00
Rupert Swarbrick
f6f84b0b06 Read config data in 2 steps in core_ibex scripts
No functional change, but this means we can look at the configuration
object to do other stuff without having to reload things.
2022-04-28 13:52:07 +01:00
Rupert Swarbrick
ecdb1e01f6 Remove ISA, ISA_ISS from Makefile
Move their calculation into the Python scripts, which means that we
don't have to make sure everything is kept in sync.
2022-04-27 16:33:49 +01:00
Rupert Swarbrick
b63ab3b120 Strengthen types in ibex_config.py
This should make it easier for other scripts to use
parse_config().
2022-04-27 16:33:49 +01:00
Canberk Topal
3ad3bd0d71 [dv] Coverage fixes
Makes coverage work for VCS and XLM.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-04-27 10:52:44 +01:00
Harry Callahan
4db6d15def Fix dead link 2022-04-27 10:51:42 +01:00
Rupert Swarbrick
d6bc8a6f2c Fix relocation of files in run-instr-gen for riscv_csr_test
Commit a628007 broke this test (which uses different paths from all
the others: aargh!)
2022-04-26 15:55:37 +01:00
Rupert Swarbrick
8e1fb63ff3 Don't pass --iterations to list_tests.py if not overriding it
This fixes a bug introduced by 14c400c, where I sort of half made this
change but didn't follow through the whole way!
2022-04-26 11:11:52 +01:00
Rupert Swarbrick
f082cf2351 Rationalize paths in core_ibex Makefile and scripts
Now we have the following structure (for an example where we've just
run seed 123 of riscv_arithmetic_basic_test):

    out/
    +- build/
    |  +- tb/
    |  |    (built testbench)
    |  +- instr-gen/
    |  |    (built instruction generator)
    +- run/
       +- riscv_arithmetic_basic_test.123/
       |  +- test.S
       |  +- test.o
       |  +- test.bin
       |  +- rtl.log
       |  +- trace_core_00000000.log
       |  +- spike.log
       |  ... (some more log files etc. here)
       +- fcov/
       |    (architectural fcov from riscv-dv)
       +- coverage/
       |    (merged coverage data)
       +- regr.log
       +- regr_junit.xml
       +- regr_junit_merged.xml
2022-04-26 10:57:30 +01:00
Rupert Swarbrick
ca4b655564 Delete some Makefile variables that we're not using any more 2022-04-26 10:57:30 +01:00
Rupert Swarbrick
7ac622c23b Allow compiling the TB when the working directory isn't core_ibex
This makes things much easier for OpenTitan integration.
2022-04-25 16:50:54 +01:00
Rupert Swarbrick
c2bead628a Simplify Makefile flow by removing sim_makefrag_gen.py
This used to work by dumping a Makefile fragment, reading it back in,
and then passing the relevant options through to the RTL compile and
run scripts.

This commit switches things around so that the RTL compile and run
scripts just look up the options when they need them.
2022-04-25 15:57:57 +01:00
Rupert Swarbrick
14c400c1e7 Factor out guts of list_tests.py
No functional change, but the point is that we can vendor this into
OpenTitan where dvsim can load up the Python library and get something
sensible without having to call a subprocess and mess around with
string parsing.
2022-04-25 13:51:02 +01:00
Rupert Swarbrick
668856441a Drop the "tb copy" stage of running a simulation
I don't quite understand why I thought this was needed: perhaps some
holdover from riscv-dv expecting files to be a certain shape? Anyway,
no need to keep it now.
2022-04-22 16:17:23 +01:00
Rupert Swarbrick
a628007826 Split calls to run-instr-gen.py 2022-04-22 16:17:23 +01:00
Rupert Swarbrick
a58fb02b68 Remove unused --lsf-cmd argument from run-rtl.py 2022-04-22 16:17:23 +01:00
Rupert Swarbrick
b4f5f17e4d Split calls to compile-generated-tests.py
This also involves a bit of file renaming, which makes the stuff
downstream a bit easier.
2022-04-22 16:17:23 +01:00
Rupert Swarbrick
b06f30b8a0 Split calls to run-iss.py
Now we call it once for each test and seed instead of getting riscv-dv
to iterate over all the tests and seeds we've requested.
2022-04-22 16:17:23 +01:00
Rupert Swarbrick
19d60932d5 Move read_test_dot_seed Python code to a helper library 2022-04-22 16:17:23 +01:00
Rupert Swarbrick
35a63d7e66 Change scripts_lib run_one to provide "redirect_stdstreams" 2022-04-22 16:17:23 +01:00
Rupert Swarbrick
3e42d128cd Write instr-gen build output to a log file, rather than stdout 2022-04-22 16:17:23 +01:00
Rupert Swarbrick
9dfdc800b7 Build insn generator in a different directory from where it runs
This isn't how riscv-dv wants to work! So we do a rather nasty hack in
run-instr-gen.py and rewrite the paths that come out of riscv-dv on
the fly.

Note that we don't move the instruction generator build vars to
something like $(OUT-DIR)/instr_gen/.build.vars.mk. The problem is
that the dumping of these variables runs as part of evaluating the
rule that builds the instruction generator (before the rule actually
runs). The end result is that you would end up writing them to the
directory and then immediately deleting the directory, causing
spurious rebuilds.
2022-04-22 16:17:23 +01:00
Rupert Swarbrick
87fb0b7906 Move pre-build tidyup into Python for build-instr-gen.py 2022-04-22 16:17:23 +01:00
Rupert Swarbrick
5a9b5b9993 Revert "Remove COMPILE_OPTS from Makefile"
This reverts commit 1f57795: these options are needed for plumbing
Ibex configs through. I've got a follow-up that does this more neatly,
but that depends on some other scripting changes so let's revert the
breakage for now.
2022-04-22 16:17:23 +01:00
Rupert Swarbrick
1c02f450d6 Revert "Remove SIM_OPTS from Makefile"
This reverts commit 014b544: these options are needed for plumbing
Ibex configs through. I've got a follow-up that does this more neatly,
but that depends on some other scripting changes so let's revert the
breakage for now.
2022-04-22 16:17:23 +01:00
Rupert Swarbrick
09cfe83191 Tidy up the sim.py wrapper script and rename it merge-cov.py
Also, update the copyright notice to be lowRISC: we've rewritten
pretty much the entire file, so I don't think it really makes sense to
describe it as copyright Google any more.

While we're at it, we slightly simplify the plumbing for Xcelium,
which means we don't have to export any Xcelium-specific environment
variables from the Makefile any more.
2022-04-22 13:02:15 +01:00
Rupert Swarbrick
f7863ce57c Move run_rtl wrapper into scripts lib 2022-04-22 13:02:15 +01:00
Rupert Swarbrick
8fd1a0df50 Add a wrapper script for building the core_ibex UVM testbench
This kind of existed already, but this tweaks things so that it's the
same shape as the other scripts we're adding and (hopefully) the
Python gets a bit cleaner.
2022-04-22 13:02:15 +01:00
Rupert Swarbrick
014b5443b8 Remove SIM_OPTS from Makefile
Again, this isn't used by anything and just adds complexity.
2022-04-22 13:02:15 +01:00
Rupert Swarbrick
1f57795468 Remove COMPILE_OPTS from Makefile
Again, this isn't used by anything and just adds complexity.
2022-04-22 13:02:15 +01:00
Rupert Swarbrick
f1199a38cd Remove --simulator_yaml argument from scripts
This is always fixed, so let's just grab the file from the code that
knows it needs it.
2022-04-22 13:02:15 +01:00
Rupert Swarbrick
b504995805 Move some Python libraries into the 'scripts' directory
We're about to want to use them from something else in that directory.
2022-04-22 13:02:15 +01:00
Rupert Swarbrick
58ade762be Set empty SUFFIXES in core_ibex/Makefile
No functional change, but it makes tracking down dependencies much
easier with "make -d".
2022-04-22 13:02:15 +01:00
Rupert Swarbrick
8faf3198fa Avoid creating xrun.log files in core_ibex directory
This is a bit of an overlap with the existing sim.log files that we're
creating (which contain slightly more information), but it turns out
that if you don't say anything then you get an xrun.log in the current
working directory.
2022-04-21 22:32:08 +01:00
Michael Schaffner
e1128aa2d4 Add SYNTHESIS ifdef around functional coverage code
This functional code coverage section has hierarchical paths, which will
break certain synthesis and lint flows.

Signed-off-by: Michael Schaffner <msf@google.com>
2022-04-21 09:26:30 -07:00
Michael Schaffner
7fc013c9a4 Break long lines due to lint warnings
Signed-off-by: Michael Schaffner <msf@google.com>
2022-04-21 09:26:30 -07:00
Michael Schaffner
ed35718431 Update Verible version
Signed-off-by: Michael Schaffner <msf@google.com>
2022-04-20 09:19:58 -07:00
Rupert Swarbrick
c9b0c11076 Fix quoting in ibex_config.py
This didn't quite work properly for Xcelium (giving strings with an
embedded space: '-define IBEX_CFG_RV32M=ibex_pkg::RV32MSingleCycle').
It turned out not to matter because we were evaluating one time too
often in the shell, but we're about to stop doing that.
2022-04-20 16:05:30 +01:00
Michael Schaffner
3264fe85c6 Update fetch enable encoding
This is done to match the encoding update done in the OpenTitan repo
here: https://github.com/lowRISC/opentitan/pull/12153

Signed-off-by: Michael Schaffner <msf@google.com>
2022-04-19 15:11:25 +01:00
Rupert Swarbrick
8d044a3ddc Replace dump-vars line for ISS runs
I accidentally deleted this in commit 9e0e0cd01.
2022-04-14 12:19:30 +01:00
Harry Callahan
6cc2d6149e Nit: remove some comments that got duplicated in 4854a131 2022-04-14 11:34:27 +01:00
Rupert Swarbrick
aa7168d3bd [dv] Tweak ibex_dv.f so we can use it in OpenTitan
It turns out that there aren't many changes needed, but we need to be
able to point at a prim directory that might not be inside
vendor/lowrisc_ip: put that path in an environment variable and pass
it from core_ibex/Makefile. That way, a caller on the OpenTitan side
can just override the corresponding variable and everything works.
2022-04-14 11:06:03 +01:00
Rupert Swarbrick
7fd03d4406 [dv] Add missing entries to ibex_dv.f
Oddly, changing how we do paths (in the next commit) caused the build
to fail without them. I don't understand why it worked before!
2022-04-14 11:06:03 +01:00
Rupert Swarbrick
903d895750 Fix spurious rebuilds from dumped vars
Commit f49f452f2 greatly tidied up the file, which is nice, but also
introduced some whitespace around the first argument to vars-prereq.
In Make, this causes chaos!

In particular, we ended up checking whether a variable called
something like "$(last-   gen  -vars-loaded)" was defined. It isn't,
but $(last-gen-vars-loaded) is.

Call strip in the vars-prereq function to get rid of the whitespace at
the "entry point" for all this machinery.
2022-04-14 09:44:47 +01:00
Rupert Swarbrick
9e0e0cd014 Add a wrapper script for running tests in ISS 2022-04-14 09:40:16 +01:00
Rupert Swarbrick
6dc5c0ed84 Add a wrapper script for compiling generated tests 2022-04-14 09:40:16 +01:00
Rupert Swarbrick
2dc7765081 Add a wrapper script for running the instruction generator 2022-04-14 09:40:16 +01:00
Rupert Swarbrick
9b14d0c908 Add a wrapper script for the instruction generator build
This is the first such script, but the idea is that we're going to
move a bunch of logic out of the Makefile and into Python scripts
where things are a bit easier to understand.
2022-04-14 09:40:16 +01:00
Rupert Swarbrick
a0638a8592 Move empty line avoidance into construct_makefile.py
Before we were running sed, but that's not so convenient from a
script. Since skipping empty lines is pretty easy, let's just do it in
Python.
2022-04-14 09:40:16 +01:00
Rupert Swarbrick
dcc7f85c84 Move guts of construct_makefile into a function
This means that other Python scripts can run it without needing a
subprocess.
2022-04-14 09:40:16 +01:00
Rupert Swarbrick
cb0c81a76f Move construct_makefile.py into the scripts directory 2022-04-14 09:40:16 +01:00
Rupert Swarbrick
60a04fdc3c Add an underscore prefix to RISCV_DV_OPTS in core_ibex Makefile
This isn't supposed to be something that people update manually.
Remove it from instr-gen-build-var-deps, since it's not something that
should ever change under our feet.
2022-04-14 09:40:16 +01:00
Rupert Swarbrick
d1b98d0ece Remove LSF_CMD from core_ibex Makefile
We're not using this and I strongly doubt that it actually works. Drop
the technical debt: we can always put something back in if we need to
in future.
2022-04-14 09:40:16 +01:00
Rupert Swarbrick
4854a131fa Remove GEN_OPTS from core_ibex Makefile
We don't actually use it anywhere and it adds some complexity. Let's
put it back in if we turn out to need it.
2022-04-14 09:40:16 +01:00
Michael Schaffner
ccc9bef3ec [regfile] Add countermeasure label
Signed-off-by: Michael Schaffner <msf@google.com>
2022-04-13 14:36:52 -07:00
Michael Schaffner
cfd9b45cfc [regfile] Add spurious write enable check for secure ibex
Signed-off-by: Michael Schaffner <msf@google.com>
2022-04-13 14:36:52 -07:00
Michael Schaffner
91745a076c Update lowrisc_ip to lowRISC/opentitan@1740ccd1a
Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
1740ccd1ad19f83bf2cec120c87b807b9af2ca1b

* [prim_onehot_check] Add address-based check (Michael Schaffner)
* [flash_ctrl] convert flash config to mubi (Timothy Chen)
* [sw,tests] Enter RMA LC_STATE and check flash access and wipe (Dave
  Williams)
* [prim_onehot_check] Add lint waivers (Michael Schaffner)
* [prim] Stub out guts of prim_cdc_rand_delay for Verilator (Rupert
  Swarbrick)
* [prim] Add missing waiver (Timothy Chen)
* [prim_onehot_check] Add prim_onehot_check (Michael Schaffner)
* [dv] Add TL error case - write with instr_type = True (Weicai Yang)
* [cdc-rand] Enable CDC random delay injection (Srikrishna Iyer)
* [fpv/pinmux] Add tl integrity error check (Cindy Chen)
* [prim_assert] Add static assertion macro for checks in pkgs (Michael
  Schaffner)
* [prim] Add prim_blanker (Greg Chadwick)
* [prim, rtl] Add new onehot primitives (Greg Chadwick)
* [dvsim] Fix looping through old result directories (Cindy Chen)
* [chip dv] Fixes for tests failing in nightly (Srikrishna Iyer)
* [present] Rewrite TB to avoid non-freely licensed code (Rupert
  Swarbrick)
* [secded_gen] Fix a bug in inverted Hamming codes (Michael Schaffner)
* [prim,rtl] Fix RW collision bug in prim_1p_ram_scr (Greg Chadwick)
* [dvsim,xcelium] Fix sed commands to generate plusargs (Rupert
  Swarbrick)
* [dvsim,xcelium] Split two plusarg strings (Rupert Swarbrick)
* [dvsim] Add a missing newline to error message (Rupert Swarbrick)

Signed-off-by: Michael Schaffner <msf@google.com>
2022-04-13 14:36:52 -07:00
Harry Callahan
d819fa6296 Fixup .rtl.tb_compile vars.mk filename
This was forcing rebuilds continuously
2022-04-13 20:31:15 +01:00
Harry Callahan
f49f452f2a Improve docs explaining Makefile variable dependencies 2022-04-13 16:14:20 +01:00
Harry Callahan
b4eb7323f7 Add better dependencies for the coverage targets using stampfiles 2022-04-13 16:14:20 +01:00
Harry Callahan
9b52fc132a Handle stdstreams from submakefile commands cleanly
Some commands utilise a logfile argument, while others capture the stdstreams
into a file. Discard the stdout/stderr when a logfile argument is used.
This keeps the logs readable.
2022-04-13 11:42:25 +01:00
Harry Callahan
7083d669c6 Add parallelism to instr_gen_run and iss_sim steps
This commmit enables parallelism of more steps of the dv process by capturing
the commands generated by the riscv-dv tool, then populating and executing a
sub-makefile. This allows us to have parallelism at the level of the makefile
jobserver.
Seperated instr_gen build and run steps

A python script construct_makefile.py is used to capture the raw output commands
and construct a trivial makefile for each stage.

This commit also renames some of the helper variables and stamps for consistency.
2022-04-13 11:42:25 +01:00
Harry Callahan
9ba58db30a Changed whitespaces to be consistent throughout Makefile
- Every line in a recipe must start with a tab, except wrapping lines of dependencies.
- Wrapping dependencies of a target use only spaces. Use two spaces by default.
2022-04-13 11:42:25 +01:00
Michael Schaffner
6caf82c2b4 [lint] Minor fixes
Signed-off-by: Michael Schaffner <msf@google.com>
2022-04-12 08:38:35 -07:00
mbaykenar
2ae62c145c assign irq_nm_int_cause to all zeros 2022-04-12 15:23:44 +01:00
mbaykenar
eeedeb003a Update ibex_controller.sv
Vivado gives synthesis error complaining about assignment of irq_nm_int_cause to '0 by saying it is an enum type.

Change the assignment to NMI_INT_CAUSE_ECC, which is defined to 5'b0 in ibex_pkg.sv
2022-04-12 15:23:44 +01:00
Rupert Swarbrick
1f6bcb9ab5 [dv] Remove support for building against ibex-cosim-v0.1 2022-04-12 11:09:33 +01:00
Rupert Swarbrick
ddb069bc1c [ci,docs] Bump minimum Spike version to ibex-cosim-v0.2 2022-04-12 11:09:33 +01:00
Rupert Swarbrick
0a9f5ed1da [rtl] Remove "mispredict" ports from icache
These are no longer needed: a previous commit has moved the logic that
handles misprediction into the IF stage and branch_mispredict_i was
dead zero.
2022-04-04 16:56:04 +01:00
Rupert Swarbrick
618f1f08bd [rtl] Remove "mispredict" ports from prefetch buffer
These are no longer needed: a previous commit has moved the logic that
handles misprediction into the IF stage and branch_mispredict_i was
dead zero.
2022-04-04 16:56:04 +01:00
Rupert Swarbrick
59a4d11c10 [rtl] Combine the two branch signals in the IF stage
The prefetch buffer and icache both treat the branch_i and
branch_mispredict_i signals identically, so it's a bit cleaner to pull
that treatment up into ibex_if_stage.sv

This commit doesn't change the modules below: it just passes zeros for
the "mispredict" version. Removing those ports will be done in a
follow-up commit.
2022-04-04 16:56:04 +01:00
Canberk Topal
a3e5eebffa [dv,fcov] Timeout fix + removing .ccf from yaml
Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-04-04 15:33:14 +01:00
Canberk Topal
9acd2583e1 Update google_riscv-dv to google/riscv-dv@6e0dc18
Update code from upstream repository https://github.com/google/riscv-
dv to revision 6e0dc183a4678bfd581c1021b5ab7705f31d14a5

* [XCelium] Enable coverage collection with XCelium (Canberk Topal)

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-04-04 15:33:14 +01:00
Canberk Topal
d659c96cda Update lowrisc_ip to lowRISC/opentitan@3a33c4df2
Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
3a33c4df2ed31b0d7a8936531a4ae9a275177f1b

* [prim,rtl] Pass addr_i in no scrambling case (Canberk Topal)
* [dvsim,xcelium] Avoid an OPTP2ND error if a plusarg isn't set
  (Rupert Swarbrick)
* [dv,tcl] Merge Coverage Databases with union_all (Canberk Topal)
* [prim_count] Add missing include (Pirmin Vogel)
* [sram_ctrl] Additional write gating based on intg error (Michael
  Schaffner)
* [sram_ctrl] Remove nonce reversal to improve timing (Michael
  Schaffner)
* [sram_ctrl] Retime address mux to improve timing (Michael Schaffner)

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-04-04 15:33:14 +01:00
Greg Chadwick
a3b50fb694 [doc, fcov] Remove coverpoint names from unimplemented coverage 2022-04-04 13:05:55 +01:00
Greg Chadwick
fbf4b6a5b2 [doc, fcov] Tweak and add coverpoints
Moved some from 'Miscellaneous' to 'Exceptions/Interrupts/Debug' and
added some details along with a couple of new coverpoints.
2022-04-04 13:05:55 +01:00
Greg Chadwick
ead2174c1a Introduce internal interrupt concept
An internal interrupt triggers an NMI. A single one is implemented, one
on integrity errors being seen in load data. This replaces a synchronous
exception on an integrity error which caused timing issues.
2022-04-01 17:00:23 +01:00
Canberk Topal
4a2427cd32 Fix cov_report directory in sim.py
Enables us to save coverage groups text file which helps easily see the overall
coverage in a regression.
2022-04-01 15:46:32 +01:00
Pirmin Vogel
db926e5ef5 [ram_2p] Set DataBitsPerMask parameter for prim_ram_2p
It turned out that with the default value of 1, Vivado infers a separate
18 Kbit BRAM instance for each bit of the 32-bit word for the FPGA
examples. This can be very wasteful in terms of resource utilization
especially for smaller configurations.

As our examples don't use ECC or parity and mainly target simualation
and FPGA, it's better to use a value of 8 for the DataBitsPerMask
parameter. Vivado will then not distribute words across different BRAM
instances which results in more efficient FPGA resource utilization.

For a detailed analysis and explanation, please refer to
lowRISC/Ibex#1587.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2022-04-01 16:32:45 +02:00
Pirmin Vogel
fe3e029108 Update google_riscv-dv to google/riscv-dv@cb4295f
Update code from upstream repository https://github.com/google/riscv-
dv to revision cb4295f9ce5da2881d7746015a6105adb8f09071

* Update list search (Matthew Ballance)
* Trap and report exceptions encountered in sub-processes and
  propagate error back (Matthew Ballance)
* Workaround fix for loop test colon issue (aneels3)
* Fix typo (aneels3)
* Add support for RV64AFD (aneels3)
* Fix typo (aneels3)
* Update README.md (aneels3)
* Add support for sub_programs (aneels3)
* fix issue with imm value for 64 bit instr (aneels3)
* Allow for underscores and capital letters in ISA for ISS (Pirmin
  Vogel)
* implement rv64i (shrujal20)
* Add support for RV32FD coverage (aneels3)
* Integrate random seed for pyflow (aneels3)
* Add riscv_loop_test (ShraddhaDevaiya)

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2022-04-01 16:15:35 +02:00
Canberk Topal
2fc4cde7d2 [dv,xlm] Pass simulator flag to cov.py in Makefile
Enables us to work with only xlm licences when doing the coverage.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-03-31 15:36:06 +01:00
Canberk Topal
4c1a4ed1df Update lowrisc_ip to lowRISC/opentitan@0747afbdd
Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
0747afbddec0ad176980429fe3100b32edb71d4a

* [dv] Enable C/C++ code sourcing with VCS in .core (Canberk Topal)
* [dv/dv_base_reg] Remove duplicated `get_map_by_name` method (Cindy
  Chen)
* [prim] Pulse Sync assertion to check input/output (Eunchan Kim)
* [sparse_fsm_flop] Create flop macro to increase DV coverage (Michael
  Schaffner)
* [dvsim] Make build-randomization opt-in (Srikrishna Iyer)
* [xcelium] Fix compile error (Srikrishna Iyer)
* [dv/cov] fpv_csr_assert only collect assertion coverage (Cindy Chen)
* [dv/jtag] Fix chip_level jtag csr rw failure (Cindy Chen)
* [rtl] Convert some non-ANSI parameters to localparams (Rupert
  Swarbrick)
* [prim] Waive unused parameters for Verilator in prim_generic_otp
  (Rupert Swarbrick)
* [prim] Make a variable widening explicit in prim_present.sv (Rupert
  Swarbrick)
* [prim] Waive some ALWCOMBORDER Verilator warnings in prim_arbiter_*
  (Rupert Swarbrick)
* [prim] Fix Verilator lint warnings in prim_gf_mult.sv (Rupert
  Swarbrick)
* [prim] Make some widening comparisons explicit in prim_clock_*.sv
  (Rupert Swarbrick)
* [prim] Waive unused EnableAlertTriggerSVA for verilator lint (Rupert
  Swarbrick)
* [bazel,dvsim] Add build rules for dvsim.py (Timothy Trippel)
* [prim] Fix a bunch of Verilator lint errors in prim_packer.sv
  (Rupert Swarbrick)
* [prim_sparse_fsm_flop/lint] Move waiver to correct file (Michael
  Schaffner)
* [rv_dm dv] Test drive compile-time seed (Srikrishna Iyer)
* [dvsim] Introduce Verilog compile-time seeds (Srikrishna Iyer)
* [dvsim] Treat `tests: ["N/A"]` as an ignored testpoint (Srikrishna
  Iyer)
* [hw/dv] Removed colon from Questa build and run fail patterns.
  (David Pudner)
* [hw/dv] Code review changes for running questa simulations. (David
  Pudner)
* [hw/dv] Added apache license header to questa_initial_setup.sh.
  (David Pudner)
* [doc/ug] Updated opentitan documentation to include information
  about Questa use. (David Pudner)
* [hw/dv] Added Questa dvsim files (David Pudner)
* [dv/unr] Blackbox common security modules from UNR flow (Cindy Chen)
* [dv] Minor fix to error message in mem_model.sv (Rupert Swarbrick)
* [keymgr] Update keymgr to use prim_edn_req (Timothy Chen)
* [doc] Fix rendering of special characters in testplan table (Rupert
  Swarbrick)
* [dv] enable tlul_assert for csr part2 (Rasmus Madsen)
* [dv] Enable tlul_assert for CSR tests (Weicai Yang)
* [dv] Add valid/ready req/ack coverage for push_pull agent (Weicai
  Yang)
* [dv,verilator] Make multiple sim_ctrl extensions play nicely (Rupert
  Swarbrick)
* [chip dv] Add AST initialization routine (Srikrishna Iyer)
* [top] auto generate (Timothy Chen)
* [reggen] Make field 'qe' behavior consistent (Timothy Chen)
* [prim] IFDEF_CODE waiver in sparsefsm flop (Eunchan Kim)
* [dv] Update checklist for all blocks (Weicai Yang)
* [dv/entropy_src] Temp remove stress_all_with_rand_reset test (Cindy
  Chen)

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-03-31 15:20:56 +01:00
Canberk Topal
68b56ef0f5 Include the main C++ file only with Verilator
This is necessary for having VCS support with simple system example.
Because in the ibex_simple_system_main.cc we are including some
Verilator exclusive header files.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-03-31 14:26:29 +01:00
Canberk Topal
db0b89a7ed [dv,xlm] Save each UCM file in <test_name>.<seed>
This enables to have a coverage report in instances where we have
different types of tests.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-03-31 14:11:12 +01:00
Canberk Topal
6884f6b990 Coverage support with Cadence Tools
Enables coverage collection while running the ibex-dv with xcelium.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-03-30 17:11:17 +01:00
Prajwala Puttappa
2317bb7fc0 [icache, dv] Added ram interface and enables ecc error injection.
This commit adds ibex_icache_ram_if to connect between DUT and tag /
data RAMs.

This interface injects 1 or 2 bit error on rdata if enable_ecc_errors
bit is set. It also checks that ecc_err_o pin is asserted by DUT
whenever an ecc error is injected.

ibex_icache_ecc_vseq and ibex_icache_base_vseq have been modified to
inject ecc errors through the ram interface.
2022-03-29 16:06:44 +01:00
Prajwala Puttappa
eea478be51 [icache, dv] Removed ecc agent
This commit removes ecc agent from the testbench. Following PRs will add
changes to drive the rdata pin (input to icache) with 1 or 2 bits
flipped.
2022-03-29 16:06:44 +01:00
Harry Callahan
98931c7dff Remove logfile param in Ibex RTL Sim for Xcelium
Fixes a bug where both Xcelium and Python open the same sim.log file and race to
write the simulation results into it. This change makes Python the sole writer of this
file using the captured stdout/stderr from the subprocess.run call in
run_rtl.py.

This bug was also previously present for VCS but was fixed in 90ff7ca6c.
2022-03-28 17:50:22 +01:00
Greg Chadwick
72acfe2fca [fcov, doc] Update coverage plan
Added coverpoint and cross names to relevant plan entries so plan is up
to date with implemented coverage. Also some minor changes to remove
plan entries that are no longer required.
2022-03-28 14:53:27 +01:00
Greg Chadwick
aee235cfa6 [fcov] Add and improve functional coverage 2022-03-28 14:53:27 +01:00
Greg Chadwick
d88e5f8ce4 [rtl] Refactor pmp logic 2022-03-28 14:53:27 +01:00
Greg Chadwick
90918dff1d [rtl] Refactor illegal instruction logic
This groups the various different illegal instructions categories within
ibex_id_stage rather than spreading them between ibex_id_stage and
ibex_controller.
2022-03-28 14:53:27 +01:00
Greg Chadwick
9fd512bdbd [rtl] Refactor illegal debug CSR logic 2022-03-28 14:53:27 +01:00
Greg Chadwick
36d77ab0c5 [ci] Fix coremark cosim job
Actually fail the job if there's an error
2022-03-22 16:29:03 +00:00
Greg Chadwick
7508644c6e [simple_system_cosim] Switch to latest cosim version 2022-03-22 16:29:03 +00:00
Greg Chadwick
93b71e2190 [simple_system] Fix GetIsaString
Spike expects extension letters to be in a particular order
2022-03-22 16:29:03 +00:00
Greg Chadwick
4fa6329c58 [cosim] Fix cosim mcycle update
This resolves an off by one issue
2022-03-22 16:29:03 +00:00
Greg Chadwick
f44ae90040 [doc] Update coverage plan 2022-03-21 14:52:26 +00:00
Prajwala Puttappa
07a49045fb [ibex, dv] Removed extra hierarchy of ic_top inside icache TB
This commit removes extra hierarchy of ic_top inside icache TB and moves
the scrambling request generation logic and instantiation of data and
tag RAMs to tb.
2022-03-18 18:32:20 +00:00
Rupert Swarbrick
96d8aa6c15 Update spike_cosim.cc to be able to build against newer Spikes
This should work with versions ibex-cosim-v0.1 and ibex-cosim-v0.2.
2022-03-18 15:24:46 +00:00
Rupert Swarbrick
63509ff4da [dv,core_ibex] Fix order of 'm' and 'c' in ISA string
Recent versions of Spike allow rv32imc but not rv32icm.
2022-03-18 15:24:37 +00:00
Prajwala Puttappa
6bb67e20f8 [icache, dv] Added scrambling agent to verify scrambling in RAMs
This commit adds a new scrambling agent to drive scrambling key and
valid to the data and tag memory interfaces.

Update lowrisc_ip to lowRISC/opentitan@7c4f8b3fd

Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
7c4f8b3fde4bb625ac3330ff52d3f66507190fe5

Signed-off-by: Prajwala Puttappa <prajwalaputtappa@lowrisc.org>
2022-03-18 10:33:27 +00:00
Prajwala Puttappa
9ef123f2b1 [icache, dv] Removed support for single clock cycle PMP error response
Earlier the design supported single clock cycle error responses from PMP
block whenever a read was done from blocked memory. Now there is at
least one clock cycle delay after the request has been granted for the
error to be asserted. Therefore, this commit removes the support for
single clock cycle PMP error response.
2022-03-17 18:07:16 +00:00
Prajwala Puttappa
c900ef1476 Update lowrisc_ip to lowRISC/opentitan@7c4f8b3fd
Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
7c4f8b3fde4bb625ac3330ff52d3f66507190fe5

Please note that we're adding push_pull_agent for the first time in this
commit.

Signed-off-by: Prajwala Puttappa <prajwalaputtappa@lowrisc.org>
2022-03-17 18:06:56 +00:00
Prajwala Puttappa
be5fffa656 [icache, dv] Fixed regression failure in ibex_icache_back_line
There was issue with rtespect to calculating number of instructions per
word and this commit fixes that issue.

Number of instructions per word = 1/4*1 + 3/4(1/4*3/2 + 3/4*2) = 53/32.
Earlier th5s was calculated as 7/4.
Ideal window length needed to calculate fetch ratio percentage is
calculated as 53/32*C*2 = 848. Earlier it was calculated to be 300.
2022-03-17 14:57:53 +00:00
Greg Chadwick
f7724adcc7 [rtl] Move memory ECC checks and generation into core
Previously integrity checks for incoming memory reads and integrity
generation for outgoing memory writes were handled within ibex_lockstep
and weren't duplicated.

This moves the integrity checks and generation into the core so they are
replicated and checked as part of the lockstep mechanism.

Additionally it generates a bus error on any memory integrity check
failure. This will result in Ibex taking an exception if any data read
or instruction fetch has bad integrity.
2022-03-16 10:21:03 +00:00
Rupert Swarbrick
2f1e188346 Fix port list in top_artya7 example
The "alert_major" port was split into "internal" and "bus" parts back
in commit 9943f9a. Update the example to match.
2022-03-15 15:37:03 +00:00
Greg Chadwick
094451a948 [doc] Add examples info to README 2022-03-11 17:28:52 +00:00
Prajwala Puttappa
0a8b4a4f61 [icache, dv] Made changes required to make TB compatible with Xcelium 2022-03-10 14:18:50 +00:00
Prajwala Puttappa
15da12dfd6 Update lowrisc_ip to lowRISC/opentitan@7c4f8b3fd
Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
7c4f8b3fde4bb625ac3330ff52d3f66507190fe5

* Revert "[dv] Allow using memutil_dpi_scrambled even without
  prim_ram_1p_scr" (Rupert Swarbrick)
* [dv] Fix some signed/unsigned comparison warnings (Rupert Swarbrick)
* [dv] Make an implicit up-conversion explicit (Rupert Swarbrick)
* [dv] Remove an unused array variable in prince_ref.h (Rupert
  Swarbrick)
* [prim/security] Improve the code for prim_sparse_fsm security check
  (Cindy Chen)
* [dv] Apply VCS option `-xprop=mmsopt` only when wave dump is off
  (Weicai Yang)
* [all] variety of minor lint fixes (Timothy Chen)
* [dv] Add options to improve VCS runtime (Weicai Yang)
* [rv_dm] CSR test fixes (Srikrishna Iyer)
* [dvsim] Fix pass/fail status for synthesis regression (Michael
  Schaffner)
* [prim] Minor lint fixes for unused clocks / resets (Timothy Chen)
* [dv] Flag illegal ENUMASSIGN warnings as errors (Michael Schaffner)
* [flash_ctrl] Correct erase suspend interface behavior (Timothy Chen)
* [rstmgr] Address several d2s review items (Timothy Chen)
* [fpv/sec] Add some workaround logic for $cast keyword (Cindy Chen)
* [dv] CSR seq lib - support for adapter-less RAL (Srikrishna Iyer)
* [dv] Prepare codebase for UVM REG changes (Srikrishna Iyer)
* [dv] Print computed CSR stuff in RAL (Srikrishna Iyer)
* [dv] Allow CSR tests to run on custom RALs (Srikrishna Iyer)
* [fpv/rom_ctrl] Check connectivity for alerts in rom_ctrl (Cindy
  Chen)
* [prim] Add prim_and2 primitive (Pirmin Vogel)
* [prim_dom_and_2share] Remove EnNegedge parameter (Pirmin Vogel)
* [prim_dom_and_2share] Use prim_xor2 and prim_flop_en primitives
  (Pirmin Vogel)
* [prim_dom_and_2share] Switch to single randomness input (Pirmin
  Vogel)
* [util/dvsim] Fix confusing error message (Guillermo Maturana)
* [dvsim] Minor changes to SynCfg results reporting (Michael
  Schaffner)
* [fpv] V2S formal support (Cindy Chen)
* [tools/xcelium] updated common coverage exclusions to exclude single
  bit correctly (Rasmus Madsen)
* [dv] Clean up enable_reg_testplan (Weicai Yang)
* [top] Hook-up flash/otp control and observation bus to ast (Timothy
  Chen)
* [lint] Increase the unroll count (Eunchan Kim)
* [entropy_src] Document & Implement THRESHOLD_SCOPE (Martin Lueker-
  Boden)
* [AST] USB Observe, Clocks & POR_NI logic update (Jacob Levy)
* [prim] Add new assertion macro for generating static lint errors
  (Pirmin Vogel)
* [dv] csr_seq_lib fixes (Srikrishna Iyer)
* [dv] dv_base_reg_block - Add special knobs (Srikrishna Iyer)
* [dv] dv_base_mem - add special knobs (Srikrishna Iyer)
* [prim] Move sec_cm assertion to an include file in prim_assert
  (Weicai Yang)
* [flash_ctrl] Fixes for erase suspend (Timothy Chen)
* [dv] exclude d_user.rsp_intg[6] for xcelium (Weicai Yang)
* [prim_flop_en] Dependency fix (Michael Schaffner)
* [dv] add mubi coverage for CSR and update reggen (Weicai Yang)
* [prim] Add option for secure buffers in prim_mubi (Timothy Chen)
* [prim] Add option for hand instantiated buffers for prim_flop_en
  (Timothy Chen)
* [dv/shadow_reg] Move shadow_reg to V2S (Cindy Chen)
* [prim_count] Updated comments to reflect all changes in
  lowRISC/opentitan#10378 (Michael Tempelmeier)
* [dv] Teach ECC32 flavours of mem_area to write with integrity bits
  (Rupert Swarbrick)
* [dv/shadow_reg] update milestone for shadow reg tests (Cindy Chen)
* [checklists] Update V2S checklists (Srikrishna Iyer)
* [tools/xcelium] updated xcelium flow to vcs for coverage test
  grading (Rasmus Madsen)
* [prim] Add stub flops to remove lint warnings (Timothy Chen)
* [dv] Add automatic covergroup for all regwen CSRs (Weicai Yang)
* [dvsim] Add support for tags in testplan (Srikrishna Iyer)
* [dv] Enable xcelium to include X for toggle coverage (Weicai Yang)
* [dv] Clean up mem_bkdr_util__sram (Weicai Yang)
* [util, testplan] Allow relative testplan imports (Srikrishna Iyer)
* [prim] Add phase output to shadow register primitive (Pirmin Vogel)
* [dv] Add assertion to check double_lfsr err triggers an alert
  (Weicai Yang)
* [dv] Fix foundary failure (Weicai Yang)
* [prim] update prim_count comment (Timothy Chen)
* [prim_flop_2sync] Make the prim a standard non-generated prim
  (Michael Schaffner)
* [dv/prim_max_tree] Fix xcelium compile error (Cindy Chen)
* [dv] Fixes to enable foundry database pwrmgr_smoketest (Timothy
  Chen)
* [dv] Add countermeasure verification for double_lfsr (Weicai Yang)
* [dv] Update countermeasure verification (Weicai Yang)
* [doc] Update V2S items (Weicai Yang)
* [prim_max_tree] Remove dedicated FPV TB since all SVAs are embedded
  (Michael Schaffner)
* [prim_max_tree/fpv] Add a simple formal testbench (Michael
  Schaffner)
* [prim_max_tree] Create a primitive that calculates maxima (Michael
  Schaffner)
* [dv] CSR / RAL model fixes (Srikrishna Iyer)
* [uvmdvgen] bug fix (Srikrishna Iyer)
* [dv] Fix some Xcelium warnings (Srikrishna Iyer)
* [dv] Disable some benign warnings (Srikrishna Iyer)
* [prim_mubi*_sender] Add option to omit sender flops (Michael
  Schaffner)
* [dv, mem_bkdr_util] Fix ECC-computed backdoor WRs (Srikrishna Iyer)
* [keymgr] sparsify the data control fsm (Timothy Chen)
* [prim_lc_sender] Add AsyncOn parameter (Michael Schaffner)
* [prim] Update behavior of prim_count (Timothy Chen)
* [flash_ctrl] Minor fixes to flash foundry failure (Timothy Chen)
* [sw,tests,pwrmgr] Improve synchronization (Guillermo Maturana)
* [sw,tests] SRAM execution test DV integration (Dave Williams)
* [dv] Update common_cov_excl to exclude d_user.rsp_intg[6] (Weicai
  Yang)
* [otbn, dv] Added otbn_passthru_mem_tl_intg_err testcase (Prajwala
  Puttappa)
* [rom_ctrl, dv] Fixes regression failures in
  rom_ctrl_passthru_mem_tl_intg_err (Prajwala Puttappa)
* [dv/chip] Add jtag_csr_rw seq (Cindy Chen)
* [chip dv] Remove xcelium build opt (Srikrishna Iyer)
* [doc] Reorder D2S checklist items (Michael Schaffner)
* [reggen] Add support for validation of RTL CM annotation (Michael
  Schaffner)
* [all] various simple lint fixes (Timothy Chen)
* [mem_bkdr,dv] Add missing type to otp_write_lc_partition_cnt (Rupert
  Swarbrick)
* [dv/csr_utils_pkg] Clone ral map with top-level submaps (Cindy Chen)
* [clkmgr] various spec and parameter updates (Timothy Chen)
* [dv] Add ASSERT_NET to check net value (Weicai Yang)
* [dv] revert lowRISC/opentitan#9050 and lowRISC/opentitan#9934
  (Weicai Yang)
* [primgen] Update AscentLint waiver in generated abstract prim
  wrappers (Pirmin Vogel)
* [prim_generic] Fix lint errors (Pirmin Vogel)
* [prim_count] Fix lint warnings (Pirmin Vogel)
* [prim_alert_receiver] Fix ping during init sequence bug (Michael
  Schaffner)
* [rom_ctrl, dv] Added passthru mem test (Prajwala Puttappa)
* [prim_assert,dv] Use if condition in assert_init (Srikrishna Iyer)
* [prim_filter_cnt] Make threshold runtime programmable (Michael
  Schaffner)
* [prim_filter*] Optionally instantiate a 2-stage sync in prim_filter*
  (Michael Schaffner)
* [dv] intg_err test cleanup and change passthru_mem_tl_intg_err to
  V2S (Weicai Yang)
* [prim_xilinx] Replace KEEP with DONT_TOUCH attributes (Pirmin Vogel)
* [sram/dv] Enable the integrity test for passthru (Weicai Yang)
* [dv] Add integrity test for passthru mem (Weicai Yang)
* [dv/tools] Fix alert ping exclusion (Cindy Chen)
* [dv/mem_bkdr_util] added backdoor write of LC counter into LC
  partition in OTP (Dror Kabely)
* [prim_pad_wrapper] Add dual pad wrapper for USB (Michael Schaffner)
* [prim_clock_mux] Model generic mux with boolean ops (Michael
  Schaffner)
* [prim_buf] Ensure generic primitives contain a logic cell (Michael
  Schaffner)
* [prim_count] improved documentation and style (Michael Tempelmeier)
* Revert "[dv] Replace fileset_partner flag with fileset_ast flag"
  (Michael Schaffner)
* [dv] Replace fileset_partner flag with fileset_ast flag (Sharon
  Topaz)
* [dv] Pass data_intg_passthru to dv_base_mem (Weicai Yang)
* [dv/prim_alert] Add V3 item to testplan (Cindy Chen)
* [dv/prim_count] Add an assertion to check max count stable (Cindy
  Chen)
* [dv] Fix typo in uvmdvgen comment (Rupert Swarbrick)
* [mem_bkdr_util] Use inverted integrity in rom_encrypt_write32_integ
  (Rupert Swarbrick)
* [doc/checklist] Template fix (Cindy Chen)
* [mem_bkdr_util,rom_ctrl] Fix how we call encrypt_sram_data (Rupert
  Swarbrick)
* [rom/ram/xbar/otbn] Switch end-end bus integrity to inverted ECC
  codes (Michael Schaffner)
* [dv/prim_alert_tb] Modify the seq to ensure alert always sends
  (Cindy Chen)
* [dv,xcelium] Fix lowRISC/opentitan#4230: Xcelium compile error.
  (Timothy Trippel)
* [dv/prim_alert] Add randomization in ping request sequence (Cindy
  Chen)
* [prim_alert_receiver] Only check for ping requests after
  initialization (Michael Schaffner)
* [doc] Update D2S checklist template and description (Michael
  Schaffner)
* [prim_esc_receiver] Switch to standardized prim_count (Michael
  Schaffner)
* [prim_count] Add option to disable the connection SVA (Michael
  Schaffner)
* [otbn, rtl] Lint fixes (Greg Chadwick)
* [sram/dv] Better support partial write in scb (Weicai Yang)
* [dv/mem_bkdr_util] Fix ECC width error in OTP foundary test (Cindy
  Chen)
* [secded/lint] Fix lint errors (Michael Schaffner)
* [dv/prim_esc] Add more stimulus to reach coverage goal (Cindy Chen)
* [alert_handler] Switch to sparse fsm primitive (Michael Schaffner)
* [prim_sparse_fsm_flop] Add a parameter to disable SVA (Michael
  Schaffner)

Signed-off-by: Prajwala Puttappa <prajwalaputtappa@lowrisc.org>
2022-03-10 14:15:03 +00:00
Prajwala Puttappa
e6eb4fb11d [ibex, dv] Added a sequence to toggle fetch_enable_i pin
Ibex has a top-level `fetch_enable_i` input. When set to on (noting it's a multi-bit signal for
security hardening though only the bottom bit is looked at for non secure ibex) Ibex executes
normally. When set to off Ibex will stop executing. Randomly toggling it should have no functional
effect on Ibex's behaviour.
The fetch enable sequence will randomly toggle the value of `fetch_enable_i` with a configurable
bias between the 'On' value and all other values.
2022-03-09 10:14:46 +00:00
Greg Chadwick
3438b77921 [rtl] Add minor alert for icache ECC error 2022-03-09 08:57:24 +00:00
Greg Chadwick
f89e721040 [icache, rtl] Fix ECC error indication
Data RAM ECC needs qualifying with hit/miss.
2022-03-09 08:57:24 +00:00
Greg Chadwick
3e4669f086 [rtl] Add SEC_CM markers for security features
These are used by the OpenTitan project to track the implementation of
security countermeasures
2022-03-09 08:57:24 +00:00
Prajwala Puttappa
af0c027867 [ibex, dv] Makes delays between req, gnt and rvalid configurable
This commit adds functionalty to the memory response agent to make delays more
configurable.
There are two delays
- Delay between req and gnt
- Delay between gnt and rvalid

For each of these delays we have three modes:
* Fully random delay
* Fixed delay
* Biased delay. Randomised delays but allow biasing towards 0 delay, to give a mix of runs with back
to back transfers with no delay and some with delays.

Signed-off-by: Prajwala Puttappa <prajwalaputtappa@lowrisc.org>
2022-03-08 13:48:32 +00:00
Prajwala Puttappa
46c397501d [ibex, dv] Added new base, interrupt, debug and mem error sequences
Added an independent base test with following capabilities:
* chooses between single run, multiples runs or infinite runs (existing sequence
does this via the `num_of_interations` variable).
* interval between runs can be fixed or random, with 0 delay between runs possible.
For random intervals there should be a way to bias them more towards 0 delay
(e.g. specify 75% of delays should 0 with the rest randomly chosen).

Added an interrupt sequence that inherits from the above base sequence.
It has following capabilities:
* chooses the number of interrupts to raise
* specifies the interval between interrupt being raised and dropped
* a mask to specify interrupts that shouldn't be raised.

Added a debug sequence with the only functionality to specify the interval between
the debug request being raised and dropped

Added a sequence to corrupt instruction and data memory.

Signed-off-by: Prajwala Puttappa <prajwalaputtappa@lowrisc.org>
2022-03-08 13:43:49 +00:00
Rupert Swarbrick
c15f3b8888 [icache] Define some fake DPI functions to simplify linking
This is triggered by the fact that if the ICache parameter is false
then we don't instantiate the ibex_icache module. For verilator
simulations, the module is then discarded entirely, which means that
its two DPI functions are not defined. That's unfortunate because
we're also compiling the code in scrambled_ecc32_mem_area.cc, which
expects the functions to be defined.

The obvious solution (don't include scrambled_ecc32_mem_area.cc if you
don't have an icache) isn't easy to do, because FuseSoc doesn't
currently allow us to use parameters to configure its dependency
tree (see fusesoc issue 438 for a discussion).

The super-clever solution that I came up with before(!) was to declare
these symbols as weak in the C++ code. That way, we can do a runtime
check to make sure that no-one is silly enough to call them without an
icache, but everything will still build properly either way.

Unfortunately, that doesn't work well with xcelium simulations.
Xcelium turns out to compile all the C++ code into one .so library and
generate functions for exported DPI functions in another. These two
solibs then get loaded at runtime with dlopen(). But this doesn't work
with weak symbols: in fact, it seems you end up with the C++ version
every time. Boo!

So let's be stupider about it and define (bogus) versions of the DPI
functions in this case. Fortunately, both of them are designed to
return zero on failure so we can just return zero and needn't worry
too much.

The idea is that when this lands, we can revert the OpenTitan change
that switched the C++ code to using weak symbols and Xcelium
simulations will start working.
2022-03-03 13:48:10 +00:00
Prajwala Puttappa
bdf2f2b440 [ibex, dv] Added agent configuration for ibex_mem_intf_response_agent
Defining agent configuration for any agent is a standard UVM flow and is
a cleaner flow for defining delay between driving sequence items,
passing virtual interface etc.

Agent configuration has been added to the existing agent to make delay
configuration more flexible in the future.

Signed-off-by: Prajwala Puttappa <prajwalaputtappa@lowrisc.org>
2022-02-28 14:44:58 +00:00
Greg Chadwick
0f69d4972c [dv] Add X assertions for top-level IO
Ensure all top-level inputs and outputs are known when they are
expected to be known.
2022-02-24 14:53:21 +00:00
Greg Chadwick
58bc6f27ab [doc] Add details about icache latency to DIT docs
When the icache is enabled and data independent timing is required
variable fetch latency due to cache hit or miss may introduce
undesirable timing behaviour. This adds explicit mention of this to the
documentation.
2022-02-23 08:48:12 +00:00
Greg Chadwick
d3bd063662 [rtl] Add prim_buf for security critical signals
A sufficiently agressive optimiser may optimise these away as under
normal functioning they effectively don't do anything. They are purely
to detect the presence of induced faults.
2022-02-22 08:57:31 +00:00
Greg Chadwick
b18eceba81 [rtl] Switch to multi-bit fetch enable
The multi-bit enable aids security hardening. For non secure Ibex all
but the bottom bit is ignored so it is effectively a single bit enable.
2022-02-21 15:35:35 +00:00
Rupert Swarbrick
3475b9106c Refer to a specific tag for the ibex-cosim version of Spike
We're going to want to make a couple more releases of Spike, cleaving
a bit closer to the upstream repository. Let's be explicit about which
version people should get.
2022-02-21 09:43:11 +00:00
Rupert Swarbrick
302bb65161 [doc] Update bitmanip list in integration.rst 2022-02-17 16:19:59 +00:00
Rupert Swarbrick
36a9abbf1c Use ifndef to avoid re-declaration warnings in *cosim_dpi.svh 2022-02-17 16:19:03 +00:00
Rupert Swarbrick
9f14922382 [dv] Construct ISA string from RTL parameters for cosim tests 2022-02-17 16:06:53 +00:00
Greg Chadwick
9943f9a42c [rtl, doc] Seperate major alert into internal and bus
This is to allow more consistent signalling in systems that integrate
Ibex (e.g. OpenTitan) so bus integrity errors external to Ibex and one's
detected within Ibex can be fed into the same alert whilst seperating
out Ibex's various internal alert causes.
2022-02-17 15:11:51 +00:00
Rupert Swarbrick
e84e7de53f Fix narrowing conversion warning in cosim_dpi.cc 2022-02-17 10:17:22 +00:00
Pirmin Vogel
a46ff07489 [rtl] Fix AscentLint errors
Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2022-02-17 07:51:58 +01:00
Rupert Swarbrick
336173b4d9 Re-enable bitmanip tests 2022-02-16 12:26:36 +00:00
Rupert Swarbrick
bc4bafd8ca [docs] Update description of ISS versions
We can now point at a single version of Spike (the "ibex_cosim"
branch, until we've managed to upstream things properly). And ditch
the OVPsim stuff: that's not going to be supported again any time
soon.
2022-02-16 12:26:36 +00:00
Rupert Swarbrick
6f6cafaa4d [ci] Bump Spike version to get cosim implementation
This will only have an effect on our private CI, which picks up this
spike build from the toolnas. The build is the ibex_cosim branch,
which contains the stuff we need for the recent cosim support. It's
also new enough to support the v1.0+0.93 bitmanip flavour that we
support in the RTL.
2022-02-15 17:27:44 +00:00
Rupert Swarbrick
5691ef1a45 [ci] Bump RISC-V toolchain version to get bitmanip support
This version should have support for bitmanip 1.00+0.93, the version
that we target in the RTL.
2022-02-15 15:17:52 +00:00
fabian
bbc48a0c34 Add srecord as simple_system prerequisite 2022-02-09 09:33:07 +00:00
Rupert Swarbrick
4482af1789 [doc] Fix inline literal syntax in icache.rst 2022-02-02 10:19:13 +00:00
Rupert Swarbrick
4bcc0fae6a [doc] Fix botched table layout
My commit 46b7e07 moved the right-most pipe symbol, which causes
Sphinx to skip the rest of the file. Oops!
2022-02-02 10:19:13 +00:00
Rupert Swarbrick
46b7e07098 [doc] Fix RV32B enum description 2022-01-27 16:02:44 +00:00
Greg Chadwick
69dfa6f8da [ci] Add missing python3-dev dependency
Private CI is broken without this. The public CI runs on azure agents
which already have this installed.
2022-01-26 15:39:38 +00:00
Greg Chadwick
c0f67946f2 [rtl,doc] Add double fault detection.
Fixes #1117
2022-01-25 15:05:39 +00:00
Greg Chadwick
97fa5cf280 [rtl,doc] Add customisable PMP reset values
Fixes #1423
2022-01-24 10:01:36 +00:00
Srikrishna Iyer
7c7e0e6d70 [ibex_tracer] Void cast function calls
...whose return value is ignored. This cleans up a compile time warning.

Signed-off-by: Srikrishna Iyer <sriyer@google.com>
2022-01-20 16:59:22 -08:00
Canberk Topal
187944c417 [icache] Add RAM Primitives for scrambling
This commit includes switching to a scrambling RAM primitive for
ICache data and tag RAMs. Also introduces minor changes to ICache
to handle scrambling key valid signal.

It also includes a minor bug fix regarding not initializing
`fill_way_q` signal without ResetAll parameter. When the parameter
is not set and we have our first hit right after ICache enables,
the signal hangs.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2022-01-19 14:59:43 +00:00
Greg Chadwick
e53b033962 [examples/fpga] Fix memory interface
Logic driving instr_gnt/data_gnt violated Ibex memory protocol. It just
happened to work until a recent change.

Fixes #1500
2022-01-14 09:00:48 +00:00
Greg Chadwick
2ec8d7433e [examples/fpga] Use 64 kB memory by default
The 256 kB is too large for the Arty-A7 with the A7-35T. Only use it
for the FPGA power analysis configuration.
2022-01-14 09:00:48 +00:00
Greg Chadwick
dcdd982686 [lint] Lint fix for RndCntLfsrX parameters
This doesn't produce a lint warning in the version of verilator
currently used in CI but does produce a warning in newer versions.
2022-01-14 09:00:48 +00:00
Pirmin Vogel
448191dda2 [rtl] Use prim_flop/clock_mux2 primitives for lockstep reset generation
These primitives can serve as anchor points for constraining backend
tools.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2022-01-11 19:59:21 +01:00
Greg Chadwick
756610800b [doc] Fix config and expand max-width of docs 2022-01-11 12:49:04 +00:00
Greg Chadwick
596b4d7e92 [doc] Add new Ibex testplan 2022-01-11 12:49:04 +00:00
Pirmin Vogel
8c01488624 [rtl] Document lockstep reset generation mechanism
Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2022-01-07 21:25:06 +01:00
Greg Chadwick
a5c55f132e [dv] Add initial coverage plan 2022-01-06 13:47:04 +00:00
Pirmin Vogel
410ffd349d [bitmanip, doc] Update info on bitmanip support and area numbers
Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2021-12-16 14:18:00 +01:00
Pirmin Vogel
119ac89130 [syn] Add missing package dependency
Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2021-12-16 14:18:00 +01:00
Pirmin Vogel
36c9f4e569 [rtl] Remove redundant comments in decoder
Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2021-12-16 14:18:00 +01:00
Pirmin Vogel
92a95cac32 [bitmanip] Add new configuration option for OpenTitan Earl Grey
RV32BOTEarlGrey selects the Zba, Zbb, Zbc, Zbs sub-extensions from
v.1.0.0 of the bitmanip spec and the Zbf, Zbp, Zbr, Zbt sub-extensions
from draft v.0.93. Zbe (bcompress/bdecompress) is supported by RV32BFull
only.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2021-12-16 14:18:00 +01:00
Pirmin Vogel
a33a91b232 [lint] Fix some AscentLint errors
Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2021-12-13 17:52:20 +00:00
Greg Chadwick
fd1195a148 [dv] Set UVM_VERBOSITY to UVM_LOW
Vendored in VIP from OpenTitan is very noisy at default UVM_MEDIUM
level, producing multi-GB log files in some instances.
2021-12-10 15:28:43 +00:00
Greg Chadwick
f1cd3bffc6 [dv] Fix bad reference to instr_req_out
instr_req_out no longer exists now PMP is handled on the IF/ID
interface.
2021-12-10 10:40:22 +00:00
Tom Roberts
72a892d62c [rtl] Move PMP checking to IF stage output
- Instruction addresses are now checked in the IF stage, after the cache
  and after the prefetch buffer.
- To deal with unaligned instructions, the PMP logic checks the current
  address and the next in parallel.
- The spec_branch timing hack has been removed as it's no longer
  relevant with the PMP logic moved.
- Various updates made to the icache testbench to account for the
  changes.
- Relates to #1471

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2021-12-09 18:06:53 +00:00
Pirmin Vogel
fccdd63992 [rtl] Replace always_ff with always @(posedge .. in FPGA regfile
This resolves lowRISC/Ibex#1485.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2021-12-09 16:35:31 +01:00
Greg Chadwick
fa3df3b8ee [dv] Fix PMP error handling for icache
The icache uses a single bit to signify an error. This could either be a
PMP error or a fetch error. Add extra probing so the testbench can
differentiate between the two cases.
2021-12-09 14:08:05 +00:00
Greg Chadwick
5e7c2cf00a [dv] Add missing copyright header 2021-12-09 14:08:05 +00:00
Greg Chadwick
cedabf062a [dv] Add recoverable NMI handling to cosim
Ibex implements a custom recoverable NMI handling scheme. This adds
modeling of it to the cosim.
2021-12-09 14:08:05 +00:00
Greg Chadwick
587dc364e9 [dv] Fix dside memory checking
Spike may access up to 8 bytes from the current PC, we must assume any
of those accesses are from the iside and skip dside memory checking for
them.
2021-12-09 14:08:05 +00:00
Greg Chadwick
545a034957 [dv] Fix cosim memory size
To match with the memory available in the testbench the cosim must
provide 2 GiB of memory.
2021-12-09 14:08:05 +00:00
Michael Schaffner
045b5707c1 Update google_riscv-dv to google/riscv-dv@6053014
Update code from upstream repository https://github.com/google/riscv-
dv to revision 605301400555c235564f9336cc5fc220af7e951c

* [style] Break long lines in newly added files (Michael Schaffner)

Signed-off-by: Michael Schaffner <msf@google.com>
2021-12-08 12:32:48 -08:00
Michael Schaffner
5350c13ae3 [ibex_top] Use correct ECC codeword for '0 reset in regfile
Signed-off-by: Michael Schaffner <msf@google.com>
2021-12-08 08:54:54 +00:00
Michael Schaffner
804c538db2 Update lowrisc_ip to lowRISC/opentitan@be1359d27
Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
be1359d27d0e826e28e6611f318c286253cd05f1

* [secded_gen] Enhance inverted ECC code (Michael Schaffner)
* [rtl] Add CRC32 primitive (Greg Chadwick)
* [syn/cdc] Minor flow fixes in CDC and syn scripts (Michael
  Schaffner)
* [dv] Minor update on mem_model (Weicai Yang)
* [dv/prim_alert] Clean up alert test (Cindy Chen)
* [bazel] Build verilator with bazel (Chris Frantz)
* [cdc] Add support for initial CDC flow with open-source views
  (Michael Schaffner)
* [lc_ctrl/dv,dv_lib,dv_utils,csr_utils] Added JTAG CSR Infrastructure
  (Nigel Scales)
* [prim] Add a lint waiver for dv-only code / ifdefs (Timothy Chen)

Signed-off-by: Michael Schaffner <msf@google.com>
2021-12-08 08:54:54 +00:00
Pirmin Vogel
c78acac8cc [rtl, bitmanip] Add xperm.[nbh] instruction (Zbp, draft v.0.93)
Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2021-12-06 11:14:49 +01:00
Pirmin Vogel
40dab87448 [rtl, bitmanip] Clarify situation around zext.[bh] pseudo-instructions
This is related to lowRISC/Ibex#1228.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2021-12-03 22:43:05 +01:00
Pirmin Vogel
da85ce5ecf [rtl] Fix typo in comment
Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2021-12-03 22:43:05 +01:00
Pirmin Vogel
16d6f5ea2b [rtl, bitmanip] Align Zbb implementation with draft v.0.93 and v.1.0.0
This invovles the following changes:
- Rename pcnt to cpop
- Switch encoding of max and minu
- Remove rev from Balanced version, only available in Full version via
  grev (Zbp)
- Include sext.b/h (previously in Zb_tmp)
- Remove slo[i] and sro[i] from Balanced version, only available in Full
  version (Zbp)

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2021-12-03 22:43:05 +01:00
Pirmin Vogel
e765b4dfec [rtl, bitmanip] Align Zbs implementation with draft v.0.93 and v.1.0.0
This only involves dropping the `s` from the instruction names, i.e.,
sbext becomes bext etc.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2021-12-03 22:43:05 +01:00
Pirmin Vogel
71b43a83e2 [rtl, bitmanip] Rename bext/bdep to bcompress/bdecompress
This change is related to the bitmanip draft version 0.94. It's needed
as in draft version 0.93 as well as in version 1.00 sbext from Zbs
changes to bext, leading to two completely different instructions having
the same name.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2021-12-03 22:43:05 +01:00
Pirmin Vogel
d8e50dcc2c Update google_riscv-dv to google/riscv-dv@ea8dd25
Update code from upstream repository https://github.com/google/riscv-
dv to revision ea8dd25140178eed13c3e0f3d3a97a0c07ab44a0

* Upgrade bitmanip v.0.92 to v.0.93, enable simultaneous use with
  v.1.00 (Pirmin Vogel)
* Added v1.0.0 bitmanip support (Henrik Fegran)
* Remove the pyucis-viewer from requirements.txt (aneels3)
* Update README.md for PyFlow & add pyucis-viewer in requiremen.txt
  (aneels3)
* Fix typo with fs3_sign (aneels3)
* Add hint_cg and illegal_compressed_instr_cg covergroups (aneels3)
* override deepcopy method (aneels3)
* Fix issue with illegal_instr_testi and randselect (aneels3)
* Fixed b_extension_c() issue (shrujal20)
* Fixed get_rand_spf_dpf_value() issue (shrujal20)
* Add support for RV32C coverage (aneels3)
* Add README.md for PyFlow (aneels3)
* Add gen_timeout for PyFlow (aneels3)
* Issue google/riscv-dv#778 fix, change mie behavior in
  setup_mmode_reg (Henrik Fegran)
* Fixed wrong length of I, S, B-type immediates causing wrong sign
  extension for certain instructions (Henrik Fegran)
* Update riscv_compressed_instr.sv (AryamanAg)
* Update var binary of function convert2bin (AryamanAg)
* Improve status reporting (Philipp Wagner)
* update ml/testlist.yaml to get better coverage (Udi Jonnalagadda)
* add m extension covgroup (ishita71)
* Update pygen_src files (aneels3)

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2021-12-03 22:28:50 +01:00
Michael Schaffner
169785d071 [secded] Switch to inverted ECC codes
Signed-off-by: Michael Schaffner <msf@google.com>
2021-12-02 15:14:11 -08:00
Michael Schaffner
4df2221dee Update lowrisc_ip to lowRISC/opentitan@34ba5e45f
Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
34ba5e45f9af7d8ca6c9bdae8bd11eeeeb669d6c

* [dv] Add new ECC code options to mem_bkdr_util (Michael Schaffner)
* [secded_gen] Define and generate inverted ECC enc/dec modules
  (Michael Schaffner)
* [dv] Only run registers through one csr_rw sequence at once (Rupert
  Swarbrick)
* [alert_handler] Minor lint fix (Michael Schaffner)
* [prim_clock_div] Fix minor Verilator lint warning (Michael
  Schaffner)
* [dvsim/lint] Make message reporting more flexible (Michael
  Schaffner)
* [lint] Unify lint parser scripts (Michael Schaffner)
* [rom_cntrl, dv] Test to verify successful rom check (Prajwala
  Puttappa)
* [dv, dv_macros] Enhance `DV_GET_ENUM_PLUSARG` macro (Srikrishna
  Iyer)
* [sram/dv] Fix mem data check (Weicai Yang)
* [prim] Add flop wrapper for sparse fsm (Timothy Chen)
* [flash_ctrl] Make data / metadata memories a single entry (Timothy
  Chen)
* [dv] Teach encrypt/decrypt_sram_data to support OTBN (Rupert
  Swarbrick)

Signed-off-by: Michael Schaffner <msf@google.com>
2021-12-02 15:14:11 -08:00
Canberk Topal
53b1732b19 Update lowrisc_ip to lowRISC/opentitan@3a672eb36
This commit also adds memory manipulation package in ibex repository.

Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
3a672eb36aee5942d0912a15d15055b1d21c33d6

* [mubi] Fix path in auto-gen header (Rupert Swarbrick)
* [dv] Allow using memutil_dpi_scrambled even without prim_ram_1p_scr
  (Rupert Swarbrick)
* [prim] Fix prim_ram_1p_scr Dependencies (Canberk Topal)
* [dv/clk_rst_if] Split clk_rst_if jitter to 2 different values (Eitan
  Shapira)
* [dv] Add external hjson path support in ralgen (Srikrishna Iyer)
* [dv] Add sub RAL block creation knobs (Srikrishna Iyer)
* [pwrmgr] Make rom_ctrl check signals multi-bit (Timothy Chen)
* [dv/alert_handler] Randomize mubi input (Cindy Chen)
* [flash_ctrl] Fix bank erase / info partition issue (Timothy Chen)
* [ci] Fix CI failure (Weicai Yang)
* [Cleanup] Remove lc_tx_e type and replace it with lc_tx_t (Weicai
  Yang)
* [aes] Add gtech synthesis setup (Michael Schaffner)
* [mubi] Enhance mubi_sync with stability check (Timothy Chen)
* [prim] Fix prim_packer_fifo when ClearOnRead is false (Rupert
  Swarbrick)
* [cleanup] Remove mubi4_e and replace it with mubi4_t (Weicai Yang)
* [dv] Fix shape calculations for replicated ECC (Rupert Swarbrick)
* [dv/alert] Support LPG in alert_sender/receiver pair (Cindy Chen)
* [dv] Add a ReadWithIntegrity method to Ecc32MemArea (Rupert
  Swarbrick)
* [dv] Simplify Ecc32MemArea read/write functions (Rupert Swarbrick)
* [prim] Add option to not clear the packer FIFO upon read (Pirmin
  Vogel)
* [dv] Change intg_err test from V3 to V2S (Weicai Yang)
* [util] Delete generate_prim_mubi.py (Rupert Swarbrick)
* [dv] Slightly generalise run_stress_all_with_rand_reset_vseq (Rupert
  Swarbrick)
* [fpv] Fix some assumptions in prim_count (Cindy Chen)
* [prim] quick path to prim_count assertion (Timothy Chen)
* [dv] Support Multiple EDN Interfaces in OpenTitan (Canberk Topal)
* [prim] Add xoshiro256pp primitive. (Vladimir Rozic)
* [dv/prim_alert] Fix async fatal alert regression error (Cindy Chen)
* [prim] Add missing include to prim_xilinx_pad_wrapper (Rupert
  Swarbrick)
* [prim] Add missing include to prim_mubi_dec* (Rupert Swarbrick)
* [dv/prim_alert_receiver] Fix assertion that consumes large mem
  (Cindy Chen)
* [prim] Remove extra semicolon (Weicai Yang)
* [chip,dv] Refactor CSR exclusion method (Srikrishna Iyer)
* [top, all] update connects for mubi (Timothy Chen)
* [flash_ctrl] Add plain text integrity in flash (Timothy Chen)
* [prim] Add time-out functionality to prim_clock_meas (Timothy Chen)
* [prim] Fix DC sythesis error (Weicai Yang)
* [fpv] Fix regression failures (Cindy Chen)
* [dv/ralgen] Update `dv_base_names` input from a string to a list
  (Cindy Chen)
* [dv/ralgen] Update the `dv-base-prefix` optional input (Cindy Chen)
* [doc] Add D2S and V2S checklist items to all checklists (Michael
  Schaffner)
* [dv] Test security countermeasures (Weicai Yang)
* [dv] Fix ASSERT_INIT race condition (Weicai Yang)
* [syn/aes/otbn] Minor fixes to fix block level synthesis (Michael
  Schaffner)
* [all] updated assert rtl ifdef (Timothy Chen)
* [dv] Update TL intg testplan (Weicai Yang)
* [prim] Add prim_fifo_async_sram_adapter to FPV list (Eunchan Kim)
* [spi_device] Upload Cmd/Addr FIFO status revision (Eunchan Kim)
* [dvsim] Modify resolve_branch to handle branch names with forward
  slash. (Todd Broch)
* [prim_clock_inv] Add option to disable FPGA BUFG (Michael Schaffner)
* [ralgen] Be more explicit which tool is called (Philipp Wagner)
* [prim] Tweak prim_sync_reqack_data assertion so it can be disabled
  (Rupert Swarbrick)
* [verible] Rename rule file (Philipp Wagner)
* [dv/base_monitor] Cleaned up base monitor (Rasmus Madsen)
* [fpv] prim_counter_fpv (Cindy Chen)
* [dv/shadow_reg] Cross shadow reg error sequence with csr rw (Cindy
  Chen)
* [dv] Fix scb multi-ral (Weicai Yang)
* [dvsim] Enabling glob-style patterns for -i switch (Srikrishna Iyer)
* [dv] Split sec_cm_testplan into multiple testplans (Weicai Yang)
* [dv/dsim] Remove dsim's system_lib from library path (Guillermo
  Maturana)
* [prim_packer] Resolve width mismatch (Philipp Wagner)
* [prim] Fix lint error in prim_util_memload (Philipp Wagner)
* [prim] Minor fix to make conn checks easy (Srikrishna Iyer)
* [fpv] prim_secded FPV testbench updates bind file naming (Cindy
  Chen)
* [dv_macros.svh] minor cleanup (Srikrishna Iyer)
* [dv,xcelium] minor cleanup (Srikrishna Iyer)
* [dv/shadowed_reset] Add a shadowed_rst_n interface (Cindy Chen)
* [fpv] Update FPV file naming (Cindy Chen)
* [top] Convert to mubi usage in some areas (Timothy Chen)
* [entropy_src] mubi updates (Timothy Chen)
* [prim] Add test for mubi invalid (Timothy Chen)
* [prim_double_lfsr] Add duplicated LFSR primitive (Michael Schaffner)
* [dv] Fix shadow reg backdoor path and enable csr_reset sequence
  (Weicai Yang)
* [prim] Fix unused net (Timothy Chen)
* [dv, clk_rst_if] Improve jitter and add scaling (Srikrishna Iyer)
* [prim] Anchor buffers around register flip flops (Timothy Chen)
* [alert_handler/top] Lint fixes and lc_tx_t to mubi4_t conversions
  (Michael Schaffner)
* [prim_mubi] Replace true/false_value() functions with parameter
  (Michael Schaffner)
* [dv/dsim] Get dsim to work at full chip (Guillermo Maturana)
* [prim] Fixes for prim_count (Timothy Chen)
* [top] Add various anchor points to modules (Timothy Chen)
* [dv/pwrmgr] Add wakeup test sequence (Guillermo Maturana)
* [reggen] Add mubi support into hjson (Timothy Chen)
* [dv/shadow_reg] Fix aes shadow reg failure (Cindy Chen)
* [dv/cdc] CDC simulation model (Udi Jonnalagadda)
* [prim_lfsr/lint] Add temporary waiver for LOOP_VAR_OP lint error
  (Michael Schaffner)
* [prim_clock_buf] Add lint waiver for unused parameter (Michael
  Schaffner)
* [dvsim] Correctly set self_dir for included Hjson files (Philipp
  Wagner)
* [util] Add tooling support for V2S milestone (Srikrishna Iyer)
* [prim_mubi] Add decoder module similar to prim_lc_dec (Michael
  Schaffner)
* [prim_mubi] Add mubi sender and sync primitives (Michael Schaffner)
* [prim_mubi_pkg] Switch to True/False terminology (Michael Schaffner)
* [prim] Minor work-around for xcelium (Timothy Chen)

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2021-11-29 17:25:30 +00:00
Tom Roberts
1bbe27effe [dv/icache] Add missing window reset call
The cache hit-rate tracking logic needs to be reset on every
invalidation.

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2021-11-18 15:54:29 +00:00
Sam Shahrestani
ab4041c439 Move NT branch addr calculation to ID stage 2021-11-18 13:05:19 +00:00
Rupert Swarbrick
b66f199151 Update lowrisc_ip to lowRISC/opentitan@ad629e3e6
Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
ad629e3e6e70c5eaa3c2dd68457b0a020448b35f

* [dvsim] Introduce {self_dir} as variable (Philipp Wagner)
* [dvsim] Small cleanups (Philipp Wagner)
* [prim_lfsr] Minor lint fix (Michael Schaffner)
* [dv] Update sec_cm testplan (Weicai Yang)
* [prim/lint] Move waiver to correct waiver file (Michael Schaffner)
* [prim_assert] Relocate waivers to dedicated prim_assert.waiver file
  (Michael Schaffner)
* [alert_handler] Lint fixes and waiver updates (Michael Schaffner)
* [prim_lc_receiver] Add parameter to select reset value (Michael
  Schaffner)
* [lint] Add lint waiver for IP regfiles with shadow resets (Michael
  Schaffner)
* [fpv] Fix Verible lint errors (Philipp Wagner)
* [prim_lfsr] Minor lint fixes (Timothy Chen)
* [clkmgr] Fix measurement control CDC (Timothy Chen)
* [fpv/prim_counter] Pad one bit to include overflow case (Cindy Chen)
* [fpv] Fix issue lowRISC#8371 (Zeeshan Rafique)
* [flash_ctrl] Flash ctrl security hardening (Timothy Chen)
* [dv] Fix CI error (Cindy Chen)
* [prim_alert_*] Extend SVAs for FPV (Michael Schaffner)
* [prim_alert_*] Update DV TB to respect initialization timing
  (Michael Schaffner)
* [prim_alert_rxtx_fpv] Update FPV environment and fix SVAs (Michael
  Schaffner)
* [prim_alert_sender] Update sender to support in-band reset mechanism
  (Michael Schaffner)
* [prim_alert_sender] Simplify sender and clear ping req upon sigint
  (Michael Schaffner)
* [prim_lc_sender] Add option to select reset value (Michael
  Schaffner)
* [prim] Correct assertion valid term (Timothy Chen)
* [prim_lc_combine] Align behavior of lc combine with mubi functions
  (Michael Schaffner)
* [fpv/tool] Support GUI mode on dvsim (Cindy Chen)
* [prim_lfsr] Further permutation refinements for SBox layer (Michael
  Schaffner)
* [dv/shadow_reg] Shadow register write by field (Cindy Chen)
* [prim] Fix the edge type (Eunchan Kim)
* [checklist] Updates to checklist for D2 status (Tom Roberts)
* [prim_mubi_pkg] Add a generic multibit type and associated functions
  (Michael Schaffner)
* [prim] Minor fix and clarification to prim_count (Timothy Chen)
* [keymgr/dv] Update testplan and covergroup plan (Weicai Yang)
* [prim_lc_combine] Fix parameterization error (Michael Schaffner)
* [fpv/prim_count] Small update on prim_count assertions (Cindy Chen)
* [dv] Add ip_name in reg_block (Weicai Yang)
* [keymgr] Finalize keymgr hardening (Timothy Chen)
* [prim_lc_combine] Add a prim to compute logical AND/OR for LC
  signals (Michael Schaffner)
* [dv] Remove common_cov_excl.el from unr.cfg (Weicai Yang)
* [dv/top_level] Loop through the SW test multiple times (Cindy Chen)
* [flash_ctrl] Various clean-up and updates (Timothy Chen)
* [prim] Change prim_reg_cdc assertions (Timothy Chen)
* [prim, keymgr] Migrate keymgr_cnt to prim_count (Timothy Chen)
* [sw dv] Multi-site support for Verilator (Martin Lueker-Boden)
* [dv/csr] Update write exclusion wdata value (Cindy Chen)
* [dv/dv_base_reg] remove debug display (Cindy Chen)
* [dv/shadow_reg] Fix alert shadow_reg regression error (Cindy Chen)
* [top] Integrate ast into fpga (Timothy Chen)
* [prim_lfsr] Improve statistics of non-linear output (Michael
  Schaffner)
* [prim_esc_receiver] Fix response toggling corner case (Michael
  Schaffner)
* option to use partner ast_pkg (Sharon Topaz)
* [dv/prim_esc] Double the ping timeout cycles (Cindy Chen)
* [dv] Use sed to add -elfile for each excl file (Weicai Yang)
* [dv] Fix coverage report error (Weicai Yang)
* [dv] Update common exclusion file (Weicai Yang)
* [dv/prim_esc] Improve FSM coverage (Cindy Chen)
* [reggen] Add a check to limit the swaccess type for shadow regs
  (Michael Schaffner)
* [prim_subreg_shadow] Fix for W1S/W0C corner case (Michael Schaffner)
* [prim_subreg_shadow] Disallow phase updates when storage err is
  present (Michael Schaffner)
* [dvsim] Add passing count by milestone in reports (Srikrishna Iyer)
* [dv/tool] Include toggle coverage for prim_alert_sender in
  cover_reg_top (Cindy Chen)
* [clkmgr] Harden clock manager through frequency measurements
  (Timothy Chen)
* [dv] Only enable VCS -kdb when dumping waves (Weicai Yang)
* [dv] Fix shadow reg (Weicai Yang)
* [dvsim] Allow non-integral values of --reseed-multiplier (Rupert
  Swarbrick)
* [ast] Fixes for various ast issues (Timothy Chen)
* [prim_esc_receiver] Assert escalation in case of sigint error
  (Michael Schaffner)
* [prim_esc_receiver] Minor signal renaming for consistency (Michael
  Schaffner)
* [dv/alert_handler] Support shadow register sequence (Cindy Chen)
* [verilator] Use FileSz rather than MemSz when flattening ELF files
  (Michael Munday)
* [prim_subreg_shadow] Only assert QE when committed_reg is written
  (Michael Schaffner)
* [dv,verilator] Round up SV_MEM_WIDTH_BYTES to a multiple of 4
  (Rupert Swarbrick)
* [prim] Add missing include (Pirmin Vogel)
* [dv/cover_cfg] Exclude prim_alert/esc from xcelium (Cindy Chen)
* [dv/cover_cfg] Exclude prim_alert/esc pairs (Cindy Chen)
* [clkmgr] Use local BUFHCE clock gates on FPGA (Pirmin Vogel)
* [prim_prince] Mark "leaf" functions in prince_ref.h as static inline
  (Rupert Swarbrick)
* [dv/shadow_reg] Check status after shadow_reg write (Cindy Chen)
* [dv/shadwo_reg] Shadow reg common sequence update (Cindy Chen)
* [otp_ctrl/lc_ctrl] Add 32bit OTP vendor test ctrl/status regs to LC
  TAP (Michael Schaffner)
* [otp_ctrl] Add VENDOR_TEST partition (Michael Schaffner)
* [prim] Edge Detector (Eunchan Kim)
* [prim_diff_decode] Fix asynchronous assertions (Michael Schaffner)
* [spi_device] Instantiate Upload module (Eunchan Kim)
* [dv] Add sv_flist_gen_flags HJson var for FuseSoc (Srikrishna Iyer)
* [dv, xcelium] Properly pass excl files to IMC (Srikrishna Iyer)
* [reg] Fix shadow reg update during storage error (Timothy Chen)
* [regfile] Refactor cdc handling to the reg level (Timothy Chen)
* [dv/prim_esc] Add a testplan and increase coverage (Cindy Chen)
* [dv] Update TLUL and EDN frequency (Weicai Yang)
* [rstmgr, top] Add support for shadow resets (Timothy Chen)
* [dv] Update Xcelium cover ccf (Srikrishna Iyer)
* [dv] reduce seeds for CSR tests (Weicai Yang)
* [usb/top] Remove AND gates on non-AON domain and rename 3.3V signal
  (Michael Schaffner)
* [dv/prim_alert] Improvement on prim_alert tb (Cindy Chen)
* [prim] FIFO SRAM Adapter fix (Eunchan Kim)
* [prim] Add Write Mask port (Eunchan Kim)
* [dv] Fix timescale issue with Xcelium (Weicai Yang)
* [dv/prim_esc] Fix prim_esc regression error (Cindy Chen)
* [dv/dv_base_reg] change from uvm_low to uvm_high (Cindy Chen)
* [sram_ctrl] Harden initialization counter (Michael Schaffner)
* [tools/uvmdvgen] Fix path in testplan inclusion (Guillermo Maturana)
* [dv] Change stress_all_with_rand_reset to V3 (Weicai Yang)
* [dv] fix tl error coverage (Weicai Yang)
* [dv] Add macro DV_GET_ENUM_PLUSARG (Weicai Yang)
* [prim] SRAM Async FIFO (Eunchan Kim)
* [dv, xcelium] Fix statement coverage extraction (Srikrishna Iyer)
* [dvsim] Minor fixes to coverage extraction (Srikrishna Iyer)
* [prim_lfsr] Do not shadow |state| variable (Philipp Wagner)
* [prim] Add non-linear out option to prim_lfsr (Timothy Chen)
* [dv] Constrain TLUL to 24Mhz or higher (Weicai Yang)
* [primgen] Instantiate tech libs in stable order (Philipp Wagner)
* [primgen] Actually find the Verible Python wrapper (Philipp Wagner)
* [dv/prim_esc] fix regression error (Cindy Chen)
* [dv] Fix shadow reg predict (Weicai Yang)
* [dv/common] Exclude assertion coverage from IP level testbench
  (Cindy Chen)
* [dv/prince] hit additional toggle coverpoints (Udi Jonnalagadda)
* [sram_ctrl] Update docs (Michael Schaffner)
* [sram_ctrl] Absorb prim_ram_1p_scr (Michael Schaffner)
* [dv/prim_alert/esc] Improvements for prim_alert/esc_tb (Cindy Chen)
* [dv/dvsim] Add "testfile" grading option (Guillermo Maturana)
* [dv/prim_esc] Direct test for prim_rx/tx (Cindy Chen)
* [dv/utils] added 6MHz to clk_freq_mhz_e (Dror Kabely)
* [prim_xor2/lint] Add waiver for .* use in generated prim (Michael
  Schaffner)
* [dv, doc] Replace all 'dv.plan' with testplan (Srikrishna Iyer)
* Fix the testplan link in dvsim code (Srikrishna Iyer)
* [dv/dsim] Add dsim workaround for issue 242 (Guillermo Maturana)
* [util, reggen] Support standardized cdc handling for regfile
  (Timothy Chen)
* [dv/shadow_reg] Align shadow_reg field update behavior (Cindy Chen)
* [dvsim] Fix publish report summary typo (Cindy Chen)
* [rtl/prim_alert_sender] Allow ping_req to stay high without error
  (Cindy Chen)
* [dvsim] Separate publish report from dvsim flow [PART3] (Cindy Chen)
* [dv/prim_alert] Add a testbench for prim_alert (Cindy Chen)
* [otp_ctrl] Connect test-related GPIO signal (Michael Schaffner)
* [prim_subreg_shadow] Make local parameter a localparam (Philipp
  Wagner)
* [prim_subreg] Make software access type an enum (Philipp Wagner)
* [rtl/prim_diff_decode] Add prim_flop_2sync dependency (Cindy Chen)
* [otp_ctrl] Update AscentLint waiver file (Michael Schaffner)
* [edn] Add MaxLatency assertion (Eunchan Kim)
* [prim_subreg_shadow] Correct write data signal usage (Michael
  Schaffner)
* [script/dvsim] Separate publish report from dvsim flow [PART2]
  (Cindy Chen)
* [prim_lfsr] Fix assertion issue occuring right after reset (Michael
  Schaffner)
* [dv/shadow_reg] Handle CSR automated sequence write abort (Cindy
  Chen)
* [dv/dv_lib] Add post_apply_reset for extra delay (Guillermo
  Maturana)
* [dv] Add function coverage plan for tl_errors, tl_intg_err (Weicai
  Yang)
* [dv] Remove tl_intg_err in top-level and increase seeds for
  tl_intg_err (Weicai Yang)
* [dv/shadow_reg] Fix alert shadow reg regression error (Cindy Chen)

Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
2021-11-16 10:49:23 +00:00
Greg Chadwick
e70add7228 [ci] Add co-simulation testing of CoreMark 2021-11-12 09:39:38 +00:00
Greg Chadwick
63ac629d10 [coremark] Add option to coremark build to suppress pcount dump
When using cosim checking performance counters won't match between ISS
and RTL. This option allows coremark to be run under cosim checking.
2021-11-12 09:39:38 +00:00
Greg Chadwick
c3dd66e9fa [cosim] Update documentation for cosim
Also adjusts quick install instructions to use /opt/spike-cosim as
that's the path used by the pre-packaged version.
2021-11-12 09:39:38 +00:00
Greg Chadwick
84d2d6ad3f [cosim] Add Simple System with cosim 2021-11-12 09:39:38 +00:00
Greg Chadwick
580ddaad13 [simple_system] Refactor Simple System
Refactor Simple System into a C++ class. This enables easy extension of
Simple System.
2021-11-12 09:39:38 +00:00
Greg Chadwick
b57cad5387 [dv] Add matched instruction count to cosim 2021-11-12 09:39:38 +00:00
Greg Chadwick
c10b56ed17 [dv] Adjust cosim include paths
Some Spike include files can clash with libelf include files. Avoid
directly adding riscv and fesvr directories to include path to prevent
this.
2021-11-12 09:39:38 +00:00
Michael Munday
c35472abb9 [bitmanip][zba] Add support for Zba (address calculation) extension
Add support for the Zba extension added in v0.93 of the bit manipulation
specification (unchanged in v1.0.0). The new instructions added are:

  - sh1add: rd = (rs1 << 1) + rs2
  - sh2add: rd = (rs1 << 2) + rs2
  - sh3add: rd = (rs1 << 3) + rs2

The instructions are single cycle and have been implemented using the
adder in the ALU.

Signed-off-by: Michael Munday <mike.munday@lowrisc.org>
2021-11-01 09:58:01 +00:00
Miguel Escobar
d1aff2f1a4 [dv] get ibex dv co-sim to run w questa
This resolves lowRISC/Ibex#1280.
2021-10-25 19:47:07 +02:00
Tom Roberts
cfeef7e864 [doc] Update DIT documentation for unaligned ld/st
Relates to #1414

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2021-10-19 14:06:53 +01:00
Henner Zeller
a345da3bad Change use of blocking assignment to non-blocking inside always_ff
Fixes #1457

Signed-off-by: Henner Zeller <h.zeller@acm.org>
2021-10-16 16:46:34 +01:00
Greg Chadwick
416ecb10df [dv] Add co-simulation environment support to UVM testbench 2021-10-15 11:30:35 +01:00
Greg Chadwick
c03cc91a5d [rtl] RVFI changes and extensions for co-simulation
This adds some new `rvfi_ext` signals that are needed by the
co-simulation environment.

It also fixes/alters `rvfi_trap`. Previously it wouldn't work correctly
in various cases. Now it is fully functional, though it's meaning
includes more trap cases than the RVFI spec strictly includes. It is now
set for any instruction that produces a synchronous trap (everything bar
interrupts).
2021-10-15 11:30:35 +01:00
Greg Chadwick
648fadb34a [dv] Add co-simulation framework 2021-10-15 11:30:35 +01:00
Greg Chadwick
f4e3eefcfb [rtl,dv,doc] Flip priority of fast interrupts
This matches the priority used in Spike.

This also fixes an issue in the DV where the priority of
external/software/timer interrupts wasn't calculated correctly.
2021-10-15 11:30:35 +01:00
Udi
ff6797b26f [ibex/ml] add CSR/mem_error tests to ml_testlist
Signed-off-by: Udi <udij@google.com>
2021-10-07 16:54:46 -07:00
Zachary Snow
0aa02b0f3f [syn] Use read_verilog -defer in yosys_run_synth.tcl
Newer versions of sv2v carry through elaboration system tasks like
$fatal. ibex_top_tracing uses $fatal, but isn't actually used in the
syn_yosys flow. By using -defer, unused modules like ibex_top_tracing
are not elaborated in Yosys.
2021-10-07 12:29:16 +01:00
zeeshanrafique23
873e2281cf remove unused RD in branch insn from tracer 2021-10-01 17:51:18 +01:00
Rupert Swarbrick
305f0a80ea Add missing parameters to ibex_top_tracing 2021-09-27 11:06:04 +01:00
Wojciech Sipak
45f727dfc6 set verible action version to 'main' 2021-09-23 11:55:50 +01:00
Wojciech Sipak
ac8934459b bump verible action version 2021-09-21 16:22:17 +01:00
Greg Chadwick
31b2f6c863 [rtl] Fix retired instruction counters
When the writeback stage is present the retired instruction counter
(minstret) and the retired compressed instruction counter could see an
off by one error when an instruction was in the writeback stage when
reading the counters. With this fix the ID stage observes the
incremented value of the counters when an instruction that would
increment them is in writeback.
2021-09-17 12:28:10 +01:00
Greg Chadwick
75c030b776 [rtl] Factor ID exceptions into instruction kill
Without this an instruction taking an exception will enter WB whilst
simultaneously remaining in ID. This didn't cause any known functional
issues as in the scenarios it occurred the RF write was disabled and the
WB stage eventually gets flushed. However it's still bad behaviour and
could lead to functional issues when RTL changes. It also eases the
co-simulation DV implementation.
2021-09-17 12:28:10 +01:00
Wojciech Sipak
31c5b5eefd [ci] Add GHA workflows to review PRs using Verible
Any activity regarding a Pull Request will trigger
workflows that create automatic code review
using outputs from Verible linter
2021-09-16 12:40:25 +02:00
Greg Chadwick
6cbd7d21c5 [dv] Fix transaction ordering in ibex_mem_intf_monitor
Previously the monitor would emit write transactions the cycle the
request is seen and emit read transactions the cycle the response is
seen. This allowed later write transactions to be emitted before earlier
reads (where a new write transaction is started the cycle a read
response returns).

Now both read and write transactions are emitted when their response is
seen.

In addition the error field from the response is copied into the
transaction.
2021-09-01 09:43:37 +01:00
Greg Chadwick
6815e7b714 [rtl] Implement mvendorid/marchid/mimpid CSRs 2021-08-31 17:39:01 +01:00
Philipp Wagner
b99da424ff [style] Indent package bodies
The style guide requires the package body to be indented with two
spaces.
2021-08-31 15:30:28 +02:00
Philipp Wagner
a25790abf9 [style] Indent module header with two spaces
Both the parameter and the port list in a module header should be
indented with two spaces, according to our style guide.
2021-08-31 15:30:28 +02:00
Philipp Wagner
87bcd13a12 [style] Use logical operators for reset 2021-08-31 15:30:28 +02:00
Philipp Wagner
be27bc8bcf [style] Fix whitespace issues around operators
Our style guide typically require a single whitespace around operators.
2021-08-31 15:30:28 +02:00
Philipp Wagner
b5011ecec6 [style] Format module instantiations in tabular format
The style guide mandates tabular format in port expressions in module
instantiations
(https://github.com/lowRISC/style-guides/blob/master/VerilogCodingStyle.md#module-instantiation).

The style guide also mandates a two-space indentation for ports and
parameters in module instantiations.

Apply the formatting produced by verible-format to match our style
guide.
2021-08-31 15:30:28 +02:00
Tom Roberts
48f11c6733 [rtl] Add bus integrity checking
Extra bits are added alongside read/write data for the instruction and
data buses to facilitate data integrity checking.

Ibex testbench extended to generate the expected bits.

All other top-levels modified to add the new signals (which are mostly
ignored).

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2021-08-26 16:55:26 +01:00
Pirmin Vogel
14115ea3a8 [util] Document minimal requirement for Xilinx Vivado
This is related to lowRISC/Ibex#1425.
2021-08-26 14:42:26 +02:00
Greg Chadwick
3f9022a16d [rtl] Fix mtval for unaligned accesses
Previously the raw incremented address was used which is the calculated
address + 4. This is confusing as it refers to a byte that wouldn't be
accessed (e.g. a lw at 0x8000009e which faults on the access to
0x8000000a0, would report an mtval of 0x8000000a2). With this change
mtval will refer to the first byte on the other half of the word
boundary the unaligned access crosses.
2021-08-13 15:45:29 +01:00
Tom Roberts
65bf9c94f9 [rtl] Add LFSR permutation option
Random constants are sent through the hierarchy as parameters in-line
with other OpenTitan modules.

Further detail on this mechanism can be found in lowrisc/opentitan#2229

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2021-08-10 16:13:02 +01:00
Greg Chadwick
dbc2b6f5dc [rtl/doc] Update ePMP CSR addresses and documentation
mseccfg and mseccfgh have changed their addresses. This updates to the
newly allocated values.

The ePMP specification is now available as a versioned PDF,
documentation is updated to point to that removing the local PDF copy.
2021-08-05 08:01:56 +01:00
Canberk Topal
9af580f6d9 [fpga] Add power analysis scripts to FPGA example
This commit adds power analysis scripts to the Arty A7
example design. They can be used by setting the newly
added `FPGAPowerAnalysis` parameter to 1.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2021-08-03 16:51:16 +01:00
Canberk Topal
1b1247e1de [fpga] Changed to 2p_ram for FPGA top level
1-Port RAM is removed because of both execution and performance
issues. CLKIN1_PERIOD parameter is defined in clkgen module
for Vivado simulations.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2021-08-03 16:51:16 +01:00
Canberk Topal
4b54d79fb4 [sw/fpga] coremark/link.ld update for FPGA sim
This commit updates link.ld RAM length to include max BRAM capacity
for Arty A7-35. It also changes coremark makefile to include a .vmem
output, which then can be used for FPGA implementations.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
2021-08-03 16:51:16 +01:00
Tom Roberts
7c0b1ff160 [rtl] Add register slice on output of shadow core
This decouples the shadow core from any timing paths and so should ease
implementation.

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2021-08-03 13:47:00 +01:00
Tom Roberts
4d729e20e5 [rtl] Buffer cleanup in top-level
A minor change to use the Width parameter of prim_buf. No functional
impact but stops the hierarchy from being cluttered with hundreds of
generate contexts in the top level.

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2021-08-03 13:47:00 +01:00
Dawid Zimonczyk
d44966373e Added cast to enum 2021-07-26 09:48:41 +01:00
Tom Roberts
a1902004f9 [rtl] Add ResetAll parameter
This parameter forces a reset of all registers inside the core. This is
required to guarantee a common starting point for lockstep and thus
prevent spurious lockstep failure alerts.

Another minor change in this commit rearranges the writeback stage
multiplexing to gate incoming lsu write data when not valid. This stops
any X values from the data bus propagating to the register file
signalling (and thus to the lockstep comparison) which would cause the
lockstep alert to be X. It has the side effect of possibly reducing
power consumption in the register file.

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2021-07-22 16:53:27 +01:00
Philipp Wagner
44777dc16d Copy verible-format configuration from OpenTitan
This configuration is the closest we can get to our style guide right
now, so let's go with that.
2021-07-22 13:17:21 +01:00
Philipp Wagner
d003d479ff Update lowrisc_ip to lowRISC/opentitan@da3ac7c4e
Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
da3ac7c4eb23a92194874ad2daf2e5f9e3330572

* [memutil] Allow use without scrambled memories (Philipp Wagner)
* [prim_prince] Fix comment (Philipp Wagner)
* [memutil] Fix width mismatch (Philipp Wagner)
* [prim] Allow disabling SVAs ensuring REQ is held until ACK at run
  time (Pirmin Vogel)
* [prim] Fix typo that caused fifo_async to get stuck (Timothy Chen)
* [prim] Add a missing ROM_CFG_DEFAULT to prim_rom_pkg.sv (Rupert
  Swarbrick)
* [dvsim] Do not assume the build failed if "ERROR" is printed
  (Philipp Wagner)
* [prim_subreg_shadow] Invert meaning of SWACCESS in shadow/stage regs
  (Michael Schaffner)
* [prim_arb_tree/rv_plic_target] Remove TODOs due to a Vivado tool bug
  (Michael Schaffner)
* [primgen] Remove unused import (Philipp Wagner)
* [primgen] Add shebang (Philipp Wagner)
* [primgen] Make primgen "portable" again (Philipp Wagner)
* [dv] Small optimization in memutil (Philipp Wagner)
* [tools/ascent] updated ascent to use the --job-prefix option (Rasmus
  Madsen)
* [otp_ctrl] Remove invalid command error (Michael Schaffner)
* [tlul] Add some missing dependencies (Michael Schaffner)
* [otbn/otp_ctrl] Replicate dmem scrambling keystream (Michael
  Schaffner)
* [adc_ctrl] Various preparation steps for d2 (Timothy Chen)
* [tools/dvsim] Fix some VCS flags (Guillermo Maturana)
* Revert "[prim] Do remove prim_esc.core from the dependencies"
  (Rupert Swarbrick)
* [prim] Remove dependency of prim:esc on a hardware block (Rupert
  Swarbrick)
* [lint] prim_ram_1p_scr verilator lint fixes (Greg Chadwick)
* [dv] Add scrambled_ecc32_mem_area for memutils (Greg Chadwick)
* [dv] Add C++ memory scrambling model (Greg Chadwick)
* [tools/dsim] Fix non-LRM compliant code (Guillermo Maturana)
* [prim] Do remove prim_esc.core from the dependencies (Michael
  Schaffner)
* [dv/dv_utils] Improvement on `max` function (Cindy Chen)
* [alert_handler] Implement reverse ping feature (Michael Schaffner)
* [prim_esc] Split the prims into their own core file (Michael
  Schaffner)
* [dvsim] Fix GUI mode and launcher creation fixes (Srikrishna Iyer)
* [dv/common] Stress_all_with_rand_reset apply reset concurrently
  (Cindy Chen)
* [dv/all] update scoreboard `csr_addrs` accesses (Udi Jonnalagadda)
* [dv/csr_utils] update unmapped_addr calculation (Udi Jonnalagadda)
* [dv] Update intg alert names (Weicai Yang)
* [dv, flash_ctrl] Fix the intr test (Srikrishna Iyer)
* [prim_fifo_async] Fix a width calculation issue in case of Depth = 1
  (Michael Schaffner)
* [dv] Update VCS opt for uvm_hdl_* (Weicai Yang)
* [dv, util] Make poll_for_stop() opt-in (Srikrishna Iyer)
* [dvsim] Separate publish report option [PART1] (Cindy Chen)
* [dv/kmac/sram] reduce iterations of smoke test (Udi Jonnalagadda)
* [dv/stress_all_with_reset] Revert back IPs that uses apply_reset
  (Cindy Chen)
* [dv/edn_reset] Fix apply_reset to concurrently deassert resets
  (Cindy Chen)
* [dv] Update VCS cov merge opts (Srikrishna Iyer)
* [dv] Add TL integrity error test for CSR (Weicai Yang)
* [dv, chip] Remove USB clk driver (Srikrishna Iyer)
* [script/dvsim] Update output folder (Cindy Chen)
* [dv/edn_reset] Update IPs that overrides apply_reset task (Cindy
  Chen)
* [dv/edn_reset] Fix stress_all_with_rand_reset error (Cindy Chen)
* [dv/dv_base_scoreboard] remove duplicated code (Cindy Chen)
* [otbn,dv] Teach otbn_memutil to track expected end address (Rupert
  Swarbrick)
* [dv, dv_utils_pkg] Fix common int typedefs (Srikrishna Iyer)
* [prim_lfsr] Fix spyglass lint warnings (Michael Schaffner)
* [prim_clock_gating] Target 7series Xilinx devices (Philipp Wagner)
* [dv/edn_rst] Add coverage to collect edn reset and dut reset (Cindy
  Chen)
* [otp_ctrl/lc_ctrl] Add LC TAP register to control OTP test
  mechanisms (Michael Schaffner)
* [prim_alert*/prim_esc*] Rework placement of size_only bufs/flops
  (Michael Schaffner)
* [dv] fix a typo in tl_device_access_types_testplan (Weicai Yang)
* [prim_otp] Rework generic model to match new error behavior (Michael
  Schaffner)
* [dv/tlul_common_test] Add a testplan for TLUL integrity check (Cindy
  Chen)
* [dvsim] Allow recursive testplan import (Srikrishna Iyer)
* [primgen] Use verible-verilog-syntax for parsing (Mariusz Glebocki)
* [prim] Break always_comb block to avoid apparent loop (Rupert
  Swarbrick)
* [dvsim] Fix testplan bugs (Srikrishna Iyer)
* [fpv] update secded_gen (Cindy Chen)
* [dv/template] small fixes on index.md format (Cindy Chen)
* [prim_otp] Add a waiver for power signal unused in generic prim
  (Michael Schaffner)
* [simutil_verilator] Improve timeout handling (Rupert Swarbrick)
* [testplans] Rename entries with testpoints (Srikrishna Iyer)
* [dvsim/testplan] Fix the rendered testplan (Srikrishna Iyer)
* [dv/cov] exclude prim_lfsr and prim_prince (Udi Jonnalagadda)

Signed-off-by: Philipp Wagner <phw@lowrisc.org>
2021-07-20 13:44:11 +01:00
Philipp Wagner
270cd91b38 Fix the verible-format CI job
The toplevel core file got renamed, but the experimental verible-format
CI job wasn't updated in sync. Fix that.
2021-07-15 15:47:57 +01:00
Philipp Wagner
ed46a5c9f5 [ci] Update dependencies to match OpenTitan
Use the same dependencies as we use in OpenTitan to make it easier to
diagnose potential issues. No change in behavior expected.
2021-07-14 11:12:09 +01:00
Tobias Wölfel
7032df0d8b [formal] Read Verilog files in Yosys
All files read at this point should be Verilog and not SystemVerilog.
Do not use the SystemVerilog specifier for reading files.
2021-07-14 11:02:46 +01:00
Tobias Wölfel
e1eaa1c804 [formal] Switch to new top level
Use `ibex_top` instead of `ibex_core`.
2021-07-14 11:02:46 +01:00
Rupert Swarbrick
594c2368c3 Get riscv-formal flow working again
No guarantees that this actually does anything useful, but at least
the Makefile works again.
2021-07-14 11:02:46 +01:00
Leon Woestenberg
7506d4da2a [sw] Fix GNU GCC toolchain component substitution for file path case.
This invocation would break:

make -C examples/sw/led/ CC=/opt/lowrisc-toolchain-gcc-rv32imc-20210412-1/bin/riscv32-unknown-elf-gcc

because the "-gcc" occurence inside the directory name would also be replaced.

Fix by first deriving CROSS_COMPILE from CC, then conditionally build other tool file names/paths.

Signed-off-by: Leon Woestenberg <leon@sidebranch.com>
2021-07-12 12:53:53 +01:00
Dawid Zimonczyk
a0582afb4e Avoid premailer 3.9.0 due to API breakage
From OpenTitan pull request #6769
2021-07-12 10:27:29 +01:00
Rupert Swarbrick
90ff7ca6c3 [dv,core_ibex] Only write sim.log once
We're already redirecting stdout to sim.log in run_rtl.py. Specifying
'-l' as well meant that VCS opened sim.log in a separate FD.
Suprisingly enough, this mostly worked, but not always! Just write
once :-)
2021-06-29 14:55:22 +01:00
Greg Chadwick
8ec65d02f8 [dv] Newline tweaks for regression logging 2021-06-29 14:08:01 +01:00
Greg Chadwick
ef545a8bd8 [dv] Improve results reporting
This commits adds a yaml based intermediate format for test results.
compare.py serialises a TestRunResult (a named tuple type) into this
format for each test run it checks. collect_results.py reads them all
back in to produce reports.

Three reports are output:
- regr.log - plain text report much like the one previously produced
- regr_junit.xml, regr_junit_merged.xml - JUnit report format, the
  _merged version batches together multiple tests to appear to be a
  single test case under a test suite. This gives better results with
  Azure's JUnit reporting.
2021-06-25 18:31:21 +01:00
Tom Roberts
6daae3509a [rtl] Modify fetch_en_i behavior
This signal used to be a one shot enable out of reset. We need an option
to pause execution for OpenTitan, so fetch_enable is extended to cover
that.

The signal is already driven low by the testbench at the end of test.
This is moved after the performance counter reads to ensure they can
complete.

Fixes #1105

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2021-06-23 09:16:27 +01:00
Tom Roberts
8a4c1b9e6d [dv/uvm/core] Fix a minor reset issue
Fix the reset polarity in the irq driver (clears irq signals to zero
on reset rather than them being x) plus remove an unused signal.

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2021-06-23 09:16:27 +01:00
Tom Roberts
62aa2bcab8 [dv/uvm/core_ibex] Fix timeout issue in wfi tests
The test loops around waiting for the core to sleep then sending
interrupts to wake it. In some cases, the sequence sends an interrupt
that isn't enabled. It never gets back to try again with a new interrupt
since the test is waiting to see wfi first. This change removes that
requirement since it is redundant anyway (have to see wfi to sleep).

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2021-06-18 17:36:38 +01:00
Rupert Swarbrick
8dd21e491f Append logs for tests to regr.log
Commit 700f29b changed things so that details of the various tests
that ran ended up in separate files. This is nice (and important for
running things in parallel), but isn't massively helpful if you use
regr.log to understand what happened from a CI run!

This patch adds the logs again, splitting them up so that failing
tests come before passing ones (since you usually just care about the
failures).
2021-06-18 15:08:04 +01:00
Tom Roberts
fd4fdc4519 [dv/uvm/core_ibex] Pass ISA from Makefile
This allows run.py to pass ISA options through to Spike. This relates to
the failure in #1369 (test inserts a bitmanip instruction which Spike
interprets as valid but the core treats as invalid depending on config).

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2021-06-18 11:09:39 +01:00
Tom Roberts
1a46c4ede6 [dv/uvm/core_ibex] Update CSR description file
The CSR tests don't currently support multiple configurations
(see #1333). Since the OpenTitan configuration is the only one currently
being run, update this file to pass with that for now.

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2021-06-18 11:09:39 +01:00
Tom Roberts
a8e17579e2 [rtl] Fix decode values for B Operand mux select
With data-independent timing enabled and BranchTargetALU configured,
branches will stall for a cycle causing an illegal value to be decoded
for the B Operand. No functional impact of this, but an assertion fires
so we might as well tie it off properly.

Fixes #1367

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2021-06-18 11:09:39 +01:00
Tom Roberts
f3b163af35 [rtl] Add reset to lockstep delayed inputs
In tests with multiple resets, these signals could hold onto spurious
values through reset (since the clock is also gated) which caused
assertion failures on resumption.

Fixes #1368

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2021-06-18 11:09:39 +01:00
Rupert Swarbrick
2ce6653c65 [core_ibex,dv] Allow running RTL simulations in parallel 2021-06-16 14:37:10 +01:00
Rupert Swarbrick
6a07438cc5 [uvm,core_ibex] Add missing dependency in Makefile
We can't run coverage until the simulation is complete.
2021-06-15 16:48:51 +01:00
Rupert Swarbrick
700f29b7b3 [uvm,core_ibex] Run comparisons in parallel
This patch teaches Make which tests we're actually running (via the
list_tests.py script), which means that we can compare the ISS and RTL
results in parallel rather than serially.

There's a bit of duplicated code (both list_tests.py and sim.py
currently contain the code to get a list of tests and then filter by
Ibex configuration), but this should go away with a later patch that
runs the RTL simulations in parallel in a similar way.

Note: This might seem a little silly: trace comparison takes way less
time than the RTL simulation! The point is that it's probably easier
to work "from the bottom" than to start by parallelising the
simulations themselves.
2021-06-15 16:48:51 +01:00
Rupert Swarbrick
b40f5b8f55 [core_ibex,dv] Name RTL runs by seed, not iteration index
This makes path calculations a bit easier when it comes to loading
stuff up for comparison (allowing us to move more into the Makefile).
Long-term, it might also allow us to change how we track things
entirely, getting rid of the start-seed part of the output directory
structure.
2021-06-15 16:48:51 +01:00
Rupert Swarbrick
d611de9a60 [uvm] Remove --seed argument from sim.py
This isn't used any more: we use --start_seed instead. Remove support
for it, which simplifies the code quite a bit.
2021-06-15 16:48:51 +01:00
Rupert Swarbrick
6c44070bf5 [dv] Fix icache formal tb after recent parameter changes 2021-06-15 15:03:08 +01:00
Dawid Zimonczyk
e716b5add8 Add the Width parameter to prim_buf module
The prim_buf.sv file in Ibex is a manual copy of a file which is
typically auto-generated by FuseSoC/primgen. However, Ibex DV doesn't
yet run FuseSoC, and we provide a pregenerated copy instead. The
auto-generated file and its copy got out of sync. Fix that by adding the
new Width parameter.
2021-06-10 10:00:15 +01:00
Tom Roberts
7071b04a66 [rtl] Fix typo in MCOUNTEREN
DbgTriggerEn has no impact on whether this is an illegal csr op.

Fixes #1379

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2021-06-09 14:59:33 +01:00
Rupert Swarbrick
7ceff60749 Describe where to find a RISC-V toolchain 2021-06-08 15:41:02 +01:00
Dawid Zimonczyk
047e1d6d22 [core_ibex] Update command to work with newer versions of Riviera
These changes match newer versions of Riviera. They work for all
versions >= 2020.04. Ibex itself only compiles successfully with
version 2021.04, so there's no need to maintain command-line
compatibility with older versions.
2021-06-07 10:50:46 +01:00
Rupert Swarbrick
514c096892 [core_ibex,dv] Don't compile coverage model if COV=0 2021-06-03 10:05:11 +01:00
Tom Roberts
93a76b3900 [config] Add an Opentitan configuration
This adds the configuration instantiated in Opentitan and adds
missing prim support to allow the TB to run that configuration.

Resolves #1362

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2021-05-26 16:23:33 +01:00
Rupert Swarbrick
e0b477069e Update lowrisc_ip to lowRISC/opentitan@7117c349d
Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
7117c349d5465b5152d3bb774079013924a3e9ba

* [dv/common] Improve coverage exclusion method (Cindy Chen)
* [prim] Waive unused parameter warnings for an FPGA-specific param
  (Rupert Swarbrick)
* [dpi] Fix indexing bug in ecc32_mem_area (Rupert Swarbrick)
* [dv, xcelium] Dump covergroup report (Srikrishna Iyer)
* [dvsim] Testplanner refactor & covergroup support (Srikrishna Iyer)
* [otp_ctrl] Workaround for generated prim depending on generated prim
  (Michael Schaffner)
* [dpi_memutil] Fix bug in RegisterMemoryArea (Rupert Swarbrick)
* [rom_ctrl/dv] Add skeleton testbench (Tom Roberts)
* [dvsim/verilator] Remove FUSESOC_IGNORE (Michael Schaffner)
* [checklists] Update all checklists for consistency (Srikrishna Iyer)
* [dv] Add integrity generation to backdoor memory loading (Greg
  Chadwick)
* [prim_secded] Add C reference models for Hsiao encode (Greg
  Chadwick)
* [rtl/prim_async_fifo] Fix async fifo typo when depth <= 2 (Cindy
  Chen)
* [dv/unr] Fix unr clk rst ports (Cindy Chen)
* [pads] - added AnalogIn1 pads for OTP supply (Arnon Sharlin)
* [dv/common] add ECC support to mem_bkdr_if (Udi Jonnalagadda)

Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
2021-05-25 15:14:52 +01:00
Philipp Wagner
71a8763553 [doc] Fix building with sphinxcontrib-wavedrom 3.x
sphinxcontrib-wavedrom 3.x uses wavedrom-cli by default, which can't be
installed on ReadTheDocs. Use the wavedrompy library again instead.
2021-05-11 18:28:56 +01:00
Philipp Wagner
252dde8225 [doc] Require Sphinx 3 until wavedrom is compatible
Sphinx 4 removed some deprecated functionality that was still used by
sphinxcontrib-wavedrom. Use Sphinx 3 until wavedrom releases an updated
version.
2021-05-11 18:28:56 +01:00
Philipp Wagner
c7cb958f0d Update lowrisc_ip to lowRISC/opentitan@ca950b43a
Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
ca950b43a0e9ef5013b8e2e5de765bc34fb59b74

Two updates to the Ibex code were required:
* Adjust the prim_secded port names to match the changes in
  OpenTitan.
* Replace `has_ral` in `ibex_icache_env_cfg.sv` and
  `ibex_icache_base_test.sv` with its newer equivalent, matching
  https://github.com/lowRISC/opentitan/pull/5932 and the additional
  updates in https://github.com/lowRISC/opentitan/pull/5951.

Upstream changes include:
* [prim_secded] Use _i/_o suffix for port names (Philipp Wagner)
* [tl,dv] Allow bits to be set in responses regardless of mask (Rupert
  Swarbrick)
* [push_pull agent] Driver code refactor (Srikrishna Iyer)
* [dv/dvsim] Group failures per test in buckets (Guillermo Maturana)
* [dv/uvmdvgen] Flag error for paths in block name (Guillermo
  Maturana)
* [prim_fifo_async] Style fixes (Philipp Wagner)
* Remove non-ASCII characters from SV code and meson.build (Rupert
  Swarbrick)
* [dv/spi_device] Fix spi_device_csr_wr_with_rand_reset timeout issue
  (Cindy Chen)
* [otp] Update to match latest foundry wrapper (Timothy Chen)
* [flash] update to match latest foundry wrapper (Timothy Chen)
* [top] Latest ast integration (Timothy Chen)
* [lint] Strengthen Verible lint check to 100-character lines (Rupert
  Swarbrick)
* [ prim ] Suppress unneeded assertion when clearing prim_packer_fifo
  (Martin Lueker-Boden)
* [dv/otp_ctrl] Add coverage exclusions (Cindy Chen)
* [dv/dvsim] Add "^Error:" as a run fail pattern. (Guillermo Maturana)
* [dvsim] Fix column bug in DV summary report (Srikrishna Iyer)
* [dvsim] Fix testplan test counts (Srikrishna Iyer)
* [dvsim] Fix lowRISC/opentitan#6061 (Srikrishna Iyer)
* [prim_clock_div] Update waiver (Michael Schaffner)
* [fpv] dvsim script error (Cindy Chen)
* [prim_otp] Update interface (Michael Schaffner)
* [dvsim] update edacloudlauncher imports (Udi Jonnalagadda)
* [dv/doc] Minor fix on dv_doc (Cindy Chen)
* [dvsim] Scheduler updates - max_parallel, max_poll (Srikrishna Iyer)
* [dvsim] Set `Deploy.job_name` more robustly (Srikrishna Iyer)
* [prim] Make SECDED prim generation deterministic (Rupert Swarbrick)
* [tool, xcel] Support dumpping the array of struct in shm/vcd (Tung
  Hoang)
* [dv/otp_ctrl] OTP_CTRL DV doc (Cindy Chen)
* [dv/dv_macros] Fix DV_PRINT_ARR_CONTENTS (Guillermo Maturana)
* [prim_pad_attr/prim_flop_en] Add waiver files (Michael Schaffner)
* [prim_usb_diff] Minor lint fix (Michael Schaffner)
* [prim_clock_div] Update waiver file (Michael Schaffner)
* [top] change prim_generic usage into prim (Timothy Chen)
* [formal/conn] Support dvsim to publish regression result summary
  (Cindy Chen)
* Add formatting changes from allow list (Rafal Kapuscik)
* [prim] Add generic and Xilinx-specific xor2 primitives (Pirmin
  Vogel)
* [prim] Add Width parameter to buffer primitives (Pirmin Vogel)
* [prim] Add generic and Xilinx-specific enable-FF primitives (Pirmin
  Vogel)
* [prim] Remove temporary workaround in parameter list related to
  primgen (Pirmin Vogel)
* [dv/dvsim] Provides more context on some failures. (Guillermo
  Maturana)
* [dvsim] Fix local run error. (Eunchan Kim)
* [dv] Support multi-ral (part 4) (Weicai Yang)
* [dv/dvsim] Adds failure bucketizer for triage. (Guillermo Maturana)
* [lint/docs] Update ascentlint dvsim command in readme (Michael
  Schaffner)
* [top] Various top level lint fixes (Timothy Chen)
* [pinmux/padring] Wire up the pad attribute WARL behavior modules
  (Michael Schaffner)
* [dv] Fix tl_error failure (Weicai Yang)
* [pinout] Update flash test mode and voltage signals/pads (Michael
  Schaffner)
* [pad_wrapper] Extend the generic and Xilinx pad wrapper models
  (Michael Schaffner)
* [dv] Update scb for all blocks (Weicai Yang)
* [dv] Support multi-ral (part 3) (Weicai Yang)
* [prim_arbiter,lint] Tell Verilator to split variables for scheduling
  (Rupert Swarbrick)
* [prim] Fix lint warnings, replace inline AscentLint waivers (Pirmin
  Vogel)
* [dvsim] Scratch root default to $REPO_TOP/scratch (Srikrishna Iyer)
* [dv] Update `process_tl_access` args for all blocks (Weicai Yang)
* [dv] Support multi-ral (part 2) (Weicai Yang)
* [formal] Clean up some formal warnings (Cindy Chen)
* [topgen] Rework pinmux datastructure and templatize tops (Michael
  Schaffner)
* [otp_ctrl] Several small lint fixes (Michael Schaffner)
* [prim_fifo_async] Make async FIFO output zero when empty (Noah
  Moroze)
* [flash] Improve flash ECC handling based on transasction attribute
  (Timothy Chen)
* [dv] Remove toggle coverage excl for a_user/d_user (Weicai Yang)
* [dvsim] Fix remaining comments  from lowRISC/opentitan#5876
  (Srikrishna Iyer)
* [dv] Support multi-ral (part 1) (Weicai Yang)

Signed-off-by: Philipp Wagner <phw@lowrisc.org>
2021-05-11 18:28:56 +01:00
Greg Chadwick
8ef06de73d [rtl] Fix lint issues 2021-04-30 10:28:30 +01:00
Rupert Swarbrick
53926b5fb9 [rtl] Break long lines in Ibex tracer
These go over the 100 character limit in our style guide (and will
cause Verible lint warnings when vendored into OpenTitan).
2021-04-22 12:30:47 +01:00
Rupert Swarbrick
5c60b094fe [rtl] Break long lines in icache
No functional change.
2021-04-21 17:03:23 +01:00
Tom Roberts
7ac218f3ae [rtl] Wire scan_rst_ni through ibex_top_tracing
Better to have the tracing top consistent with the non-tracing top.

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2021-04-21 12:41:24 +01:00
Timothy Chen
33cca5e127 [ibex] Add reset bypass controls
Signed-off-by: Timothy Chen <timothytim@google.com>
2021-04-21 09:14:12 +01:00
Timothy Chen
6c04708303 [ibex] Fix buffer instantiations
Signed-off-by: Timothy Chen <timothytim@google.com>
2021-04-20 09:25:10 +01:00
Dawid Zimonczyk
d8bf475da7 add cast to enum
Signed-off-by: Dawid Zimonczyk <dawidz@aldec.com.pl>
2021-04-19 11:32:37 +01:00
Michael Schaffner
0e7117fbec [lockstep] Introduce optimization barrier around lockstep Ibex
Certain synthesis tools like DC are very smart at optimizing away redundant logic.
Hence, we have to insert an optimization barrier at the IOs of the lockstep Ibex.
This is achieved by manually buffering each bit using prim_buf.
Our Xilinx and DC synthesis flows make sure that these buffers cannot be optimized
away using keep attributes (Vivado) and size_only constraints (DC).

Signed-off-by: Michael Schaffner <msf@google.com>
2021-04-16 09:26:41 +01:00
Greg Chadwick
1b59c67b50 [dv] Remove MISA from csr_description.yaml
The value of `misa` will change depending on whether M or B are enabled.
The presence and read values of other CSRs may also depend upon the Ibex
configuration. A fix is required to allow riscv_csr_test to deal with
different CSR descriptions for different Ibex configurations. For now
just comment out `misa` from the descriptions file to enable
riscv_csr_test to run on a wider range of configurations.
2021-04-14 12:13:12 +01:00
Philipp Wagner
48a886a25f Update README to match design
Since this part of the README was written the design moved on. Let's
update it. This update follows the text we have at
https://ibex-core.readthedocs.io/en/latest/index.html.
2021-04-14 11:59:10 +01:00
Tom Roberts
07c04bc3f1 Fix a couple of synthesis bugs
1. Missing prim_assert in ibex_top.sv (more of an rtl bug but only found
in running synthesis scripts)
2. Write out the pre-mapped netlist before mapping latches

Relates to #1335

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2021-04-14 11:49:48 +01:00
Greg Chadwick
69e715b287 [dv] Improvements to functional coverage
This adds more instruction categories and corrects various issues in the
categorization code. Further cross coverage has been added including
illegal bins to remove bins that cannot occur.

The concept of using SVAs with cross coverage has been dropped. The
systemverilog scheduling model makes the concept unworkable.
2021-04-14 08:55:16 +01:00
Greg Chadwick
ed5f12c99e [rtl] Fix RF read enables for illegal instruction/fetch error
The read enables should only be asserted where an actual RF read will
occur. Where there is an illegal instruction or a fetch error the raw
decoder signals might still be asserted but should be squashed before
they become the true enable signals.
2021-04-12 16:08:25 +01:00
Greg Chadwick
3b578a6f9b [rtl] illegal_csr_write shouldn't factor in csr_op_en_i
csr_op_en_i signals whether or not the CSR access will actually happen,
but whether an illegal write is being can be determined with just the
address and access type. This change will improve timing and avoid
circular logic that might occur from the use of the illegal_csr_write
signal.
2021-04-12 16:08:25 +01:00
Greg Chadwick
5504876110 [dv] Add known failure detection to riscv_debug_ebreakmu_test 2021-04-09 18:42:12 +01:00
Greg Chadwick
25cd6600c6 [dv] Don't kill regression on sim error
When the simulator terminates with an error code that is reported as a
test failure and the regression continues. A new check for a plain
'Error' message is required to catch simulator reported errors that
don't become a UVM_FATAL or UVM_ERROR message (e.g. hitting an illegal
coverage bin). Previously any such simulation error would kill the whole
regression.
2021-04-08 09:59:17 +01:00
Tom Roberts
a88f5eb912 [rtl] Add dual core lockstep option
Note that the alert output is tied off for now until an option is added
to reset all registers (otherwise there will be X propagation).

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2021-04-07 12:07:38 +01:00
Tom Roberts
6a3200929b [rtl] Add a new top level plus wiring
This commit creates a new top level wrapping the core, register file and
icache RAMs. The tracing top level is also renamed to ibex_top_tracing
to match. This new top level is intended to enable a dual core lockstep
implementation of Ibex.

There are no functional changes in this commit, only wiring.

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2021-04-07 12:07:38 +01:00
Tom Roberts
b106001d82 [rtl/icache] Move various parameters into the pkg
No functional change. These parameters are effectively fixed. Moving
them to the pkg eases top-level wiring of RAM signals.

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2021-04-07 12:07:38 +01:00
Pirmin Vogel
a799a92e5e [rtl] Add SVA to ensure valid_i in compressed decoder is known
This signal is used to gate several assertions related to
unknown/invalid selector signals. We want to be sure to catch any X
values entering the compressed decoder and ultimately ID.

This is related to lowRISC/Ibex#540.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2021-04-06 18:22:55 +02:00
Rupert Swarbrick
8d37af2751 Update google_riscv-dv to google/riscv-dv@59dcd8c
Update code from upstream repository https://github.com/google/riscv-
dv to revision 59dcd8c813484eb6dcca67e7e36089fe772b9cc8

* Update scripts for Metrics CI regression:  bug fixes, change ISS to
  spike in CI regression (Aimee Sutton)
* Add illegal and load store instruction (aneels3)
* Avoid generating hint instruction when RV32C is turned off
  (google/riscv-dv#787) (taoliug)
* Fix illegal opcode issue in the cov_test (google/riscv-dv#786)
  (taoliug)
* [questa] Remove -access=rwc from vlog command line arguments (Rupert
  Swarbrick)
* [ci] temporarily disable CI flow (Udi Jonnalagadda)
* fix issue with rcs for num_of_harts (aneels3)
* fix multi-hart label issue (aneels3)
* add multi_hart test (ishita71)
* Fix minor issues (aneels3)
* Add riscv_signature_pkg (aneels3)
* add gen_signature_handshake (ishita71)
* Add gen_interrupt_vector_table (aneels3)
* Remove the unnecessary lines (Anil Sharma)
* fix issue with riscv_rand_instr_test (aneels3)
* Add multiprocessing code block (aneels3)

Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
2021-04-06 14:13:39 +01:00
Rupert Swarbrick
026db55c89 [util] Document required VCS version
We don't actually run anything that checks this at the moment, but at
least we now have it written down somewhere.
2021-04-06 14:13:22 +01:00
Rupert Swarbrick
5d7b7c1e6f [util] Manually "vendor" latest check_tool_requirements.py
This comes from OpenTitan and can't currently be vendored in
properly (because it doesn't live in its own directory). We'll sort
that out eventually but, for now, copy in some recent changes by hand.
2021-04-06 14:13:22 +01:00
Rupert Swarbrick
c7f44557d2 Fix initialisation in ibex_icache_env_cfg.sv 2021-04-06 12:50:03 +01:00
Rupert Swarbrick
7d61def943 Update lowrisc_ip to lowRISC/opentitan@f29a0f7a7
Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
f29a0f7a7115e03fba734b1c00691c253aceb07e. The list of OpenTitan
changes that are merged in appears at the bottom of the commit.

There are some manual changes needed to adapt the code to work with
these changes.

 - The ICache monitors need some extra types to adapt to the (rather
   odd) data model that the OpenTitan dv_lib code now uses, where a
   monitor needs to know an agent's associated sequence type.

 - Verilator simulations now use MemArea slightly differently

OpenTitan changes:

* [dv] Allow monitor items to have different types from sequence items
  (Rupert Swarbrick)
* [dvsim] Fix primary_cfg handling (Srikrishna Iyer)
* [dvsim] Deal with non unicode chars in log files (Srikrishna Iyer)
* [dvsim] Added common build fail patterns (Srikrishna Iyer)
* [dvsim] Minot cleanup to the lint flow (Srikrishna Iyer)
* [dvsim] Minor cleanups to to formal flow (Srikrishna Iyer)
* [dvsim] Fixes to UNR and cov analysis flows (Srikrishna Iyer)
* [dvsim] Very minor cleanup of Deploy class (Srikrishna Iyer)
* [dvsim] LsfLauncher report early errors as F (Srikrishna Iyer)
* [dvsim] Minor fix in clean_odirs function (Srikrishna Iyer)
* [chip dv] Set +sw_images as comma-separated list (Srikrishna Iyer)
* [flash_ctrl] Split tl intefaces for flash_ctrl and prim_flash_cfg
  (Timothy Chen)
* [keymgr] Fix input value checks (Timothy Chen)
* [formal/script] Update generic formal flow naming from `fpv` to
  `formal` (Cindy Chen)
* [top, prim] Address wmask and data width mismatch issue (Timothy
  Chen)
* [dvsim] Add GUI mode for running simulations (Srikrishna Iyer)
* [dv] Fix reg backdoor (Weicai Yang)
* [dpi] Make an "ECC32" flavour of MemArea (Rupert Swarbrick)
* [uvmdvgen] Fix has_interrupts in env_cfg (Cindy Chen)
* [dvsim] Keep dependencies list (Srikrishna Iyer)
* [prim_prince] Reverse the k0||k1 mapping to match with the paper
  (Michael Schaffner)
* [dvsim] Fix printing of last 10 lines (Srikrishna Iyer)
* [primgen] Minor fix to enable types with underscores (Michael
  Schaffner)
* [dvsim] Prevent command echo suppression (Srikrishna Iyer)
* [dvsim] Spot fixes for LSF and internal launcher (Srikrishna Iyer)
* [sva] csr assertion dependency update (Cindy Chen)
* [memutil] Change DpiMemUtil so that it no longer owns MemAreas
  (Rupert Swarbrick)
* [memutil] Factor out MemArea as a class (Rupert Swarbrick)
* [prim] Split out PRESENT and PRINCE support from prim:all (Rupert
  Swarbrick)
* [fpv/otp_ctrl] Disable assertions due to lc_esc_en (Cindy Chen)
* [prim_prince] Annotate some arrays to avoid UNOPTFLAT warnings
  (Rupert Swarbrick)
* [top] Hook up latest ast ports and complete a few other integration
  (Timothy Chen)
* Eliminate `#pragma once` in favor of include guards (Chris Frantz)
* [sw,dv] Update headers to pass fix_include_guards.py (Alex Bradbury)
* [xbar/dv] Fix assertion error due to short reset (Weicai Yang)
* [sram] Add memory initialization (Timothy Chen)
* [uvmdvgen] Update links in checklist template (Philipp Wagner)
* [dv/uvmdvgen] Add comment for testplan (Cindy Chen)
* [dv/top_earlgrey] chip csr_aliasing timeout (Cindy Chen)
* [dvsim] Cosmetic updates to launcher methods (Srikrishna Iyer)
* [dv] Update csr_wr to support field write (Weicai Yang)
* [dv/common] Fix regression warnings (Cindy Chen)
* [dv] Get blocks with multiple device interfaces working with chip DV
  (Rupert Swarbrick)
* [doc] Use relative links in Hjson-related shortcodes (Philipp
  Wagner)
* [dvsim] minor enhancement to clean_odir (Srikrishna Iyer)
* [dvsim] Statically display jobs' status (Srikrishna Iyer)
* [dvsim] Do weighted scheduling of jobs (Srikrishna Iyer)
* [dvsim] Schedule jobs by dependency (Srikrishna Iyer)
* [dv] Xcelium UNR typo (Srikrishna Iyer)
* [dvsim] Implement LsfLauncher (Srikrishna Iyer)
* [dv/chip] solve same_csr_outstanding_timeout (Cindy Chen)
* [dv] make dv_base_agent work for high-level agent (Weicai Yang)
* [tools/dv] added UNR flow for xcelium (Rasmus Madsen)
* [prim] Split prim:subreg out of prim:all (Rupert Swarbrick)
* [prim] Split prim_alert_* out of prim:all (Rupert Swarbrick)
* [prim] Split out fifos into a prim_fifo core (Rupert Swarbrick)
* [prim] Split out arbiters into a prim_arbiter core (Rupert
  Swarbrick)
* [prim] Make prim:flop_2sync depend on prim:flop (Rupert Swarbrick)

Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
2021-04-06 12:49:51 +01:00
Rupert Swarbrick
b04c1850b6 Avoid encumbered name in ibex_icache_testplan.hjson
With this change, we no longer use "sanity" in non-vendored code.
2021-04-05 15:38:56 +01:00
Philipp Wagner
69ae65c713 [dv] Remove semicolon
It's Python.
2021-03-22 18:28:18 +00:00
Philipp Wagner
907a3f6ec7 [dv] Fix name of ELF file in report
The name of the ELF file was wrong in the regr.log file, it should be
e.g. `riscv_debug_ebreakmu_test_9.o`, not
`riscv_debug_ebreakmu_test.9.o`.
2021-03-22 18:28:18 +00:00
Greg Chadwick
c1e287e13b [dv] Fix riscv_nested_interrupt_test
This broke due to changes in IRQ sequences. It relies on the inner
interrupt being an NMI. This alters the test to use the specific NMI
sequence.
2021-03-22 17:35:35 +00:00
Greg Chadwick
2c3c474cc0 [dv] Fix riscv_irq_in_debug_mode_test
Test wasn't handling a case where the IRQ remains raised after DRET so
IRQ should be handled.
2021-03-22 17:35:35 +00:00
Greg Chadwick
f0a4042d6a [dv] Allow full IRQ randomisation
`no_nmi` in irq_raise_seq and irq_raise_single_seq would always cause an
NMI to be raised if it was set. This alters it to have the same
behaviour as `no_fast`. Setting `no_nmi` prevents an NMI from being
produced by the sequences, leaving it clears allows an NMI to be
produced but doesn't force it. This allows tests which can deal with NMI
along with other IRQs to fully randomise IRQs.

A new `irq_raise_nmi_seq` is provided for tests that specifically want
an NMI.
2021-03-22 17:35:35 +00:00
Greg Chadwick
5711d4fc15 [dv] Small core_ibex_test_lib refactor
Splits out checking for IRQ handling and waiting for specific xRET to
seperate tasks to allow more flexible checking.
2021-03-22 17:35:35 +00:00
Greg Chadwick
4b43afa533 [doc] Fix table rendering for mseccfg 2021-03-19 10:51:49 +00:00
Greg Chadwick
357b40828f [rtl] Add MSECCFGH CSR
This is the top 32 bits of MSECCFG. It currently has no specified bits
so reads as 0 and ignores writes.
2021-03-19 10:51:49 +00:00
Greg Chadwick
d78e0d9a06 [rtl] Hard wire dcsr.stepie to 0
This indicates interrupts do not occur in single step mode.

Fixes #1279
2021-03-17 15:59:47 +00:00
Greg Chadwick
50be975226 [rtl] Fix hardware breakpoints and exceptions interaction
This change will cause the ID stage to stall if there is a potential
debug mode entry until instructions in both ID and WB have completed.
This fixes an issue with incorrect behaviour around hardware breakpoints
and exceptions that could cause exception entry to be missed, hardware
breakpoints to be triggered incorrectly or missed entirely.

In addition single step control logic is altered to work correctly with
the new debug mode entry behaviour.
2021-03-17 15:59:47 +00:00
Yusef Karim
62b1a30c7d Fix spacing for bullet points to appear
Bullet points now appear properly for the last paragraph under the Data Independent Timing section.
2021-03-16 07:49:18 +00:00
Udi Jonnalagadda
6576247a1e [ci/ibex] temporarily remove pmp_full_random_test
this test is arbitrarily failing in regressions on a Spike timeout,
temporarily remove this to avoid blocking.

@udinator to fix this in the near future.

Signed-off-by: Udi Jonnalagadda <udij@google.com>
2021-03-14 20:11:34 +00:00
Tom Roberts
42827fc9cd [rtl/icache] Switch ECC granularity to 32bits
Changes the ECC granularity in the data RAMs from 64bit to 32bit. This
is to align with an upcoming change in bus ECC. Relates to
lowRISC/opentitan#5450

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2021-03-12 17:27:52 +00:00
Tom Roberts
2c75c2b2ec Update lowrisc_ip to lowRISC/opentitan@1ae03937f
Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
1ae03937f0bb4b146bb6e736bccb4821bfda556b

* [prim/fifo_async] Add assertions on pointers (Tom Roberts)
* [prim/fifo_async] Add support for Depth <= 2 (Tom Roberts)
* [prim/fifo_async] Code tidy-up (Tom Roberts)
* [top / ast] Continued ast integration (Timothy Chen)
* [dvsim] Use bash when running make underneath (Srikrishna Iyer)
* [prim] Increase maximum width for prim_util_memload to 312 (Greg
  Chadwick)
* [sram_ctrl] Fix potential back-to-back partial write bug (Michael
  Schaffner)
* [dvsim] Fix for lowRISC/opentitan#5527 (Srikrishna Iyer)
* [lint] Waive Verilator UNUSED warnings for packages (Rupert
  Swarbrick)
* [uvmdvgen] Update DV doc path and terminology (Srikrishna Iyer)
* [clkmgr] Fix dft issues (Timothy Chen)
* [util] add `dec` types to prim_secded_pkg (Udi Jonnalagadda)
* [util] minor updates to secded_gen (Udi Jonnalagadda)
* [lint] Fix a bunch of lint warnings related to long lines (>100
  chars) (Michael Schaffner)
* [dv] Update common intr_test seq (Weicai Yang)
* [util] Slight refactor of secded_gen.py (Timothy Chen)
* [tlul] Add memory transmission integrity checks (Timothy Chen)
* [dvsim] Move clean_odirs to `util.py` (Srikrishna Iyer)
* [dvsim] Split Deploy into Deploy and Launcher (Srikrishna Iyer)
* [dvsim] Add utils.TS_FORMAT* vars (Srikrishna Iyer)
* [dv/lock_reg] Update IPs to adopt the lock_reg changes (Cindy Chen)
* [dv/enable_regs] Support enable registers have more than one field
  (Cindy Chen)
* [dv/base_reg] use m_field instead of accessing field (Cindy Chen)
* [dv/sram] add SRAM scrambling model for DV (Udi Jonnalagadda)
* [dv/tools] Updated Coverage flow for xcelium (Rasmus Madsen)

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2021-03-12 16:15:22 +00:00
Greg Chadwick
50f09b71a9 [rtl] Fix lint issues 2021-03-11 16:10:32 +00:00
Udi Jonnalagadda
70c3702421 [dv/ibex] filter out tests on a per-config basis
This PR adds functionality to filter out tests during regressions for a
particular config.

e.g. if a full regression is kicked off using the `small` config, we
don't want to attempt to run any PMP and bitmanip tests as the RTL
parameter-set will not support it.

To do this, a new YAML field called `rtl_params` is added to relevant
test entries, to indicate what parameters (if any) are required to be
able to run the particular test, along with the required value of said
parameters.

`sim.py` will then parse this field (if it exists), and using
information from `ibex_configs.yaml` pertaining to the current config,
will remove tests from being run on-the-fly.

This also gives us the convenient side effect of not having to re-run
instruction generation if there is a parameter/config mismatch, we can
just rerun the RTL compilation and simulation stages safely.

Signed-off-by: Udi Jonnalagadda <udij@google.com>
2021-03-10 19:00:52 +00:00
Tom Roberts
6d9e1aca8a [rtl] Minor lint fix in ibex_core.sv
Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2021-03-04 12:32:04 +00:00
Vladimir Rozic
5363499190 [rtl] Add MCOUNTEREN CSR
This commit adds the MCOUNTEREN CSR as required by the RISC-V spec.
The register is defined as WARL. At the moment, Ibex doesn't enable U-mode
access to the performance montiors. Consequently, writes to the register are
ignored and it reads as zero which is okay according to the spec.

This resolves lowRISC/Ibex#1278 .
2021-03-04 12:00:59 +00:00
Tom Roberts
5ef18f0b78 Update lowrisc_ip to lowRISC/opentitan@6cc5c164b
NOTE this commit includes various changes to align the Ibex repo with
changes upstream in OT!

Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
6cc5c164ba96d339f06cbcede0d17d2c96ce3c05

* [dv] Add SV_FCOV_SVA back (Srikrishna Iyer)
* [DV][FCOV] Minor updates to lowRISC/opentitan#5414 (Srikrishna Iyer)
* [dvsim] Fix --cov + --build|run-only bugs (Srikrishna Iyer)
* [lint] Waivers for rv_core_ibex lint (Greg Chadwick)
* [lint] Allow one branch in unique case (Greg Chadwick)
* [dv/macros] Add fcov macros from Ibex (Tom Roberts)
* [dvsim/verilator] Fix pre-build cmd failure when hw/foundry is
  absent (Michael Schaffner)
* [verilator/otp] Enable OTP preloading in verilator (Michael
  Schaffner)
* [dvsim] Use builtins wherever possible (Srikrishna Iyer)
* [prim] Avoid an apparent combinatorial loop in prim_secded_*_dec.sv
  (Rupert Swarbrick)
* [dv/shadow_reg] Fix aes shadow reg error (Cindy Chen)
* [lint] Remove comportable waivers from non-comportable IPs (Michael
  Schaffner)
* [dv] Fix VPD dumping (Srikrishna Iyer)
* [prim] Waive Verilator lint warning in prim_lfsr.sv (Pirmin Vogel)
* [dv] Hard code various dv connections until full hook-up (Timothy
  Chen)
* [tlul] Add payload checker and generator on device side only.
  (Timothy Chen)
* [prim_packer] Silence verilator width warnings (Rupert Swarbrick)
* [dvsim] lint fixes to FlowCfg (Srikrishna Iyer)
* [dvsim] Minor improvement to FlowCfg (Srikrishna Iyer)
* [dvsim] lint fixes to Scheduler (Srikrishna Iyer)
* [dvsim] Very small update to Timer. (Srikrishna Iyer)
* [lint] Update Verible lint parser to detect Verible syntax errors
  (Michael Schaffner)
* [lint] Spot errors in the lint flow that we weren't expecting
  (Rupert Swarbrick)
* [lint] Remove Fusesoc-related message waivers (Michael Schaffner)
* [top / rst] Adjust the way rst_ni is used in design (Timothy Chen)
* [dvsim/syn] Update parsing script and area reporting (Michael
  Schaffner)
* [dv/regwen] update REGWEN conventions (Cindy Chen)
* [dv/tools] Bug fix to common.tcl tb_top section. (Eitan Shapira)
* [dv] Fix stress_all with reset (Weicai Yang)
* [prim] Add a new slow to fast clock synchronizer (Tom Roberts)
* [prim] Minor lint fix (Tom Roberts)
* [tlul] Add instruction type to tlul (Timothy Chen)
* [top] Ast updates (Timothy Chen)
* [lint] Increase threshold for max number of bits in an array
  (Michael Schaffner)
* [dv] add dv_base_reg_pkg to env_pkg template (Udi Jonnalagadda)
* [dv/verilator] Ignore foundry dir (Srikrishna Iyer)
* [dv] Provide license diagnostic info for VCS (Srikrishna Iyer)
* [prim/otp_ctrl] Fix ECC correctable bug in generic OTP wrapper
  (Michael Schaffner)
* [prim_ram_1p_scr] Make parity and diffusion layer settings more
  flexible (Michael Schaffner)
* [prim] fix flash sram adapter use for configuration space (Timothy
  Chen)
* [dv] Make CSR fields randomizable by default. (Srikrishna Iyer)
* [dv/prim] minor updates (Udi Jonnalagadda)
* [top] Minor lint fixes (Timothy Chen)
* [prim_flash] Flash port alignments (Michael Schaffner)
* [prim_util_pkg] Fix DC warning in _clog2() (Philipp Wagner)
* Add missing full_o output signal of prim_fifo_sync (Philipp Wagner)
* [dv] Gracefully kill simulation (Srikrishna Iyer)
* [dv] Minor updates to prim tbs (Srikrishna Iyer)
* [flash / top] Minor edits based on reviews (Timothy Chen)
* [flash_ctrl / top] Various functional updates to flash (Timothy
  Chen)
* [dv/otp_ctrl] regwen sequence (Cindy Chen)
* [prim] Wire up full_o sync fifo output port in prim_sram_arbiter
  (Rupert Swarbrick)
* [dvsim] Generate FUSESOC_IGNORE at top of scratch root (Rupert
  Swarbrick)
* Revert "[lint] Remove Fusesoc-related message waivers" (Michael
  Schaffner)
* Revert "[lint] Rename tool warnings to flow warnings and reduce
  their severity" (Michael Schaffner)
* Revert "[lint] Provision syntax error filter for Verible lint"
  (Michael Schaffner)
* [prim] Update fifo behavior during reset (Timothy Chen)
* [dv] Move cip related macros to cip_macros (Weicai Yang)
* [dv/dvsim] Fix when next_item does not have dependency (Cindy Chen)
* [prim_packer_fifo/rtl] reset to disable output controls (Mark
  Branstad)
* [lint] Provision syntax error filter for Verible lint (Michael
  Schaffner)
* [lint] Rename tool warnings to flow warnings and reduce their
  severity (Michael Schaffner)
* [lint] Remove Fusesoc-related message waivers (Michael Schaffner)
* [dv/dvsim] collect coverage in scheduler (Cindy Chen)
* [dvsim] Fix Syn class (Michael Schaffner)
* [dv/shadow_reg] move get_shadow_regs function to dv_base_ral_block
  (Cindy Chen)
* [lc_ctrl] Switch ECC to standard Hamming code (Michael Schaffner)
* [prim_ram_*p_adv/prim_otp] Add option to use standard Hamming ECC
  (Michael Schaffner)
* [secded_gen] Fix template bug that results in lint error (Michael
  Schaffner)
* [prim/fifo_async] Disallow non-power-of-two depths (Tom Roberts)
* [dv/alert] update shadow_reg alert naming in DV (Cindy Chen)
* [dv] Align csr::reset_asserted to actual reset pin (Weicai Yang)
* [prim_secded*_fpv] Generate FPV testbenches (Michael Schaffner)
* [prim_secded*] Regenerate all SECDED primitives (Michael Schaffner)
* [secded_gen] Add ability to generate FPV TB's and correct Hamming
  code (Michael Schaffner)
* [dvsim] Run cov_merge / cov_report as part of the main set of jobs
  (Rupert Swarbrick)
* [dvsim] Get rid of Deploy's static dispatch_counter (Rupert
  Swarbrick)
* [dvsim] Make the scheduling logic per-target (Rupert Swarbrick)
* [dvsim] Remove "status" from Deploy items (Rupert Swarbrick)
* [dvsim] Create jobs with dependencies instead of sub-jobs (Rupert
  Swarbrick)
* [dvsim] Simplify SimCfg._gen_results (Rupert Swarbrick)
* [dvsim] Factor deploy method out of Deploy object (Rupert Swarbrick)
* [dvsim] Move time tracking into its own class in Deploy.py (Rupert
  Swarbrick)
* [dvsim] Fix printing of Deploy objects (Rupert Swarbrick)
* [dv] make dv_macros.svh more UVM_agnostic (Srikrishna Iyer)
* [dv/prim] reduce smoke test iterations (Udi Jonnalagadda)
* [dv/hmac] reduce runtime for sha_vector test in smoke regression
  (Cindy Chen)
* [DV] Enable cov comp creation iff cov is enabled (Srikrishna Iyer)
* [prim_alert] Fix xcelium compile error (Cindy Chen)
* [alert_rxtx/fpv] Update alert sender FPV testbenches (Michael
  Schaffner)
* [alert_rxtx] Add option to latch fatal alert in alert sender
  (Michael Schaffner)
* [kmac/dv] KMAC smoke test (Udi Jonnalagadda)
* [dv/str_utils_pkg] add byte_to_str function (Udi Jonnalagadda)
* [prim] - Add new prim_lc_dec (Jacob Levy)
* [util] Move design-related helper scripts to util/design (Michael
  Schaffner)
* [prim-flash] Add missing deps (Srikrishna Iyer)
* [dv] Define SIMULATION during DV sims (Michael Schaffner)
* [dv] Fix a typo in tb.sv.tpl (Weicai Yang)
* Cleanup: Remove executable bits from source files (Philipp Wagner)
* [dv] Use separate clock for EDN (Weicai Yang)
* [dv] Add macro DV_EDN_IF_CONNECT to simplify EDN connect in TB
  (Weicai Yang)
* [dv] Fix typo in clk_rst_if (Weicai Yang)

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2021-03-04 09:56:36 +00:00
Tom Roberts
6e617c4097 [vendor] Remove fcov patch from dv_utils
This code is now upstream in the source repository.
Also amend dv_utils patch to apply cleanly.

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2021-03-04 09:56:36 +00:00
Udi Jonnalagadda
eaa7bb6eb4 [dv/ibex] update how coverage is merged
Currently, the `cov` step in the DV Makefile will only merge coverage
databases emitted directly from Ibex simulations, and will not pick up
any coverage databases generated by the RISCV-DV functional coverage
flow.

This PR updates the `gen_cov()` function in `sim.py` to recursively
search for any generated coverage directories and then merges them all.

Resultant coverage reports include all code coverage, Ibex functional
coverage, and RISCV-DV functional coverage.

The coverage-related targets in the Makefile have also been renamed to
improve clarity.

Signed-off-by: Udi Jonnalagadda <udij@google.com>
2021-03-03 01:01:28 -08:00
Rupert Swarbrick
82d0654c97 Don't automatically generate disassembly in the example Makefile
Anyone who needs to disassemble their generated ELF can probably just
call objdump directly and the precise set of flags have already
confused at least one potential contributor[1].

We're keeping the canned objdump command for "engineers that know
where to look" because some have said they find it useful. Run it with
e.g.

    make -C examples/sw/simple_system/hello_test disassemble

[1] https://github.com/lowRISC/ibex/issues/1263
2021-03-02 09:21:09 +00:00
Greg Chadwick
faa1e98a6e [dv] Fix bug in sim.py and type in testlist 2021-03-01 10:19:55 +00:00
Tom Roberts
ee8d1051bb [rtl] Add crash dump outputs
Relates to lowrisc/opentitan#4618

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2021-03-01 10:12:04 +00:00
Greg Chadwick
3e7720e403 [rtl] Lint fixes for Ascent lint issues 2021-03-01 09:52:57 +00:00
Greg Chadwick
c3bd4fa7ef [rtl] Remove paths between dmem and imem signals
Prior to this change Ibex had multiple feedthrough paths from the data
memory interface to the instruction memory interface. This existed
because Ibex would hold off doing a instruction fetch for a jump or
branch if there was a outstanding memory request. It would wait for the
response to be available so either the jump or branch would occur or an
exception was taken.

With this change the branch or jump will speculatively begin the
instruction fetch whilst there is an outstanding memory request. Should
an exception result from the memory request the fetch will be discarded
and the exception taken as normal.

An alternative fix would not factor the data error response
(data_err_i) directly into the controller logic for branches and jumps.
With this option new stall cycles would be introduced anywhere a branch
or jump immediately follows a memory instruction which would have an
adverse impact on performance.
2021-02-26 17:32:34 +00:00
Rupert Swarbrick
6ebc6bcb9f [simple_system] Fix type for mhpmcounter_get
It's probably clearer if this 64-bit counter is treated as a uint64_t,
not an int64_t (the code using it downstream expects non-negative
values).
2021-02-25 15:34:02 +00:00
Greg Chadwick
99b8f61223 [rtl] Debug mode controller changes
* `if` in `DBG_TAKEN_IF` is needless as the conditions it checks will be
  true if controller enters `DBG_TAKEN_IF` state

* flop `enter_debug_mode` so `FLUSH` state looks at what
  `enter_debug_mode` was when it was seen in `DECODE` state rather than
  what it has become. In particular the controller could enter `FLUSH`
  on the basis of performing a WFI then divert down the debug control
  path due to a new debug request being raised. In this instance it is
  preferable for the WFI to complete entering `SLEEP` before the debug
  request wakes the core back up.
2021-02-18 17:34:17 +00:00
Philipp Wagner
65287f7d7b Fix deprecated sphinx html_context usage in conf.py
We were using the old html_context which has been deprecated
for a while. This PR switches to html_css_files instead.
See sphinx-doc/sphinx#8885 for more information.
2021-02-18 12:06:38 +00:00
Greg Chadwick
7cee76bf05 [dv] Reorder checks in sim.py
The UVM log should be checked for failures before attempting to process
the core trace log. A simulation failure could mean the trace log
doesn't exist and is is preferable to report the simulation error from
the log rather than trace not found as a failure cause.
2021-02-15 17:52:35 +00:00
Greg Chadwick
0cb2afffa9 Update google_riscv-dv to google/riscv-dv@0b62525
Update code from upstream repository https://github.com/google/riscv-
dv to revision 0b625258549e733082c12e5dc749f05aefb07d5a

* Add a knob to use rounding mode from the instruction (google/riscv-
  dv#767) (taoliug)
* Add rounding mode support for floating point arithmetic instructions
  (google/riscv-dv#766) (taoliug)
* Fix syntax issue (google/riscv-dv#765) (taoliug)
* Add riscv_amo_instr (aneels3)
* convert string to enum type (ishita71)
* Remove unintended errors in the coverage flow (google/riscv-dv#757)
  (taoliug)
* Fix c_test handling in the YAML testlist (google/riscv-dv#756)
  (taoliug)
* Add support for new Spike trace format (google/riscv-dv#755) (Daniel
  Bates)
* Fix google/riscv-dv#751 for floating point coverage (Weicai Yang)
* Fix issues with implemented TODO's (aneels3)
* fix randomize_gpr (aneels3)
* Add file riscv_b_instr.py (ishita71)
* add std_randomize todo (pvipsyash)
* Add todo for floating_point test (ShraddhaDevaiya)
* Add scripts to integrate with Metrics regression platform (Aimee
  Sutton)

Includes a fix to dv/uvm/core_ibex/sim.py to use `asm_test` rather than
`asm_tests` due to changes in RISCV-DV

Signed-off-by: Greg Chadwick <gac@lowrisc.org>
2021-02-04 08:37:00 +00:00
Greg Chadwick
860b085e25 [dv] Add RISCV-DV patch to fix csr_test
The assembly for the  CSR test is generated by a script from RISCV-DV. A
.org directive is required to put the generated code at the correct
start address for the instantiated Ibex core.
2021-02-04 08:37:00 +00:00
Greg Chadwick
aa3067cf43 [dv] Fix MISA CSR reset value
MISA reset value now indicates B extension support
2021-02-04 08:37:00 +00:00
Greg Chadwick
d8b2cb0a68 [dv] Fix issues with timeout on WFI
riscv_interrupt_instr_test and riscv_debug_instr_test aim to produce
interrupt and debug requests once per unique instruction they've seen.
One exception to this is WFI instructions, as these always require an
interrupt or debug request to wake the core. This fixes two timeout
issues with WFI instructions.

1. The return value of `decode_instruction` is used to determine whether
   an instruction should have an interrupt or debug request generated
   for it. For WFI this must always happen or the test will hang.

2. Before calling check_stimulus in a test the testbench waits for 50
   clock cycles. For the riscv_interrupt_instr_test and
   riscv_debug_instr_test if a WFI is executed during these 50 cycles
   the test will hang. This adds a check to see if the core has gone to
   sleep in those tests and if so sends interrupt/debug stimulus to wake
   it up.
2021-02-04 08:37:00 +00:00
Greg Chadwick
e749d8fe3d [dv] Add ePMP support to cs_registers testbench 2021-02-01 12:22:49 +00:00
Greg Chadwick
c8c3c55071 [dv] Fix race condition in cs_registers testbench
The `driver_tick` DPI call drove inputs directly but was being scheduled
in an undefined order with other always_ff blocks.  This results in a
race condition where some always_ff blocks see old inputs and others see
new in the same clock tick. Instead use values from `driver_tick` to
perform NBA updates and avoid the race condition.
2021-02-01 12:22:49 +00:00
Greg Chadwick
8defdc4d6c [doc] Add ePMP information 2021-02-01 12:22:49 +00:00
Greg Chadwick
374e05ec65 [rtl] Add ePMP support to Ibex
This implemements the RISC-V Trusted Execution Environment (TEE) working
group proposal 'PMP Enhancements for memory access and execution
prevention on Machine mode'. The proposal is awaiting ratification and
is not expected to change beyond minor tweaks before it becomes part of
the RISC-V priviledged specification.

No seperate 'classic' PMP only mode is provided as different PMP
behaviour only occurs when the MSECCFG CSR is written to. This CSR is
introduced by the proposal and has no specified function in the current
RISC-V priviledged specification.
2021-02-01 12:22:49 +00:00
Greg Chadwick
373212ee89 [dv] Improve sim.py error reporting
* Handle missing log files with error messages rather than terminating
  on unhandled exceptions
* Output potential failure causes from sim log file into regression log
* Alter per test output to make it clearer what line corresponds to what
  test
* Only output [PASSED] or [FAILED] a single time per test
* Don't output [PASSED] where sim log is good but ISS comparison is not
2021-01-29 16:58:26 +00:00
Rupert Swarbrick
f291d1beb9 [dv] Rename stored copy of run phase
In UVM 1.2, at least, uvm_component (a base class of
core_ibex_base_test) still has a method called run(). Ironically, this
has been renamed to "run_phase" to avoid conflicting with user names,
but the old-style phase names still exist at the moment.

Rename our copy of the phase object to cur_run_phase, which doesn't
conflict. Also, set it back to null at the end of the run_phase()
task. We shouldn't ever use it afterwards, and it's probably a good
idea to explode with a null object error if we do.
2021-01-29 08:14:51 +00:00
Rupert Swarbrick
8d43b854ab [dv] Be explicit about the target priv_mode in wait_ret test
The previous code contained

    wait (dut_vif.dut_cb.priv_mode === select_mode())

and VCS warns that this wait block will only trigger on changes to
explicit arguments. That is, if the in_nested_trap field changes, so
the return value of the select_mode() method would change to match
priv_mode, the wait statement won't finish.

This patch explicitly stores a snapshot of the value of select_mode()
just before the wait line. I think this is the intended behaviour, and
will no longer trigger warnings from VCS.
2021-01-29 08:14:21 +00:00
Rupert Swarbrick
6ab3e4a993 [dv] Wire up alerts to dut probe interface
This silences VCS warnings about the DUT having missing port
connections. It doesn't add any actual testing for these signals.

The patch also re-orders the signals to match the order in
ibex_core_tracing.sv, to make it easier to spot what's going on by
eye.
2021-01-27 17:04:12 +00:00
Rupert Swarbrick
e318cd8dd5 Specify boot address in hex to avoid 32-bit signed overflow
I wonder whether we could use some form of quoting to allow
"32'h8000_0000" to get through Riviera's TCL, but we don't have any
way to test, so let's go with the easy option.
2021-01-27 14:30:58 +00:00
Rupert Swarbrick
05b9f51403 [syn] Fail a bit more gracefully if something goes wrong 2021-01-27 10:43:28 +00:00
Rupert Swarbrick
b295f07b2d [doc] Update dependency descriptions for Spike/OVPsim
This should match what's going on a bit more accurately. The link to
OVPsim now points at the (free of cost) commercial tool: riscv-ovpsim
doesn't support the bitmanip specification that we're using at the
moment.
2021-01-25 17:41:40 +00:00
Greg Chadwick
77b9e9c78c [syn] Add missing include path
With the introduction of dv_fcov_macros.svh we need to add it as an
included path for sv2v.
2021-01-25 17:37:18 +00:00
Rupert Swarbrick
fbe4e9da08 [verilator] Remove clock gating waiver and add extra warning
The -Wwarn-IMPERFECTSCH flag is suggested in the Verilator docs (to
help spot if we get a clock gating hint wrong). The waiver is no
longer needed because we now add the relevant hint in the
RTL (vendored in prim_generic_clock_gating.sv from OpenTitan).
2021-01-25 10:25:26 +00:00
Rupert Swarbrick
07b65abbd0 [rtl] Fix lint "fix" with DbgTriggerEn
The previous change was wrong: it was trying to define a signal with
DbgHwNumLen bits that contained DbgHwBreakNum - 1. Unfortunately, '1
is *not* the same as a zero-extended version of 1'b1.
2021-01-22 15:26:27 +00:00
Rupert Swarbrick
7624481972 [rtl] Fix lint warning when DbgTriggerEn parameter is set
DbgHwBreakNum - 1 is an int, so generates a warning if it's assigned
to tselect_d (of type logic [DbgHwNumLen-1:0]). Explicitly generate
the value we need as a localparam.

This lint warning doesn't appear by default in the Ibex repository,
because DbgTriggerEn is disabled. It does, however, appear in
OpenTitan because we enable it there.
2021-01-22 13:01:07 +00:00
Greg Chadwick
794d865f56 [dv] Ibex uarch functional coverage
This adds a framework for gathering functional coverage for Ibex
microarchitecture along with a selection of initial coverpoints.
2021-01-22 11:12:08 +00:00
Greg Chadwick
d717e2385e Update lowrisc_ip to lowRISC/opentitan@7aa5c2b89
Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
7aa5c2b890fa5d4e3d0b43e0f5e561cb7743a01d

* [flash] updated flash wrapper md file (Dana Agur)
* [flash / top / ast] functional updates (Timothy Chen)
* [ralgen, dv] Associated changes to ralgen (Srikrishna Iyer)
* [prim_sync_reqack_data] Fix SVA checking DST-to-SRC data stability
  (Pirmin Vogel)
* [dv/keymgr] temp disable alert checking in scb (Cindy Chen)
* [dvsim] Fix a wrong path in print message (Weicai Yang)
* [prim] Teach verilator to recognise a clock gate (Rupert Swarbrick)
* [prim_lc_sync] Add AsyncOn parameter to enable/disable the sync
  flops (Michael Schaffner)
* [clkmgr / top] Add clock divider step down to support lc_ctrl
  transition (Timothy Chen)
* [prim_sync_reqack] Use NRZ protocol internally for increased
  throughput (Pirmin Vogel)
* [prim] correct interface documentation. (Timothy Chen)
* [flash_ctrl] Add tlul configuration interface to prim_flash (Timothy
  Chen)
* [flash_ctrl] Use hamming code for 64b ECC (Timothy Chen)
* [prim/edn] Fix lint error (width mismatch) (Eunchan Kim)

Signed-off-by: Greg Chadwick <gac@lowrisc.org>
2021-01-22 11:12:08 +00:00
Greg Chadwick
698cf93183 [dv] Patch for fcov macros in dv_utils 2021-01-22 11:12:08 +00:00
3222 changed files with 887002 additions and 26324 deletions

View file

@ -0,0 +1,102 @@
name: Ibex RTL CI Steps
description: Ibex RTL CI Steps
inputs:
ibex_config:
required: true
description: Ibex configuration to run CI for
runs:
using: "composite"
steps:
# ibex_config.py will exit with error code 1 on any error which will cause
# the CI to fail if there's an issue with the configuration file or an
# incorrect configuration name being used
- name: Test and display fusesoc config for ${{ inputs.ibex_config }}
shell: bash
run: |
IBEX_CONFIG_OPTS=`./util/ibex_config.py ${{ inputs.ibex_config }} fusesoc_opts`
echo $IBEX_CONFIG_OPTS
echo "IBEX_CONFIG_OPTS=$IBEX_CONFIG_OPTS" >> $GITHUB_ENV
- name: Lint Verilog source files with Verilator for ${{ inputs.ibex_config }}
shell: bash
run: |
set +e
fusesoc --cores-root . run --target=lint --tool=verilator lowrisc:ibex:ibex_top_tracing $IBEX_CONFIG_OPTS
if [ $? != 0 ]; then
echo -n "::error::"
echo "Verilog lint failed. Run 'fusesoc --cores-root . run --target=lint --tool=verilator lowrisc:ibex:ibex_top_tracing $IBEX_CONFIG_OPTS' to check and fix all errors."
exit 1
fi
- name: Lint Verilog source files with Verible Verilog Lint for ${{ inputs.ibex_config }}
shell: bash
run: |
set +e
fusesoc --cores-root . run --target=lint --tool=veriblelint lowrisc:ibex:ibex_top_tracing $IBEX_CONFIG_OPTS
if [ $? != 0 ]; then
echo -n "::error::"
echo "Verilog lint failed. Run 'fusesoc --cores-root . run --target=lint --tool=veriblelint lowrisc:ibex:ibex_top_tracing $IBEX_CONFIG_OPTS' to check and fix all errors."
exit 1
fi
- name: Run RISC-V Compliance test for Ibex RV32IMC for ${{ inputs.ibex_config }}
shell: bash
run: |
set +e
# Build simulation model of Ibex
fusesoc --cores-root=. run --target=sim --setup --build lowrisc:ibex:ibex_riscv_compliance $IBEX_CONFIG_OPTS
if [ $? != 0 ]; then
echo -n "::error::"
echo "Unable to build Verilator model of Ibex for compliance testing."
exit 1
fi
# Run compliance test suite
export TARGET_SIM=$PWD/build/lowrisc_ibex_ibex_riscv_compliance_0.1/sim-verilator/Vibex_riscv_compliance
export RISCV_PREFIX=riscv32-unknown-elf-
export RISCV_TARGET=ibex
export RISCV_DEVICE=rv32imc
fail=0
for isa in rv32i rv32im rv32imc rv32Zicsr rv32Zifencei; do
make -C build/riscv-compliance RISCV_ISA=$isa 2>&1 | tee run.log
if [ ${PIPESTATUS[0]} != 0 ]; then
echo -n "::error::"
echo "The RISC-V compliance test suite failed for $isa"
# There's no easy way to get the test results in machine-readable
# form to properly exclude known-failing tests. Going with an
# approximate solution for now.
if [ $isa == rv32i ] && grep -q 'FAIL: 4/48' run.log; then
echo -n "::error::"
echo "Expected failure for rv32i, see lowrisc/ibex#100 more more information."
else
fail=1
fi
fi
done
exit $fail
- name: Run Verilator co-sim tests for for ${{ inputs.ibex_config }}
shell: bash
run: |
source ci/setup-cosim.sh
# Build simple system with co-simulation
fusesoc --cores-root=. run --target=sim --setup --build lowrisc:ibex:ibex_simple_system_cosim $IBEX_CONFIG_OPTS
# Run directed tests against simple system co-simulation
./ci/run-cosim-test.sh --skip-pass-check CoreMark examples/sw/benchmarks/coremark/coremark.elf
if ./util/ibex_config.py ${{ inputs.ibex_config }} query_fields PMPEnable | grep -q 'PMPEnable=1'; then
./ci/run-cosim-test.sh --skip-pass-check pmp_smoke examples/sw/simple_system/pmp_smoke_test/pmp_smoke_test.elf
else
echo "PMP not supported on ${{ inputs.ibex_config }}, skipping pmp_smoke_test"
fi
if ./util/ibex_config.py ${{ inputs.ibex_config }} query_fields SecureIbex | grep -q 'SecureIbex=1'; then
./ci/run-cosim-test.sh dit_test examples/sw/simple_system/dit_test/dit_test.elf
./ci/run-cosim-test.sh dummy_instr_test examples/sw/simple_system/dummy_instr_test/dummy_instr_test.elf
else
echo "Security features not supported on ${{ inputs.ibex_config }}, skipping security feature tests"
fi

151
.github/workflows/ci.yml vendored Normal file
View file

@ -0,0 +1,151 @@
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
# GitHub Actions CI build configuration
name: Ibex CI
on:
push:
tags:
- "*"
merge_group:
types:
- checks_requested
pull_request:
branches:
- "*"
# Note: All tests run as part of one job to avoid copying intermediate build
# artifacts around (e.g. Verilator and toolchain builds). Once more builds/tests
# are added, we need to re-evaluate this decision to parallelize jobs and
# improve end-to-end CI times.
jobs:
lint_dv:
name: Run quality checks (Lint and DV)
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
# Fetch all history so that we can run git diff on the base branch
fetch-depth: 0
- name: Setup environment variables
run: |
# Filter out empty lines or comments
grep -v '^\(#\|$\)' ci/vars.env >> $GITHUB_ENV
- name: Install build dependencies
run: |
ci/install-build-deps.sh
- name: Display environment
run: |
echo $PATH
python3 --version
echo -n "fusesoc "
fusesoc --version
verilator --version
riscv32-unknown-elf-gcc --version
verible-verilog-lint --version
# Verible format is experimental so only run on default config for now,
# will eventually become part of the per-config CI
- name: Format all source code with Verible format (experimental)
run: |
set +e
fusesoc --cores-root . run --no-export --target=format --tool=veribleformat lowrisc:ibex:ibex_top_tracing
if [ $? != 0 ]; then
echo -n "::error::"
echo "Verilog format with Verible failed. Run 'fusesoc --cores-root . run --no-export --target=format --tool=veribleformat lowrisc:ibex:ibex_top_tracing' to check and fix all errors."
echo "This flow is currently experimental and failures can be ignored."
fi
# Show diff of what verilog_format would have changed, and then revert.
git diff --no-pager
git reset --hard HEAD
continue-on-error: true
- name: Use clang-format to check C/C++ coding style
# This check is not idempotent, but checks changes to a base branch.
# Run it only on pull requests.
if: github.event_name == 'pull_request'
run: |
set +e
fork_origin=${{ github.event.pull_request.base.sha }}
changed_files=$(git diff --name-only $fork_origin | grep -v '^vendor' | grep -E '\.(cpp|cc|c|h)$')
test -z "$changed_files" || git diff -U0 $fork_origin $changed_files | clang-format-diff -p1 | tee clang-format-output
if [ -s clang-format-output ]; then
echo -n "::error::"
echo "C/C++ lint failed. Use 'git clang-format' with appropriate options to reformat the changed code."
exit 1
fi
- name: Build and run CSR testbench with Verilator
run: |
# Build and run CSR testbench, chosen Ibex configuration does not effect
# this so doesn't need to be part of per-config CI
fusesoc --cores-root=. run --target=sim --tool=verilator lowrisc:ibex:tb_cs_registers
- name: Get RISC-V Compliance test suite
run: |
cd build
git clone https://github.com/riscv/riscv-compliance.git
cd riscv-compliance
git checkout "$RISCV_COMPLIANCE_GIT_VERSION"
- name: Build tests for verilator co-simulation
run: |
# Build CoreMark without performance counter dump for co-simulation testing
make -C ./examples/sw/benchmarks/coremark SUPPRESS_PCOUNT_DUMP=1
make -C ./examples/sw/simple_system/pmp_smoke_test
make -C ./examples/sw/simple_system/dit_test
make -C ./examples/sw/simple_system/dummy_instr_test
# Run Ibex RTL CI per supported configuration
- name: Run Ibex RTL CI for small configuration
uses: ./.github/actions/ibex-rtl-ci-steps
with:
ibex_config: small
- name: Run Ibex RTL CI for opentitan configuration
uses: ./.github/actions/ibex-rtl-ci-steps
with:
ibex_config: opentitan
- name: Run Ibex RTL CI for maxperf configuration
uses: ./.github/actions/ibex-rtl-ci-steps
with:
ibex_config: maxperf
- name: Run Ibex RTL CI for maxperf-pmp-bmbalanced configuration
uses: ./.github/actions/ibex-rtl-ci-steps
with:
ibex_config: maxperf-pmp-bmbalanced
- name: Run Ibex RTL CI for maxperf-pmp-bmfull configuration
uses: ./.github/actions/ibex-rtl-ci-steps
with:
ibex_config: maxperf-pmp-bmfull
- name: Run Ibex RTL CI for experimental-branch-predictor configuration
uses: ./.github/actions/ibex-rtl-ci-steps
with:
ibex_config: experimental-branch-predictor
# Run lint on simple system
- name: Run Verilator lint on simple system
run: |
set +e
fusesoc --cores-root . run --target=lint --tool=verilator lowrisc:ibex:ibex_simple_system
if [ $? != 0 ]; then
echo -n "::error::"
echo "Verilog lint with Verilator failed. Run 'fusesoc --cores-root . run --target=lint --tool=verilator lowrisc:ibex:ibex_simple_system' to check and fix all errors."
exit 1
fi
- name: Run Verible lint on simple system
run: |
set +e
fusesoc --cores-root . run --target=lint --tool=veriblelint lowrisc:ibex:ibex_simple_system
if [ $? != 0 ]; then
echo -n "::error::"
echo "Verilog lint with Verible failed. Run 'fusesoc --cores-root . run --target=lint --tool=veriblelint lowrisc:ibex:ibex_simple_system' to check and fix all errors."
exit 1
fi

38
.github/workflows/pr_lint.yml vendored Normal file
View file

@ -0,0 +1,38 @@
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
# GitHub Action to run Verible linting on pull requests and add review comments.
#
# See https://github.com/chipsalliance/verible-linter-action.
name: pr-lint
# Triggers when there is any activity on a pull request, e.g. opened, updated.
on:
merge_group:
types:
- checks_requested
pull_request:
branches:
- "*"
jobs:
verible-lint:
runs-on: ubuntu-latest
env:
verible_config: "vendor/lowrisc_ip/lint/tools/veriblelint/lowrisc-styleguide.rules.verible_lint"
steps:
- uses: actions/checkout@v4
- name: Display Verible config
run: |
echo "::group::Verible config"
cat "$verible_config"
echo "::endgroup::"
- name: Run Verible linter action
uses: chipsalliance/verible-linter-action@main
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reviewdog_reporter: github-pr-check
suggest_fixes: "false"
config_file: ${{ env.verible_config }}

38
.github/workflows/private-ci.yml vendored Normal file
View file

@ -0,0 +1,38 @@
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
name: Ibex Private CI
on:
push:
tags:
- "*"
merge_group:
types:
- checks_requested
pull_request_target:
branches:
- "*"
permissions:
contents: write # For repository dispatch
jobs:
trigger:
name: Trigger Private CI
runs-on: ubuntu-latest
steps:
- name: Trigger Private CI
run: |
PAYLOAD='"target":"${{ github.repository_owner }}/lowrisc-private-ci/master/ibex-private-ci.yml","sha":"${{ github.event.pull_request.head.sha || github.sha }}"'
if ${{ github.event_name == 'pull_request_target' }}; then
PAYLOAD+=',"pull_request":${{ github.event.pull_request.number }}'
fi
curl -fL \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/dispatches \
-d '{"event_type":"cross-repo-ci","client_payload":{'"$PAYLOAD"'}}'

13
.gitignore vendored
View file

@ -18,19 +18,6 @@ ibex_simple_system_pcount.csv
# Python cache files
__pycache__
# This is generated by VCS when running DV simulations with WAVE=1.
/dv/uvm/core_ibex/ucli.key
# This is generated by UVM when running simulations and doesn't seem
# to be something you can disable.
/dv/uvm/core_ibex/tr_db.log
# This is the default output directory in dv/uvm/core_ibex and
# contains auto-generated files from building and running tests.
/dv/uvm/core_ibex/out
# This is generated by Questa tool when running DV simulations
modelsim.ini
# This is generated by Xcelium when running DV simulations, even with WAVE=0
/dv/uvm/core_ibex/waves.shm

20
.readthedocs.yml Normal file
View file

@ -0,0 +1,20 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
# Required
version: 2
# Set the version of Python and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.11"
# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: doc/conf.py
python:
install:
- requirements: doc/requirements.txt

View file

@ -5,7 +5,7 @@
# Rules for svlint, a SystemVerilog linter commonly used in editors.
# The configuration matches the lowRISC SystemVerilog style guide at
# https://github.com/lowRISC/style-guides/blob/master/VerilogCodingStyle.md.
# See https://github.com/dalance/svlint/blob/master/RULES.md for a list of rules.
# See https://github.com/dalance/svlint/blob/master/MANUAL.md for a list of rules.
[option]
exclude_paths = ["build.*", "sw/.*", ".sv.tpl$", "vendor/.*"]

View file

@ -1,84 +0,0 @@
package:
name: ibex
dependencies:
tech_cells_generic: { git: "git@github.com:pulp-platform/tech_cells_generic.git", version: 0.2.2 }
sources:
- target: synthesis
files:
- rtl/ibex_register_file_latch.sv
- target: xilinx
files:
- rtl/ibex_register_file_fpga.sv
- target: not(rtl)
include_dirs:
- rtl
- vendor/lowrisc_ip/ip/prim/rtl
files:
# Source files grouped in levels. Files in level 0 have no dependencies on files in this
# package. Files in level 1 only depend on files in level 0, files in level 2 on files in
# levels 1 and 0, etc. Files within a level are ordered alphabetically.
# Level 0
- rtl/ibex_pkg.sv
- vendor/lowrisc_ip/ip/prim/rtl/prim_assert.sv
# Level 1
- rtl/ibex_alu.sv
- rtl/ibex_compressed_decoder.sv
- rtl/ibex_controller.sv
- rtl/ibex_counter.sv
- rtl/ibex_csr.sv
- rtl/ibex_decoder.sv
- rtl/ibex_fetch_fifo.sv
- rtl/ibex_load_store_unit.sv
- rtl/ibex_multdiv_fast.sv
- rtl/ibex_multdiv_slow.sv
- rtl/ibex_pmp.sv
- rtl/ibex_wb_stage.sv
# Level 2
- rtl/ibex_cs_registers.sv
- rtl/ibex_ex_block.sv
- rtl/ibex_id_stage.sv
- rtl/ibex_prefetch_buffer.sv
# Level 3
- rtl/ibex_if_stage.sv
# Level 4
- rtl/ibex_core.sv
- target: rtl
include_dirs:
- rtl
- vendor/lowrisc_ip/ip/prim/rtl
defines:
RVFI: true
files:
# Level 0
- rtl/ibex_pkg.sv
- rtl/ibex_register_file_ff.sv
- vendor/lowrisc_ip/ip/prim/rtl/prim_assert.sv
# Level 1
- rtl/ibex_alu.sv
- rtl/ibex_compressed_decoder.sv
- rtl/ibex_controller.sv
- rtl/ibex_counter.sv
- rtl/ibex_csr.sv
- rtl/ibex_decoder.sv
- rtl/ibex_fetch_fifo.sv
- rtl/ibex_load_store_unit.sv
- rtl/ibex_multdiv_fast.sv
- rtl/ibex_multdiv_slow.sv
- rtl/ibex_pmp.sv
- rtl/ibex_tracer_pkg.sv
- rtl/ibex_wb_stage.sv
# Level 2
- rtl/ibex_cs_registers.sv
- rtl/ibex_ex_block.sv
- rtl/ibex_id_stage.sv
- rtl/ibex_prefetch_buffer.sv
- rtl/ibex_tracer.sv
# Level 3
- rtl/ibex_if_stage.sv
# Level 4
- rtl/ibex_core.sv
# Level 5
- rtl/ibex_core_tracing.sv

View file

@ -13,34 +13,68 @@ in the form of source code, bug reports, testing, marketing, or any other form,
please feel free to open a pull request to get your name added to this file.
- Alex Bradbury
- Andreas Kurth
- Andreas Traber
- Antonio Pullini
- Bryan Cantrill
- Canberk Topal
- Cathal Minnock
- Daniel Mlynek
- Dawid Zimonczyk
- Eunchan Kim
- Felix Yan
- Flavian Solt
- Florian Zaruba
- Francesco Conti
- Gary Guo
- Germain Haugou
- Greg Chadwick
- Harry Callahan
- Hai Hoang Dang
- Henner Zeller
- Hodjat Asghari Esfeden
- Igor Loi
- Ioannis Karageorgos
- Markus Wegmann
- Ivan Ribeiro
- Karol Gugala
- Leon Woestenberg
- Luís Marques
- Marek Pikuła
- Markus Wegmann
- Marno van der Maas
- Matthias Baer
- Mehmet Burak Aykenar
- Michael Gautschi
- Michael Gielda
- Michael Munday
- Michael Platzer
- Michael Schaffner
- Nils Graf
- Noah Huesser
- Noam Gallmann
- Pasquale Davide Schiavone
- Paul O'Keeffe
- Philipp Wagner
- Pirmin Vogel
- Prajwala Puttappa
- Rahul Behl
- Rhys Thomas
- Renzo Andri
- Robert Schilling
- Rupert Swarbick
- Sam Elliott
- Scott Johnson
- Stefan Mach
- Stefan Tauner
- Stefan Wallentowitz
- Sven Stucki
- Tao Liu
- Tobias Wölfel
- Tom Roberts
- Tudor Timi
- Udi Jonnalagadda
- Vladimir Rozic
- Yuichi Sugiyama
- Yusef Karim
- Zachary Snow
- Zeeshan Rafique

10
NOTICE Normal file
View file

@ -0,0 +1,10 @@
The Ibex Project
Copyright 2024 lowRISC contributors.
This product includes hardware and/or software developed as part of the
Ibex(R) (https://github.com/lowRISC/ibex) and OpenTitan(R) projects.
Ibex was originally developed by the PULP team at ETH Zurich and University of
Bologna under the name zero-riscy. Ibex verification, performance enhancement
and security hardening have been supported by the OpenTitan project
(https://www.opentitan.org).

View file

@ -1,17 +1,23 @@
[![Build Status](https://dev.azure.com/lowrisc/ibex/_apis/build/status/lowRISC.ibex?branchName=master)](https://dev.azure.com/lowrisc/ibex/_build/latest?definitionId=3&branchName=master)
[Ibex OpenTitan configuration Nightly Regression](https://ibex.reports.lowrisc.org/opentitan/latest/report.html)
<a href="https://ibex.reports.lowrisc.org/opentitan/latest/report.html">
<img src="https://ibex.reports.lowrisc.org/opentitan/latest/summary.svg">
</a>
# Ibex RISC-V Core
Ibex is a small and efficient, 32-bit, in-order RISC-V core with a 2-stage pipeline that implements
the RV32IMC instruction set architecture.
Ibex is a production-quality open source 32-bit RISC-V CPU core written in
SystemVerilog. The CPU core is heavily parametrizable and well suited for
embedded control applications. Ibex is being extensively verified and has
seen multiple tape-outs. Ibex supports the Integer (I) or Embedded (E),
Integer Multiplication and Division (M), Compressed (C), and B (Bit
Manipulation) extensions.
<p align="center"><img src="doc/03_reference/images/blockdiagram.svg" width="650"></p>
This core was initially developed as part of the [PULP platform](https://www.pulp-platform.org)
under the name "Zero-riscy" \[[1](https://doi.org/10.1109/PATMOS.2017.8106976)\], and has been
Ibex was initially developed as part of the [PULP platform](https://www.pulp-platform.org)
under the name ["Zero-riscy"](https://doi.org/10.1109/PATMOS.2017.8106976), and has been
contributed to [lowRISC](https://www.lowrisc.org) who maintains it and develops it further. It is
under active development, with further code cleanups, feature additions, and test and verification
planned for the future.
under active development.
## Configuration
@ -23,17 +29,16 @@ These are configurations on which lowRISC is focusing for performance evaluation
| Config | "micro" | "small" | "maxperf" | "maxperf-pmp-bmfull" |
| ------ | ------- | --------| ----------| -------------------- |
| Features | RV32EC | RV32IMC, 3 cycle mult | RV32IMC, 1 cycle mult, Branch target ALU, Writeback stage | RV32IMCB, 1 cycle mult, Branch target ALU, Writeback stage, 16 PMP regions |
| Performance (CoreMark/MHz) | 0.904 | 2.47 | 3.13 | 3.05 |
| Area - Yosys (kGE) | 17.44 | 26.06 | 35.64 | 58.74 |
| Area - Commercial (estimated kGE) | ~16 | ~24 | ~33 | ~54 |
| Verification status | Red | Green | Amber | Amber |
| Performance (CoreMark/MHz) | 0.904 | 2.47 | 3.13 | 3.13 |
| Area - Yosys (kGE) | 16.85 | 26.60 | 32.48 | 66.02 |
| Area - Commercial (estimated kGE) | ~15 | ~24 | ~30 | ~61 |
| Verification status | Red | Green | Green | Green |
Notes:
* Performance numbers are based on CoreMark running on the Ibex Simple System [platform](examples/simple_system/README.md).
Note that different ISAs (use of B and C extensions) give the best results for different configurations.
See the [Benchmarks README](examples/sw/benchmarks/README.md) for more information.
The "maxperf-pmp-bmfull" configuration sets a `SpecBranch` parameter in `ibex_core.sv`; this helps timing but has a small negative performance impact.
* Yosys synthesis area numbers are based on the Ibex basic synthesis [flow](syn/README.md) using the latch-based register file.
* Commercial synthesis area numbers are a rough estimate of what might be achievable with a commercial synthesis flow and technology library.
* For comparison, the original "Zero-riscy" core yields an area of 23.14kGE using our Yosys synthesis flow.
@ -42,8 +47,8 @@ Notes:
Amber indicates that some verification has been performed, but the configuration is still experimental.
Red indicates a configuration with minimal/no verification.
Users must make their own assessment of verification readiness for any tapeout.
* v0.92 of the RISC-V Bit Manipulation Extension is supported.
This is *not ratified* and there may be changes for the v1.0 ratified version.
* v.1.0.0 of the RISC-V Bit-Manipulation Extension is supported as well as the remaining sub-extensions of draft v.0.93 of the bitmanip spec.
The latter are *not ratified* and there may be changes before ratification.
See [Standards Compliance](https://ibex-core.readthedocs.io/en/latest/01_overview/compliance.html) in the Ibex documentation for more information.
## Documentation
@ -52,6 +57,17 @@ The Ibex user manual can be
[read online at ReadTheDocs](https://ibex-core.readthedocs.io/en/latest/). It is also contained in
the `doc` folder of this repository.
## Examples
The Ibex repository includes [Simple System](examples/simple_system/README.md).
This is an intentionally simple integration of Ibex with a basic system that targets simulation.
It is intended to provide an easy way to get bare metal binaries running on Ibex in simulation.
A more complete example can be found in the [Ibex Demo System repository](https://github.com/lowrisc/ibex-demo-system).
In particular it includes a integration of the [PULP RISC-V debug module](https://github.com/pulp-platform/riscv-dbg).
It targets the [Arty A7 FPGA board from Digilent](https://digilent.com/shop/arty-a7-artix-7-fpga-development-board/) and supports debugging via OpenOCD and GDB over USB (no external JTAG probe required).
The Ibex Demo System is maintained by lowRISC but is not an official part of Ibex.
## Contributing
We highly appreciate community contributions. To ease our work of reviewing your contributions,
@ -69,7 +85,7 @@ When contributing SystemVerilog source code, please try to be consistent and adh
coding style guide](https://github.com/lowRISC/style-guides/blob/master/VerilogCodingStyle.md).
When contributing C or C++ source code, please try to adhere to [the OpenTitan C++ coding style
guide](https://docs.opentitan.org/doc/rm/c_cpp_coding_style/).
guide](https://opentitan.org/book/doc/contributing/style_guides/c_cpp_coding_style.html).
All C and C++ code should be formatted with clang-format before committing.
Either run `clang-format -i filename.cc` or `git clang-format` on added files.
@ -96,9 +112,3 @@ License, Version 2.0 (see LICENSE for full text).
Many people have contributed to Ibex through the years. Please have a look at
the [credits file](CREDITS.md) and the commit history for more information.
## References
1. [Schiavone, Pasquale Davide, et al. "Slow and steady wins the race? A comparison of
ultra-low-power RISC-V cores for Internet-of-Things applications."
_27th International Symposium on Power and Timing Modeling, Optimization and Simulation
(PATMOS 2017)_](https://doi.org/10.1109/PATMOS.2017.8106976)

8
SECURITY.md Normal file
View file

@ -0,0 +1,8 @@
# Reporting Security Issues
The lowRISC team and Ibex community (including the OpenTitan partnership) take security issues seriously.
We appreciate all efforts to find security vulnerabilities in Ibex and ask that responsible disclosure is practiced should you discover a potential vulnerability.
As Ibex and in particular its secure configuration was developed as part of [OpenTitan](https://www.github.com/lowrisc/opentitan) contact [security@opentitan.org](mailto:security@opentitan.org) to report any security issues and do not open a public issue.
[security@opentitan.org](mailto:security@opentitan.org) will advise on the coordinated vulnerability disclosure (CVD) procedure.

View file

@ -1,120 +0,0 @@
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
# Azure Pipelines CI build configuration
# Documentation at https://aka.ms/yaml
variables:
- template: ci/vars.yml
trigger:
batch: true
branches:
include:
- '*'
tags:
include:
- '*'
pr:
branches:
include:
- '*'
# Note: All tests run as part of one job to avoid copying intermediate build
# artifacts around (e.g. Verilator and toolchain builds). Once more builds/tests
# are added, we need to re-evaluate this decision to parallelize jobs and
# improve end-to-end CI times.
jobs:
- job: lint_dv
displayName: Run quality checks (Lint and DV)
pool:
vmImage: "ubuntu-18.04"
steps:
- bash: |
ci/install-build-deps.sh
displayName: Install build dependencies
- bash: |
echo $PATH
python3 --version
echo -n "fusesoc "
fusesoc --version
verilator --version
riscv32-unknown-elf-gcc --version
verible-verilog-lint --version
displayName: Display environment
# Verible format is experimental so only run on default config for now,
# will eventually become part of the per-config CI
- bash: |
fusesoc --cores-root . run --no-export --target=format --tool=veribleformat lowrisc:ibex:ibex_core_tracing
if [ $? != 0 ]; then
echo -n "##vso[task.logissue type=error]"
echo "Verilog format with Verible failed. Run 'fusesoc --cores-root . run --no-export --target=format --tool=veribleformat lowrisc:ibex:ibex_core_tracing' to check and fix all errors."
echo "This flow is currently experimental and failures can be ignored."
fi
# Show diff of what verilog_format would have changed, and then revert.
git diff
git reset --hard HEAD
continueOnError: true
displayName: Format all source code with Verible format (experimental)
- bash: |
fork_origin=$(git merge-base --fork-point origin/master)
changed_files=$(git diff --name-only $fork_origin | grep -v '^vendor' | grep -E '\.(cpp|cc|c|h)$')
test -z "$changed_files" || git diff -U0 $fork_origin $changed_files | clang-format-diff -p1 | tee clang-format-output
if [ -s clang-format-output ]; then
echo -n "##vso[task.logissue type=error]"
echo "C/C++ lint failed. Use 'git clang-format' with appropriate options to reformat the changed code."
exit 1
fi
# This check is not idempotent, but checks changes to a base branch.
# Run it only on pull requests.
condition: eq(variables['Build.Reason'], 'PullRequest')
displayName: 'Use clang-format to check C/C++ coding style'
- bash: |
# Build and run CSR testbench, chosen Ibex configuration does not effect
# this so doesn't need to be part of per-config CI
fusesoc --cores-root=. run --target=sim --tool=verilator lowrisc:ibex:tb_cs_registers
displayName: Build and run CSR testbench with Verilator
- bash: |
cd build
git clone https://github.com/riscv/riscv-compliance.git
cd riscv-compliance
git checkout "$RISCV_COMPLIANCE_GIT_VERSION"
displayName: Get RISC-V Compliance test suite
# Run Ibex RTL CI per supported configuration
- template : ci/ibex-rtl-ci-steps.yml
parameters:
ibex_configs:
# Note: Try to keep the list of configurations in sync with the one used
# in Private CI.
- small
- experimental-maxperf-pmp
- experimental-maxperf-pmp-bmfull
- experimental-maxperf-pmp-bmfull-icache
- experimental-branch-predictor
# Run lint on simple system
- bash: |
fusesoc --cores-root . run --target=lint --tool=verilator lowrisc:ibex:ibex_simple_system
if [ $? != 0 ]; then
echo -n "##vso[task.logissue type=error]"
echo "Verilog lint with Verilator failed. Run 'fusesoc --cores-root . run --target=lint --tool=verilator lowrisc:ibex:ibex_simple_system' to check and fix all errors."
exit 1
fi
displayName: Run Verilator lint on simple system
- bash: |
fusesoc --cores-root . run --target=lint --tool=veriblelint lowrisc:ibex:ibex_simple_system
if [ $? != 0 ]; then
echo -n "##vso[task.logissue type=error]"
echo "Verilog lint with Verible failed. Run 'fusesoc --cores-root . run --target=lint --tool=veriblelint lowrisc:ibex:ibex_simple_system' to check and fix all errors."
exit 1
fi
displayName: Run Verible lint on simple system

View file

@ -1,31 +0,0 @@
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
#
# Private CI trigger. Used to run tooling that can't currently be shared
# publicly.
trigger:
batch: true
branches:
include:
- '*'
tags:
include:
- "*"
pr:
branches:
include:
- '*'
# The runner used for private CI enforces the use of the template below. All
# build steps need to be placed into the template.
resources:
repositories:
- repository: lowrisc-private-ci
type: github
endpoint: lowRISC
name: lowrisc/lowrisc-private-ci
extends:
template: jobs-ibex.yml@lowrisc-private-ci

View file

@ -1,67 +0,0 @@
parameters:
ibex_configs: []
steps:
- ${{ each config in parameters.ibex_configs }}:
# ibex_config.py will exit with error code 1 on any error which will cause
# the CI to fail if there's an issue with the configuration file or an
# incorrect configuration name being used
- bash: |
set -e
IBEX_CONFIG_OPTS=`./util/ibex_config.py ${{ config }} fusesoc_opts`
echo $IBEX_CONFIG_OPTS
echo "##vso[task.setvariable variable=ibex_config_opts]" $IBEX_CONFIG_OPTS
displayName: Test and display fusesoc config for ${{ config }}
- bash: |
fusesoc --cores-root . run --target=lint --tool=verilator lowrisc:ibex:ibex_core_tracing $IBEX_CONFIG_OPTS
if [ $? != 0 ]; then
echo -n "##vso[task.logissue type=error]"
echo "Verilog lint failed. Run 'fusesoc --cores-root . run --target=lint --tool=verilator lowrisc:ibex:ibex_core_tracing $IBEX_CONFIG_OPTS' to check and fix all errors."
exit 1
fi
displayName: Lint Verilog source files with Verilator for ${{ config }}
- bash: |
fusesoc --cores-root . run --target=lint --tool=veriblelint lowrisc:ibex:ibex_core_tracing $IBEX_CONFIG_OPTS
if [ $? != 0 ]; then
echo -n "##vso[task.logissue type=error]"
echo "Verilog lint failed. Run 'fusesoc --cores-root . run --target=lint --tool=veriblelint lowrisc:ibex:ibex_core_tracing $IBEX_CONFIG_OPTS' to check and fix all errors."
exit 1
fi
displayName: Lint Verilog source files with Verible Verilog Lint for ${{ config }}
- bash: |
# Build simulation model of Ibex
fusesoc --cores-root=. run --target=sim --setup --build lowrisc:ibex:ibex_riscv_compliance $IBEX_CONFIG_OPTS
if [ $? != 0 ]; then
echo -n "##vso[task.logissue type=error]"
echo "Unable to build Verilator model of Ibex for compliance testing."
exit 1
fi
# Run compliance test suite
export TARGET_SIM=$PWD/build/lowrisc_ibex_ibex_riscv_compliance_0.1/sim-verilator/Vibex_riscv_compliance
export RISCV_PREFIX=riscv32-unknown-elf-
export RISCV_TARGET=ibex
export RISCV_DEVICE=rv32imc
fail=0
for isa in rv32i rv32im rv32imc rv32Zicsr rv32Zifencei; do
make -C build/riscv-compliance RISCV_ISA=$isa 2>&1 | tee run.log
if [ ${PIPESTATUS[0]} != 0 ]; then
echo -n "##vso[task.logissue type=error]"
echo "The RISC-V compliance test suite failed for $isa"
# There's no easy way to get the test results in machine-readable
# form to properly exclude known-failing tests. Going with an
# approximate solution for now.
if [ $isa == rv32i ] && grep -q 'FAIL: 4/48' run.log; then
echo -n "##vso[task.logissue type=error]"
echo "Expected failure for rv32i, see lowrisc/ibex#100 more more information."
else
fail=1
fi
fi
done
exit $fail
displayName: Run RISC-V Compliance test for Ibex RV32IMC for ${{ config }}

View file

@ -11,27 +11,26 @@ set -e
[ -f /etc/os-release ] || (echo "/etc/os-release doesn't exist."; exit 1)
. /etc/os-release
[ ! -z "$VERILATOR_VERSION" ] || (echo "VERILATOR_VERSION must be set."; exit 1)
[ ! -z "$VERIBLE_VERSION" ] || (echo "VERIBLE_VERSION must be set."; exit 1)
[ ! -z "$RISCV_TOOLCHAIN_TAR_VERSION" ] || (echo "RISCV_TOOLCHAIN_TAR_VERSION must be set."; exit 1)
[ ! -z "$RISCV_TOOLCHAIN_TAR_VARIANT" ] || (echo "RISCV_TOOLCHAIN_TAR_VARIANT must be set."; exit 1)
[ -n "$VERILATOR_VERSION" ] || (echo "VERILATOR_VERSION must be set."; exit 1)
[ -n "$VERIBLE_VERSION" ] || (echo "VERIBLE_VERSION must be set."; exit 1)
[ -n "$RISCV_TOOLCHAIN_TAR_VERSION" ] || (echo "RISCV_TOOLCHAIN_TAR_VERSION must be set."; exit 1)
[ -n "$RISCV_TOOLCHAIN_TAR_VARIANT" ] || (echo "RISCV_TOOLCHAIN_TAR_VARIANT must be set."; exit 1)
SUDO_CMD=""
if [ $(id -u) -ne 0 ]; then
if [ "$(id -u)" -ne 0 ]; then
SUDO_CMD="sudo "
fi
if [ -z "$GITHUB_ACTIONS" ]; then
GITHUB_PATH=/dev/null
fi
case "$ID-$VERSION_ID" in
ubuntu-16.04|ubuntu-18.04)
ubuntu-20.04|ubuntu-22.04)
# Curl must be available to get the repo key below.
$SUDO_CMD apt-get update
$SUDO_CMD apt-get install -y curl
# Make Verilator repository available
curl -Ls https://download.opensuse.org/repositories/home:phiwag:edatools/xUbuntu_$VERSION_ID/Release.key | $SUDO_CMD apt-key add -
$SUDO_CMD sh -c "echo 'deb http://download.opensuse.org/repositories/home:/phiwag:/edatools/xUbuntu_$VERSION_ID/ /' > /etc/apt/sources.list.d/edatools.list"
$SUDO_CMD apt-get update
# Packaged dependencies
# Install python3-yaml through apt to get a version with libyaml bindings,
# which is significantly faster than the pure Python version.
@ -42,6 +41,7 @@ case "$ID-$VERSION_ID" in
python3-setuptools \
python3-wheel \
python3-yaml \
python3-dev \
srecord \
zlib1g-dev \
git \
@ -52,27 +52,41 @@ case "$ID-$VERSION_ID" in
bison \
libelf-dev \
clang-format \
"verilator-$VERILATOR_VERSION" \
xz-utils
wget \
xz-utils \
libcairo2-dev
# Python dependencies
#
# Updating pip and setuptools is required to have these tools properly
# parse Python-version metadata, which some packages uses to specify that
# an older version of a package must be used for a certain Python version.
# If that information is not read, pip installs the latest version, which
# then fails to run.
$SUDO_CMD pip3 install -U pip setuptools
wget https://storage.googleapis.com/ibex-cosim-builds/ibex-cosim-"$IBEX_COSIM_VERSION".tar.gz
$SUDO_CMD mkdir -p /tools/riscv-isa-sim
$SUDO_CMD chmod 777 /tools/riscv-isa-sim
$SUDO_CMD tar -C /tools/riscv-isa-sim -xvzf ibex-cosim-"$IBEX_COSIM_VERSION".tar.gz --strip-components=1
echo "/tools/riscv-isa-sim/bin" >> $GITHUB_PATH
$SUDO_CMD pip3 install -r python-requirements.txt
wget https://storage.googleapis.com/verilator-builds/verilator-"$VERILATOR_VERSION".tar.gz
$SUDO_CMD mkdir -p /tools/verilator
$SUDO_CMD chmod 777 /tools/verilator
$SUDO_CMD tar -C /tools/verilator -xvzf verilator-"$VERILATOR_VERSION".tar.gz
echo "/tools/verilator/$VERILATOR_VERSION/bin" >> $GITHUB_PATH
# Python dependencies
#
# Updating pip and setuptools is required to have these tools properly
# parse Python-version metadata, which some packages uses to specify that
# an older version of a package must be used for a certain Python version.
# If that information is not read, pip installs the latest version, which
# then fails to run.
$SUDO_CMD pip3 install -U pip "setuptools<66.0.0"
# Install Verible
mkdir -p build/verible
cd build/verible
curl -Ls -o verible.tar.gz "https://github.com/google/verible/releases/download/$VERIBLE_VERSION/verible-$VERIBLE_VERSION-Ubuntu-$VERSION_ID-$VERSION_CODENAME-x86_64.tar.gz"
$SUDO_CMD mkdir -p /tools/verible && $SUDO_CMD chmod 777 /tools/verible
tar -C /tools/verible -xf verible.tar.gz --strip-components=1
echo "##vso[task.prependpath]/tools/verible/bin"
$SUDO_CMD pip3 install -r python-requirements.txt
# Install Verible
mkdir -p build/verible
cd build/verible
VERIBLE_URL="https://github.com/chipsalliance/verible/releases/download/$VERIBLE_VERSION/verible-$VERIBLE_VERSION-linux-static-x86_64.tar.gz"
$SUDO_CMD mkdir -p /tools/verible
curl -sSfL "$VERIBLE_URL" | $SUDO_CMD tar -C /tools/verible -xvzf - --strip-components=1
# Fixup bin permission which is broken in tarball.
$SUDO_CMD chmod 755 /tools/verible/bin
echo "/tools/verible/bin" >> $GITHUB_PATH
;;
*)
@ -86,5 +100,5 @@ TOOLCHAIN_URL="https://github.com/lowRISC/lowrisc-toolchains/releases/download/$
mkdir -p build/toolchain
curl -Ls -o build/toolchain/rv32-toolchain.tar.xz "$TOOLCHAIN_URL"
$SUDO_CMD mkdir -p /tools/riscv && $SUDO_CMD chmod 777 /tools/riscv
tar -C /tools/riscv -xf build/toolchain/rv32-toolchain.tar.xz --strip-components=1
echo "##vso[task.prependpath]/tools/riscv/bin"
$SUDO_CMD tar -C /tools/riscv -xf build/toolchain/rv32-toolchain.tar.xz --strip-components=1
echo "/tools/riscv/bin" >> $GITHUB_PATH

51
ci/run-cosim-test.sh Executable file
View file

@ -0,0 +1,51 @@
#!/bin/bash
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
#
# Run an elf against simple system co-simulation and check the UART output for
# reported pass/fail reporting as appropriate for use in GitHub Actions
SKIP_PASS_CHECK=0
if [ $# -eq 3 ]; then
if [ $1 == "--skip-pass-check" ]; then
SKIP_PASS_CHECK=1
fi
TEST_NAME=$2
TEST_ELF=$3
elif [ $# -eq 2 ]; then
TEST_NAME=$1
TEST_ELF=$2
else
echo "Usage: $0 [--skip-pass-check] test_name test_elf"
exit 1
fi
echo "Running $TEST_NAME with co-simulation"
build/lowrisc_ibex_ibex_simple_system_cosim_0/sim-verilator/Vibex_simple_system --meminit=ram,$TEST_ELF
if [ $? != 0 ]; then
echo "::error::Running % failed co-simulation testing"
exit 1
fi
grep 'FAILURE' ibex_simple_system.log
if [ $? != 1 ]; then
echo "::error::Failure seen in $TEST_NAME log"
echo "Log contents:"
cat ibex_simple_system.log
exit 1
fi
if [ $SKIP_PASS_CHECK != 1 ]; then
grep 'PASS' ibex_simple_system.log
if [ $? != 0 ]; then
echo "::error::No pass seen in $TEST_NAME log"
echo "Log contents:"
cat ibex_simple_system.log
exit 1
fi
fi
echo "$TEST_NAME succeeded"

3
ci/setup-cosim.sh Normal file
View file

@ -0,0 +1,3 @@
#!/bin/sh
export PKG_CONFIG_PATH=/tools/riscv-isa-sim/lib/pkgconfig:$PATH

15
ci/vars.env Normal file
View file

@ -0,0 +1,15 @@
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
# Pipeline variables, used by the public and private CI pipelines
# Quote values to ensure they are parsed as string (version numbers might
# end up as float otherwise).
VERILATOR_VERSION=v4.210
IBEX_COSIM_VERSION=39612f9
RISCV_TOOLCHAIN_TAR_VERSION=20220210-1
RISCV_TOOLCHAIN_TAR_VARIANT=lowrisc-toolchain-gcc-rv32imcb
RISCV_COMPLIANCE_GIT_VERSION=844c6660ef3f0d9b96957991109dfd80cc4938e2
VERIBLE_VERSION=v0.0-3622-g07b310a3
# lowRISC-internal version numbers of Ibex-specific Spike builds.
SPIKE_IBEX_VERSION=20220817-git-eccdcb15c3e51b4f7906c7b42fb824f24a4338a2

View file

@ -1,15 +0,0 @@
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
# Pipeline variables, used by the public and private CI pipelines
# Quote values to ensure they are parsed as string (version numbers might
# end up as float otherwise).
variables:
VERILATOR_VERSION: "4.040"
RISCV_TOOLCHAIN_TAR_VERSION: "20200904-1"
RISCV_TOOLCHAIN_TAR_VARIANT: "lowrisc-toolchain-gcc-rv32imcb"
RISCV_COMPLIANCE_GIT_VERSION: "844c6660ef3f0d9b96957991109dfd80cc4938e2"
VERIBLE_VERSION: "v0.0-705-g75249d0"
# lowRISC-internal version numbers of Ibex-specific Spike builds.
SPIKE_IBEX_VERSION: "20201023-git-255bf1cacc599b1413438c269100f3ecd0eb3352"

View file

@ -1,43 +0,0 @@
#!/usr/bin/env python3
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
# Read an Azure Pipelines-compatible variables file, and convert it into
# logging commands that Azure Pipelines understands, effectively setting the
# variables at runtime.
#
# This script can be used as a workaround if variables cannot be included in the
# Pipeline definition directly.
#
# See https://docs.microsoft.com/en-us/azure/devops/pipelines/scripts/logging-commands
# for more information on logging commands.
import sys
import yaml
def vars_to_logging_cmd(vars_file):
data = {}
print(vars_file)
with open(vars_file, 'r', encoding="utf-8") as fp:
data = yaml.load(fp, Loader=yaml.SafeLoader)
if not (isinstance(data, dict) and 'variables' in data):
print("YAML file wasn't a dictionary with a 'variables' key. Got: {}"
.format(data))
print("Setting variables from {}".format(vars_file))
for key, value in data['variables'].items():
# Note: These lines won't show up in the Azure Pipelines output unless
# "System Diagnostics" are enabled (go to the Azure Pipelines web UI,
# click on "Run pipeline" to manually run a pipeline, and check "Enable
# system diagnostics".)
print("##vso[task.setvariable variable={}]{}".format(key, value))
return 0
if __name__ == "__main__":
if len(sys.argv) < 2:
print("Usage: {} VARS_FILE".format(sys.argv[0]))
sys.exit(1)
sys.exit(vars_to_logging_cmd(sys.argv[1]))

View file

@ -5,10 +5,11 @@ Ibex is a standards-compliant 32 bit RISC-V processor.
It follows these specifications:
* `RISC-V Instruction Set Manual, Volume I: User-Level ISA, document version 20190608-Base-Ratified (June 8, 2019) <https://github.com/riscv/riscv-isa-manual/releases/download/Ratified-IMFDQC-and-Priv-v1.11/riscv-spec-20190608.pdf>`_
* `RISC-V Instruction Set Manual, Volume II: Privileged Architecture, document version 20190608-Base-Ratified (June 8, 2019) <https://github.com/riscv/riscv-isa-manual/releases/download/Ratified-IMFDQC-and-Priv-v1.11/riscv-privileged-20190608.pdf>`_.
Ibex implements the Machine ISA version 1.11.
* `RISC-V Instruction Set Manual, Volume II: Privileged Architecture, document version 20211203 (December 4, 2021) <https://github.com/riscv/riscv-isa-manual/releases/download/Priv-v1.12/riscv-privileged-20211203.pdf>`_.
Ibex implements the Machine ISA version 1.12.
* `RISC-V External Debug Support, version 0.13.2 <https://content.riscv.org/wp-content/uploads/2019/03/riscv-debug-release.pdf>`_
* `RISC-V Bit Manipulation Extension, version 0.92 (draft from November 8, 2019) <https://github.com/riscv/riscv-bitmanip/blob/master/bitmanip-0.92.pdf>`_
* `RISC-V Bit-Manipulation Extension, version 1.0.0 <https://github.com/riscv/riscv-bitmanip/releases/download/1.0.0/bitmanip-1.0.0-38-g865e7a7.pdf>`_ and `version 0.93 (draft from January 10, 2021) <https://github.com/riscv/riscv-bitmanip/blob/master/bitmanip-0.93.pdf>`_
* `PMP Enhancements for memory access and execution prevention on Machine mode (Smepmp) version 1.0 <https://github.com/riscv/riscv-tee/blob/191b563b08b31cc2974d604a3b670d8666a2e093/Smepmp/Smepmp.pdf>`_
Many features in the RISC-V specification are optional, and Ibex can be parametrized to enable or disable some of them.
@ -34,8 +35,8 @@ In addition, the following instruction set extensions are available.
- 2.0
- optional
* - **B**: Draft Extension for Bit Manipulation Instructions
- 0.92 [#B_draft]_
* - **B**: Standard Extension for Bit-Manipulation Instructions
- 1.0.0 + 0.93 [#B_draft]_
- optional
* - **Zicsr**: Control and Status Register Instructions
@ -46,8 +47,11 @@ In addition, the following instruction set extensions are available.
- 2.0
- always enabled
Most content of the RISC-V privileged specification is optional.
Ibex currently supports the following features according to the RISC-V Privileged Specification, version 1.11.
* - **Smepmp** - PMP Enhancements for memory access and execution prevention on Machine mode
- 1.0
- always enabled in configurations with PMP see :ref:`PMP Enhancements<pmp-enhancements>`
Ibex currently supports the following features according to the RISC-V Privileged Specification, version 1.12.
* M-Mode and U-Mode
* All CSRs listed in :ref:`cs-registers`
@ -56,7 +60,9 @@ Ibex currently supports the following features according to the RISC-V Privilege
.. rubric:: Footnotes
.. [#B_draft] Note that while Ibex fully implements draft version 0.92 of the RISC-V Bit Manipulation Extension, this extension may change before being ratified as a standard by the RISC-V Foundation.
.. [#B_draft] Ibex fully implements the ratified version 1.0.0 of the RISC-V Bit-Manipulation Extension including the Zba, Zbb, Zbc and Zbs sub-extensions.
In addition, Ibex also supports the remaining Zbe, Zbf, Zbp, Zbr and Zbt sub-extensions as defined in draft version 0.93 of the RISC-V Bit-Manipulation Extension.
Note that the latter sub-extensions may change before being ratified as a standard by the RISC-V Foundation.
Ibex will be updated to match future versions of the specification.
Prior to ratification this may involve backwards incompatible changes.
Additionally, neither GCC or Clang have committed to maintaining support upstream for unratified versions of the specification.

View file

@ -1,7 +1,7 @@
Introduction to Ibex
====================
Ibex is a production-quality open source 32 bit RISC-V CPU core written in SystemVerilog.
Ibex is a production-quality open source 32-bit RISC-V CPU core written in SystemVerilog.
The CPU core is heavily parametrizable and well suited for embedded control applications.
Ibex is being extensively verified and has seen multiple tape-outs.
@ -14,3 +14,4 @@ Read on for more information Ibex in general: what standards it implements, what
compliance
targets
licensing
verification_overview

View file

@ -7,8 +7,6 @@ ASIC Synthesis
ASIC synthesis is supported for Ibex.
The whole design is completely synchronous and uses positive-edge triggered flip-flops, except for the register file, which can be implemented either with latches or with flip-flops.
See :ref:`register-file` for more details.
The core occupies an area of roughly 24 kGE when using the latch-based register file and implementing the RV32IMC ISA, or 16 kGE when implementing the RV32EC ISA.
FPGA Synthesis
--------------

View file

@ -0,0 +1,22 @@
Verification Overview
=====================
Ibex is verified using a :ref:`UVM based testbench<verification>` that employs a :ref:`co-simulation methodology<cosim>` to cross-check Ibex execution against an ISS reference model (`Spike <https://github.com/lowRISC/riscv-isa-sim>`_).
The testbench runs binaries built from source produced by the `RISC-DV <https://github.com/chipsalliance/riscv-dv>`_ random instruction generator.
Additional stimulus is provided in the form of randomized memory timings, memory errors, interrupts and debug requests by the testbench.
A comprehensive :ref:`testplan<testplan>` and :ref:`coverage plan<coverage-plan>` are implemented.
Verification Status
-------------------
Ibex has a large number of parameters resulting in a large number of possible configurations.
The configuration space is too large to fully verify the design for all possible parameter sets.
To manage this complexity regressions runs and verification closure target a number of :ref:`supported configurations<ibex-config>`.
Current verification closure effort is focussed on the ``opentitan`` configuration and is the only configuration with nightly regression runs.
Verification maturity is tracked via :ref:`verification_stages` that are `defined by the OpenTitan project <https://opentitan.org/book/doc/project_governance/development_stages.html#hardware-verification-stages-v>`_.
Ibex has achieved **V2S** for the `opentitan` configuration, broadly this means verification is almost complete (over 90% code and functional coverage hit with over 90% regression pass rate with test plan and coverage plan fully implemented) but not yet closed.
Nightly regression results, including a coverage summary and details of test failures, for the ``opentitan`` Ibex configuration are published at https://ibex.reports.lowrisc.org/opentitan/latest/report.html. Below is a summary of these results:
.. image:: https://ibex.reports.lowrisc.org/opentitan/latest/summary.svg

View file

@ -0,0 +1,43 @@
.. _ibex-config:
Ibex Configurations
===================
The ``ibex_top`` module has a large number of top-level parameters which configure the core (see :ref:`core-integration`).
This gives rise to a huge number of possible Ibex core configurations.
To manage this complexity a number of named configurations is provided in the :file:`ibex_configs.yml` file.
A subset of these are 'supported configurations' which are the focus of verification and development activities.
Configuration Tool
------------------
A tool :file:`util/ibex_config.py` is provided to work with the named configurations.
This tool provides command line options to set Ibex parameters for various EDA tools for a named configuration.
Various Ibex flows (e.g. the DV flow) use this tool internally and can be provided with a configuration name from :file:`util/ibex_config.py` to work with.
Here is an example of using the configuration tool to get the FuseSoC options required to build the ``opentitan`` configuration.
.. code-block:: bash
# Request FuseSoC options required to build the 'opentitan' Ibex configuration.
./util/ibex_config.py opentitan fusesoc_opts
# The output of the tool
--RV32E=0 --RV32M=ibex_pkg::RV32MSingleCycle --RV32B=ibex_pkg::RV32BOTEarlGrey --RegFile=ibex_pkg::RegFileFF --BranchTargetALU=1 --WritebackStage=1 --ICache=1 --ICacheECC=1 --ICacheScramble=1 --BranchPredictor=0 --DbgTriggerEn=1 --SecureIbex=1 --PMPEnable=1 --PMPGranularity=0 --PMPNumRegions=16 --MHPMCounterNum=10 --MHPMCounterWidth=32
For further information about using the tool check the help provided on the command line.
.. code-block:: bash
# Get help on using ibex_config.py
./util/ibex_config.py -h
Supported Configurations
------------------------
The current set of supported configurations are:
* ``small`` - RV32IMC with two stage pipeline and 3 cycle multiplier
* ``opentitan`` - The configuration used by the `OpenTitan <www.opentitan.org>`_ project
* ``maxperf`` - RV32IMC with three stage pipeline and single cycle multiplier, maximum performance (using stable features) configuration.
* ``maxperf-pmp-bmbalanced`` - ``maxperf`` configuration with PMP and the 'balanced' bit-manipulation configuration (:ref:`core-integration` for details).

View file

@ -3,16 +3,25 @@
Examples
========
To make use of Ibex it has to be integrated as described in :ref:`core-integration`.
There are two examples that demonstrate Ibex usage.
FPGA
----
The first is 'Simple System' and is part of the Ibex repository.
It demonstrates a minimal system connecting Ibex to some memory with a timer peripheral and is targeted at simulation.
A minimal example for the `Arty A7 <https://reference.digilentinc.com/reference/programmable-logic/arty-a7/start>`_ FPGA Development board is provided.
In this example Ibex is directly linked to a SRAM memory instance.
Four LEDs from the board are connected to the data bus and are updated each time when a word is written.
The memory is separated into a instruction and data section.
The instructions memory is initialized at synthesis time by reading the output from the software build.
The software writes to the data section the complementary lower for bits of a word every second resulting in blinking LEDs.
The second is the `'Ibex Demo System' <https://www.github.com/lowrisc/ibex-demo-system>`_ which is a separate repository.
It is targeted at FPGA implementation and contains some extra peripherals along with a RISC-V debug module integration.
Simple System
-------------
Simple system is built via FuseSoC.
Verilator is the primary simulator it is designed for, though other simulators are also supported (such as VCS).
Its aim is to make running a binary against Ibex RTL, obtaining an instruction trace, wave trace and any other simulation outputs as simple as possible along with demonstrating basic Ibex integration.
See the `Simple System README <https://github.com/lowRISC/ibex/tree/master/examples/simple_system>`_ for more information.
There is an extended version of simple system which adds co-simulation checking.
This cross-checks every instruction execution against a RISC-V ISS.
It is the same co-simulation method used by our full DV environment but enables its use in a far simpler setup.
The simple system co-simulation setup is compatible with Verilator (unlike our full DV environment).
See :ref:`cosim` for more information.
Find the description of how to build and program the Arty board in ``examples/fpga/artya7/README.md``.

View file

@ -3,11 +3,16 @@
Getting Started with Ibex
=========================
This page discusses initial steps and requirements to start using Ibex in your design.
The Ibex repository contains all the RTL needed to simulate and synthesize an Ibex core.
`FuseSoC <https://github.com/olofk/fusesoc>`_ core files list the RTL files required to build Ibex (see :file:`ibex_core.core`).
The core itself is contained in the :file:`rtl/` directory, though it utilizes some primitives found in the :file:`vendor/lowrisc_ip/` directory.
These primitives come from the `OpenTitan <https://github.com/lowrisc/opentitan>`_ project but are copied into the Ibex repository so the RTL has no external dependencies.
You may wish to replace these primitives with your own and some are only required for specific configurations.
See :ref:`integration-prims` for more information.
Register File
-------------
There are several paths to follow depending on what you wish to accomplish:
Ibex comes with three different register file implementations that can be selected using the enumerated parameter ``RegFile`` defined in :file:`rtl/ibex_pkg.sv`.
Depending on the target technology, either the flip-flop-based ("ibex_pkg::RegFileFF", default), the latch-based ("ibex_pkg::RegFileLatch") or an FPGA-targeted ("ibex_pkg::RegFileFPGA") implementation should be selected.
For more information about the three register file implementations and their trade-offs, check out :ref:`register-file`.
* See :ref:`examples` for a basic simulation setup running the core in isolation and a simple FPGA system.
* See :ref:`verification` to begin working with the DV flow.
* See :ref:`core-integration` to integrate the Ibex core into your own design.
* See :ref:`integration-fusesoc-files` for information on how to get a complete RTL file listing to build Ibex for use outside of FuseSoC based flows.

View file

@ -10,5 +10,6 @@ It is aimed at hardware developers integrating Ibex into a design, and software
system_requirements
getting_started
configuration
integration
examples

View file

@ -3,75 +3,166 @@
Core Integration
================
The main module is named ``ibex_core`` and can be found in ``ibex_core.sv``.
Below, the instantiation template is given and the parameters and interfaces are described.
The main module is named ``ibex_top`` and can be found in ``ibex_top.sv``.
Note that the core logic is split-out from the register file and RAMs under ``ibex_top``.
This is to facilitate a dual-core lockstep implementation (see :ref:`security`).
Register File
-------------
Ibex comes with three different register file implementations that can be selected using the enumerated parameter ``RegFile`` defined in :file:`rtl/ibex_pkg.sv`.
Depending on the target technology, either the flip-flop-based ("ibex_pkg::RegFileFF", default), the latch-based ("ibex_pkg::RegFileLatch") or an FPGA-targeted ("ibex_pkg::RegFileFPGA") implementation should be selected.
For more information about the three register file implementations and their trade-offs, check out :ref:`register-file`.
Identification CSRs
-------------------
The RISC-V Privileged Architecture specifies several read-only CSRs that identify the vendor and micro-architecture of a CPU.
These are ``mvendorid``, ``marchid`` and ``mimpid``.
The fixed, read-only values for these CSRs are defined in :file:`rtl/ibex_pkg.sv`.
Implementers should carefully consider appropriate values for these registers.
Ibex, as an open source implementation, has an assigned architecture ID (``marchid``) of 22.
(Allocations are specified in `marchid.md of the riscv-isa-manual repository <https://github.com/riscv/riscv-isa-manual/blob/master/marchid.md>`_.)
If significant changes are made to the micro-architecture a different architecture ID should be used.
The vendor ID and implementation ID (``mvendorid`` and ``mimpid``) both read as 0 by default, meaning non-implemented.
Implementers may wish to use other values here.
Please see the RISC-V Privileged Architecture specification for more details on what these IDs represent and how they should be chosen.
.. _integration-prims:
Primitives
----------
Ibex uses a number of primitive modules (that are held outside the :file:`rtl/` which contains the Ibex RTL).
Full implementations of these primitives are provided in the Ibex repository but implementors may wish to provide their own implementations.
Some of the primitives are only used for specific Ibex configurations so can be ignored/removed if you're not using one of those configurations.
The mandatory primitives (used by all configurations) are:
* ``prim_buf`` - A buffer, used to ensure security critical logic isn't optimized out in synthesis (by applying suitable constraints to prim_buf).
In configurations where ``SecureIbex == 0`` it must exist but can be implemented as a straight passthrough.
* ``prim_clock_gating`` - A clock gate.
The configuration dependent primitives are:
* ``prim_clock_mux2`` - A clock mux, used by the lockstep duplicate core.
Required where ``SecureIbex == 1``.
* ``prim_flop`` - A flip flop, used to ensure security critical logic isn't optimized out in synthesis (by applying suitable constraints to prim_flop).
Required where ``SecureIbex == 1``.
* ``prim_ram_1p`` - A single ported RAM.
Required where ``ICache == 1``.
* ``prim_ram_1p_scr`` - A single ported RAM which scrambles its contents with cryptographic primitives.
Required where ``ICache == 1`` and ``SecureIbex == 1``.
* ``prim_lfsr`` - Linear feedback shift register, used for pseudo random number generation for dummy instruction insertion.
Required where ``SecureIbex == 1``.
* ``prim_onehot_check`` - Checks a onehot signal is correct, for detecting fault injection attacks.
Required where ``SecureIbex == 1``.
* ``prim_secded_X`` - Various primitives to encode and decode SECDED (single error correct, double error detect) error detection and correction codes.
Required where ``SecureIbex == 1``.
Primitives exclusively used by other primitives:
* ``prim_present`` / ``prim_prince`` / ``prim_subst_perm`` - Cryptographic primitives used by ``prim_ram_1p_scr``.
* ``prim_ram_1p_adv`` - Wrapper around ``prim_ram_1p`` that adds support for ECC, used by ``prim_ram_1p_scr``.
.. _integration-fusesoc-files:
RTL File List
-------------
Ibex flows use `FuseSoC <https://github.com/olofk/fusesoc>`_ to gather needed RTL files and run builds.
If you want to use Ibex without FuseSoC the following FuseSoC command will copy all the needed files into a build directory.
.. code-block:: bash
fusesoc --cores-root . run --target=lint --setup --build-root ./build/ibex_out lowrisc:ibex:ibex_top
FuseSoC uses Python and it can be installed using pip.
.. code-block:: bash
pip3 install -U -r python-requirements.txt
Ibex uses a `custom fork of FuseSoC <https://github.com/lowRISC/fusesoc/tree/ot>`_, so you must install it via this method rather than installing FuseSoC separately.
The RTL will be in :file:`./build/ibex_out/src` which is further divided into different sub-directories.
A file list containing paths to all of the RTL files can be found in :file:`./build/ibex_out/ibex-verilator/lowrisc_ibex_ibex_top_0.1.vc`.
Instantiation Template
----------------------
.. code-block:: verilog
ibex_core #(
.PMPEnable ( 0 ),
.PMPGranularity ( 0 ),
.PMPNumRegions ( 4 ),
.MHPMCounterNum ( 0 ),
.MHPMCounterWidth ( 40 ),
.RV32E ( 0 ),
.RV32M ( ibex_pkg::RV32MFast ),
.RV32B ( ibex_pkg::RV32BNone ),
.RegFile ( ibex_pkg::RegFileFF ),
.ICache ( 0 ),
.ICacheECC ( 0 ),
.BranchPrediction ( 0 ),
.SecureIbex ( 0 ),
.DbgTriggerEn ( 0 ),
.DmHaltAddr ( 32'h1A110800 ),
.DmExceptionAddr ( 32'h1A110808 )
) u_core (
ibex_top #(
.PMPEnable ( 0 ),
.PMPGranularity ( 0 ),
.PMPNumRegions ( 4 ),
.MHPMCounterNum ( 0 ),
.MHPMCounterWidth ( 40 ),
.RV32E ( 0 ),
.RV32M ( ibex_pkg::RV32MFast ),
.RV32B ( ibex_pkg::RV32BNone ),
.RegFile ( ibex_pkg::RegFileFF ),
.ICache ( 0 ),
.ICacheECC ( 0 ),
.ICacheScramble ( 0 ),
.BranchPrediction ( 0 ),
.SecureIbex ( 0 ),
.RndCnstLfsrSeed ( ibex_pkg::RndCnstLfsrSeedDefault ),
.RndCnstLfsrPerm ( ibex_pkg::RndCnstLfsrPermDefault ),
.DbgTriggerEn ( 0 ),
.DmBaseAddr ( 32'h1A110000 ),
.DmAddrMask ( 32'h00000FFF ),
.DmHaltAddr ( 32'h1A110800 ),
.DmExceptionAddr ( 32'h1A110808 )
) u_top (
// Clock and reset
.clk_i (),
.rst_ni (),
.test_en_i (),
.clk_i (),
.rst_ni (),
.test_en_i (),
.scan_rst_ni (),
.ram_cfg_i (),
// Configuration
.hart_id_i (),
.boot_addr_i (),
.hart_id_i (),
.boot_addr_i (),
// Instruction memory interface
.instr_req_o (),
.instr_gnt_i (),
.instr_rvalid_i (),
.instr_addr_o (),
.instr_rdata_i (),
.instr_err_i (),
.instr_req_o (),
.instr_gnt_i (),
.instr_rvalid_i (),
.instr_addr_o (),
.instr_rdata_i (),
.instr_rdata_intg_i (),
.instr_err_i (),
// Data memory interface
.data_req_o (),
.data_gnt_i (),
.data_rvalid_i (),
.data_we_o (),
.data_be_o (),
.data_addr_o (),
.data_wdata_o (),
.data_rdata_i (),
.data_err_i (),
.data_req_o (),
.data_gnt_i (),
.data_rvalid_i (),
.data_we_o (),
.data_be_o (),
.data_addr_o (),
.data_wdata_o (),
.data_wdata_intg_o (),
.data_rdata_i (),
.data_rdata_intg_i (),
.data_err_i (),
// Interrupt inputs
.irq_software_i (),
.irq_timer_i (),
.irq_external_i (),
.irq_fast_i (),
.irq_nm_i (),
.irq_software_i (),
.irq_timer_i (),
.irq_external_i (),
.irq_fast_i (),
.irq_nm_i (),
// Debug interface
.debug_req_i (),
.debug_req_i (),
.crash_dump_o (),
// Special control signals
.fetch_enable_i (),
.alert_minor_o (),
.alert_major_o (),
.core_sleep_o ()
.fetch_enable_i (),
.alert_minor_o (),
.alert_major_internal_o (),
.alert_major_bus_o (),
.core_sleep_o ()
);
Parameters
@ -100,34 +191,45 @@ Parameters
+------------------------------+---------------------+------------+-----------------------------------------------------------------------+
| ``RV32B`` | ibex_pkg::rv32b_e | RV32BNone | B(itmanipulation) extension select: |
| | | | "ibex_pkg::RV32BNone": No B-extension |
| | | | "ibex_pkg::RV32BBalanced": Sub-extensions Zbb, Zbs, Zbf and Zbt |
| | | | "ibex_pkg::RV32Full": All sub-extensions |
| | | | "ibex_pkg::RV32BBalanced": Sub-extensions Zba, Zbb, Zbs, Zbf and Zbt |
| | | | "ibex_pkg::RV32BOTEarlGrey": All sub-extensions except Zbe |
| | | | "ibex_pkg::RV32BFull": All sub-extensions |
+------------------------------+---------------------+------------+-----------------------------------------------------------------------+
| ``RegFile`` | ibex_pkg::regfile_e | RegFileFF | Register file implementation select: |
| | | | "ibex_pkg::RegFileFF": Generic flip-flop-based register file |
| | | | "ibex_pkg::RegFileFPGA": Register file for FPGA targets |
| | | | "ibex_pkg::RegFileLatch": Latch-based register file for ASIC targets |
+------------------------------+---------------------+------------+-----------------------------------------------------------------------+
| ``BranchTargetALU`` | bit | 0 | *EXPERIMENTAL* - Enables branch target ALU removing a stall |
| | | | cycle from taken branches |
| ``BranchTargetALU`` | bit | 0 | Enables branch target ALU removing a stall cycle from taken branches |
+------------------------------+---------------------+------------+-----------------------------------------------------------------------+
| ``WritebackStage`` | bit | 0 | *EXPERIMENTAL* - Enables third pipeline stage (writeback) |
| | | | improving performance of loads and stores |
| ``WritebackStage`` | bit | 0 | Enables third pipeline stage (writeback) improving performance of |
| | | | loads and stores |
+------------------------------+---------------------+------------+-----------------------------------------------------------------------+
| ``ICache`` | bit | 0 | *EXPERIMENTAL* Enable instruction cache instead of prefetch |
| | | | buffer |
| ``ICache`` | bit | 0 | Enable instruction cache instead of prefetch buffer |
+------------------------------+---------------------+------------+-----------------------------------------------------------------------+
| ``ICacheECC`` | bit | 0 | *EXPERIMENTAL* Enable SECDED ECC protection in ICache (if |
| | | | ICache == 1) |
| ``ICacheECC`` | bit | 0 | Enable SECDED ECC protection in ICache (if ICache == 1) |
+------------------------------+---------------------+------------+-----------------------------------------------------------------------+
| ``ICacheScramble`` | bit | 0 | Enabling this parameter replaces tag and data RAMs of ICache with |
| | | | scrambling RAM primitives. |
+------------------------------+---------------------+------------+-----------------------------------------------------------------------+
| ``BranchPrediction`` | bit | 0 | *EXPERIMENTAL* Enable Static branch prediction |
+------------------------------+---------------------+------------+-----------------------------------------------------------------------+
| ``SecureIbex`` | bit | 0 | *EXPERIMENTAL* Enable various additional features targeting |
| | | | secure code execution. Note: SecureIbex == 1'b1 and |
| | | | RV32M == ibex_pkg::RV32MNone is an illegal combination. |
| ``SecureIbex`` | bit | 0 | Enable various additional features targeting secure code execution. |
| | | | Note: SecureIbex == 1'b1 and RV32M == ibex_pkg::RV32MNone is an |
| | | | illegal combination. |
+------------------------------+---------------------+------------+-----------------------------------------------------------------------+
| ``RndCnstLfsrSeed`` | lfsr_seed_t | see above | Set the starting seed of the LFSR used to generate dummy instructions |
| | | | (only relevant when SecureIbex == 1'b1) |
+------------------------------+---------------------+------------+-----------------------------------------------------------------------+
| ``RndCnstLfsrPerm`` | lfsr_perm_t | see above | Set the permutation applied to the output of the LFSR used to |
| | | | generate dummy instructions (only relevant when SecureIbex == 1'b1) |
+------------------------------+---------------------+------------+-----------------------------------------------------------------------+
| ``DbgTriggerEn`` | bit | 0 | Enable debug trigger support (one trigger only) |
+------------------------------+---------------------+------------+-----------------------------------------------------------------------+
| ``DmBaseAddr`` | int | 0x1A110000 | Base address of the Debug Module |
+------------------------------+---------------------+------------+-----------------------------------------------------------------------+
| ``DmAddrMask`` | int | 0x1A110000 | Address mask of the Debug Module |
+------------------------------+---------------------+------------+-----------------------------------------------------------------------+
| ``DmHaltAddr`` | int | 0x1A110800 | Address to jump to when entering Debug Mode |
+------------------------------+---------------------+------------+-----------------------------------------------------------------------+
| ``DmExceptionAddr`` | int | 0x1A110808 | Address to jump to when an exception occurs while in Debug Mode |
@ -148,52 +250,75 @@ This is well supported by most tools but some care is needed when overriding the
Interfaces
----------
+-------------------------+-------------------------+-----+----------------------------------------+
| Signal(s) | Width | Dir | Description |
+=========================+=========================+=====+========================================+
| ``clk_i`` | 1 | in | Clock signal |
+-------------------------+-------------------------+-----+----------------------------------------+
| ``rst_ni`` | 1 | in | Active-low asynchronous reset |
+-------------------------+-------------------------+-----+----------------------------------------+
| ``test_en_i`` | 1 | in | Test input, enables clock |
+-------------------------+-------------------------+-----+----------------------------------------+
| ``hart_id_i`` | 32 | in | Hart ID, usually static, can be read |
| | | | from :ref:`csr-mhartid` CSR |
+-------------------------+-------------------------+-----+----------------------------------------+
| ``boot_addr_i`` | 32 | in | First program counter after reset |
| | | | = ``boot_addr_i`` + 0x80, |
| | | | see :ref:`exceptions-interrupts` |
+-------------------------+-------------------------+-----+----------------------------------------+
| ``instr_*`` | Instruction fetch interface, see :ref:`instruction-fetch` |
+-------------------------+------------------------------------------------------------------------+
| ``data_*`` | Load-store unit interface, see :ref:`load-store-unit` |
+-------------------------+------------------------------------------------------------------------+
| ``irq_*`` | Interrupt inputs, see :ref:`exceptions-interrupts` |
+-------------------------+------------------------------------------------------------------------+
| ``debug_*`` | Debug interface, see :ref:`debug-support` |
+-------------------------+-------------------------+-----+----------------------------------------+
| ``fetch_enable_i`` | 1 | in | When it comes out of reset, the core |
| | | | will not start fetching and executing |
| | | | instructions until it sees this pin |
| | | | set to 1'b1. Once started, it will |
| | | | continue until the next reset, |
| | | | regardless of the value of this pin. |
+-------------------------+-------------------------+-----+----------------------------------------+
| ``core_sleep_o`` | 1 | out | Core in WFI with no outstanding data |
| | | | or instruction accesses. Deasserts |
| | | | if an external event (interrupt or |
| | | | debug req) wakes the core up |
+-------------------------+-------------------------+-----+----------------------------------------+
| ``alert_minor_o`` | 1 | out | Core has detected a fault which it can |
| | | | safely recover from. Can be used by a |
| | | | system to log errors over time and |
| | | | detect tampering / attack. This signal |
| | | | is a pulse, one cycle per alert. |
+-------------------------+-------------------------+-----+----------------------------------------+
| ``alert_major_o`` | 1 | out | Core has detected a fault which cannot |
| | | | be recovered from. Can be used by a |
| | | | system to reset the core and possibly |
| | | | take other remedial action. This |
| | | | signal is a pulse, but might be set |
| | | | for multiple cycles per alert. |
+-------------------------+-------------------------+-----+----------------------------------------+
+----------------------------+-------------------------+-----+----------------------------------------+
| Signal(s) | Width | Dir | Description |
+============================+=========================+=====+========================================+
| ``clk_i`` | 1 | in | Clock signal |
+----------------------------+-------------------------+-----+----------------------------------------+
| ``rst_ni`` | 1 | in | Active-low asynchronous reset |
+----------------------------+-------------------------+-----+----------------------------------------+
| ``test_en_i`` | 1 | in | Test input, enables clock and allows |
| | | | test control of reset. |
+----------------------------+-------------------------+-----+----------------------------------------+
| ``scan_rst_ni`` | 1 | in | Test controlled reset. If DFT not |
| | | | used, tie off to 1. |
+----------------------------+-------------------------+-----+----------------------------------------+
| ``ram_cfg_i`` | 10 | in | RAM configuration inputs, routed to |
| | | | the icache RAMs |
+----------------------------+-------------------------+-----+----------------------------------------+
| ``hart_id_i`` | 32 | in | Hart ID, usually static, can be read |
| | | | from :ref:`csr-mhartid` CSR |
+----------------------------+-------------------------+-----+----------------------------------------+
| ``boot_addr_i`` | 32 | in | First program counter after reset |
| | | | = ``boot_addr_i`` + 0x80, |
| | | | see :ref:`exceptions-interrupts` |
+----------------------------+-------------------------+-----+----------------------------------------+
| ``instr_*`` | Instruction fetch interface, see :ref:`instruction-fetch` |
+----------------------------+------------------------------------------------------------------------+
| ``data_*`` | Load-store unit interface, see :ref:`load-store-unit` |
+----------------------------+------------------------------------------------------------------------+
| ``irq_*`` | Interrupt inputs, see :ref:`exceptions-interrupts` |
+----------------------------+-------------------------+-----+----------------------------------------+
| ``scramble_*`` | Scrambling key interface, see :ref:`icache` |
+----------------------------+------------------------------------------------------------------------+
| ``debug_*`` | Debug interface, see :ref:`debug-support` |
+----------------------------+------------------------------------------------------------------------+
| ``crash_dump_o`` | A set of signals that can be captured on reset to aid crash debugging. |
+----------------------------+------------------------------------------------------------------------+
| ``double_fault_seen_o`` | A double fault was observed, see :ref:`double-fault-detect` |
+----------------------------+-------------------------+-----+----------------------------------------+
| ``fetch_enable_i`` | 4 | in | Allow the core to fetch instructions. |
| | | | If this bit is set low, the core will |
| | | | pause fetching new instructions and |
| | | | immediately halt once any in-flight |
| | | | instructions in the ID/EX and WB |
| | | | stages have finished. A multi-bit |
| | | | encoding scheme is used. See |
| | | | `IbexMuBiOn` / `IbexMuBiOff` in |
| | | | :file:`rtl/ibex_pkg.sv` |
+----------------------------+-------------------------+-----+----------------------------------------+
| ``core_sleep_o`` | 1 | out | Core in WFI with no outstanding data |
| | | | or instruction accesses. Deasserts |
| | | | if an external event (interrupt or |
| | | | debug req) wakes the core up |
+----------------------------+-------------------------+-----+----------------------------------------+
| ``alert_minor_o`` | 1 | out | Core has detected a fault which it can |
| | | | safely recover from. Can be used by a |
| | | | system to log errors over time and |
| | | | detect tampering / attack. This signal |
| | | | is a pulse, one cycle per alert. |
+----------------------------+-------------------------+-----+----------------------------------------+
| ``alert_major_internal_o`` | 1 | out | Core has detected an internal fault |
| | | | which cannot be recovered from. Can be |
| | | | used by a system to reset the core and |
| | | | possibly take other remedial action. |
| | | | This signal is a pulse, but might be |
| | | | set for multiple cycles per alert. |
+----------------------------+-------------------------+-----+----------------------------------------+
| ``alert_major_bus_o`` | 1 | out | Core has detected a bus fault |
| | | | which cannot be recovered from. Can be |
| | | | used by a system to reset the core and |
| | | | possibly take other remedial action. |
| | | | This signal is a pulse, but might be |
| | | | set for multiple cycles per alert. |
+----------------------------+-------------------------+-----+----------------------------------------+

View file

@ -8,9 +8,10 @@ The following tools are known to work with the RTL code of Ibex.
Please `file an issue <https://github.com/lowRISC/ibex/issues>`_ if you experience problems with any of the listed tools, or if you have successfully used a tool with Ibex which is not listed here.
- Synopsys Design Compiler
- Xilinx Vivado
- Cadence Genus
- Xilinx Vivado, version |tool_requirements.vivado| and up.
- Verilator, version |tool_requirements.verilator| and up.
- Synopsys VCS
- Synopsys VCS, version at least |tool_requirements.vcs|.
- Cadence Incisive/Xcelium
- Mentor Questa
- Aldec Riviera Pro
@ -18,6 +19,10 @@ Please `file an issue <https://github.com/lowRISC/ibex/issues>`_ if you experien
To run the UVM testbench a RTL simulator which supports SystemVerilog and UVM 1.2 is required.
The `documentation of riscv-dv <https://github.com/google/riscv-dv#prerequisites>`_ contains a list of supported simulators.
To compile code that runs on Ibex, you'll need a RISC-V toolchain.
This isn't part of the core as such, but is necessary for verification.
See the :doc:`Verification <../03_reference/verification>` section of the Reference Guide for more details about which toolchains the project currently uses for testing.
Tools with known issues
-----------------------

177
doc/03_reference/cosim.rst Normal file
View file

@ -0,0 +1,177 @@
.. _cosim:
Co-simulation System
====================
Overview
--------
A co-simulation system is provided that can run in either the Ibex UVM DV environment or with Simple System.
This system runs a RISC-V ISS (currently only Spike is supported) in lockstep with an Ibex core.
All instructions executed by Ibex and memory transactions generated are checked against the behaviour of the ISS.
This system supports memory errors, interrupt and debug requests which are observed in the RTL simulation and forwarded to the ISS so the ISS and RTL remain in sync.
The system uses a generic interface to allow support of multiple ISSes.
Only VCS is supported as a simulator, though no VCS specific functionality is required so adding support for another simulator should be straight-forward.
To run the co-simulation system, a particular version of Spike is required (see the Setup and Usage section, below).
The RISC-V Formal Interface (RVFI) is used to provide information about retired instructions and instructions that produce synchronous traps for checking.
The RVFI has been extended to provide interrupt and debug information and the value of various CSRs that are harder to model (e.g. ``mcycle``).
These extended signals have the prefix ``rvfi_ext``
Setup and Usage
---------------
Clone the `lowRISC fork of Spike <https://github.com/lowRISC/riscv-isa-sim>`_ and check out the ``ibex-cosim-v0.5`` tag.
Other, later, versions called ``ibex-cosim-v*`` may also work but there's no guarantee of backwards compatibility.
Follow the Spike build instructions to build and install Spike.
The ``--enable-commitlog`` and ``--enable-misaligned`` options must be passed to ``configure``.
We recommend using a custom install location (using ``--prefix=<path>`` with ``configure``) to avoid cluttering system directories.
Note that, if you do this, you will also need to add an entry to ``PKG_CONFIG_PATH`` so that ``pkg-config`` can tell us how to build against the installed Spike libraries.
To build/run the UVM DV environment with the co-simulator, add the ``COSIM=1`` argument to the make command.
To build Simple System with the co-simulator, build the ``lowrisc:ibex:ibex_simple_system_cosim`` core.
Quick Build and Run Instructions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Build and install the co-simulator
.. code-block:: bash
# Get the Ibex co-simulation spike branch
git clone -b ibex_cosim https://github.com/lowRISC/riscv-isa-sim.git riscv-isa-sim-cosim
# Setup build directory
cd riscv-isa-sim-cosim
mkdir build
cd build
# Configure and build spike
../configure --enable-commitlog --enable-misaligned --prefix=/opt/spike-cosim
sudo make -j8 install
Run the UVM DV regression with co-simulation enabled
.. code-block:: bash
# Run regression with co-simulation enabled
cd <ibex_area>/dv/uvm/core_ibex
make COSIM=1
Build and run Simple System with the co-simulation enabled
.. code-block:: bash
# Build simulator
fusesoc --cores-root=. run --target=sim --setup --build lowrisc:ibex:ibex_simple_system_cosim --RV32E=0 --RV32M=ibex_pkg::RV32MFast
# Build coremark test binary, with performance counter dump disabled. The
# co-simulator system doesn't produce matching performance counters in spike so
# any read of those CSRs results in a mismatch and a failure.
make -C ./examples/sw/benchmarks/coremark SUPPRESS_PCOUNT_DUMP=1
# Run coremark binary with co-simulation checking
build/lowrisc_ibex_ibex_simple_system_cosim_0/sim-verilator/Vibex_simple_system --meminit=ram,examples/sw/benchmarks/coremark/coremark.elf
Co-simulation details
----------------------
The co-simulation system uses DPI calls to link the DV and ISS sides together.
A C++ interface is defined in ``dv/cosim/cosim.h`` with a DPI wrapper provided by ``dv/cosim/cosim_dpi.cc`` and ``dv/cosim/cosim_dpi.h``.
A ``chandle``, which points to some class instance that implements the interface, must be provided by the DV environment.
All the co-simulation DPI calls take this ``chandle`` as a first argument.
The details below discuss the C++ interface.
The DPI version of the interface is almost identical, with all functions prefaced with ``riscv_cosim`` and taking a ``chandle`` of the co-simulation instance to use.
The core function of the co-simulation interface is the ``step`` function:
.. code-block:: c++
virtual bool step(uint32_t write_reg, uint32_t write_reg_data, uint32_t pc, bool sync_trap);
``step`` takes arguments giving the PC of the most recently retired or synchronously trapping instruction in the DUT along with details of any register write that occurred.
Where ``step`` is provided with a retired (successfully executed) instruction it steps the ISS by one instruction and checks it executed the same instruction, with the same register write result, as the DUT.
When ``step`` is provided with an instruction that produces a synchronous trap, it checks the ISS also traps on the same instruction but does not step to the next executed instruction.
That instruction will be the first instruction of the trap handler and will be checked/stepped by the next call to ``step`` when it retires from the DUT.
Any data memory accesses that the ISS produces during the ``step`` are checked against observed DUT memory accesses.
``step`` returns false if any checks have failed.
If any errors occur during the step they can be accessed via ``get_errors`` which returns a vector of error messages.
For the DPI interface errors are accessed using ``riscv_cosim_get_num_errors`` and ``riscv_cosim_get_error``.
When errors have been checked they can be cleared with ``clear_errors``.
Trap Handling
^^^^^^^^^^^^^
Traps are separated into two categories, synchronous and asynchronous.
Synchronous traps are caused by a particular instruction's execution (e.g. an illegal instruction).
Asynchronous traps are caused by external interrupts.
Note that in Ibex error responses to both loads and store produce a synchronous trap so the co-simulation system has the same behaviour.
A synchronous trap is associated with a particular instruction and prevents that instruction from completing its execution.
That instruction doesn't retire, but is still made visible on the RVFI.
The ``rvfi_trap`` signal is asserted for an instruction that causes a synchronous trap.
As described above ``step`` should be called for any instruction that causes a synchronous trap to check the trap is also seen by the ISS.
An asynchronous trap can be seen as occurring between instructions and as such doesn't have an associated instruction, nothing will be seen on RVFI with ``rvfi_trap`` set.
The co-simulation system will immediately take any pending asynchronous trap when ``step`` is called, expecting the instruction checked with ``step`` to be the first instruction of the trap handler.
While a debug request is not strictly an asynchronous trap (it doesn't use the same exception handling mechanism), they work identically to asynchronous traps for the co-simulation system.
When a debug request is pending when ``step`` is called the co-simulation will expect the instruction checked by ``step`` to be the first instruction of the debug handler.
Interrupts and Debug Requests
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The DV environment must observe any incoming interrupts and debug requests generated by the testbench and notify the co-simulation system of them using ``set_mip``, ``set_debug_req`` and ``set_nmi``.
An interrupt or debug request will take immediate effect at the next ``step`` (if architecturally required to do so).
The DV environment is responsible for determining when to call ``set_mip``, ``set_debug_req`` and ``set_nmi`` to ensure a RTL and co-simulation match.
The state of the incoming interrupts and debug request is sampled when an instruction moves from IF to ID/EX.
The sampled state is tracked with the rest of the RVFI pipeline and used to call ``set_mip``, ``set_debug_req`` and ``set_nmi`` when the instruction is output by the RVFI.
A complication occurs when more than one interrupt or debug requests occur between individual instruction fetches.
One interrupt or debug request may take priority over another when they all occur together but when they occur in time is important as well.
If interrupt and debug request notification is associated exclusively with retired instructions the co-simulation system cannot correctly prioritise multiple interrupts and debug requests.
To deal with this the RVFI can also signal an interrupt event not associated with an instruction by setting ``rvfi_ext_irq_valid`` without setting ``rvfi_valid``.
When this is set the interrupt related RVFI signals are valid and provide the interrupt state.
The RVFI is used in this way, as opposed to a separate notification interface, so the interrupt notifications are ordered relative to the retired instructions.
See the comments in :file:`rtl/ibex_core.sv`, around the ``new_debug_req``, ``new_nmi``, ``new_irq`` and ``rvfi_irq_valid`` signals for further details.
Memory Access Checking and Bus Errors
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The co-simulation system must be informed of all Dside accesses performed by the RTL using ``notify_dside_access``.
See :file:`dv/cosim/cosim.h` for further details.
As Ibex doesn't perform speculative Dside memory accesses, all notified accesses are expected to match with accesses performed by the ISS in the same order they are notified.
Accesses notified via ``notify_dside_access`` can specify they saw an error response, the co-simulation system will produce the appropriate trap when the ISS attempts to access the address that saw the error.
Accesses must be notified before they occur in the ISS for the access matching and trapping on errors to work.
Iside accesses from Ibex can be speculative, so there is no simple link between accesses produced by the RTL and the accesses performed by the ISS for the Iside.
This means no direct checking of Iside accesses is done, however errors on the Iside accesses that result in an instruction fault trap need to be notified to the co-simulation system.
``set_iside_error`` does this, it is provided with the address that saw the bus error and it should be called immediately before the ``step`` that will process the trap.
The co-simulation system will produce an instruction fault trap if it attempts to access the provided error address in the ``step`` call following the ``set_iside_error`` call.
Two methods are available for dealing with bus errors on the Iside, they differ in where they probe.
One probes on the external instr_X memory interface, the other probes internally within the IF stage.
The probe used is selected by the ``probe_imem_for_err`` field of the ``core_ibex_cosim_cfg`` structure.
When set external probing is used, otherwise internal probing is used.
Both probe points look for addresses that have seen bus errors.
If an instruction entering ID/EX fetches from an address that has seen a bus error (as recorded by one of the probing methods) its ``rvfi_order_id`` is recorded.
When a faulting instruction is reported on the RVFI and its ``rvfi_order_id`` matches a recorded faulting one ``set_iside_error`` is called with the faulting address before the next ``step``.
The external interface probe should be used when it is guaranteed that a bus error to address A on the external interface results in a fetch error the next time an instruction with address A is observed entering the ID/EX stage (providing no successful access to A has occurred in the mean time).
Otherwise the internal probe should be used.
When Ibex is used with the prefetch buffer this guarantee holds and the external probe can be used.
When Ibex is used with the instruction cache this guarantee does not hold and the internal probe must be used.
Care should be taken when using the internal probe as it will miss any bug that causes instruction faults to be ignored by the prefetch buffer or ICache (or whatever else has been used in place of these by a custom implementation).
In the case of the Ibex ICache a separate testbench ensures instruction faults are dealt with appropriately within the ICache.

View file

@ -0,0 +1,446 @@
.. _coverage-plan:
Coverage Plan
=============
.. todo::
Branch prediction hasn't yet been considered, this will add more coverage points and alter some others
Introduction
------------
Ibex functional coverage is split into two major categories:
* Architectural coverage - which is concerned with instructions being executed and exercising various features of the RISC-V architecture (e.g. PMP) and does not consider the details of how this execution occurs.
* Microarchitectural coverage - which is concerned with the specifics of the RTL operation, ensuring interesting corner cases are seen along with various micro-architectural events (e.g. the different kinds of stall) and combinations of them.
Architectural coverage is not Ibex specific. It can be determined directly from a trace of executed instructions and is handled by RISCV-DV, details can be found in the `RISCV-DV documentation <https://htmlpreview.github.io/?https://github.com/google/riscv-dv/blob/master/docs/build/singlehtml/index.html#document-coverage_model>`_.
Microarchitectural coverage will probe the Ibex RTL directly and is described here.
There is some inevitable overlap between architectural and microarchitectural coverage but we aim to minimise it.
Coverage Implementation
-----------------------
All coverpoints and cross coverage defined below is associated with a name ``cp_name``.
This is the name of the coverpoint or cross that implements the described coverage.
Coverage is implemented in two files; :file:`dv/uvm/core_ibex/fcov/core_ibex_pmp_fcov_if.sv` for PMP related coverage and :file:`dv/uvm/core_ibex/fcov/core_ibex_fcov_if.sv` for everything else.
Microarchitectural Events and Behaviour
---------------------------------------
Below are lists of specific things from the microarchitecture that will be included in functional coverage.
Each of the points listed below must be covered.
This will be further combined using cross coverage which is described in the section below.
Instructions
^^^^^^^^^^^^
Categories
""""""""""
``cp_id_instr_category``
Instructions can be grouped into a number of categories.
Each category exercises different data and control paths in the core.
For example the ``ADD`` and ``SUB`` instructions are in the same category as they are almost identical for the microarchitecture (both read two registers and write to one, both feed operands to the ALU and take their result from it, both have the same response to interrupts etc; the only difference is the ALU operation).
Instructions can be compressed or uncompressed but that isn't factored into the instruction categories below (excepting for illegal instructions).
The decompression occurs in the IF stage and is invisible to the ID/EX stage so isn't relevant for instruction execution.
A separate set of category-agnostic compressed instruction behaviour is considered instead.
An instruction category is sampled at the ID/EX stage (which is where all the varying behaviours actually occur).
Some categories are just a single instruction, which is named without further description.
* **ALU** - All of the reg/reg reg/imm instructions that use the ALU.
This is any RISC-V instruction with an opcode of ``7'b0010011`` or ``7'b0110011`` (``ibex_pkg::OPCODE_OP`` and ``ibex_pkg::OPCODE_OP_IMM``) other than the ``MUL*`` and ``DIV*`` family of instructions (from RV32M).
* **Mul** - Any ``MUL*`` instruction (from RV32M).
* **Div** - Any ``DIV*`` instruction (from RV32M).
* **Branch** - Any ``B*`` family branch instruction.
* **Jump** - ``JAL``/``JALR``
* **Load** - Any ``L*`` family load instruction.
* **Store** - Any ``S*`` family load instruction.
* **CSRAccess** - Any instruction from Zicsr.
* **EBreakDbg**/**EBreakExc** - An ``EBREAK`` instruction that either enters debug mode (Dbg) or causes an exception (Exc).
Which occurs depends upon the setting of ``dcsr.ebreakm`` / ``dcsr.ebreaku`` combined with the privilege level of executed instruction.
* **ECall** - ``ECALL`` is an environment call used for escalation of privilege.
* **MRet** - ``MRET`` return out of M-mode
* **DRet** - ``DRET`` ruturn from debug mode.
* **WFI** - wait for interrupt.
* **Fence** - ``FENCE`` memory fence on the data side.
* **FenceI** - ``FENCE.I`` instruction fence instruction.
* **FetchError** - Any instruction that saw a fetch error.
* **CompressedIllegal** - Any compressed instruction with an illegal encoding.
* **UncompressedIllegal** - Any uncompressed instruction with an illegal encoding.
* **CSRIllegal** - Any instruction attempting a CSR access that is not allowed.
* **PrivIllegal** - Illegal due to privilege level or being in/out of debug mode.
* **OtherIllegal** - Any other instruction that raises an Illegal instruction exception that isn't in the other categories.
* **None** - No instruction in ID/EX stage.
Stalls
""""""
``cp_stall_type_id``
Not all instructions can see all kinds of stalls.
A stall category is sampled at the ID/EX stage only (as stalls in IF and WB don't break down into categories).
* **Instr** - A stall caused by a multi-cycle instruction.
This can be seen by instructions from categories:
* **MUL**
* **DIV**
* **Branch**
* **Jump**
* **LdHz** - A load hazard, the instruction in ID/EX depends upon the result of a load that is awaiting a response in writeback.
This can be seen by instructions from categories:
* **ALU**
* **Mul**
* **Div**
* **Branch**
* **Jump**
* **Load**
* **Store**
* **CSRAccess**
* **Mem** - Memory stall, the instruction in ID/EX is awaiting a prior memory request to complete before it can begin (to allow precise interrupts on a memory error response). This can be seen for all instruction categories
Privilege Level
"""""""""""""""
Ibex can operate at either the M (machine) or U (user) privilege levels.
Different aspects of the Ibex microarchitecture can be using different privilege levels at once.
* ``cp_priv_mode_id`` - Privilege level of ID/EX stage instruction.
* ``cp_priv_mode_lsu`` - Privilege level of LSU operation (ID/EX privilege level modified by ``mstatus.mprv`` and ``mstatus.mpp`` settings).
Note that the privilege level of the instruction in WB isn't retained by the microarchitecture and is not relevant to coverage.
The privilege level of the IF instruction is effectively unknown.
The instruction is checked when moving from IF to ID/EX against the ID stage privilege level to check if execution is permitted by PMP.
Any instruction that reaches WB can be considered bound to retire and any relevant checks and functionality altered by the privilege mode is dealt with at an earlier stage.
Hazards
"""""""
Ibex hazards all occur in the interaction between the ID and EX stage.
* RAW Reg - Read after write hazard, instruction in ID/EX reads a register that writeback is writing.
Split into two versions:
* RAW load - Instruction in ID/EX reading from destination of load in writeback.
Produces a stall (Category LdHz) and shouldn't forward data.
Covered by ``cp_stall_type_id``
* ``cp_wb_reg_no_load_hz`` - Instruction in writeback isn't a load.
Handled with data forwarding and no stall.
* RAW Load/Store bytes - Load with bytes overlapping a store immediately before it.
Covered by ``cp_mem_raw_hz``
State Specific Behaviour
""""""""""""""""""""""""
Some instructions will behave differently depending upon the state of the processor (e.g. the privilege level the instruction executes at, CSR settings or whether the processor is in debug mode).
* Instruction illegal in U Mode.
* ``cp_mret_in_umode`` - ``MRET``
* ``cp_wfi_in_umode`` - ``WFI``
* Read and write to M-mode CSR - Covered by crosses ``csr_write_priv_cross`` and ``csr_read_only_priv_cross```
* Debug mode instructions (cover execution in and out of debug mode).
* ``DRET``
* ``csr_read_only_debug_cross``, ``csr_write_debug_cross`` - Access to debug CSRs.
* ``dcsr``
* ``dpc``
* ``dscratch0``
* ``dscratch1``
* Access to trigger CSRs (also possible in M mode: cover execution in M mode, debug mode and U mode).
Covered by ``csr_read_only_debug_cross``, ``csr_write_debug_cross``, ``csr_read_only_priv_cross``, ``csr_write_priv_cross``.
* ``tselect``
* ``tdata1``
* ``tdata2``
* ``tdata3``
* Loads/stores with ``mstatus.mprv`` set and unset.
Covered by ``mprv_effect_cross``
* EBreak behaviour in U/M mode with different ``dcsr.ebreakm`` / ``dcsr.ebreaku`` settings.
Covered by ``priv_mode_instr_cross``
* ``cp_single_step_instr`` - Single step over every instruction category
Pipeline State
^^^^^^^^^^^^^^
Each pipeline stage has some associated state.
* ``cp_if_stage_state`` - IF stage full and fetching, full and idle, empty and fetching, or empty and idle.
General IF stage full and stalled uninteresting as will only occur when ID stage is full and stalled.
* ``cp_wb_stage_state`` - WB stage full and stalled, full and unstalled, or empty
* ``cp_id_stage_state`` - ID stage full and stalled, full and unstalled, or empty.
* Controller (within ID stage) state machine states
* ``cp_controller_fsm`` - Possible transitions between these states.
* ``RESET`` -> ``BOOT_SET``
* ``BOOT_SET`` -> ``FIRST_FETCH``
* ``FIRST_FETCH`` -> ``DECODE``
* ``FIRST_FETCH`` -> ``IRQ_TAKEN``
* ``FIRST_FETCH`` -> ``DBG_TAKEN_IF``
* ``DECODE`` -> ``FLUSH``
* ``DECODE`` -> ``DBG_TAKEN_IF``
* ``DECODE`` -> ``IRQ_TAKEN``
* ``IRQ_TAKEN`` -> ``DECODE``
* ``DBG_TAKEN_IF`` -> ``DECODE``
* ``DBG_TAKEN_ID`` -> ``DECODE``
* ``FLUSH`` -> ``DECODE``
* ``FLUSH`` -> ``DBG_TAKEN_ID``
* ``FLUSH`` -> ``WAIT_SLEEP``
* ``FLUSH`` -> ``DBG_TAKEN_IF``
* ``WAIT_SLEEP`` -> ``SLEEP``
* ``SLEEP`` -> ``FIRST_FETCH``
Exceptions/Interrupts/Debug
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Exceptions, interrupts and debug entry can all cause control flow changes combined with CSR writes and privilege level changes and work quite similarly within the controller but not identically.
Furthermore they can all occur together and must be appropriately prioritised (consider an instruction with hardware trigger point matching it, that causes some exception and an interrupt is raised the cycle it enters the ID/EX stage).
* Exception from instruction fetch error (covered by the **FetchError** instruction category).
* ``pmp_iside_mode_cross`` - Exception from instruction PMP violation.
* Exception from illegal instruction (covered by the illegal instruction categories).
* ``cp_ls_error_exception`` - Exception from memory fetch error.
* ``cp_ls_pmp_exception`` - Load store unit exception from PMP.
* ``pmp_dside_mode_cross`` - Exception from memory access PMP violation.
* Unaligned memory access
* ``misaligned_insn_bus_err_cross``, ``misaligned_data_bus_err_cross`` - Cover all error and no error scenarios for memory fetch error; first access saw error, second
access saw error, neither access saw error
* Interrupt raised/taken.
* ``cp_interrupt_taken`` - Interrupt raised/taken for each available interrupt line.
For cross coverage, the precise interrupt that's raised/taken is not relevant and it only needs to be grouped by NMI vs non-NMI.
This is done by using ``cp_nmi_taken`` coverpoint in the crosses.
* ``interrupt_taken_instr_cross`` - Interrupt raised/taken the first cycle an instruction is in ID/EX or some other cycle the instruction is in ID/EX.
* ``cp_debug_req`` - External debug request.
* ``cp_single_step_taken`` - Instruction executed when debug single step enabled.
* ``cp_single_step_exception`` - Single step over an instruction that takes an exception.
* ``cp_insn_trigger_enter_debug`` - Instruction matches hardware trigger point.
* ``cp_debug_mode`` - Ibex operating in debug mode.
* ``cp_debug_wakeup`` - Ibex wakes up after being halted from debug request.
* ``irq_wfi_cross``, ``debug_wfi_cross`` - Debug and Interrupt whilst sleeping with WFI
* Cover with global interrupts enabled and disabled
* Cover with specific interrupt enabled and disabled (Should exit sleep when
interrupt is enabled but global interrupts set to disabled, should continue
sleeping when both are disabled).
Continuing to sleep in the case explained above is covered by ``cp_irq_continue_sleep``, otherwise the behaviour is captured in ``irq_wfi_cross``
* Debug and interrupt occurring whilst entering WFI
* Covering period between WFI entering ID/EX stage and going into sleep
Covered by bin ``enter_sleep`` of ``cp_controller_fsm_sleep`` that is used by ``irq_wfi_cross`` and ``debug_wfi_cross``.
* ``cp_double_fault`` - Double fault
PMP
^^^
* ``cp_region_mode`` - Each region configured with different matching modes.
* Off
* TOR
* NA4
* NAPOT
* ``cp_napot_addr_modes`` - When NAPOT is enabled check that each address mode is seen at least once.
* ``cp_region_priv_bits`` - Each region configured with all possible permissions including locked/unlocked.
* Different permissions with MML enabled and disabled, separate cover points for R/W/X/L values with and without MML.
* Access fail & pass.
* ``misaligned_lsu_access_cross`` - All combinations of unaligned access split across a boundary, both halves pass, neither pass, just the first passes, just the second passes.
* Two possible boundary splits; across a 32-bit boundary within a region or a boundary between PMP regions.
* ``cp_pmp_iside_region_override``, ``cp_pmp_iside2_region_override``, ``cp_pmp_dside_region_override`` - Higher priority entry allows access that lower priority entry prevents.
* ``pmp_instr_edge_cross`` - Compressed instruction access (16-bit) passes PMP but 32-bit access at same address crosses PMP region boundary.
* Each field of mssecfg enabled/disabled, as well as written to using a CSR write, with relevant functionality tested.
* RLB - rule locking bypass.
* ``cp_edit_locked_pmpcfg``, ``cp_edit_locked_pmpaddr`` - Modify locked region with RLB set.
* ``rlb_csr_cross`` - Try to enable RLB when RLB is disabled and locked regions present.
* MMWP - machine mode whitelist policy.
* ``pmp_dside/iside/iside2_nomatch_cross`` - M-mode access fail due to not matching any PMP regions.
* ``mmwp_csr_cross`` - Try to disable when enabled.
* MML - machine mode lockdown policy.
* ``mml_sticky_cross`` - Try to disable when enabled.
* Access close to PMP region modification that allows/disallows that access.
* ``pmp_wr_exec_region`` - Explores behaviour around adding executable regions when MML is enabled.
Cross of current region configuration with region configuration that is being written and RLB setting.
It only considers regions that aren't currently executable with writes attempted to make them executable.
Non MML configurations are not sampled.
CSRs
^^^^
Basic read/write functionality must be tested on all implemented CSRs.
* ``cp_csr_read_only`` - Read from CSR, there is also ``cp_csr_invalid_read_only`` for illegal CSRs.
* ``cp_csr_write`` - Write to CSR, there is also ``cp_csr_invalid_write`` for illegal CSRs.
* Write to read only CSR.
Covered by ensuring ``cp_csr_write`` is seen for read-only CSRs
* ``cp_warl_check_CSRNAME`` - Write illegal/unsupported value to WARL field for CSR named ``CSRNAME``.
* ``csr_read_only_priv_cross``, ``csr_write_priv_cross``, ``csr_read_only_debug_cross``, ``csr_write_debug_cross`` - Crosses of reads and writes to CSRs from different privilege levels/debug mode.
* Access to CSR disallowed due to privilege levels/debug mode
Covered by ensuring within the crosses
CSRs addresses do not need to be crossed with the variety of CSR instructions as these all use the same basic read & write interface into ``ibex_cs_registers``.
Coverage of the above points will be sampled at the ``ibex_cs_registers`` interface (as opposed to sampling CSR instructions).
Security Countermeasures
^^^^^^^^^^^^^^^^^^^^^^^^
For more detail about each security countermeasure in Ibex see :ref:`security`
* ``cp_data_ind_timing`` - Enabling/Disabling "Data Independent Timing" feature.
* ``cp_data_ind_timing_instr`` - Executing each instruction category while data independent timing feature is enabled.
* ``cp_dummy_instr_en`` - Enabling/Disabling "Dummy Instruction Insertion" feature.
* ``cp_dummy_instr_mask`` - Frequency of injection for the dummy instructions.
* ``cp_dummy_instr_type`` - Type of the injected dummy instruction.
* ``cp_dummy_instr`` - Executing each instruction category while dummy instruction insertion feature is enabled.
* ``cp_dummy_instr_if_stage`` - The IF stage handles a dummy instruction.
* ``cp_dummy_instr_id_stage`` - The ID/EX stage handles a dummy instruction.
* ``cp_dummy_instr_wb_stage`` - The WB stage handles a dummy instruction.
* ``cp_rf_a_ecc_err``, ``cp_rf_b_ecc_err`` - Register file integrity (ECC) fault is seen for port A/B.
* ``cp_icache_ecc_err`` - ICache has seen an integrity (ECC) fault.
* ``cp_mem_load_ecc_err`` - An ECC error has been seen on a load response
* ``cp_mem_store_ecc_err`` - An ECC error has been seen on a store response
* ``cp_lockstep_err`` - Lockstep glitch fault seen.
* ``cp_rf_we_glitch_err`` - Register file write enable glitch fault seen.
* ``cp_pc_mismatch_err`` - PC mismatch error seen.
The :ref:`security features Ibex implements <security>` are given specific security countermeasure names in OpenTitan (see 'Security Countermeasures' in the `Comportability Definition and Specification <https://opentitan.org/book/doc/contributing/hw/comportability/index.html#security-countermeasures>`_ documentation section).
The mapping between security countermeasures and coverpoints that demonstrate it being used is given below.
+--------------------------------+-------------------------------------------------------+
| Security Countermeasure | Coverpoint(s) |
+================================+=======================================================+
| BUS.INTEGRITY | ``cp_mem_load_ecc_err`` ``cp_mem_store_ecc_err`` |
+--------------------------------+-------------------------------------------------------+
| SCRAMBLE.KEY.SIDELOAD | ``FENCE.I`` of ``cp_id_instr_category`` |
+--------------------------------+-------------------------------------------------------+
| CORE.DATA_REG_SW.SCA | ``cp_data_ind_timing`` ``cp_data_ind_timining_instr`` |
+--------------------------------+-------------------------------------------------------+
| PC.CTRL_FLOW.CONSISTENCY | ``cp_pc_mismatch_err`` |
+--------------------------------+-------------------------------------------------------+
| CTRL_FLOW.UNPREDICTABLE | ``cp_dummy_instr`` and related coverpoints |
+--------------------------------+-------------------------------------------------------+
| DATA_REG_SW.INTEGRITY | ``cp_rf_a_ecc_err`` ``cp_rf_b_ecc_err`` |
+--------------------------------+-------------------------------------------------------+
| DATA_REG_SW.GLITCH_DETECT | ``cp_rf_we_glitch_err`` |
+--------------------------------+-------------------------------------------------------+
| LOGIC.SHADOW | ``cp_lockstep_err`` |
+--------------------------------+-------------------------------------------------------+
| FETCH.CTRL.LC_GATED | ``cp_fetch_enable`` |
+--------------------------------+-------------------------------------------------------+
| EXCEPTION.CTRL_FLOW.LOCAL_ESC | ``cp_double_fault`` |
+--------------------------------+-------------------------------------------------------+
| EXCEPTION.CTRL_FLOW.GLOBAL_ESC | ``cp_double_fault`` |
+--------------------------------+-------------------------------------------------------+
| ICACHE.MEM.SCRAMBLE | ``FENCE.I`` of ``cp_id_instr_category`` |
+--------------------------------+-------------------------------------------------------+
| ICACHE.MEM.INTEGRITY | ``cp_icache_ecc_err`` |
+--------------------------------+-------------------------------------------------------+
Memory Interface Behaviour
^^^^^^^^^^^^^^^^^^^^^^^^^^
Covering different scenarios around timing of memory requests and responses and
related behaviour
* ``cp_dmem_response_latency``/``cp_imem_response_latency`` - Latency of response from request for dmem and imem.
Separated into two bins ``single_cycle`` (immediate response after request) and ``multi_cycle`` (all other latencies).
* ``dmem_req_gnt_valid``/``imem_req_gnt_rvalid`` - Request, grant and rvalid all seen in the same cycle for dmem and imem.
This means a response is seen the same cycle a new request is being granted.
Miscellaneous
^^^^^^^^^^^^^
Various points of interest do not fit into the categories above.
* ``instr_unstalled`` - Instruction unstalled - Cover the cycle an instruction is unstalled having just been stalled.
* ``cp_icache_enable`` - Enabling/Disabling ICache.
* ``cp_fetch_enable`` - Fetch enabled and disabled via top-level ``fetch_enable_i`` input.
Cross Coverage
--------------
Much of the more complex behaviour lies at the combination of the individual microarchitectural behaviours above.
Cross coverage is used to capture that.
Crosses listed below are ones that don't already fit into the above categories.
There are some broad crosses containing many bins aiming to capture all combinations of some generalised behaviours as well as some more specific ones to capture all combinations of behaviours focused on a particular area.
Cross coverage will be intentionally broad.
Where it is proving hard to hit particular bins they will be reviewed in more detail to determine if they're impossible to hit or if simply hard to hit and whether hitting them provides meaningful gains to verification quality.
Excluded bins will either become illegal bins (where they are impossible to hit, so a failure will be seen if they are hit) or ignore bins (where they don't factor into coverage statistics).
There must be a documented reason a particular bin is added to the illegal or ignore bins.
* ``pipe_cross`` - Instruction Categories x Pipeline stage states across IF, ID/EX and WB
* Covers all possibilities of instruction combinations that could fill the pipeline. State only for IF/WB suffices to cover this as all the interesting per instruction behaviour occurs in ID/EX.
* All bins containing instruction categories other than **None** ignored when ID/EX stage is empty.
* ``priv_mode_instr_cross`` - Instructions Categories x ID/EX Privilege level
* ``stall_cross`` - Instruction Categories x Stall Categories
* Illegal bins will be used to exclude instruction and stall categories that cannot occur.
* ``wb_reg_no_load_hz_instr_cross`` - Instruction Categories x Hazards
* ``stall_cross`` covers the RAW load hazard (as it produces a LdHz stall).
* RAW hazard between load/store requires no cross coverage as it's only seen for load and store instructions so the single coverpoint suffices.
* ``debug_instruction_cross`` - Instruction Categories x Debug Mode
* ``controller_instr_cross`` - Instruction Categories x Controller state transitions of interest
* ``interrupt_taken_instr_cross``, ``debug_entry_if_instr_cross``, ``pipe_flush_instr_cross`` - Interrupt taken/Debug mode entry/Pipe flush x instruction unstalled x instruction category
* Three separate cross coverage groups: one for interrupt, debug and pipe flush.
* Covers all instruction categories being interrupted/entering debug mode/flushing the pipeline both where this occurs during a stall and when it occurs just when they've unstalled.
* ``exception_stall_instr_cross`` - PMP exception x load/store error exception x instruction category x stall type x unstalled x irq pending x debug req
* Large cross to cover all possibilities of combinations between interrupt, debug and exceptions for all instruction categories across all stall behaviours.
* ``pmp_iside_priv_bits_cross``, ``pmp_iside2_priv_bits_cross``, ``pmp_dside_priv_bits_cross``, PMP regions x permissions x access fail/pass x privilege level
* Three crosses, one for each PMP channel (instruction, instruction 2 and data).
* ``dummy_instr_config_cross`` - Dummy Instruction Type x Dummy Instruction Insertion Frequency to explore all possible configurations.
* ``rf_ecc_err_cross`` - ECC Error on Port A x ECC Error on Port B to explore all possible combinations of reported ECC errors.
* ``debug_req_dummy_instr_{if,id,wb}_stage_cross`` - The IF, ID/EX, or WB stage handles a dummy instruction while a debug request arrives.
* ``irq_pending_dummy_instr_{if,id,wb}_stage_cross`` - The IF, ID/EX, or WB stage handles a dummy instruction while an IRQ is pending.

View file

@ -46,6 +46,12 @@ Ibex implements all the Control and Status Registers (CSRs) listed in the follow
+---------+--------------------+--------+-----------------------------------------------+
| 0x3BF | ``pmpaddr15`` | WARL | PMP Address Register |
+---------+--------------------+--------+-----------------------------------------------+
| 0x5A8 | ``scontext`` | WARL | Supervisor Context Register |
+---------+--------------------+--------+-----------------------------------------------+
| 0x747 | ``mseccfg`` | WARL | Machine Security Configuration |
+---------+--------------------+--------+-----------------------------------------------+
| 0x757 | ``mseccfgh`` | WARL | Upper 32 bits of ``mseccfg`` |
+---------+--------------------+--------+-----------------------------------------------+
| 0x7A0 | ``tselect`` | WARL | Trigger Select Register |
+---------+--------------------+--------+-----------------------------------------------+
| 0x7A1 | ``tdata1`` | WARL | Trigger Data Register 1 |
@ -56,7 +62,7 @@ Ibex implements all the Control and Status Registers (CSRs) listed in the follow
+---------+--------------------+--------+-----------------------------------------------+
| 0x7A8 | ``mcontext`` | WARL | Machine Context Register |
+---------+--------------------+--------+-----------------------------------------------+
| 0x7AA | ``scontext`` | WARL | Supervisor Context Register |
| 0x7AA | ``mscontext`` | WARL | Machine Supervisor Context Register |
+---------+--------------------+--------+-----------------------------------------------+
| 0x7B0 | ``dcsr`` | WARL | Debug Control and Status Register |
+---------+--------------------+--------+-----------------------------------------------+
@ -66,7 +72,7 @@ Ibex implements all the Control and Status Registers (CSRs) listed in the follow
+---------+--------------------+--------+-----------------------------------------------+
| 0x7B3 | ``dscratch1`` | RW | Debug Scratch Register 1 |
+---------+--------------------+--------+-----------------------------------------------+
| 0x7C0 | ``cpuctrl`` | WARL | CPU Control Register (Custom CSR) |
| 0x7C0 | ``cpuctrlsts`` | WARL | CPU Control and Status Register (Custom CSR) |
+---------+--------------------+--------+-----------------------------------------------+
| 0x7C1 | ``secureseed`` | WARL | Security feature random seed (Custom CSR) |
+---------+--------------------+--------+-----------------------------------------------+
@ -90,6 +96,12 @@ Ibex implements all the Control and Status Registers (CSRs) listed in the follow
+---------+--------------------+--------+-----------------------------------------------+
| 0xB9F | ``mhpmcounter31h`` | WARL | Upper 32 bits of ``mhmpcounter31`` |
+---------+--------------------+--------+-----------------------------------------------+
| 0xF11 | ``mvendorid`` | R | Machine Vendor ID |
+---------+--------------------+--------+-----------------------------------------------+
| 0xF12 | ``marchid`` | R | Machine Architecture ID |
+---------+--------------------+--------+-----------------------------------------------+
| 0xF13 | ``mimpid`` | R | Machine Implementation ID |
+---------+--------------------+--------+-----------------------------------------------+
| 0xF14 | ``mhartid`` | R | Hardware Thread ID |
+---------+--------------------+--------+-----------------------------------------------+
@ -101,7 +113,7 @@ Machine Status (mstatus)
CSR Address: ``0x300``
Reset Value: ``0x0000_1800``
Reset Value: ``0x0000_0080``
+-------+-----+---------------------------------------------------------------------------------+
| Bit# | R/W | Description |
@ -298,6 +310,29 @@ Reset Value: ``0x0000_0000``
| address[33:2] |
+----------------+
Machine Security Configuration (mseccfg/mseccfgh)
-------------------------------------------------
CSR Address: ``mseccfg``: ``0x747`` ``mseccfg``: ``0x757``
Reset Value: ``0x0000_0000_0000_0000``
+------+-----------------------------------------------------------------------------------------------------------------------------------+
| Bit# | Definition |
+------+-----------------------------------------------------------------------------------------------------------------------------------+
| 2 | **Rule Locking Bypass (RLB):** If set locked PMP entries can be modified |
+------+-----------------------------------------------------------------------------------------------------------------------------------+
| 1 | **Machine Mode Whitelist Policy (MMWP):** If set default policy for PMP is deny for M-Mode accesses that don't match a PMP region |
+------+-----------------------------------------------------------------------------------------------------------------------------------+
| 0 | **Machine Mode Lockdown (MML):** Alters behaviour of ``pmpcfgX`` bits |
+------+-----------------------------------------------------------------------------------------------------------------------------------+
``mseccfg`` is specified in the Trusted Execution Environment (TEE) working group proposal `PMP Enhancements for memory access and execution prevention on Machine mode (Smepmp) version 0.9.3 <https://github.com/riscv/riscv-tee/blob/61455747230a26002d741f64879dd78cc9689323/Smepmp/Smepmp.pdf>`_, which gives the full details of it's functionality including the new PMP behaviour when ``mseccfg.MML`` is set.
Note that the reset value means PMP behavior out of reset matches the RISC-V Privileged Architecture.
A write to ``mseccfg`` is required to change it.
Note ``mseccfgh`` reads as all 0s and ignores all writes.
Any access to ``mseccfg`` or ``mseccfgh`` when using an Ibex configuration without PMP (``PMPEnable`` is 0) will trigger an illegal instruction exception.
.. _csr-tselect:
Trigger Select Register (tselect)
@ -491,8 +526,8 @@ Reset Value: ``0x0000_0000``
Scratch register to be used by the debug module.
Accessible in Debug Mode only.
CPU Control Register (cpuctrl)
------------------------------
CPU Control and Status Register (cpuctrlsts)
--------------------------------------------
CSR Address: ``0x7C0``
@ -505,6 +540,21 @@ Other bit fields read as zero.
+-------+------+------------------------------------------------------------------+
| Bit# | R/W | Description |
+=======+======+==================================================================+
| 8 | R | **ic_scr_key_valid:** The icache scrambling key is valid. A |
| | | ``fence.i`` instruction is guaranteed to fetch a new key. If |
| | | the instruction cache has not been configured or the core has |
| | | not been configured with security features (ICache parameter |
| | | == 0 or SecureIbex parameter == 0), this field will always read |
| | | as zero. (see :ref:`icache-scramble-key`) |
+-------+------+------------------------------------------------------------------+
| 7 | RW | **double_fault_seen:** A synchronous exception was observed when |
| | | the ``sync_exc_seen`` field was set. This field must be manually |
| | | cleared, hardware only sets it (see :ref:`double-fault-detect`). |
+-------+------+------------------------------------------------------------------+
| 6 | RW | **sync_exc_seen:** A synchronous exception has been observed. |
| | | This flag is cleared when ``mret`` is executed. |
| | | (see :ref:`double-fault-detect`). |
+-------+------+------------------------------------------------------------------+
| 5:3 | WARL | **dummy_instr_mask:** Mask to control frequency of dummy |
| | | instruction insertion. If the core has not been configured with |
@ -549,6 +599,38 @@ The User Mode ``time(h)`` registers are not implemented in Ibex.
Any access to these registers will trap.
It is recommended that trap handler software provides a means of accessing platform-defined ``mtime(h)`` timers where available.
Machine Vendor ID (mvendorid)
-----------------------------
CSR Address: ``0xF11``
Reset Value: ``0x0000_0000``
Use the ``CSR_MVENDORID_VALUE`` parameter in :file:`rtl/ibex_pkg.sv` to change the fixed value.
Details of what the ID represents can be found in the RISC-V Privileged Specification.
Machine Architecture ID (marchid)
---------------------------------
CSR Address: ``0xF12``
Reset Value: ``0x0000_0016``
Use the ``CSR_MARCHID_VALUE`` parameter in :file:`rtl/ibex_pkg.sv` to change the fixed value.
The value used is allocated specifically to Ibex.
If significant changes are made a different ID should be used.
Details of what the ID represents can be found in the RISC-V Privileged Specification.
Machine Implementation ID (mimpid)
----------------------------------
CSR Address: ``0xF13``
Reset Value: ``0x0000_0000``
Use the ``CSR_MIMPID_VALUE`` parameter in :file:`rtl/ibex_pkg.sv` to change the fixed value.
Details of what the ID represents can be found in the RISC-V Privileged Specification.
.. _csr-mhartid:
Hardware Thread ID (mhartid)

View file

@ -3,7 +3,7 @@
Debug Support
=============
Ibex offers support for execution-based debug according to the `RISC-V Debug Specification <https://riscv.org/specifications/debug-specification/>`_, version 0.13.
Ibex offers support for execution-based debug according to the `RISC-V Debug Specification <https://github.com/riscv/riscv-debug-spec/blob/0.13-test-release/riscv-debug-spec.pdf>`_, version 0.13.
.. note::
@ -32,6 +32,10 @@ Parameters
+---------------------+-----------------------------------------------------------------+
| Parameter | Description |
+=====================+=================================================================+
| ``DmBaseAddr`` | Base address of the Debug Module |
+---------------------+-----------------------------------------------------------------+
| ``DmAddrMask`` | Address mask of the Debug Module |
+---------------------+-----------------------------------------------------------------+
| ``DmHaltAddr`` | Address to jump to when entering Debug Mode |
+---------------------+-----------------------------------------------------------------+
| ``DmExceptionAddr`` | Address to jump to when an exception occurs while in Debug Mode |

View file

@ -50,7 +50,8 @@ To enable interrupts, both the global interrupt enable (MIE) bit in the ``mstatu
For more information, see the :ref:`cs-registers` documentation.
If multiple interrupts are pending, they are handled in the priority order defined by the RISC-V Privileged Specification, version 1.11 (see Machine Interrupt Registers, Section 3.1.9).
The highest priority is given to the interrupt with the highest ID, except for timer interrupts, which have the lowest priority.
The fast interrupts have a platform defined priority.
In Ibex they take priority over all other interrupts and between fast interrupts the highest priority is given to the interrupt with the lowest ID.
The NMI is enabled independent of the values in the ``mstatus`` and ``mie`` CSRs, and it is not visible through the ``mip`` CSR.
It has interrupt ID 31, i.e., it has the highest priority of all interrupts and the core jumps to the trap-handler base address (in ``mtvec``) plus 0x7C to handle the NMI.
@ -62,6 +63,32 @@ It is assumed that the interrupt handler signals completion of the handling rout
In Debug Mode, all interrupts including the NMI are ignored independent of ``mstatus``.MIE and the content of the ``mie`` CSR.
.. _internal-interrupts:
Internal Interrupts
-------------------
Some events produce an 'internal interrupt'.
An internal interrupt produces an NMI (using the same vector as the external NMI) with ``mcause`` and ``mtval`` being set to indicate the cause of the internal interrupt.
The external NMI takes priority over all internal interrupts.
Entering the handler for an internal interrupt automatically clears the internal interrupt.
Internal interrupts are considered to be non-recoverable in general.
Specific details of how an internal interrupt relates to the event that triggers it are listed below.
Given these details it may be possible for software to recover from an internal interrupt under specific circumstances.
The possible ``mcause`` values for an internal interrupt are listed below:
+-------------+-------------------------------------------------------------------------------------------------------------+
| ``mcause`` | Description |
+-------------+-------------------------------------------------------------------------------------------------------------+
| 0xFFFFFFE0 | Load integrity error internal interrupt. |
| | Only generated when SecureIbex == 1. |
| | ``mtval`` gives the faulting address. |
| | The interrupt will be taken at most one instruction after the faulting load. |
| | In particular a load or store immediately after a faulting load may execute before the interrupt is taken. |
+-------------+-------------------------------------------------------------------------------------------------------------+
| 0x8000001F | External NMI |
+-------------+-------------------------------------------------------------------------------------------------------------+
Recoverable Non-Maskable Interrupt
----------------------------------
@ -98,6 +125,9 @@ Ibex can trigger an exception due to the following exception causes:
The illegal instruction exception, instruction access fault, LSU error exceptions and ECALL instruction exceptions cannot be disabled and are always active.
Note that Ibex cannot generated an 'instruction address misaligned' exception as all configurations implement the 'C' extension.
Under the RISC-V architecture it is simply not possible to branch or otherwise start executing from a PC that isn't 16-bit aligned.
So with 'C' implemented all possible PCs are appropriately aligned.
Nested Interrupt/Exception Handling
-----------------------------------
@ -147,3 +177,19 @@ The purpose of the nonstandard ``mstack`` CSRs in Ibex is only to support recove
These CSRs are not accessible by software.
While handling an NMI, all interrupts are ignored independent of ``mstatus``.MIE.
Nested NMIs are not supported.
.. _double-fault-detect:
Double Fault Detection
----------------------
Ibex has a mechanism to detect when a double fault has occurred.
A double fault is defined as a synchronous exception occurring whilst handling a previous synchronous exception.
The ``cpuctrl`` custom CSR has fields to provide software visibility and access to this mechanism.
When a synchronous exception occurs, Ibex sets ``cpuctrl``.sync_exception_seen.
Ibex clears ``cpuctrl``.sync_exception_seen when ``mret`` is executed.
If a synchronous exception occurs whilst ``cpuctrl``.sync_exception_seen is set, a double fault has been detected.
When a double fault is detected, the ``double_fault_seen_o`` output is asserted for one cycle and ``cpuctrl``.double_fault_seen is set.
Note that writing the ``cpuctrl``.double_fault_seen field has no effect on the ``double_fault_seen_o`` output.

View file

@ -93,6 +93,32 @@ Indicative RAM sizes for common configurations are given in the table below:
| 4kB, 4 way, 64bit line | 4 x 128 x 22bit | 4 x 128 x 64bit |
+------------------------------+-----------------+------------------+
ICache Scrambling
^^^^^^^^^^^^^^^^^
If ICacheScramble parameter is enabled, all RAM primitives are replaced with scrambling RAM primitive.
For more information about how scrambling works internally (see :file:`vendor/lowrisc_ip/ip/prim/doc/prim_ram_1p_scr.md`).
Interface for receiving scrambling key follows req / ack protocol.
Ibex first requests a new ephemeral key by asserting the request (``scramble_req_o``) and when a fresh valid key is indicated by ``scramble_key_valid_i``, it deasserts the request.
Note that in current implementation, it is assumed req/ack protocol is synchronized before arriving to Ibex top level.
.. _icache-scramble-key:
Scramble Key Renewal
^^^^^^^^^^^^^^^^^^^^
To get a new scrambling key execute a FENCE.I instruction.
With a new scrambling key the existing cache contents are effectively corrupt and will be invalidated by the FENCE.I.
Following a FENCE.I cache lookups will always miss until the invalidation is complete.
This allows CPU fetch and execution to continue using direct memory accesses whilst the scramble key request and cache invalidation proceeds in the background.
Should a second FENCE.I be executed before the first invalidation completes there are two possibilities
1. The request for a new scramble key is still in progress.
As a new request cannot begin whilst one is in progress the FENCE.I is ignored.
2. The request for a new scramble key has completed and the invalidation is in progress.
The invalidation stops and a new scramble key requested and the process starts over.
To guarantee a new scramble key ensure the ``ic_scr_key_valid`` bit in the ``cpuctrlsts`` CSR is set before executing the FENCE.I instruction.
Sub Unit Description
--------------------
@ -158,6 +184,8 @@ The remaining data from hits is buffered in the fill buffer data storage and sup
To deal with misalignment caused by compressed instructions, there is a 16bit skid buffer to store the upper halfword.
.. _icache-ecc:
Cache ECC protection
^^^^^^^^^^^^^^^^^^^^
@ -187,6 +215,7 @@ Any error (single or double bit) in any RAM will effectively cancel a cache hit
The request which observed an error will fetch it's data from the main instruction memory as normal for a cache miss.
The cache index and way (or ways) with errors are stored in IC1, and a cache write is forced the next cycle to invalidate that line.
Lookup requests will be blocked in IC0 while the invalidation write is performed.
If an ECC error is seen a minor alert will be signaled.
Cache invalidation
^^^^^^^^^^^^^^^^^^
@ -204,7 +233,7 @@ This isn't an attempt to describe the cache's performance characteristics.
The I$ has a single clock (``clk_i``) and asynchronous reset (``rst_ni``).
Data is requested from the instruction memory with the ports prefixed by ``instr_``. These work as described in :ref:`instruction-fetch`.
Note that there's one extra port on the I$, which doesn't appear at the ``ibex_core`` top-level.
Note that there's one extra port on the I$, which doesn't appear at the ``ibex_top`` top-level.
This is ``instr_pmp_err_i``.
If the PMP block disallows a fetch for a certain address, it will squash the outgoing memory request entirely and set ``instr_pmp_err_i``.
If that happens, the cache drops ``instr_req_o`` and stops making any further requests for that cache line.

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 76 KiB

Before After
Before After

File diff suppressed because it is too large Load diff

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 118 KiB

Before After
Before After

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 148 KiB

View file

@ -22,5 +22,9 @@ It describes the design in detail, discusses the verification approach and the r
debug
tracer
verification
verification_stages
cosim
testplan
coverage_plan
rvfi
history

View file

@ -56,7 +56,7 @@ Arithmetic Logic Unit (ALU)
---------------------------
Source File: :file:`rtl/ibex_alu.sv`
The Arithmetic Logic Logic (ALU) is a purely combinational block that implements operations required for the Integer Computational Instructions and the comparison operations required for the Control Transfer Instructions in the RV32I RISC-V Specification.
The Arithmetic Logic Unit (ALU) is a purely combinational block that implements operations required for the Integer Computational Instructions and the comparison operations required for the Control Transfer Instructions in the RV32I RISC-V Specification.
Other blocks use the ALU for the following tasks:
* Mult/Div uses it to perform addition as part of the multiplication and division algorithms
@ -64,46 +64,45 @@ Other blocks use the ALU for the following tasks:
* It computes memory addresses for loads and stores with a Reg + Imm calculation
* The LSU uses it to increment addresses when performing two accesses to handle an unaligned access
Bit Manipulation Extension
Support for the `RISC-V Bit Manipulation Extension (draft version 0.92 from November 8, 2019) <https://github.com/riscv/riscv-bitmanip/blob/master/bitmanip-0.92.pdf>`_ is optional. [#B_draft]_
Bit-Manipulation Extension
Support for the `RISC-V Bit-Manipulation Extension version 1.0.0 <https://github.com/riscv/riscv-bitmanip/releases/download/1.0.0/bitmanip-1.0.0-38-g865e7a7.pdf>`_ and `draft version 0.93 from January 10, 2021 <https://github.com/riscv/riscv-bitmanip/blob/master/bitmanip-0.93.pdf>`_ is optional. [#B_draft]_
It can be enabled via the enumerated parameter ``RV32B`` defined in :file:`rtl/ibex_pkg.sv`.
By default, this parameter is set to "ibex_pkg::RV32BNone" to disable the bit manipulation extension.
By default, this parameter is set to "ibex_pkg::RV32BNone" to disable the bit-manipulation extension.
There are two versions of the bit manipulation extension available:
The balanced implementation comprises a set of sub-extensions aiming for good benefits at a reasonable area overhead.
There are three versions of the bit-manipulation extension available:
The balanced version comprises a set of sub-extensions aiming for good benefits at a reasonable area overhead.
It can be selected by setting the ``RV32B`` parameter to "ibex_pkg::RV32BBalanced".
The full implementation comprises all 32 bit instructions defined in the extension.
This version can be selected by setting the ``RV32B`` parameter to "ibex_pkg::RV32BFull".
The following table lists the implemented instructions in each version.
The OTEarlGrey version comprises all sub-extensions except for the Zbe.
This version can be selected by setting the ``RV32B`` parameter to "ibex_pkg::RV32BOTEarlGrey".
The full version comprises all sub-extensions and can be selected by setting the ``RV32B`` parameter to "ibex_pkg::RV32BFull".
The following table gives an overview of which sub-extensions are implemented in each version and of which instructions are implemented as multi-cycle instructions.
Multi-cycle instructions are completed in 2 cycles.
All remaining instructions complete in a single cycle.
+---------------------------------+---------------+--------------------------+
| Z-Extension | Version | Multi-Cycle Instructions |
+=================================+===============+==========================+
| Zbb (Base) | Balanced/Full | rol, ror[i] |
+---------------------------------+---------------+--------------------------+
| Zbs (Single-bit) | Balanced/Full | None |
+---------------------------------+---------------+--------------------------+
| Zbp (Permutation) | Full | None |
+---------------------------------+---------------+--------------------------+
| Zbe (Bit extract/deposit) | Full | All |
+---------------------------------+---------------+--------------------------+
| Zbf (Bit-field place) | Balanced/Full | All |
+---------------------------------+---------------+--------------------------+
| Zbc (Carry-less multiply) | Full | None |
+---------------------------------+---------------+--------------------------+
| Zbr (CRC) | Full | All |
+---------------------------------+---------------+--------------------------+
| Zbt (Ternary) | Balanced/Full | All |
+---------------------------------+---------------+--------------------------+
| Zb_tmp (Temporary) [#B_zb_tmp]_ | Balanced/Full | None |
+---------------------------------+---------------+--------------------------+
+--------------------------------+---------+----------+------------+------+--------------------+
| Bit-Manipulation Sub-Extension | Spec. | Balanced | OTEarlGrey | Full | Multi-Cycle Instr. |
+================================+=========+==========+============+======+====================+
| Zba (Address generation) | v.1.0.0 | X | X | X | None |
+--------------------------------+---------+----------+------------+------+--------------------+
| Zbb (Base) | v.1.0.0 | X | X | X | rol, ror[i] |
+--------------------------------+---------+----------+------------+------+--------------------+
| Zbc (Carry-less multiply) | v.1.0.0 | | X | X | None |
+--------------------------------+---------+----------+------------+------+--------------------+
| Zbs (Single-bit) | v.1.0.0 | X | X | X | None |
+--------------------------------+---------+----------+------------+------+--------------------+
| Zbe (Bit compress/decompress) | v.0.93 | | | X | All |
+--------------------------------+---------+----------+------------+------+--------------------+
| Zbf (Bit-field place) | v.0.93 | X | X | X | All |
+--------------------------------+---------+----------+------------+------+--------------------+
| Zbp (Permutation) | v.0.93 | | X | X | None |
+--------------------------------+---------+----------+------------+------+--------------------+
| Zbr (CRC) | v.0.93 | | X | X | All |
+--------------------------------+---------+----------+------------+------+--------------------+
| Zbt (Ternary) | v.0.93 | X | X | X | All |
+--------------------------------+---------+----------+------------+------+--------------------+
The implementation of the B-extension comes with an area overhead of 1.8 to 3.0 kGE for the balanced version and 6.0 to 8.7 kGE for the full version.
That corresponds to an approximate percentage increase in area of 9 to 14 % and 25 to 30 % for the balanced and full versions respectively.
The ranges correspond to synthesis results generated using relaxed and maximum frequency targets respectively.
The designs have been synthesized using Synopsys Design Compiler targeting TSMC 65 nm technology.
The implementation of the Bit-Manipulation Extension comes with an area overhead of 2.7 kGE for the balanced version, 6.1 kGE for the OTEarlGrey version, and 7.5 kGE for the full version.
These numbers were obtained by synthesizing the design with Yosys and relaxed timing constraints.
.. _mult-div:
@ -173,11 +172,9 @@ See :ref:`load-store-unit` for more details.
.. rubric:: Footnotes
.. [#B_draft] Ibex fully implements draft version 0.92 of the RISC-V Bit Manipulation Extension.
This extension may change before being ratified as a standard by the RISC-V Foundation.
.. [#B_draft] Ibex fully implements the ratified version 1.0.0 of the RISC-V Bit-Manipulation Extension including the Zba, Zbb, Zbc and Zbs sub-extensions.
In addition, Ibex also supports the remaining Zbe, Zbf, Zbp, Zbr and Zbt sub-extensions as defined in draft version 0.93 of the RISC-V Bit-Manipulation Extension.
Note that the latter sub-extensions may change before being ratified as a standard by the RISC-V Foundation.
Ibex will be updated to match future versions of the specification.
Prior to ratification this may involve backwards incompatible changes.
Additionally, neither GCC or Clang have committed to maintaining support upstream for unratified versions of the specification.
.. [#B_zb_tmp] The sign-extend instructions `sext.b/sext.h` are defined but not unambiguously categorized in draft version 0.92 of the extension.
Temporarily, they have been assigned a separate Z-extension (Zb_tmp) both in Ibex and the RISCV-DV random instruction generator used to verify the bit manipulation instructions in Ibex.

View file

@ -45,26 +45,28 @@ The main difference is that the instruction interface does not allow for write t
.. tabularcolumns:: |p{4cm}|l|p{9cm}|
+-------------------------+-----------+-----------------------------------------------+
| Signal | Direction | Description |
+=========================+===========+===============================================+
| ``instr_req_o`` | output | Request valid, must stay high until |
| | | ``instr_gnt_i`` is high for one cycle |
+-------------------------+-----------+-----------------------------------------------+
| ``instr_addr_o[31:0]`` | output | Address, word aligned |
+-------------------------+-----------+-----------------------------------------------+
| ``instr_gnt_i`` | input | The other side accepted the request. |
| | | ``instr_req_o`` may be deasserted in the next |
| | | cycle. |
+-------------------------+-----------+-----------------------------------------------+
| ``instr_rvalid_i`` | input | ``instr_rdata_i`` holds valid data when |
| | | ``instr_rvalid_i`` is high. This signal will |
| | | be high for exactly one cycle per request. |
+-------------------------+-----------+-----------------------------------------------+
| ``instr_rdata_i[31:0]`` | input | Data read from memory |
+-------------------------+-----------+-----------------------------------------------+
| ``instr_err_i`` | input | Memory access error |
+-------------------------+-----------+-----------------------------------------------+
+-----------------------------+-----------+-----------------------------------------------+
| Signal | Direction | Description |
+=============================+===========+===============================================+
| ``instr_req_o`` | output | Request valid, must stay high until |
| | | ``instr_gnt_i`` is high for one cycle |
+-----------------------------+-----------+-----------------------------------------------+
| ``instr_addr_o[31:0]`` | output | Address, word aligned |
+-----------------------------+-----------+-----------------------------------------------+
| ``instr_gnt_i`` | input | The other side accepted the request. |
| | | ``instr_req_o`` may be deasserted in the next |
| | | cycle. |
+-----------------------------+-----------+-----------------------------------------------+
| ``instr_rvalid_i`` | input | ``instr_rdata_i`` holds valid data when |
| | | ``instr_rvalid_i`` is high. This signal will |
| | | be high for exactly one cycle per request. |
+-----------------------------+-----------+-----------------------------------------------+
| ``instr_rdata_i[31:0]`` | input | Data read from memory |
+-----------------------------+-----------+-----------------------------------------------+
| ``instr_rdata_intg_i[6:0]`` | input | Data integrity bits from memory |
+-----------------------------+-----------+-----------------------------------------------+
| ``instr_err_i`` | input | Memory access error |
+-----------------------------+-----------+-----------------------------------------------+
Misaligned Accesses

View file

@ -14,39 +14,60 @@ Data-Side Memory Interface
Signals that are used by the LSU:
+-------------------------+-----------+-----------------------------------------------+
| Signal | Direction | Description |
+=========================+===========+===============================================+
| ``data_req_o`` | output | Request valid, must stay high until |
| | | ``data_gnt_i`` is high for one cycle |
+-------------------------+-----------+-----------------------------------------------+
| ``data_addr_o[31:0]`` | output | Address, word aligned |
+-------------------------+-----------+-----------------------------------------------+
| ``data_we_o`` | output | Write Enable, high for writes, low for |
| | | reads. Sent together with ``data_req_o`` |
+-------------------------+-----------+-----------------------------------------------+
| ``data_be_o[3:0]`` | output | Byte Enable. Is set for the bytes to |
| | | write/read, sent together with ``data_req_o`` |
+-------------------------+-----------+-----------------------------------------------+
| ``data_wdata_o[31:0]`` | output | Data to be written to memory, sent together |
| | | with ``data_req_o`` |
+-------------------------+-----------+-----------------------------------------------+
| ``data_gnt_i`` | input | The other side accepted the request. |
| | | Outputs may change in the next cycle. |
+-------------------------+-----------+-----------------------------------------------+
| ``data_rvalid_i`` | input | ``data_err_i`` and ``data_rdata_i`` hold |
| | | valid data when ``data_rvalid_i`` is high. |
| | | This signal will be high for exactly one |
| | | cycle per request. |
+-------------------------+-----------+-----------------------------------------------+
| ``data_err_i`` | input | Error response from the bus or the memory: |
| | | request cannot be handled. High in case of an |
| | | error. |
+-------------------------+-----------+-----------------------------------------------+
| ``data_rdata_i[31:0]`` | input | Data read from memory |
+-------------------------+-----------+-----------------------------------------------+
+----------------------------+-----------+-----------------------------------------------+
| Signal | Direction | Description |
+============================+===========+===============================================+
| ``data_req_o`` | output | Request valid, must stay high until |
| | | ``data_gnt_i`` is high for one cycle |
+----------------------------+-----------+-----------------------------------------------+
| ``data_addr_o[31:0]`` | output | Address, word aligned |
+----------------------------+-----------+-----------------------------------------------+
| ``data_we_o`` | output | Write Enable, high for writes, low for |
| | | reads. Sent together with ``data_req_o`` |
+----------------------------+-----------+-----------------------------------------------+
| ``data_be_o[3:0]`` | output | Byte Enable. Is set for the bytes to |
| | | write/read, sent together with ``data_req_o`` |
+----------------------------+-----------+-----------------------------------------------+
| ``data_wdata_o[31:0]`` | output | Data to be written to memory, sent together |
| | | with ``data_req_o`` |
+----------------------------+-----------+-----------------------------------------------+
| ``data_wdata_intg_o[6:0]`` | output | Integrity bits to be written to memory, sent |
| | | together with ``data_req_o`` (not used unless |
| | | the SecureIbex parameter is set) |
+----------------------------+-----------+-----------------------------------------------+
| ``data_gnt_i`` | input | The other side accepted the request. |
| | | Outputs may change in the next cycle. |
+----------------------------+-----------+-----------------------------------------------+
| ``data_rvalid_i`` | input | ``data_err_i`` and ``data_rdata_i`` hold |
| | | valid data when ``data_rvalid_i`` is high. |
| | | This signal will be high for exactly one |
| | | cycle per request. |
+----------------------------+-----------+-----------------------------------------------+
| ``data_err_i`` | input | Error response from the bus or the memory: |
| | | request cannot be handled. High in case of an |
| | | error. |
+----------------------------+-----------+-----------------------------------------------+
| ``data_rdata_i[31:0]`` | input | Data read from memory |
+----------------------------+-----------+-----------------------------------------------+
| ``data_rdata_intg_i[6:0]`` | input | Integrity bits read from memory (ignored |
| | | unless the SecureIbex parameter is set) |
+----------------------------+-----------+-----------------------------------------------+
Bus Integrity Checking
----------------------
The core can optionally generate and verify check bits sent alongside the data for memory accesses.
Checkbits are generated and checked using an inverted 39/32 Hsaio code (see :file:`vendor/lowrisc_ip/ip/prim/rtl/prim_secded_inv_39_32_enc.sv`).
An :ref:`internal interrupt<internal-interrupts>` will be generated and a bus major alert signalled if there is a mismatch.
Where load data has bad checkbits the write to the load's destination register will be suppressed.
Ibex checks the integrity against the response data for both loads and stores.
For stores the response data is otherwise ignored so the data can be any value provided the integrity is valid (``data_rdata_intg_i`` must match with ``data_rdata_i``).
It is recommended for write responses some fixed value is placed on ``data_rdata_i`` and ``data_rdata_intg_i`` by the memory system Ibex is connected to in configurations where integrity is used.
This feature is only used if the core is configured with the SecureIbex parameter set.
For all other configurations, the integrity signals can be ignored.
Misaligned Accesses
-------------------

View file

@ -26,7 +26,7 @@ See Multi- and Single-Cycle Instructions below for the details.
Third Pipeline Stage
--------------------
Ibex can be configured to have a third pipeline stage (Writeback) which has major effects on performance and instruction behaviour.
This feature is *EXPERIMENTAL* and the details of its impact are not yet documented here.
The details of its impact are not yet documented here.
All of the information presented below applies only to the two stage pipeline provided in the default configurations.
Multi- and Single-Cycle Instructions

View file

@ -3,7 +3,7 @@
Physical Memory Protection (PMP)
================================
The Physical Memory Protection (PMP) unit implements region-based memory access checking in-accordance with the RISC-V Privileged Specification, version 1.11.
The Physical Memory Protection (PMP) unit implements region-based memory access checking in-accordance with the RISC-V Privileged Specification, version 1.12 and implements the `PMP Enhancements for memory access and execution prevention on Machine mode (Smepmp) version 1.0 <https://github.com/riscv/riscv-tee/blob/191b563b08b31cc2974d604a3b670d8666a2e093/Smepmp/Smepmp.pdf>`_ extension.
The following configuration parameters are available to control PMP checking:
+----------------+---------------+----------------------------------------------------------+
@ -30,3 +30,31 @@ PMP Granularity
The PMP granularity parameter is used to reduce the size of the address matching comparators by increasing the minimum region size.
When the granularity is greater than zero, NA4 mode is not available and will be treated as OFF mode.
.. _pmp-enhancements:
PMP Enhancements
----------------
These are described in more detail in `PMP Enhancements for memory access and execution prevention on Machine mode (Smepmp) version 1.0 <https://github.com/riscv/riscv-tee/blob/191b563b08b31cc2974d604a3b670d8666a2e093/Smepmp/Smepmp.pdf>`_.
If Ibex is configured to include PMP (PMPEnable is not zero) the PMP enhancements are always included.
Use of the enhanced behavior is optional, if no writes to ``mseccfg`` occur PMP behavior will remain exactly as if Smepmp was not implemented.
The enhancements add:
* A new CSR ``mseccfg`` providing functionality to allow locked regions to be modified and to implement default deny for M-mode accesses.
* New PMP region configurations which are U-Mode or M-Mode accessible only with varying read/write/execute settings along with some shared U and M mode accessible configurations.
These new configurations supersede the original ones and are enabled via ``mseccfg``.
Custom Reset Values
-------------------
By default all PMP CSRs (include ``mseccfg``) are reset to 0.
Some applications may want other reset values.
Default reset values are defined in :file:`ibex_pkg.sv`.
An implementation can either modify this file or pass custom reset values as a module parameter.
Debug Mode
----------
In debug mode, the PMP allows all accesses to addresses of the Debug Module, as defined by the `DmBaseAddr` and `DmAddrMask` module parameters.
This is mandated by the RISC-V Debug Specification (v1.0.0).

View file

@ -9,8 +9,9 @@ All features are runtime configurable via bits in the **cpuctrl** custom CSR.
Outputs
-------
Ibex has two alert outputs for signalling security issues.
The major alert (**alert_major_o**) indicates a critical security issue from which the core cannot recover.
Ibex has three alert outputs for signalling security issues.
The internal major alert (**alert_major_internal_o**) indicates a critical security issue from which the core cannot recover which was detected internally in `ibex_top`.
The bus major alert (**alert_major_internal_o**) indicates a critical security issue from which the core cannot recover which was detected on incoming bus data.
The minor alert (**alert_minor_o**) indicates potential security issues which can be monitored over time by a system.
Data Independent Timing
@ -21,10 +22,20 @@ This makes it more difficult for an external observer to infer secret data by ob
In Ibex, most instructions already execute independent of their input operands.
When data-independent timing is enabled:
* Branches execute identically regardless of their taken/not-taken status
* Early completion of multiplication by zero/one is removed
* Early completion of divide by zero is removed
Note that data memory operations to unaligned addresses might result in multiple bus accesses being made.
This in turn could expose information about the address as a timing side-channel.
It is therefore recommended to stick to aligned memory accesses when using this feature for critical code regions.
When Ibex is configured to use an instruction cache, stalls on instruction fetch can see variable latency (depending on whether or not they hit in the cache).
Software that has need of data independent timing may wish to disable the instruction cache to avoid this or to carefully analyse execution to determine if variable latency introduced by the cache causes unacceptable leakage.
The instruction cache is controlled by the **icache_enable** bit in the **cpuctrl** register.
Precise details of fetch timing will depend upon the memory system Ibex is connected to.
Dummy Instruction Insertion
---------------------------
@ -49,18 +60,51 @@ The frequency of injected instructions can be tuned via the **dummy_instr_mask**
Other values of **dummy_instr_mask** are legal, but will have a less predictable impact.
The interval between instruction insertion is randomized in the core using an LFSR.
The initial seed and output permutation for this LFSR can be set using parameters from the top-level of Ibex.
Sofware can periodically re-seed this LFSR with true random numbers (if available) via the **secureseed** CSR.
This will make the insertion interval of dummy instructions much harder for an attacker to predict.
Note that the dummy instruction feature inserts multiply and divide instructions.
The core must be configured with a multiplier (`RV32M != ibex_pkg::RV32MNone`) or errors will occur using this feature.
Bus integrity checking
----------------------
Extra signals are available alongside the instruction and data side memory channels to support bus integrity checking.
When the SecureIbex parameter is set, incoming data will be checked against the supplied checkbits.
An :ref:`internal interrupt<internal-interrupts>` will be generated and a bus major alert signalled if there is a mismatch.
Where load data has bad checkbits the write to the load's destination register will be suppressed.
Write data can be checked against the supplied checkbits at its destination to confirm integrity.
Register file ECC
-----------------
When Ibex is configured with the SecureIbex parameter, ECC checking is added to all reads of the register file.
This can be useful to detect fault injection attacks since the register file covers a reasonably large area.
No attempt is made to correct detected errors, but an external alert is raised for the system to take action.
No attempt is made to correct detected errors, but an internal major alert is signaled for the system to take action.
Register file write enable glitch detection
-------------------------------------------
When Ibex is configured with the SecureIbex parameter, the write enable signal into the register file is checked to be one-hot.
This can be useful to detect fault injection attacks.
No attempt is made to correct detected errors, but an internal major alert is signaled for the system to take action.
Register file read addresses glitch detection
-------------------------------------------
When Ibex is configured with the SecureIbex parameter, the read addresses provided to the register file are converted to one-hot encoded signals, and a one-hot encoded MUX is used to select the register to read from.
By using one-hot encoding checkers, glitches in the one-hot encoded signals are detected.
Bit-flips inside the plain read addresses before the one-hot conversion happens are detected by the dual core lockstep.
This can be useful to detect fault injection attacks.
No attempt is made to correct detected errors, but an internal major alert is signaled for the system to take action.
ICache ECC
----------
The ICache can be configured with ECC protection.
When an ECC error is detected a minor alert is signaled.
See :ref:`icache-ecc` for more information.
Hardened PC
-----------
@ -68,11 +112,22 @@ Hardened PC
This adds a check that the PC driven from the IF stage has not been modified.
A check is asserted that the current IF stage PC equals the previous PC plus the correct increment.
The check is disabled after branches and after reset.
If a mismatch is detected, a major alert is signaled.
If a mismatch is detected, an internal major alert is signaled.
Shadow CSRs
-----------
Certain critical CSRs (`mstatus`, `mtvec`, `cpuctrl`, `pmpcfg` and `pmpaddr`) have extra glitch detection enabled.
This creates a second copy of the register which stores a complemented version of the main CSR data.
A constant check is made that the two copies are consistent, and a major alert is signalled if not.
A constant check is made that the two copies are consistent, and an internal major alert is signalled if not.
Note that this feature is not currently used when the SecureIbex parameter is set due to overlap with dual core lockstep.
Dual core lockstep
------------------
This configuration option instantiates a second copy of the core logic, referred to as the shadow core.
The shadow core executes using a delayed version of all inputs supplied to the main core.
All outputs of the shadow core are compared against a delayed version of the outputs of the main core.
Any mismatch between the two sets of outputs will trigger an internal major alert.
Note that the register file and icache RAMs are not duplicated since these units are covered by ECC protection.

View file

@ -0,0 +1,109 @@
.. _testplan:
.. todo::
Add detail about security hardening verification.
.. note::
This testplan is a work in progress still being implemented so this document may not match the implemented verification in the repository.
Test Plan
=========
Goals
-----
* Verify compliance with all the RISC-V specifications Ibex supports.
* Verify Ibex's security hardening features.
* Ensure correct functionality is maintained across all possible behaviours of external interfaces (interrupts, memory responses, debug requests etc).
* Hit all functional coverage points, described in :ref:`coverage-plan`.
Testbench Architecture
----------------------
.. figure:: images/tb2.svg
:alt: Testbench Architecture
Architecture of the UVM testbench for Ibex core
Ibex utilises a co-simulation checking approach described in detail in :ref:`cosim`.
With the co-simulation system all instructions Ibex executes and all external events such as an interrupts or memory errors are fed to a golden model.
The results of every instruction execution and every memory access are crossed checked against the golden model with any mismatches resulting in a test failure.
The aim is to check all possible externally observable behaviours of ``ibex_top`` against the golden model.
The golden model used is the `Spike RISC-V ISS <https://github.com/riscv-software-src/riscv-isa-sim>`_.
The testbench uses UVM.
It consists of 3 agents:
Co-simulation Agent:
This has multiple monitors.
One monitors the RVFI interface which provides details of retired instructions.
The other monitors relate to fetched instructions and instruction memory errors; more details are provided in :ref:`coverage-plan`.
Additionally it connects to the monitor of the Memory Interface Agent for the instruction and data side via analysis ports.
The monitored transactions are used by a scoreboard to provide information to the co-simulation system allowing it to step the golden model and check its execution and memory activity against Ibex's behaviour.
Memory Interface Agent
This provides a driver and a monitor for the :ref:`Ibex Memory Interface Protocol<lsu-protocol>`.
The driver provides fully randomised and configurable timings for responses and randomisation of error responses.
Two agents are instantiated; one for the data memory interface the other for the instruction memory interface.
Read data for memory responses is provided from a backing memory; write requests update the contents of the backing memory.
This is separate from the memory used by the golden model in the co-simulation agent.
The contents of these two memories will be identical unless there is a mismatch resulting in a failure.
The backing memory is held in a memory model as a separate UVM component.
The two agents use the same backing memory so they have a coherent view of memory.
IRQ Agent
This provides a driver and a monitor for the IRQ interface.
It provides randomised interrupt stimulus to Ibex when a test requests it.
Constraints can be used to control types of interrupts generated (e.g. NMI or not) and whether multiple interrupts should be raised together.
Debug and reset signals are a single wire each so do not have a dedicated agent.
Instead any sequence that wishes to use them will directly manipulate them via a virtual interface
The testbench instantiates the agents described above along with the memory model used by both the data and instruction side memory agents.
A test consists of executing a pre-built binary (which is loaded into the memory model at the start of the test via backdoor accesses) along with configuring agents to provide appropriate stimulus for the test.
Some tests may use the agents to generate stimulus at particular times (e.g. interrupts).
A test may perform additional checking on top of the co-simulation golden model comparison where appropriate (e.g. ensuring a raised interrupt has caused an exception).
Stimulus Strategy
-----------------
Stimulus falls into two categories:
* Instructions to execute: These are generated by the `RISC-V DV random instruction <https://github.com/google/riscv-dv>`_ generator and provided to the testbench via a raw binary file.
* Activity on external interfaces.
Instructions are generated ahead of time so the test has no control over them at run time.
All external interfaces have their stimulus generated at run time so can be controlled by the test.
It is the responsibility of the regression run environment to ensure generated instructions are matched with appropriate tests (e.g. ensuring an exception handler is present where interrupts are expected).
Stimulus generation will use a coverage based approach.
Stimulus is developed based upon the :ref:`coverage-plan`.
Where coverage is not being hit stimulus will be added to hit it.
Tests
-----
As with stimulus, test sequence development uses a coverage based approach.
Tests will be added such that all coverage in the :ref:`coverage-plan` can be hit.
Not all the details of specific tests will be documented here.
The test list (`dv/uvm/core_ibex/riscv_dv_extension/testlist.yaml <https://github.com/lowRISC/ibex/blob/master/dv/uvm/core_ibex/riscv_dv_extension/testlist.yaml>`_), provides an exhaustive list of all tests along with a brief description of what the test does.
A test will execute a binary whilst running zero or more sequences that provide stimulus to external interfaces of ``ibex_top``.
As the memory interfaces are all driven by Ibex, with any testbench generated activity in response to a request from Ibex, they do not require explicit sequences run by the test.
Instead the test can configure the randomisation of memory delays as it wishes.
Memory errors can be configured to always occur in statically defined areas of the memory map or a sequence can be used to inject them via the memory interface agent.
The following sequences are available for tests to use.
Each sequence is derived from a base sequence which provides controls to repeat the sequence at fixed or random internals, forever or after a random number of repeats.
Full details can be found in `dv/uvm/core_ibex/tests/core_ibex_seq_lib.sv <https://github.com/lowRISC/ibex/blob/master/dv/uvm/core_ibex/tests/core_ibex_seq_lib.sv>`_.
* ``irq_raise_seq`` - Raises one or more interrupts.
The testbench binary can write to a special memory location to acknowledge the interrupt and cause it to drop.
Alternatively the testbench can drop it after a given amount of time.
* ``debug_seq`` - Raises the external debug request.
The testbench binary can write to a special memory location to acknowledge the request and cause it to drop.
Alternatively the testbench can drop it after a given amount of time.
* ``mem_error_seq`` - Injects a memory error in either the instruction side or data side, so the next access results in an error response.
* ``reset_seq`` - Resets the core.

View file

@ -4,7 +4,7 @@ Tracer
======
The module ``ibex_tracer`` can be used to create a log of the executed instructions.
It is used by ``ibex_core_tracing`` which forwards the `RVFI signals <https://github.com/SymbioticEDA/riscv-formal/blob/master/docs/rvfi.md>`_ to the tracer (see also :ref:`rvfi`).
It is used by ``ibex_top_tracing`` which forwards the `RVFI signals <https://github.com/SymbioticEDA/riscv-formal/blob/master/docs/rvfi.md>`_ to the tracer (see also :ref:`rvfi`).
Output file
-----------

View file

@ -1,3 +1,5 @@
.. _verification:
Verification
============
@ -17,6 +19,14 @@ At a high level, this testbench uses the open source `RISCV-DV random instructio
simple memory model, stimulates the Ibex core to run this program in memory, and then compares the
core trace log against a golden model ISS trace log to check for correctness of execution.
Verification maturity is tracked via :ref:`verification_stages` that are `defined by the OpenTitan project <https://opentitan.org/book/doc/project_governance/development_stages.html#hardware-verification-stages-v>`_.
Ibex has achieved **V2S** for the ``opentitan`` configuration, broadly this means verification almost complete (over 90% code and functional coverage hit with over 90% regression pass rate with test plan and coverage plan fully implemented) but not yet closed.
Nightly regression results, including a coverage summary and details of test failures, for the ``opentitan`` Ibex configuration are published at https://ibex.reports.lowrisc.org/opentitan/latest/report.html. Below is a summary of these results:
.. image:: https://ibex.reports.lowrisc.org/opentitan/latest/summary.svg
Testbench Architecture
^^^^^^^^^^^^^^^^^^^^^^
@ -78,6 +88,7 @@ coverage. This includes testing all RV32IMCB instructions, privileged
spec compliance, exception and interrupt testing, Debug Mode operation etc.
The complete test list can be found in the file `dv/uvm/core_ibex/riscv_dv_extension/testlist.yaml
<https://github.com/lowRISC/ibex/blob/master/dv/uvm/core_ibex/riscv_dv_extension/testlist.yaml>`_.
For details on coverage see the :ref:`coverage-plan`.
Please note that verification is still a work in progress.
@ -90,18 +101,27 @@ Prerequisites & Environment Setup
In order to run the co-simulation flow, you'll need:
- A SystemVerilog simulator that supports UVM.
The flow is currently tested with VCS.
- A RISC-V instruction set simulator, such as Spike_ or OVPsim_.
Note that when building Spike the ``--enable-commitlog`` and ``--enable-misaligned`` options must be passed to the ``configure`` script.
- The Spike RISC-V instruction set simulator
lowRISC maintains a `lowRISC-specific Spike fork <LRSpike_>`_, needed to model:
+ Cosimulation (needed for verification)
+ Some custom CSRs
+ Custom NMI behavior
Ibex verification should work with the Spike version that named ``ibex_cosim``.
Spike must be built with the ``--enable-commitlog`` and ``--enable-misaligned`` options.
``--enable-commitlog`` is needed to produce log output to track the instructions that were executed.
``--enable-misaligned`` tells Spike to simulate a core that handles misaligned accesses in hardware (rather than jumping to a trap handler).
If it is desired to simulate the core with the Icache enabled, a `lowRISC-specific branch of Spike <https://github.com/lowRISC/riscv-isa-sim/tree/ibex>`_ must be used.
Ibex supports v0.92 of the Bitmanip specification.
The ``master`` branch of Spike_ and OVPSim_ may support a different version.
It is recommended the `lowRISC-specific branch of Spike <https://github.com/lowRISC/riscv-isa-sim/tree/ibex>`_ is used when using a configuration with Bitmanip to ensure the simulated version of the Bitmanip specification matches with the RTL implemented version.
Note that Ibex used to support the commercial OVPsim simulator.
This is not currently possible because OVPsim doesn't support the co-simulation approach that we use.
- A working RISC-V toolchain (to compile / assemble the generated programs before simulating them).
Either download a `pre-built toolchain <riscv-toolchain-releases_>`_ (quicker) or download and build the `RISC-V GNU compiler toolchain <riscv-toolchain-source_>`_.
For the latter, the Bitmanip patches have to be manually installed to enable support for the Bitmanip draft extension.
For further information, checkout the `Bitmanip Extension on GitHub <bitmanip_>`_ and `how we create the pre-built toolchains <bitmanip-patches_>`_.
@ -115,16 +135,12 @@ to tell the RISCV-DV code where to find them:
export RISCV_GCC="$RISCV_TOOLCHAIN/bin/riscv32-unknown-elf-gcc"
export RISCV_OBJCOPY="$RISCV_TOOLCHAIN/bin/riscv32-unknown-elf-objcopy"
export SPIKE_PATH=/path/to/spike/bin
export OVPSIM_PATH=/path/to/ovpsim/bin
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/path/to/spike/lib/pkgconfig
(Obviously, you only need to set ``SPIKE_PATH`` or ``OVPSIM_PATH`` if
you have installed the corresponding instruction set simulator)
.. _Spike: https://github.com/riscv/riscv-isa-sim
.. _OVPsim: https://github.com/riscv/riscv-ovpsim
.. _LRSpike: https://github.com/lowRISC/riscv-isa-sim
.. _riscv-toolchain-source: https://github.com/riscv/riscv-gnu-toolchain
.. _riscv-toolchain-releases: https://github.com/lowRISC/lowrisc-toolchains/releases
.. _bitmanip-patches: https://github.com/lowRISC/lowrisc-toolchains#how-to-generate-the-bitmanip-patches
.. _bitmanip-patches: https://github.com/lowRISC/lowrisc-toolchains#how-to-generate-the-bitmanip-patch
.. _bitmanip: https://github.com/riscv/riscv-bitmanip
End-to-end RTL/ISS co-simulation flow
@ -149,11 +165,11 @@ proper interrupt handler, entered Debug Mode properly, updated any CSRs correctl
handshaking mechanism provided by the RISCV-DV instruction generator is heavily used, which
effectively allows the core to send status information to the testbench during program execution for
any analysis that is required to increase verification effectiveness.
This mechanism is explained in detail at https://github.com/google/riscv-dv/blob/master/HANDSHAKE.md.
This mechanism is explained in detail at https://github.com/google/riscv-dv/blob/master/docs/source/handshake.rst.
As a sidenote, the signature address that this testbench uses for the handshaking is ``0x8ffffffc``.
Additionally, as is mentioned in the RISCV-DV documentation of this handshake, a small set of API
tasks are provided in `dv/uvm/core_ibex/tests/core_ibex_base_test.sv
<https://github.com/lowRISC/ibex/blob/master/dv/uvm/core_ibex/tests/core_ibex_base_tests.sv>`_ to enable easy
<https://github.com/lowRISC/ibex/blob/master/dv/uvm/core_ibex/tests/core_ibex_base_test.sv>`_ to enable easy
and efficient integration and usage of this mechanism in this test environment.
To see how this handshake is used during real simulations, look in
`dv/uvm/core_ibex/tests/core_ibex_test_lib.sv
@ -199,15 +215,9 @@ The entirety of this flow is controlled by the Makefile found at
# Generate the assembly tests only
make gen
# Pass addtional options to the generator
make GEN_OPTS="xxxx" ...
# Compile and run RTL simulation
make TEST=xxx compile,rtl_sim
# Use a different ISS (default is spike)
make ... ISS=ovpsim
# Run a full regression with coverage
make COV=1

View file

@ -0,0 +1,224 @@
.. _verification_stages:
Verification Stages
===================
Ibex is being verified as part of the `OpenTitan <https://www.opentitan.org>`_ project and follows the `verification stages used in OpenTitan <https://opentitan.org/book/doc/project_governance/development_stages.html#hardware-verification-stages-v>`_.
The current verification stage of the 'opentitan' configuration of Ibex is **V2S**.
The full definition of V2S can be found at the `OpenTitan V2 <https://opentitan.org/book/doc/project_governance/checklist/index.html#v2>`_ and `OpenTitan V2S <https://opentitan.org/book/doc/project_governance/checklist/index.html#v2s>`_ checklists.
Other Ibex configurations do not have a formal verification stage at present.
V1 Checklist
------------
+---------------+------------------------------------+------------+-------------------------------------------------------+
| Type | Item | Resolution | Notes |
+===============+====================================+============+=======================================================+
| Documentation | DV_DOC_DRAFT_COMPLETE | Waived | Plan created, but does not conform to other templates |
+---------------+------------------------------------+------------+-------------------------------------------------------+
| Documentation | TESTPLAN_COMPLETED | Done | |
+---------------+------------------------------------+------------+-------------------------------------------------------+
| Testbench | TB_TOP_CREATED | Done | |
+---------------+------------------------------------+------------+-------------------------------------------------------+
| Testbench | PRELIMINARY_ASSERTION_CHECKS_ADDED | N/A | |
+---------------+------------------------------------+------------+-------------------------------------------------------+
| Testbench | SIM_TB_ENV_CREATED | Done | |
+---------------+------------------------------------+------------+-------------------------------------------------------+
| Testbench | SIM_RAL_MODEL_GEN_AUTOMATED | N/A | |
+---------------+------------------------------------+------------+-------------------------------------------------------+
| Testbench | CSR_CHECK_GEN_AUTOMATED | N/A | |
+---------------+------------------------------------+------------+-------------------------------------------------------+
| Testbench | TB_GEN_AUTOMATED | N/A | |
+---------------+------------------------------------+------------+-------------------------------------------------------+
| Tests | SIM_SMOKE_TEST_PASSING | Done | |
+---------------+------------------------------------+------------+-------------------------------------------------------+
| Tests | SIM_CSR_MEM_TEST_SUITE_PASSING | Done | |
+---------------+------------------------------------+------------+-------------------------------------------------------+
| Tests | FPV_MAIN_ASSERTIONS_PROVEN | N/A | |
+---------------+------------------------------------+------------+-------------------------------------------------------+
| Tool Setup | SIM_ALT_TOOL_SETUP | Waived | waived for now, doesnt follow standard tool flow |
+---------------+------------------------------------+------------+-------------------------------------------------------+
| Regression | SIM_SMOKE_REGRESSION_SETUP | Done | |
+---------------+------------------------------------+------------+-------------------------------------------------------+
| Regression | SIM_NIGHTLY_REGRESSION_SETUP | Done | |
+---------------+------------------------------------+------------+-------------------------------------------------------+
| Regression | FPV_REGRESSION_SETUP | N/A | |
+---------------+------------------------------------+------------+-------------------------------------------------------+
| Coverage | SIM_COVERAGE_MODEL_ADDED | Done | |
+---------------+------------------------------------+------------+-------------------------------------------------------+
| Code Quality | TB_LINT_SETUP | Waived | |
+---------------+------------------------------------+------------+-------------------------------------------------------+
| Integration | PRE_VERIFIED_SUB_MODULES_V1 | N/A | |
+---------------+------------------------------------+------------+-------------------------------------------------------+
| Review | DESIGN_SPEC_REVIEWED | Done | |
+---------------+------------------------------------+------------+-------------------------------------------------------+
| Review | TESTPLAN_REVIEWED | Waived | Not done, will be reviewed in V2 |
+---------------+------------------------------------+------------+-------------------------------------------------------+
| Review | STD_TEST_CATEGORIES_PLANNED | Done | different format than comportable modules |
+---------------+------------------------------------+------------+-------------------------------------------------------+
| Review | V2_CHECKLIST_SCOPED | Done | |
+---------------+------------------------------------+------------+-------------------------------------------------------+
V2 Checklist
------------
+---------------+-------------------------------------+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Type | Item | Resolution | Notes |
+===============+=====================================+============+======================================================================================================================================================================+
| Documentation | DESIGN_DELTAS_CAPTURED_V2 | Complete | |
+---------------+-------------------------------------+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Testbench | FUNCTIONAL_COVERAGE_IMPLEMENTED | Complete | |
+---------------+-------------------------------------+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Testbench | ALL_INTERFACES_EXERCISED | Complete | |
+---------------+-------------------------------------+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Testbench | ALL_ASSERTION_CHECKS_ADDED | Complete | |
+---------------+-------------------------------------+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Testbench | SIM_TB_ENV_COMPLETED | Complete | |
+---------------+-------------------------------------+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Tests | SIM_ALL_TESTS_PASSING | Complete | Note the ``riscv_assorted_traps_interrupts_debug`` test sees many failures (but does have some seeds that pass). |
| | | | The test attempts to generally combine many different stimuli and under OpenTitan classification would be considered a V3 test. |
+---------------+-------------------------------------+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Tests | FPV_ALL_ASSERTIONS_WRITTEN | N/A | No formal applied for non-security features in Ibex. |
+---------------+-------------------------------------+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Tests | FPV_ALL_ASSUMPTIONS_REVIEWED | N/A | No formal applied for non-security features in Ibex. |
+---------------+-------------------------------------+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Tests | SIM_FW_SIMULATED | N/A | No ROM or firmware present. |
+---------------+-------------------------------------+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Regression | SIM_NIGHTLY_REGRESSION_V2 | Complete | Regression run in GitHub Actions only accessible to OpenTitan members. |
| | | | Publicly viewable reports on the `OpenTitan regression dashboard <https://reports.opentitan.org/hw/top_earlgrey/dv/summary/latest/report.html>`_ are planned for V3. |
+---------------+-------------------------------------+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Coverage | SIM_CODE_COVERAGE_V2 | Complete | Coverage results available in nightly regression run. |
+---------------+-------------------------------------+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Coverage | SIM_FUNCTIONAL_COVERAGE_V2 | Complete | Coverage results available in nightly regression run. |
| | | | Note the average grade (the average of coverage % for each individual coverpoint and cross) is used for the 90% figure. |
| | | | As the functional coverage contains some very large crosses a simple % of all bins hit biases too much toward these crosses. |
+---------------+-------------------------------------+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Coverage | FPV_CODE_COVERAGE_V2 | N/A | No formal applied for non-security features in Ibex. |
+---------------+-------------------------------------+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Coverage | FPV_COI_COVERAGE_V2 | N/A | No formal applied for non-security features in Ibex. |
+---------------+-------------------------------------+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Integration | PRE_VERIFIED_SUB_MODULES_V2 | Complete | ICache is verified in a seperate testbench. |
+---------------+-------------------------------------+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Issues | NO_HIGH_PRIORITY_ISSUES_PENDING | Complete | |
+---------------+-------------------------------------+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Issues | ALL_LOW_PRIORITY_ISSUES_ROOT_CAUSED | Complete | |
+---------------+-------------------------------------+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Review | DV_DOC_TESTPLAN_REVIEWED | Complete | |
+---------------+-------------------------------------+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Review | V3_CHECKLIST_SCOPED | Complete | |
+---------------+-------------------------------------+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
**PMP Testing Note**: A large number of iterations of ``pmp_full_random_test`` are required to meet coverage goals and timed out tests must be included in the coverage collection.
This is because of the large cross bins for PMP that aim to explore the full space of possible behaviour.
The current strategy of random generation is very inefficient at exploring this space.
It is also complex to write a randomly generated test that can deal with all possible scenarios without hitting a double faulting or time out scenarios (e.g. consider a random configuration that gives you no executable regions and ePMP modes like machine mode lockdown and machine mode whitelist policy).
Co-simulation checking is enabled when this test is run (as it is for all block level verification tests) so would detect any incorrect behaviour.
From investigation we are confident the time-outs seen are simply badly performing tests (e.g. very slowly working its way through an instruction block with no execute permissions by attempting to execute one instruction, faulting, trying the next and getting the same result over and over).
For future work we will explore more efficient strategies for exploring this space as well as employing formal methods to achieve full verification closure.
V2S Checklist
-------------
+---------------+--------------------------+------------+--------------------------------------------------------------------------------------------------------------------------------------+
| Type | Item | Resolution | Notes |
+===============+==========================+============+======================================================================================================================================+
| Documentation | SEC_CM_TESTPLAN_COMPLETE | Complete | The security counter measure to test mapping can be found below |
+---------------+--------------------------+------------+--------------------------------------------------------------------------------------------------------------------------------------+
| Tests | FPV_SEC_CM_VERIFIED | Complete | See the `OpenTitan FPV Results Dashboard <https://reports.opentitan.org/hw/top_earlgrey/formal/sec_cm/summary/latest/report.html>`_. |
+---------------+--------------------------+------------+--------------------------------------------------------------------------------------------------------------------------------------+
| Tests | SIM_SEC_CM_VERIFIED | Complete | |
+---------------+--------------------------+------------+--------------------------------------------------------------------------------------------------------------------------------------+
| Coverage | SIM_COVERAGE_REVIEWED | Complete | |
+---------------+--------------------------+------------+--------------------------------------------------------------------------------------------------------------------------------------+
| Review | SEC_CM_DV_REVIEWED | Complete | |
+---------------+--------------------------+------------+--------------------------------------------------------------------------------------------------------------------------------------+
Ibex SEC_CM Test Mapping
------------------------
The :ref:`security features Ibex implements <security>` are given specific security countermeasure names in OpenTitan (see 'Security Countermeasures' in the `Comportability Definition and Specification <https://opentitan.org/book/doc/contributing/hw/comportability/index.html#security-countermeasures>`_ documentation section).
Each countermeasure has a test that exercises it.
The mapping between countermeasures and tests is given below
+--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Security Countermeasure | Test |
+================================+============================================================================================================================================================================================================================================================================================================+
| BUS.INTEGRITY | ``riscv_mem_intg_error_test`` in Ibex DV. |
| | The ``chip_sw_data_integrity`` OpenTitan top-level test will trigger integrity errors within the OpenTitan specific ``rv_core_ibex`` wrapper. |
| | The TL-UL host adapter used in the OpenTitan specific ``rv_core_ibex`` is fully verified elsewhere in OpenTitan. |
+--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| SCRAMBLE.KEY.SIDELOAD | ``riscv_rand_instr_test`` in Ibex DV. |
| | This test executes ``FENCE.I`` which rotates the scramble key. |
| | The ``rv_core_ibex_icache_invalidate_test`` OpenTitan top-level test covers assertions within the OpenTitan specific ``rv_core_ibex`` wrapper that check that a ``FENCE.I`` results in an icache scramble key request and that the returned key is correctly supplied to the scrambling memory primitives. |
+--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| CORE.DATA_REG_SW.SCA | ``dit_test`` directed test run against simple system cosimulation. |
| | The test runs functions that whose timing is data dependent with data independent timing disabled. |
| | It passes where the runs with data independent timing enabled all execute in the same amount of time and the runs without it enabled take different amounts of time. |
+--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| PC.CTRL_FLOW.CONSISTENCY | ``riscv_pc_intg_test`` in Ibex DV. |
+--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| CTRL_FLOW.UNPREDICTABLE | ``dummy_instr_test`` directed test run against simple system cosimulation. |
| | The test runs a function with dummy instructions disabled and enabled. |
| | It passes where the runs without dummy instructions all have the same timing and runs with dummy instructions all have different timing. |
+--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| DATA_REG_SW.INTEGRITY | ``riscv_rf_intg_test`` in Ibex DV. |
+--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| DATA_REG_SW.GLITCH_DETECT | Covered by formal verification of security countermeasures within OpenTitan. |
+--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| LOGIC.SHADOW | ``chip_sw_rv_core_ibex_lockstep_glitch`` top-level test in OpenTitan |
+--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| FETCH.CTRL.LC_GATED | ``riscv_rand_instr_test`` in Ibex DV. |
| | Fetch enable is randomly toggled in various tests and correct behaviour checked via an assertion. |
+--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| EXCEPTION.CTRL_FLOW.LOCAL_ESC | ``riscv_pmp_full_random_test`` in Ibex DV. |
| | This test produces double faults, which are checked by an assertion. |
| | ``chip_sw_rv_core_ibex_double_fault`` top-level test in OpenTitan demonstrates escalation on a double fault |
+--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| EXCEPTION.CTRL_FLOW.GLOBAL_ESC | ``riscv_pmp_full_random_test`` in Ibex DV. |
| | This test produces double faults, which are checked by an assertion. |
| | ``chip_sw_rv_core_ibex_double_fault`` top-level test in OpenTitan demonstrates escalation on a double fault |
+--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ICACHE.MEM.SCRAMBLE | No explicit testing, the scrambling memory primitive is seperately verified within OpenTitan. |
| | Assertions in the OpenTitan specific ``rv_core_ibex`` wrapper ensure a newly requested scramble key is correctly applied to the scrambling memories. |
| | The ``rv_core_ibex_icache_invalidate_test`` OpenTitan top-level test covers assertions within the OpenTitan specific ``rv_core_ibex`` wrapper that check that a ``FENCE.I`` results in an icache scramble key request and that the returned key is correctly supplied to the scrambling memory primitives. |
+--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ICACHE.MEM.INTEGRITY | ``riscv_icache_intg_test`` in Ibex DV. |
+--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
V3 Checklist
------------
+---------------+--------------------------------+-------------+-------+
| Type | Item | Resolution | Notes |
+===============+================================+=============+=======+
| Documentation | DESIGN_DELTAS_CAPTURED_V3 | Not Started | |
+---------------+--------------------------------+-------------+-------+
| Tests | X_PROP_ANALYSIS_COMPLETED | Not Started | |
+---------------+--------------------------------+-------------+-------+
| Tests | FPV_ASSERTIONS_PROVEN_AT_V3 | Not Started | |
+---------------+--------------------------------+-------------+-------+
| Regression | SIM_NIGHTLY_REGRESSION_AT_V3 | Not Started | |
+---------------+--------------------------------+-------------+-------+
| Coverage | SIM_CODE_COVERAGE_AT_100 | Not Started | |
+---------------+--------------------------------+-------------+-------+
| Coverage | SIM_FUNCTIONAL_COVERAGE_AT_100 | Not Started | |
+---------------+--------------------------------+-------------+-------+
| Coverage | FPV_CODE_COVERAGE_AT_100 | Not Started | |
+---------------+--------------------------------+-------------+-------+
| Coverage | FPV_COI_COVERAGE_AT_100 | Not Started | |
+---------------+--------------------------------+-------------+-------+
| Code Quality | ALL_TODOS_RESOLVED | Not Started | |
+---------------+--------------------------------+-------------+-------+
| Code Quality | NO_TOOL_WARNINGS_THROWN | Not Started | |
+---------------+--------------------------------+-------------+-------+
| Code Quality | TB_LINT_COMPLETE | Not Started | |
+---------------+--------------------------------+-------------+-------+
| Integration | PRE_VERIFIED_SUB_MODULES_V3 | Not Started | |
+---------------+--------------------------------+-------------+-------+
| Issues | NO_ISSUES_PENDING | Not Started | |
+---------------+--------------------------------+-------------+-------+
| Review | Reviewer(s) | Not Started | |
+---------------+--------------------------------+-------------+-------+
| Review | Signoff date | Not Started | |
+---------------+--------------------------------+-------------+-------+

View file

@ -25,10 +25,8 @@ The concierge duties rotate between several core developers on a weekly basis.
You can find today's concierge on duty in a `public calendar <https://calendar.google.com/calendar/embed?src=lowrisc.org_s0pdodkddnggdp40jusjij27h4%40group.calendar.google.com>`_.
* Greg Chadwick (`@GregAC <https://github.com/gregac>`_)
* Tom Roberts (`@tomroberts-lowrisc <https://github.com/tomroberts-lowrisc>`_)
* Rupert Swarbrick (`@rswarbrick <https://github.com/rswarbrick>`_)
* Pirmin Vogel (`@vogelpi <https://github.com/vogelpi>`_)
* Philipp Wagner (`@imphil <https://github.com/imphil>`_)
You can be Ibex Concierge, too.
Please talk to any of the current concierges to discuss!

View file

@ -11,3 +11,8 @@
overflow: visible !important;
}
}
.wy-nav-content {
max-width: 1000px !important;
}

View file

@ -12,12 +12,19 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
import sys
# Source top directory
topsrcdir = os.path.join(os.path.dirname(__file__), '..')
old_sys_path = sys.path
try:
sys.path.append(os.path.join(topsrcdir, 'util'))
import check_tool_requirements as ctr
finally:
sys.path = old_sys_path
numfig=True
numfig_format = {'figure': 'Figure %s', 'table': 'Table %s', 'code-block': 'Listing %s'}
@ -35,7 +42,9 @@ extensions = [
'sphinx.ext.todo',
]
# Wavedrom
wavedrom_html_jsinline = False
render_using_wavedrompy = True
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
@ -105,11 +114,9 @@ html_logo = 'images/logo.svg'
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_context = {
'css_files' : [
'_static/theme_overrides.css', # Fix wide tables in RTD theme
],
}
html_css_files = [
'theme_overrides.css', # Fix wide tables in RTD theme
]
# -- Options for LaTeX output ---------------------------------------------
@ -166,7 +173,8 @@ texinfo_documents = [
# Add minimum versions of required tools as variables for use inside the
# documentation.
exec(open(os.path.join(topsrcdir, 'tool_requirements.py')).read())
tool_reqs = ctr.read_tool_requirements()
rst_epilog = ""
for tool_name, tool_version in __TOOL_REQUIREMENTS__.items():
rst_epilog += ".. |tool_requirements.{}| replace:: {}\n".format(tool_name, tool_version)
for tool, req in tool_reqs.items():
rst_epilog += (".. |tool_requirements.{}| replace:: {}\n"
.format(tool, req.min_version))

View file

@ -1,5 +1,6 @@
setuptools_scm
sphinx>=2.1.0
sphinx>=7.0
sphinx_rtd_theme
sphinxcontrib-wavedrom
wavedrom>=1.9.0rc1
jinja2 == 3.0.3

19
dv/cosim/cosim.core Normal file
View file

@ -0,0 +1,19 @@
CAPI=2:
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
name: "lowrisc:dv:cosim"
description: "Co-simulator framework"
filesets:
files_cpp:
files:
- cosim.h: { is_include_file: true }
- spike_cosim.cc
- spike_cosim.h: { is_include_file: true }
file_type: cppSource
targets:
default:
filesets:
- files_cpp

166
dv/cosim/cosim.h Normal file
View file

@ -0,0 +1,166 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
#include <string>
#include <vector>
#ifndef COSIM_H_
#define COSIM_H_
// Information about a dside transaction observed on the DUT memory interface
struct DSideAccessInfo {
// set when the access is a store, in which case `data` is the store data from
// the DUT. Otherwise `data` is the load data provided to the DUT.
bool store;
// `addr` is the address and must be 32-bit aligned. `data` and `be` are
// aligned to the address. For example an 8-bit store of 0xff to 0x12 has
// `data` as 0x00ff0000, `addr` as 0x10 and `be` as 0b0100.
uint32_t data;
uint32_t addr;
uint32_t be;
// set if an error response to the transaction is seen.
bool error;
// `misaligned_first` and `misaligned_second` are set when the transaction is
// generated for a misaligned store or load instruction. `misaligned_first`
// is true when the transaction is for the lower half and `misaligned_second`
// is true when the transaction is for the upper half, if it exists.
//
// For example an unaligned 32-bit load to 0x3 produces a transaction with
// `addr` as 0x0 and `misaligned_first` set to true, then a transaction with
// `addr` as 0x4 and `misaligned_second` set to true. An unaligned 16-bit load
// to 0x01 only produces a transaction with `addr` as 0x0 and
// `misaligned_first` set to true, there is no second half.
bool misaligned_first;
bool misaligned_second;
bool misaligned_first_saw_error;
bool m_mode_access;
};
class Cosim {
public:
virtual ~Cosim() {}
// Add a memory to the co-simulator environment.
//
// Use `backdoor_write_mem`/`backdoor_read_mem` to access it from the
// simulation environment.
virtual void add_memory(uint32_t base_addr, size_t size) = 0;
// Write bytes to co-simulator memory.
//
// returns false if write fails (e.g. because no memory exists at the bytes
// being written).
virtual bool backdoor_write_mem(uint32_t addr, size_t len,
const uint8_t *data_in) = 0;
// Read bytes from co-simulator memory.
//
// returns false if read fails (e.g. because no memory exists at the bytes
// being read).
virtual bool backdoor_read_mem(uint32_t addr, size_t len,
uint8_t *data_out) = 0;
// Step the co-simulator, checking register write and PC of executed
// instruction match the supplied values. `write_reg` gives the index of the
// written register along with `write_reg_data` which provides the data. A
// `write_reg` of 0 indicates no register write occurred.
//
// `sync_trap` is set to true when the instruction caused a synchronous trap.
// In this case the instruction doesn't retire so no register write occurs (so
// `write_reg` must be 0).
//
// Returns false if there are any errors; use `get_errors` to obtain details
virtual bool step(uint32_t write_reg, uint32_t write_reg_data, uint32_t pc,
bool sync_trap, bool suppress_reg_write) = 0;
// When more than one of `set_mip`, `set_nmi` or `set_debug_req` is called
// before `step` which one takes effect is chosen by the co-simulator. Which
// should take priority is architecturally defined by the RISC-V
// specification.
// Set the value of MIP.
//
// Two versions of MIP must be supplied the `pre_mip` and the `post_mip`. The
// `pre_mip` is the value of MIP that is used to determine if an interrupt is
// pending. The `post_mip` is the value of MIP that the next instruction
// executed (which will be the first instruction of the interrupt vector when
// an interrupt ir triggered) observes. These will be different in the case
// where an interrupt is raised triggering an interrupt handler but then
// drops before the first instruction of the handler has executed.
//
// At the next call of `step`, the MIP values will take effect (i.e. if it's a
// new interrupt that is enabled it will step straight to that handler).
virtual void set_mip(uint32_t pre_mip, uint32_t post_mip) = 0;
// Set the state of the NMI (non-maskable interrupt) line.
//
// The NMI signal is a level triggered interrupt. When the NMI is taken the
// CPU ignores the NMI line until an `mret` instruction is executed. If the
// NMI is high following the `mret` (regardless of whether it has been low or
// not whilst the first NMI is being handled) a new NMI is taken.
//
// When an NMI is due to be taken that will occur at the next call of `step`.
virtual void set_nmi(bool nmi) = 0;
// Set the state of the internal NMI (non-maskable interrupt) line.
// Behaviour wise this is almost as same as external NMI case explained at
// set_nmi method. Difference is that this one is a response from Ibex rather
// than an input.
virtual void set_nmi_int(bool nmi_int) = 0;
// Set the debug request.
//
// When set to true the core will enter debug mode at the next step
virtual void set_debug_req(bool debug_req) = 0;
// Set the value of mcycle.
//
// The co-simulation model doesn't alter the value of mcycle itself (other
// than instructions that do a direct CSR write). mcycle should be set to the
// correct value before any `step` call that may execute an instruction that
// observes the value of mcycle.
//
// A full 64-bit value is provided setting both the mcycle and mcycleh CSRs.
virtual void set_mcycle(uint64_t mcycle) = 0;
// Set the value of a CSR. This is used when it is needed to have direct
// communication between DUT and Spike (e.g. Performance counters).
virtual void set_csr(const int csr_num, const uint32_t new_val) = 0;
// Set the ICache scramble key valid bit that is visible in CPUCTRLSTS.
virtual void set_ic_scr_key_valid(bool valid) = 0;
// Tell the co-simulation model about observed transactions on the dside
// memory interface of the DUT. Accesses are notified once the response to a
// transaction is seen.
//
// Observed transactions for the DUT are checked against accesses from the
// co-simulation model when a memory access occurs during a `step`. If there
// is a mismatch an error is reported which can be obtained via `get_errors`.
virtual void notify_dside_access(const DSideAccessInfo &access_info) = 0;
// Tell the co-simulation model about an error response to an iside fetch.
//
// `addr` must be 32-bit aligned.
//
// The next step following a call to `set_iside_error` must produce an
// instruction fault at the given address.
virtual void set_iside_error(uint32_t addr) = 0;
// Get a vector of strings describing errors that have occurred during `step`
virtual const std::vector<std::string> &get_errors() = 0;
// Clear internal vector of error descriptions
virtual void clear_errors() = 0;
// Returns a count of instructions executed by co-simulator and DUT without
// failures.
virtual unsigned int get_insn_cnt() = 0;
};
#endif // COSIM_H_

128
dv/cosim/cosim_dpi.cc Normal file
View file

@ -0,0 +1,128 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
#include "cosim_dpi.h"
#include <svdpi.h>
#include <cassert>
#include "cosim.h"
int riscv_cosim_step(Cosim *cosim, const svBitVecVal *write_reg,
const svBitVecVal *write_reg_data, const svBitVecVal *pc,
svBit sync_trap, svBit suppress_reg_write) {
assert(cosim);
return cosim->step(write_reg[0], write_reg_data[0], pc[0], sync_trap,
suppress_reg_write)
? 1
: 0;
}
void riscv_cosim_set_mip(Cosim *cosim, const svBitVecVal *pre_mip,
const svBitVecVal *post_mip) {
assert(cosim);
cosim->set_mip(pre_mip[0], post_mip[0]);
}
void riscv_cosim_set_nmi(Cosim *cosim, svBit nmi) {
assert(cosim);
cosim->set_nmi(nmi);
}
void riscv_cosim_set_nmi_int(Cosim *cosim, svBit nmi_int) {
assert(cosim);
cosim->set_nmi_int(nmi_int);
}
void riscv_cosim_set_debug_req(Cosim *cosim, svBit debug_req) {
assert(cosim);
cosim->set_debug_req(debug_req);
}
void riscv_cosim_set_mcycle(Cosim *cosim, svBitVecVal *mcycle) {
assert(cosim);
uint64_t mcycle_full = mcycle[0] | (uint64_t)mcycle[1] << 32;
cosim->set_mcycle(mcycle_full);
}
void riscv_cosim_set_csr(Cosim *cosim, const int csr_id,
const svBitVecVal *csr_val) {
assert(cosim);
cosim->set_csr(csr_id, (uint32_t)csr_val[0]);
}
void riscv_cosim_set_ic_scr_key_valid(Cosim *cosim, svBit valid) {
assert(cosim);
cosim->set_ic_scr_key_valid(valid);
}
void riscv_cosim_notify_dside_access(Cosim *cosim, svBit store,
svBitVecVal *addr, svBitVecVal *data,
svBitVecVal *be, svBit error,
svBit misaligned_first,
svBit misaligned_second,
svBit misaligned_first_saw_error,
svBit m_mode_access) {
assert(cosim);
cosim->notify_dside_access(DSideAccessInfo{
.store = store != 0,
.data = data[0],
.addr = addr[0],
.be = be[0],
.error = error != 0,
.misaligned_first = misaligned_first != 0,
.misaligned_second = misaligned_second != 0,
.misaligned_first_saw_error = misaligned_first_saw_error != 0,
.m_mode_access = m_mode_access != 0});
}
void riscv_cosim_set_iside_error(Cosim *cosim, svBitVecVal *addr) {
assert(cosim);
cosim->set_iside_error(addr[0]);
}
int riscv_cosim_get_num_errors(Cosim *cosim) {
assert(cosim);
return cosim->get_errors().size();
}
const char *riscv_cosim_get_error(Cosim *cosim, int index) {
assert(cosim);
if (index >= cosim->get_errors().size()) {
return nullptr;
}
return cosim->get_errors()[index].c_str();
}
void riscv_cosim_clear_errors(Cosim *cosim) {
assert(cosim);
cosim->clear_errors();
}
void riscv_cosim_write_mem_byte(Cosim *cosim, const svBitVecVal *addr,
const svBitVecVal *d) {
assert(cosim);
uint8_t byte = d[0] & 0xff;
cosim->backdoor_write_mem(addr[0], 1, &byte);
}
unsigned int riscv_cosim_get_insn_cnt(Cosim *cosim) {
assert(cosim);
return cosim->get_insn_cnt();
}

20
dv/cosim/cosim_dpi.core Normal file
View file

@ -0,0 +1,20 @@
CAPI=2:
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
name: "lowrisc:dv:cosim_dpi"
description: "DPI wrapper for Co-simulator framework"
filesets:
files_cpp:
depend:
- lowrisc:dv:cosim
files:
- cosim_dpi.cc: { file_type: cppSource }
- cosim_dpi.h: { file_type: cppSource, is_include_file: true }
- cosim_dpi.svh: {file_type: systemVerilogSource }
targets:
default:
filesets:
- files_cpp

45
dv/cosim/cosim_dpi.h Normal file
View file

@ -0,0 +1,45 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
#ifndef COSIM_DPI_H_
#define COSIM_DPI_H_
#include <stdint.h>
#include <svdpi.h>
#include "cosim.h"
// This adapts the C++ interface of the `Cosim` class to be used via DPI. See
// the documentation in cosim.h for further details
extern "C" {
int riscv_cosim_step(Cosim *cosim, const svBitVecVal *write_reg,
const svBitVecVal *write_reg_data, const svBitVecVal *pc,
svBit sync_trap, svBit suppress_reg_write);
void riscv_cosim_set_mip(Cosim *cosim, const svBitVecVal *pre_mip,
const svBitVecVal *post_mip);
void riscv_cosim_set_nmi(Cosim *cosim, svBit nmi);
void riscv_cosim_set_nmi_int(Cosim *cosim, svBit nmi_int);
void riscv_cosim_set_debug_req(Cosim *cosim, svBit debug_req);
void riscv_cosim_set_mcycle(Cosim *cosim, svBitVecVal *mcycle);
void riscv_cosim_set_csr(Cosim *cosim, const int csr_id,
const svBitVecVal *csr_val);
void riscv_cosim_set_ic_scr_key_valid(Cosim *cosim, svBit valid);
void riscv_cosim_notify_dside_access(Cosim *cosim, svBit store,
svBitVecVal *addr, svBitVecVal *data,
svBitVecVal *be, svBit error,
svBit misaligned_first,
svBit misaligned_second,
svBit misaligned_first_saw_error,
svBit m_mode_access);
void riscv_cosim_set_iside_error(Cosim *cosim, svBitVecVal *addr);
int riscv_cosim_get_num_errors(Cosim *cosim);
const char *riscv_cosim_get_error(Cosim *cosim, int index);
void riscv_cosim_clear_errors(Cosim *cosim);
void riscv_cosim_write_mem_byte(Cosim *cosim, const svBitVecVal *addr,
const svBitVecVal *d);
unsigned int riscv_cosim_get_insn_cnt(Cosim *cosim);
}
#endif // COSIM_DPI_H_

35
dv/cosim/cosim_dpi.svh Normal file
View file

@ -0,0 +1,35 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
// DPI interface to co-simulation model, see `cosim.h` for the interface description.
// Implemented as a header file as VCS needs `import` declarations included in each verilog file
// that uses them.
`ifndef COSIM_DPI_SVH
`define COSIM_DPI_SVH
import "DPI-C" function int riscv_cosim_step(chandle cosim_handle, bit [4:0] write_reg,
bit [31:0] write_reg_data, bit [31:0] pc, bit sync_trap, bit suppress_reg_write);
import "DPI-C" function void riscv_cosim_set_mip(chandle cosim_handle, bit [31:0] pre_mip,
bit [31:0] post_mip);
import "DPI-C" function void riscv_cosim_set_nmi(chandle cosim_handle, bit nmi);
import "DPI-C" function void riscv_cosim_set_nmi_int(chandle cosim_handle, bit nmi_int);
import "DPI-C" function void riscv_cosim_set_debug_req(chandle cosim_handle, bit debug_req);
import "DPI-C" function void riscv_cosim_set_mcycle(chandle cosim_handle, bit [63:0] mcycle);
import "DPI-C" function void riscv_cosim_set_csr(chandle cosim_handle, int csr_id,
bit [31:0] csr_val);
import "DPI-C" function void riscv_cosim_set_ic_scr_key_valid(chandle cosim_handle, bit valid);
import "DPI-C" function void riscv_cosim_notify_dside_access(chandle cosim_handle, bit store,
bit [31:0] addr, bit [31:0] data, bit [3:0] be, bit error, bit misaligned_first,
bit misaligned_second, bit misaligned_first_saw_error, bit m_mode_access);
import "DPI-C" function int riscv_cosim_set_iside_error(chandle cosim_handle, bit [31:0] addr);
import "DPI-C" function int riscv_cosim_get_num_errors(chandle cosim_handle);
import "DPI-C" function string riscv_cosim_get_error(chandle cosim_handle, int index);
import "DPI-C" function void riscv_cosim_clear_errors(chandle cosim_handle);
import "DPI-C" function void riscv_cosim_write_mem_byte(chandle cosim_handle, bit [31:0] addr,
bit [7:0] d);
import "DPI-C" function int unsigned riscv_cosim_get_insn_cnt(chandle cosim_handle);
`endif

1144
dv/cosim/spike_cosim.cc Normal file

File diff suppressed because it is too large Load diff

147
dv/cosim/spike_cosim.h Normal file
View file

@ -0,0 +1,147 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
#ifndef SPIKE_COSIM_H_
#define SPIKE_COSIM_H_
#include <stdint.h>
#include <deque>
#include <memory>
#include <string>
#include <vector>
#include "cosim.h"
#include "riscv/devices.h"
#include "riscv/log_file.h"
#include "riscv/processor.h"
#include "riscv/simif.h"
#define IBEX_MARCHID 22
class SpikeCosim : public simif_t, public Cosim {
private:
// A sigsegv has been observed when deleting isa_parser_t instances under
// Xcelium on CentOS 7. The root cause is unknown so for a workaround simply
// use a raw pointer for isa_parser that never gets deleted. This produces a
// minor memory leak but it is of little consequence as when SpikeCosim is
// being deleted it is the end of simulation and the process will be
// terminated shortly anyway.
#ifdef COSIM_SIGSEGV_WORKAROUND
isa_parser_t *isa_parser;
#else
std::unique_ptr<isa_parser_t> isa_parser;
#endif
std::unique_ptr<processor_t> processor;
std::unique_ptr<log_file_t> log;
bus_t bus;
std::vector<std::unique_ptr<mem_t>> mems;
std::vector<std::string> errors;
bool nmi_mode;
typedef struct {
uint8_t mpp;
bool mpie;
uint32_t epc;
uint32_t cause;
} mstack_t;
mstack_t mstack;
void fixup_csr(int csr_num, uint32_t csr_val);
struct PendingMemAccess {
DSideAccessInfo dut_access_info;
uint32_t be_spike;
};
std::vector<PendingMemAccess> pending_dside_accesses;
bool pending_iside_error;
uint32_t pending_iside_err_addr;
typedef enum {
kCheckMemOk, // Checks passed and access succeded in RTL
kCheckMemCheckFailed, // Checks failed
kCheckMemBusError // Checks passed, but access generated bus error in RTL
} check_mem_result_e;
check_mem_result_e check_mem_access(bool store, uint32_t addr, size_t len,
const uint8_t *bytes);
bool pc_is_mret(uint32_t pc);
bool pc_is_load(uint32_t pc, uint32_t &rd_out);
bool pc_is_debug_ebreak(uint32_t pc);
bool check_debug_ebreak(uint32_t write_reg, uint32_t pc, bool sync_trap);
bool check_gpr_write(const commit_log_reg_t::value_type &reg_change,
uint32_t write_reg, uint32_t write_reg_data);
bool check_suppress_reg_write(uint32_t write_reg, uint32_t pc,
uint32_t &suppressed_write_reg);
void on_csr_write(const commit_log_reg_t::value_type &reg_change);
void leave_nmi_mode();
bool change_cpuctrlsts_sync_exc_seen(bool flag);
void set_cpuctrlsts_double_fault_seen();
void handle_cpuctrl_exception_entry();
void initial_proc_setup(uint32_t start_pc, uint32_t start_mtvec,
uint32_t mhpm_counter_num);
void early_interrupt_handle();
void misaligned_pmp_fixup();
unsigned int insn_cnt;
public:
SpikeCosim(const std::string &isa_string, uint32_t start_pc,
uint32_t start_mtvec, const std::string &trace_log_path,
bool secure_ibex, bool icache_en, uint32_t pmp_num_regions,
uint32_t pmp_granularity, uint32_t mhpm_counter_num);
// simif_t implementation
virtual char *addr_to_mem(reg_t addr) override;
virtual bool mmio_load(reg_t addr, size_t len, uint8_t *bytes) override;
virtual bool mmio_store(reg_t addr, size_t len,
const uint8_t *bytes) override;
virtual void proc_reset(unsigned id) override;
virtual const char *get_symbol(uint64_t addr) override;
// Cosim implementation
void add_memory(uint32_t base_addr, size_t size) override;
bool backdoor_write_mem(uint32_t addr, size_t len,
const uint8_t *data_in) override;
bool backdoor_read_mem(uint32_t addr, size_t len, uint8_t *data_out) override;
bool step(uint32_t write_reg, uint32_t write_reg_data, uint32_t pc,
bool sync_trap, bool suppress_reg_write) override;
bool check_retired_instr(uint32_t write_reg, uint32_t write_reg_data,
uint32_t dut_pc, bool suppress_reg_write);
bool check_sync_trap(uint32_t write_reg, uint32_t pc,
uint32_t initial_spike_pc);
void set_mip(uint32_t pre_mip, uint32_t post_mip) override;
void set_nmi(bool nmi) override;
void set_nmi_int(bool nmi_int) override;
void set_debug_req(bool debug_req) override;
void set_mcycle(uint64_t mcycle) override;
void set_csr(const int csr_num, const uint32_t new_val) override;
void set_ic_scr_key_valid(bool valid) override;
void notify_dside_access(const DSideAccessInfo &access_info) override;
// The spike co-simulator assumes iside and dside accesses within a step are
// disjoint. If both access the same address within a step memory faults may
// be incorrectly cause on one rather than the other or the access checking
// will break.
// TODO: Work on spike changes to remove this restriction
void set_iside_error(uint32_t addr) override;
const std::vector<std::string> &get_errors() override;
void clear_errors() override;
unsigned int get_insn_cnt() override;
};
#endif // SPIKE_COSIM_H_

View file

@ -9,7 +9,7 @@
// 'rtl' directory), see verilator_waiver_rtl.vlt in the same
// directory.
//
// See https://www.veripool.org/projects/verilator/wiki/Manual-verilator#CONFIGURATION-FILES
// See https://verilator.org/guide/latest/exe_verilator.html#configuration-files
// for documentation.
//
// Important: This file must included *before* any other Verilog file is read.

View file

@ -4,6 +4,7 @@
#include "base_register.h"
#include <cassert>
#include <iostream>
BaseRegister::BaseRegister(
@ -32,8 +33,8 @@ uint32_t BaseRegister::RegisterClear(uint32_t newval) {
return read_value;
}
bool BaseRegister::MatchAddr(uint32_t addr) {
return (addr == register_address_);
bool BaseRegister::MatchAddr(uint32_t addr, uint32_t addr_mask) {
return ((addr & addr_mask) == (register_address_ & addr_mask));
}
bool BaseRegister::ProcessTransaction(bool *match, RegisterTransaction *trans) {
@ -82,7 +83,62 @@ uint32_t BaseRegister::RegisterRead() { return register_value_; }
uint32_t BaseRegister::GetLockMask() { return 0; }
BaseRegister *BaseRegister::GetRegisterFromMap(uint32_t addr) {
for (auto &reg : *map_pointer_) {
if (reg->MatchAddr(addr)) {
return reg.get();
}
}
return nullptr;
}
MSeccfgRegister::MSeccfgRegister(
uint32_t addr, std::vector<std::unique_ptr<BaseRegister>> *map_pointer)
: BaseRegister(addr, map_pointer) {}
bool MSeccfgRegister::AnyPmpCfgsLocked() {
for (auto &reg : *map_pointer_) {
// Iterate through PMPCfgX CSRs, returning true is any has a lock bit set
if (reg->MatchAddr(kCSRPMPCfg0, 0xfffffffc)) {
if ((reg->RegisterRead() & 0x80808080) != 0) {
return true;
}
}
}
return false;
}
uint32_t MSeccfgRegister::GetLockMask() {
uint32_t lock_mask = 0xFFFFFFF8;
// When RLB == 0 and any PMPCfgX has a lock bit set RLB must remain 0
if (AnyPmpCfgsLocked() && ((register_value_ & kMSeccfgRlb) == 0)) {
lock_mask |= kMSeccfgRlb;
}
// Once set MMWP cannot be unset
if (register_value_ & kMSeccfgMmwp) {
lock_mask |= kMSeccfgMmwp;
}
// Once set MML cannot be unset
if (register_value_ & kMSeccfgMml) {
lock_mask |= kMSeccfgMml;
}
return lock_mask;
}
uint32_t PmpCfgRegister::GetLockMask() {
BaseRegister *mseccfg = GetRegisterFromMap(kCSRMSeccfg);
assert(mseccfg);
if (mseccfg->RegisterRead() & kMSeccfgRlb) {
return 0;
}
uint32_t lock_mask = 0;
if (register_value_ & 0x80)
lock_mask |= 0xFF;
@ -98,44 +154,53 @@ uint32_t PmpCfgRegister::GetLockMask() {
uint32_t PmpCfgRegister::RegisterWrite(uint32_t newval) {
uint32_t lock_mask = GetLockMask();
uint32_t read_value = register_value_;
register_value_ &= lock_mask;
register_value_ |= (newval & ~lock_mask);
register_value_ &= raz_mask_;
for (int i = 0; i < 4; i++) {
// Reserved check, W = 1, R = 0
if (((register_value_ >> (8 * i)) & 0x3) == 0x2) {
register_value_ &= ~(0x3 << (8 * i));
}
}
register_value_ = HandleReservedVals(register_value_);
return read_value;
}
uint32_t PmpCfgRegister::RegisterSet(uint32_t newval) {
uint32_t lock_mask = GetLockMask();
uint32_t read_value = register_value_;
register_value_ |= (newval & ~lock_mask);
register_value_ &= raz_mask_;
for (int i = 0; i < 4; i++) {
// Reserved check, W = 1, R = 0
if (((register_value_ >> (8 * i)) & 0x3) == 0x2) {
register_value_ &= ~(0x3 << (8 * i));
}
}
register_value_ = HandleReservedVals(register_value_);
return read_value;
}
uint32_t PmpCfgRegister::RegisterClear(uint32_t newval) {
uint32_t lock_mask = GetLockMask();
uint32_t read_value = register_value_;
register_value_ &= (~newval | lock_mask);
register_value_ &= raz_mask_;
register_value_ = HandleReservedVals(register_value_);
return read_value;
}
uint32_t PmpCfgRegister::HandleReservedVals(uint32_t cfg_val) {
BaseRegister *mseccfg = GetRegisterFromMap(kCSRMSeccfg);
assert(mseccfg);
cfg_val &= raz_mask_;
if (mseccfg->RegisterRead() & kMSeccfgMml) {
// No reserved L/R/W/X values when MML Set
return cfg_val;
}
for (int i = 0; i < 4; i++) {
// Reserved check, W = 1, R = 0
if (((register_value_ >> (8 * i)) & 0x3) == 0x2) {
register_value_ &= ~(0x3 << (8 * i));
if (((cfg_val >> (8 * i)) & 0x3) == 0x2) {
cfg_val &= ~(0x3 << (8 * i));
}
}
return read_value;
return cfg_val;
}
uint32_t PmpAddrRegister::GetLockMask() {

View file

@ -26,13 +26,30 @@ class BaseRegister {
virtual uint32_t RegisterClear(uint32_t newval);
virtual uint32_t RegisterRead();
virtual bool ProcessTransaction(bool *match, RegisterTransaction *trans);
virtual bool MatchAddr(uint32_t addr);
virtual bool MatchAddr(uint32_t addr, uint32_t addr_mask = 0xFFFFFFFF);
virtual uint32_t GetLockMask();
protected:
uint32_t register_value_;
uint32_t register_address_;
std::vector<std::unique_ptr<BaseRegister>> *map_pointer_;
BaseRegister *GetRegisterFromMap(uint32_t addr);
};
/**
* Machine Security Configuration class
*
* Has special behaviour for when bits are locked so requires a custom
* `GetLockMask` implementation
*/
class MSeccfgRegister : public BaseRegister {
public:
MSeccfgRegister(uint32_t addr,
std::vector<std::unique_ptr<BaseRegister>> *map_pointer);
uint32_t GetLockMask();
private:
bool AnyPmpCfgsLocked();
};
/**
@ -48,6 +65,7 @@ class PmpCfgRegister : public BaseRegister {
uint32_t RegisterClear(uint32_t newval);
private:
uint32_t HandleReservedVals(uint32_t cfg_val);
const uint32_t raz_mask_ = 0x9F9F9F9F;
};

View file

@ -7,6 +7,10 @@
#include <iostream>
RegisterModel::RegisterModel(SimCtrl *sc, CSRParams *params) : simctrl_(sc) {
register_map_.push_back(
std::make_unique<MSeccfgRegister>(kCSRMSeccfg, &register_map_));
register_map_.push_back(
std::make_unique<NonImpRegister>(kCSRMSeccfgh, &register_map_));
// Instantiate all the registers
for (unsigned int i = 0; i < 4; i++) {
uint32_t reg_addr = 0x3A0 + i;
@ -29,11 +33,11 @@ RegisterModel::RegisterModel(SimCtrl *sc, CSRParams *params) : simctrl_(sc) {
}
}
// mcountinhibit
// - MSBs are always 1: unused counters cannot be enabled
// - MSBs are always 0: unused counters cannot be inhibited
// - Bit 1 is always 0: time cannot be disabled
uint32_t mcountinhibit_mask =
(~((0x1 << params->MHPMCounterNum) - 1) << 3) | 0x2;
uint32_t mcountinhibit_resval = ~((0x1 << params->MHPMCounterNum) - 1) << 3;
uint32_t mcountinhibit_resval = 0;
register_map_.push_back(std::make_unique<WARLRegister>(
0x320, &register_map_, mcountinhibit_mask, mcountinhibit_resval));
// Performance counter setup
@ -41,7 +45,7 @@ RegisterModel::RegisterModel(SimCtrl *sc, CSRParams *params) : simctrl_(sc) {
uint32_t reg_addr = 0x320 + i;
if (i < (params->MHPMCounterNum + 3)) {
register_map_.push_back(std::make_unique<WARLRegister>(
reg_addr, &register_map_, 0xFFFFFFFF, 0x1 << i));
reg_addr, &register_map_, 0xFFFFFFFF, 0x1 << (i - 3)));
} else {
register_map_.push_back(
std::make_unique<NonImpRegister>(reg_addr, &register_map_));

View file

@ -58,6 +58,8 @@ CSR(MHPMEvent28, 0x33C)
CSR(MHPMEvent29, 0x33D)
CSR(MHPMEvent30, 0x33E)
CSR(MHPMEvent31, 0x33F)
CSR(MSeccfg, 0x747)
CSR(MSeccfgh, 0x757)
CSR(MCycle, 0xB00)
CSR(MInstret, 0xB02)
CSR(MHPMCounter3, 0xB03)

View file

@ -15,6 +15,11 @@ enum CSRegisterAddr : int {
#include "csr_listing.def"
};
// Individual bits for MSECCFG CSR
const int kMSeccfgMml = 0x1;
const int kMSeccfgMmwp = 0x2;
const int kMSeccfgRlb = 0x4;
// Create an indexable array of all CSR addresses
static const uint16_t CSRAddresses[] = {
#define CSR(reg, addr) addr,

View file

@ -33,6 +33,11 @@ module tb_cs_registers #(
logic illegal_csr_insn_o;
logic csr_access_d;
ibex_pkg::csr_num_e csr_addr_d;
logic [31:0] csr_wdata_d;
ibex_pkg::csr_op_e csr_op_d;
logic csr_op_en_d;
//-----------------
// Reset generation
//-----------------
@ -121,12 +126,26 @@ module tb_cs_registers #(
csr_addr_i,
csr_wdata_i,
csr_rdata_o);
reg_dpi::driver_tick("reg_driver",
csr_access_i,
csr_op_i,
csr_op_en_i,
csr_addr_i,
csr_wdata_i);
csr_access_d,
csr_op_d,
csr_op_en_d,
csr_addr_d,
csr_wdata_d);
// Use NBA to drive inputs to ensure correct scheduling.
// This always_ff block will be executed on the positive edge of the clock with undefined order
// vs all other always_ff triggered on the positive edge of the clock. If `driver_tick` drives
// the inputs directly some of the always_ff blocks will see the old version of the inputs and
// others will see the new version depending on scheduling order. This schedules all the inputs
// to be NBA updates to avoid the race condition (in effect acting like any other always_ff
// block with the _d values being computed via DPI rather than combinational logic).
csr_access_i <= csr_access_d;
csr_addr_i <= csr_addr_d;
csr_wdata_i <= csr_wdata_d;
csr_op_i <= csr_op_d;
csr_op_en_i <= csr_op_en_d;
end
endmodule

View file

@ -13,9 +13,11 @@ int main(int argc, char **argv) {
simctrl.SetTop(&top, &top.IO_CLK, &top.IO_RST_N,
VerilatorSimCtrlFlags::ResetPolarityNegative);
memutil.RegisterMemoryArea(
"ram",
"TOP.ibex_riscv_compliance.u_ram.u_ram.gen_generic.u_impl_generic");
MemArea ram(
"TOP.ibex_riscv_compliance.u_ram.u_ram.gen_generic.u_impl_generic",
64 * 1024 / 4, 4);
memutil.RegisterMemoryArea("ram", 0x0, &ram);
simctrl.RegisterExtension(&memutil);
return simctrl.Exec(argc, argv).first;

View file

@ -5,24 +5,23 @@ CAPI=2:
name: "lowrisc:ibex:ibex_riscv_compliance:0.1"
description: "Ibex simulation for RISC-V compliance testing (using Verilator)"
filesets:
files_sim_verilator:
files_sim:
depend:
- lowrisc:dv_verilator:memutil_verilator
- lowrisc:dv_verilator:simutil_verilator
- lowrisc:ibex:ibex_core_tracing
- lowrisc:ibex:ibex_top_tracing
- lowrisc:ibex:sim_shared
files:
- rtl/ibex_riscv_compliance.sv
- ibex_riscv_compliance.cc: { file_type: cppSource }
- rtl/riscv_testutil.sv
file_type: systemVerilogSource
files_verilator_waiver:
files_verilator:
depend:
- lowrisc:dv_verilator:memutil_verilator
- lowrisc:dv_verilator:simutil_verilator
files:
- ibex_riscv_compliance.cc: { file_type: cppSource }
- lint/verilator_waiver.vlt: {file_type: vlt}
parameters:
RV32E:
datatype: int
@ -78,6 +77,24 @@ parameters:
default: 0
description: "Enables static branch prediction (EXPERIMENTAL)"
DbgTriggerEn:
datatype: int
default: 0
paramtype: vlogparam
description: "Enable support for debug triggers. "
SecureIbex:
datatype: int
default: 0
paramtype: vlogparam
description: "Enables security hardening features (EXPERIMENTAL) [0/1]"
ICacheScramble:
datatype: int
default: 0
paramtype: vlogparam
description: "Enables ICache scrambling feature (EXPERIMENTAL) [0/1]"
PMPEnable:
datatype: int
default: 0
@ -96,12 +113,24 @@ parameters:
paramtype: vlogparam
description: "Number of PMP regions"
MHPMCounterNum:
datatype: int
paramtype: vlogparam
default: 0
description: Number of performance monitor event counters [0/29]
MHPMCounterWidth:
datatype: int
paramtype: vlogparam
default: 40
description: Bit width of performance monitor event counters [32/64]
targets:
sim:
default_tool: verilator
filesets:
- tool_verilator ? (files_verilator_waiver)
- files_sim_verilator
- files_sim
- tool_verilator ? (files_verilator)
parameters:
- RV32E
- RV32M
@ -112,9 +141,14 @@ targets:
- BranchTargetALU
- WritebackStage
- BranchPredictor
- DbgTriggerEn
- SecureIbex
- ICacheScramble
- PMPEnable
- PMPGranularity
- PMPNumRegions
- MHPMCounterNum
- MHPMCounterWidth
toplevel: ibex_riscv_compliance
tools:
verilator:
@ -127,6 +161,6 @@ targets:
- '--trace-structs'
- '--trace-params'
- '--trace-max-array 1024'
- '-CFLAGS "-std=c++11 -Wall -DVM_TRACE_FMT_FST -DTOPLEVEL_NAME=ibex_riscv_compliance -g"'
- '-CFLAGS "-std=c++14 -Wall -DVM_TRACE_FMT_FST -DTOPLEVEL_NAME=ibex_riscv_compliance -g"'
- '-LDFLAGS "-pthread -lutil -lelf"'
- "-Wall"

View file

@ -9,7 +9,7 @@
// 'rtl' directory), see verilator_waiver_rtl.vlt in the same
// directory.
//
// See https://www.veripool.org/projects/verilator/wiki/Manual-verilator#CONFIGURATION-FILES
// See https://verilator.org/guide/latest/exe_verilator.html#configuration-files
// for documentation.
//
// Important: This file must included *before* any other Verilog file is read.

View file

@ -15,18 +15,23 @@ module ibex_riscv_compliance (
input IO_RST_N
);
parameter bit PMPEnable = 1'b0;
parameter int unsigned PMPGranularity = 0;
parameter int unsigned PMPNumRegions = 4;
parameter bit RV32E = 1'b0;
parameter ibex_pkg::rv32m_e RV32M = ibex_pkg::RV32MFast;
parameter ibex_pkg::rv32b_e RV32B = ibex_pkg::RV32BNone;
parameter ibex_pkg::regfile_e RegFile = ibex_pkg::RegFileFF;
parameter bit BranchTargetALU = 1'b0;
parameter bit WritebackStage = 1'b0;
parameter bit ICache = 1'b0;
parameter bit ICacheECC = 1'b0;
parameter bit BranchPredictor = 1'b0;
parameter bit PMPEnable = 1'b0;
parameter int unsigned PMPGranularity = 0;
parameter int unsigned PMPNumRegions = 4;
parameter int unsigned MHPMCounterNum = 0;
parameter int unsigned MHPMCounterWidth = 40;
parameter bit RV32E = 1'b0;
parameter ibex_pkg::rv32m_e RV32M = ibex_pkg::RV32MFast;
parameter ibex_pkg::rv32b_e RV32B = ibex_pkg::RV32BNone;
parameter ibex_pkg::regfile_e RegFile = ibex_pkg::RegFileFF;
parameter bit BranchTargetALU = 1'b0;
parameter bit WritebackStage = 1'b0;
parameter bit ICache = 1'b0;
parameter bit ICacheECC = 1'b0;
parameter bit BranchPredictor = 1'b0;
parameter bit SecureIbex = 1'b0;
parameter bit ICacheScramble = 1'b0;
parameter bit DbgTriggerEn = 1'b0;
logic clk_sys, rst_sys_n;
@ -61,6 +66,9 @@ module ibex_riscv_compliance (
logic [31:0] host_rdata [NrHosts];
logic host_err [NrHosts];
logic [6:0] ibex_data_rdata_intg;
logic [6:0] ibex_instr_rdata_intg;
// devices (slaves)
logic device_req [NrDevices];
logic [31:0] device_addr [NrDevices];
@ -79,7 +87,6 @@ module ibex_riscv_compliance (
assign cfg_device_addr_base[TestUtilDevice] = 32'h20000;
assign cfg_device_addr_mask[TestUtilDevice] = ~32'h3FF; // 1 kB
bus #(
.NrDevices (NrDevices),
.NrHosts (NrHosts ),
@ -112,60 +119,98 @@ module ibex_riscv_compliance (
.cfg_device_addr_mask
);
ibex_core_tracing #(
.PMPEnable (PMPEnable ),
.PMPGranularity (PMPGranularity ),
.PMPNumRegions (PMPNumRegions ),
.RV32E (RV32E ),
.RV32M (RV32M ),
.RV32B (RV32B ),
.RegFile (RegFile ),
.BranchTargetALU (BranchTargetALU ),
.WritebackStage (WritebackStage ),
.ICache (ICache ),
.ICacheECC (ICacheECC ),
.BranchPredictor (BranchPredictor ),
.DmHaltAddr (32'h00000000 ),
.DmExceptionAddr (32'h00000000 )
) u_core (
.clk_i (clk_sys ),
.rst_ni (rst_sys_n ),
if (SecureIbex) begin : g_mem_rdata_ecc
logic [31:0] unused_data_rdata;
logic [31:0] unused_instr_rdata;
.test_en_i ('b0 ),
prim_secded_inv_39_32_enc u_data_rdata_intg_gen (
.data_i (host_rdata[CoreD]),
.data_o ({ibex_data_rdata_intg, unused_data_rdata})
);
.hart_id_i (32'b0 ),
prim_secded_inv_39_32_enc u_instr_rdata_intg_gen (
.data_i (host_rdata[CoreI]),
.data_o ({ibex_instr_rdata_intg, unused_instr_rdata})
);
end else begin : g_no_mem_rdata_ecc
assign ibex_data_rdata_intg = '0;
assign ibex_instr_rdata_intg = '0;
end
ibex_top_tracing #(
.PMPEnable (PMPEnable ),
.PMPGranularity (PMPGranularity ),
.PMPNumRegions (PMPNumRegions ),
.MHPMCounterNum (MHPMCounterNum ),
.MHPMCounterWidth (MHPMCounterWidth ),
.RV32E (RV32E ),
.RV32M (RV32M ),
.RV32B (RV32B ),
.RegFile (RegFile ),
.BranchTargetALU (BranchTargetALU ),
.WritebackStage (WritebackStage ),
.ICache (ICache ),
.ICacheECC (ICacheECC ),
.BranchPredictor (BranchPredictor ),
.DbgTriggerEn (DbgTriggerEn ),
.SecureIbex (SecureIbex ),
.ICacheScramble (ICacheScramble ),
.DmBaseAddr (32'h00000000 ),
.DmAddrMask (32'h00000003 ),
.DmHaltAddr (32'h00000000 ),
.DmExceptionAddr (32'h00000000 )
) u_top (
.clk_i (clk_sys ),
.rst_ni (rst_sys_n ),
.test_en_i ('b0 ),
.scan_rst_ni (1'b1 ),
.ram_cfg_i ('b0 ),
.hart_id_i (32'b0 ),
// First instruction executed is at 0x0 + 0x80
.boot_addr_i (32'h00000000 ),
.boot_addr_i (32'h00000000 ),
.instr_req_o (host_req[CoreI] ),
.instr_gnt_i (host_gnt[CoreI] ),
.instr_rvalid_i (host_rvalid[CoreI]),
.instr_addr_o (host_addr[CoreI] ),
.instr_rdata_i (host_rdata[CoreI] ),
.instr_err_i (host_err[CoreI] ),
.instr_req_o (host_req[CoreI] ),
.instr_gnt_i (host_gnt[CoreI] ),
.instr_rvalid_i (host_rvalid[CoreI] ),
.instr_addr_o (host_addr[CoreI] ),
.instr_rdata_i (host_rdata[CoreI] ),
.instr_rdata_intg_i (ibex_instr_rdata_intg),
.instr_err_i (host_err[CoreI] ),
.data_req_o (host_req[CoreD] ),
.data_gnt_i (host_gnt[CoreD] ),
.data_rvalid_i (host_rvalid[CoreD]),
.data_we_o (host_we[CoreD] ),
.data_be_o (host_be[CoreD] ),
.data_addr_o (host_addr[CoreD] ),
.data_wdata_o (host_wdata[CoreD] ),
.data_rdata_i (host_rdata[CoreD] ),
.data_err_i (host_err[CoreD] ),
.data_req_o (host_req[CoreD] ),
.data_gnt_i (host_gnt[CoreD] ),
.data_rvalid_i (host_rvalid[CoreD] ),
.data_we_o (host_we[CoreD] ),
.data_be_o (host_be[CoreD] ),
.data_addr_o (host_addr[CoreD] ),
.data_wdata_o (host_wdata[CoreD] ),
.data_wdata_intg_o ( ),
.data_rdata_i (host_rdata[CoreD] ),
.data_rdata_intg_i (ibex_data_rdata_intg ),
.data_err_i (host_err[CoreD] ),
.irq_software_i (1'b0 ),
.irq_timer_i (1'b0 ),
.irq_external_i (1'b0 ),
.irq_fast_i (15'b0 ),
.irq_nm_i (1'b0 ),
.irq_software_i (1'b0 ),
.irq_timer_i (1'b0 ),
.irq_external_i (1'b0 ),
.irq_fast_i (15'b0 ),
.irq_nm_i (1'b0 ),
.debug_req_i ('b0 ),
.scramble_key_valid_i ('0 ),
.scramble_key_i ('0 ),
.scramble_nonce_i ('0 ),
.scramble_req_o ( ),
.fetch_enable_i ('b1 ),
.alert_minor_o ( ),
.alert_major_o ( ),
.core_sleep_o ( )
.debug_req_i ('b0 ),
.crash_dump_o ( ),
.double_fault_seen_o ( ),
.fetch_enable_i (ibex_pkg::IbexMuBiOn ),
.alert_minor_o ( ),
.alert_major_internal_o ( ),
.alert_major_bus_o ( ),
.core_sleep_o ( )
);
// SRAM block for instruction and data storage

View file

@ -5,14 +5,20 @@
project: ibex
// These keys are expected by dvsim.py, so we have to set them to something.
doc_server: bogus.doc.server
results_server: bogus.results.server
book: bogus.book.domain
doc_server: bogus.doc.server
results_server: bogus.results.server
results_html_name: report.html
// Default directory structure for the output
scratch_base_path: "{scratch_root}/{dut}.{flow}.{tool}"
scratch_path: "{scratch_base_path}/{branch}"
tool_srcs_dir: "{scratch_path}/{tool}"
// Common DVSIM data structures
build_pass_patterns: []
build_fail_patterns: []
// The current design level
design_level: "ip"
}

25
dv/uvm/core_ibex/.gitignore vendored Normal file
View file

@ -0,0 +1,25 @@
# This is generated by VCS when running DV simulations with WAVE=1.
ucli.key
# This is generated by UVM when running simulations and doesn't seem
# to be something you can disable.
tr_db.log
# This is the default output directory in dv/uvm/core_ibex and
# contains auto-generated files from building and running tests.
out
# This is generated by the Makefile based on the ibex configuration
riscv_dv_extension/riscv_core_setting.sv
# This is generated by Xcelium when running DV simulations, even with WAVE=0
waves.shm
# Log files generated by Cadence tools when running DV simulations
xrun.history
xrun.log
xmsc.log
# Generated by coverage
imc.key
mdv.log

View file

@ -2,11 +2,20 @@
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
GEN_DIR := $(realpath ../../../vendor/google_riscv-dv)
TOOLCHAIN := ${RISCV_TOOLCHAIN}
# Top-Level Makefile
###############################################################################
.SUFFIXES:
export
# Explicitly ask for the bash shell
SHELL := bash
SHELL := bash
# Build the 'all' target by default, override with e.g. GOAL=rtl_tb_compile
GOAL ?= all
###############################################################################
# CONFIGURATION KNOBS
# Seed for instruction generator and RTL simulation
#
@ -17,423 +26,79 @@ SHELL := bash
# start passing again without fixing the bug).
SEED := $(shell echo $$RANDOM)
# This is the top-level output directory. Everything we generate goes in
# here. Most generated stuff actually goes in $(OUT)/seed-$(SEED), which allows
# us to run multiple times without deleting existing results.
OUT := out
OUT-SEED := $(OUT)/seed-$(SEED)
# Run time options for the instruction generator
GEN_OPTS :=
# Compile time options for ibex RTL simulation
COMPILE_OPTS +=
# Run time options for ibex RTL simulation
SIM_OPTS :=
# Enable waveform dumping
WAVES := 1
WAVES := 0
# Enable coverage dump
COV := 0
# RTL simulator
SIMULATOR := vcs
# RTL simulator (xlm, vcs, questa, dsim, )
SIMULATOR := xlm
# ISS (spike, ovpsim)
ISS := spike
# ISS runtime options
ISS_OPTS :=
# ISA
ISA := rv32imcb
# Test name (default: full regression)
TEST := all
TESTLIST := riscv_dv_extension/testlist.yaml
RISCV-DV-TESTLIST := riscv_dv_extension/testlist.yaml
DIRECTED-TESTLIST := directed_tests/directed_testlist.yaml
# Verbose logging
VERBOSE :=
# Number of iterations for each test, assign a non-zero value to override the
VERBOSE := 0
# Number of iterations for each test, assign a non-empty value to override the
# iteration count in the test list
ITERATIONS := 0
# LSF CMD
LSF_CMD :=
# Generator timeout limit in seconds
TIMEOUT := 1800
# Privileged CSR YAML description file
CSR_FILE := riscv_dv_extension/csr_description.yaml
# Pass/fail signature address at the end of test
ITERATIONS :=
# Pass/fail signature address at the end of test (see riscv_dv handshake documentation)
SIGNATURE_ADDR := 8ffffffc
### Ibex top level parameters ###
### Required by RISCV-DV, some ISS, and RTL ###
# PMP Regions
PMP_REGIONS := 16
# PMP Granularity
PMP_GRANULARITY := 0
IBEX_CONFIG := opentitan
IBEX_CONFIG := experimental-maxperf-pmp-bmfull-icache
# Path to DUT used for coverage reports
DUT_COV_RTL_PATH := "ibex_top"
# TODO(udinator) - might need options for SAIL/Whisper/Spike
ifeq (${ISS},ovpsim)
ISS_OPTS += --override riscvOVPsim/cpu/PMP_registers=${PMP_REGIONS}
ISS_OPTS += --override riscvOVPsim/cpu/PMP_grain=${PMP_GRANULARITY}
export EXTRA_COSIM_CFLAGS ?=
ifeq ($(COSIM_SIGSEGV_WORKAROUND), 1)
EXTRA_COSIM_CFLAGS += -DCOSIM_SIGSEGV_WORKAROUND
endif
# A version of $(OUT) with a trailing '/'. The point is that this will
# never match the name of a phony targets like "sim" (which causes
# strange rebuilds otherwise). The call to $(dir ) avoids adding
# another trailing slash if $(OUT) had one already.
OUT-DIR := $(dir $(OUT)/)
###############################################################################
# This expands to '@' if VERBOSE is 0 or not set, and to the empty
# string otherwise. Prefix commands with it in order that they only
# get printed when VERBOSE.
verb = $(if $(filter-out 0,$(VERBOSE)),,@)
# Setup the necessary paths for all python scripts to find all other relevant modules.
export PYTHONPATH := $(shell python3 -c 'from scripts.setup_imports import get_pythonpath; get_pythonpath()')
SHELL=/bin/bash
# We run the 'create_metadata' step in this top-level makefile, so the sub-make
# invocations can query the generated metadata objects. Since the targets/dependencies
# are extracted from this metadata, it must be query-able in the makefile 'immediate' stage.
.PHONY: run
run:
@env PYTHONPATH=$(PYTHONPATH) python3 ./scripts/metadata.py \
--op "create_metadata" \
--dir-metadata $(METADATA-DIR) \
--dir-out $(OUT-DIR) \
--args-list "\
SEED=$(SEED) WAVES=$(WAVES) COV=$(COV) SIMULATOR=$(SIMULATOR) \
ISS=$(ISS) TEST=$(TEST) VERBOSE=$(VERBOSE) ITERATIONS=$(ITERATIONS) \
SIGNATURE_ADDR=$(SIGNATURE_ADDR) IBEX_CONFIG=$(IBEX_CONFIG) \
DUT_COV_RTL_PATH=$(DUT_COV_RTL_PATH)"
@$(MAKE) --file wrapper.mk --environment-overrides --no-print-directory $(GOAL)
export PRJ_DIR:= $(realpath ../../..)
###############################################################################
all: sim
# This is the top-level output directory. Everything we generate goes in
# here.
OUT := out
instr: iss_sim
# Derived directories from $(OUT), used for stuff that's built once or
# stuff that gets run for each seed, respectively. Using OUT-DIR on
# the way avoids ugly double slashes if $(OUT) happens to end in a /.
export OUT-DIR := $(dir $(OUT)/)
export METADATA-DIR := $(OUT-DIR)metadata
sim: post_compare cov
# riscv-dv extension directory
export EXT_DIR := riscv_dv_extension
###############################################################################
.PHONY: clean
clean:
rm -rf $(OUT-DIR)
# Common options for all targets
COMMON_OPTS := $(if $(call equal,$(VERBOSE),1),--verbose,)
# Options for all targets that depend on the tests we're running.
TEST_OPTS := $(COMMON_OPTS) \
--start_seed=${SEED} \
--test="${TEST}" \
--testlist=${TESTLIST} \
--iterations=${ITERATIONS}
# Options used for privileged CSR test generation
CSR_OPTS=--csr_yaml=${CSR_FILE} \
--isa="${ISA}" \
--end_signature_addr=${SIGNATURE_ADDR}
RISCV_DV_OPTS=--custom_target=riscv_dv_extension \
--isa="${ISA}" \
--mabi=ilp32 \
# To avoid cluttering the output directory with stamp files, we place them in
# $(metadata).
metadata := $(OUT-SEED)/.metadata
# This is a list of directories that are automatically generated by some
# targets. To ensure the directory has been built, add a order-only dependency
# (with the pipe symbol before it) on the directory name and add the directory
# to this list.
gen-dirs := $(OUT-DIR) $(OUT-SEED) $(metadata) $(OUT-DIR)rtl_sim
$(gen-dirs): %:
mkdir -p $@
# sim-cfg-mk is a makefile fragment that sets-up anything simulator specific, it
# is generated by sim_makefrag_gen.py
sim-cfg-mk = $(OUT-DIR).sim-cfg.mk
# The include of $(sim-cfg-mk) below tells Make that it should ensure the file
# exists. This rule tells Make how to build it. We also want to ensure it's
# built on every run. Declaring the rule to be .PHONY doesn't work because it
# causes Make to no longer think the rule actually generates the file. If you
# do that, the file gets re-built, but Make doesn't read the new contents. So
# instead we depend on FORCE (a phony target). This ensures a rebuild, but also
# causes an infinite recursion: when we re-read this file to include the new
# contents of $(sim-cfg-mk), we run the rule again. To avoid that, we check for
# MAKE_RESTARTS, which is defined on re-runs. Phew!
ifndef MAKE_RESTARTS
$(sim-cfg-mk): FORCE | $(OUT-DIR)
@./sim_makefrag_gen.py $(SIMULATOR) $(IBEX_CONFIG) $(PRJ_DIR) $@
endif
include $(sim-cfg-mk)
.PHONY: test-cfg
test-cfg:
@echo "COMPILE_OPTS" $(COMPILE_OPTS)
@echo "SIM_OPTS" $(SIM_OPTS)
rm -f $(EXT_DIR)/riscv_core_setting.sv
###############################################################################
# Utility functions.
#
# If VS is a list of variable names, P is a path and X is a string, then $(call
# dump-vars,P,X,VS) will expand to a list of 'file' commands that write each
# variable to P in Makefile syntax, but with "last-X-" prepended. At the start
# of the file, we also define last-X-vars-loaded to 1. You can use this to
# check whether there was a dump file at all.
#
# Note that this doesn't work by expanding to a command. Instead, *evaluating*
# dump-vars causes the variables to be dumped.
dump-var = $(file >>$(1),last-$(2)-$(3) := $($(3)))
dump-vars = $(file >$(1),last-$(2)-vars-loaded := .) \
$(foreach name,$(3),$(call dump-var,$(1),$(2),$(name)))
# equal checks whether two strings are equal, evaluating to '.' if they are and
# '' otherwise.
both-empty = $(if $(1),,$(if $(2),,.))
find-find = $(if $(and $(findstring $(1),$(2)),$(findstring $(2),$(1))),.,)
equal = $(or $(call both-empty,$(1),$(2)),$(call find-find,$(1),$(2)))
# var-differs is used to check whether a variable has changed since it was
# dumped. If it has changed, the function evaluates to '.' (with some
# whitespace) and prints a message to the console; if not, it evaluates to ''.
#
# Call it as $(call var-differs,X,TGT,V).
var-differs = \
$(if $(call equal,$(strip $($(3))),$(strip $(last-$(1)-$(3)))),,\
.$(info Repeating $(2) because variable $(3) has changed value.))
# vars-differ is used to check whether several variables have the same value as
# they had when they were dumped. If we haven't loaded the dumpfile, it
# silently evaluates to '!'. Otherwise, if all the variables match, it
# evaluates to '.'. If not, it evaluates to '.' and prints some messages to the
# console explaining why a rebuild is happening.
#
# Call it as $(call vars-differ,X,TGT,VS).
vars-differ-lst = $(foreach v,$(3),$(call var-differs,$(1),$(2),$(v)))
vars-differ-sp = \
$(if $(last-$(1)-vars-loaded),\
$(if $(strip $(call vars-differ-lst,$(1),$(2),$(3))),.,),\
!)
vars-differ = $(strip $(call vars-differ-sp,$(1),$(2),$(3)))
# A phony target which can be used to force recompilation.
.PHONY: FORCE
FORCE:
# vars-prereq is empty if every variable in VS matches the last run (loaded
# with tag X), otherwise it is set to FORCE (which will force a recompile and
# might print a message to the console explaining why we're rebuilding TGT).
#
# Call it as $(call vars-prereq,X,TGT,VS)
vars-prereq = $(if $(call vars-differ,$(1),$(2),$(3)),FORCE,)
###############################################################################
# Generate random instructions
#
# This depends on the vendored in code in $(GEN_DIR). It also depends on the
# values of some variables (we want to regenerate things if, for example, the
# simulator changes). Since we're writing out to $(OUT-SEED), we don't have to
# depend on the value of SEED. However, we do have to make sure that the
# variables whose names are listed in $(gen-var-deps) haven't changed.
#
# To do this variable tracking, we dump each of the variables to a Makefile
# fragment and try to load it up the next time around.
gen-var-deps := GEN_OPTS SIMULATOR RISCV_DV_OPTS CSR_OPTS \
SIGNATURE_ADDR PMP_REGIONS PMP_GRANULARITY TEST_OPTS
# Load up the generation stage's saved variable values. If this fails, that's
# no problem: we'll assume that the previous run either doesn't exist or
# something went wrong.
-include $(metadata)/gen-vars.mk
# gen-vars-prereq is empty if every variable in gen-var-deps matches the last run,
# otherwise it is set to FORCE (which will force a recompile). Note that we
# define it with '=', not ':=', so we don't evaluate it if we're not trying to
# run the gen target.
gen-vars-prereq = \
$(call vars-prereq,gen,building instruction generator,$(gen-var-deps))
# A variable containing a file list for the riscv-dv vendored-in module.
# Depending on these files gives a safe over-approximation that will ensure we
# rebuild things if that module changes.
#
# Note that this is defined with ":=". As a result, we'll always run the find
# command exactly once. Wasteful if we're trying to make clean, but much better
# than running it for every target otherwise.
risc-dv-files := $(shell find $(GEN_DIR) -type f)
# This actually runs the instruction generator. Note that the rule depends on
# the (phony) FORCE target if any variables have changed. If the rule actually
# runs, it starts by deleting any existing contents of $(OUT-SEED)/instr_gen.
$(metadata)/instr_gen.gen.stamp: \
$(gen-vars-prereq) $(risc-dv-files) $(TESTLIST) | $(metadata)
$(verb)rm -rf $(OUT-SEED)/instr_gen
$(verb)python3 ${GEN_DIR}/run.py \
--output=$(OUT-SEED)/instr_gen ${GEN_OPTS} \
--steps=gen \
--gen_timeout=${TIMEOUT} \
--lsf_cmd="${LSF_CMD}" \
--simulator="${SIMULATOR}" \
${RISCV_DV_OPTS} \
${TEST_OPTS} \
${CSR_OPTS} \
--sim_opts="+uvm_set_inst_override=riscv_asm_program_gen,ibex_asm_program_gen,"uvm_test_top.asm_gen" \
+signature_addr=${SIGNATURE_ADDR} +pmp_num_regions=${PMP_REGIONS} \
+pmp_granularity=${PMP_GRANULARITY} +tvec_alignment=8"
$(call dump-vars,$(metadata)/gen-vars.mk,gen,$(gen-var-deps))
@touch $@
.PHONY: gen
gen: $(metadata)/instr_gen.gen.stamp
###############################################################################
# Compile the generated assembly programs
#
# We don't explicitly track dependencies on the RISCV toolchain, so this
# doesn't depend on anything more than the instr_gen stage did.
$(metadata)/instr_gen.compile.stamp: \
$(metadata)/instr_gen.gen.stamp $(TESTLIST)
$(verb)python3 ${GEN_DIR}/run.py \
--o=$(OUT-SEED)/instr_gen ${GEN_OPTS} \
--steps=gcc_compile \
${TEST_OPTS} \
--gcc_opts=-mno-strict-align \
${RISCV_DV_OPTS} && \
touch $@
.PHONY: gcc_compile
gcc_compile: $(metadata)/instr_gen.compile.stamp
###############################################################################
# Run the instruction set simulator
#
# This (obviously) depends on having compiled the generated programs, so we
# don't have to worry about variables that affect the 'gen' stage. However, the
# ISS and ISS_OPTS variables do affect the output, so we need to dump them. See
# the 'gen' stage for more verbose explanations of how this works.
iss-var-deps := ISS ISS_OPTS
-include $(metadata)/iss-vars.mk
iss-vars-prereq = $(call vars-prereq,iss,running ISS,$(iss-var-deps))
$(metadata)/instr_gen.iss.stamp: \
$(iss-vars-prereq) $(TESTLIST) $(metadata)/instr_gen.compile.stamp
$(verb)python3 ${GEN_DIR}/run.py \
--o=$(OUT-SEED)/instr_gen ${GEN_OPTS} \
--steps=iss_sim \
${TEST_OPTS} \
--iss="${ISS}" \
--iss_opts="${ISS_OPTS}" \
${RISCV_DV_OPTS}
$(call dump-vars,$(metadata)/iss-vars.mk,iss,$(iss-var-deps))
@touch $@
.PHONY: iss_sim
iss_sim: $(metadata)/instr_gen.iss.stamp
###############################################################################
# Compile ibex core TB
#
# Note that (unlike everything else) this doesn't depend on the seed: the DUT
# doesn't depend on which test we're running!
#
# It does, however, depend on various variables. These are listed in
# compile-var-deps. See the 'gen' stage for more verbose explanations of how
# the variable dumping works.
#
# The compiled ibex testbench (obviously!) also depends on the design and the
# DV code. The clever way of doing this would be to look at a dependency
# listing generated by the simulator as a side-effect of doing the compile (a
# bit like using the -M flags with a C compiler). Unfortunately, that doesn't
# look like it's particularly easy, so we'll just depend on every .v, .sv or
# .svh file in the dv or rtl directories. Note that this variable is set with
# '=', rather than ':='. This means that we don't bother running the find
# commands unless we need the compiled testbench.
all-verilog = \
$(shell find ../../../rtl -name '*.v' -o -name '*.sv' -o -name '*.svh') \
$(shell find ../.. -name '*.v' -o -name '*.sv' -o -name '*.svh')
compile-var-deps := COMMON_OPTS SIMULATOR COV WAVES COMPILE_OPTS
-include $(OUT-DIR)rtl_sim/.compile-vars.mk
compile-vars-prereq = $(call vars-prereq,comp,compiling TB,$(compile-var-deps))
$(call dump-vars-match,$(compile-var-deps),comp)
cov-arg := $(if $(call equal,$(COV),1),--en_cov,)
wave-arg := $(if $(call equal,$(WAVES),1),--en_wave,)
lsf-arg := $(if $(LSF_CMD),--lsf_cmd="$(LSF_CMD)",)
$(OUT-DIR)rtl_sim/.compile.stamp: \
$(compile-vars-prereq) $(all-verilog) $(risc-dv-files) \
sim.py yaml/rtl_simulation.yaml \
| $(OUT-DIR)rtl_sim
$(verb)./sim.py \
--o=$(OUT-DIR) \
--steps=compile \
${COMMON_OPTS} \
--simulator="${SIMULATOR}" --simulator_yaml=yaml/rtl_simulation.yaml \
$(cov-arg) $(wave-arg) $(lsf-arg) \
--cmp_opts="${COMPILE_OPTS}"
$(call dump-vars,$(OUT-DIR)rtl_sim/.compile-vars.mk,comp,$(compile-var-deps))
@touch $@
.PHONY: compile
compile: $(OUT-DIR)rtl_sim/.compile.stamp
###############################################################################
# Run ibex RTL simulation with generated programs
#
# Because we compile a TB once rather than for each seed, we have to copy in
# that directory before we start. We make this step (rather than actually
# running the test) dependent on having the right variables. That way, we'll
# correctly delete the sim directory and re-copy it if necessary.
#
# Note that the variables we depend on are gen-vars-prereq. We also depend on
# COV and WAVES, but these dependencies will come for free from the dependency
# on the compiled TB.
$(metadata)/rtl_sim.compile.stamp: \
$(gen-vars-prereq) $(risc-dv-files) $(OUT-DIR)rtl_sim/.compile.stamp
rm -rf $(OUT-SEED)/rtl_sim
cp -r $(OUT-DIR)rtl_sim $(OUT-SEED)
@touch $@
# This rule actually runs the simulation. It depends on the copied-in testbench
# and also on us having already compiled the test programs.
$(metadata)/rtl_sim.run.stamp: \
$(metadata)/rtl_sim.compile.stamp \
$(metadata)/instr_gen.compile.stamp $(TESTLIST) \
sim.py yaml/rtl_simulation.yaml
$(verb)./sim.py \
--o=$(OUT-SEED) \
--steps=sim \
${TEST_OPTS} \
--simulator="${SIMULATOR}" --simulator_yaml=yaml/rtl_simulation.yaml \
$(cov-arg) $(wave-arg) $(lsf-arg) \
--sim_opts="+signature_addr=${SIGNATURE_ADDR} ${SIM_OPTS}"
@touch $@
.PHONY: rtl_sim
rtl_sim: $(metadata)/rtl_sim.run.stamp
###############################################################################
# Compare ISS and RTL sim results
$(OUT-SEED)/regr.log: \
$(metadata)/instr_gen.iss.stamp \
$(metadata)/rtl_sim.run.stamp $(TESTLIST)
$(verb)rm -f $@
$(verb)./sim.py \
--o=$(OUT-SEED) \
--steps=compare \
${TEST_OPTS} \
--simulator="${SIMULATOR}" \
--iss="${ISS}"
.PHONY: post_compare
post_compare: $(OUT-SEED)/regr.log
###############################################################################
# Generate RISCV-DV functional coverage
# TODO(udi) - add B extension
fcov:
$(verb)python3 ${GEN_DIR}/cov.py \
--core ibex \
--dir ${OUT-SEED}/rtl_sim \
-o ${OUT-SEED}/fcov \
--isa rv32imcb \
--custom_target riscv_dv_extension
# Merge all output coverage directories into the <out>/rtl_sim directory
cov:
$(verb)rm -rf $(OUT-DIR)rtl_sim/test.vdb
$(verb)./sim.py \
--steps=cov \
${TEST_OPTS} \
--simulator="${SIMULATOR}" \
$(lsf-arg) \
--o="$(OUT-DIR)"
@if [ -d "test.vdb" ]; then \
mv -f test.vdb $(OUT-DIR)rtl_sim/; \
fi

View file

@ -0,0 +1,35 @@
# DV for the ibex core
For detailed documention on how Ibex's verification works, please have a look at [the dedicated documentation page](https://ibex-core.readthedocs.io/en/latest/03_reference/verification.html).
This README provides a quick start guide to get things running.
## Prerequisites
You need to have Xcelium available on your machine.
You can check whether you have it available by running: `xrun --verison`
You also need Spike to be able to compare to in the cosimulation.
We use a lowRISC specific Spike which you can find [on its own GitHub page](https://github.com/lowRISC/riscv-isa-sim/tree/ibex_cosim).
Some quick build instructions from within the `riscv-isa-sim` repo:
```bash
mkdir build
cd build
../configure --enable-commitlog --enable-misaligned --prefix=$SPIKE_INSTALL_DIR
make
make install
export SPIKE_PATH=$SPIKE_INSTALL_DIR/bin
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$SPIKE_INSTALL_DIR/lib/pkgconfig
```
You will need the [RISC-V toolchain](https://github.com/riscv-collab/riscv-gnu-toolchain).
You'll need to add this to your path and then also set the following environment variables:
```bash
export RISCV_GCC=riscv32-unknown-elf-gcc
export RISCV_OBJCOPY=riscv32-unknown-elf-objcopy
```
## Running tests
To run tests you can make variations of the following command, where you replace `$TEST_NAME` with the test (or a series of comma-separated tests) that you would like to run as specified in `dv/uvm/core_ibex/riscv_dv_extension/testlist.yaml`:
```bash
make --keep-going IBEX_CONFIG=opentitan SIMULATOR=xlm ISS=spike ITERATIONS=1 SEED=1 TEST=$TEST_NAME WAVES=0 COV=0
```

View file

@ -2,4 +2,5 @@
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
`include "ibex_icache_ecc_base_seq.sv"
#include <time.h>
long int get_unix_timestamp() { return time(NULL); }

View file

@ -0,0 +1,10 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
`ifndef DATE_DPI_SVH
`define DATE_DPI_SVH
import "DPI-C" function longint get_unix_timestamp();
`endif

View file

@ -0,0 +1,28 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
interface core_ibex_ifetch_if(input logic clk);
logic reset;
logic fetch_ready;
logic fetch_valid;
logic [31:0] fetch_rdata;
logic [31:0] fetch_addr;
logic fetch_err;
logic fetch_err_plus2;
clocking monitor_cb @(posedge clk);
input reset;
input fetch_ready;
input fetch_valid;
input fetch_rdata;
input fetch_addr;
input fetch_err;
input fetch_err_plus2;
endclocking
task automatic wait_clks(input int num);
repeat (num) @(posedge clk);
endtask
endinterface

View file

@ -0,0 +1,22 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
interface core_ibex_ifetch_pmp_if(input logic clk);
logic reset;
logic fetch_valid;
logic [31:0] fetch_addr;
logic fetch_pmp_err;
clocking monitor_cb @(posedge clk);
input reset;
input fetch_valid;
input fetch_addr;
input fetch_pmp_err;
endclocking
task automatic wait_clks(input int num);
repeat (num) @(posedge clk);
endtask
endinterface : core_ibex_ifetch_pmp_if

View file

@ -0,0 +1,80 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
`include "cosim_dpi.svh"
class ibex_cosim_agent extends uvm_agent;
ibex_rvfi_monitor rvfi_monitor;
ibex_ifetch_monitor ifetch_monitor;
ibex_ifetch_pmp_monitor ifetch_pmp_monitor;
ibex_cosim_scoreboard scoreboard;
uvm_analysis_export#(ibex_mem_intf_seq_item) dmem_port;
uvm_analysis_export#(ibex_mem_intf_seq_item) imem_port;
`uvm_component_utils(ibex_cosim_agent)
function new(string name="", uvm_component parent=null);
super.new(name, parent);
dmem_port = new("dmem_port", this);
imem_port = new("imem_port", this);
endfunction
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
rvfi_monitor = ibex_rvfi_monitor::type_id::create("rvfi_monitor", this);
scoreboard = ibex_cosim_scoreboard::type_id::create("scoreboard", this);
ifetch_monitor = ibex_ifetch_monitor::type_id::create("ifetch_monitor", this);
ifetch_pmp_monitor = ibex_ifetch_pmp_monitor::type_id::create("ifetch_pmp_monitor", this);
endfunction: build_phase
virtual function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
rvfi_monitor.item_collected_port.connect(scoreboard.rvfi_port.analysis_export);
ifetch_monitor.item_collected_port.connect(scoreboard.ifetch_port.analysis_export);
ifetch_pmp_monitor.item_collected_port.connect(scoreboard.ifetch_pmp_port.analysis_export);
dmem_port.connect(scoreboard.dmem_port.analysis_export);
imem_port.connect(scoreboard.imem_port.analysis_export);
endfunction: connect_phase
function void write_mem_byte(bit [31:0] addr, bit [7:0] d);
riscv_cosim_write_mem_byte(scoreboard.cosim_handle, addr, d);
endfunction
function void write_mem_word(bit [31:0] addr, bit [DATA_WIDTH-1:0] d);
for (int i = 0; i < DATA_WIDTH / 8; i++) begin
write_mem_byte(addr + i, d[7:0]);
d = d >> 8;
end
endfunction
// Backdoor-load the test binary file into the cosim memory model
function void load_binary_to_mem(bit[31:0] base_addr, string bin);
bit [7:0] r8;
bit [31:0] addr = base_addr;
int bin_fd;
bin_fd = $fopen(bin,"rb");
if (!bin_fd)
`uvm_fatal(get_full_name(), $sformatf("Cannot open file %0s", bin))
while ($fread(r8,bin_fd)) begin
`uvm_info(`gfn, $sformatf("Init mem [0x%h] = 0x%0h", addr, r8), UVM_FULL)
write_mem_byte(addr, r8);
addr++;
end
endfunction
function void reset();
scoreboard.rvfi_port.flush();
scoreboard.dmem_port.flush();
scoreboard.imem_port.flush();
scoreboard.ifetch_port.flush();
scoreboard.ifetch_pmp_port.flush();
scoreboard.reset_e.trigger();
endfunction : reset
endclass : ibex_cosim_agent

View file

@ -0,0 +1,20 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
package ibex_cosim_agent_pkg;
import uvm_pkg::*;
import ibex_mem_intf_pkg::*;
`include "uvm_macros.svh"
`include "ibex_cosim_cfg.sv"
`include "ibex_rvfi_seq_item.sv"
`include "ibex_rvfi_monitor.sv"
`include "ibex_ifetch_seq_item.sv"
`include "ibex_ifetch_monitor.sv"
`include "ibex_ifetch_pmp_seq_item.sv"
`include "ibex_ifetch_pmp_monitor.sv"
`include "ibex_cosim_scoreboard.sv"
`include "ibex_cosim_agent.sv"
endpackage

View file

@ -0,0 +1,32 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
class core_ibex_cosim_cfg extends uvm_object;
string isa_string;
bit [31:0] start_pc;
bit [31:0] start_mtvec;
bit probe_imem_for_errs;
string log_file;
bit [31:0] pmp_num_regions;
bit [31:0] pmp_granularity;
bit [31:0] mhpm_counter_num;
bit relax_cosim_check;
bit secure_ibex;
bit icache;
`uvm_object_utils_begin(core_ibex_cosim_cfg)
`uvm_field_string(isa_string, UVM_DEFAULT)
`uvm_field_int(start_pc, UVM_DEFAULT)
`uvm_field_int(start_mtvec, UVM_DEFAULT)
`uvm_field_int(probe_imem_for_errs, UVM_DEFAULT)
`uvm_field_string(log_file, UVM_DEFAULT)
`uvm_field_int(pmp_num_regions, UVM_DEFAULT)
`uvm_field_int(pmp_granularity, UVM_DEFAULT)
`uvm_field_int(mhpm_counter_num, UVM_DEFAULT)
`uvm_field_int(secure_ibex, UVM_DEFAULT)
`uvm_field_int(icache, UVM_DEFAULT)
`uvm_object_utils_end
`uvm_object_new
endclass

View file

@ -0,0 +1,358 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
`include "spike_cosim_dpi.svh"
`include "cosim_dpi.svh"
class ibex_cosim_scoreboard extends uvm_scoreboard;
chandle cosim_handle;
core_ibex_cosim_cfg cfg;
uvm_tlm_analysis_fifo #(ibex_rvfi_seq_item) rvfi_port;
uvm_tlm_analysis_fifo #(ibex_mem_intf_seq_item) dmem_port;
uvm_tlm_analysis_fifo #(ibex_mem_intf_seq_item) imem_port;
uvm_tlm_analysis_fifo #(ibex_ifetch_seq_item) ifetch_port;
uvm_tlm_analysis_fifo #(ibex_ifetch_pmp_seq_item) ifetch_pmp_port;
virtual core_ibex_instr_monitor_if instr_vif;
virtual core_ibex_dut_probe_if dut_vif;
uvm_event reset_e;
uvm_event check_inserted_iside_error_e;
bit failed_iside_accesses [bit[31:0]];
bit iside_pmp_failure [bit[31:0]];
typedef struct {
bit [63:0] order;
bit [31:0] addr;
} iside_err_t;
iside_err_t iside_error_queue [$];
`uvm_component_utils(ibex_cosim_scoreboard)
function new(string name="", uvm_component parent=null);
super.new(name, parent);
rvfi_port = new("rvfi_port", this);
dmem_port = new("dmem_port", this);
imem_port = new("imem_port", this);
ifetch_port = new("ifetch_port", this);
ifetch_pmp_port = new("ifetch_pmp_port", this);
cosim_handle = null;
reset_e = new();
check_inserted_iside_error_e = new();
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
if (!uvm_config_db#(core_ibex_cosim_cfg)::get(this, "", "cosim_cfg", cfg)) begin
`uvm_fatal(`gfn, "Cannot get cosim configuration")
end
if (!uvm_config_db#(virtual core_ibex_instr_monitor_if)::get(null, "", "instr_monitor_if",
instr_vif)) begin
`uvm_fatal(`gfn, "Cannot get instr_monitor_if")
end
if (!uvm_config_db#(virtual core_ibex_dut_probe_if)::get(null, "", "dut_if",
dut_vif)) begin
`uvm_fatal(`gfn, "Cannot get dut_probe_if")
end
init_cosim();
endfunction : build_phase
protected function void init_cosim();
cleanup_cosim();
// TODO: Ensure log file on reset gets append rather than overwrite?
cosim_handle = spike_cosim_init(cfg.isa_string, cfg.start_pc, cfg.start_mtvec, cfg.log_file,
cfg.pmp_num_regions, cfg.pmp_granularity, cfg.mhpm_counter_num, cfg.secure_ibex, cfg.icache);
if (cosim_handle == null) begin
`uvm_fatal(`gfn, "Could not initialise cosim")
end
endfunction
protected function void cleanup_cosim();
if (cosim_handle) begin
spike_cosim_release(cosim_handle);
end
cosim_handle = null;
endfunction
virtual task run_phase(uvm_phase phase);
forever begin
@(negedge instr_vif.reset)
fork : isolation_fork
run_cosim_rvfi();
run_cosim_dmem();
run_cosim_imem_errors();
run_cosim_prune_imem_errors();
if (cfg.probe_imem_for_errs) begin
run_cosim_imem();
end else begin
fork
run_cosim_ifetch();
run_cosim_ifetch_pmp();
join_any
end
join_none
reset_e.wait_trigger();
disable fork;
handle_reset();
end // forever
endtask : run_phase
task run_cosim_rvfi();
ibex_rvfi_seq_item rvfi_instr;
forever begin
rvfi_port.get(rvfi_instr);
if (rvfi_instr.irq_only) begin
// RVFI item is only notifying about new interrupts, not a retired instruction, so provide
// cosim with interrupt information and loop back to await the next item.
riscv_cosim_set_nmi(cosim_handle, rvfi_instr.nmi);
riscv_cosim_set_nmi_int(cosim_handle, rvfi_instr.nmi_int);
riscv_cosim_set_mip(cosim_handle, rvfi_instr.pre_mip, rvfi_instr.pre_mip);
continue;
end
if (iside_error_queue.size() > 0) begin
// Remove entries from iside_error_queue where the instruction never reaches the RVFI
// interface because it was flushed.
while (iside_error_queue.size() > 0 && iside_error_queue[0].order < rvfi_instr.order) begin
iside_error_queue.pop_front();
end
// Check if the top of the iside_error_queue relates to the current RVFI instruction. If so
// notify the cosim environment of an instruction error.
if (iside_error_queue.size() !=0 && iside_error_queue[0].order == rvfi_instr.order) begin
riscv_cosim_set_iside_error(cosim_handle, iside_error_queue[0].addr);
iside_error_queue.pop_front();
end
end
// Note these must be called in this order to ensure debug vs nmi vs normal interrupt are
// handled with the correct priority when they occur together.
riscv_cosim_set_debug_req(cosim_handle, rvfi_instr.debug_req);
riscv_cosim_set_nmi(cosim_handle, rvfi_instr.nmi);
riscv_cosim_set_nmi_int(cosim_handle, rvfi_instr.nmi_int);
riscv_cosim_set_mip(cosim_handle, rvfi_instr.pre_mip, rvfi_instr.post_mip);
riscv_cosim_set_mcycle(cosim_handle, rvfi_instr.mcycle);
// Set performance counters through a pseudo-backdoor write
for (int i=0; i < 10; i++) begin
riscv_cosim_set_csr(cosim_handle,
ibex_pkg::CSR_MHPMCOUNTER3 + i, rvfi_instr.mhpmcounters[i]);
riscv_cosim_set_csr(cosim_handle,
ibex_pkg::CSR_MHPMCOUNTER3H + i, rvfi_instr.mhpmcountersh[i]);
end
riscv_cosim_set_ic_scr_key_valid(cosim_handle, rvfi_instr.ic_scr_key_valid);
if (!riscv_cosim_step(cosim_handle, rvfi_instr.rd_addr, rvfi_instr.rd_wdata, rvfi_instr.pc,
rvfi_instr.trap, rvfi_instr.rf_wr_suppress)) begin
// cosim instruction step doesn't match rvfi captured instruction, report a fatal error
// with the details
if (cfg.relax_cosim_check) begin
`uvm_info(`gfn, get_cosim_error_str(), UVM_LOW)
end else begin
`uvm_fatal(`gfn, get_cosim_error_str())
end
end
end
endtask: run_cosim_rvfi
task run_cosim_dmem();
ibex_mem_intf_seq_item mem_op;
forever begin
dmem_port.get(mem_op);
// Notify the cosim of all dside accesses emitted by the RTL
riscv_cosim_notify_dside_access(cosim_handle, mem_op.read_write == WRITE, mem_op.addr,
mem_op.data, mem_op.be, mem_op.error, mem_op.misaligned_first, mem_op.misaligned_second,
mem_op.misaligned_first_saw_error, mem_op.m_mode_access);
end
endtask: run_cosim_dmem
task run_cosim_imem();
ibex_mem_intf_seq_item mem_op;
forever begin
// Take stream of transaction from imem monitor. Where an imem access has an error record it
// in failed_iside_accesses. If an access has succeeded remove it from failed_imem_accesses if
// it's there.
// Note all transactions are 32-bit aligned.
imem_port.get(mem_op);
if (mem_op.error) begin
failed_iside_accesses[mem_op.addr] = 1'b1;
end else begin
if (failed_iside_accesses.exists(mem_op.addr)) begin
failed_iside_accesses.delete(mem_op.addr);
end
end
end
endtask: run_cosim_imem
task run_cosim_ifetch();
ibex_ifetch_seq_item ifetch;
bit [31:0] aligned_fetch_addr;
bit [31:0] aligned_fetch_addr_next;
forever begin
ifetch_port.get(ifetch);
aligned_fetch_addr = {ifetch.fetch_addr[31:2], 2'b0};
aligned_fetch_addr_next = aligned_fetch_addr + 32'd4;
if (ifetch.fetch_err) begin
// Instruction error observed in fetch stage
bit [31:0] failing_addr;
// Determine which address failed.
if (ifetch.fetch_err_plus2) begin
// Instruction crosses a 32-bit boundary and second half failed
failing_addr = aligned_fetch_addr_next;
end else begin
failing_addr = aligned_fetch_addr;
end
failed_iside_accesses[failing_addr] = 1'b1;
end else begin
if (ifetch.fetch_addr[1:0] != 0 && ifetch.fetch_rdata[1:0] == 2'b11) begin
// Instruction crosses 32-bit boundary, so remove any failed accesses on the other side of
// the 32-bit boundary.
if (failed_iside_accesses.exists(aligned_fetch_addr_next)) begin
failed_iside_accesses.delete(aligned_fetch_addr_next);
end
end
if (failed_iside_accesses.exists(aligned_fetch_addr)) begin
failed_iside_accesses.delete(aligned_fetch_addr);
end
end
end
endtask: run_cosim_ifetch
task run_cosim_ifetch_pmp();
ibex_ifetch_pmp_seq_item ifetch_pmp;
// Keep track of which addresses have seen PMP failures.
forever begin
ifetch_pmp_port.get(ifetch_pmp);
if (ifetch_pmp.fetch_pmp_err) begin
iside_pmp_failure[ifetch_pmp.fetch_addr] = 1'b1;
end else begin
if (iside_pmp_failure.exists(ifetch_pmp.fetch_addr)) begin
iside_pmp_failure.delete(ifetch_pmp.fetch_addr);
end
end
end
endtask
task run_cosim_imem_errors();
bit [63:0] latest_order = 64'hffffffff_ffffffff;
bit [31:0] aligned_addr;
bit [31:0] aligned_next_addr;
forever begin
// Wait for new instruction to appear in ID stage
wait (instr_vif.instr_cb.valid_id &&
instr_vif.instr_cb.instr_new_id &&
latest_order != instr_vif.instr_cb.rvfi_order_id);
latest_order = instr_vif.instr_cb.rvfi_order_id;
if (dut_vif.dut_cb.wb_exception)
// If an exception in writeback occurs the instruction in ID will be flushed and hence not
// produce an iside error so skip the rest of the loop. A writeback exception may occur
// after this cycle before the instruction in ID moves out of the ID stage. The
// `run_cosim_prune_imem_errors` task deals with this case.
continue;
// Determine if the instruction comes from an address that has seen an error that wasn't a PMP
// error (the icache records both PMP errors and fetch errors with the same error bits). If a
// fetch error was seen add the instruction order ID and address to iside_error_queue.
aligned_addr = instr_vif.instr_cb.pc_id & 32'hfffffffc;
aligned_next_addr = aligned_addr + 32'd4;
if (failed_iside_accesses.exists(aligned_addr) && !iside_pmp_failure.exists(aligned_addr))
begin
iside_error_queue.push_back('{order : instr_vif.instr_cb.rvfi_order_id,
addr : aligned_addr});
check_inserted_iside_error_e.trigger();
end else if (!instr_vif.instr_cb.is_compressed_id &&
(instr_vif.instr_cb.pc_id & 32'h3) != 0 &&
failed_iside_accesses.exists(aligned_next_addr) &&
!iside_pmp_failure.exists(aligned_next_addr))
begin
// Where an instruction crosses a 32-bit boundary, check if an error was seen on the other
// side of the boundary
iside_error_queue.push_back('{order : instr_vif.instr_cb.rvfi_order_id,
addr : aligned_next_addr});
check_inserted_iside_error_e.trigger();
end
end
endtask: run_cosim_imem_errors;
task run_cosim_prune_imem_errors();
// Errors are added to the iside error queue the first cycle the instruction that sees the error
// is in the ID stage. Cycles following this the writeback stage may cause an exception flushing
// the ID stage so the iside error never occurs. When this happens we need to pop the new iside
// error off the queue.
forever begin
// Wait until the `run_cosim_imem_errors` task notifies us it's added a error to the queue
check_inserted_iside_error_e.wait_ptrigger();
// Wait for the next clock
@(instr_vif.instr_cb);
// Wait for a new instruction or a writeback exception. When a new instruction has entered the
// ID stage and we haven't seen a writeback exception we know the instruction associated with the
// error just added to the queue isn't getting flushed.
wait (instr_vif.instr_cb.instr_new_id || dut_vif.dut_cb.wb_exception);
if (!instr_vif.instr_cb.instr_new_id && dut_vif.dut_cb.wb_exception) begin
// If we hit a writeback exception without seeing a new instruction then the newly added
// error relates to an instruction just flushed from the ID stage so pop it from the
// queue.
iside_error_queue.pop_back();
end
end
endtask: run_cosim_prune_imem_errors
function string get_cosim_error_str();
string error = "Cosim mismatch ";
for (int i = 0; i < riscv_cosim_get_num_errors(cosim_handle); ++i) begin
error = {error, riscv_cosim_get_error(cosim_handle, i), "\n"};
end
riscv_cosim_clear_errors(cosim_handle);
return error;
endfunction : get_cosim_error_str
function void final_phase(uvm_phase phase);
super.final_phase(phase);
`uvm_info(`gfn, $sformatf("Co-simulation matched %d instructions",
riscv_cosim_get_insn_cnt(cosim_handle)), UVM_LOW)
cleanup_cosim();
endfunction : final_phase
// If the UVM_EXIT action is triggered (such as by reaching max_quit_count), this callback is run.
// This ensures proper cleanup, such as commiting the logfile to disk.
function void pre_abort();
cleanup_cosim();
endfunction
task handle_reset();
init_cosim();
endtask
endclass : ibex_cosim_scoreboard

View file

@ -0,0 +1,45 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
class ibex_ifetch_monitor extends uvm_monitor;
protected virtual core_ibex_ifetch_if vif;
uvm_analysis_port#(ibex_ifetch_seq_item) item_collected_port;
`uvm_component_utils(ibex_ifetch_monitor)
`uvm_component_new
function void build_phase(uvm_phase phase);
super.build_phase(phase);
item_collected_port = new("item_collected_port", this);
if(!uvm_config_db#(virtual core_ibex_ifetch_if)::get(this, "", "ifetch_if", vif)) begin
`uvm_fatal("NOVIF", {"virtual interface must be set for: ", get_full_name(), ".vif"});
end
endfunction
virtual task run_phase(uvm_phase phase);
ibex_ifetch_seq_item trans_collected;
wait (vif.monitor_cb.reset === 1'b0);
forever begin
while(!(vif.monitor_cb.fetch_valid && vif.monitor_cb.fetch_ready)) vif.wait_clks(1);
trans_collected = ibex_ifetch_seq_item::type_id::create("trans_collected");
trans_collected.fetch_rdata = vif.monitor_cb.fetch_rdata;
trans_collected.fetch_addr = vif.monitor_cb.fetch_addr;
trans_collected.fetch_err = vif.monitor_cb.fetch_err;
trans_collected.fetch_err_plus2 = vif.monitor_cb.fetch_err_plus2;
`uvm_info(`gfn, $sformatf("Seen ifetch:\n%s", trans_collected.sprint()),
UVM_HIGH)
item_collected_port.write(trans_collected);
vif.wait_clks(1);
end
endtask: run_phase
endclass : ibex_ifetch_monitor

View file

@ -0,0 +1,43 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
class ibex_ifetch_pmp_monitor extends uvm_monitor;
protected virtual core_ibex_ifetch_pmp_if vif;
uvm_analysis_port#(ibex_ifetch_pmp_seq_item) item_collected_port;
`uvm_component_utils(ibex_ifetch_pmp_monitor)
`uvm_component_new
function void build_phase(uvm_phase phase);
super.build_phase(phase);
item_collected_port = new("item_collected_port", this);
if(!uvm_config_db#(virtual core_ibex_ifetch_pmp_if)::get(this, "", "ifetch_pmp_if", vif)) begin
`uvm_fatal("NOVIF", {"virtual interface must be set for: ", get_full_name(), ".vif"});
end
endfunction
virtual task run_phase(uvm_phase phase);
ibex_ifetch_pmp_seq_item trans_collected;
wait (vif.monitor_cb.reset === 1'b0);
forever begin
while(!vif.monitor_cb.fetch_valid) vif.wait_clks(1);
trans_collected = ibex_ifetch_pmp_seq_item::type_id::create("trans_collected");
trans_collected.fetch_addr = vif.monitor_cb.fetch_addr;
trans_collected.fetch_pmp_err = vif.monitor_cb.fetch_pmp_err;
`uvm_info(`gfn, $sformatf("Seen ifetch:\n%s", trans_collected.sprint()),
UVM_HIGH)
item_collected_port.write(trans_collected);
vif.wait_clks(1);
end
endtask: run_phase
endclass : ibex_ifetch_pmp_monitor

View file

@ -0,0 +1,15 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
class ibex_ifetch_pmp_seq_item extends uvm_sequence_item;
bit [31:0] fetch_addr;
bit fetch_pmp_err;
`uvm_object_utils_begin(ibex_ifetch_pmp_seq_item)
`uvm_field_int (fetch_addr, UVM_DEFAULT)
`uvm_field_int (fetch_pmp_err, UVM_DEFAULT)
`uvm_object_utils_end
`uvm_object_new
endclass : ibex_ifetch_pmp_seq_item

View file

@ -0,0 +1,19 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
class ibex_ifetch_seq_item extends uvm_sequence_item;
bit [31:0] fetch_rdata;
bit [31:0] fetch_addr;
bit fetch_err;
bit fetch_err_plus2;
`uvm_object_utils_begin(ibex_ifetch_seq_item)
`uvm_field_int (fetch_rdata, UVM_DEFAULT)
`uvm_field_int (fetch_addr, UVM_DEFAULT)
`uvm_field_int (fetch_err, UVM_DEFAULT)
`uvm_field_int (fetch_err_plus2, UVM_DEFAULT)
`uvm_object_utils_end
`uvm_object_new
endclass : ibex_ifetch_seq_item

View file

@ -0,0 +1,62 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
class ibex_rvfi_monitor extends uvm_monitor;
protected virtual core_ibex_rvfi_if vif;
uvm_analysis_port#(ibex_rvfi_seq_item) item_collected_port;
`uvm_component_utils(ibex_rvfi_monitor)
`uvm_component_new
function void build_phase(uvm_phase phase);
super.build_phase(phase);
item_collected_port = new("item_collected_port", this);
if(!uvm_config_db#(virtual core_ibex_rvfi_if)::get(this, "", "rvfi_if", vif)) begin
`uvm_fatal("NOVIF", {"virtual interface must be set for: ", get_full_name(), ".vif"});
end
endfunction: build_phase
virtual task run_phase(uvm_phase phase);
ibex_rvfi_seq_item trans_collected;
wait (vif.monitor_cb.reset === 1'b0);
forever begin
// Wait for a retired instruction
while(!(vif.monitor_cb.valid || vif.monitor_cb.ext_irq_valid)) vif.wait_clks(1);
// Read instruction details from RVFI interface
trans_collected = ibex_rvfi_seq_item::type_id::create("trans_collected");
trans_collected.irq_only = !vif.monitor_cb.valid && vif.monitor_cb.ext_irq_valid;
trans_collected.trap = vif.monitor_cb.trap;
trans_collected.pc = vif.monitor_cb.pc_rdata;
trans_collected.rd_addr = vif.monitor_cb.rd_addr;
trans_collected.rd_wdata = vif.monitor_cb.rd_wdata;
trans_collected.order = vif.monitor_cb.order;
trans_collected.pre_mip = vif.monitor_cb.ext_pre_mip;
trans_collected.post_mip = vif.monitor_cb.ext_post_mip;
trans_collected.nmi = vif.monitor_cb.ext_nmi;
trans_collected.nmi_int = vif.monitor_cb.ext_nmi_int;
trans_collected.debug_req = vif.monitor_cb.ext_debug_req;
trans_collected.rf_wr_suppress = vif.monitor_cb.ext_rf_wr_suppress;
trans_collected.mcycle = vif.monitor_cb.ext_mcycle;
trans_collected.ic_scr_key_valid = vif.monitor_cb.ext_ic_scr_key_valid;
for (int i=0; i < 10; i++) begin
trans_collected.mhpmcounters[i] = vif.monitor_cb.ext_mhpmcounters[i];
trans_collected.mhpmcountersh[i] = vif.monitor_cb.ext_mhpmcountersh[i];
end
`uvm_info(get_full_name(), $sformatf("Seen instruction:\n%s", trans_collected.sprint()),
UVM_HIGH)
item_collected_port.write(trans_collected);
vif.wait_clks(1);
end
endtask : run_phase
endclass : ibex_rvfi_monitor

View file

@ -0,0 +1,44 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
class ibex_rvfi_seq_item extends uvm_sequence_item;
bit irq_only;
bit trap;
bit [31:0] pc;
bit [4:0] rd_addr;
bit [31:0] rd_wdata;
bit [63:0] order;
bit [31:0] pre_mip;
bit [31:0] post_mip;
bit nmi;
bit nmi_int;
bit debug_req;
bit rf_wr_suppress;
bit [63:0] mcycle;
bit [31:0] mhpmcounters [10];
bit [31:0] mhpmcountersh [10];
bit ic_scr_key_valid;
`uvm_object_utils_begin(ibex_rvfi_seq_item)
`uvm_field_int (trap, UVM_DEFAULT)
`uvm_field_int (pc, UVM_DEFAULT)
`uvm_field_int (rd_addr, UVM_DEFAULT)
`uvm_field_int (rd_wdata, UVM_DEFAULT)
`uvm_field_int (order, UVM_DEFAULT)
`uvm_field_int (pre_mip, UVM_DEFAULT)
`uvm_field_int (post_mip, UVM_DEFAULT)
`uvm_field_int (nmi, UVM_DEFAULT)
`uvm_field_int (nmi_int, UVM_DEFAULT)
`uvm_field_int (debug_req, UVM_DEFAULT)
`uvm_field_int (rf_wr_suppress, UVM_DEFAULT)
`uvm_field_int (mcycle, UVM_DEFAULT)
`uvm_field_sarray_int (mhpmcounters, UVM_DEFAULT)
`uvm_field_sarray_int (mhpmcountersh, UVM_DEFAULT)
`uvm_field_int (ic_scr_key_valid, UVM_DEFAULT)
`uvm_object_utils_end
`uvm_object_new
endclass : ibex_rvfi_seq_item

View file

@ -0,0 +1,40 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
#include <svdpi.h>
#include <cassert>
#include "cosim.h"
#include "spike_cosim.h"
extern "C" {
void *spike_cosim_init(const char *isa_string, svBitVecVal *start_pc,
svBitVecVal *start_mtvec, const char *log_file_path_cstr,
svBitVecVal *pmp_num_regions,
svBitVecVal *pmp_granularity,
svBitVecVal *mhpm_counter_num, svBit secure_ibex,
svBit icache) {
assert(isa_string);
std::string log_file_path;
if (log_file_path_cstr) {
log_file_path = log_file_path_cstr;
}
SpikeCosim *cosim = new SpikeCosim(
isa_string, start_pc[0], start_mtvec[0], log_file_path, secure_ibex,
icache, pmp_num_regions[0], pmp_granularity[0], mhpm_counter_num[0]);
cosim->add_memory(0x80000000, 0x80000000);
cosim->add_memory(0x00000000, 0x80000000);
return static_cast<Cosim *>(cosim);
}
void spike_cosim_release(void *cosim_handle) {
auto cosim = static_cast<Cosim *>(cosim_handle);
delete cosim;
}
}

View file

@ -0,0 +1,21 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
`ifndef SPIKE_COSIM_DPI_SVH
`define SPIKE_COSIM_DPI_SVH
import "DPI-C" function
chandle spike_cosim_init(string isa_string,
bit [31:0] start_pc,
bit [31:0] start_mtvec,
string log_file_path,
bit [31:0] pmp_num_regions,
bit [31:0] pmp_granularity,
bit [31:0] mhpm_counter_num,
bit secure_ibex,
bit icache);
import "DPI-C" function void spike_cosim_release(chandle cosim_handle);
`endif

View file

@ -4,7 +4,8 @@
interface ibex_mem_intf#(
parameter int ADDR_WIDTH = 32,
parameter int DATA_WIDTH = 32
parameter int DATA_WIDTH = 32,
parameter int INTG_WIDTH = 7
) (
input clk
);
@ -17,8 +18,15 @@ interface ibex_mem_intf#(
wire [DATA_WIDTH/8-1:0] be;
wire rvalid;
wire [DATA_WIDTH-1:0] wdata;
wire [INTG_WIDTH-1:0] wintg;
wire [DATA_WIDTH-1:0] rdata;
wire [INTG_WIDTH-1:0] rintg;
wire error;
wire misaligned_first;
wire misaligned_second;
wire misaligned_first_saw_error;
wire m_mode_access;
wire spurious_response;
clocking request_driver_cb @(posedge clk);
input reset;
@ -29,8 +37,11 @@ interface ibex_mem_intf#(
output be;
input rvalid;
output wdata;
output wintg;
input rdata;
input rintg;
input error;
input spurious_response;
endclocking
clocking response_driver_cb @(posedge clk);
@ -42,8 +53,11 @@ interface ibex_mem_intf#(
input be;
output rvalid;
input wdata;
input wintg;
output rdata;
output rintg;
output error;
output spurious_response;
endclocking
clocking monitor_cb @(posedge clk);
@ -55,8 +69,15 @@ interface ibex_mem_intf#(
input be;
input rvalid;
input wdata;
input wintg;
input rdata;
input rintg;
input error;
input misaligned_first;
input misaligned_second;
input misaligned_first_saw_error;
input m_mode_access;
input spurious_response;
endclocking
task automatic wait_clks(input int num);

View file

@ -5,19 +5,16 @@
package ibex_mem_intf_agent_pkg;
import uvm_pkg::*;
import ibex_mem_intf_pkg::*;
import mem_model_pkg::*;
parameter int DATA_WIDTH = 32;
parameter int ADDR_WIDTH = 32;
typedef enum { READ, WRITE } rw_e;
import ibex_cosim_agent_pkg::*;
`include "uvm_macros.svh"
`include "ibex_mem_intf_seq_item.sv"
typedef uvm_sequencer#(ibex_mem_intf_seq_item) ibex_mem_intf_request_sequencer;
`include "ibex_mem_intf_monitor.sv"
`include "ibex_mem_intf_response_agent_cfg.sv"
`include "ibex_mem_intf_response_driver.sv"
`include "ibex_mem_intf_response_sequencer.sv"
`include "ibex_mem_intf_response_seq_lib.sv"
@ -25,4 +22,8 @@ package ibex_mem_intf_agent_pkg;
`include "ibex_mem_intf_request_driver.sv"
`include "ibex_mem_intf_request_agent.sv"
// Re-export parameters from ibex_mem_intf_pkg so that other packages can access them through this
// package.
export ibex_mem_intf_pkg::*;
endpackage

View file

@ -10,18 +10,28 @@ class ibex_mem_intf_monitor extends uvm_monitor;
protected virtual ibex_mem_intf vif;
mailbox #(ibex_mem_intf_seq_item) collect_data_queue;
// The monitor tick event fires every clock cycle once any writes to
// outstanding_access_port and addr_ph_ports have occurred.
event monitor_tick;
mailbox #(ibex_mem_intf_seq_item) collect_response_queue;
uvm_analysis_port#(ibex_mem_intf_seq_item) item_collected_port;
uvm_analysis_port#(ibex_mem_intf_seq_item) addr_ph_port;
// The number of outstanding accesses is written to this port every clock cycle
uvm_analysis_port#(int) outstanding_accesses_port;
`uvm_component_utils(ibex_mem_intf_monitor)
`uvm_component_new
int outstanding_accesses = 0;
function void build_phase(uvm_phase phase);
super.build_phase(phase);
item_collected_port = new("item_collected_port", this);
addr_ph_port = new("addr_ph_port_monitor", this);
collect_data_queue = new();
collect_response_queue = new();
outstanding_accesses_port = new("outstanding_accesses_port", this);
if(!uvm_config_db#(virtual ibex_mem_intf)::get(this, "", "vif", vif)) begin
`uvm_fatal("NOVIF",{"virtual interface must be set for: ",get_full_name(),".vif"});
end
@ -30,13 +40,15 @@ class ibex_mem_intf_monitor extends uvm_monitor;
virtual task run_phase(uvm_phase phase);
wait (vif.monitor_cb.reset === 1'b0);
forever begin
fork : check_mem_intf
collect_address_phase();
collect_data_phase();
wait (vif.monitor_cb.reset === 1'b1);
join_any
// Will only reach this point when mid-test reset is asserted
disable fork;
fork begin : isolation_fork
fork : check_mem_intf
collect_address_phase();
collect_response_phase();
wait (vif.monitor_cb.reset === 1'b1);
join_any
// Will only reach this point when mid-test reset is asserted
disable fork;
end join
handle_reset();
end
endtask : run_phase
@ -44,45 +56,74 @@ class ibex_mem_intf_monitor extends uvm_monitor;
virtual protected task handle_reset();
ibex_mem_intf_seq_item mailbox_result;
// Clear the mailbox of any content
while (collect_data_queue.try_get(mailbox_result));
while (collect_response_queue.try_get(mailbox_result));
wait (vif.monitor_cb.reset === 1'b0);
endtask
virtual protected task collect_address_phase();
ibex_mem_intf_seq_item trans_collected;
forever begin
@(vif.monitor_cb);
trans_collected = ibex_mem_intf_seq_item::type_id::create("trans_collected");
while(!(vif.monitor_cb.request && vif.monitor_cb.grant)) vif.wait_clks(1);
trans_collected.addr = vif.monitor_cb.addr;
trans_collected.be = vif.monitor_cb.be;
while (!(vif.monitor_cb.request && vif.monitor_cb.grant)) begin
if (vif.monitor_cb.rvalid && !vif.monitor_cb.spurious_response) begin
outstanding_accesses--;
end
outstanding_accesses_port.write(outstanding_accesses);
-> monitor_tick;
@(vif.monitor_cb);
end
trans_collected.addr = vif.monitor_cb.addr;
trans_collected.be = vif.monitor_cb.be;
trans_collected.misaligned_first = vif.monitor_cb.misaligned_first;
trans_collected.misaligned_second = vif.monitor_cb.misaligned_second;
trans_collected.misaligned_first_saw_error = vif.monitor_cb.misaligned_first_saw_error;
trans_collected.m_mode_access = vif.monitor_cb.m_mode_access;
`uvm_info(get_full_name(), $sformatf("Detect request with address: %0x",
trans_collected.addr), UVM_HIGH)
if(vif.monitor_cb.we) begin
if (vif.monitor_cb.we) begin
trans_collected.read_write = WRITE;
trans_collected.data = vif.monitor_cb.wdata;
trans_collected.intg = vif.monitor_cb.wintg;
end else begin
trans_collected.read_write = READ;
end
addr_ph_port.write(trans_collected);
`uvm_info(get_full_name(),"Send through addr_ph_port", UVM_HIGH)
if(trans_collected.read_write == WRITE)
item_collected_port.write(trans_collected);
else
collect_data_queue.put(trans_collected);
vif.wait_clks(1);
collect_response_queue.put(trans_collected);
outstanding_accesses++;
if (vif.monitor_cb.rvalid && !vif.monitor_cb.spurious_response) begin
outstanding_accesses--;
end
outstanding_accesses_port.write(outstanding_accesses);
-> monitor_tick;
end
endtask : collect_address_phase
virtual protected task collect_data_phase();
virtual protected task collect_response_phase();
ibex_mem_intf_seq_item trans_collected;
forever begin
collect_data_queue.get(trans_collected);
collect_response_queue.get(trans_collected);
do
vif.wait_clks(1);
while(vif.monitor_cb.rvalid === 0);
trans_collected.data = vif.monitor_cb.rdata;
@(vif.monitor_cb);
while(vif.monitor_cb.rvalid === 0 || vif.monitor_cb.spurious_response === 1);
if (trans_collected.read_write == READ) begin
trans_collected.data = vif.monitor_cb.rdata;
trans_collected.intg = vif.monitor_cb.rintg;
end
trans_collected.error = vif.monitor_cb.error;
item_collected_port.write(trans_collected);
end
endtask : collect_data_phase
endtask : collect_response_phase
endclass : ibex_mem_intf_monitor

View file

@ -0,0 +1,18 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
package ibex_mem_intf_pkg;
import uvm_pkg::*;
parameter int DATA_WIDTH = 32;
parameter int ADDR_WIDTH = 32;
parameter int INTG_WIDTH = 7;
typedef enum { READ, WRITE } rw_e;
`include "uvm_macros.svh"
`include "ibex_mem_intf_seq_item.sv"
endpackage

Some files were not shown because too many files have changed in this diff Show more