OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel_21/] [or1200/] [rtl/] [verilog/] [or1200_dc_fsm.v] - Diff between revs 617 and 636

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 617 Rev 636
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: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.
 
//
// 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_DCFSM_IDLE       3'd0
`define OR1200_DCFSM_IDLE       3'd0
`define OR1200_DCFSM_DOLOAD     3'd1
`define OR1200_DCFSM_CLOAD      3'd1
`define OR1200_DCFSM_LREFILL3   3'd2
`define OR1200_DCFSM_LREFILL3   3'd2
`define OR1200_DCFSM_DOSTORE    3'd3
`define OR1200_DCFSM_CSTORE     3'd3
`define OR1200_DCFSM_SREFILL4   3'd4
`define OR1200_DCFSM_SREFILL4   3'd4
 
`define OR1200_DCFSM_ILOAD      3'd5
 
`define OR1200_DCFSM_ISTORE     3'd6
 
 
//
//
// Data cache FSM for cache line of 16 bytes (4x singleword)
// Data cache FSM for cache line of 16 bytes (4x singleword)
//
//
 
 
Line 127... Line 132...
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;
 
wire                            first_store_hit_ack;
 
 
//
//
// Generate of DCRAM write enables
// Generate of DCRAM write enables
//
//
assign dcram_we = {4{load & biudata_valid}} | {4{store & biudata_valid}} & dcpu_sel_i;
assign dcram_we = {4{load & biudata_valid & (state != `OR1200_DCFSM_ILOAD)}} | {4{first_store_hit_ack}} & dcpu_sel_i;
 
 
//
//
// 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;
 
 
//
//
// Assert for cache hit first word ready
// Assert for 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_DOLOAD) & !tagcomp_miss & !dcdmmu_ci_i | (state == `OR1200_DCFSM_DOSTORE) & !tagcomp_miss & biudata_valid;
assign first_hit_ack = (state == `OR1200_DCFSM_CLOAD) & !tagcomp_miss | first_store_hit_ack;
assign first_miss_ack = ((state == `OR1200_DCFSM_DOLOAD) | (state == `OR1200_DCFSM_DOSTORE)) & (tagcomp_miss | dcdmmu_ci_i) & biudata_valid;
assign first_store_hit_ack = (state == `OR1200_DCFSM_CSTORE) & !tagcomp_miss & biudata_valid;
assign first_miss_err = ((state == `OR1200_DCFSM_DOLOAD) | (state == `OR1200_DCFSM_DOSTORE)) & (tagcomp_miss | dcdmmu_ci_i) & biudata_error;
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_err = ((state == `OR1200_DCFSM_CLOAD) | (state == `OR1200_DCFSM_CSTORE) | (state == `OR1200_DCFSM_ILOAD) | (state == `OR1200_DCFSM_ISTORE)) & 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_DOLOAD) & tagcomp_miss
assign burst = (state == `OR1200_DCFSM_CLOAD) & tagcomp_miss
                | (state == `OR1200_DCFSM_LREFILL3) | (state == `OR1200_DCFSM_SREFILL4);
                | (state == `OR1200_DCFSM_LREFILL3)
 
`ifdef OR1200_DC_STORE_REFILL
 
                | (state == `OR1200_DCFSM_SREFILL4)
 
`endif
 
                ;
 
 
//
//
// Main DC FSM
// Main DC FSM
//
//
always @(posedge clk or posedge rst) begin
always @(posedge clk or posedge rst) begin
Line 169... Line 181...
                cnt <= #1 3'b000;
                cnt <= #1 3'b000;
        end
        end
        else
        else
        case (state)    // synopsys parallel_case
        case (state)    // synopsys parallel_case
                `OR1200_DCFSM_IDLE :
                `OR1200_DCFSM_IDLE :
                        if (dc_en & dcdmmu_cyc_i & dcdmmu_stb_i & dcpu_we_i) begin      // store
                        if (dc_en & dcdmmu_ci_i & dcdmmu_cyc_i & dcdmmu_stb_i & dcpu_we_i) begin        // store to cache-inhibited area
                                state <= #1 `OR1200_DCFSM_DOSTORE;
                                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;
                                saved_addr <= #1 start_addr;
                                saved_addr <= #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;
                        end
                        end
                        else if (dc_en & dcdmmu_cyc_i & dcdmmu_stb_i) begin             // load
                        else if (dc_en & dcdmmu_cyc_i & dcdmmu_stb_i) begin             // load from cached area
                                state <= #1 `OR1200_DCFSM_DOLOAD;
                                state <= #1 `OR1200_DCFSM_CLOAD;
                                saved_addr <= #1 start_addr;
                                saved_addr <= #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;
                        end
                        end
Line 189... Line 215...
                                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;
                        end
                        end
                `OR1200_DCFSM_DOLOAD:
                `OR1200_DCFSM_CLOAD:            // load from cached area
                        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_cyc_i & dcdmmu_stb_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;
Line 202... Line 228...
                        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;
                        end
                        end
                        else if (dcdmmu_ci_i & biudata_valid) begin     // load from cache inhibit page
 
                                state <= #1 `OR1200_DCFSM_IDLE;
 
                                hitmiss_eval <= #1 1'b0;
 
                                load <= #1 1'b0;
 
                        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[3:2] <= #1 saved_addr[3:2] + 'd1;
                                hitmiss_eval <= #1 1'b0;
                                hitmiss_eval <= #1 1'b0;
                                cnt <= #1 `OR1200_DCLS-2;
                                cnt <= #1 `OR1200_DCLS-2;
                        end
                        end
                        else if (!tagcomp_miss & !dcdmmu_ci_i) begin    // load hit and not cache inhibit, finish immediately
                        else if (!tagcomp_miss) 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;
                        end
                        end
                        else                                            // load in-progress
                        else                                            // load in-progress
Line 232... Line 253...
                        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_DOSTORE:
                `OR1200_DCFSM_CSTORE:           // store to cached area
                        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_cyc_i & dcdmmu_stb_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;
Line 245... Line 266...
                        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;
                        end
                        end
                        else if (dcdmmu_ci_i & biudata_valid) begin     // store to cache inhibit page
`ifdef OR1200_DC_STORE_REFILL
                                state <= #1 `OR1200_DCFSM_IDLE;
 
                                hitmiss_eval <= #1 1'b0;
 
                                store <= #1 1'b0;
 
                        end
 
                        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;
                        end
                        end
 
`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;
                        end
                        end
                        else                                            // store write-through in-progress
                        else                                            // store write-through in-progress
                                hitmiss_eval <= #1 1'b0;
                                hitmiss_eval <= #1 1'b0;
 
`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;
Line 276... Line 295...
                        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
 
                `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
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.