Line 42... |
Line 42... |
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//
|
//
|
// CVS Revision History
|
// CVS Revision History
|
//
|
//
|
// $Log: not supported by cvs2svn $
|
// $Log: not supported by cvs2svn $
|
|
// Revision 1.3 2002/01/28 01:16:00 lampret
|
|
// Changed 'void' nop-ops instead of insn[0] to use insn[16]. Debug unit stalls the tick timer. Prepared new flag generation for add and and insns. Blocked DC/IC while they are turned off. Fixed I/D MMU SPRs layout except WAYs. TODO: smart IC invalidate, l.j 2 and TLB ways.
|
|
//
|
// Revision 1.2 2002/01/14 06:18:22 lampret
|
// Revision 1.2 2002/01/14 06:18:22 lampret
|
// Fixed mem2reg bug in FAST implementation. Updated debug unit to work with new genpc/if.
|
// Fixed mem2reg bug in FAST implementation. Updated debug unit to work with new genpc/if.
|
//
|
//
|
// Revision 1.1 2002/01/03 08:16:15 lampret
|
// Revision 1.1 2002/01/03 08:16:15 lampret
|
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
|
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
|
Line 74... |
Line 77... |
`include "timescale.v"
|
`include "timescale.v"
|
// synopsys translate_on
|
// synopsys translate_on
|
`include "or1200_defines.v"
|
`include "or1200_defines.v"
|
|
|
`define OR1200_ICFSM_IDLE 3'd0
|
`define OR1200_ICFSM_IDLE 3'd0
|
`define OR1200_ICFSM_DOLOAD 3'd1
|
`define OR1200_ICFSM_CFETCH 3'd1
|
`define OR1200_ICFSM_LREFILL3 3'd2
|
`define OR1200_ICFSM_LREFILL3 3'd2
|
|
`define OR1200_ICFSM_IFETCH 3'd3
|
|
|
//
|
//
|
// Data cache FSM for cache line of 16 bytes (4x singleword)
|
// Data cache FSM for cache line of 16 bytes (4x singleword)
|
//
|
//
|
|
|
Line 126... |
Line 130... |
reg load;
|
reg load;
|
|
|
//
|
//
|
// Generate of ICRAM write enables
|
// Generate of ICRAM write enables
|
//
|
//
|
assign icram_we = {4{load & biudata_valid}};
|
assign icram_we = {4{load & biudata_valid & (state != `OR1200_ICFSM_IFETCH)}};
|
|
|
//
|
//
|
// BIU read and write
|
// BIU read and write
|
//
|
//
|
assign biu_read = (hitmiss_eval & tagcomp_miss) | (!hitmiss_eval & load);
|
assign biu_read = (hitmiss_eval & tagcomp_miss) | (!hitmiss_eval & load);
|
Line 138... |
Line 142... |
//
|
//
|
// Assert for cache hit first word ready
|
// Assert for cache hit first word ready
|
// Assert for cache miss first word stored/loaded OK
|
// Assert for cache miss first word stored/loaded OK
|
// Assert for cache miss first word stored/loaded with an error
|
// Assert for cache miss first word stored/loaded with an error
|
//
|
//
|
assign first_hit_ack = (state == `OR1200_ICFSM_DOLOAD) & hitmiss_eval & !tagcomp_miss & !icimmu_ci_i;
|
assign first_hit_ack = (state == `OR1200_ICFSM_CFETCH) & hitmiss_eval & !tagcomp_miss;
|
assign first_miss_ack = (state == `OR1200_ICFSM_DOLOAD) & (tagcomp_miss | icimmu_ci_i) & biudata_valid;
|
assign first_miss_ack = ((state == `OR1200_ICFSM_CFETCH) | (state == `OR1200_ICFSM_IFETCH)) & biudata_valid;
|
assign first_miss_err = (state == `OR1200_ICFSM_DOLOAD) & (tagcomp_miss | icimmu_ci_i) & biudata_error;
|
assign first_miss_err = ((state == `OR1200_ICFSM_CFETCH) | (state == `OR1200_ICFSM_IFETCH)) & biudata_error;
|
|
|
//
|
//
|
// Assert burst when doing reload of complete cache line
|
// Assert burst when doing reload of complete cache line
|
//
|
//
|
assign burst = (state == `OR1200_ICFSM_DOLOAD) & tagcomp_miss
|
assign burst = (state == `OR1200_ICFSM_CFETCH) & tagcomp_miss
|
| (state == `OR1200_ICFSM_LREFILL3);
|
| (state == `OR1200_ICFSM_LREFILL3);
|
|
|
//
|
//
|
// Main IC FSM
|
// Main IC FSM
|
//
|
//
|
Line 162... |
Line 166... |
cnt <= #1 3'b000;
|
cnt <= #1 3'b000;
|
end
|
end
|
else
|
else
|
case (state) // synopsys parallel_case
|
case (state) // synopsys parallel_case
|
`OR1200_ICFSM_IDLE :
|
`OR1200_ICFSM_IDLE :
|
if (ic_en & icimmu_cyc_i & icimmu_stb_i) begin // load
|
if (ic_en & icimmu_cyc_i & icimmu_stb_i & icimmu_ci_i) begin // fetch from cache-inhibited area
|
state <= #1 `OR1200_ICFSM_DOLOAD;
|
state <= #1 `OR1200_ICFSM_IFETCH;
|
|
saved_addr <= #1 start_addr;
|
|
hitmiss_eval <= #1 1'b0;
|
|
load <= #1 1'b1;
|
|
end
|
|
else if (ic_en & icimmu_cyc_i & icimmu_stb_i) begin // fetch from cached area
|
|
state <= #1 `OR1200_ICFSM_CFETCH;
|
saved_addr <= #1 start_addr;
|
saved_addr <= #1 start_addr;
|
hitmiss_eval <= #1 1'b1;
|
hitmiss_eval <= #1 1'b1;
|
load <= #1 1'b1;
|
load <= #1 1'b1;
|
end
|
end
|
else begin // idle
|
else begin // idle
|
state <= #1 `OR1200_ICFSM_IDLE;
|
state <= #1 `OR1200_ICFSM_IDLE;
|
hitmiss_eval <= #1 1'b0;
|
hitmiss_eval <= #1 1'b0;
|
load <= #1 1'b0;
|
load <= #1 1'b0;
|
end
|
end
|
`OR1200_ICFSM_DOLOAD:
|
`OR1200_ICFSM_CFETCH: // fetch from cached area
|
if (!ic_en)
|
if (!ic_en)
|
state <= #1 `OR1200_ICFSM_IDLE;
|
state <= #1 `OR1200_ICFSM_IDLE;
|
else if (hitmiss_eval & !(icimmu_cyc_i & icimmu_stb_i)) begin // load aborted (usually caused by IMMU)
|
else if (hitmiss_eval & !(icimmu_cyc_i & icimmu_stb_i)) begin // fetch aborted (usually caused by IMMU)
|
state <= #1 `OR1200_ICFSM_IDLE;
|
state <= #1 `OR1200_ICFSM_IDLE;
|
hitmiss_eval <= #1 1'b0;
|
hitmiss_eval <= #1 1'b0;
|
load <= #1 1'b0;
|
load <= #1 1'b0;
|
end
|
end
|
else if (icimmu_ci_i & biudata_valid) begin // load from cache inhibit page
|
else if (biudata_error) begin // fetch terminated with an error
|
state <= #1 `OR1200_ICFSM_IDLE;
|
state <= #1 `OR1200_ICFSM_IDLE;
|
hitmiss_eval <= #1 1'b0;
|
hitmiss_eval <= #1 1'b0;
|
load <= #1 1'b0;
|
load <= #1 1'b0;
|
end
|
end
|
else if (tagcomp_miss & biudata_valid) begin // load missed, finish current external load and refill
|
else if (tagcomp_miss & biudata_valid) begin // fetch missed, finish current external fetch and refill
|
state <= #1 `OR1200_ICFSM_LREFILL3;
|
state <= #1 `OR1200_ICFSM_LREFILL3;
|
saved_addr[3:2] <= #1 saved_addr[3:2] + 'd1;
|
saved_addr[3:2] <= #1 saved_addr[3:2] + 'd1;
|
hitmiss_eval <= #1 1'b0;
|
hitmiss_eval <= #1 1'b0;
|
cnt <= #1 `OR1200_ICLS-2;
|
cnt <= #1 `OR1200_ICLS-2;
|
end
|
end
|
else if (!tagcomp_miss & !icimmu_ci_i) begin // load hit and not cache inhibit, finish immediately
|
else if (!tagcomp_miss) begin // fetch hit, finish immediately
|
state <= #1 `OR1200_ICFSM_DOLOAD;
|
state <= #1 `OR1200_ICFSM_CFETCH;
|
saved_addr <= #1 start_addr;
|
saved_addr <= #1 start_addr;
|
hitmiss_eval <= #1 1'b1;
|
hitmiss_eval <= #1 1'b1;
|
load <= #1 1'b1;
|
load <= #1 1'b1;
|
end
|
end
|
else if (!icimmu_cyc_i | !icimmu_stb_i) begin // load aborted (usually caused by exception)
|
else if (!icimmu_cyc_i | !icimmu_stb_i) begin // fetch aborted (usually caused by exception)
|
state <= #1 `OR1200_ICFSM_IDLE;
|
state <= #1 `OR1200_ICFSM_IDLE;
|
hitmiss_eval <= #1 1'b0;
|
hitmiss_eval <= #1 1'b0;
|
load <= #1 1'b0;
|
load <= #1 1'b0;
|
end
|
end
|
else // load in-progress
|
else // fetch in-progress
|
hitmiss_eval <= #1 1'b0;
|
hitmiss_eval <= #1 1'b0;
|
`OR1200_ICFSM_LREFILL3 : begin
|
`OR1200_ICFSM_LREFILL3 : begin
|
if (!ic_en)
|
if (!ic_en)
|
state <= #1 `OR1200_ICFSM_IDLE;
|
state <= #1 `OR1200_ICFSM_IDLE;
|
else if (biudata_valid && (|cnt)) begin // refill ack, more loads to come
|
else if (biudata_valid && (|cnt)) begin // refill ack, more fetchs to come
|
cnt <= #1 cnt - 'd1;
|
cnt <= #1 cnt - 'd1;
|
saved_addr[3:2] <= #1 saved_addr[3:2] + 'd1;
|
saved_addr[3:2] <= #1 saved_addr[3:2] + 'd1;
|
end
|
end
|
else if (biudata_valid) begin // last load of line refill
|
else if (biudata_valid) begin // last fetch of line refill
|
state <= #1 `OR1200_ICFSM_IDLE;
|
state <= #1 `OR1200_ICFSM_IDLE;
|
saved_addr <= #1 start_addr;
|
saved_addr <= #1 start_addr;
|
hitmiss_eval <= #1 1'b0;
|
hitmiss_eval <= #1 1'b0;
|
load <= #1 1'b0;
|
load <= #1 1'b0;
|
end
|
end
|
end
|
end
|
|
`OR1200_ICFSM_IFETCH: // fetch from cache-inhibited area
|
|
if (!ic_en)
|
|
state <= #1 `OR1200_ICFSM_IDLE;
|
|
else if (!(icimmu_cyc_i & icimmu_stb_i)) begin // fetch aborted (usually caused by IMMU)
|
|
state <= #1 `OR1200_ICFSM_IDLE;
|
|
hitmiss_eval <= #1 1'b0;
|
|
load <= #1 1'b0;
|
|
end
|
|
else if (biudata_error) begin // fetch terminated with an error
|
|
state <= #1 `OR1200_ICFSM_IDLE;
|
|
hitmiss_eval <= #1 1'b0;
|
|
load <= #1 1'b0;
|
|
end
|
|
else if (biudata_valid) begin // fetch from cache inhibit page
|
|
state <= #1 `OR1200_ICFSM_IDLE;
|
|
hitmiss_eval <= #1 1'b0;
|
|
load <= #1 1'b0;
|
|
end
|
|
else // fetch in-progress
|
|
hitmiss_eval <= #1 1'b0;
|
default:
|
default:
|
state <= #1 `OR1200_ICFSM_IDLE;
|
state <= #1 `OR1200_ICFSM_IDLE;
|
endcase
|
endcase
|
end
|
end
|
|
|