Line 56... |
Line 56... |
`define OR1200_ICFSM_CFETCH 2'd1
|
`define OR1200_ICFSM_CFETCH 2'd1
|
`define OR1200_ICFSM_LREFILL3 2'd2
|
`define OR1200_ICFSM_LREFILL3 2'd2
|
`define OR1200_ICFSM_IFETCH 2'd3
|
`define OR1200_ICFSM_IFETCH 2'd3
|
|
|
//
|
//
|
// Data cache FSM for cache line of 16 bytes (4x singleword)
|
// Instruction cache FSM
|
//
|
//
|
|
|
module or1200_ic_fsm(
|
module or1200_ic_fsm(
|
// Clock and reset
|
// Clock and reset
|
clk, rst,
|
clk, rst,
|
|
|
// Internal i/f to top level IC
|
// Internal i/f to top level IC
|
ic_en, icqmem_cycstb_i, icqmem_ci_i,
|
ic_en, icqmem_cycstb_i, icqmem_ci_i,
|
tagcomp_miss, biudata_valid, biudata_error, start_addr, saved_addr,
|
tagcomp_miss,
|
icram_we, biu_read, first_hit_ack, first_miss_ack, first_miss_err,
|
biudata_valid, biudata_error,
|
burst, tag_we
|
start_addr, saved_addr,
|
|
icram_we, tag_we,
|
|
biu_read,
|
|
first_hit_ack, first_miss_ack, first_miss_err,
|
|
burst
|
);
|
);
|
|
|
//
|
//
|
// I/O
|
// I/O
|
//
|
//
|
Line 100... |
Line 104... |
reg [1:0] state;
|
reg [1:0] state;
|
reg [2:0] cnt;
|
reg [2:0] cnt;
|
reg hitmiss_eval;
|
reg hitmiss_eval;
|
reg load;
|
reg load;
|
reg cache_inhibit;
|
reg cache_inhibit;
|
reg waiting_for_first_fill_ack; // JPB
|
reg last_eval_miss; // JPB
|
|
|
//
|
//
|
// Generate of ICRAM write enables
|
// Generate of ICRAM write enables
|
//
|
//
|
assign icram_we = {4{biu_read & biudata_valid & !cache_inhibit}};
|
assign icram_we = {4{biu_read & biudata_valid & !cache_inhibit}};
|
Line 143... |
Line 147... |
saved_addr_r <= 32'b0;
|
saved_addr_r <= 32'b0;
|
hitmiss_eval <= 1'b0;
|
hitmiss_eval <= 1'b0;
|
load <= 1'b0;
|
load <= 1'b0;
|
cnt <= 3'b000;
|
cnt <= 3'b000;
|
cache_inhibit <= 1'b0;
|
cache_inhibit <= 1'b0;
|
waiting_for_first_fill_ack <= 0; // JPB
|
last_eval_miss <= 0; // JPB
|
|
|
end
|
end
|
else
|
else
|
case (state) // synopsys parallel_case
|
case (state) // synopsys parallel_case
|
`OR1200_ICFSM_IDLE :
|
`OR1200_ICFSM_IDLE :
|
Line 155... |
Line 159... |
state <= `OR1200_ICFSM_CFETCH;
|
state <= `OR1200_ICFSM_CFETCH;
|
saved_addr_r <= start_addr;
|
saved_addr_r <= start_addr;
|
hitmiss_eval <= 1'b1;
|
hitmiss_eval <= 1'b1;
|
load <= 1'b1;
|
load <= 1'b1;
|
cache_inhibit <= icqmem_ci_i;
|
cache_inhibit <= icqmem_ci_i;
|
waiting_for_first_fill_ack <= 0; // JPB
|
last_eval_miss <= 0; // JPB
|
end
|
end
|
else begin // idle
|
else begin // idle
|
hitmiss_eval <= 1'b0;
|
hitmiss_eval <= 1'b0;
|
load <= 1'b0;
|
load <= 1'b0;
|
cache_inhibit <= 1'b0;
|
cache_inhibit <= 1'b0;
|
Line 180... |
Line 184... |
(cache_inhibit & biudata_valid)) begin
|
(cache_inhibit & biudata_valid)) begin
|
state <= `OR1200_ICFSM_IDLE;
|
state <= `OR1200_ICFSM_IDLE;
|
hitmiss_eval <= 1'b0;
|
hitmiss_eval <= 1'b0;
|
load <= 1'b0;
|
load <= 1'b0;
|
cache_inhibit <= 1'b0;
|
cache_inhibit <= 1'b0;
|
waiting_for_first_fill_ack <= 0;
|
|
end // if ((!ic_en) ||...
|
end // if ((!ic_en) ||...
|
// fetch missed, finish current external fetch and refill
|
// fetch missed, wait for first fetch and continue filling line
|
else if (tagcomp_miss & biudata_valid) begin
|
else if (tagcomp_miss & biudata_valid) begin
|
state <= `OR1200_ICFSM_LREFILL3;
|
state <= `OR1200_ICFSM_LREFILL3;
|
saved_addr_r[3:2] <= saved_addr_r[3:2] + 1'd1;
|
saved_addr_r[3:2] <= saved_addr_r[3:2] + 1'd1;
|
hitmiss_eval <= 1'b0;
|
hitmiss_eval <= 1'b0;
|
cnt <= `OR1200_ICLS-2;
|
cnt <= `OR1200_ICLS-2;
|
cache_inhibit <= 1'b0;
|
cache_inhibit <= 1'b0;
|
waiting_for_first_fill_ack <= 0; // JPB
|
|
end
|
end
|
// fetch aborted (usually caused by exception)
|
// fetch aborted (usually caused by exception)
|
else if (!icqmem_cycstb_i) begin
|
else if (!icqmem_cycstb_i
|
|
& !last_eval_miss // JPB
|
|
) begin
|
state <= `OR1200_ICFSM_IDLE;
|
state <= `OR1200_ICFSM_IDLE;
|
hitmiss_eval <= 1'b0;
|
hitmiss_eval <= 1'b0;
|
load <= 1'b0;
|
load <= 1'b0;
|
cache_inhibit <= 1'b0;
|
cache_inhibit <= 1'b0;
|
waiting_for_first_fill_ack <= 0; // JPB
|
|
end
|
end
|
// fetch hit, finish immediately
|
// fetch hit, wait in this state for now
|
else if (!tagcomp_miss & !icqmem_ci_i &
|
else if (!tagcomp_miss & !icqmem_ci_i) begin
|
!waiting_for_first_fill_ack) begin
|
|
state <= `OR1200_ICFSM_IDLE; // JPB
|
|
load <= 1'b0; // JPB
|
|
hitmiss_eval <= 1'b0; // JPB
|
|
saved_addr_r <= start_addr;
|
saved_addr_r <= start_addr;
|
cache_inhibit <= 1'b0;
|
cache_inhibit <= 1'b0;
|
end
|
end
|
else // fetch in-progress
|
else // fetch in-progress
|
hitmiss_eval <= 1'b0;
|
hitmiss_eval <= 1'b0;
|
|
|
if (hitmiss_eval & tagcomp_miss) // JPB
|
if (hitmiss_eval & !tagcomp_miss) // JPB
|
waiting_for_first_fill_ack <= 1;
|
last_eval_miss <= 1; // JPB
|
|
|
end
|
end
|
`OR1200_ICFSM_LREFILL3 : begin
|
`OR1200_ICFSM_LREFILL3 : begin
|
// abort because IC has just been turned off
|
// abort because IC has just been turned off
|
if (!ic_en) begin
|
if (!ic_en) begin
|