From 2203590f9fe70d09b97e314edce83da3c169529a Mon Sep 17 00:00:00 2001 From: bbracker Date: Mon, 15 Nov 2021 14:49:00 -0800 Subject: [PATCH] get current privilege level from GDB for checkpoints --- tests/linux-testgen/testvector-generation/parseState.py | 5 +++-- wally-pipelined/testbench/testbench-linux.sv | 6 ++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/linux-testgen/testvector-generation/parseState.py b/tests/linux-testgen/testvector-generation/parseState.py index 9a2173b0..bbbf535b 100755 --- a/tests/linux-testgen/testvector-generation/parseState.py +++ b/tests/linux-testgen/testvector-generation/parseState.py @@ -34,7 +34,8 @@ stateGDBpath = outDir+'intermediate-outputs/stateGDB.txt' if not os.path.exists(stateGDBpath): sys.exit('Error input file '+stateGDBpath+'not found') -singleCSRs = ['pc','mip','mie','mscratch','mcause','mepc','mtvec','medeleg','mideleg','sscratch','scause','sepc','stvec','sedeleg','sideleg','satp','mstatus'] +singleCSRs = ['pc','mip','mie','mscratch','mcause','mepc','mtvec','medeleg','mideleg','sscratch','scause','sepc','stvec','sedeleg','sideleg','satp','mstatus','priv'] +# priv (current privilege mode) isn't technically a CSR but we can log it with the same machinery thirtyTwoBitCSRs = ['mcounteren','scounteren'] listCSRs = ['hpmcounter','pmpaddr'] pmpcfg = ['pmpcfg'] @@ -75,7 +76,7 @@ with open(stateGDBpath, 'r') as stateGDB: outFile = open(outDir+outFileName, 'w') outFile.write(val+'\n') outFile.close() - if name in thirtyTwoBitCSRs: + elif name in thirtyTwoBitCSRs: outFileName = 'checkpoint-'+name.upper() outFile = open(outDir+outFileName, 'w') val = int(val,16) & 0xffffffff diff --git a/wally-pipelined/testbench/testbench-linux.sv b/wally-pipelined/testbench/testbench-linux.sv index 2ca31e58..eb820c13 100644 --- a/wally-pipelined/testbench/testbench-linux.sv +++ b/wally-pipelined/testbench/testbench-linux.sv @@ -197,7 +197,7 @@ module testbench(); `define STATUS_MIE `CSR_BASE.csrsr.STATUS_MIE `define STATUS_SIE `CSR_BASE.csrsr.STATUS_SIE `define STATUS_UIE `CSR_BASE.csrsr.STATUS_UIE - `define CURR_PRIV dut.hart.priv.privmodereg.q + `define PRIV dut.hart.priv.privmodereg.q `define INSTRET dut.hart.priv.csr.genblk1.counters.genblk1.genblk2.INSTRETreg.q // Common Macros `define checkCSR(CSR) \ @@ -289,11 +289,11 @@ module testbench(); `INIT_CHECKPOINT_VAL(MTVEC, [`XLEN-1:0]); `INIT_CHECKPOINT_VAL(STVEC, [`XLEN-1:0]); `INIT_CHECKPOINT_VAL(SATP, [`XLEN-1:0]); + `INIT_CHECKPOINT_VAL(PRIV, [1:0]); `MAKE_CHECKPOINT_INIT_SIGNAL(MSTATUS, [`XLEN-1:0],0,0); integer ramFile; integer readResult; - assign initPriv = (initPC[0][`XLEN-1]) ? 2'h1 : 2'h3; // *** a hacky way to detect initial privilege level initial begin force dut.hart.priv.SwIntM = 0; force dut.hart.priv.TimerIntM = 0; @@ -325,7 +325,6 @@ module testbench(); force {`STATUS_SPIE,`STATUS_UPIE,`STATUS_MIE} = initMSTATUS[0][5:3]; force {`STATUS_SIE,`STATUS_UIE} = initMSTATUS[0][1:0]; force `INSTRET = CHECKPOINT; - force `CURR_PRIV = initPriv; while (reset!==1) #1; while (reset!==0) #1; #1; @@ -335,7 +334,6 @@ module testbench(); release {`STATUS_SPIE,`STATUS_UPIE,`STATUS_MIE}; release {`STATUS_SIE,`STATUS_UIE}; release `INSTRET; - release `CURR_PRIV; end // Get the E-stage trace reader ahead of the M-stage trace reader matchCountE = $fgets(lineE,traceFileE);