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

Draft : Added test cases for load address match trigger in sdtrig extension #487

Open
wants to merge 31 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
ac1e9a3
Added test cases for load address match trigger in sdtrig extension
anuani21 Sep 3, 2024
16c1028
Merge branch 'dev' into Sdtrig
anuani21 Sep 3, 2024
222b4d6
Updated load test cases and added store, execute test cases with diff…
anuani21 Sep 30, 2024
04b414d
Merge branch 'dev' into Sdtrig
anuani21 Sep 30, 2024
d2e7cd8
updated tests
anuani21 Oct 4, 2024
dbb9090
Merge branch 'Sdtrig' of https://github.com/anuani21/riscv-arch-test …
anuani21 Oct 4, 2024
fc0c35e
Modified test cases
anuani21 Oct 4, 2024
02b07a3
Removed
anuani21 Oct 4, 2024
486cab3
Delete riscv-test-suite/rv32i_m/sdtrig/store_match5.S
anuani21 Oct 4, 2024
66801c4
Delete riscv-test-suite/rv32i_m/sdtrig/execute_match0.S
anuani21 Oct 4, 2024
65c0e80
Delete riscv-test-suite/rv32i_m/sdtrig/execute_match2.S
anuani21 Oct 4, 2024
491877e
Delete riscv-test-suite/rv32i_m/sdtrig/execute_match3.S
anuani21 Oct 4, 2024
c22ab26
Delete riscv-test-suite/rv32i_m/sdtrig/execute_match4.S
anuani21 Oct 4, 2024
c33f0d4
Delete riscv-test-suite/rv32i_m/sdtrig/execute_match5.S
anuani21 Oct 4, 2024
eab99bd
Delete riscv-test-suite/rv32i_m/sdtrig/load_match0.S
anuani21 Oct 4, 2024
0eaefef
Delete riscv-test-suite/rv32i_m/sdtrig/load_match1.S
anuani21 Oct 4, 2024
b401d05
Delete riscv-test-suite/rv32i_m/sdtrig/load_match2.S
anuani21 Oct 4, 2024
16949c0
Delete riscv-test-suite/rv32i_m/sdtrig/load_match3.S
anuani21 Oct 4, 2024
821d960
Delete riscv-test-suite/rv32i_m/sdtrig/load_match4.S
anuani21 Oct 4, 2024
29cc8b1
Delete riscv-test-suite/rv32i_m/sdtrig/load_match5.S
anuani21 Oct 4, 2024
2020acc
Delete riscv-test-suite/rv32i_m/sdtrig/store_match0.S
anuani21 Oct 4, 2024
9d52f76
Delete riscv-test-suite/rv32i_m/sdtrig/store_match1.S
anuani21 Oct 4, 2024
47f0808
Delete riscv-test-suite/rv32i_m/sdtrig/store_match2.S
anuani21 Oct 4, 2024
2198dd5
Delete riscv-test-suite/rv32i_m/sdtrig/store_match3.S
anuani21 Oct 4, 2024
18abd78
Delete riscv-test-suite/rv32i_m/sdtrig/store_match4.S
anuani21 Oct 4, 2024
b3abd20
Delete riscv-test-suite/rv32i_m/sdtrig/src directory
anuani21 Oct 4, 2024
c858b14
Updated test cases for execute,load and store operations
anuani21 Oct 4, 2024
717eaf8
Merge branch 'riscv-non-isa:dev' into Sdtrig
anuani21 Oct 15, 2024
2d0b254
Updated test cases
anuani21 Oct 15, 2024
61b43c4
Icount test cases
anuani21 Nov 1, 2024
8ea168a
Merge branch 'riscv-non-isa:dev' into Sdtrig
anuani21 Nov 1, 2024
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
3,112 changes: 3,112 additions & 0 deletions riscv-test-suite/env/debug_defines.h

Large diffs are not rendered by default.

114 changes: 114 additions & 0 deletions riscv-test-suite/rv32i_m/sdtrig/src/execute_match0.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#include "model_test.h"
#include "arch_test.h"
#include "debug_defines.h"
RVTEST_ISA("RV32IZicsr_Sdtrig")

.section .text.init
.globl rvtest_entry_point
rvtest_entry_point:
RVMODEL_BOOT
RVTEST_CODE_BEGIN

#ifdef TEST_CASE_1
RVTEST_CASE(1,"//check ISA:=regex(.*I.*Zicsr.*Sdtrig.*);def TEST_CASE_1=True;",execute_match0)
RVTEST_SIGBASE(x1, signature_x1_0)
# Set mtvec to the address of the trap handler
la a0, trap_handler
csrw mtvec, a0

# Read the misa
csrr t2, misa
RVTEST_SIGUPD(x1,t2)
li t1, (1 << 18)
and t2,t2,t1

bnez t2, implement_mie
beqz t2 , implement_tcontrol

implement_mie:
li t1,(1<<3)
csrw mstatus, t1
csrr t4, mstatus
j resume_code

implement_tcontrol:

li t3, (1<<3)
csrw tcontrol, t3
csrr t4, tcontrol
j resume_code

resume_code:
# Write 0 to tselect, read back and append it to the signature
csrw tselect, zero
csrr t0, tselect
RVTEST_SIGUPD(x1, t0)

# Read tinfo
csrr t6, tinfo

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now this isn't used anywhere.

# Set the value of tdata
csrw tdata1, zero
csrr a3, tdata1

# Set the address for tdata2 where the trigger should occur
la t2, 0x80001234 # Set the data value to match
csrw tdata2, t2


# Set up trigger to cause a trap on a breakpoint
# Configure tdata1 for address match control
li t2, (CSR_TDATA1_TYPE_MCONTROL6 << 28 | \
CSR_TDATA1_DMODE_BOTH << 27 | \
CSR_MCONTROL6_SELECT_ADDRESS << 21 | \
CSR_MCONTROL6_SIZE_ANY << 16 | \
CSR_MCONTROL6_CHAIN_DISABLED << 11 | \
CSR_MCONTROL6_ACTION_BREAKPOINT << 12 | \
CSR_MCONTROL6_MATCH_EQUAL << 7 | \
CSR_MCONTROL6_M | \
CSR_MCONTROL6_EXECUTE)
csrw tdata1, t2
csrr t4,tdata1
RVTEST_SIGUPD(x1, t4)
csrr t6,tdata2
RVTEST_SIGUPD(x1, t6)

# Trigger setup complete; now perform an instruction that will hit the trigger
la t4, 0x80001234
jalr x0,0(t4)
nop
nop

#endif

trap_handler:
# Save trap information
csrr t0, mcause # Cause of the trap
csrr t1, mepc # Program counter at the time of trap
csrr t2, mtval # Trap value
RVTEST_SIGUPD(x1, t0) # Update signature with mcause
RVTEST_SIGUPD(x1, t1) # Update signature with mepc
RVTEST_SIGUPD(x1, t2) # Update signature with mtval

# Check if the trigger hit bit is set (bit 22 in tdata1)
csrr t3, tdata1
RVTEST_SIGUPD(x1, t3)

end:
RVTEST_CODE_END
RVMODEL_HALT

# Output data section.
RVMODEL_DATA_BEGIN
rvtest_sig_begin:
sig_begin_canary:
CANARY;

signature_x1_0:
.fill 128*(XLEN/32),4,0xdeadbeef

sig_end_canary:
CANARY;
rvtest_sig_end:
RVMODEL_DATA_END

116 changes: 116 additions & 0 deletions riscv-test-suite/rv32i_m/sdtrig/src/execute_match1.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#include "model_test.h"
#include "arch_test.h"
#include "debug_defines.h"
RVTEST_ISA("RV32IZicsr_Sdtrig")

.section .text.init
.globl rvtest_entry_point
rvtest_entry_point:
RVMODEL_BOOT
RVTEST_CODE_BEGIN

#ifdef TEST_CASE_1
RVTEST_CASE(1,"//check ISA:=regex(.*I.*Zicsr.*Sdtrig.*);def TEST_CASE_1=True;",execute_match1)
RVTEST_SIGBASE(x1, signature_x1_0)

# Set mtvec to the address of the trap handler
la a0, trap_handler
csrw mtvec, a0

# Read the misa
csrr t2, misa
RVTEST_SIGUPD(x1,t2)
li t1, (1 << 18)
and t2,t2,t1

bnez t2, implement_mie
beqz t2 , implement_tcontrol

implement_mie:
li t1,(1<<3)
csrw mstatus, t1
csrr t4, mstatus
j resume_code

implement_tcontrol:

li t3, (1<<3)
csrw tcontrol, t3
csrr t4, tcontrol
j resume_code

resume_code:

# Write 0 to tselect, read back and append it to the signature
csrw tselect, zero
csrr t0, tselect
RVTEST_SIGUPD(x1, t0)

# Read tinfo
csrr t6, tinfo

# Set the value of tdata
csrw tdata1, zero
csrr a3, tdata1

# Set the address for tdata2 where the trigger should occur
la t2, 0x80001001 # Set the data value to match
csrw tdata2, t2


# Set up trigger to cause a trap on a breakpoint
# Configure tdata1 for address match control
li t2, (CSR_TDATA1_TYPE_MCONTROL6 << 28 | \
CSR_TDATA1_DMODE_BOTH << 27 | \
CSR_MCONTROL6_SELECT_ADDRESS << 21 | \
CSR_MCONTROL6_SIZE_ANY << 16 | \
CSR_MCONTROL6_CHAIN_DISABLED << 11 | \
CSR_MCONTROL6_ACTION_BREAKPOINT << 12 | \
CSR_MCONTROL6_MATCH_NAPOT << 7 | \
CSR_MCONTROL6_M | \
CSR_MCONTROL6_EXECUTE)
csrw tdata1, t2
csrr t4,tdata1
RVTEST_SIGUPD(x1, t4)
csrr t6,tdata2
RVTEST_SIGUPD(x1, t6)

# Trigger setup complete; now perform an instruction that will hit the trigger
la t4, 0x80001000
jalr x0,0(t4)
nop
nop

#endif

trap_handler:
# Save trap information
csrr t0, mcause # Cause of the trap
csrr t1, mepc # Program counter at the time of trap
csrr t2, mtval # Trap value
RVTEST_SIGUPD(x1, t0) # Update signature with mcause
RVTEST_SIGUPD(x1, t1) # Update signature with mepc
RVTEST_SIGUPD(x1, t2) # Update signature with mtval

# Check if the trigger hit bit is set (bit 22 in tdata1)
csrr t3, tdata1
RVTEST_SIGUPD(x1, t3)

end:
RVTEST_CODE_END
RVMODEL_HALT

# Output data section.
RVMODEL_DATA_BEGIN
rvtest_sig_begin:
sig_begin_canary:
CANARY;

signature_x1_0:
.fill 128*(XLEN/32),4,0xdeadbeef

sig_end_canary:
CANARY;
rvtest_sig_end:
RVMODEL_DATA_END

115 changes: 115 additions & 0 deletions riscv-test-suite/rv32i_m/sdtrig/src/execute_match2.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#include "model_test.h"
#include "arch_test.h"
#include "debug_defines.h"
RVTEST_ISA("RV32IZicsr_Sdtrig")

.section .text.init
.globl rvtest_entry_point
rvtest_entry_point:
RVMODEL_BOOT
RVTEST_CODE_BEGIN

#ifdef TEST_CASE_1
RVTEST_CASE(1,"//check ISA:=regex(.*I.*Zicsr.*Sdtrig.*);def TEST_CASE_1=True;",execute_match2)
RVTEST_SIGBASE(x1, signature_x1_0)

# Set mtvec to the address of the trap handler
la a0, trap_handler
csrw mtvec, a0

# Read the misa
csrr t2, misa
RVTEST_SIGUPD(x1,t2)
li t1, (1 << 18)
and t2,t2,t1

bnez t2, implement_mie
beqz t2 , implement_tcontrol

implement_mie:
li t1,(1<<3)
csrw mstatus, t1
csrr t4, mstatus
j resume_code

implement_tcontrol:

li t3, (1<<3)
csrw tcontrol, t3
csrr t4, tcontrol
j resume_code

resume_code:

# Write 0 to tselect, read back and append it to the signature
csrw tselect, zero
csrr t0, tselect
RVTEST_SIGUPD(x1, t0)

# Read tinfo
csrr t6, tinfo

# Set the value of tdata
csrw tdata1, zero
csrr a3, tdata1

# Set the address for tdata2 where the trigger should occur
la t2, 0x80001233 # Set the data value to match
csrw tdata2, t2

# Set up trigger to cause a trap on a breakpoint
# Configure tdata1 for address match control
li t2, (CSR_TDATA1_TYPE_MCONTROL6 << 28 | \
CSR_TDATA1_DMODE_BOTH << 27 | \
CSR_MCONTROL6_SELECT_ADDRESS << 21 | \
CSR_MCONTROL6_SIZE_ANY << 16 | \
CSR_MCONTROL6_CHAIN_DISABLED << 11 | \
CSR_MCONTROL6_ACTION_BREAKPOINT << 12 | \
CSR_MCONTROL6_MATCH_GE << 7 | \
CSR_MCONTROL6_M | \
CSR_MCONTROL6_EXECUTE)
csrw tdata1, t2
csrr t4,tdata1
RVTEST_SIGUPD(x1, t4)
csrr t6,tdata2
RVTEST_SIGUPD(x1, t6)

# Trigger setup complete; now perform an instruction that will hit the trigger
la t4, 0x80001234
jalr x0,0(t4)
nop
nop

#endif

trap_handler:
# Save trap information
csrr t0, mcause # Cause of the trap
csrr t1, mepc # Program counter at the time of trap
csrr t2, mtval # Trap value
RVTEST_SIGUPD(x1, t0) # Update signature with mcause
RVTEST_SIGUPD(x1, t1) # Update signature with mepc
RVTEST_SIGUPD(x1, t2) # Update signature with mtval

# Check if the trigger hit bit is set (bit 22 in tdata1)
csrr t3, tdata1
RVTEST_SIGUPD(x1, t3)

end:
RVTEST_CODE_END
RVMODEL_HALT

# Output data section.
RVMODEL_DATA_BEGIN
rvtest_sig_begin:
sig_begin_canary:
CANARY;

signature_x1_0:
.fill 128*(XLEN/32),4,0xdeadbeef

sig_end_canary:
CANARY;
rvtest_sig_end:
RVMODEL_DATA_END

Loading