added WFI and mstatus fp, tw bit tests

This commit is contained in:
Kip Macsai-Goren 2022-04-25 18:21:56 +00:00
parent e0a1a54678
commit 36e82e8613
7 changed files with 3288 additions and 1 deletions

View File

@ -37,6 +37,7 @@ rv64i_sc_tests = \
WALLY-misa-01 \
WALLY-AMO \
WALLY-LRSC \
WALLY-trap-sret-01 \
# WALLY-scratch-01 \
# WALLY-sscratch-s-01 \
@ -64,10 +65,12 @@ target_tests_nosim = \
WALLY-MIE-01 \
WALLY-PIE-stack-01 \
WALLY-PIE-stack-s-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-01 \
# Have all 0's in references!
#WALLY-MEPC \
#WALLY-SEPC \

View File

@ -0,0 +1,65 @@
///////////////////////////////////////////
//
// WALLY-wait-for-interrupt
//
// Author: Kip Macsai-Goren <kmacsaigoren@g.hmc.edu>
//
// Created 2022-04-24
//
// Copyright (C) 2021 Harvey Mudd College & Oklahoma State University
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
// is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
// BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
// OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
///////////////////////////////////////////
#include "WALLY-TEST-LIB-64.h"
INIT_TESTS
TRAP_HANDLER m, DEBUG=1 // turn on recording mtval and status bits on traps
li x28, 0x8
csrs mstatus, x28 // set mstatus.MIE bit to 1
WRITE_READ_CSR mie, 0xFFF // Enable interrupts from all sources
// Code copied from test library to cause m time interrupt, with time loop replaced with wfi.
li x28, 0x60 // Desired offset from the present time
mv a3, x28 // copy value in to know to stop waiting for interrupt after this many cycles
la x29, 0x02004000 // MTIMECMP register in CLINT
la x30, 0x0200BFF8 // MTIME register in CLINT
lw x7, 0(x30) // low word of MTIME
lw x31, 4(x30) // high word of MTIME
add x28, x7, x28 // add desired offset to the current time
bgtu x28, x7, nowrap // check new time exceeds current time (no wraparound)
addi x31, x31, 1 // if wrap, increment most significant word
sw x31,4(x29) // store into most significant word of MTIMECMP
nowrap:
sw x28, 0(x29) // store into least significant word of MTIMECMP
auipc ra, 0x0
addi ra, ra, 0xC // load address after wfi into ra so we return to the right place after handling the time interrupt
wfi // test wfi until trap goes off
li x28, 0x600d111 // magic number "good 111" to write to output after interrupt goes off.
// this tests whether wfi is a nop or not since we should get the output for the interrupt before this one
sd x28, 0(x6)
addi x6, x6, 8
addi x16, x16, 8
END_TESTS
TEST_STACK_AND_DATA

View File

@ -0,0 +1,103 @@
///////////////////////////////////////////
//
// WALLY-status-floating-point
//
// Author: Kip Macsai-Goren <kmacsaigoren@g.hmc.edu>
//
// Created 2022-04-24
//
// Copyright (C) 2021 Harvey Mudd College & Oklahoma State University
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
// is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
// BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
// OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
///////////////////////////////////////////
#include "WALLY-TEST-LIB-64.h"
INIT_TESTS
TRAP_HANDLER m
// Misa.F is already 1 in this config, aking floating point enabled
# li x29, 0x28
# csrs misa, x29 // disable floating point and double floating point
li x28, 0x8000000000006000 // mask bits for SD and FS bits of status csr
li x29, 0x2000
csrs mstatus, x29 // turn on FS for spike???
csrr x29, mstatus
and x29, x29, x28
sd x29, 0(x6) // read initial FS, SD bits, which should be 01 and 0 respectively
addi x6, x6, 8
addi x16, x16, 8
flw f1, 0(x6) // make FS dirty by loading random value in
csrr x29, mstatus
and x29, x29, x28
sd x29, 0(x6) // read dirty FS, SD bits, which should be 11 and 1 respectively
addi x6, x6, 8
addi x16, x16, 8
li x29, 0x4000
csrs mstatus, x29
li x29, 0x8000000000002000
csrc mstatus, x29 // set SD to 0 and FS to 10 by writing mstatus
csrr x29, mstatus
and x29, x29, x28
sd x29, 0(x6) // read written FS, SD bits to confirm previous write
addi x6, x6, 8
addi x16, x16, 8
flw f1, 0(x6) // make FS dirty by loading random value in
csrr x29, mstatus
and x29, x29, x28
sd x29, 0(x6) // read dirty FS, SD bits, which should be 11 and 1 respectively
addi x6, x6, 8
addi x16, x16, 8
// fp_supported_success:
// sw x0, 0(x6) // write a zero to signature to indicate successful test
// addi x6, x6, 8
// addi x16, x16, 8
// j fp_unsupported
// fp_supported_failure:
// li x29, 0x1
// sw x29, 0(x6)
// addi x6, x6, 8
// addi x16, x16, 8
// j fp_unsupported
li x29, 0x28
csrc misa, x29 // disable floating point and double floating point
csrr x29, mstatus
and x29, x29, x28
sd x29, 0(x6) // read disabled FS, SD bits, which should both be 0
addi x6, x6, 8
addi x16, x16, 8
csrs mstatus, x28 // attempt to write 11 and 1 to fs and sd in mstatus (this should not work)
csrr x29, mstatus
and x29, x29, x28
sd x29, 0(x6) // read disabled FS, SD bits, which should both be 0
addi x6, x6, 8
addi x16, x16, 8
END_TESTS
TEST_STACK_AND_DATA

View File

@ -0,0 +1,44 @@
///////////////////////////////////////////
//
// WALLY-status-timeout-wait
//
// Author: Kip Macsai-Goren <kmacsaigoren@g.hmc.edu>
//
// Created 2022-04-24
//
// Copyright (C) 2021 Harvey Mudd College & Oklahoma State University
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
// is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
// BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
// OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
///////////////////////////////////////////
#include "WALLY-TEST-LIB-64.h"
INIT_TESTS
TRAP_HANDLER m, DEBUG=1 // turn on recording mtval and status bits on traps
li x28, 0x200000
csrs mstatus, x28 // set mstatus.TW bit to 1
GOTO_S_MODE // go to S mode so the TW can be triggered
nop
nop
nop // let the ecall go through the pipeline before testing the wfi instruction
wfi // call wfi when there's no interrupt to wait for
// eventually should cause illegal instruction
END_TESTS
TEST_STACK_AND_DATA