Skip to content

Commit 4f6c493

Browse files
Merge pull request #279 from ACWright256/main
Excluded and added coverage for WFI test case.
2 parents 0ad5165 + 667c54c commit 4f6c493

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

src/privileged/privdec.sv

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ module privdec (
6969
logic [`WFI_TIMEOUT_BIT:0] WFICount, WFICountPlus1;
7070
assign WFICountPlus1 = WFICount + 1;
7171
floprc #(`WFI_TIMEOUT_BIT+1) wficountreg(clk, reset, ~wfiM, WFICountPlus1, WFICount); // count while in WFI
72+
// coverage off -item e 1 -fecexprrow 1
73+
// WFI Timout trap will not occur when STATUS_TW is low while in supervisor mode, so the system gets stuck waiting for an interrupt and triggers a watchdog timeout.
7274
assign WFITimeoutM = ((STATUS_TW & PrivilegeModeW != `M_MODE) | (`S_SUPPORTED & PrivilegeModeW == `U_MODE)) & WFICount[`WFI_TIMEOUT_BIT];
75+
// coverage on
7376
end else assign WFITimeoutM = 0;
7477

7578
///////////////////////////////////////////

tests/coverage/priv.S

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,24 @@ main:
169169
csrw mcounteren, t0
170170
csrw scounteren, t0
171171

172+
#getting the remainder of PMD instructions
173+
174+
#go to user mode
175+
li a0, 0
176+
ecall
177+
#set status TVM to 0 by writing to bit 20 of mstatus as 0
178+
#bseti t0, zero, 20
179+
sfence.vma zero, zero
180+
181+
# Go to supervisor mode
182+
li a0, 1
183+
ecall
184+
185+
sfence.vma zero, zero
186+
187+
li a0, 3
188+
ecall
189+
172190
# Write to satp when status.TVM is 1 from machine mode
173191
bseti t0, zero, 20
174192
csrs mstatus, t0
@@ -203,6 +221,30 @@ main:
203221

204222
csrr t0, hpmcounter22
205223

224+
#getting the mpp and mstatus Mpriv condition met
225+
#go to machine mode
226+
li a0, 3
227+
ecall
228+
# set bit 17 of mstatus to enable STATUS_MPRV
229+
bseti t1, zero, 17
230+
csrs mstatus, t1
231+
232+
li a0, 3
233+
ecall
234+
235+
# set bit 21 of mstatus to 0 to disable STATUS_TW
236+
csrr t1, mstatus
237+
bseti t2, zero, 21
238+
not t2, t2
239+
and t1, t1, t2
240+
csrs mstatus, t1
241+
242+
# go to user mode
243+
li a0, 0
244+
ecall
245+
246+
wfi
247+
206248
j done
207249

208250

0 commit comments

Comments
 (0)