Skip to content
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

[dv] Fix performance counter printing in simple system #2102

Merged
merged 2 commits into from
Nov 24, 2023

Conversation

rswarbrick
Copy link
Contributor

This comes in two commits, but the first is a silly typo fix. The commit message for the second is:

[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.

Partial fix for #2101.

@rswarbrick rswarbrick added the Component:DV Design verification (DV) or testing issue label Nov 20, 2023
@rswarbrick rswarbrick requested a review from GregAC November 20, 2023 16:22
@rswarbrick rswarbrick linked an issue Nov 20, 2023 that may be closed by this pull request
if (index == 0 || index == 2)
return true;

// The "NONE" counter is fake. That never exists.
Copy link
Contributor

@nbdd0121 nbdd0121 Nov 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// The "NONE" counter is fake. That never exists.
// The "NONE" counter is a placeholder for the "MTIME" CSR. That never exists.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that makes sense. I couldn't figure this out: how can we tell that index 1 corresponds to the MTIME CSR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's in the order of MCYCLE, MTIME, MINSTRET, MHPMCOUNTER3, ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm clearly being slow here. Where does that list of CSRs come from? Is it a standard RISC-V thing? My web searches find lots of Ibex...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at e.g. the RISC-V privileged spec, I see MCYCLE, (a gap here), MINSTRET, MHPMCOUNTER3, ... in table 2.5.

Is there a spec that explains that the gap is MTIME?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MTIME was once an actual CSR but later removed from the spec since people want it to be MMIO instead of actual CSR. But you can guess that this counter is reserved for MTIME by looking at the list of user-mode CSRs, which is CYCLE, TIME, INSTRET, HPMCOUNTER3, ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahah! Thanks for the explanation. I'll tweak this PR to match.

This will avoid printing out a load of spurious zeros if the Ibex
config doesn't enable the corresponding counter.
@nbdd0121 nbdd0121 enabled auto-merge November 24, 2023 20:11
@nbdd0121 nbdd0121 added this pull request to the merge queue Nov 24, 2023
Merged via the queue into lowRISC:master with commit c37edf5 Nov 24, 2023
10 checks passed
@rswarbrick rswarbrick deleted the hpm-fewer-zeroes branch November 24, 2023 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component:DV Design verification (DV) or testing issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Strange performance counters after following Simple System guide
2 participants