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

Subversion Repositories or1k

[/] [or1k/] [branches/] [mp3_stable/] [or1200/] [rtl/] [verilog/] [frz_logic.v] - Diff between revs 205 and 209

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

Rev 205 Rev 209
Line 69... Line 69...
module frz_logic(
module frz_logic(
        // Clock and reset
        // Clock and reset
        clk, rst,
        clk, rst,
 
 
        // Internal i/f
        // Internal i/f
        multicycle, except_flushpipe, lsu_stall, if_stall, dclsu_unstall, branch_stall, force_dslot_fetch,
        multicycle, except_flushpipe, lsu_stall, if_stall,
 
        dclsu_unstall, branch_stall, du_stall, mac_stall,
 
        force_dslot_fetch,
        if_freeze, id_freeze, ex_freeze, wb_freeze
        if_freeze, id_freeze, ex_freeze, wb_freeze
);
);
 
 
//
//
// I/O
// I/O
Line 85... Line 87...
input                           lsu_stall;
input                           lsu_stall;
input                           if_stall;
input                           if_stall;
input                           dclsu_unstall;
input                           dclsu_unstall;
input                           branch_stall;
input                           branch_stall;
input                           force_dslot_fetch;
input                           force_dslot_fetch;
 
input                           du_stall;
 
input                           mac_stall;
output                          if_freeze;
output                          if_freeze;
output                          id_freeze;
output                          id_freeze;
output                          ex_freeze;
output                          ex_freeze;
output                          wb_freeze;
output                          wb_freeze;
 
 
//
//
// Internal wires and regs
// Internal wires and regs
//
//
reg                             multicycle_freeze;
reg                             multicycle_freeze;
reg     [1:0]                    state;
 
reg     [2:0]                    state2;
reg     [2:0]                    state2;
reg     [2:0]                    multicycle_cnt;
reg     [2:0]                    multicycle_cnt;
reg                             done_once;
reg                             done_once;
 
 
//
//
// Pipeline freeze
// Pipeline freeze
//
//
assign if_freeze = id_freeze;
// Rules how to create freeze signals:
assign id_freeze = (lsu_stall | (~dclsu_unstall & if_stall) | multicycle_freeze | force_dslot_fetch) & ~except_flushpipe;
// 1. Not overwriting pipeline stages:
assign ex_freeze = (lsu_stall | (~dclsu_unstall & if_stall) | multicycle_freeze) & ~except_flushpipe;
// Frreze signals at the beginning of pipeline (such as if_freeze) can be asserted more
assign wb_freeze = (lsu_stall | (~dclsu_unstall & if_stall) | multicycle_freeze) & ~except_flushpipe;
// often than freeze signals at the of pipeline (such as wb_freeze). In other words, wb_freeze must never
 
// be asserted when ex_freeze is not. ex_freeze must never be asserted when id_freeze is not etc.
 
//
 
// 2. Inserting NOPs in the middle of pipeline only if supported:
 
// At this time, only ex_freeze (and wb_freeze) can be deassrted when id_freeze (and if_freeze) are asserted.
 
// This way NOP is asserted from stage ID into EX stage.
//
//
// Freeze FSM1
assign if_freeze = id_freeze;
//
assign id_freeze = (lsu_stall | (~dclsu_unstall & if_stall) | multicycle_freeze | force_dslot_fetch) & ~except_flushpipe | du_stall;
always @(posedge clk or posedge rst) begin
assign ex_freeze = wb_freeze;
        if (rst) begin
assign wb_freeze = (lsu_stall | (~dclsu_unstall & if_stall) | multicycle_freeze) & ~except_flushpipe | du_stall | mac_stall;
                state <= #1 `NO_FREEZE;
 
        end
 
        else
 
                case (state)    // synopsys full_case parallel_case
 
                `NO_FREEZE :
 
                        if (lsu_stall) begin
 
                                state <= #1 `FREEZE_BYDC;
 
                        end
 
                `FREEZE_BYDC :
 
                        if (!lsu_stall) begin
 
                                state <= #1 `NO_FREEZE;
 
                        end
 
        endcase
 
end
 
 
 
//
//
// Freeze FSM2
// Freeze FSM2
//
//
always @(posedge clk or posedge rst) begin
always @(posedge clk or posedge rst) begin
Line 169... Line 162...
                        else begin
                        else begin
                                state2 <= #1 `NO_FREEZE;
                                state2 <= #1 `NO_FREEZE;
                                multicycle_freeze <= #1 1'b0;
                                multicycle_freeze <= #1 1'b0;
                        end
                        end
                `WAIT_LSU_TO_FINISH:
                `WAIT_LSU_TO_FINISH:
                        if (!lsu_stall && !multicycle) begin
                        if (!lsu_stall && !(|multicycle)) begin
                                state2 <= #1 `NO_FREEZE;
                                state2 <= #1 `NO_FREEZE;
                        end
                        end
                        else if (!lsu_stall && multicycle) begin
                        else if (!lsu_stall & (|multicycle)) begin
                                state2 <= #1 `FREEZE_BYMULTICYCLE;
                                state2 <= #1 `FREEZE_BYMULTICYCLE;
                                multicycle_freeze <= #1 1'b1;
                                multicycle_freeze <= #1 1'b1;
                                multicycle_cnt <= #1 multicycle - 'd1;
                                multicycle_cnt <= #1 multicycle - 'd1;
                        end
                        end
        endcase
        endcase

powered by: WebSVN 2.1.0

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