mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
make testbench successfully deactivate TimerIntM so as to create a nice pulse
This commit is contained in:
parent
28fed18421
commit
b3f00f2682
@ -126,6 +126,7 @@ module testbench();
|
|||||||
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;
|
||||||
|
logic forcedInterrupt;
|
||||||
integer NumCSRMIndex;
|
integer NumCSRMIndex;
|
||||||
integer NumCSRWIndex;
|
integer NumCSRWIndex;
|
||||||
integer NumCSRPostWIndex;
|
integer NumCSRPostWIndex;
|
||||||
@ -207,61 +208,59 @@ 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("%tns, %d instrs: CSR = %s. Forcing interrupt of cause = %x", $time, InstrCountW, ExpectedCSRArrayM[NumCSRM], ExpectedCSRArrayValueM[NumCSRM]);
|
$display("%tns, %d instrs: CSR = %s. Forcing interrupt of cause = %x", $time, InstrCountW, ExpectedCSRArrayM[NumCSRM], ExpectedCSRArrayValueM[NumCSRM]);
|
||||||
|
forcedInterrupt = 1;
|
||||||
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 else if(ExpectedIntType == 4) begin
|
||||||
|
force dut.hart.priv.TimerIntM = 1'b1;
|
||||||
|
$display("Force TimeIntM");
|
||||||
|
end else if(ExpectedIntType == 8) begin
|
||||||
|
force dut.hart.priv.ExtIntM = 1'b1;
|
||||||
|
$display("Force ExtIntM");
|
||||||
|
end else forcedInterrupt = 0;
|
||||||
|
end
|
||||||
|
NumCSRM++;
|
||||||
end
|
end
|
||||||
else if(ExpectedIntType == 4) begin
|
|
||||||
force dut.hart.priv.TimerIntM = 1'b1;
|
|
||||||
$display("Force TimeIntM");
|
|
||||||
end
|
|
||||||
else if(ExpectedIntType == 8) begin
|
|
||||||
force dut.hart.priv.ExtIntM = 1'b1;
|
|
||||||
$display("Force ExtIntM");
|
|
||||||
end
|
|
||||||
end
|
|
||||||
NumCSRM++;
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
// override on special conditions
|
// override on special conditions
|
||||||
if (ExpectedMemAdrM == 'h10000005) begin
|
if (ExpectedMemAdrM == 'h10000005) begin
|
||||||
@ -338,24 +337,19 @@ module testbench();
|
|||||||
end
|
end
|
||||||
|
|
||||||
// force interrupts to 0
|
// force interrupts to 0
|
||||||
for(NumCSRMIndex = 0; NumCSRMIndex < NumCSRM; NumCSRMIndex++) begin
|
if (forcedInterrupt) begin
|
||||||
if(ExpectedCSRArrayM[NumCSRMIndex].substr(1, 5) == "cause" && (ExpectedCSRArrayValueM[NumCSRMIndex][`XLEN-1] == 1'b1)) begin
|
forcedInterrupt = 0;
|
||||||
//what type?
|
if(ExpectedIntType == 0) begin
|
||||||
ExpectedIntType = ExpectedCSRArrayValueM[NumCSRM] & 64'h0000_000C;
|
force dut.hart.priv.SwIntM = 1'b0;
|
||||||
$display("%tns, %d instrs: CSR = %s. Forcing interrupt of cause = %x back to 0", $time, InstrCountW, ExpectedCSRArrayM[NumCSRM], ExpectedCSRArrayValueM[NumCSRM]);
|
$display("Force SwIntM");
|
||||||
|
end
|
||||||
if(ExpectedIntType == 0) begin
|
else if(ExpectedIntType == 4) begin
|
||||||
force dut.hart.priv.SwIntM = 1'b0;
|
force dut.hart.priv.TimerIntM = 1'b0;
|
||||||
$display("Force SwIntM");
|
$display("Force TimeIntM");
|
||||||
end
|
end
|
||||||
else if(ExpectedIntType == 4) begin
|
else if(ExpectedIntType == 8) begin
|
||||||
force dut.hart.priv.TimerIntM = 1'b0;
|
force dut.hart.priv.ExtIntM = 1'b0;
|
||||||
$display("Force TimeIntM");
|
$display("Force ExtIntM");
|
||||||
end
|
|
||||||
else if(ExpectedIntType == 8) begin
|
|
||||||
force dut.hart.priv.ExtIntM = 1'b0;
|
|
||||||
$display("Force ExtIntM");
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user