From 0e08c4393de324e0c3d12c7f4042670106af035f Mon Sep 17 00:00:00 2001 From: Noah Limpert Date: Wed, 29 Mar 2023 13:07:34 -0700 Subject: [PATCH 1/9] access of 4KiB spaced mem locations, aim to fill + evict a line of all 4 ways --- tests/coverage/lsu.S | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/coverage/lsu.S diff --git a/tests/coverage/lsu.S b/tests/coverage/lsu.S new file mode 100644 index 00000000..92d01b19 --- /dev/null +++ b/tests/coverage/lsu.S @@ -0,0 +1,34 @@ +//lsu.S +// A set of tests meant to stress the LSU to increase coverage +// Manuel Alejandro Mendoza Manriquez mmendozamanriquez@g.hmc.edu +// Noah Limpert nlimpert@g.hmc.edu +// March 28 2023 + + +// Test 1 +// Cache ways 1,2,3 do not have SelFlush = 0 +// To make SelFlush = 0 we must evict lines from ways 1,2,3 +// Will load 4 words with same tags, filling 4 ways of cache +// edit and store these words so that dirty bit is set ( is this necessary?) +// Will then load 4 more words, evicting the previous 4 words +// will make SelFlush = 0 for all 4 ways. + +// Load code to initialize stack, handle interrupts, terminate +#include "WALLY-init-lib.h" + +main: + li t0, 4096 //offset such that set will be same + li t1, 0 #t1 = i = 0 + li t2, 8 # n = 8 + add t3, sp, 0 // what our offset for loads and stores will be + +for1: bge t1, t2, done + add t3, t3, t0 + lw t4, 0(t3) + addi t4, t4, 1 + sw t4, 0(t3) + addi t1, t1, 1 + j for1 + + + From 0fea40282ad829a7823ab286ab02a070ab574fa6 Mon Sep 17 00:00:00 2001 From: Noah Limpert Date: Wed, 29 Mar 2023 13:08:33 -0700 Subject: [PATCH 2/9] instantiate 5 4KiB arrays, aim to thrash all 4 ways --- tests/coverage/lsuGB.S | 99 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 tests/coverage/lsuGB.S diff --git a/tests/coverage/lsuGB.S b/tests/coverage/lsuGB.S new file mode 100644 index 00000000..8a902ba7 --- /dev/null +++ b/tests/coverage/lsuGB.S @@ -0,0 +1,99 @@ +//lsuGB.S +// A set of tests meant to stress the LSU to increase coverage +// Manuel Alejandro Mendoza Manriquez mmendozamanriquez@g.hmc.edu +// Noah Limpert nlimpert@g.hmc.edu +// March 28 2023 + + +// Test 2 +//Try to thrash ! used godbolt! +// Cache ways 1,2,3 do not have SelFlush = 0 +// To make SelFlush = 0 we must evict lines from ways 1,2,3 +// Will load 4 words with same tags, filling 4 ways of cache +// edit and store these words so that dirty bit is set ( is this necessary?) +// Will then load 4 more words, evicting the previous 4 words +// will make SelFlush = 0 for all 4 ways. + +// Load code to initialize stack, handle interrupts, terminate +#include "WALLY-init-lib.h" + +main: + addi sp,sp,-32 + sd s0,24(sp) + addi s0,sp,32 + li t1,-20480 + add sp,sp,t1 + sw zero,-20(s0) + j .L2 +.L3: + li a5,-4096 + addi a4,s0,-16 + add a4,a4,a5 + lw a5,-20(s0) + slli a5,a5,2 + add a5,a4,a5 + lw a4,-8(a5) + li a5,-8192 + addi a3,s0,-16 + add a3,a3,a5 + lw a5,-20(s0) + slli a5,a5,2 + add a5,a3,a5 + sw a4,-8(a5) + li a5,-8192 + addi a4,s0,-16 + add a4,a4,a5 + lw a5,-20(s0) + slli a5,a5,2 + add a5,a4,a5 + lw a4,-8(a5) + li a5,-12288 + addi a3,s0,-16 + add a3,a3,a5 + lw a5,-20(s0) + slli a5,a5,2 + add a5,a3,a5 + sw a4,-8(a5) + li a5,-12288 + addi a4,s0,-16 + add a4,a4,a5 + lw a5,-20(s0) + slli a5,a5,2 + add a5,a4,a5 + lw a4,-8(a5) + li a5,-16384 + addi a3,s0,-16 + add a3,a3,a5 + lw a5,-20(s0) + slli a5,a5,2 + add a5,a3,a5 + sw a4,-8(a5) + li a5,-16384 + addi a4,s0,-16 + add a4,a4,a5 + lw a5,-20(s0) + slli a5,a5,2 + add a5,a4,a5 + lw a4,-8(a5) + li a5,-20480 + addi a3,s0,-16 + add a3,a3,a5 + lw a5,-20(s0) + slli a5,a5,2 + add a5,a3,a5 + sw a4,-8(a5) + lw a5,-20(s0) + addiw a5,a5,1 + sw a5,-20(s0) +.L2: + lw a5,-20(s0) + sext.w a4,a5 + li a5,1023 + ble a4,a5,.L3 + nop + nop + li t1,20480 + add sp,sp,t1 + ld s0,24(sp) + addi sp,sp,32 + j done \ No newline at end of file From f7702436896f88b9cd921ac95e241a32ffb6499f Mon Sep 17 00:00:00 2001 From: Noah Limpert Date: Mon, 3 Apr 2023 21:54:27 -0700 Subject: [PATCH 3/9] Test File for Pull Request, Attempt to fill all four ways --- tests/coverage/lsu_test1.S | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/coverage/lsu_test1.S diff --git a/tests/coverage/lsu_test1.S b/tests/coverage/lsu_test1.S new file mode 100644 index 00000000..92d01b19 --- /dev/null +++ b/tests/coverage/lsu_test1.S @@ -0,0 +1,34 @@ +//lsu.S +// A set of tests meant to stress the LSU to increase coverage +// Manuel Alejandro Mendoza Manriquez mmendozamanriquez@g.hmc.edu +// Noah Limpert nlimpert@g.hmc.edu +// March 28 2023 + + +// Test 1 +// Cache ways 1,2,3 do not have SelFlush = 0 +// To make SelFlush = 0 we must evict lines from ways 1,2,3 +// Will load 4 words with same tags, filling 4 ways of cache +// edit and store these words so that dirty bit is set ( is this necessary?) +// Will then load 4 more words, evicting the previous 4 words +// will make SelFlush = 0 for all 4 ways. + +// Load code to initialize stack, handle interrupts, terminate +#include "WALLY-init-lib.h" + +main: + li t0, 4096 //offset such that set will be same + li t1, 0 #t1 = i = 0 + li t2, 8 # n = 8 + add t3, sp, 0 // what our offset for loads and stores will be + +for1: bge t1, t2, done + add t3, t3, t0 + lw t4, 0(t3) + addi t4, t4, 1 + sw t4, 0(t3) + addi t1, t1, 1 + j for1 + + + From 98420e45acf188654311d3f4fe9ad97217742ac8 Mon Sep 17 00:00:00 2001 From: Noah Limpert Date: Thu, 13 Apr 2023 15:13:55 -0700 Subject: [PATCH 4/9] update tests.vh, add tlbKP to load all lines of tlb --- tests/coverage/tlbKP.S | 143 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 tests/coverage/tlbKP.S diff --git a/tests/coverage/tlbKP.S b/tests/coverage/tlbKP.S new file mode 100644 index 00000000..5aaf5c19 --- /dev/null +++ b/tests/coverage/tlbKP.S @@ -0,0 +1,143 @@ +/////////////////////////////////////////// +// lsu_test.S +// +// Written: mmendozamanriquez@hmc.edu 4 April 2023 +// nlimpert@hmc.edu +// +// Purpose: Test coverage for LSU +// +// A component of the CORE-V-WALLY configurable RISC-V project. +// +// Copyright (C) 2021-23 Harvey Mudd College & Oklahoma State University +// +// SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 +// +// Licensed under the Solderpad Hardware License v 2.1 (the “License”); you may not use this file +// except in compliance with the License, or, at your option, the Apache License version 2.0. You +// may obtain a copy of the License at +// +// https://solderpad.org/licenses/SHL-2.1/ +// +// Unless required by applicable law or agreed to in writing, any work distributed under the +// License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +// either express or implied. See the License for the specific language governing permissions +// and limitations under the License. +//////////////////////////////////////////////////////////////////////////////////////////////// + +// load code to initalize stack, handle interrupts, terminate + +#include "WALLY-init-lib.h" + +# run-elf.bash find this in project description +main: + # Page table root address at 0x80010000 + li t5, 0x9000000000080010 + csrw satp, t5 + + # sfence.vma x0, x0 + + # switch to supervisor mode + li a0, 1 + ecall + + li t0, 0x80015000 + + li t2, 0 # i = 0 + li t3, 33 # Max amount of Loops = 32 + +loop: bge t2, t3, finished # exit loop if i >= loops + lw t1, 0(t0) + li t4, 0x1000 + add t0, t0, t4 + addi t2, t2, 1 + j loop + +finished: + j done + +.data + +.align 16 +# Page table situated at 0x80010000 +pagetable: + .8byte 0x200044C1 // old page table was 200040 which just pointed to itself! wrong + +.align 12 + .8byte 0x0000000000000000 + .8byte 0x00000000200048C1 + .8byte 0x00000000200048C1 + + +.align 12 + .8byte 0x0000000020004CC1 + //.8byte 0x00000200800CF// ADD IN THE MEGAPAGE should 3 nibbles of zeros be removed? + +.align 12 + #80000000 + .8byte 0x200000CF + .8byte 0x200004CF + .8byte 0x200008CF + .8byte 0x20000CCF + + .8byte 0x200010CF + .8byte 0x200014CF + .8byte 0x200018CF + .8byte 0x20001CCF + + .8byte 0x200020CF + .8byte 0x200024CF + .8byte 0x200028CF + .8byte 0x20002CCF + + .8byte 0x200030CF + .8byte 0x200034CF + .8byte 0x200038CF + .8byte 0x20003CCF + + .8byte 0x200040CF + .8byte 0x200044CF + .8byte 0x200048CF + .8byte 0x20004CCF + + .8byte 0x200050CF + .8byte 0x200054CF + .8byte 0x200058CF + .8byte 0x20005CCF + + .8byte 0x200060CF + .8byte 0x200064CF + .8byte 0x200068CF + .8byte 0x20006CCF + + .8byte 0x200070CF + .8byte 0x200074CF + .8byte 0x200078CF + .8byte 0x20007CCF + + .8byte 0x200080CF + .8byte 0x200084CF + .8byte 0x200088CF + .8byte 0x20008CCF + + .8byte 0x200090CF + .8byte 0x200094CF + .8byte 0x200098CF + .8byte 0x20009CCF + + .8byte 0x200100CF + .8byte 0x200104CF + .8byte 0x200108CF + .8byte 0x20010CCF + + .8byte 0x200110CF + .8byte 0x200114CF + .8byte 0x200118CF + .8byte 0x20011CCF + + .8byte 0x200120CF + .8byte 0x200124CF + .8byte 0x200128CF + .8byte 0x20012CCF + + .8byte 0x200130CF + .8byte 0x200134CF From 419377a8f8d7af5766d5b6b878363c133d69903c Mon Sep 17 00:00:00 2001 From: Noah Limpert Date: Thu, 13 Apr 2023 16:59:10 -0700 Subject: [PATCH 5/9] git did not seem to add tests.vh, trying again --- testbench/tests.vh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testbench/tests.vh b/testbench/tests.vh index 55cf464f..6a0f8027 100644 --- a/testbench/tests.vh +++ b/testbench/tests.vh @@ -52,7 +52,8 @@ string tvpaths[] = '{ "fpu", "lsu", "vm64check", - "pmp" + "pmp", + "tlbKP" }; string coremark[] = '{ From 4ab27b4f12f5efcb43a34f17bdde8dcc166dabff Mon Sep 17 00:00:00 2001 From: Noah Limpert Date: Thu, 13 Apr 2023 17:28:37 -0700 Subject: [PATCH 6/9] Revert "Test File for Pull Request, Attempt to fill all four ways" This reverts commit f7702436896f88b9cd921ac95e241a32ffb6499f. --- tests/coverage/lsu_test1.S | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 tests/coverage/lsu_test1.S diff --git a/tests/coverage/lsu_test1.S b/tests/coverage/lsu_test1.S deleted file mode 100644 index 92d01b19..00000000 --- a/tests/coverage/lsu_test1.S +++ /dev/null @@ -1,34 +0,0 @@ -//lsu.S -// A set of tests meant to stress the LSU to increase coverage -// Manuel Alejandro Mendoza Manriquez mmendozamanriquez@g.hmc.edu -// Noah Limpert nlimpert@g.hmc.edu -// March 28 2023 - - -// Test 1 -// Cache ways 1,2,3 do not have SelFlush = 0 -// To make SelFlush = 0 we must evict lines from ways 1,2,3 -// Will load 4 words with same tags, filling 4 ways of cache -// edit and store these words so that dirty bit is set ( is this necessary?) -// Will then load 4 more words, evicting the previous 4 words -// will make SelFlush = 0 for all 4 ways. - -// Load code to initialize stack, handle interrupts, terminate -#include "WALLY-init-lib.h" - -main: - li t0, 4096 //offset such that set will be same - li t1, 0 #t1 = i = 0 - li t2, 8 # n = 8 - add t3, sp, 0 // what our offset for loads and stores will be - -for1: bge t1, t2, done - add t3, t3, t0 - lw t4, 0(t3) - addi t4, t4, 1 - sw t4, 0(t3) - addi t1, t1, 1 - j for1 - - - From c76de00d606fb0ff45cef2a52109a790719ac020 Mon Sep 17 00:00:00 2001 From: Noah Limpert Date: Thu, 13 Apr 2023 17:40:39 -0700 Subject: [PATCH 7/9] Revert "instantiate 5 4KiB arrays, aim to thrash all 4 ways" This reverts commit 0fea40282ad829a7823ab286ab02a070ab574fa6. --- tests/coverage/lsuGB.S | 99 ------------------------------------------ 1 file changed, 99 deletions(-) delete mode 100644 tests/coverage/lsuGB.S diff --git a/tests/coverage/lsuGB.S b/tests/coverage/lsuGB.S deleted file mode 100644 index 8a902ba7..00000000 --- a/tests/coverage/lsuGB.S +++ /dev/null @@ -1,99 +0,0 @@ -//lsuGB.S -// A set of tests meant to stress the LSU to increase coverage -// Manuel Alejandro Mendoza Manriquez mmendozamanriquez@g.hmc.edu -// Noah Limpert nlimpert@g.hmc.edu -// March 28 2023 - - -// Test 2 -//Try to thrash ! used godbolt! -// Cache ways 1,2,3 do not have SelFlush = 0 -// To make SelFlush = 0 we must evict lines from ways 1,2,3 -// Will load 4 words with same tags, filling 4 ways of cache -// edit and store these words so that dirty bit is set ( is this necessary?) -// Will then load 4 more words, evicting the previous 4 words -// will make SelFlush = 0 for all 4 ways. - -// Load code to initialize stack, handle interrupts, terminate -#include "WALLY-init-lib.h" - -main: - addi sp,sp,-32 - sd s0,24(sp) - addi s0,sp,32 - li t1,-20480 - add sp,sp,t1 - sw zero,-20(s0) - j .L2 -.L3: - li a5,-4096 - addi a4,s0,-16 - add a4,a4,a5 - lw a5,-20(s0) - slli a5,a5,2 - add a5,a4,a5 - lw a4,-8(a5) - li a5,-8192 - addi a3,s0,-16 - add a3,a3,a5 - lw a5,-20(s0) - slli a5,a5,2 - add a5,a3,a5 - sw a4,-8(a5) - li a5,-8192 - addi a4,s0,-16 - add a4,a4,a5 - lw a5,-20(s0) - slli a5,a5,2 - add a5,a4,a5 - lw a4,-8(a5) - li a5,-12288 - addi a3,s0,-16 - add a3,a3,a5 - lw a5,-20(s0) - slli a5,a5,2 - add a5,a3,a5 - sw a4,-8(a5) - li a5,-12288 - addi a4,s0,-16 - add a4,a4,a5 - lw a5,-20(s0) - slli a5,a5,2 - add a5,a4,a5 - lw a4,-8(a5) - li a5,-16384 - addi a3,s0,-16 - add a3,a3,a5 - lw a5,-20(s0) - slli a5,a5,2 - add a5,a3,a5 - sw a4,-8(a5) - li a5,-16384 - addi a4,s0,-16 - add a4,a4,a5 - lw a5,-20(s0) - slli a5,a5,2 - add a5,a4,a5 - lw a4,-8(a5) - li a5,-20480 - addi a3,s0,-16 - add a3,a3,a5 - lw a5,-20(s0) - slli a5,a5,2 - add a5,a3,a5 - sw a4,-8(a5) - lw a5,-20(s0) - addiw a5,a5,1 - sw a5,-20(s0) -.L2: - lw a5,-20(s0) - sext.w a4,a5 - li a5,1023 - ble a4,a5,.L3 - nop - nop - li t1,20480 - add sp,sp,t1 - ld s0,24(sp) - addi sp,sp,32 - j done \ No newline at end of file From 187c5b07c79354ba579d9744a419158c05cbb854 Mon Sep 17 00:00:00 2001 From: Noah Limpert Date: Thu, 13 Apr 2023 17:44:09 -0700 Subject: [PATCH 8/9] make pull request more clean --- tests/coverage/lsu.S | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 tests/coverage/lsu.S diff --git a/tests/coverage/lsu.S b/tests/coverage/lsu.S deleted file mode 100644 index a5d8b1e5..00000000 --- a/tests/coverage/lsu.S +++ /dev/null @@ -1,35 +0,0 @@ -/////////////////////////////////////////// -// lsu.S -// -// Written: Kevin Box and Miles Cook kbox@hmc.edu mdcook@hmc.edu 26 March 2023 -// -// Purpose: Test coverage for lsu -// -// A component of the CORE-V-WALLY configurable RISC-V project. -// -// Copyright (C) 2021-23 Harvey Mudd College & Oklahoma State University -// -// SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 -// -// Licensed under the Solderpad Hardware License v 2.1 (the “License”); you may not use this file -// except in compliance with the License, or, at your option, the Apache License version 2.0. You -// may obtain a copy of the License at -// -// https://solderpad.org/licenses/SHL-2.1/ -// -// Unless required by applicable law or agreed to in writing, any work distributed under the -// License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, -// either express or implied. See the License for the specific language governing permissions -// and limitations under the License. -//////////////////////////////////////////////////////////////////////////////////////////////// - -// load code to initalize stack, handle interrupts, terminate -#include "WALLY-init-lib.h" - -main: - - sfence.vma x0, x0 // sfence.vma to assert TLBFlush - - j done - - From 30ed9c2b69264cc0cafe6d2b766aa803511fae00 Mon Sep 17 00:00:00 2001 From: Noah Limpert Date: Thu, 13 Apr 2023 17:50:18 -0700 Subject: [PATCH 9/9] add back K. Box and M. Cook Lsu test --- tests/coverage/lsu.S | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/coverage/lsu.S diff --git a/tests/coverage/lsu.S b/tests/coverage/lsu.S new file mode 100644 index 00000000..c50b79eb --- /dev/null +++ b/tests/coverage/lsu.S @@ -0,0 +1,33 @@ +/////////////////////////////////////////// +// lsu.S +// +// Written: Kevin Box and Miles Cook kbox@hmc.edu mdcook@hmc.edu 26 March 2023 +// +// Purpose: Test coverage for lsu +// +// A component of the CORE-V-WALLY configurable RISC-V project. +// +// Copyright (C) 2021-23 Harvey Mudd College & Oklahoma State University +// +// SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 +// +// Licensed under the Solderpad Hardware License v 2.1 (the “License”); you may not use this file +// except in compliance with the License, or, at your option, the Apache License version 2.0. You +// may obtain a copy of the License at +// +// https://solderpad.org/licenses/SHL-2.1/ +// +// Unless required by applicable law or agreed to in writing, any work distributed under the +// License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +// either express or implied. See the License for the specific language governing permissions +// and limitations under the License. +//////////////////////////////////////////////////////////////////////////////////////////////// + +// load code to initalize stack, handle interrupts, terminate +#include "WALLY-init-lib.h" + +main: + + sfence.vma x0, x0 // sfence.vma to assert TLBFlush + + j done \ No newline at end of file