| 1 | // ========== Copyright Header Begin ========================================== |
| 2 | // |
| 3 | // OpenSPARC T2 Processor File: fflp_fcram_fwd_arb.v |
| 4 | // Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved |
| 5 | // 4150 Network Circle, Santa Clara, California 95054, U.S.A. |
| 6 | // |
| 7 | // * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 8 | // |
| 9 | // This program is free software; you can redistribute it and/or modify |
| 10 | // it under the terms of the GNU General Public License as published by |
| 11 | // the Free Software Foundation; version 2 of the License. |
| 12 | // |
| 13 | // This program is distributed in the hope that it will be useful, |
| 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | // GNU General Public License for more details. |
| 17 | // |
| 18 | // You should have received a copy of the GNU General Public License |
| 19 | // along with this program; if not, write to the Free Software |
| 20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 21 | // |
| 22 | // For the avoidance of doubt, and except that if any non-GPL license |
| 23 | // choice is available it will apply instead, Sun elects to use only |
| 24 | // the General Public License version 2 (GPLv2) at this time for any |
| 25 | // software where a choice of GPL license versions is made |
| 26 | // available with the language indicating that GPLv2 or any later version |
| 27 | // may be used, or where a choice of which version of the GPL is applied is |
| 28 | // otherwise unspecified. |
| 29 | // |
| 30 | // Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 31 | // CA 95054 USA or visit www.sun.com if you need additional information or |
| 32 | // have any questions. |
| 33 | // |
| 34 | // ========== Copyright Header End ============================================ |
| 35 | /**********************************************************************/ |
| 36 | /*project name: NIU */ |
| 37 | /*module name: fflp_fcram_fwd_arb */ |
| 38 | /* */ |
| 39 | /*child modules in: none */ |
| 40 | /*interface modules: */ |
| 41 | /*author name: Jeanne Cai */ |
| 42 | /*date created: 16-03-2004 */ |
| 43 | /* */ |
| 44 | /* Copyright (c) 2004, Sun Microsystems, Inc. */ |
| 45 | /* Sun Proprietary and Confidential */ |
| 46 | /* */ |
| 47 | /*modifications: */ |
| 48 | /**********************************************************************/ |
| 49 | |
| 50 | module fflp_fcram_fwd_arb |
| 51 | ( |
| 52 | cclk, |
| 53 | reset, |
| 54 | fc_fifo_empty_sync, |
| 55 | fc_fifo_fc_lookup, |
| 56 | srch_burst_done, |
| 57 | |
| 58 | fc_lookup_req, |
| 59 | fwd_no_fc_sched_sm, |
| 60 | srch_no_fc_done |
| 61 | |
| 62 | ); |
| 63 | |
| 64 | |
| 65 | input cclk; |
| 66 | input reset; |
| 67 | input fc_fifo_empty_sync; |
| 68 | input fc_fifo_fc_lookup; |
| 69 | input srch_burst_done; |
| 70 | |
| 71 | output fc_lookup_req; |
| 72 | output fwd_no_fc_sched_sm; |
| 73 | output srch_no_fc_done; |
| 74 | |
| 75 | reg fc_lookup_req; |
| 76 | reg inc_wait_cnt; |
| 77 | reg fwd_no_fc_sched_sm; |
| 78 | reg srch_no_fc_done; |
| 79 | reg[1:0] next_state; |
| 80 | |
| 81 | wire[1:0] state; |
| 82 | wire[2:0] wait_cnt; |
| 83 | wire[2:0] wait_cnt_in; |
| 84 | wire wait_cnt_done; |
| 85 | |
| 86 | wire fwd_req; |
| 87 | |
| 88 | |
| 89 | //state machine states |
| 90 | parameter |
| 91 | IDLE = 2'b00, |
| 92 | IDLE_WAIT = 2'b01, |
| 93 | FC_ACC_WAIT = 2'b10; |
| 94 | |
| 95 | always @ (state or fwd_req or fc_fifo_fc_lookup or |
| 96 | srch_burst_done or wait_cnt_done) |
| 97 | |
| 98 | begin |
| 99 | |
| 100 | fc_lookup_req = 1'b0; |
| 101 | inc_wait_cnt = 1'b0; |
| 102 | fwd_no_fc_sched_sm = 1'b0; |
| 103 | srch_no_fc_done = 1'b0; |
| 104 | |
| 105 | case (state) //synopsys parallel_case full_case |
| 106 | // 0in < case -full -parallel -message "0in ERROR: case check in fflp_fcram_fwd_arb" |
| 107 | |
| 108 | IDLE: |
| 109 | begin |
| 110 | if (fwd_req & fc_fifo_fc_lookup) |
| 111 | begin |
| 112 | fc_lookup_req = 1'b1; |
| 113 | fwd_no_fc_sched_sm = 1'b0; |
| 114 | next_state = FC_ACC_WAIT; |
| 115 | end |
| 116 | else if (fwd_req) |
| 117 | begin |
| 118 | fc_lookup_req = 1'b0; |
| 119 | fwd_no_fc_sched_sm = 1'b1; |
| 120 | next_state = IDLE_WAIT; |
| 121 | end |
| 122 | else |
| 123 | begin |
| 124 | fc_lookup_req = 1'b0; |
| 125 | next_state = state; |
| 126 | end |
| 127 | end |
| 128 | |
| 129 | IDLE_WAIT: |
| 130 | begin |
| 131 | inc_wait_cnt = 1'b1; |
| 132 | if (wait_cnt_done) |
| 133 | begin |
| 134 | srch_no_fc_done = 1'b1; |
| 135 | next_state = IDLE; |
| 136 | end |
| 137 | else |
| 138 | begin |
| 139 | srch_no_fc_done = 1'b0; |
| 140 | next_state = state; |
| 141 | end |
| 142 | end |
| 143 | |
| 144 | FC_ACC_WAIT: |
| 145 | begin |
| 146 | fc_lookup_req = 1'b1; |
| 147 | if (srch_burst_done) |
| 148 | next_state = IDLE; |
| 149 | else |
| 150 | next_state = state; |
| 151 | end |
| 152 | |
| 153 | default: |
| 154 | next_state = IDLE; |
| 155 | |
| 156 | endcase |
| 157 | |
| 158 | end |
| 159 | |
| 160 | |
| 161 | dffr #(2) state_reg (cclk, reset, next_state, state); |
| 162 | |
| 163 | |
| 164 | assign wait_cnt_in = wait_cnt_done ? 3'b000 : (wait_cnt + 3'd1); |
| 165 | assign wait_cnt_done = (wait_cnt == 3'b110); |
| 166 | |
| 167 | dffre #(3) wait_cnt_reg (cclk, reset, inc_wait_cnt, wait_cnt_in, wait_cnt); |
| 168 | |
| 169 | assign fwd_req = !fc_fifo_empty_sync; |
| 170 | |
| 171 | |
| 172 | endmodule |