forked from Github_Repos/cvw
modified testbench to not allow Wally to generate its own interrupts (because of fundamental interrupt imprecision limitations)
This commit is contained in:
parent
c463f177e9
commit
b3bc3cf6d0
@ -30,8 +30,7 @@
|
|||||||
|
|
||||||
module testbench();
|
module testbench();
|
||||||
|
|
||||||
parameter waveOnICount = `BUSYBEAR*140000 + `BUILDROOT*3080000; // # of instructions at which to turn on waves in graphical sim
|
parameter waveOnICount = `BUSYBEAR*140000 + `BUILDROOT*6779000; // # of instructions at which to turn on waves in graphical sim
|
||||||
parameter stopICount = `BUSYBEAR*143898 + `BUILDROOT*0000000; // # instructions at which to halt sim completely (set to 0 to let it run as far as it can)
|
|
||||||
|
|
||||||
string ProgramAddrMapFile, ProgramLabelMapFile;
|
string ProgramAddrMapFile, ProgramLabelMapFile;
|
||||||
|
|
||||||
@ -72,9 +71,9 @@ module testbench();
|
|||||||
// Signal Declarations
|
// Signal Declarations
|
||||||
// -------------------
|
// -------------------
|
||||||
// Testbench Core
|
// Testbench Core
|
||||||
integer instrs;
|
|
||||||
integer warningCount = 0;
|
integer warningCount = 0;
|
||||||
// PC, Instr Checking
|
integer errorCount = 0;
|
||||||
|
// P, Instr Checking
|
||||||
logic [`XLEN-1:0] PCW;
|
logic [`XLEN-1:0] PCW;
|
||||||
integer data_file_all;
|
integer data_file_all;
|
||||||
|
|
||||||
@ -85,64 +84,68 @@ module testbench();
|
|||||||
// Write Back trace signals
|
// Write Back trace signals
|
||||||
logic checkInstrW;
|
logic checkInstrW;
|
||||||
|
|
||||||
//integer RegAdr;
|
//integer RegAdr;
|
||||||
|
|
||||||
integer fault;
|
integer fault;
|
||||||
logic TrapW;
|
logic TrapW;
|
||||||
|
|
||||||
// Signals used to parse the trace file.
|
// Signals used to parse the trace file.
|
||||||
logic checkInstrM;
|
logic checkInstrM;
|
||||||
integer matchCount;
|
integer matchCount;
|
||||||
string line;
|
string line;
|
||||||
logic [`XLEN-1:0] ExpectedPCM;
|
logic [`XLEN-1:0] ExpectedPCM;
|
||||||
logic [31:0] ExpectedInstrM;
|
logic [31:0] ExpectedInstrM;
|
||||||
string textM;
|
string textM;
|
||||||
string token;
|
string token;
|
||||||
string ExpectedTokens [31:0];
|
string ExpectedTokens [31:0];
|
||||||
integer index;
|
integer index;
|
||||||
integer StartIndex, EndIndex;
|
integer StartIndex, EndIndex;
|
||||||
integer TokenIndex;
|
integer TokenIndex;
|
||||||
integer MarkerIndex;
|
integer MarkerIndex;
|
||||||
integer NumCSRM;
|
integer NumCSRM;
|
||||||
|
|
||||||
// Memory stage expected values from trace
|
// Memory stage expected values from trace
|
||||||
string RegWriteM;
|
string RegWriteM;
|
||||||
integer ExpectedRegAdrM;
|
integer ExpectedRegAdrM;
|
||||||
logic [`XLEN-1:0] ExpectedRegValueM;
|
logic [`XLEN-1:0] ExpectedRegValueM;
|
||||||
string MemOpM;
|
string MemOpM;
|
||||||
logic [`XLEN-1:0] ExpectedMemAdrM, ExpectedMemReadDataM, ExpectedMemWriteDataM;
|
logic [`XLEN-1:0] ExpectedMemAdrM, ExpectedMemReadDataM, ExpectedMemWriteDataM;
|
||||||
string ExpectedCSRArrayM[10:0];
|
string ExpectedCSRArrayM[10:0];
|
||||||
logic [`XLEN-1:0] ExpectedCSRArrayValueM[10:0];
|
logic [`XLEN-1:0] ExpectedCSRArrayValueM[10:0];
|
||||||
|
|
||||||
// Write back stage expected values from trace
|
// Write back stage expected values from trace
|
||||||
logic [`XLEN-1:0] ExpectedPCW;
|
logic [`XLEN-1:0] ExpectedPCW;
|
||||||
logic [31:0] ExpectedInstrW;
|
logic [31:0] ExpectedInstrW;
|
||||||
string textW;
|
string textW;
|
||||||
string RegWriteW;
|
string RegWriteW;
|
||||||
integer ExpectedRegAdrW;
|
integer ExpectedRegAdrW;
|
||||||
logic [`XLEN-1:0] ExpectedRegValueW;
|
logic [`XLEN-1:0] ExpectedRegValueW;
|
||||||
string MemOpW;
|
string MemOpW;
|
||||||
logic [`XLEN-1:0] ExpectedMemAdrW, ExpectedMemReadDataW, ExpectedMemWriteDataW;
|
logic [`XLEN-1:0] ExpectedMemAdrW, ExpectedMemReadDataW, ExpectedMemWriteDataW;
|
||||||
integer NumCSRW;
|
integer NumCSRW;
|
||||||
string ExpectedCSRArrayW[10:0];
|
string ExpectedCSRArrayW[10:0];
|
||||||
logic [`XLEN-1:0] ExpectedCSRArrayValueW[10:0];
|
logic [`XLEN-1:0] ExpectedCSRArrayValueW[10:0];
|
||||||
logic [`XLEN-1:0] ExpectedIntType;
|
logic [`XLEN-1:0] ExpectedIntType;
|
||||||
integer NumCSRMIndex;
|
integer NumCSRMIndex;
|
||||||
integer NumCSRWIndex;
|
integer NumCSRWIndex;
|
||||||
integer NumCSRPostWIndex;
|
integer NumCSRPostWIndex;
|
||||||
// logic CurrentInterruptForce;
|
// logic CurrentInterruptForce;
|
||||||
logic [`XLEN-1:0] InstrCountW;
|
logic [`XLEN-1:0] InstrCountW;
|
||||||
|
|
||||||
// -----------
|
// -----------
|
||||||
// Error Macro
|
// Error Macro
|
||||||
// -----------
|
// -----------
|
||||||
`define ERROR \
|
`define ERROR \
|
||||||
$display("processed %0d instructions with %0d warnings", instrs, warningCount); \
|
errorCount +=1; \
|
||||||
|
$display("processed %0d instructions with %0d warnings", InstrCountW, warningCount); \
|
||||||
$stop;
|
$stop;
|
||||||
|
|
||||||
initial begin
|
initial begin
|
||||||
data_file_all = $fopen({`LINUX_TEST_VECTORS,"all.txt"}, "r");
|
data_file_all = $fopen({`LINUX_TEST_VECTORS,"all.txt"}, "r");
|
||||||
InstrCountW = '0;
|
InstrCountW = '0;
|
||||||
|
force dut.hart.priv.SwIntM = 0;
|
||||||
|
force dut.hart.priv.TimerIntM = 0;
|
||||||
|
force dut.hart.priv.ExtIntM = 0;
|
||||||
end
|
end
|
||||||
|
|
||||||
/* -----\/----- EXCLUDED -----\/-----
|
/* -----\/----- EXCLUDED -----\/-----
|
||||||
@ -160,7 +163,7 @@ module testbench();
|
|||||||
flopenrc #(`XLEN) PCWReg(clk, reset, dut.hart.FlushW, ~dut.hart.ieu.dp.StallW, dut.hart.ifu.PCM, PCW);
|
flopenrc #(`XLEN) PCWReg(clk, reset, dut.hart.FlushW, ~dut.hart.ieu.dp.StallW, dut.hart.ifu.PCM, PCW);
|
||||||
flopenr #(1) TrapWReg(clk, reset, ~dut.hart.StallW, dut.hart.hzu.TrapM, TrapW);
|
flopenr #(1) TrapWReg(clk, reset, ~dut.hart.StallW, dut.hart.hzu.TrapM, TrapW);
|
||||||
|
|
||||||
// because qemu does not match exactly to wally it is necessary to read the the
|
// Because qemu does not match exactly to wally it is necessary to read the the
|
||||||
// trace in the memory stage and detect if anything in wally must be overwritten.
|
// trace in the memory stage and detect if anything in wally must be overwritten.
|
||||||
// This includes mtimer, interrupts, and various bits in mstatus and xtval.
|
// This includes mtimer, interrupts, and various bits in mstatus and xtval.
|
||||||
|
|
||||||
@ -186,14 +189,14 @@ module testbench();
|
|||||||
TokenIndex = 0;
|
TokenIndex = 0;
|
||||||
//$display("len = %d", line.len());
|
//$display("len = %d", line.len());
|
||||||
for(index = 0; index < line.len(); index++) begin
|
for(index = 0; index < line.len(); index++) begin
|
||||||
//$display("char = %s", line[index]);
|
//$display("char = %s", line[index]);
|
||||||
if (line[index] == " " || line[index] == "\n") begin
|
if (line[index] == " " || line[index] == "\n") begin
|
||||||
EndIndex = index;
|
EndIndex = index;
|
||||||
ExpectedTokens[TokenIndex] = line.substr(StartIndex, EndIndex-1);
|
ExpectedTokens[TokenIndex] = line.substr(StartIndex, EndIndex-1);
|
||||||
//$display("In Tokenizer %s", line.substr(StartIndex, EndIndex-1));
|
//$display("In Tokenizer %s", line.substr(StartIndex, EndIndex-1));
|
||||||
StartIndex = EndIndex + 1;
|
StartIndex = EndIndex + 1;
|
||||||
TokenIndex++;
|
TokenIndex++;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
MarkerIndex = 3;
|
MarkerIndex = 3;
|
||||||
@ -204,71 +207,71 @@ module testbench();
|
|||||||
#2;
|
#2;
|
||||||
|
|
||||||
while(TokenIndex > MarkerIndex) begin
|
while(TokenIndex > MarkerIndex) begin
|
||||||
// parse the GPR
|
// parse the GPR
|
||||||
if (ExpectedTokens[MarkerIndex] == "GPR") begin
|
if (ExpectedTokens[MarkerIndex] == "GPR") begin
|
||||||
RegWriteM = ExpectedTokens[MarkerIndex];
|
RegWriteM = ExpectedTokens[MarkerIndex];
|
||||||
matchCount = $sscanf(ExpectedTokens[MarkerIndex+1], "%d", ExpectedRegAdrM);
|
matchCount = $sscanf(ExpectedTokens[MarkerIndex+1], "%d", ExpectedRegAdrM);
|
||||||
matchCount = $sscanf(ExpectedTokens[MarkerIndex+2], "%x", ExpectedRegValueM);
|
matchCount = $sscanf(ExpectedTokens[MarkerIndex+2], "%x", ExpectedRegValueM);
|
||||||
|
|
||||||
MarkerIndex += 3;
|
MarkerIndex += 3;
|
||||||
|
|
||||||
// parse memory address, read data, and/or write data
|
// parse memory address, read data, and/or write data
|
||||||
end else if(ExpectedTokens[MarkerIndex].substr(0, 2) == "Mem") begin
|
end else if(ExpectedTokens[MarkerIndex].substr(0, 2) == "Mem") begin
|
||||||
MemOpM = ExpectedTokens[MarkerIndex];
|
MemOpM = ExpectedTokens[MarkerIndex];
|
||||||
matchCount = $sscanf(ExpectedTokens[MarkerIndex+1], "%x", ExpectedMemAdrM);
|
matchCount = $sscanf(ExpectedTokens[MarkerIndex+1], "%x", ExpectedMemAdrM);
|
||||||
matchCount = $sscanf(ExpectedTokens[MarkerIndex+2], "%x", ExpectedMemWriteDataM);
|
matchCount = $sscanf(ExpectedTokens[MarkerIndex+2], "%x", ExpectedMemWriteDataM);
|
||||||
matchCount = $sscanf(ExpectedTokens[MarkerIndex+3], "%x", ExpectedMemReadDataM);
|
matchCount = $sscanf(ExpectedTokens[MarkerIndex+3], "%x", ExpectedMemReadDataM);
|
||||||
|
|
||||||
MarkerIndex += 4;
|
MarkerIndex += 4;
|
||||||
|
|
||||||
// parse CSRs, because there are 1 or more CSRs after the CSR token
|
// parse CSRs, because there are 1 or more CSRs after the CSR token
|
||||||
// we check if the CSR token or the number of CSRs is greater than 0.
|
// we check if the CSR token or the number of CSRs is greater than 0.
|
||||||
// if so then we want to parse for a CSR.
|
// if so then we want to parse for a CSR.
|
||||||
end else if(ExpectedTokens[MarkerIndex] == "CSR" || NumCSRM > 0) begin
|
end else if(ExpectedTokens[MarkerIndex] == "CSR" || NumCSRM > 0) begin
|
||||||
if(ExpectedTokens[MarkerIndex] == "CSR") begin
|
if(ExpectedTokens[MarkerIndex] == "CSR") begin
|
||||||
// all additional CSR's won't have this token.
|
// all additional CSR's won't have this token.
|
||||||
MarkerIndex++;
|
MarkerIndex++;
|
||||||
end
|
end
|
||||||
matchCount = $sscanf(ExpectedTokens[MarkerIndex], "%s", ExpectedCSRArrayM[NumCSRM]);
|
matchCount = $sscanf(ExpectedTokens[MarkerIndex], "%s", ExpectedCSRArrayM[NumCSRM]);
|
||||||
matchCount = $sscanf(ExpectedTokens[MarkerIndex+1], "%x", ExpectedCSRArrayValueM[NumCSRM]);
|
matchCount = $sscanf(ExpectedTokens[MarkerIndex+1], "%x", ExpectedCSRArrayValueM[NumCSRM]);
|
||||||
|
|
||||||
MarkerIndex += 2;
|
MarkerIndex += 2;
|
||||||
|
|
||||||
// if we get an xcause with the interrupt bit set we must generate an interrupt as interrupts
|
// if we get an xcause with the interrupt bit set we must generate an interrupt as interrupts
|
||||||
// are imprecise. Forcing the trap at this time will allow wally to track what qemu does.
|
// are imprecise. Forcing the trap at this time will allow wally to track what qemu does.
|
||||||
// the msb of xcause will be set.
|
// the msb of xcause will be set.
|
||||||
// bits 1:0 select mode; 0 = user, 1 = superviser, 3 = machine
|
// bits 1:0 select mode; 0 = user, 1 = superviser, 3 = machine
|
||||||
// bits 3:2 select the type of interrupt, 0 = software, 1 = timer, 2 = external
|
// bits 3:2 select the type of interrupt, 0 = software, 1 = timer, 2 = external
|
||||||
if(ExpectedCSRArrayM[NumCSRM].substr(1, 5) == "cause" && (ExpectedCSRArrayValueM[NumCSRM][`XLEN-1] == 1'b1)) begin
|
if(ExpectedCSRArrayM[NumCSRM].substr(1, 5) == "cause" && (ExpectedCSRArrayValueM[NumCSRM][`XLEN-1] == 1'b1)) begin
|
||||||
//what type?
|
//what type?
|
||||||
ExpectedIntType = ExpectedCSRArrayValueM[NumCSRM] & 64'h0000_000C;
|
ExpectedIntType = ExpectedCSRArrayValueM[NumCSRM] & 64'h0000_000C;
|
||||||
$display("%t: CSR = %s. Forcing interrupt of cause = %x", $time, ExpectedCSRArrayM[NumCSRM], ExpectedCSRArrayValueM[NumCSRM]);
|
$display("%tns, %d instrs: CSR = %s. Forcing interrupt of cause = %x", $time, InstrCountW, ExpectedCSRArrayM[NumCSRM], ExpectedCSRArrayValueM[NumCSRM]);
|
||||||
|
|
||||||
if(ExpectedIntType == 0) begin
|
if(ExpectedIntType == 0) begin
|
||||||
force dut.hart.priv.SwIntM = 1'b1;
|
force dut.hart.priv.SwIntM = 1'b1;
|
||||||
$display("Force SwIntM");
|
$display("Force SwIntM");
|
||||||
end
|
end
|
||||||
else if(ExpectedIntType == 4) begin
|
else if(ExpectedIntType == 4) begin
|
||||||
force dut.hart.priv.TimerIntM = 1'b1;
|
force dut.hart.priv.TimerIntM = 1'b1;
|
||||||
$display("Force TimeIntM");
|
$display("Force TimeIntM");
|
||||||
end
|
end
|
||||||
else if(ExpectedIntType == 8) begin
|
else if(ExpectedIntType == 8) begin
|
||||||
force dut.hart.priv.ExtIntM = 1'b1;
|
force dut.hart.priv.ExtIntM = 1'b1;
|
||||||
$display("Force ExtIntM");
|
$display("Force ExtIntM");
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
NumCSRM++;
|
NumCSRM++;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
// override on special conditions
|
// override on special conditions
|
||||||
if (ExpectedMemAdrM == 'h10000005) begin
|
if (ExpectedMemAdrM == 'h10000005) begin
|
||||||
//$display("%t: Overwriting read data from CLINT.", $time);
|
//$display("%tns, %d instrs: Overwriting read data from CLINT.", $time, InstrCountW);
|
||||||
force dut.hart.ieu.dp.ReadDataM = ExpectedMemReadDataM;
|
force dut.hart.ieu.dp.ReadDataM = ExpectedMemReadDataM;
|
||||||
end
|
end
|
||||||
if(textM.substr(0,5) == "rdtime") begin
|
if(textM.substr(0,5) == "rdtime") begin
|
||||||
$display("%t: Overwrite read value of CSR on read of MTIME in memory stage.", $time);
|
$display("%tns, %d instrs: Overwrite read value of CSR on read of MTIME in memory stage.", $time, InstrCountW);
|
||||||
force dut.hart.priv.csr.CSRReadValM = ExpectedRegValueM;
|
force dut.hart.priv.csr.CSRReadValM = ExpectedRegValueM;
|
||||||
//dut.hart.ieu.dp.regf.wd3
|
//dut.hart.ieu.dp.regf.wd3
|
||||||
end
|
end
|
||||||
|
|
||||||
end // if (checkInstrM)
|
end // if (checkInstrM)
|
||||||
@ -291,61 +294,71 @@ module testbench();
|
|||||||
end
|
end
|
||||||
else if(~dut.hart.StallW) begin
|
else if(~dut.hart.StallW) begin
|
||||||
if(dut.hart.FlushW) begin
|
if(dut.hart.FlushW) begin
|
||||||
ExpectedPCW <= '0;
|
ExpectedPCW <= '0;
|
||||||
ExpectedInstrW <= '0;
|
ExpectedInstrW <= '0;
|
||||||
textW <= "";
|
textW <= "";
|
||||||
RegWriteW <= "";
|
RegWriteW <= "";
|
||||||
ExpectedRegAdrW <= '0;
|
ExpectedRegAdrW <= '0;
|
||||||
ExpectedRegValueW <= '0;
|
ExpectedRegValueW <= '0;
|
||||||
ExpectedMemAdrW <= '0;
|
ExpectedMemAdrW <= '0;
|
||||||
MemOpW <= "";
|
MemOpW <= "";
|
||||||
ExpectedMemWriteDataW <= '0;
|
ExpectedMemWriteDataW <= '0;
|
||||||
ExpectedMemReadDataW <= '0;
|
ExpectedMemReadDataW <= '0;
|
||||||
NumCSRW <= '0;
|
NumCSRW <= '0;
|
||||||
end else begin
|
end else begin
|
||||||
ExpectedPCW <= ExpectedPCM;
|
ExpectedPCW <= ExpectedPCM;
|
||||||
ExpectedInstrW <= ExpectedInstrM;
|
ExpectedInstrW <= ExpectedInstrM;
|
||||||
textW <= textM;
|
textW <= textM;
|
||||||
RegWriteW <= RegWriteM;
|
RegWriteW <= RegWriteM;
|
||||||
ExpectedRegAdrW <= ExpectedRegAdrM;
|
ExpectedRegAdrW <= ExpectedRegAdrM;
|
||||||
ExpectedRegValueW <= ExpectedRegValueM;
|
ExpectedRegValueW <= ExpectedRegValueM;
|
||||||
ExpectedMemAdrW <= ExpectedMemAdrM;
|
ExpectedMemAdrW <= ExpectedMemAdrM;
|
||||||
MemOpW <= MemOpM;
|
MemOpW <= MemOpM;
|
||||||
ExpectedMemWriteDataW <= ExpectedMemWriteDataM;
|
ExpectedMemWriteDataW <= ExpectedMemWriteDataM;
|
||||||
ExpectedMemReadDataW <= ExpectedMemReadDataM;
|
ExpectedMemReadDataW <= ExpectedMemReadDataM;
|
||||||
NumCSRW <= NumCSRM;
|
NumCSRW <= NumCSRM;
|
||||||
for(NumCSRWIndex = 0; NumCSRWIndex < NumCSRM; NumCSRWIndex++) begin
|
for(NumCSRWIndex = 0; NumCSRWIndex < NumCSRM; NumCSRWIndex++) begin
|
||||||
ExpectedCSRArrayW[NumCSRWIndex] = ExpectedCSRArrayM[NumCSRWIndex];
|
ExpectedCSRArrayW[NumCSRWIndex] = ExpectedCSRArrayM[NumCSRWIndex];
|
||||||
ExpectedCSRArrayValueW[NumCSRWIndex] = ExpectedCSRArrayValueM[NumCSRWIndex];
|
ExpectedCSRArrayValueW[NumCSRWIndex] = ExpectedCSRArrayValueM[NumCSRWIndex];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
// override on special conditions
|
// override on special conditions
|
||||||
#1;
|
#1;
|
||||||
|
|
||||||
|
|
||||||
if(~dut.hart.StallW) begin
|
if(~dut.hart.StallW) begin
|
||||||
if(textM.substr(0,5) == "rdtime") begin
|
if(textM.substr(0,5) == "rdtime") begin
|
||||||
$display("%t:Releasing force of CSRReadValM.", $time);
|
$display("%tns, %d instrs: Releasing force of CSRReadValM.", $time, InstrCountW);
|
||||||
release dut.hart.priv.csr.CSRReadValM;
|
release dut.hart.priv.csr.CSRReadValM;
|
||||||
//release dut.hart.ieu.dp.regf.wd3;
|
//release dut.hart.ieu.dp.regf.wd3;
|
||||||
end
|
end
|
||||||
|
|
||||||
if (ExpectedMemAdrM == 'h10000005) begin
|
if (ExpectedMemAdrM == 'h10000005) begin
|
||||||
//$display("%t: releasing force of ReadDataM.", $time);
|
//$display("%tns, %d instrs: releasing force of ReadDataM.", $time, InstrCountW);
|
||||||
release dut.hart.ieu.dp.ReadDataM;
|
release dut.hart.ieu.dp.ReadDataM;
|
||||||
end
|
end
|
||||||
|
|
||||||
// remove forces on interrupts
|
// force interrupts to 0
|
||||||
for(NumCSRMIndex = 0; NumCSRMIndex < NumCSRM; NumCSRMIndex++) begin
|
for(NumCSRMIndex = 0; NumCSRMIndex < NumCSRM; NumCSRMIndex++) begin
|
||||||
if(ExpectedCSRArrayM[NumCSRMIndex].substr(1, 5) == "cause" && (ExpectedCSRArrayValueM[NumCSRMIndex][`XLEN-1] == 1'b1)) begin
|
if(ExpectedCSRArrayM[NumCSRMIndex].substr(1, 5) == "cause" && (ExpectedCSRArrayValueM[NumCSRMIndex][`XLEN-1] == 1'b1)) begin
|
||||||
//what type?
|
//what type?
|
||||||
$display("%t: Releasing all forces on interrupts", $time);
|
ExpectedIntType = ExpectedCSRArrayValueM[NumCSRM] & 64'h0000_000C;
|
||||||
|
$display("%tns, %d instrs: CSR = %s. Forcing interrupt of cause = %x back to 0", $time, InstrCountW, ExpectedCSRArrayM[NumCSRM], ExpectedCSRArrayValueM[NumCSRM]);
|
||||||
release dut.hart.priv.SwIntM;
|
|
||||||
release dut.hart.priv.TimerIntM;
|
if(ExpectedIntType == 0) begin
|
||||||
release dut.hart.priv.ExtIntM;
|
force dut.hart.priv.SwIntM = 1'b0;
|
||||||
end
|
$display("Force SwIntM");
|
||||||
end
|
end
|
||||||
|
else if(ExpectedIntType == 4) begin
|
||||||
|
force dut.hart.priv.TimerIntM = 1'b0;
|
||||||
|
$display("Force TimeIntM");
|
||||||
|
end
|
||||||
|
else if(ExpectedIntType == 8) begin
|
||||||
|
force dut.hart.priv.ExtIntM = 1'b0;
|
||||||
|
$display("Force ExtIntM");
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -355,229 +368,214 @@ module testbench();
|
|||||||
// always check PC, instruction bits
|
// always check PC, instruction bits
|
||||||
if (checkInstrW) begin
|
if (checkInstrW) begin
|
||||||
InstrCountW += 1;
|
InstrCountW += 1;
|
||||||
|
// turn on waves at certain point
|
||||||
|
if (InstrCountW == waveOnICount) $stop;
|
||||||
// check PCW
|
// check PCW
|
||||||
fault = 0;
|
fault = 0;
|
||||||
if(PCW != ExpectedPCW) begin
|
if(PCW != ExpectedPCW) begin
|
||||||
$display("PCW: %016x does not equal ExpectedPCW: %016x", PCW, ExpectedPCW);
|
$display("PCW: %016x does not equal ExpectedPCW: %016x", PCW, ExpectedPCW);
|
||||||
fault = 1;
|
fault = 1;
|
||||||
end
|
end
|
||||||
|
|
||||||
// check instruction value
|
// check instruction value
|
||||||
if(dut.hart.ifu.InstrW != ExpectedInstrW) begin
|
if(dut.hart.ifu.InstrW != ExpectedInstrW) begin
|
||||||
$display("InstrW: %x does not equal ExpectedInstrW: %x", dut.hart.ifu.InstrW, ExpectedInstrW);
|
$display("InstrW: %x does not equal ExpectedInstrW: %x", dut.hart.ifu.InstrW, ExpectedInstrW);
|
||||||
fault = 1;
|
fault = 1;
|
||||||
end
|
end
|
||||||
|
|
||||||
// check the number of instructions
|
// check the number of instructions
|
||||||
if(dut.hart.priv.csr.genblk1.counters.genblk1.INSTRET_REGW != InstrCountW) begin
|
if(dut.hart.priv.csr.genblk1.counters.genblk1.INSTRET_REGW != InstrCountW) begin
|
||||||
$display("%t, Number of instruction Retired = %d does not equal number of instructions in trace = %d", $time, dut.hart.priv.csr.genblk1.counters.genblk1.INSTRET_REGW, InstrCountW);
|
$display("%t, Number of instruction Retired = %d does not equal number of instructions in trace = %d", $time, dut.hart.priv.csr.genblk1.counters.genblk1.INSTRET_REGW, InstrCountW);
|
||||||
if(!`DontHaltOnCSRMisMatch) fault = 1;
|
if(!`DontHaltOnCSRMisMatch) fault = 1;
|
||||||
end
|
end
|
||||||
|
|
||||||
#2; // delay 2 ns.
|
#2; // delay 2 ns.
|
||||||
|
|
||||||
|
|
||||||
if(`DEBUG_TRACE > 2) begin
|
if(`DEBUG_TRACE > 2) begin
|
||||||
$display("Reg Write Address: %02d ? expected value: %02d", dut.hart.ieu.dp.regf.a3, ExpectedRegAdrW);
|
$display("Reg Write Address: %02d ? expected value: %02d", dut.hart.ieu.dp.regf.a3, ExpectedRegAdrW);
|
||||||
$display("RF[%02d]: %016x ? expected value: %016x", ExpectedRegAdrW, dut.hart.ieu.dp.regf.rf[ExpectedRegAdrW], ExpectedRegValueW);
|
$display("RF[%02d]: %016x ? expected value: %016x", ExpectedRegAdrW, dut.hart.ieu.dp.regf.rf[ExpectedRegAdrW], ExpectedRegValueW);
|
||||||
end
|
end
|
||||||
|
|
||||||
if (RegWriteW == "GPR") begin
|
if (RegWriteW == "GPR") begin
|
||||||
if (dut.hart.ieu.dp.regf.a3 != ExpectedRegAdrW) begin
|
if (dut.hart.ieu.dp.regf.a3 != ExpectedRegAdrW) begin
|
||||||
$display("Reg Write Address: %02d does not equal expected value: %02d", dut.hart.ieu.dp.regf.a3, ExpectedRegAdrW);
|
$display("Reg Write Address: %02d does not equal expected value: %02d", dut.hart.ieu.dp.regf.a3, ExpectedRegAdrW);
|
||||||
fault = 1;
|
fault = 1;
|
||||||
end
|
end
|
||||||
|
|
||||||
if (dut.hart.ieu.dp.regf.rf[ExpectedRegAdrW] != ExpectedRegValueW) begin
|
if (dut.hart.ieu.dp.regf.rf[ExpectedRegAdrW] != ExpectedRegValueW) begin
|
||||||
$display("RF[%02d]: %016x does not equal expected value: %016x", ExpectedRegAdrW, dut.hart.ieu.dp.regf.rf[ExpectedRegAdrW], ExpectedRegValueW);
|
$display("RF[%02d]: %016x does not equal expected value: %016x", ExpectedRegAdrW, dut.hart.ieu.dp.regf.rf[ExpectedRegAdrW], ExpectedRegValueW);
|
||||||
fault = 1;
|
fault = 1;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if (MemOpW.substr(0,2) == "Mem") begin
|
if (MemOpW.substr(0,2) == "Mem") begin
|
||||||
if(`DEBUG_TRACE > 3) $display("\tMemAdrW: %016x ? expected: %016x", MemAdrW, ExpectedMemAdrW);
|
if(`DEBUG_TRACE > 3) $display("\tMemAdrW: %016x ? expected: %016x", MemAdrW, ExpectedMemAdrW);
|
||||||
|
|
||||||
// always check address
|
// always check address
|
||||||
if (MemAdrW != ExpectedMemAdrW) begin
|
if (MemAdrW != ExpectedMemAdrW) begin
|
||||||
$display("MemAdrW: %016x does not equal expected value: %016x", MemAdrW, ExpectedMemAdrW);
|
$display("MemAdrW: %016x does not equal expected value: %016x", MemAdrW, ExpectedMemAdrW);
|
||||||
fault = 1;
|
fault = 1;
|
||||||
end
|
end
|
||||||
|
|
||||||
// check read data
|
// check read data
|
||||||
if(MemOpW == "MemR" || MemOpW == "MemRW") begin
|
if(MemOpW == "MemR" || MemOpW == "MemRW") begin
|
||||||
if(`DEBUG_TRACE > 3) $display("\tReadDataW: %016x ? expected: %016x", dut.hart.ieu.dp.ReadDataW, ExpectedMemReadDataW);
|
if(`DEBUG_TRACE > 3) $display("\tReadDataW: %016x ? expected: %016x", dut.hart.ieu.dp.ReadDataW, ExpectedMemReadDataW);
|
||||||
if (dut.hart.ieu.dp.ReadDataW != ExpectedMemReadDataW) begin
|
if (dut.hart.ieu.dp.ReadDataW != ExpectedMemReadDataW) begin
|
||||||
$display("ReadDataW: %016x does not equal expected value: %016x", dut.hart.ieu.dp.ReadDataW, ExpectedMemReadDataW);
|
$display("ReadDataW: %016x does not equal expected value: %016x", dut.hart.ieu.dp.ReadDataW, ExpectedMemReadDataW);
|
||||||
fault = 1;
|
fault = 1;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
// check write data
|
// check write data
|
||||||
else if(ExpectedTokens[MarkerIndex] == "MemW" || ExpectedTokens[MarkerIndex] == "MemRW") begin
|
else if(ExpectedTokens[MarkerIndex] == "MemW" || ExpectedTokens[MarkerIndex] == "MemRW") begin
|
||||||
if(`DEBUG_TRACE > 3) $display("\tWriteDataW: %016x ? expected: %016x", WriteDataW, ExpectedMemWriteDataW);
|
if(`DEBUG_TRACE > 3) $display("\tWriteDataW: %016x ? expected: %016x", WriteDataW, ExpectedMemWriteDataW);
|
||||||
if (WriteDataW != ExpectedMemWriteDataW) begin
|
if (WriteDataW != ExpectedMemWriteDataW) begin
|
||||||
$display("WriteDataW: %016x does not equal expected value: %016x", WriteDataW, ExpectedMemWriteDataW);
|
$display("WriteDataW: %016x does not equal expected value: %016x", WriteDataW, ExpectedMemWriteDataW);
|
||||||
fault = 1;
|
fault = 1;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
// check csr
|
// check csr
|
||||||
//$display("%t, about to check csr, NumCSRW = %d", $time, NumCSRW);
|
//$display("%t, about to check csr, NumCSRW = %d", $time, NumCSRW);
|
||||||
for(NumCSRPostWIndex = 0; NumCSRPostWIndex < NumCSRW; NumCSRPostWIndex++) begin
|
for(NumCSRPostWIndex = 0; NumCSRPostWIndex < NumCSRW; NumCSRPostWIndex++) begin
|
||||||
/* -----\/----- EXCLUDED -----\/-----
|
/* -----\/----- EXCLUDED -----\/-----
|
||||||
if(`DEBUG_TRACE > 0) begin
|
if(`DEBUG_TRACE > 0) begin
|
||||||
$display("%t, NumCSRPostWIndex = %d, Expected CSR: %s = %016x", $time, NumCSRPostWIndex, ExpectedCSRArrayW[NumCSRPostWIndex], ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
$display("%t, NumCSRPostWIndex = %d, Expected CSR: %s = %016x", $time, NumCSRPostWIndex, ExpectedCSRArrayW[NumCSRPostWIndex], ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
||||||
end
|
end
|
||||||
-----/\----- EXCLUDED -----/\----- */
|
-----/\----- EXCLUDED -----/\----- */
|
||||||
case(ExpectedCSRArrayW[NumCSRPostWIndex])
|
case(ExpectedCSRArrayW[NumCSRPostWIndex])
|
||||||
"mhartid": begin
|
"mhartid": begin
|
||||||
if(`DEBUG_TRACE > 0) begin
|
if(`DEBUG_TRACE > 0) begin
|
||||||
$display("CSR: %s = %016x, expected = %016x", ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MHARTID_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
$display("CSR: %s = %016x, expected = %016x", ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MHARTID_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
||||||
end
|
end
|
||||||
if (dut.hart.priv.csr.genblk1.csrm.MHARTID_REGW != ExpectedCSRArrayValueW[NumCSRPostWIndex]) begin
|
if (dut.hart.priv.csr.genblk1.csrm.MHARTID_REGW != ExpectedCSRArrayValueW[NumCSRPostWIndex]) begin
|
||||||
$display("%t, CSR: %s = %016x, does not equal expected value %016x", $time, ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MHARTID_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
$display("%t, CSR: %s = %016x, does not equal expected value %016x", $time, ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MHARTID_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
||||||
if(!`DontHaltOnCSRMisMatch) fault = 1;
|
if(!`DontHaltOnCSRMisMatch) fault = 1;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
"mstatus": begin
|
"mstatus": begin
|
||||||
if(`DEBUG_TRACE > 0) begin
|
if(`DEBUG_TRACE > 0) begin
|
||||||
$display("CSR: %s = %016x, expected = %016x", ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MSTATUS_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
$display("CSR: %s = %016x, expected = %016x", ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MSTATUS_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
||||||
end
|
end
|
||||||
if ((dut.hart.priv.csr.genblk1.csrm.MSTATUS_REGW) != (ExpectedCSRArrayValueW[NumCSRPostWIndex])) begin
|
if ((dut.hart.priv.csr.genblk1.csrm.MSTATUS_REGW) != (ExpectedCSRArrayValueW[NumCSRPostWIndex])) begin
|
||||||
$display("%t, CSR: %s = %016x, does not equal expected value %016x", $time, ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MSTATUS_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
$display("%t, CSR: %s = %016x, does not equal expected value %016x", $time, ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MSTATUS_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
||||||
if(!`DontHaltOnCSRMisMatch) fault = 1;
|
if(!`DontHaltOnCSRMisMatch) fault = 1;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
"mtvec": begin
|
"mtvec": begin
|
||||||
if(`DEBUG_TRACE > 0) begin
|
if(`DEBUG_TRACE > 0) begin
|
||||||
$display("CSR: %s = %016x, expected = %016x", ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MTVEC_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
$display("CSR: %s = %016x, expected = %016x", ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MTVEC_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
||||||
end
|
end
|
||||||
if (dut.hart.priv.csr.genblk1.csrm.MTVEC_REGW != ExpectedCSRArrayValueW[NumCSRPostWIndex]) begin
|
if (dut.hart.priv.csr.genblk1.csrm.MTVEC_REGW != ExpectedCSRArrayValueW[NumCSRPostWIndex]) begin
|
||||||
$display("%t, CSR: %s = %016x, does not equal expected value %016x", $time, ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MTVEC_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
$display("%t, CSR: %s = %016x, does not equal expected value %016x", $time, ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MTVEC_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
||||||
if(!`DontHaltOnCSRMisMatch) fault = 1;
|
if(!`DontHaltOnCSRMisMatch) fault = 1;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
"mip": begin
|
"mip": begin
|
||||||
if(`DEBUG_TRACE > 0) begin
|
if(`DEBUG_TRACE > 0) begin
|
||||||
$display("CSR: %s = %016x, expected = %016x", ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MIP_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
$display("CSR: %s = %016x, expected = %016x", ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MIP_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
||||||
end
|
end
|
||||||
if (dut.hart.priv.csr.genblk1.csrm.MIP_REGW != ExpectedCSRArrayValueW[NumCSRPostWIndex]) begin
|
if (dut.hart.priv.csr.genblk1.csrm.MIP_REGW != ExpectedCSRArrayValueW[NumCSRPostWIndex]) begin
|
||||||
$display("%t, CSR: %s = %016x, does not equal expected value %016x", $time, ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MIP_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
$display("%t, CSR: %s = %016x, does not equal expected value %016x", $time, ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MIP_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
||||||
if(!`DontHaltOnCSRMisMatch) fault = 1;
|
if(!`DontHaltOnCSRMisMatch) fault = 1;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
"mie": begin
|
"mie": begin
|
||||||
if(`DEBUG_TRACE > 0) begin
|
if(`DEBUG_TRACE > 0) begin
|
||||||
$display("CSR: %s = %016x, expected = %016x", ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MIE_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
$display("CSR: %s = %016x, expected = %016x", ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MIE_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
||||||
end
|
end
|
||||||
if (dut.hart.priv.csr.genblk1.csrm.MIE_REGW != ExpectedCSRArrayValueW[NumCSRPostWIndex]) begin
|
if (dut.hart.priv.csr.genblk1.csrm.MIE_REGW != ExpectedCSRArrayValueW[NumCSRPostWIndex]) begin
|
||||||
$display("%t, CSR: %s = %016x, does not equal expected value %016x", $time, ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MIE_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
$display("%t, CSR: %s = %016x, does not equal expected value %016x", $time, ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MIE_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
||||||
if(!`DontHaltOnCSRMisMatch) fault = 1;
|
if(!`DontHaltOnCSRMisMatch) fault = 1;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
"mideleg": begin
|
"mideleg": begin
|
||||||
if(`DEBUG_TRACE > 0) begin
|
if(`DEBUG_TRACE > 0) begin
|
||||||
$display("CSR: %s = %016x, expected = %016x", ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MIDELEG_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
$display("CSR: %s = %016x, expected = %016x", ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MIDELEG_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
||||||
end
|
end
|
||||||
if (dut.hart.priv.csr.genblk1.csrm.MIDELEG_REGW != ExpectedCSRArrayValueW[NumCSRPostWIndex]) begin
|
if (dut.hart.priv.csr.genblk1.csrm.MIDELEG_REGW != ExpectedCSRArrayValueW[NumCSRPostWIndex]) begin
|
||||||
$display("%t, CSR: %s = %016x, does not equal expected value %016x", $time, ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MIDELEG_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
$display("%t, CSR: %s = %016x, does not equal expected value %016x", $time, ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MIDELEG_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
||||||
if(!`DontHaltOnCSRMisMatch) fault = 1;
|
if(!`DontHaltOnCSRMisMatch) fault = 1;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
"medeleg": begin
|
"medeleg": begin
|
||||||
if(`DEBUG_TRACE > 0) begin
|
if(`DEBUG_TRACE > 0) begin
|
||||||
$display("CSR: %s = %016x, expected = %016x", ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MEDELEG_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
$display("CSR: %s = %016x, expected = %016x", ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MEDELEG_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
||||||
end
|
end
|
||||||
if (dut.hart.priv.csr.genblk1.csrm.MEDELEG_REGW != ExpectedCSRArrayValueW[NumCSRPostWIndex]) begin
|
if (dut.hart.priv.csr.genblk1.csrm.MEDELEG_REGW != ExpectedCSRArrayValueW[NumCSRPostWIndex]) begin
|
||||||
$display("%t, CSR: %s = %016x, does not equal expected value %016x", $time, ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MEDELEG_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
$display("%t, CSR: %s = %016x, does not equal expected value %016x", $time, ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MEDELEG_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
||||||
if(!`DontHaltOnCSRMisMatch) fault = 1;
|
if(!`DontHaltOnCSRMisMatch) fault = 1;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
"mepc": begin
|
"mepc": begin
|
||||||
if(`DEBUG_TRACE > 0) begin
|
if(`DEBUG_TRACE > 0) begin
|
||||||
$display("CSR: %s = %016x, expected = %016x", ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MEPC_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
$display("CSR: %s = %016x, expected = %016x", ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MEPC_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
||||||
end
|
end
|
||||||
if (dut.hart.priv.csr.genblk1.csrm.MEPC_REGW != ExpectedCSRArrayValueW[NumCSRPostWIndex]) begin
|
if (dut.hart.priv.csr.genblk1.csrm.MEPC_REGW != ExpectedCSRArrayValueW[NumCSRPostWIndex]) begin
|
||||||
$display("%t, CSR: %s = %016x, does not equal expected value %016x", $time, ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MEPC_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
$display("%t, CSR: %s = %016x, does not equal expected value %016x", $time, ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MEPC_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
||||||
if(!`DontHaltOnCSRMisMatch) fault = 1;
|
if(!`DontHaltOnCSRMisMatch) fault = 1;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
"mtval": begin
|
||||||
"mtval": begin
|
if(`DEBUG_TRACE > 0) begin
|
||||||
if(`DEBUG_TRACE > 0) begin
|
$display("CSR: %s = %016x, expected = %016x", ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MTVAL_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
||||||
$display("CSR: %s = %016x, expected = %016x", ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MTVAL_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
end
|
||||||
end
|
if (dut.hart.priv.csr.genblk1.csrm.MTVAL_REGW != ExpectedCSRArrayValueW[NumCSRPostWIndex]) begin
|
||||||
if (dut.hart.priv.csr.genblk1.csrm.MTVAL_REGW != ExpectedCSRArrayValueW[NumCSRPostWIndex]) begin
|
$display("%t, CSR: %s = %016x, does not equal expected value %016x", $time, ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MTVAL_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
||||||
$display("%t, CSR: %s = %016x, does not equal expected value %016x", $time, ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrm.MTVAL_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
if(!`DontHaltOnCSRMisMatch) fault = 1;
|
||||||
if(!`DontHaltOnCSRMisMatch) fault = 1;
|
end
|
||||||
end
|
end
|
||||||
end
|
"sepc": begin
|
||||||
|
if(`DEBUG_TRACE > 0) begin
|
||||||
"sepc": begin
|
$display("CSR: %s = %016x, expected = %016x", ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrs.SEPC_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
||||||
if(`DEBUG_TRACE > 0) begin
|
end
|
||||||
$display("CSR: %s = %016x, expected = %016x", ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrs.SEPC_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
if (dut.hart.priv.csr.genblk1.csrs.SEPC_REGW != ExpectedCSRArrayValueW[NumCSRPostWIndex]) begin
|
||||||
end
|
$display("%t, CSR: %s = %016x, does not equal expected value %016x", $time, ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrs.SEPC_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
||||||
if (dut.hart.priv.csr.genblk1.csrs.SEPC_REGW != ExpectedCSRArrayValueW[NumCSRPostWIndex]) begin
|
if(!`DontHaltOnCSRMisMatch) fault = 1;
|
||||||
$display("%t, CSR: %s = %016x, does not equal expected value %016x", $time, ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrs.SEPC_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
end
|
||||||
if(!`DontHaltOnCSRMisMatch) fault = 1;
|
end
|
||||||
end
|
"scause": begin
|
||||||
end
|
if(`DEBUG_TRACE > 0) begin
|
||||||
"scause": begin
|
$display("CSR: %s = %016x, expected = %016x", ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrs.genblk1.SCAUSE_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
||||||
if(`DEBUG_TRACE > 0) begin
|
end
|
||||||
$display("CSR: %s = %016x, expected = %016x", ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrs.genblk1.SCAUSE_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
if (dut.hart.priv.csr.genblk1.csrs.genblk1.SCAUSE_REGW != ExpectedCSRArrayValueW[NumCSRPostWIndex]) begin
|
||||||
end
|
$display("%t, CSR: %s = %016x, does not equal expected value %016x", $time, ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrs.genblk1.SCAUSE_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
||||||
if (dut.hart.priv.csr.genblk1.csrs.genblk1.SCAUSE_REGW != ExpectedCSRArrayValueW[NumCSRPostWIndex]) begin
|
if(!`DontHaltOnCSRMisMatch) fault = 1;
|
||||||
$display("%t, CSR: %s = %016x, does not equal expected value %016x", $time, ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrs.genblk1.SCAUSE_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
end
|
||||||
if(!`DontHaltOnCSRMisMatch) fault = 1;
|
end
|
||||||
end
|
"stvec": begin
|
||||||
end
|
if(`DEBUG_TRACE > 0) begin
|
||||||
"stvec": begin
|
$display("CSR: %s = %016x, expected = %016x", ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrs.STVEC_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
||||||
if(`DEBUG_TRACE > 0) begin
|
end
|
||||||
$display("CSR: %s = %016x, expected = %016x", ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrs.STVEC_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
if (dut.hart.priv.csr.genblk1.csrs.STVEC_REGW != ExpectedCSRArrayValueW[NumCSRPostWIndex]) begin
|
||||||
end
|
$display("%t, CSR: %s = %016x, does not equal expected value %016x", $time, ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrs.STVEC_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
||||||
if (dut.hart.priv.csr.genblk1.csrs.STVEC_REGW != ExpectedCSRArrayValueW[NumCSRPostWIndex]) begin
|
if(!`DontHaltOnCSRMisMatch) fault = 1;
|
||||||
$display("%t, CSR: %s = %016x, does not equal expected value %016x", $time, ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrs.STVEC_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
end
|
||||||
if(!`DontHaltOnCSRMisMatch) fault = 1;
|
end
|
||||||
end
|
"stval": begin
|
||||||
end
|
if(`DEBUG_TRACE > 0) begin
|
||||||
"stval": begin
|
$display("CSR: %s = %016x, expected = %016x", ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrs.genblk1.STVAL_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
||||||
if(`DEBUG_TRACE > 0) begin
|
end
|
||||||
$display("CSR: %s = %016x, expected = %016x", ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrs.genblk1.STVAL_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
if (dut.hart.priv.csr.genblk1.csrs.genblk1.STVAL_REGW != ExpectedCSRArrayValueW[NumCSRPostWIndex]) begin
|
||||||
end
|
$display("%t, CSR: %s = %016x, does not equal expected value %016x", $time, ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrs.genblk1.STVAL_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
||||||
if (dut.hart.priv.csr.genblk1.csrs.genblk1.STVAL_REGW != ExpectedCSRArrayValueW[NumCSRPostWIndex]) begin
|
if(!`DontHaltOnCSRMisMatch) fault = 1;
|
||||||
$display("%t, CSR: %s = %016x, does not equal expected value %016x", $time, ExpectedCSRArrayW[NumCSRPostWIndex], dut.hart.priv.csr.genblk1.csrs.genblk1.STVAL_REGW, ExpectedCSRArrayValueW[NumCSRPostWIndex]);
|
end
|
||||||
if(!`DontHaltOnCSRMisMatch) fault = 1;
|
end
|
||||||
end
|
endcase // case (ExpectedCSRArrayW[NumCSRPostWIndex])
|
||||||
end
|
|
||||||
endcase // case (ExpectedCSRArrayW[NumCSRPostWIndex])
|
|
||||||
|
|
||||||
/* -----\/----- EXCLUDED -----\/-----
|
|
||||||
if(CurrentInterruptForce) begin
|
|
||||||
CurrentInterruptForce = 1'b0;
|
|
||||||
// remove forces on interrupts
|
|
||||||
$display("%t: Releasing all forces on interrupts", $time);
|
|
||||||
|
|
||||||
release dut.hart.priv.SwIntM;
|
|
||||||
release dut.hart.priv.TimerIntM;
|
|
||||||
release dut.hart.priv.ExtIntM;
|
|
||||||
end
|
|
||||||
-----/\----- EXCLUDED -----/\----- */
|
|
||||||
|
|
||||||
end // for (NumCSRPostWIndex = 0; NumCSRPostWIndex < NumCSRW; NumCSRPostWIndex++)
|
end // for (NumCSRPostWIndex = 0; NumCSRPostWIndex < NumCSRW; NumCSRPostWIndex++)
|
||||||
if (fault == 1) begin
|
if (fault == 1) begin `ERROR end
|
||||||
`ERROR
|
|
||||||
end
|
|
||||||
end // if (checkInstrW)
|
end // if (checkInstrW)
|
||||||
end // always @ (negedge clk)
|
end // always @ (negedge clk)
|
||||||
|
|
||||||
|
|
||||||
// track the current function
|
// track the current function
|
||||||
FunctionName FunctionName(.reset(reset),
|
FunctionName FunctionName(.reset(reset),
|
||||||
.clk(clk),
|
.clk(clk),
|
||||||
.ProgramAddrMapFile(ProgramAddrMapFile),
|
.ProgramAddrMapFile(ProgramAddrMapFile),
|
||||||
.ProgramLabelMapFile(ProgramLabelMapFile));
|
.ProgramLabelMapFile(ProgramLabelMapFile));
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -589,7 +587,6 @@ module testbench();
|
|||||||
// --------------
|
// --------------
|
||||||
initial
|
initial
|
||||||
begin
|
begin
|
||||||
instrs = 0;
|
|
||||||
reset <= 1; # 22; reset <= 0;
|
reset <= 1; # 22; reset <= 0;
|
||||||
end
|
end
|
||||||
// initial loading of memories
|
// initial loading of memories
|
||||||
|
Loading…
Reference in New Issue
Block a user