forked from Github_Repos/cvw
filter traps list down to just interrupts
This commit is contained in:
parent
ea0471dcc7
commit
0a8ce0593a
68
linux/testvector-generation/filterTrapsToInterrupts.py
Executable file
68
linux/testvector-generation/filterTrapsToInterrupts.py
Executable file
@ -0,0 +1,68 @@
|
|||||||
|
#! /usr/bin/python3
|
||||||
|
import sys, os
|
||||||
|
from functools import reduce
|
||||||
|
|
||||||
|
################
|
||||||
|
# Helper Funcs #
|
||||||
|
################
|
||||||
|
|
||||||
|
def tokenize(string):
|
||||||
|
tokens = []
|
||||||
|
token = ''
|
||||||
|
whitespace = 0
|
||||||
|
prevWhitespace = 0
|
||||||
|
for char in string:
|
||||||
|
prevWhitespace = whitespace
|
||||||
|
whitespace = char in ' \t\n'
|
||||||
|
if (whitespace):
|
||||||
|
if ((not prevWhitespace) and (token != '')):
|
||||||
|
tokens.append(token)
|
||||||
|
token = ''
|
||||||
|
else:
|
||||||
|
token = token + char
|
||||||
|
return tokens
|
||||||
|
|
||||||
|
def strip0x(num):
|
||||||
|
return num[2:]
|
||||||
|
|
||||||
|
def stripZeroes(num):
|
||||||
|
num = num.strip('0')
|
||||||
|
if num=='':
|
||||||
|
return '0'
|
||||||
|
else:
|
||||||
|
return num
|
||||||
|
|
||||||
|
#############
|
||||||
|
# Main Code #
|
||||||
|
#############
|
||||||
|
print("Begin filtering traps down to just external interrupts.")
|
||||||
|
|
||||||
|
# Parse Args
|
||||||
|
if len(sys.argv) != 2:
|
||||||
|
sys.exit('Error filterTrapsToInterrupts.py expects 1 arg: <path_to_testvector_dir>')
|
||||||
|
tvDir = sys.argv[1]+'/'
|
||||||
|
trapsFilePath = tvDir+'traps.txt'
|
||||||
|
if not os.path.exists(trapsFilePath):
|
||||||
|
sys.exit('Error input file '+trapsFilePath+'not found')
|
||||||
|
|
||||||
|
with open(tvDir+'interrupts.txt', 'w') as interruptsFile:
|
||||||
|
with open(trapsFilePath, 'r') as trapsFile:
|
||||||
|
while True:
|
||||||
|
trap = trapsFile.readline()
|
||||||
|
if trap == '':
|
||||||
|
break
|
||||||
|
trapType = trap.split(' ')[-1]
|
||||||
|
if ('interrupt' in trap) and (('external' in trapType) or ('m_timer' in trapType)): # no s_timer because that is not controlled by CLINT
|
||||||
|
interruptsFile.write(trap) # overall line
|
||||||
|
interruptsFile.write(trapsFile.readline()) # attempted instr count
|
||||||
|
interruptsFile.write(trapsFile.readline()) # hart #
|
||||||
|
interruptsFile.write(trapsFile.readline()) # asynchronous
|
||||||
|
interruptsFile.write(trapsFile.readline()) # cause
|
||||||
|
interruptsFile.write(trapsFile.readline()) # epc
|
||||||
|
interruptsFile.write(trapsFile.readline()) # tval
|
||||||
|
interruptsFile.write(trapsFile.readline()) # description
|
||||||
|
else:
|
||||||
|
for i in range(7):
|
||||||
|
trapsFile.readline()
|
||||||
|
|
||||||
|
print("Finished filtering traps down to just external interrupts.")
|
@ -4,10 +4,12 @@ imageDir=$RISCV/buildroot/output/images
|
|||||||
tvDir=$RISCV/linux-testvectors
|
tvDir=$RISCV/linux-testvectors
|
||||||
recordFile="$tvDir/all.qemu"
|
recordFile="$tvDir/all.qemu"
|
||||||
traceFile="$tvDir/all.txt"
|
traceFile="$tvDir/all.txt"
|
||||||
|
trapsFile="$tvDir/traps.txt"
|
||||||
interruptsFile="$tvDir/interrupts.txt"
|
interruptsFile="$tvDir/interrupts.txt"
|
||||||
|
|
||||||
read -p "Warning: running this script will overwrite the contents of:
|
read -p "Warning: running this script will overwrite the contents of:
|
||||||
* $traceFile
|
* $traceFile
|
||||||
|
* $trapsFile
|
||||||
* $interruptsFile
|
* $interruptsFile
|
||||||
Would you like to proceed? (y/n) " -n 1 -r
|
Would you like to proceed? (y/n) " -n 1 -r
|
||||||
echo
|
echo
|
||||||
@ -28,6 +30,7 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
touch $traceFile
|
touch $traceFile
|
||||||
|
touch $trapsFile
|
||||||
touch $interruptsFile
|
touch $interruptsFile
|
||||||
|
|
||||||
# QEMU Simulation
|
# QEMU Simulation
|
||||||
@ -38,7 +41,9 @@ then
|
|||||||
-bios $imageDir/fw_jump.elf -kernel $imageDir/Image -append "root=/dev/vda ro" -initrd $imageDir/rootfs.cpio \
|
-bios $imageDir/fw_jump.elf -kernel $imageDir/Image -append "root=/dev/vda ro" -initrd $imageDir/rootfs.cpio \
|
||||||
-singlestep -rtc clock=vm -icount shift=0,align=off,sleep=on,rr=replay,rrfile=$recordFile \
|
-singlestep -rtc clock=vm -icount shift=0,align=off,sleep=on,rr=replay,rrfile=$recordFile \
|
||||||
-d nochain,cpu,in_asm,int \
|
-d nochain,cpu,in_asm,int \
|
||||||
2>&1 >./qemu-serial | ./parseQEMUtoGDB.py | ./parseGDBtoTrace.py $interruptsFile | ./remove_dup.awk > $traceFile)
|
2>&1 >./qemu-serial | ./parseQEMUtoGDB.py | ./parseGDBtoTrace.py $trapsFile | ./remove_dup.awk > $traceFile)
|
||||||
|
|
||||||
|
./filterTrapsToInterrupts.py $tvDir
|
||||||
|
|
||||||
echo "genTrace.sh completed!"
|
echo "genTrace.sh completed!"
|
||||||
echo "You may want to restrict write access to $tvDir now and give cad ownership of it."
|
echo "You may want to restrict write access to $tvDir now and give cad ownership of it."
|
||||||
|
Loading…
Reference in New Issue
Block a user