Skip to content

Commit

Permalink
feat(diff): support Sstc extension and set csr init (#55)
Browse files Browse the repository at this point in the history
* feat(diff): support Sstc extension

* fix(csr): set xtimecmp and m/henvcfg init when Sstc extension enable
  • Loading branch information
sinceforYy authored Nov 13, 2024
1 parent 37bfda6 commit 5f8a8b3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion difftest/difftest-def.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@
"_zfa_zfh_zvfh" \
"_svinval_sscofpmf" \
"_svpbmt" \
"_zicbom_zicboz"
"_zicbom_zicboz" \
"_sstc"

#define CONFIG_MEMORY_SIZE (16 * 1024 * 1024 * 1024UL)
#define CONFIG_FLASH_BASE 0x10000000UL
Expand Down
6 changes: 4 additions & 2 deletions riscv/csr_init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ void state_t::csr_init(processor_t* const proc, reg_t max_isa)
(proc->extension_enabled(EXT_ZICFISS) ? MENVCFG_SSE : 0) |
(proc->extension_enabled(EXT_SSDBLTRP) ? MENVCFG_DTE : 0);
const reg_t menvcfg_init = (proc->extension_enabled(EXT_ZICBOM) ? MENVCFG_CBCFE | MENVCFG_CBIE : 0) |
(proc->extension_enabled(EXT_ZICBOZ) ? MENVCFG_CBZE : 0);
(proc->extension_enabled(EXT_ZICBOZ) ? MENVCFG_CBZE : 0) |
(proc->extension_enabled(EXT_SSTC) ? MENVCFG_STCE : 0);
menvcfg = std::make_shared<envcfg_csr_t>(proc, CSR_MENVCFG, menvcfg_mask, menvcfg_init);
if (xlen == 32) {
add_user_csr(CSR_MENVCFG, std::make_shared<rv32_low_csr_t>(proc, CSR_MENVCFG, menvcfg));
Expand All @@ -298,7 +299,8 @@ void state_t::csr_init(processor_t* const proc, reg_t max_isa)
(proc->extension_enabled(EXT_ZICFISS) ? HENVCFG_SSE : 0) |
(proc->extension_enabled(EXT_SSDBLTRP) ? HENVCFG_DTE : 0);
const reg_t henvcfg_init = (proc->extension_enabled(EXT_ZICBOM) ? HENVCFG_CBCFE | HENVCFG_CBIE : 0) |
(proc->extension_enabled(EXT_ZICBOZ) ? HENVCFG_CBZE : 0);
(proc->extension_enabled(EXT_ZICBOZ) ? HENVCFG_CBZE : 0) |
(proc->extension_enabled(EXT_SSTC) ? HENVCFG_STCE : 0);
henvcfg = std::make_shared<henvcfg_csr_t>(proc, CSR_HENVCFG, henvcfg_mask, henvcfg_init, menvcfg);
if (xlen == 32) {
add_hypervisor_csr(CSR_HENVCFG, std::make_shared<rv32_low_csr_t>(proc, CSR_HENVCFG, henvcfg));
Expand Down
2 changes: 1 addition & 1 deletion riscv/csrs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1740,7 +1740,7 @@ bool henvcfg_csr_t::unlogged_write(const reg_t val) noexcept {
}

stimecmp_csr_t::stimecmp_csr_t(processor_t* const proc, const reg_t addr, const reg_t imask):
basic_csr_t(proc, addr, 0), intr_mask(imask) {
basic_csr_t(proc, addr, 0xffffffffffffffff), intr_mask(imask) {
}

bool stimecmp_csr_t::unlogged_write(const reg_t val) noexcept {
Expand Down

0 comments on commit 5f8a8b3

Please sign in to comment.