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

Added Tests and Coverage for Exception Handling(Illegal instruction, environment calls and misaligned address exceptions) and Trap State Restoration Exceptions #605

Open
wants to merge 22 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6f8344f
Added tests for M mode exceptions
maria-rehman Jan 13, 2025
930a1d3
Added tests for U mode exceptions
maria-rehman Jan 13, 2025
82e3be9
Added tests for S mode exceptions
maria-rehman Jan 13, 2025
c9d7241
All merged M mode, S mode and U mode exceptions tests and tests for m…
maria-rehman Jan 13, 2025
218753e
Added test for different field values of fence.i
maria-rehman Jan 13, 2025
8866dbc
Added coverpoints
maria-rehman Jan 13, 2025
d95831b
Modified the M mode coverpoints
maria-rehman Jan 14, 2025
261cd84
Modified the Smode Coverpoints
maria-rehman Jan 14, 2025
e18c65d
Modified the tests for the U mode exceptions
maria-rehman Jan 14, 2025
c28922e
Modified the coverpoints for the U mode exceptions
maria-rehman Jan 14, 2025
b8c7416
Modified the test for fenci different field values
maria-rehman Jan 14, 2025
12757a4
Added the test for undefined opcodes
maria-rehman Jan 14, 2025
14bc1f0
Seperate tests are removed
maria-rehman Jan 15, 2025
6d605a2
Modified Coverpoint for M mode
maria-rehman Jan 15, 2025
0cb3e9d
Modified undefined opcodes test
maria-rehman Jan 15, 2025
b6f33c2
Added the tests for the ecall, illegal and misaligned exceptions for …
maria-rehman Jan 15, 2025
9561f96
trap_entry_test_illegal.S
maria-rehman Jan 16, 2025
fdfa46c
Modified M mode exceptions
maria-rehman Jan 16, 2025
b819262
Modified version
maria-rehman Jan 18, 2025
e726788
Modification in covergroups
maria-rehman Jan 18, 2025
9df4a90
Final Updated Version
maria-rehman Jan 22, 2025
1dc4476
Updated some comments in the file for future use
maria-rehman Jan 22, 2025
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
53 changes: 53 additions & 0 deletions coverage/excp_msu/rv32i_excp_Mmode.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

# Address illegal instruction exceptions coverpoints #

# This coverpoint will cover the illegal csr inappropriate csr and read only csr accesses, causing illegal instruction exceptions
cp_M_excp_illegal:
config:
- check ISA:=regex(.*32.*); check ISA:=regex(.*I.*Zicsr.*); def rvtest_mtrap_routine=True;
mnemonics:
"{csrrw, csrrs, csrrc, ecall}": 0
val_comb:
# for illegal csr
mode == 'M' and mnemonic == "csrrw" and mcause == ${CAUSE_ILLEGAL_INSTRUCTION} : 0

# for inappropriate csr
mode == 'M' and mnemonic == "csrrs" and mcause == ${CAUSE_ILLEGAL_INSTRUCTION} : 0

# for read only csr
mode == 'M' and mnemonic == "csrrc" and mcause == ${CAUSE_ILLEGAL_INSTRUCTION} : 0

# When mstatus TVM bit is set, accessing satp and sfence.vma in M-Mode should not raise illegal instruction fault.
mode == "M" and (mstatus & ${MSTATUS_TVM} == ${MSTATUS_TVM}) and mnemonic == "csrrw" and satp != 0: 0



# Address misaligned exceptions coverpoints #

# coverpoint for the load address misaligned
cp_M_load_addr_misaligned:
config:
- check ISA:=regex(.*32.*); check ISA:=regex(.*I.*Zicsr.*); def rvtest_mtrap_routine=True;
mnemonics:
lw : 0
val_comb:
mode == 'M' and mnemonic == "lw" and mcause == ${CAUSE_MISALIGNED_LOAD} : 0

# coverpoint for the store address misaligned
cp_M_store_addr_misaligned:
config:
- check ISA:=regex(.*32.*); check ISA:=regex(.*I.*Zicsr.*); def rvtest_mtrap_routine=True;
mnemonics:
sw : 0
val_comb:
mode == 'M' and mnemonic == "sw" and mcause == ${CAUSE_MISALIGNED_STORE} : 0

# this coverpoint is for ecall in machine mode
cp_M_ecall:
config:
- check ISA:=regex(.*I.*); def rvtest_mtrap_routine=True
mnemonics:
ecall: 0
val_comb:
# for ecall
mode == 'M' and mnemonic == "ecall" and mcause == ${CAUSE_MACHINE_ECALL} : 0
61 changes: 61 additions & 0 deletions coverage/excp_msu/rv32i_excp_Smode.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

# Coverpoints for S mode #

# this coverpoint is for ecall in Supervisor mode
cp_S_ecall:
config:
- check ISA:=regex(.*32.*); ISA:=regex(.*I.*); def rvtest_mtrap_routine=True; def rvtest_strap_routine=True
mnemonics:
ecall: 0
val_comb:
# for ecall
mode == 'S' and mnemonic == "ecall" and mcause == ${CAUSE_SUPERVISOR_ECALL} : 0


# Illegal instruction exceptions coverpoints #

# This coverpoint will cover the illegal csr inappropriate csr and read only csr accesses, causing illegal instruction exceptions
cp_S_excp_illegal:
config:
- check ISA:=regex(.*32.*); check ISA:=regex(.*I.*Zicsr.*); def rvtest_mtrap_routine=True; def rvtest_strap_routine=True

mnemonics:
"{csrrw, csrrs, csrrc, ecall}": 0

val_comb:
# for illegal csr
mode == 'S' and mnemonic == "csrrc" and mcause == ${CAUSE_ILLEGAL_INSTRUCTION} : 0

# for inappropriate csr
mode == 'S' and mnemonic == "csrrs" and mcause == ${CAUSE_ILLEGAL_INSTRUCTION} : 0

# for read only csr
mode == 'S' and mnemonic == "csrrw" and mcause == ${CAUSE_ILLEGAL_INSTRUCTION} : 0

# for mstatus_tvm bit enable
mode == "S" and (mstatus & ${MSTATUS_TVM} == ${MSTATUS_TVM}) and mnemonic == "csrrw" and mcause == ${CAUSE_ILLEGAL_INSTRUCTION}: 0




# Address misaligned exceptions coverpoints #

# coverpoint for the load address misaligned
cp_S_load_addr_misaligned:
config:
- check ISA:=regex(.*32.*); check ISA:=regex(.*I.*Zicsr.*); def rvtest_mtrap_routine=True; def rvtest_mtrap_routine=True
mnemonics:
lw : 0
val_comb:
mode == 'S' and mnemonic == "lw" and mcause == ${CAUSE_MISALIGNED_LOAD} : 0

# coverpoint for the store address misaligned
cp_S_store_addr_misaligned:
config:
- check ISA:=regex(.*32.*); check ISA:=regex(.*I.*Zicsr.*); def rvtest_mtrap_routine=True;
mnemonics:
sw : 0
val_comb:
mode == 'S' and mnemonic == "sw" and mcause == ${CAUSE_MISALIGNED_STORE} : 0


67 changes: 67 additions & 0 deletions coverage/excp_msu/rv32i_excp_Umode.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@



# this coverpoint is for ecall in Supervisor mode
cp_U_ecall:
config:
- check ISA:=regex(.*32.*); ISA:=regex(.*I.*); def rvtest_mtrap_routine=True; def rvtest_strap_routine=True

mnemonics:
ecall: 0

val_comb:
# for ecall
mode == 'U' and mnemonic == "ecall" and mcause == ${CAUSE_USER_ECALL}: 0

cp_U_excp_illegal:
config:
- check ISA:=regex(.*32.*); check ISA:=regex(.*I.*Zicsr.*); def rvtest_mtrap_routine=True; def rvtest_strap_routine=True

mnemonics:
"{csrrw, csrrs, csrrc, ecall}": 0

val_comb:
# for illegal csr/ non existing csr
mode == 'U' and mnemonic == "csrrc" and mcause == ${CAUSE_ILLEGAL_INSTRUCTION} : 0

# for inappropriate privillage mode
mode == 'U' and mnemonic == "csrrs" and mcause == ${CAUSE_ILLEGAL_INSTRUCTION} : 0

# for writing read only register
mode == 'U' and mnemonic == "csrrw" and mcause == ${CAUSE_ILLEGAL_INSTRUCTION} : 0

# for mstatus_tvm bit enable
mode == "U" and (mstatus & ${MSTATUS_TVM} == ${MSTATUS_TVM}) and mnemonic == "csrrw" and mcause == ${CAUSE_ILLEGAL_INSTRUCTION}: 0

# for medeleg
mode == "U" and (medeleg == 0x100) and mnemonic == "ecall" and scause == ${CAUSE_USER_ECALL}: 0


# coverpoint for the load address misaligned #

cp_U_load_addr_misaligned:
config:
- check ISA:=regex(.*32.*); check ISA:=regex(.*I.*Zicsr.*); def rvtest_mtrap_routine=True; def rvtest_strap_routine=True

mnemonics:
lw: 0

val_comb:
# for load
mode == 'U' and mnemonic == "lw" and mcause == ${CAUSE_MISALIGNED_LOAD} : 0

# coverpoint for the load address misaligned #

cp_U_store_addr_misaligned:
config:
- check ISA:=regex(.*32.*); check ISA:=regex(.*I.*Zicsr.*); def rvtest_mtrap_routine=True; def rvtest_strap_routine=True

mnemonics:
sw: 0

val_comb:
# for store
mode == 'U' and mnemonic == "sw" and mcause == ${CAUSE_MISALIGNED_STORE} : 0



147 changes: 147 additions & 0 deletions coverage/excp_msu/rv32i_traps_entry.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@

# These coverpoints will check that when illegal instrction exception occrs
# does it correctly updates the valuse of the mcause and mtval


m_trap_test_illegal_m_cause_tval:
config:
- check ISA:=regex(.*32.*); check ISA:=regex(.*I.*Zicsr.*); def rvtest_mtrap_routine=True;
mnemonics:
csrrw : 0
val_comb:
# for illegal csr
mode == 'M' and mnemonic == "csrrw" and mcause == ${CAUSE_ILLEGAL_INSTRUCTION} and mtval == 0xfff31073 : 0

s_trap_test_illegal_m_cause_tval:
config:
- check ISA:=regex(.*32.*); check ISA:=regex(.*I.*Zicsr.*); def rvtest_mtrap_routine=True;
mnemonics:
csrrc : 0
val_comb:
# for illegal csr
mode == 'S' and mnemonic == "csrrc" and mcause == ${CAUSE_ILLEGAL_INSTRUCTION} and mtval == 0xfff73373 : 0

u_trap_test_illegal_m_cause_tval:
config:
- check ISA:=regex(.*32.*); check ISA:=regex(.*I.*Zicsr.*); def rvtest_mtrap_routine=True;
mnemonics:
csrrs : 0
val_comb:
# for illegal csr
mode == 'U' and mnemonic == "csrrs" and mcause == ${CAUSE_ILLEGAL_INSTRUCTION} and mtval == 0xfff72373 : 0


# These coverpoints will check that when illegal instrction exception occurs
# does it correctly updates the values of the scause and stval

s_trap_test_illegal_s_cause_tval:
config:
- check ISA:=regex(.*32.*); check ISA:=regex(.*I.*Zicsr.*); def rvtest_mtrap_routine=True; def rvtest_strap_routine=True;
mnemonics:
csrrc : 0
val_comb:
# for illegal csr
mode == 'S' and mnemonic == "csrrc" and scause == ${CAUSE_ILLEGAL_INSTRUCTION} and stval == 0xfff73373 : 0

u_trap_test_illegal_s_cause_tval:
config:
- check ISA:=regex(.*32.*); check ISA:=regex(.*I.*Zicsr.*); def rvtest_mtrap_routine=True; def rvtest_strap_routine=True;
mnemonics:
csrrs : 0
val_comb:
# for illegal csr
mode == 'U' and mnemonic == "csrrs" and scause == ${CAUSE_ILLEGAL_INSTRUCTION} and stval == 0xfff72373 : 0


# These coverpoints will check that when load store address misaligned exception
# occurs does it correctly updates the valuse of the mcause and mtval

m_trap_test_load_m_cause_tval:
config:
- check ISA:=regex(.*32.*); check ISA:=regex(.*I.*Zicsr.*); def rvtest_mtrap_routine=True;
mnemonics:
"{lw , lh}" : 0
val_comb:
mode == 'M' and mnemonic == {"lw" , "lh"} and mcause == ${CAUSE_MISALIGNED_LOAD} and (mtval & 0x3) != 0: 0

m_trap_test_store_m_cause_tval:
config:
- check ISA:=regex(.*32.*); check ISA:=regex(.*I.*Zicsr.*); def rvtest_mtrap_routine=True;
mnemonics:
"{sw , sh}" : 0
val_comb:
mode == 'M' and mnemonic == {"sw" , "sh"} and mcause == ${CAUSE_MISALIGNED_STORE} and (mtval & 0x3) != 0: 0

s_trap_test_load_m_cause_tval:
config:
- check ISA:=regex(.*32.*); check ISA:=regex(.*I.*Zicsr.*); def rvtest_mtrap_routine=True; def rvtest_strap_routine=True;
mnemonics:
"{lw , lh}" : 0
val_comb:
mode == 'S' and mnemonic == {"lw" , "lh"} and mcause == ${CAUSE_MISALIGNED_LOAD} and (mtval & 0x3) != 0: 0

s_trap_test_store_m_cause_tval:
config:
- check ISA:=regex(.*32.*); check ISA:=regex(.*I.*Zicsr.*); def rvtest_mtrap_routine=True; def rvtest_strap_routine=True;
mnemonics:
"{sw , sh}" : 0
val_comb:
mode == 'S' and mnemonic == {"sw" , "sh"} and mcause == ${CAUSE_MISALIGNED_STORE} and (mtval & 0x3) != 0: 0

u_trap_test_load_m_cause_tval:
config:
- check ISA:=regex(.*32.*); check ISA:=regex(.*I.*Zicsr.*); def rvtest_mtrap_routine=True; def rvtest_strap_routine=True;
mnemonics:
"{lw , lh}" : 0
val_comb:
mode == 'U' and mnemonic == {"lw" , "lh"} and mcause == ${CAUSE_MISALIGNED_LOAD} and (mtval & 0x3) != 0: 0

u_trap_test_store_m_cause_tval:
config:
- check ISA:=regex(.*32.*); check ISA:=regex(.*I.*Zicsr.*); def rvtest_mtrap_routine=True; def rvtest_strap_routine=True;
mnemonics:
"{sw , sh}" : 0
val_comb:
mode == 'S' and mnemonic == {"sw" , "sh"} and mcause == ${CAUSE_MISALIGNED_STORE} and (mtval & 0x3) != 0: 0


# These coverpoints will check that when load store address misaligned exception
# occurs does it correctly updates the values of the scause and stval

s_trap_test_load_s_cause_tval:
config:
- check ISA:=regex(.*32.*); check ISA:=regex(.*I.*Zicsr.*); def rvtest_mtrap_routine=True; def rvtest_strap_routine=True;
mnemonics:
"{lw , lh}" : 0
val_comb:
mode == 'S' and mnemonic == {"lw" , "lh"} and scause == ${CAUSE_MISALIGNED_LOAD} and (stval & 0x3) != 0: 0


s_trap_test_store_s_cause_tval:
config:
- check ISA:=regex(.*32.*); check ISA:=regex(.*I.*Zicsr.*); def rvtest_mtrap_routine=True; def rvtest_strap_routine=True;
mnemonics:
"{sw , sh}" : 0
val_comb:
mode == 'S' and mnemonic == {"sw" , "sh"} and scause == ${CAUSE_MISALIGNED_STORE} and (stval & 0x3) != 0: 0


u_trap_test_load_s_cause_tval:
config:
- check ISA:=regex(.*32.*); check ISA:=regex(.*I.*Zicsr.*); def rvtest_mtrap_routine=True; def rvtest_strap_routine=True;
mnemonics:
"{lw , lh}" : 0
val_comb:
mode == 'U' and mnemonic == {"lw" , "lh"} and scause == ${CAUSE_MISALIGNED_LOAD} and (stval & 0x3) != 0: 0


u_trap_test_store_s_cause_tval:
config:
- check ISA:=regex(.*32.*); check ISA:=regex(.*I.*Zicsr.*); def rvtest_mtrap_routine=True; def rvtest_strap_routine=True;
mnemonics:
"{sw , sh}" : 0
val_comb:
mode == 'U' and mnemonic == {"sw" , "sh"} and scause == ${CAUSE_MISALIGNED_STORE} and (stval & 0x3) != 0: 0



53 changes: 53 additions & 0 deletions coverage/excp_msu/rv64i_excp_Mmode.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

# Address illegal instruction exceptions coverpoints #

# This coverpoint will cover the illegal csr inappropriate csr and read only csr accesses, causing illegal instruction exceptions
cp_M_excp_illegal:
config:
- check ISA:=regex(.*64.*); check ISA:=regex(.*I.*Zicsr.*); def rvtest_mtrap_routine=True;
mnemonics:
"{csrrw, csrrs, csrrc, ecall}": 0
val_comb:
# for illegal csr
mode == 'M' and mnemonic == "csrrw" and mcause == ${CAUSE_ILLEGAL_INSTRUCTION} : 0

# for inappropriate csr
mode == 'M' and mnemonic == "csrrs" and mcause == ${CAUSE_ILLEGAL_INSTRUCTION} : 0

# for read only csr
mode == 'M' and mnemonic == "csrrc" and mcause == ${CAUSE_ILLEGAL_INSTRUCTION} : 0

# When mstatus TVM bit is set, accessing satp and sfence.vma in M-Mode should not raise illegal instruction fault.
mode == "M" and (mstatus & ${MSTATUS_TVM} == ${MSTATUS_TVM}) and mnemonic == "csrrw" and satp != 0: 0



# Address misaligned exceptions coverpoints #

# coverpoint for the load address misaligned
cp_M_load_addr_misaligned:
config:
- check ISA:=regex(.*64.*); check ISA:=regex(.*I.*Zicsr.*); def rvtest_mtrap_routine=True;
mnemonics:
lw : 0
val_comb:
mode == 'M' and mnemonic == "lw" and mcause == ${CAUSE_MISALIGNED_LOAD} : 0

# coverpoint for the store address misaligned
cp_M_store_addr_misaligned:
config:
- check ISA:=regex(.*64.*); check ISA:=regex(.*I.*Zicsr.*); def rvtest_mtrap_routine=True;
mnemonics:
sw : 0
val_comb:
mode == 'M' and mnemonic == "sw" and mcause == ${CAUSE_MISALIGNED_STORE} : 0

# this coverpoint is for ecall in machine mode
cp_M_ecall:
config:
- check ISA:=regex(.*I.*); def rvtest_mtrap_routine=True
mnemonics:
ecall: 0
val_comb:
# for ecall
mode == 'M' and mnemonic == "ecall" and mcause == ${CAUSE_MACHINE_ECALL} : 0
Loading