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

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel_25/] [or1200/] [rtl/] [verilog/] [or1200_ic_fsm.v] - Diff between revs 1163 and 1171

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

Rev 1163 Rev 1171
Line 4... Line 4...
////                                                              ////
////                                                              ////
////  This file is part of the OpenRISC 1200 project              ////
////  This file is part of the OpenRISC 1200 project              ////
////  http://www.opencores.org/cores/or1k/                        ////
////  http://www.opencores.org/cores/or1k/                        ////
////                                                              ////
////                                                              ////
////  Description                                                 ////
////  Description                                                 ////
////  Data cache state machine                                    ////
////  Insn cache state machine                                    ////
////                                                              ////
////                                                              ////
////  To Do:                                                      ////
////  To Do:                                                      ////
////   - make it smaller and faster                               ////
////   - make it smaller and faster                               ////
////                                                              ////
////                                                              ////
////  Author(s):                                                  ////
////  Author(s):                                                  ////
Line 42... Line 42...
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//
//
// CVS Revision History
// CVS Revision History
//
//
// $Log: not supported by cvs2svn $
// $Log: not supported by cvs2svn $
 
// Revision 1.8  2003/06/06 02:54:47  lampret
 
// When OR1200_NO_IMMU and OR1200_NO_IC are not both defined or undefined at the same time, results in a IC bug. Fixed.
 
//
// Revision 1.7  2002/03/29 15:16:55  lampret
// Revision 1.7  2002/03/29 15:16:55  lampret
// Some of the warnings fixed.
// Some of the warnings fixed.
//
//
// Revision 1.6  2002/03/28 19:10:40  lampret
// Revision 1.6  2002/03/28 19:10:40  lampret
// Optimized cache controller FSM.
// Optimized cache controller FSM.
Line 106... Line 109...
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, icimmu_cycstb_i, icimmu_ci_i,
        ic_en, icqmem_cycstb_i, icqmem_ci_i,
        tagcomp_miss, biudata_valid, biudata_error, start_addr, saved_addr,
        tagcomp_miss, biudata_valid, biudata_error, start_addr, saved_addr,
        icram_we, biu_read, first_hit_ack, first_miss_ack, first_miss_err,
        icram_we, biu_read, first_hit_ack, first_miss_ack, first_miss_err,
        burst, tag_we
        burst, tag_we
);
);
 
 
Line 118... Line 121...
// I/O
// I/O
//
//
input                           clk;
input                           clk;
input                           rst;
input                           rst;
input                           ic_en;
input                           ic_en;
input                           icimmu_cycstb_i;
input                           icqmem_cycstb_i;
input                           icimmu_ci_i;
input                           icqmem_ci_i;
input                           tagcomp_miss;
input                           tagcomp_miss;
input                           biudata_valid;
input                           biudata_valid;
input                           biudata_error;
input                           biudata_error;
input   [31:0]                   start_addr;
input   [31:0]                   start_addr;
output  [31:0]                   saved_addr;
output  [31:0]                   saved_addr;
Line 162... Line 165...
//
//
// 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_CFETCH) & hitmiss_eval & !tagcomp_miss & !cache_inhibit & !icimmu_ci_i;
assign first_hit_ack = (state == `OR1200_ICFSM_CFETCH) & hitmiss_eval & !tagcomp_miss & !cache_inhibit & !icqmem_ci_i;
assign first_miss_ack = (state == `OR1200_ICFSM_CFETCH) & biudata_valid;
assign first_miss_ack = (state == `OR1200_ICFSM_CFETCH) & biudata_valid;
assign first_miss_err = (state == `OR1200_ICFSM_CFETCH) & biudata_error;
assign first_miss_err = (state == `OR1200_ICFSM_CFETCH) & biudata_error;
 
 
//
//
// Assert burst when doing reload of complete cache line
// Assert burst when doing reload of complete cache line
Line 187... Line 190...
                cache_inhibit <= #1 1'b0;
                cache_inhibit <= #1 1'b0;
        end
        end
        else
        else
        case (state)    // synopsys parallel_case
        case (state)    // synopsys parallel_case
                `OR1200_ICFSM_IDLE :
                `OR1200_ICFSM_IDLE :
                        if (ic_en & icimmu_cycstb_i) begin              // fetch
                        if (ic_en & icqmem_cycstb_i) begin              // fetch
                                state <= #1 `OR1200_ICFSM_CFETCH;
                                state <= #1 `OR1200_ICFSM_CFETCH;
                                saved_addr_r <= #1 start_addr;
                                saved_addr_r <= #1 start_addr;
                                hitmiss_eval <= #1 1'b1;
                                hitmiss_eval <= #1 1'b1;
                                load <= #1 1'b1;
                                load <= #1 1'b1;
                                cache_inhibit <= #1 1'b0;
                                cache_inhibit <= #1 1'b0;
Line 200... Line 203...
                                hitmiss_eval <= #1 1'b0;
                                hitmiss_eval <= #1 1'b0;
                                load <= #1 1'b0;
                                load <= #1 1'b0;
                                cache_inhibit <= #1 1'b0;
                                cache_inhibit <= #1 1'b0;
                        end
                        end
                `OR1200_ICFSM_CFETCH: begin     // fetch
                `OR1200_ICFSM_CFETCH: begin     // fetch
                        if (icimmu_cycstb_i & icimmu_ci_i)
                        if (icqmem_cycstb_i & icqmem_ci_i)
                                cache_inhibit <= #1 1'b1;
                                cache_inhibit <= #1 1'b1;
                        if (hitmiss_eval)
                        if (hitmiss_eval)
                                saved_addr_r[31:13] <= #1 start_addr[31:13];
                                saved_addr_r[31:13] <= #1 start_addr[31:13];
                        if ((!ic_en) ||
                        if ((!ic_en) ||
                            (hitmiss_eval & !icimmu_cycstb_i) ||        // fetch aborted (usually caused by IMMU)
                            (hitmiss_eval & !icqmem_cycstb_i) ||        // fetch aborted (usually caused by IMMU)
                            (biudata_error) ||                                          // fetch terminated with an error
                            (biudata_error) ||                                          // fetch terminated with an error
                            (cache_inhibit & biudata_valid)) begin      // fetch from cache-inhibited page
                            (cache_inhibit & biudata_valid)) begin      // fetch from cache-inhibited page
                                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;
                                cache_inhibit <= #1 1'b0;
                                cache_inhibit <= #1 1'b0;
                        end
                        end
                        else if (tagcomp_miss & biudata_valid) begin    // fetch missed, finish current external fetch 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_r[3:2] <= #1 saved_addr_r[3:2] + 'd1;
                                saved_addr_r[3:2] <= #1 saved_addr_r[3:2] + 1'd1;
                                hitmiss_eval <= #1 1'b0;
                                hitmiss_eval <= #1 1'b0;
                                cnt <= #1 `OR1200_ICLS-2;
                                cnt <= #1 `OR1200_ICLS-2;
                                cache_inhibit <= #1 1'b0;
                                cache_inhibit <= #1 1'b0;
                        end
                        end
                        else if (!tagcomp_miss & !icimmu_ci_i) begin    // fetch hit, finish immediately
                        else if (!tagcomp_miss & !icqmem_ci_i) begin    // fetch hit, finish immediately
                                saved_addr_r <= #1 start_addr;
                                saved_addr_r <= #1 start_addr;
                                cache_inhibit <= #1 1'b0;
                                cache_inhibit <= #1 1'b0;
                        end
                        end
                        else if (!icimmu_cycstb_i) begin        // fetch aborted (usually caused by exception)
                        else if (!icqmem_cycstb_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;
                                cache_inhibit <= #1 1'b0;
                                cache_inhibit <= #1 1'b0;
                        end
                        end
                        else                                            // fetch in-progress
                        else                                            // fetch in-progress
                                hitmiss_eval <= #1 1'b0;
                                hitmiss_eval <= #1 1'b0;
                end
                end
                `OR1200_ICFSM_LREFILL3 : begin
                `OR1200_ICFSM_LREFILL3 : begin
                        if (biudata_valid && (|cnt)) begin              // refill ack, more fetchs to come
                        if (biudata_valid && (|cnt)) begin              // refill ack, more fetchs to come
                                cnt <= #1 cnt - 'd1;
                                cnt <= #1 cnt - 1'd1;
                                saved_addr_r[3:2] <= #1 saved_addr_r[3:2] + 'd1;
                                saved_addr_r[3:2] <= #1 saved_addr_r[3:2] + 1'd1;
                        end
                        end
                        else if (biudata_valid) begin                   // last fetch 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_r <= #1 start_addr;
                                saved_addr_r <= #1 start_addr;
                                hitmiss_eval <= #1 1'b0;
                                hitmiss_eval <= #1 1'b0;

powered by: WebSVN 2.1.0

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