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

Gate base counters on Zicntr extension #658

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions model/riscv_extensions.sail
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ enum clause extension = Ext_U
enum clause extension = Ext_Zicbom
// Cache-Block Zero Instructions
enum clause extension = Ext_Zicboz
// Base Counters and Timers
enum clause extension = Ext_Zicntr
// Integer Conditional Operations
enum clause extension = Ext_Zicond
// Instruction-Fetch Fence
Expand Down
21 changes: 11 additions & 10 deletions model/riscv_zicntr_control.sail
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/* */
/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/
function clause extensionEnabled(Ext_Zicntr) = true

/* user counters/timers */
mapping clause csr_name_map = 0xC00 <-> "cycle"
Expand All @@ -14,12 +15,12 @@ mapping clause csr_name_map = 0xC80 <-> "cycleh"
mapping clause csr_name_map = 0xC81 <-> "timeh"
mapping clause csr_name_map = 0xC82 <-> "instreth"

function clause is_CSR_defined(0xC00) = extensionEnabled(Ext_U) // cycle
function clause is_CSR_defined(0xC01) = extensionEnabled(Ext_U) // time
function clause is_CSR_defined(0xC02) = extensionEnabled(Ext_U) // instret
function clause is_CSR_defined(0xC80) = extensionEnabled(Ext_U) & (xlen == 32) // cycleh
function clause is_CSR_defined(0xC81) = extensionEnabled(Ext_U) & (xlen == 32) // timeh
function clause is_CSR_defined(0xC82) = extensionEnabled(Ext_U) & (xlen == 32) // instreth
function clause is_CSR_defined(0xC00) = extensionEnabled(Ext_Zicntr) & extensionEnabled(Ext_U) // cycle
function clause is_CSR_defined(0xC01) = extensionEnabled(Ext_Zicntr) & extensionEnabled(Ext_U) // time
function clause is_CSR_defined(0xC02) = extensionEnabled(Ext_Zicntr) & extensionEnabled(Ext_U) // instret
function clause is_CSR_defined(0xC80) = extensionEnabled(Ext_Zicntr) & extensionEnabled(Ext_U) & (xlen == 32) // cycleh
function clause is_CSR_defined(0xC81) = extensionEnabled(Ext_Zicntr) & extensionEnabled(Ext_U) & (xlen == 32) // timeh
function clause is_CSR_defined(0xC82) = extensionEnabled(Ext_Zicntr) & extensionEnabled(Ext_U) & (xlen == 32) // instreth

function clause read_CSR(0xC00) = mcycle[(xlen - 1) .. 0]
function clause read_CSR(0xC01) = mtime[(xlen - 1) .. 0]
Expand All @@ -35,10 +36,10 @@ mapping clause csr_name_map = 0xB02 <-> "minstret"
mapping clause csr_name_map = 0xB80 <-> "mcycleh"
mapping clause csr_name_map = 0xB82 <-> "minstreth"

function clause is_CSR_defined(0xB00) = true // mcycle
function clause is_CSR_defined(0xB02) = true // minstret
function clause is_CSR_defined(0xB80) = xlen == 32 // mcycleh
function clause is_CSR_defined(0xB82) = xlen == 32 // minstreth
function clause is_CSR_defined(0xB00) = extensionEnabled(Ext_Zicntr) // mcycle
function clause is_CSR_defined(0xB02) = extensionEnabled(Ext_Zicntr) // minstret
function clause is_CSR_defined(0xB80) = extensionEnabled(Ext_Zicntr) & xlen == 32 // mcycleh
function clause is_CSR_defined(0xB82) = extensionEnabled(Ext_Zicntr) & xlen == 32 // minstreth

function clause read_CSR(0xB00) = mcycle[(xlen - 1) .. 0]
function clause read_CSR(0xB02) = minstret[(xlen - 1) .. 0]
Expand Down
Loading