Skip to content

Commit 62e2a64

Browse files
committed
fix(dbltrp): align logic of sdt with xiangshan
* align vsstatus.sdt/henvcfg.DTE interaction logic with xiangshan * as vsstatus is not aliase of otther CSR fields and SDT is controlled by henvcfg.DTE. According to the manual, when the read/write property of **sdt** changes from **RO** to **RW**, its immediate value becomes **UNSPECIFIED** but valid. XiangShan adopts the simplest hardware implementation, allowing **vsstatus.sdt** to be written when **DTE** is disabled, while reads are masked by **DTE**. In contrast, Spike employs a design where both reads and writes are masked. To align the behavior of **vsstatus.sdt** in Spike with XiangShan during comparison, we adjust Spike's write behavior under **DTE**-disabled conditions to match XiangShan's. * add mstatus.sdt/sie, mstatus.mdt/mie missing interatcion logic. when sdt/mdt write 1, sie/mie will clear.
1 parent de6170a commit 62e2a64

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

riscv/csrs.cc

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -501,10 +501,21 @@ vsstatus_csr_t::vsstatus_csr_t(processor_t* const proc, const reg_t addr):
501501

502502
bool vsstatus_csr_t::unlogged_write(const reg_t val) noexcept {
503503
const reg_t hDTE = (state->henvcfg->read() & HENVCFG_DTE);
504-
const reg_t adj_write_mask = sstatus_write_mask & ~(hDTE ? 0 : SSTATUS_SDT);
504+
const reg_t adj_write_mask =
505+
#if defined(DIFFTEST) && defined(CPU_XIANGSHAN)
506+
sstatus_write_mask;
507+
#else
508+
sstatus_write_mask & ~(hDTE ? 0 : SSTATUS_SDT);
509+
#endif
505510
reg_t newval = (this->val & ~adj_write_mask) | (val & adj_write_mask);
511+
bool write_sdt =
512+
#if defined(DIFFTEST) && defined(CPU_XIANGSHAN)
513+
newval & SSTATUS_SDT && hDTE;
514+
#else
515+
(newval & SSTATUS_SDT);
516+
#endif
506517

507-
newval = (newval & SSTATUS_SDT) ? (newval & ~SSTATUS_SIE) : newval;
518+
newval = (write_sdt) ? (newval & ~SSTATUS_SIE) : newval;
508519

509520
if (state->v) maybe_flush_tlb(newval);
510521
this->val = adjust_sd(newval);
@@ -527,9 +538,7 @@ bool sstatus_proxy_csr_t::unlogged_write(const reg_t val) noexcept {
527538
const reg_t mDTE = (state->menvcfg->read() & MENVCFG_DTE);
528539
const reg_t adj_write_mask = sstatus_write_mask & ~(mDTE ? 0 : SSTATUS_SDT);
529540
reg_t new_mstatus = (mstatus->read() & ~adj_write_mask) | (val & adj_write_mask);
530-
531541
new_mstatus = (new_mstatus & SSTATUS_SDT) ? (new_mstatus & ~SSTATUS_SIE) : new_mstatus;
532-
533542
// On RV32 this will only log the low 32 bits, so make sure we're
534543
// not modifying anything in the upper 32 bits.
535544
assert((adj_write_mask & 0xffffffffU) == adj_write_mask);

0 commit comments

Comments
 (0)