Skip to content

Commit

Permalink
Add stateen support
Browse files Browse the repository at this point in the history
  • Loading branch information
trdthg committed Mar 3, 2025
1 parent 2dfc4ff commit 5debc31
Show file tree
Hide file tree
Showing 10 changed files with 362 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile.old
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ PRELUDE = prelude.sail riscv_errors.sail $(SAIL_XLEN) $(SAIL_FLEN) $(SAIL_VLEN)

SAIL_REGS_SRCS = riscv_csr_begin.sail # Start of CSR scattered definitions.
SAIL_REGS_SRCS += riscv_reg_type.sail riscv_freg_type.sail riscv_regs.sail riscv_pc_access.sail riscv_sys_regs.sail
SAIL_REGS_SRCS += riscv_stateen_regs.sail
SAIL_REGS_SRCS += riscv_pmp_regs.sail riscv_pmp_control.sail
SAIL_REGS_SRCS += riscv_ext_regs.sail $(SAIL_CHECK_SRCS)
SAIL_REGS_SRCS += riscv_vreg_type.sail riscv_vext_regs.sail
Expand Down
10 changes: 10 additions & 0 deletions c_emulator/riscv_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,21 @@ bool sys_enable_zicboz(unit u)
return rv_enable_zicboz;
}

bool sys_enable_ssstateen(unit u)
{
return rv_enable_ssstateen;
}

bool sys_enable_sstc(unit u)
{
return rv_enable_sstc;
}

bool sys_enable_smstateen(unit u)
{
return rv_enable_smstateen;
}

uint64_t sys_pmp_count(unit u)
{
return rv_pmp_count;
Expand Down
2 changes: 2 additions & 0 deletions c_emulator/riscv_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ bool sys_enable_vext(unit);
bool sys_enable_bext(unit);
bool sys_enable_zicbom(unit);
bool sys_enable_zicboz(unit);
bool sys_enable_ssstateen(unit u);
bool sys_enable_sstc(unit);
bool sys_enable_smstateen(unit u);

uint64_t sys_pmp_count(unit);
uint64_t sys_pmp_grain(unit);
Expand Down
2 changes: 2 additions & 0 deletions c_emulator/riscv_platform_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ bool rv_enable_vext = true;
bool rv_enable_bext = false;
bool rv_enable_zicbom = false;
bool rv_enable_zicboz = false;
bool rv_enable_ssstateen = false;
bool rv_enable_sstc = false;
bool rv_enable_smstateen = false;

bool rv_enable_dirty_update = false;
bool rv_enable_misaligned = false;
Expand Down
2 changes: 2 additions & 0 deletions c_emulator/riscv_platform_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ extern bool rv_enable_vext;
extern bool rv_enable_bext;
extern bool rv_enable_zicbom;
extern bool rv_enable_zicboz;
extern bool rv_enable_ssstateen;
extern bool rv_enable_sstc;
extern bool rv_enable_smstateen;
extern bool rv_enable_writable_misa;
extern bool rv_enable_dirty_update;
extern bool rv_enable_misaligned;
Expand Down
10 changes: 10 additions & 0 deletions c_emulator/riscv_sim.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ enum {
OPT_ENABLE_ZCB,
OPT_ENABLE_ZICBOM,
OPT_ENABLE_ZICBOZ,
OPT_ENABLE_SSSTATEEN,
OPT_ENABLE_SSTC,
OPT_ENABLE_SMSTATEEN,
OPT_CACHE_BLOCK_SIZE,
};

Expand Down Expand Up @@ -396,10 +398,18 @@ static int process_args(int argc, char **argv)
fprintf(stderr, "enabling Zicboz extension.\n");
rv_enable_zicboz = true;
break;
case OPT_ENABLE_SSSTATEEN:
fprintf(stderr, "enabling Ssstateen extension.\n");
rv_enable_ssstateen = true;
break;
case OPT_ENABLE_SSTC:
fprintf(stderr, "enabling Sstc extension.\n");
rv_enable_sstc = true;
break;
case OPT_ENABLE_SMSTATEEN:
fprintf(stderr, "enabling Smstateen extension.\n");
rv_enable_smstateen = true;
break;
case OPT_CACHE_BLOCK_SIZE:
block_size_exp = ilog2(atol(optarg));

Expand Down
1 change: 1 addition & 0 deletions model/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ foreach (xlen IN ITEMS 32 64)
${sail_check_srcs}
"riscv_vreg_type.sail"
"riscv_vext_regs.sail"
"riscv_stateen_regs.sail"
)

set(sail_arch_srcs
Expand Down
4 changes: 4 additions & 0 deletions model/riscv_extensions.sail
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ enum clause extension = Ext_Zhinx

// Count Overflow and Mode-Based Filtering
enum clause extension = Ext_Sscofpmf
// Supervisor-mode view of the state-enable extension
enum clause extension = Ext_Ssstateen
// Supervisor-mode Timer Interrupts
enum clause extension = Ext_Sstc
// Fine-Grained Address-Translation Cache Invalidation
Expand All @@ -116,3 +118,5 @@ enum clause extension = Ext_Svpbmt

// Cycle and Instret Privilege Mode Filtering
enum clause extension = Ext_Smcntrpmf
// Machine-mode view of the state-enable extension
enum clause extension = Ext_Smstateen
Loading

0 comments on commit 5debc31

Please sign in to comment.