Skip to content

Commit dbf9d1c

Browse files
committed
Update lowrisc_ibex to lowRISC/ibex@aae4809a
Update code from upstream repository https://github.com/lowRISC/ibex.git to revision aae4809aea170fc605bdaa64a70a13efd2408829 * [dv] Check u-mode counter alias the correct m-mode counter (Samuel Riedel) * [formal] Exclude u-mode counters from formal verification (Samuel Riedel) * [doc] Document the newly added performance counters (Samuel Riedel) * [dv] Add directed test for mcounteren lock signal (Samuel Riedel) * [dv] Add `mcounteren` directed test (Samuel Riedel) * [dv] Fix ordering in `directed_testlist.yml` (Samuel Riedel) * [dv] Implement Ibex-specific mcounteren behavior in cosim (Samuel Riedel) * [rtl] Add input to lock mcounteren (Samuel Riedel) * [rtl] Add unpriviledged counter/timers (Samuel Riedel) * [rtl] Add register for `mcounteren` (Samuel Riedel) * [rtl] Fix incrementing `minstret` after setting it (Samuel Riedel) * [rtl] Fix speculative increment of `minstret` (Samuel Riedel) * [syn] Fix scripts for new vendored lowrisc_ip (Harry Callahan) * [syn] Add nix devShell for example synthesis flow (Harry Callahan) * [dv] Fixup explicit static lifetime on initializer by seperating decl from assign. (Harry Callahan) * [vendor/google_riscv-dv] Add VCS -Xcflags to suppress build warnings (Harry Callahan) * [vendor/google_riscv-dv] use env bash and non-absolute bash paths (Harry Callahan) * [rtl] Explicitly define mapping to `prim_generic` for linter targets (Samuel Riedel) * [rtl] Fix prim_generic mapping in ibex_top (Samuel Riedel) * [rtl] Move prim_generic dependency to ibex_top (Samuel Riedel) * [doc] Ibex Concierge updated (Marno van der Maas) Signed-off-by: Samuel Riedel <sriedel@lowrisc.org>
1 parent 402143f commit dbf9d1c

39 files changed

Lines changed: 905 additions & 151 deletions

File tree

hw/ip_templates/rv_core_ibex/rtl/rv_core_ibex.sv.tpl

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ module ${module_instance_name}
237237
logic [ 3:0] rvfi_mem_wmask;
238238
logic [31:0] rvfi_mem_rdata;
239239
logic [31:0] rvfi_mem_wdata;
240+
logic rvfi_ext_expanded_insn_valid;
241+
logic [15:0] rvfi_ext_expanded_insn;
240242
`endif
241243

242244
import tlul_pkg::tl_h2d_t;
@@ -568,18 +570,21 @@ module ${module_instance_name}
568570
.rvfi_mem_rdata,
569571
.rvfi_mem_wdata,
570572
// Unused ports from the RVFI interface
571-
.rvfi_ext_pre_mip (),
572-
.rvfi_ext_post_mip (),
573-
.rvfi_ext_nmi (),
574-
.rvfi_ext_nmi_int (),
575-
.rvfi_ext_debug_req (),
576-
.rvfi_ext_debug_mode (),
577-
.rvfi_ext_rf_wr_suppress (),
578-
.rvfi_ext_mcycle (),
579-
.rvfi_ext_mhpmcounters (),
580-
.rvfi_ext_mhpmcountersh (),
581-
.rvfi_ext_ic_scr_key_valid(),
582-
.rvfi_ext_irq_valid (),
573+
.rvfi_ext_pre_mip (),
574+
.rvfi_ext_post_mip (),
575+
.rvfi_ext_nmi (),
576+
.rvfi_ext_nmi_int (),
577+
.rvfi_ext_debug_req (),
578+
.rvfi_ext_debug_mode (),
579+
.rvfi_ext_rf_wr_suppress (),
580+
.rvfi_ext_mcycle (),
581+
.rvfi_ext_mhpmcounters (),
582+
.rvfi_ext_mhpmcountersh (),
583+
.rvfi_ext_ic_scr_key_valid (),
584+
.rvfi_ext_irq_valid (),
585+
.rvfi_ext_expanded_insn_valid(),
586+
.rvfi_ext_expanded_insn (),
587+
.rvfi_ext_expanded_insn_last (),
583588
`endif
584589
// SEC_CM: FETCH.CTRL.LC_GATED
585590
.fetch_enable_i (fetch_enable),
@@ -836,7 +841,9 @@ module ${module_instance_name}
836841
.rvfi_mem_rmask,
837842
.rvfi_mem_wmask,
838843
.rvfi_mem_rdata,
839-
.rvfi_mem_wdata
844+
.rvfi_mem_wdata,
845+
.rvfi_ext_expanded_insn_valid,
846+
.rvfi_ext_expanded_insn
840847
);
841848
`endif
842849

hw/top_darjeeling/ip_autogen/rv_core_ibex/rtl/rv_core_ibex.sv

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ module rv_core_ibex
224224
logic [ 3:0] rvfi_mem_wmask;
225225
logic [31:0] rvfi_mem_rdata;
226226
logic [31:0] rvfi_mem_wdata;
227+
logic rvfi_ext_expanded_insn_valid;
228+
logic [15:0] rvfi_ext_expanded_insn;
227229
`endif
228230

229231
import tlul_pkg::tl_h2d_t;
@@ -555,18 +557,21 @@ module rv_core_ibex
555557
.rvfi_mem_rdata,
556558
.rvfi_mem_wdata,
557559
// Unused ports from the RVFI interface
558-
.rvfi_ext_pre_mip (),
559-
.rvfi_ext_post_mip (),
560-
.rvfi_ext_nmi (),
561-
.rvfi_ext_nmi_int (),
562-
.rvfi_ext_debug_req (),
563-
.rvfi_ext_debug_mode (),
564-
.rvfi_ext_rf_wr_suppress (),
565-
.rvfi_ext_mcycle (),
566-
.rvfi_ext_mhpmcounters (),
567-
.rvfi_ext_mhpmcountersh (),
568-
.rvfi_ext_ic_scr_key_valid(),
569-
.rvfi_ext_irq_valid (),
560+
.rvfi_ext_pre_mip (),
561+
.rvfi_ext_post_mip (),
562+
.rvfi_ext_nmi (),
563+
.rvfi_ext_nmi_int (),
564+
.rvfi_ext_debug_req (),
565+
.rvfi_ext_debug_mode (),
566+
.rvfi_ext_rf_wr_suppress (),
567+
.rvfi_ext_mcycle (),
568+
.rvfi_ext_mhpmcounters (),
569+
.rvfi_ext_mhpmcountersh (),
570+
.rvfi_ext_ic_scr_key_valid (),
571+
.rvfi_ext_irq_valid (),
572+
.rvfi_ext_expanded_insn_valid(),
573+
.rvfi_ext_expanded_insn (),
574+
.rvfi_ext_expanded_insn_last (),
570575
`endif
571576
// SEC_CM: FETCH.CTRL.LC_GATED
572577
.fetch_enable_i (fetch_enable),
@@ -823,7 +828,9 @@ module rv_core_ibex
823828
.rvfi_mem_rmask,
824829
.rvfi_mem_wmask,
825830
.rvfi_mem_rdata,
826-
.rvfi_mem_wdata
831+
.rvfi_mem_wdata,
832+
.rvfi_ext_expanded_insn_valid,
833+
.rvfi_ext_expanded_insn
827834
);
828835
`endif
829836

hw/top_earlgrey/ip_autogen/rv_core_ibex/rtl/rv_core_ibex.sv

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ module rv_core_ibex
224224
logic [ 3:0] rvfi_mem_wmask;
225225
logic [31:0] rvfi_mem_rdata;
226226
logic [31:0] rvfi_mem_wdata;
227+
logic rvfi_ext_expanded_insn_valid;
228+
logic [15:0] rvfi_ext_expanded_insn;
227229
`endif
228230

229231
import tlul_pkg::tl_h2d_t;
@@ -555,18 +557,21 @@ module rv_core_ibex
555557
.rvfi_mem_rdata,
556558
.rvfi_mem_wdata,
557559
// Unused ports from the RVFI interface
558-
.rvfi_ext_pre_mip (),
559-
.rvfi_ext_post_mip (),
560-
.rvfi_ext_nmi (),
561-
.rvfi_ext_nmi_int (),
562-
.rvfi_ext_debug_req (),
563-
.rvfi_ext_debug_mode (),
564-
.rvfi_ext_rf_wr_suppress (),
565-
.rvfi_ext_mcycle (),
566-
.rvfi_ext_mhpmcounters (),
567-
.rvfi_ext_mhpmcountersh (),
568-
.rvfi_ext_ic_scr_key_valid(),
569-
.rvfi_ext_irq_valid (),
560+
.rvfi_ext_pre_mip (),
561+
.rvfi_ext_post_mip (),
562+
.rvfi_ext_nmi (),
563+
.rvfi_ext_nmi_int (),
564+
.rvfi_ext_debug_req (),
565+
.rvfi_ext_debug_mode (),
566+
.rvfi_ext_rf_wr_suppress (),
567+
.rvfi_ext_mcycle (),
568+
.rvfi_ext_mhpmcounters (),
569+
.rvfi_ext_mhpmcountersh (),
570+
.rvfi_ext_ic_scr_key_valid (),
571+
.rvfi_ext_irq_valid (),
572+
.rvfi_ext_expanded_insn_valid(),
573+
.rvfi_ext_expanded_insn (),
574+
.rvfi_ext_expanded_insn_last (),
570575
`endif
571576
// SEC_CM: FETCH.CTRL.LC_GATED
572577
.fetch_enable_i (fetch_enable),
@@ -823,7 +828,9 @@ module rv_core_ibex
823828
.rvfi_mem_rmask,
824829
.rvfi_mem_wmask,
825830
.rvfi_mem_rdata,
826-
.rvfi_mem_wdata
831+
.rvfi_mem_wdata,
832+
.rvfi_ext_expanded_insn_valid,
833+
.rvfi_ext_expanded_insn
827834
);
828835
`endif
829836

hw/top_englishbreakfast/ip_autogen/rv_core_ibex/rtl/rv_core_ibex.sv

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ module rv_core_ibex
224224
logic [ 3:0] rvfi_mem_wmask;
225225
logic [31:0] rvfi_mem_rdata;
226226
logic [31:0] rvfi_mem_wdata;
227+
logic rvfi_ext_expanded_insn_valid;
228+
logic [15:0] rvfi_ext_expanded_insn;
227229
`endif
228230

229231
import tlul_pkg::tl_h2d_t;
@@ -555,18 +557,21 @@ module rv_core_ibex
555557
.rvfi_mem_rdata,
556558
.rvfi_mem_wdata,
557559
// Unused ports from the RVFI interface
558-
.rvfi_ext_pre_mip (),
559-
.rvfi_ext_post_mip (),
560-
.rvfi_ext_nmi (),
561-
.rvfi_ext_nmi_int (),
562-
.rvfi_ext_debug_req (),
563-
.rvfi_ext_debug_mode (),
564-
.rvfi_ext_rf_wr_suppress (),
565-
.rvfi_ext_mcycle (),
566-
.rvfi_ext_mhpmcounters (),
567-
.rvfi_ext_mhpmcountersh (),
568-
.rvfi_ext_ic_scr_key_valid(),
569-
.rvfi_ext_irq_valid (),
560+
.rvfi_ext_pre_mip (),
561+
.rvfi_ext_post_mip (),
562+
.rvfi_ext_nmi (),
563+
.rvfi_ext_nmi_int (),
564+
.rvfi_ext_debug_req (),
565+
.rvfi_ext_debug_mode (),
566+
.rvfi_ext_rf_wr_suppress (),
567+
.rvfi_ext_mcycle (),
568+
.rvfi_ext_mhpmcounters (),
569+
.rvfi_ext_mhpmcountersh (),
570+
.rvfi_ext_ic_scr_key_valid (),
571+
.rvfi_ext_irq_valid (),
572+
.rvfi_ext_expanded_insn_valid(),
573+
.rvfi_ext_expanded_insn (),
574+
.rvfi_ext_expanded_insn_last (),
570575
`endif
571576
// SEC_CM: FETCH.CTRL.LC_GATED
572577
.fetch_enable_i (fetch_enable),
@@ -823,7 +828,9 @@ module rv_core_ibex
823828
.rvfi_mem_rmask,
824829
.rvfi_mem_wmask,
825830
.rvfi_mem_rdata,
826-
.rvfi_mem_wdata
831+
.rvfi_mem_wdata,
832+
.rvfi_ext_expanded_insn_valid,
833+
.rvfi_ext_expanded_insn
827834
);
828835
`endif
829836

hw/vendor/lowrisc_ibex.lock.hjson

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
upstream:
1010
{
1111
url: https://github.com/lowRISC/ibex.git
12-
rev: ac911ec101c7e9df5eeb2317ec3db664023b1c24
12+
rev: aae4809aea170fc605bdaa64a70a13efd2408829
1313
}
1414
}

hw/vendor/lowrisc_ibex/doc/01_overview/compliance.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ In addition, the following instruction set extensions are available.
4343
- 2.0
4444
- always enabled
4545

46+
* - **"Zicntr" and "Zihpm"**: Extensions for Counters and Hardware Performance Counters in User mode
47+
- 2.0
48+
- always enabled
49+
4650
* - **Zifencei**: Instruction-Fetch Fence
4751
- 2.0
4852
- always enabled

hw/vendor/lowrisc_ibex/doc/03_reference/performance_counters.rst

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
Performance Counters
44
====================
55

6-
Ibex implements performance counters according to the RISC-V Privileged Specification, version 1.11 (see Hardware Performance Monitor, Section 3.1.11).
6+
Ibex implements performance counters according to the RISC-V Privileged Specification, version 1.11 (see Hardware Performance Monitor, Section 3.1.11) and supports the **Zihpm** (Hardware Performance Counters) extension.
77
The performance counters are placed inside the Control and Status Registers (CSRs) and can be accessed with the ``CSRRW(I)`` and ``CSRRS/C(I)`` instructions.
88

9-
Ibex implements the clock cycle counter ``mcycle(h)``, the retired instruction counter ``minstret(h)``, as well as the 29 event counters ``mhpmcounter3(h)`` - ``mhpmcounter31(h)`` and the corresponding event selector CSRs ``mhpmevent3`` - ``mhpmevent31``, and the ``mcountinhibit`` CSR to individually enable/disable the counters.
9+
Ibex implements the machine-mode clock cycle counter ``mcycle(h)``, the retired instruction counter ``minstret(h)``, as well as the 29 event counters ``mhpmcounter3(h)`` - ``mhpmcounter31(h)`` and the corresponding event selector CSRs ``mhpmevent3`` - ``mhpmevent31``, and the ``mcountinhibit`` CSR to individually enable/disable the counters.
10+
11+
Additionally, Ibex implements the Zicntr and Zihpm extensions which provide User-mode (U-mode) aliases for these performance counters: ``cycle(h)``, ``instret(h)``, and ``hpmcounter3(h)`` - ``hpmcounter31(h)``. These aliases provide read-only access to the exact same underlying hardware counters configured in M-mode.
12+
1013
``mcycle(h)`` and ``minstret(h)`` are always available and 64 bit wide.
1114
The ``mhpmcounter`` performance counters are optional (unavailable by default) and parametrizable in width.
1215

@@ -60,6 +63,19 @@ In particular, to enable/disable ``mcycle(h)``, bit 0 must be written. For ``min
6063
The lower 32 bits of all counters can be accessed through the base register, whereas the upper 32 bits are accessed through the ``h``-register.
6164
Reads to all these registers are non-destructive.
6265

66+
User-Mode Counter Access (mcounteren)
67+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
68+
69+
Access to the U-mode counter aliases (``cycle(h)``, ``instret(h)``, and ``hpmcounterX(h)``) is controlled via the Machine Counter-Enable CSR (``mcounteren``). This register can gate access to the counters from less privileged modes to prevent benchmarking the core if desired.
70+
71+
* **Bit 0** controls access to ``cycle(h)``.
72+
* **Bit 2** controls access to ``instret(h)``.
73+
* **Bit X** controls access to ``hpmcounterX(h)``.
74+
75+
When a bit in ``mcounteren`` is clear (0), any attempt to read the corresponding counter alias from U-mode will trigger an illegal instruction exception.
76+
77+
To secure this mechanism, the ``mcounteren`` register can be locked against software modifications using a MUBI input signal called ``mcounteren_writeable``. When this signal disables writes, any attempt by software to modify the contents of ``mcounteren`` is ignored.
78+
6379
Parametrization at synthesis time
6480
---------------------------------
6581

hw/vendor/lowrisc_ibex/doc/04_developer/concierge.rst

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,7 @@ The Ibex Concierge
88
The Ibex Concierge is the friendly caretaker of the Ibex project.
99
It's a rotating duty shared by experienced contributors to help newcomers find their way around the project, and to stay on top of the various small tasks necessary to keep the project going.
1010

11-
The Ibex CPU project is a reasonably large open source project.
12-
Like all projects we experience two challenges:
13-
we want to lend a helping hand to new developers, answering their questions or helping them with code contributions.
14-
And we need to stay on top of our "caretaker" tasks, like fixing problems with our continuous integration setup, triaging issues and pull requests, etc.
15-
The Ibex Concierge combines these two duties in one person.
16-
17-
Please reach out to the Ibex Concierge if you have trouble finding your way around the Ibex project.
18-
You can find today's Ibex Concierge in the calendar below.
11+
The best way to reach the Ibex Concierge team is by creating an issue on our repository.
1912

2013

2114
Who is Ibex Concierge today?
@@ -24,14 +17,11 @@ Who is Ibex Concierge today?
2417
The concierge duties rotate between several core developers on a weekly basis.
2518
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>`_.
2619

27-
Besides the concierge on duty you can also contact the following people for urgent matters:
20+
Besides the concierge on duty you can also contact the following people for urgent matters and for prioritisation:
2821

2922
* Marno van der Maas (`@marnovandermaas <https://github.com/marnovandermaas>`_)
3023
* Rupert Swarbrick (`@rswarbrick <https://github.com/rswarbrick>`_)
3124

32-
You can be Ibex Concierge, too.
33-
Please talk to any of the current concierges to discuss!
34-
3525
.. raw:: html
3626

3727
<iframe src="https://calendar.google.com/calendar/embed?src=lowrisc.org_s0pdodkddnggdp40jusjij27h4%40group.calendar.google.com" style="border: 0" width="100%" height="600" frameborder="0" scrolling="no"></iframe>
@@ -41,32 +31,31 @@ Ibex Concierge duties
4131
---------------------
4232

4333
The Ibex Concierge is aware of what's happening in the Ibex project, and helps to ensure that everyone feels welcome and is able to work productively.
44-
The list of duties includes, but isn't strictly limited to the following tasks.
34+
The list of duties includes, but isn't strictly limited to the following tasks:
4535

4636
* Triage incoming issues and pull requests.
4737

4838
* Assign labels to them.
4939

50-
* Give initial feedback with an indication of what the next steps are.
51-
52-
* Answer questions if possible.
53-
5440
* Ask for clarifications where necessary.
5541

56-
* Redirect to the right developers as needed.
42+
* Give initial feedback with an indication of what the next steps are, this does not mean detailed feedback.
5743

58-
* Track progress of open issues and pull requests.
59-
Ensure contributors always know what's going on, and are informed if things take longer.
44+
* Where more detailed feedback is necessary redirect this to one of the core developers for prioritisation.
6045

61-
* Welcome new contributors, and provide (hands-on) help to get them up to speed.
62-
For example, help them get their commits into good shape, etc.
46+
* When time permits, track progress of open issues and pull requests.
6347

64-
* Fix or coordinate fixes to necessary infrastructure, such as the continuous integration setup in a timely manner.
48+
* Try to ensure that contributors know what's going on, and are informed if things take longer or are de-prioritised.
6549

66-
* Go through the list of open pull requests: ping developers if information or action is needed, close abandoned pull requests, etc.
50+
* If you find any abandoned pull requests, close them.
6751

68-
* Assist with the review and update of open issues.
52+
* Check the continuous integration runs and make sure that faults are reported immediately.
53+
If applicable, coordinate fixes to necessary infrastructure.
6954

7055
* At the end of the week, hand over to the next Ibex Concierge on the rota.
56+
Best thing to do is have a hand-over meeting of no more than half an hour.
7157

72-
Note the obvious: it is not the job of the Ibex Concierge to fix all bugs, implement all incoming feature requests, or be available 24/7.
58+
Note the obvious:
59+
It is not the job of the Ibex Concierge to fix all bugs, implement all incoming feature requests, or be available 24/7.
60+
We expect the Ibex Concierge to spend less than half a day a week on their duties.
61+
Anything beyond that needs to fit into broader priorities.

hw/vendor/lowrisc_ibex/dv/cosim/spike_cosim.cc

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ SpikeCosim::SpikeCosim(const std::string &isa_string, uint32_t start_pc,
3939
uint32_t pmp_num_regions, uint32_t pmp_granularity,
4040
uint32_t mhpm_counter_num, uint32_t dm_start_addr,
4141
uint32_t dm_end_addr)
42-
: nmi_mode(false), pending_iside_error(false), insn_cnt(0) {
42+
: nmi_mode(false),
43+
pending_iside_error(false),
44+
insn_cnt(0),
45+
mhpm_counter_num(mhpm_counter_num) {
4346
FILE *log_file = nullptr;
4447
if (trace_log_path.length() != 0) {
4548
log = std::make_unique<log_file_t>(trace_log_path.c_str());
@@ -832,6 +835,19 @@ void SpikeCosim::fixup_csr(int csr_num, uint32_t csr_val) {
832835
processor->set_csr(csr_num, new_val);
833836
#else
834837
processor->put_csr(csr_num, new_val);
838+
#endif
839+
break;
840+
}
841+
case CSR_MCOUNTEREN: {
842+
// Bits 3..3+mhpm_counter_num-1 correspond to implemented HPM counters
843+
reg_t hpm_mask = ((1 << mhpm_counter_num) - 1) << 3;
844+
// Bit 0 and 2 are for mcycle and minstret which are always implemented
845+
// Bit 1 is for time which is not implemented, hence the mask 0x5
846+
reg_t new_val = csr_val & (0x5 | hpm_mask);
847+
#ifdef OLD_SPIKE
848+
processor->set_csr(csr_num, new_val);
849+
#else
850+
processor->put_csr(csr_num, new_val);
835851
#endif
836852
break;
837853
}

hw/vendor/lowrisc_ibex/dv/cosim/spike_cosim.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ class SpikeCosim : public simif_t, public Cosim {
9898
void misaligned_pmp_fixup();
9999

100100
unsigned int insn_cnt;
101+
uint32_t mhpm_counter_num;
101102

102103
public:
103104
SpikeCosim(const std::string &isa_string, uint32_t start_pc,

0 commit comments

Comments
 (0)