From bfb07f4572085cb4d3ec1b8f2f035f3eaa888e7a Mon Sep 17 00:00:00 2001 From: David Harris Date: Thu, 12 May 2022 04:31:00 +0000 Subject: [PATCH 1/3] Added examples/asm/trap trap handler example --- examples/asm/trap/Makefile | 19 ++++ examples/asm/trap/trap | Bin 0 -> 7240 bytes examples/asm/trap/trap.S | 131 ++++++++++++++++++++++++ examples/asm/trap/trap.reference_output | 6 ++ 4 files changed, 156 insertions(+) create mode 100644 examples/asm/trap/Makefile create mode 100755 examples/asm/trap/trap create mode 100644 examples/asm/trap/trap.S create mode 100644 examples/asm/trap/trap.reference_output diff --git a/examples/asm/trap/Makefile b/examples/asm/trap/Makefile new file mode 100644 index 000000000..6e9f1b47c --- /dev/null +++ b/examples/asm/trap/Makefile @@ -0,0 +1,19 @@ +TARGET = trap + +$(TARGET).objdump: $(TARGET) + riscv64-unknown-elf-objdump -D $(TARGET) > $(TARGET).objdump + +$(TARGET): $(TARGET).S Makefile + riscv64-unknown-elf-gcc -g -o $(TARGET) -march=rv64gc -mabi=lp64 -mcmodel=medany \ + -nostartfiles -T../../link/link.ld $(TARGET).S + +sim: + spike +signature=$(TARGET).signature.output +signature-granularity=8 $(TARGET) + diff --ignore-case $(TARGET).signature.output $(TARGET).reference_output || exit + echo "Signature matches! Success!" + +clean: + rm -f $(TARGET) $(TARGET).objdump $(TARGET).signature.output + + + diff --git a/examples/asm/trap/trap b/examples/asm/trap/trap new file mode 100755 index 0000000000000000000000000000000000000000..1d7d3bbc6df2110efb0e4c30fb76c2173bb0e7a2 GIT binary patch literal 7240 zcmeHMPiP!f82@HwHztiub`vE+58Y&~_;)jI*H%PjlaQK18f#-jP~6VWPO?LGcb1t+ znt;(p{Up)q+= z7=aAps7{CQF_95@fed^Jq3qTVJh6;B5O*N%K-_`2191o94#XXZI}mpu?m*muxC3zq z{$mFQ1_AmNB{OgYW%paK1?Ll2RDkuB&7`+>PWMteelq&H3Z35CsD5RLeCjjanp*JA zCv;`p!;x0Y|MdOzzIrR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 Subject: [PATCH 2/3] Added MCONFIGPTR CSR hardwired to 0 --- pipelined/src/privileged/csrm.sv | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pipelined/src/privileged/csrm.sv b/pipelined/src/privileged/csrm.sv index 21234fc60..b32d30d26 100644 --- a/pipelined/src/privileged/csrm.sv +++ b/pipelined/src/privileged/csrm.sv @@ -38,6 +38,7 @@ module csrm #(parameter MARCHID = 12'hF12, MIMPID = 12'hF13, MHARTID = 12'hF14, + MCONFIGPTR = 12'hF15, MSTATUS = 12'h300, MISA_ADR = 12'h301, MEDELEG = 12'h302, @@ -186,6 +187,7 @@ module csrm #(parameter MARCHID: CSRMReadValM = 0; MIMPID: CSRMReadValM = `XLEN'h100; // pipelined implementation MHARTID: CSRMReadValM = MHARTID_REGW; // hardwired to 0 + MCONFIGPTR: CSRReadValM = 0; // hardwired to 0 MSTATUS: CSRMReadValM = MSTATUS_REGW; MSTATUSH: CSRMReadValM = MSTATUSH_REGW; MTVEC: CSRMReadValM = MTVEC_REGW; From 73a84f28b9a7445330af3cef709f8a784c729b8a Mon Sep 17 00:00:00 2001 From: David Harris Date: Thu, 12 May 2022 04:45:41 +0000 Subject: [PATCH 3/3] Moved some privileged tests to be simulated. --- bin/testlist.pl | 2 +- .../riscv-test-suite/rv32i_m/privilege/Makefrag | 11 +++++++---- .../riscv-test-suite/rv64i_m/privilege/Makefrag | 11 +++++++---- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/bin/testlist.pl b/bin/testlist.pl index 745ff29e5..12be0a913 100755 --- a/bin/testlist.pl +++ b/bin/testlist.pl @@ -9,7 +9,7 @@ use warnings; import os; if ($#ARGV != 0) { - die("Usage: $0 workpath [e.g. $0 $WALLY/addins/riscv-arch-test/work") + die("Usage: $0 workpath [e.g. $0 \$WALLY/addins/riscv-arch-test/work") } my $mypath = $ARGV[0]; my @dirs = glob($mypath.'/*/*'); diff --git a/tests/wally-riscv-arch-test/riscv-test-suite/rv32i_m/privilege/Makefrag b/tests/wally-riscv-arch-test/riscv-test-suite/rv32i_m/privilege/Makefrag index 3b530f755..b48db0871 100644 --- a/tests/wally-riscv-arch-test/riscv-test-suite/rv32i_m/privilege/Makefrag +++ b/tests/wally-riscv-arch-test/riscv-test-suite/rv32i_m/privilege/Makefrag @@ -36,6 +36,9 @@ rv32i_sc_tests = \ WALLY-misa-01 \ WALLY-amo \ WALLY-lrsc \ + WALLY-status-mie-01 \ + WALLY-trap-sret-01 \ + target_tests_nosim = \ WALLY-pma \ @@ -43,15 +46,15 @@ target_tests_nosim = \ WALLY-stvec-01 \ WALLY-mie-01 \ WALLY-sie-01 \ - WALLY-status-mie-01 \ - WALLY-status-sie-01 \ - WALLY-trap-sret-01 \ WALLY-trap-01 \ WALLY-trap-s-01 \ WALLY-trap-u-01 \ - WALLY-status-tw-01 \ WALLY-wfi-01 \ WALLY-status-fp-enabled-01 \ + WALLY-status-sie-01 \ + WALLY-status-tw-01 \ + +# unclear why wfi, status-fp-enabled, status-sie, and status-tw fail rv32i_tests = $(addsuffix .elf, $(rv32i_sc_tests)) diff --git a/tests/wally-riscv-arch-test/riscv-test-suite/rv64i_m/privilege/Makefrag b/tests/wally-riscv-arch-test/riscv-test-suite/rv64i_m/privilege/Makefrag index c81f1537a..319c5d930 100644 --- a/tests/wally-riscv-arch-test/riscv-test-suite/rv64i_m/privilege/Makefrag +++ b/tests/wally-riscv-arch-test/riscv-test-suite/rv64i_m/privilege/Makefrag @@ -38,6 +38,10 @@ rv64i_sc_tests = \ WALLY-amo \ WALLY-lrsc \ WALLY-trap-sret-01 \ + WALLY-status-mie-01 \ + WALLY-status-sie-01 \ + WALLY-status-tw-01 \ + # Don't simulate these because they rely on SoC features that Spike does not offer. target_tests_nosim = \ @@ -47,14 +51,13 @@ target_tests_nosim = \ WALLY-stvec-01 \ WALLY-mie-01 \ WALLY-sie-01 \ - WALLY-status-mie-01 \ - WALLY-status-sie-01 \ WALLY-trap-01 \ WALLY-trap-s-01 \ WALLY-trap-u-01 \ - WALLY-status-tw-01 \ - WALLY-wfi-01 \ WALLY-status-fp-enabled-01 \ + WALLY-wfi-01 \ + +# unclear why status-fp-enabled and wfi aren't simulating ok rv64i_tests = $(addsuffix .elf, $(rv64i_sc_tests))