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

Incorrect performance counter #139

Closed
jserv opened this issue Jun 2, 2023 · 0 comments
Closed

Incorrect performance counter #139

jserv opened this issue Jun 2, 2023 · 0 comments
Assignees

Comments

@jserv
Copy link
Contributor

jserv commented Jun 2, 2023

@ypaskell implemented a number of 64-bit read-only user-level counters, including CSR_CYCLE and CSR_CYCLEH (#33).

The procedure to validate:

make clean
rm -rf src/mini-gdbstub
git reset --hard 53a6f9463c4b344746cb1154cbfb995e44f30300
make
build/rv32emu build/perfcount.elf

Output:

cycle count: 1728
instret: 174
Sparkle state:
4DF96879 8C7C2C33
82236B4A 904F4DD7
D6A030E8 F03B09AA
C4C3BB34 F063DFF9
61F9CEFF 8EC21FFA
93DF370F 83ACF1E2

However, in recent commits, both CSR_CYCLE and CSR_CYCLEH fail to deliver the expected values.

$ build/rv32emu build/perfcount.elf 
cycle count: 0
instret: 0
Sparkle state:
4DF96879 8C7C2C33
82236B4A 904F4DD7
D6A030E8 F03B09AA
C4C3BB34 F063DFF9
61F9CEFF 8EC21FFA
93DF370F 83ACF1E2

There is no increment for both cycle count and instret.

qwe661234 added a commit to qwe661234/rv32emu that referenced this issue Jun 2, 2023
The issue occurs when the variable csr undergoes sign-extension. Specifically,
the values of CSR_CYCLE and CSR_CYCLEH are assigned as 0xC00 and 0xC80 respectively.
During the decoding immediate stage, these values are unintentionally sign-extended
to 0xFFFFFX00 and 0xFFFFFC80. To mitigate this problem, a solution is only
the last 12 bits of csr are considered, disregarding the sign extension.

Solve: sysprog21#139
qwe661234 added a commit to qwe661234/rv32emu that referenced this issue Jun 2, 2023
The issue occurs when the variable csr undergoes sign-extension. Specifically,
the values of CSR_CYCLE and CSR_CYCLEH are assigned as 0xC00 and 0xC80 respectively.
During the decoding immediate stage, these values are unintentionally sign-extended
to 0xFFFFFC00 and 0xFFFFFC80. To mitigate this problem, a solution is only
the last 12 bits of csr are considered, disregarding the sign extension.

Solve: sysprog21#139
@jserv jserv closed this as completed in 206094b Jun 2, 2023
2011eric pushed a commit to 2011eric/rv32emu that referenced this issue Jul 22, 2023
The issue occurs when the CSR undergoes sign-extension. Specifically, the values
of CSR_CYCLE and CSR_CYCLEH are assigned as 0xC00 and 0xC80 respectively.
During the decoding immediate stage, these values are unintentionally sign-extended
to 0xFFFFFC00 and 0xFFFFFC80. To mitigate this problem, a solution is only
the last 12 bits of CSR are considered, disregarding the sign extension.

Close sysprog21#139
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants