mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
get current privilege level from GDB for checkpoints
This commit is contained in:
parent
3dd83b3113
commit
2203590f9f
@ -34,7 +34,8 @@ stateGDBpath = outDir+'intermediate-outputs/stateGDB.txt'
|
|||||||
if not os.path.exists(stateGDBpath):
|
if not os.path.exists(stateGDBpath):
|
||||||
sys.exit('Error input file '+stateGDBpath+'not found')
|
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']
|
thirtyTwoBitCSRs = ['mcounteren','scounteren']
|
||||||
listCSRs = ['hpmcounter','pmpaddr']
|
listCSRs = ['hpmcounter','pmpaddr']
|
||||||
pmpcfg = ['pmpcfg']
|
pmpcfg = ['pmpcfg']
|
||||||
@ -75,7 +76,7 @@ with open(stateGDBpath, 'r') as stateGDB:
|
|||||||
outFile = open(outDir+outFileName, 'w')
|
outFile = open(outDir+outFileName, 'w')
|
||||||
outFile.write(val+'\n')
|
outFile.write(val+'\n')
|
||||||
outFile.close()
|
outFile.close()
|
||||||
if name in thirtyTwoBitCSRs:
|
elif name in thirtyTwoBitCSRs:
|
||||||
outFileName = 'checkpoint-'+name.upper()
|
outFileName = 'checkpoint-'+name.upper()
|
||||||
outFile = open(outDir+outFileName, 'w')
|
outFile = open(outDir+outFileName, 'w')
|
||||||
val = int(val,16) & 0xffffffff
|
val = int(val,16) & 0xffffffff
|
||||||
|
@ -197,7 +197,7 @@ module testbench();
|
|||||||
`define STATUS_MIE `CSR_BASE.csrsr.STATUS_MIE
|
`define STATUS_MIE `CSR_BASE.csrsr.STATUS_MIE
|
||||||
`define STATUS_SIE `CSR_BASE.csrsr.STATUS_SIE
|
`define STATUS_SIE `CSR_BASE.csrsr.STATUS_SIE
|
||||||
`define STATUS_UIE `CSR_BASE.csrsr.STATUS_UIE
|
`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
|
`define INSTRET dut.hart.priv.csr.genblk1.counters.genblk1.genblk2.INSTRETreg.q
|
||||||
// Common Macros
|
// Common Macros
|
||||||
`define checkCSR(CSR) \
|
`define checkCSR(CSR) \
|
||||||
@ -289,11 +289,11 @@ module testbench();
|
|||||||
`INIT_CHECKPOINT_VAL(MTVEC, [`XLEN-1:0]);
|
`INIT_CHECKPOINT_VAL(MTVEC, [`XLEN-1:0]);
|
||||||
`INIT_CHECKPOINT_VAL(STVEC, [`XLEN-1:0]);
|
`INIT_CHECKPOINT_VAL(STVEC, [`XLEN-1:0]);
|
||||||
`INIT_CHECKPOINT_VAL(SATP, [`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);
|
`MAKE_CHECKPOINT_INIT_SIGNAL(MSTATUS, [`XLEN-1:0],0,0);
|
||||||
|
|
||||||
integer ramFile;
|
integer ramFile;
|
||||||
integer readResult;
|
integer readResult;
|
||||||
assign initPriv = (initPC[0][`XLEN-1]) ? 2'h1 : 2'h3; // *** a hacky way to detect initial privilege level
|
|
||||||
initial begin
|
initial begin
|
||||||
force dut.hart.priv.SwIntM = 0;
|
force dut.hart.priv.SwIntM = 0;
|
||||||
force dut.hart.priv.TimerIntM = 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_SPIE,`STATUS_UPIE,`STATUS_MIE} = initMSTATUS[0][5:3];
|
||||||
force {`STATUS_SIE,`STATUS_UIE} = initMSTATUS[0][1:0];
|
force {`STATUS_SIE,`STATUS_UIE} = initMSTATUS[0][1:0];
|
||||||
force `INSTRET = CHECKPOINT;
|
force `INSTRET = CHECKPOINT;
|
||||||
force `CURR_PRIV = initPriv;
|
|
||||||
while (reset!==1) #1;
|
while (reset!==1) #1;
|
||||||
while (reset!==0) #1;
|
while (reset!==0) #1;
|
||||||
#1;
|
#1;
|
||||||
@ -335,7 +334,6 @@ module testbench();
|
|||||||
release {`STATUS_SPIE,`STATUS_UPIE,`STATUS_MIE};
|
release {`STATUS_SPIE,`STATUS_UPIE,`STATUS_MIE};
|
||||||
release {`STATUS_SIE,`STATUS_UIE};
|
release {`STATUS_SIE,`STATUS_UIE};
|
||||||
release `INSTRET;
|
release `INSTRET;
|
||||||
release `CURR_PRIV;
|
|
||||||
end
|
end
|
||||||
// Get the E-stage trace reader ahead of the M-stage trace reader
|
// Get the E-stage trace reader ahead of the M-stage trace reader
|
||||||
matchCountE = $fgets(lineE,traceFileE);
|
matchCountE = $fgets(lineE,traceFileE);
|
||||||
|
Loading…
Reference in New Issue
Block a user