make testbench successfully deactivate TimerIntM so as to create a nice pulse

This commit is contained in:
bbracker 2021-09-07 15:36:47 -04:00
parent da9a366d20
commit f8272c45d1

View File

@ -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;
@ -246,19 +247,17 @@ module testbench();
//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 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 else forcedInterrupt = 0;
end end
NumCSRM++; NumCSRM++;
end end
@ -338,12 +337,8 @@ 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?
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]);
if(ExpectedIntType == 0) begin if(ExpectedIntType == 0) begin
force dut.hart.priv.SwIntM = 1'b0; force dut.hart.priv.SwIntM = 1'b0;
$display("Force SwIntM"); $display("Force SwIntM");
@ -360,7 +355,6 @@ module testbench();
end end
end end
end end
end
// step2: make all checks in the write back stage. // step2: make all checks in the write back stage.
always @(negedge clk) begin always @(negedge clk) begin