mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
Fixed sutble RAS bug when the stack size was not a power of 2.
This commit is contained in:
parent
de7c0ff786
commit
9ec2bfd052
@ -27,8 +27,7 @@
|
|||||||
// and limitations under the License.
|
// and limitations under the License.
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
module RASPredictor import cvw::*; #(parameter cvw_t P,
|
module RASPredictor import cvw::*; #(parameter cvw_t P)(
|
||||||
parameter StackSize = 16 )(
|
|
||||||
input logic clk,
|
input logic clk,
|
||||||
input logic reset,
|
input logic reset,
|
||||||
input logic StallF, StallD, StallE, StallM, FlushD, FlushE, FlushM,
|
input logic StallF, StallD, StallE, StallM, FlushD, FlushE, FlushM,
|
||||||
@ -41,10 +40,10 @@ module RASPredictor import cvw::*; #(parameter cvw_t P,
|
|||||||
);
|
);
|
||||||
|
|
||||||
logic CounterEn;
|
logic CounterEn;
|
||||||
localparam Depth = $clog2(StackSize);
|
localparam Depth = $clog2(P.RAS_SIZE);
|
||||||
|
|
||||||
logic [Depth-1:0] NextPtr, Ptr, P1, M1, IncDecPtr;
|
logic [Depth-1:0] NextPtr, Ptr, P1, M1, IncDecPtr;
|
||||||
logic [StackSize-1:0] [P.XLEN-1:0] memory;
|
logic [P.RAS_SIZE-1:0] [P.XLEN-1:0] memory;
|
||||||
integer index;
|
integer index;
|
||||||
|
|
||||||
logic PopF;
|
logic PopF;
|
||||||
@ -76,14 +75,17 @@ module RASPredictor import cvw::*; #(parameter cvw_t P,
|
|||||||
assign P1 = 1;
|
assign P1 = 1;
|
||||||
assign M1 = '1; // -1
|
assign M1 = '1; // -1
|
||||||
mux2 #(Depth) PtrMux(P1, M1, DecrementPtr, IncDecPtr);
|
mux2 #(Depth) PtrMux(P1, M1, DecrementPtr, IncDecPtr);
|
||||||
assign NextPtr = Ptr + IncDecPtr;
|
logic [Depth-1:0] Sum;
|
||||||
|
assign Sum = Ptr + IncDecPtr;
|
||||||
|
assign NextPtr = Sum == P.RAS_SIZE[Depth-1:0] ? 0 : Sum; // wrap back around if our stack is not a power of 2
|
||||||
|
//assign NextPtr = Ptr + IncDecPtr;
|
||||||
|
|
||||||
flopenr #(Depth) PTR(clk, reset, CounterEn, NextPtr, Ptr);
|
flopenr #(Depth) PTR(clk, reset, CounterEn, NextPtr, Ptr);
|
||||||
|
|
||||||
// RAS must be reset.
|
// RAS must be reset.
|
||||||
always_ff @ (posedge clk) begin
|
always_ff @ (posedge clk) begin
|
||||||
if(reset) begin
|
if(reset) begin
|
||||||
for(index=0; index<StackSize; index++)
|
for(index=0; index<P.RAS_SIZE; index++)
|
||||||
memory[index] <= {P.XLEN{1'b0}};
|
memory[index] <= {P.XLEN{1'b0}};
|
||||||
end else if(PushE) begin
|
end else if(PushE) begin
|
||||||
memory[NextPtr] <= #1 PCLinkE;
|
memory[NextPtr] <= #1 PCLinkE;
|
||||||
|
Loading…
Reference in New Issue
Block a user