Line 42... |
Line 42... |
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//
|
//
|
// CVS Revision History
|
// CVS Revision History
|
//
|
//
|
// $Log: not supported by cvs2svn $
|
// $Log: not supported by cvs2svn $
|
|
// Revision 1.4 2002/02/01 19:56:54 lampret
|
|
// Fixed combinational loops.
|
|
//
|
// Revision 1.3 2002/01/28 01:15:59 lampret
|
// Revision 1.3 2002/01/28 01:15:59 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.
|
// 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.
|
Line 93... |
Line 96... |
module or1200_dc_fsm(
|
module or1200_dc_fsm(
|
// Clock and reset
|
// Clock and reset
|
clk, rst,
|
clk, rst,
|
|
|
// Internal i/f to top level DC
|
// Internal i/f to top level DC
|
dc_en, dcdmmu_cyc_i, dcdmmu_stb_i, dcdmmu_ci_i, dcpu_we_i, dcpu_sel_i,
|
dc_en, dcdmmu_cycstb_i, dcdmmu_ci_i, dcpu_we_i, dcpu_sel_i,
|
tagcomp_miss, biudata_valid, biudata_error, start_addr, saved_addr,
|
tagcomp_miss, biudata_valid, biudata_error, start_addr, saved_addr,
|
dcram_we, biu_read, biu_write, first_hit_ack, first_miss_ack, first_miss_err,
|
dcram_we, biu_read, biu_write, first_hit_ack, first_miss_ack, first_miss_err,
|
burst
|
burst, tag_we, dc_addr
|
);
|
);
|
|
|
//
|
//
|
// I/O
|
// I/O
|
//
|
//
|
input clk;
|
input clk;
|
input rst;
|
input rst;
|
input dc_en;
|
input dc_en;
|
input dcdmmu_cyc_i;
|
input dcdmmu_cycstb_i;
|
input dcdmmu_stb_i;
|
|
input dcdmmu_ci_i;
|
input dcdmmu_ci_i;
|
input dcpu_we_i;
|
input dcpu_we_i;
|
input [3:0] dcpu_sel_i;
|
input [3:0] dcpu_sel_i;
|
input tagcomp_miss;
|
input tagcomp_miss;
|
input biudata_valid;
|
input biudata_valid;
|
Line 122... |
Line 124... |
output biu_write;
|
output biu_write;
|
output first_hit_ack;
|
output first_hit_ack;
|
output first_miss_ack;
|
output first_miss_ack;
|
output first_miss_err;
|
output first_miss_err;
|
output burst;
|
output burst;
|
|
output tag_we;
|
|
output [31:0] dc_addr;
|
|
|
//
|
//
|
// Internal wires and regs
|
// Internal wires and regs
|
//
|
//
|
reg [31:0] saved_addr;
|
reg [31:0] saved_addr_r;
|
reg [2:0] state;
|
reg [2:0] state;
|
reg [2:0] cnt;
|
reg [2:0] cnt;
|
reg hitmiss_eval;
|
reg hitmiss_eval;
|
reg store;
|
reg store;
|
reg load;
|
reg load;
|
|
reg cache_inhibit;
|
wire first_store_hit_ack;
|
wire first_store_hit_ack;
|
|
|
//
|
//
|
// Generate of DCRAM write enables
|
// Generate of DCRAM write enables
|
//
|
//
|
assign dcram_we = {4{load & biudata_valid & (state != `OR1200_DCFSM_ILOAD)}} | {4{first_store_hit_ack}} & dcpu_sel_i;
|
assign dcram_we = {4{load & biudata_valid & !cache_inhibit}} | {4{first_store_hit_ack}} & dcpu_sel_i;
|
|
assign tag_we = biu_read & biudata_valid & !cache_inhibit;
|
|
|
//
|
//
|
// 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);
|
assign biu_write = store;
|
assign biu_write = store;
|
|
|
|
assign dc_addr = (biu_read | biu_write) & !hitmiss_eval ? saved_addr : start_addr;
|
|
assign saved_addr = saved_addr_r;
|
|
|
//
|
//
|
// Assert for cache hit first word ready
|
// Assert for cache hit first word ready
|
// Assert for store cache hit first word ready
|
// Assert for store 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_DCFSM_CLOAD) & !tagcomp_miss | first_store_hit_ack;
|
assign first_hit_ack = (state == `OR1200_DCFSM_CLOAD) & !tagcomp_miss & !cache_inhibit & !dcdmmu_ci_i | first_store_hit_ack;
|
assign first_store_hit_ack = (state == `OR1200_DCFSM_CSTORE) & !tagcomp_miss & biudata_valid;
|
assign first_store_hit_ack = (state == `OR1200_DCFSM_CSTORE) & !tagcomp_miss & biudata_valid & !cache_inhibit & !dcdmmu_ci_i;
|
assign first_miss_ack = ((state == `OR1200_DCFSM_CLOAD) | (state == `OR1200_DCFSM_CSTORE) | (state == `OR1200_DCFSM_ILOAD) | (state == `OR1200_DCFSM_ISTORE)) & biudata_valid;
|
assign first_miss_ack = ((state == `OR1200_DCFSM_CLOAD) | (state == `OR1200_DCFSM_CSTORE)) & biudata_valid;
|
assign first_miss_err = ((state == `OR1200_DCFSM_CLOAD) | (state == `OR1200_DCFSM_CSTORE) | (state == `OR1200_DCFSM_ILOAD) | (state == `OR1200_DCFSM_ISTORE)) & biudata_error;
|
assign first_miss_err = ((state == `OR1200_DCFSM_CLOAD) | (state == `OR1200_DCFSM_CSTORE)) & biudata_error;
|
|
|
//
|
//
|
// Assert burst when doing reload of complete cache line
|
// Assert burst when doing reload of complete cache line
|
//
|
//
|
assign burst = (state == `OR1200_DCFSM_CLOAD) & tagcomp_miss
|
assign burst = (state == `OR1200_DCFSM_CLOAD) & tagcomp_miss & !cache_inhibit
|
| (state == `OR1200_DCFSM_LREFILL3)
|
| (state == `OR1200_DCFSM_LREFILL3)
|
`ifdef OR1200_DC_STORE_REFILL
|
`ifdef OR1200_DC_STORE_REFILL
|
| (state == `OR1200_DCFSM_SREFILL4)
|
| (state == `OR1200_DCFSM_SREFILL4)
|
`endif
|
`endif
|
;
|
;
|
Line 172... |
Line 181... |
// Main DC FSM
|
// Main DC FSM
|
//
|
//
|
always @(posedge clk or posedge rst) begin
|
always @(posedge clk or posedge rst) begin
|
if (rst) begin
|
if (rst) begin
|
state <= #1 `OR1200_DCFSM_IDLE;
|
state <= #1 `OR1200_DCFSM_IDLE;
|
saved_addr <= #1 32'b0;
|
saved_addr_r <= #1 32'b0;
|
hitmiss_eval <= #1 1'b0;
|
hitmiss_eval <= #1 1'b0;
|
store <= #1 1'b0;
|
store <= #1 1'b0;
|
load <= #1 1'b0;
|
load <= #1 1'b0;
|
cnt <= #1 3'b000;
|
cnt <= #1 3'b000;
|
|
cache_inhibit <= #1 1'b0;
|
end
|
end
|
else
|
else
|
case (state) // synopsys parallel_case
|
case (state) // synopsys parallel_case
|
`OR1200_DCFSM_IDLE :
|
`OR1200_DCFSM_IDLE :
|
if (dc_en & dcdmmu_ci_i & dcdmmu_cyc_i & dcdmmu_stb_i & dcpu_we_i) begin // store to cache-inhibited area
|
if (dc_en & dcdmmu_cycstb_i & dcpu_we_i) begin // store
|
state <= #1 `OR1200_DCFSM_ISTORE;
|
|
saved_addr <= #1 start_addr;
|
|
hitmiss_eval <= #1 1'b0;
|
|
store <= #1 1'b1;
|
|
load <= #1 1'b0;
|
|
end
|
|
else if (dc_en & dcdmmu_ci_i & dcdmmu_cyc_i & dcdmmu_stb_i) begin // load from cache-inhibited area
|
|
state <= #1 `OR1200_DCFSM_ILOAD;
|
|
saved_addr <= #1 start_addr;
|
|
hitmiss_eval <= #1 1'b0;
|
|
store <= #1 1'b0;
|
|
load <= #1 1'b1;
|
|
end
|
|
else if (dc_en & dcdmmu_cyc_i & dcdmmu_stb_i & dcpu_we_i) begin // store to cached area
|
|
state <= #1 `OR1200_DCFSM_CSTORE;
|
state <= #1 `OR1200_DCFSM_CSTORE;
|
saved_addr <= #1 start_addr;
|
saved_addr_r <= #1 start_addr;
|
hitmiss_eval <= #1 1'b1;
|
hitmiss_eval <= #1 1'b1;
|
store <= #1 1'b1;
|
store <= #1 1'b1;
|
load <= #1 1'b0;
|
load <= #1 1'b0;
|
|
cache_inhibit <= #1 1'b0;
|
end
|
end
|
else if (dc_en & dcdmmu_cyc_i & dcdmmu_stb_i) begin // load from cached area
|
else if (dc_en & dcdmmu_cycstb_i) begin // load
|
state <= #1 `OR1200_DCFSM_CLOAD;
|
state <= #1 `OR1200_DCFSM_CLOAD;
|
saved_addr <= #1 start_addr;
|
saved_addr_r <= #1 start_addr;
|
hitmiss_eval <= #1 1'b1;
|
hitmiss_eval <= #1 1'b1;
|
store <= #1 1'b0;
|
store <= #1 1'b0;
|
load <= #1 1'b1;
|
load <= #1 1'b1;
|
|
cache_inhibit <= #1 1'b0;
|
end
|
end
|
else begin // idle
|
else begin // idle
|
state <= #1 `OR1200_DCFSM_IDLE;
|
state <= #1 `OR1200_DCFSM_IDLE;
|
hitmiss_eval <= #1 1'b0;
|
hitmiss_eval <= #1 1'b0;
|
store <= #1 1'b0;
|
store <= #1 1'b0;
|
load <= #1 1'b0;
|
load <= #1 1'b0;
|
|
cache_inhibit <= #1 1'b0;
|
end
|
end
|
`OR1200_DCFSM_CLOAD: // load from cached area
|
`OR1200_DCFSM_CLOAD: begin // load
|
|
if (dcdmmu_cycstb_i & dcdmmu_ci_i)
|
|
cache_inhibit <= #1 1'b1;
|
|
if (hitmiss_eval)
|
|
saved_addr_r[31:13] <= #1 start_addr[31:13];
|
if (!dc_en)
|
if (!dc_en)
|
state <= #1 `OR1200_DCFSM_IDLE;
|
state <= #1 `OR1200_DCFSM_IDLE;
|
else if (hitmiss_eval & !(dcdmmu_cyc_i & dcdmmu_stb_i)) begin // load aborted (usually caused by DMMU)
|
else if (hitmiss_eval & !dcdmmu_cycstb_i) begin // load aborted (usually caused by DMMU)
|
state <= #1 `OR1200_DCFSM_IDLE;
|
state <= #1 `OR1200_DCFSM_IDLE;
|
hitmiss_eval <= #1 1'b0;
|
hitmiss_eval <= #1 1'b0;
|
load <= #1 1'b0;
|
load <= #1 1'b0;
|
|
cache_inhibit <= #1 1'b0;
|
end
|
end
|
else if (biudata_error) begin // load terminated with an error
|
else if (biudata_error) begin // load terminated with an error
|
state <= #1 `OR1200_DCFSM_IDLE;
|
state <= #1 `OR1200_DCFSM_IDLE;
|
hitmiss_eval <= #1 1'b0;
|
hitmiss_eval <= #1 1'b0;
|
load <= #1 1'b0;
|
load <= #1 1'b0;
|
|
cache_inhibit <= #1 1'b0;
|
|
end
|
|
else if ((cache_inhibit | dcdmmu_ci_i) & biudata_valid) begin // load from cache-inhibited area
|
|
state <= #1 `OR1200_DCFSM_IDLE;
|
|
hitmiss_eval <= #1 1'b0;
|
|
load <= #1 1'b0;
|
|
cache_inhibit <= #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 // load missed, finish current external load and refill
|
state <= #1 `OR1200_DCFSM_LREFILL3;
|
state <= #1 `OR1200_DCFSM_LREFILL3;
|
saved_addr[3:2] <= #1 saved_addr[3:2] + 'd1;
|
saved_addr_r[3:2] <= #1 saved_addr_r[3:2] + 'd1;
|
hitmiss_eval <= #1 1'b0;
|
hitmiss_eval <= #1 1'b0;
|
cnt <= #1 `OR1200_DCLS-2;
|
cnt <= #1 `OR1200_DCLS-2;
|
|
cache_inhibit <= #1 1'b0;
|
end
|
end
|
else if (!tagcomp_miss) begin // load hit, finish immediately
|
else if (!tagcomp_miss & !dcdmmu_ci_i) begin // load hit, finish immediately
|
state <= #1 `OR1200_DCFSM_IDLE;
|
state <= #1 `OR1200_DCFSM_IDLE;
|
hitmiss_eval <= #1 1'b0;
|
hitmiss_eval <= #1 1'b0;
|
load <= #1 1'b0;
|
load <= #1 1'b0;
|
|
cache_inhibit <= #1 1'b0;
|
end
|
end
|
else // load in-progress
|
else // load in-progress
|
hitmiss_eval <= #1 1'b0;
|
hitmiss_eval <= #1 1'b0;
|
|
end
|
`OR1200_DCFSM_LREFILL3 : begin
|
`OR1200_DCFSM_LREFILL3 : begin
|
if (!dc_en)
|
if (!dc_en)
|
state <= #1 `OR1200_DCFSM_IDLE;
|
state <= #1 `OR1200_DCFSM_IDLE;
|
else if (biudata_valid && (|cnt)) begin // refill ack, more loads to come
|
else if (biudata_valid && (|cnt)) begin // refill ack, more loads to come
|
cnt <= #1 cnt - 'd1;
|
cnt <= #1 cnt - 'd1;
|
saved_addr[3:2] <= #1 saved_addr[3:2] + 'd1;
|
saved_addr_r[3:2] <= #1 saved_addr_r[3:2] + 'd1;
|
end
|
end
|
else if (biudata_valid) begin // last load of line refill
|
else if (biudata_valid) begin // last load of line refill
|
state <= #1 `OR1200_DCFSM_IDLE;
|
state <= #1 `OR1200_DCFSM_IDLE;
|
load <= #1 1'b0;
|
load <= #1 1'b0;
|
end
|
end
|
end
|
end
|
`OR1200_DCFSM_CSTORE: // store to cached area
|
`OR1200_DCFSM_CSTORE: begin // store
|
|
if (dcdmmu_cycstb_i & dcdmmu_ci_i)
|
|
cache_inhibit <= #1 1'b1;
|
|
if (hitmiss_eval)
|
|
saved_addr_r[31:13] <= #1 start_addr[31:13];
|
if (!dc_en)
|
if (!dc_en)
|
state <= #1 `OR1200_DCFSM_IDLE;
|
state <= #1 `OR1200_DCFSM_IDLE;
|
else if (hitmiss_eval & !(dcdmmu_cyc_i & dcdmmu_stb_i)) begin // store aborted (usually caused by DMMU)
|
else if (hitmiss_eval & !dcdmmu_cycstb_i) begin // store aborted (usually caused by DMMU)
|
state <= #1 `OR1200_DCFSM_IDLE;
|
state <= #1 `OR1200_DCFSM_IDLE;
|
hitmiss_eval <= #1 1'b0;
|
hitmiss_eval <= #1 1'b0;
|
store <= #1 1'b0;
|
store <= #1 1'b0;
|
|
cache_inhibit <= #1 1'b0;
|
end
|
end
|
else if (biudata_error) begin // store terminated with an error
|
else if (biudata_error) begin // store terminated with an error
|
state <= #1 `OR1200_DCFSM_IDLE;
|
state <= #1 `OR1200_DCFSM_IDLE;
|
hitmiss_eval <= #1 1'b0;
|
hitmiss_eval <= #1 1'b0;
|
store <= #1 1'b0;
|
store <= #1 1'b0;
|
|
cache_inhibit <= #1 1'b0;
|
|
end
|
|
else if ((cache_inhibit | dcdmmu_ci_i) & biudata_valid) begin // store to cache-inhibited area
|
|
state <= #1 `OR1200_DCFSM_IDLE;
|
|
hitmiss_eval <= #1 1'b0;
|
|
store <= #1 1'b0;
|
|
cache_inhibit <= #1 1'b0;
|
end
|
end
|
`ifdef OR1200_DC_STORE_REFILL
|
`ifdef OR1200_DC_STORE_REFILL
|
else if (tagcomp_miss & biudata_valid) begin // store missed, finish write-through and do load refill
|
else if (tagcomp_miss & biudata_valid) begin // store missed, finish write-through and do load refill
|
state <= #1 `OR1200_DCFSM_SREFILL4;
|
state <= #1 `OR1200_DCFSM_SREFILL4;
|
hitmiss_eval <= #1 1'b0;
|
hitmiss_eval <= #1 1'b0;
|
store <= #1 1'b0;
|
store <= #1 1'b0;
|
load <= #1 1'b1;
|
load <= #1 1'b1;
|
cnt <= #1 `OR1200_DCLS-1;
|
cnt <= #1 `OR1200_DCLS-1;
|
|
cache_inhibit <= #1 1'b0;
|
end
|
end
|
`endif
|
`endif
|
else if (biudata_valid) begin // store hit, finish write-through
|
else if (biudata_valid) begin // store hit, finish write-through
|
state <= #1 `OR1200_DCFSM_IDLE;
|
state <= #1 `OR1200_DCFSM_IDLE;
|
hitmiss_eval <= #1 1'b0;
|
hitmiss_eval <= #1 1'b0;
|
store <= #1 1'b0;
|
store <= #1 1'b0;
|
|
cache_inhibit <= #1 1'b0;
|
end
|
end
|
else // store write-through in-progress
|
else // store write-through in-progress
|
hitmiss_eval <= #1 1'b0;
|
hitmiss_eval <= #1 1'b0;
|
|
end
|
`ifdef OR1200_DC_STORE_REFILL
|
`ifdef OR1200_DC_STORE_REFILL
|
`OR1200_DCFSM_SREFILL4 : begin
|
`OR1200_DCFSM_SREFILL4 : begin
|
if (!dc_en)
|
if (!dc_en)
|
state <= #1 `OR1200_DCFSM_IDLE;
|
state <= #1 `OR1200_DCFSM_IDLE;
|
else if (biudata_valid && (|cnt)) begin // refill ack, more loads to come
|
else if (biudata_valid && (|cnt)) begin // refill ack, more loads to come
|
cnt <= #1 cnt - 'd1;
|
cnt <= #1 cnt - 'd1;
|
saved_addr[3:2] <= #1 saved_addr[3:2] + 'd1;
|
saved_addr_r[3:2] <= #1 saved_addr_r[3:2] + 'd1;
|
end
|
end
|
else if (biudata_valid) begin // last load of line refill
|
else if (biudata_valid) begin // last load of line refill
|
state <= #1 `OR1200_DCFSM_IDLE;
|
state <= #1 `OR1200_DCFSM_IDLE;
|
load <= #1 1'b0;
|
load <= #1 1'b0;
|
end
|
end
|
end
|
end
|
`endif
|
`endif
|
`OR1200_DCFSM_ILOAD: // load from cache-inhibited area
|
|
if (!dc_en)
|
|
state <= #1 `OR1200_DCFSM_IDLE;
|
|
else if (!(dcdmmu_cyc_i & dcdmmu_stb_i)) begin // load aborted (usually caused by DMMU)
|
|
state <= #1 `OR1200_DCFSM_IDLE;
|
|
hitmiss_eval <= #1 1'b0;
|
|
load <= #1 1'b0;
|
|
end
|
|
else if (biudata_error) begin // load terminated with an error
|
|
state <= #1 `OR1200_DCFSM_IDLE;
|
|
hitmiss_eval <= #1 1'b0;
|
|
load <= #1 1'b0;
|
|
end
|
|
else if (biudata_valid) begin // load from cache inhibit page
|
|
state <= #1 `OR1200_DCFSM_IDLE;
|
|
hitmiss_eval <= #1 1'b0;
|
|
load <= #1 1'b0;
|
|
end
|
|
else // load in-progress
|
|
hitmiss_eval <= #1 1'b0;
|
|
`OR1200_DCFSM_ISTORE: // store to cache-inhibited area
|
|
if (!dc_en)
|
|
state <= #1 `OR1200_DCFSM_IDLE;
|
|
else if (!(dcdmmu_cyc_i & dcdmmu_stb_i)) begin // store aborted (usually caused by DMMU)
|
|
state <= #1 `OR1200_DCFSM_IDLE;
|
|
hitmiss_eval <= #1 1'b0;
|
|
store <= #1 1'b0;
|
|
end
|
|
else if (biudata_error) begin // store terminated with an error
|
|
state <= #1 `OR1200_DCFSM_IDLE;
|
|
hitmiss_eval <= #1 1'b0;
|
|
store <= #1 1'b0;
|
|
end
|
|
else if (biudata_valid) begin // store to cache inhibit page
|
|
state <= #1 `OR1200_DCFSM_IDLE;
|
|
hitmiss_eval <= #1 1'b0;
|
|
store <= #1 1'b0;
|
|
end
|
|
else // store write-through in-progress
|
|
hitmiss_eval <= #1 1'b0;
|
|
default:
|
default:
|
state <= #1 `OR1200_DCFSM_IDLE;
|
state <= #1 `OR1200_DCFSM_IDLE;
|
endcase
|
endcase
|
end
|
end
|
|
|