fix speculation ignoring for PC fetching

This commit is contained in:
Noah Boorstin 2021-01-25 19:45:26 -05:00
parent b7988e536f
commit 05d4f2d33d
2 changed files with 17 additions and 10 deletions

View File

@ -43,6 +43,9 @@ add wave -divider
add wave -hex /testbench_busybear/pcExpected
add wave -hex /testbench_busybear/dut/dp/PCF
add wave -hex /testbench_busybear/dut/dp/InstrF
add wave /testbench_busybear/lastInstrF
add wave /testbench_busybear/speculative
add wave /testbench_busybear/lastPC2
add wave -divider
# registers!
add wave -hex /testbench_busybear/rfExpected

View File

@ -115,22 +115,26 @@ module testbench_busybear();
end
end
logic speculative, nextSpec;
logic speculative;
initial begin
speculative = 0;
nextSpec = 0;
speculative = 0;
end
logic [63:0] lastInstrF, lastPC, lastPC2;
integer instrs;
initial begin
instrs = 0;
end
always @(PCF) begin
speculative <= nextSpec;
if (speculative) begin
nextSpec <= (PCF != pcExpected);
lastInstrF = InstrF;
lastPC <= PCF;
lastPC2 <= lastPC;
if (speculative && lastPC != pcExpected) begin
speculative = (PCF != pcExpected);
end
if (~speculative) begin
else begin
//if (~speculative) begin
// first read instruction
scan_file_PC = $fscanf(data_file_PC, "%x\n", InstrF);
// then expected PC value
@ -142,17 +146,17 @@ module testbench_busybear();
$stop;
end
// are we at a branch/jump?
case (InstrF[6:0]) //todo: add C versions of these
case (lastInstrF[6:0]) //todo: add C versions of these
7'b1101111, //JAL
7'b1100111, //JALR
7'b1100011: //B
nextSpec <= 1;
speculative = 1;
default:
nextSpec <= 0;
speculative = 0;
endcase
//check things!
if ((~nextSpec) && (PCF !== pcExpected)) begin
if ((~speculative) && (PCF !== pcExpected)) begin
$display("%t ps: PC does not equal PC expected: %x, %x", $time, PCF, pcExpected);
// $stop;
end