From c98c0dd3e05c3f81698913e39c2a377fb3077fd4 Mon Sep 17 00:00:00 2001 From: Rose Thompson Date: Wed, 13 Dec 2023 13:05:10 -0600 Subject: [PATCH] Removed unnecessary pc reset logic from ifu and btb. --- src/ifu/bpred/btb.sv | 8 +------- src/ifu/ifu.sv | 7 +++---- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/ifu/bpred/btb.sv b/src/ifu/bpred/btb.sv index 066176daa..567e4d3cd 100644 --- a/src/ifu/bpred/btb.sv +++ b/src/ifu/bpred/btb.sv @@ -50,7 +50,6 @@ module btb import cvw::*; #(parameter cvw_t P, ); logic [Depth-1:0] PCNextFIndex, PCFIndex, PCDIndex, PCEIndex, PCMIndex, PCWIndex; - logic [P.XLEN-1:0] ResetPC; logic MatchD, MatchE, MatchM, MatchW, MatchX; logic [P.XLEN+3:0] ForwardBTBPrediction, ForwardBTBPredictionF; logic [P.XLEN+3:0] TableBTBPredF; @@ -70,12 +69,7 @@ module btb import cvw::*; #(parameter cvw_t P, assign PCMIndex = {PCM[Depth+1] ^ PCM[1], PCM[Depth:2]}; assign PCWIndex = {PCW[Depth+1] ^ PCW[1], PCW[Depth:2]}; - // must output a valid PC and valid bit during reset. Because only PCF, not PCNextF is reset, PCNextF is invalid - // during reset. The BTB must produce a non X PC1NextF to allow the simulation to run. - // While the mux could be included in IFU it is not necessary for the IROM/I$/bus. - // For now it is optimal to leave it here. - assign ResetPC = P.RESET_VECTOR[P.XLEN-1:0]; - assign PCNextFIndex = reset ? ResetPC[Depth+1:2] : {PCNextF[Depth+1] ^ PCNextF[1], PCNextF[Depth:2]}; + assign PCNextFIndex = {PCNextF[Depth+1] ^ PCNextF[1], PCNextF[Depth:2]}; assign MatchD = PCFIndex == PCDIndex; assign MatchE = PCFIndex == PCEIndex; diff --git a/src/ifu/ifu.sv b/src/ifu/ifu.sv index 4a02848b5..7ebdd5878 100644 --- a/src/ifu/ifu.sv +++ b/src/ifu/ifu.sv @@ -300,8 +300,8 @@ module ifu import cvw::*; #(parameter cvw_t P) ( mux2 #(P.XLEN) pcmux2(.d0(PC1NextF), .d1(NextValidPCE), .s(CSRWriteFenceM),.y(PC2NextF)); else assign PC2NextF = PC1NextF; - assign PCNextF = {UnalignedPCNextF[P.XLEN-1:1], 1'b0}; // hart-SPEC p. 21 about 16-bit alignment - flopenl #(P.XLEN) pcreg(clk, reset, ~StallF, PCNextF, P.RESET_VECTOR[P.XLEN-1:0], PCF); + mux2 #(P.XLEN) pcresetmux({UnalignedPCNextF[P.XLEN-1:1], 1'b0}, P.RESET_VECTOR[P.XLEN-1:0], reset, PCNextF); + flopen #(P.XLEN) pcreg(clk, ~StallF | reset, PCNextF, PCF); // pcadder // add 2 or 4 to the PC, based on whether the instruction is 16 bits or 32 @@ -315,8 +315,7 @@ module ifu import cvw::*; #(parameter cvw_t P) ( // an X. This version of the code does not die because if CompressedF is an X it just defaults to the last // option. The above code would work, but propagates the x. always_comb - if(reset) PCPlus2or4F = '0; - else if (CompressedF) // add 2 + if (CompressedF) // add 2 if (PCF[1]) PCPlus2or4F = {PCPlus4F, 2'b00}; else PCPlus2or4F = {PCF[P.XLEN-1:2], 2'b10}; else PCPlus2or4F = {PCPlus4F, PCF[1:0]}; // add 4