-
Notifications
You must be signed in to change notification settings - Fork 746
Add mcounteren register
#2403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add mcounteren register
#2403
Changes from 8 commits
6355f79
72eaebf
216c77c
bacacea
497d1ec
ed45547
791beb6
6c1539e
c27c013
e0d9935
37ddcd4
49bffac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -128,6 +128,17 @@ class Cosim { | |
| // 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 minstret. | ||
| // | ||
| // The co-simulation model doesn't alter the value of minstret itself (other | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How come this is true? Spike should have all the information it needs to calculate minstret right?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right. And it does, the Spike counter is just lagging one instruction behind Ibex. It should match though, so I'll investigate a bit more... |
||
| // than instructions that do a direct CSR write). minstret should be set to | ||
| // the correct value before any `step` call that may execute an instruction | ||
| // that observes the value of minstret. | ||
| // | ||
| // A full 64-bit value is provided setting both the minstret and minstreth | ||
| // CSRs. | ||
| virtual void set_minstret(uint64_t minstret) = 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; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,6 +103,7 @@ module top import ibex_pkg::*; #( | |
|
|
||
| // CPU Control Signals | ||
| input ibex_mubi_t fetch_enable_i, | ||
| input ibex_mubi_t mcounteren_writable_i, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the point of making this an input as opposed to a parameter? Is there a use-case to be able to switch this dynamically during runtime?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. This allows locking the |
||
| output logic core_sleep_o, | ||
| output logic alert_minor_o, | ||
| output logic alert_major_internal_o, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,6 +80,14 @@ def add_configs_and_handwritten_directed_tests(): | |
| test_srcs: empty/empty.S | ||
| config: riscv-tests | ||
|
|
||
| - test: mcounteren_test | ||
| desc: > | ||
| Tests the mcounteren CSR: reset value, hardwired-zero bit 1 (time), | ||
| and U-mode counter access gating. | ||
| iterations: 1 | ||
| test_srcs: mcounteren_test/mcounteren_test.S | ||
| config: riscv-tests | ||
|
|
||
| - test: pmp_mseccfg_test_rlb1_l0_0_u0 | ||
| desc: > | ||
| mseccfg test | ||
|
|
@@ -469,11 +477,11 @@ def _main() -> int: | |
| add_configs_and_handwritten_directed_tests() | ||
|
|
||
| if 'riscv-tests' in test_suite_list or test_suite == 'all': | ||
| isa_tests = {'rv32mi', 'rv32uc', 'rv32ui', 'rv32um'} | ||
| isa_tests = ['rv32mi', 'rv32uc', 'rv32um', 'rv32ui'] | ||
| append_directed_testlist(isa_tests, '../../../../vendor/riscv-tests/isa/', 'riscv-tests', 1) | ||
|
|
||
| if 'riscv-arch-tests' in test_suite_list or test_suite == 'all': | ||
| arch_tests = {'rv32i_m/B/src', 'rv32i_m/C/src', 'rv32i_m/I/src', 'rv32i_m/M/src', 'rv32i_m/Zifencei/src'} | ||
| arch_tests = ['rv32i_m/M/src', 'rv32i_m/C/src', 'rv32i_m/Zifencei/src', 'rv32i_m/I/src', 'rv32i_m/B/src'] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit extra space here. |
||
| append_directed_testlist(arch_tests, '../../../../vendor/riscv-arch-tests/riscv-test-suite/', 'riscv-arch-tests', 1) | ||
|
|
||
| if 'epmp-tests' in test_suite_list or test_suite == 'all': | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This bump adds ZIHPM extension to Spike but it also pulls in the Zc* extensions. Is there any risk in that inclusion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. But that will be fine, because we anyway already have the Zc* extension in the RTL. Only the DV is not fully merged yet, but already having Spike support those extensions will not hurt.