Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / design / sys / iop / dmu / rtl / dmu_tmu_dim_xfrfsm.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: dmu_tmu_dim_xfrfsm.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 ============================================
35module dmu_tmu_dim_xfrfsm (
36 clk,
37 rst_l,
38
39 // ilu <-> dmu-tmu
40 k2y_rcd_deq,
41
42 // RMU interface
43 tm2rm_rcd_enq,
44 rm2tm_rcd_full,
45
46 // internal interface
47 diu_dma_full,
48 diu_int_full,
49
50 int_cl_req,
51
52 rcd_is_msg,
53 rcd_is_msi,
54 rcd_is_cpld,
55 rcd_is_dmawr,
56
57 data_start,
58 data_done,
59
60 rcd_empty,
61 rcd_deq,
62
63 // debug
64 low_dbg_sel_a,
65 low_dbg_sel_b,
66 xfrfsm_dbg_a,
67 xfrfsm_dbg_b,
68
69 // idle check
70 xfrfsm_is_idle,
71 tmu_is_idle);
72
73 //synopsys sync_set_reset "rst_l"
74
75 // >>>>>>>>>>>>>>>>>>>>>>>>> Parameter Declarations <<<<<<<<<<<<<<<<<<<<<<<<<
76
77 // states
78 parameter // summit enum xfr_enum
79 IDLE = 0,
80 DEQ = 1,
81 DATA = 2;
82
83 // state number
84 parameter STATE_NUM = 3;
85
86 // >>>>>>>>>>>>>>>>>>>>>>>>> Port Declarations <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
87
88 //------------------------------------------------------------------------
89 // Clock and Reset Signals
90 //------------------------------------------------------------------------
91 input clk;
92 input rst_l;
93
94 //------------------------------------------------------------------------
95 // record interface to ILU
96 //------------------------------------------------------------------------
97 output k2y_rcd_deq;
98
99 //------------------------------------------------------------------------
100 // RMU interface
101 //------------------------------------------------------------------------
102 output tm2rm_rcd_enq;
103 input rm2tm_rcd_full;
104
105 //------------------------------------------------------------------------
106 // Internal interface
107 //------------------------------------------------------------------------
108 input diu_dma_full; // from bufmgr.v
109 input diu_int_full; // from bufmgr.v
110
111 output int_cl_req; // to bufmgr.v
112
113 input rcd_is_msg; // from rcdbldr.v
114 input rcd_is_msi; // from rcdbldr.v
115 input rcd_is_cpld; // from rcdbldr.v
116 input rcd_is_dmawr; // from rcdbldr.v
117
118 output data_start; // to datafsm.v
119 input data_done; // from datafsm.v
120
121 input rcd_empty; // from rcdbldr.v
122 output rcd_deq; // to rcdbldr.v
123
124 //------------------------------------------------------------------------
125 // debug
126 //------------------------------------------------------------------------
127 input [2:0] low_dbg_sel_a;
128 input [2:0] low_dbg_sel_b;
129 output [`FIRE_DBG_DATA_BITS] xfrfsm_dbg_a;
130 output [`FIRE_DBG_DATA_BITS] xfrfsm_dbg_b;
131
132 //------------------------------------------------------------------------
133 // debug
134 //------------------------------------------------------------------------
135 output xfrfsm_is_idle;
136 input tmu_is_idle;
137
138 // >>>>>>>>>>>>>>>>>>>>>>>>> Data Type Declarations <<<<<<<<<<<<<<<<<<<<<<<<<
139
140 // ~~~~~~~~~~~~~~~~~~~~~~~~~ REGISTER - FLOPS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
141 reg [STATE_NUM-1:0] xfr_state; // 0in one_hot
142 reg data_inprogress; // data fsm is busy
143
144 reg [`FIRE_DBG_DATA_BITS] dbg_bus [0:1];
145
146 // ~~~~~~~~~~~~~~~~~~~~~~~~~ REGISTER - NON-FLOPS ~~~~~~~~~~~~~~~~~~~~~~~~
147 reg [STATE_NUM-1:0] nxt_xfr_state;
148
149 reg [`FIRE_DBG_DATA_BITS] nxt_dbg_bus [0:1];
150 reg [2:0] dbg_sel [0:1];
151
152 // ~~~~~~~~~~~~~~~~~~~~~~~~~ NETS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
153 wire rcd_has_payld;
154 wire diu_no_space;
155
156 integer i;
157 integer j;
158
159 // >>>>>>>>>>>>>>>>>>>>>>>>> Zero In Checkers <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
160
161 // #0in back_pressure -back_pressure rm2tm_rcd_full -xmit_ready tm2rm_rcd_enq -min 1 -max 1
162 // 0in assert_follower -leader rm2tm_rcd_full -follower ~tm2rm_rcd_enq -min 1 -max 1
163
164 /* 0in state -var xfr_state -val (3'b1 << IDLE) -next
165 (3'b1 << IDLE)
166 (3'b1 << DATA)
167 (3'b1 << DEQ) */
168
169 /* 0in state -var xfr_state -val (3'b1 << DATA) -next
170 (3'b1 << DATA)
171 (3'b1 << DEQ) */
172
173 /* 0in state -var xfr_state -val (3'b1 << DEQ) -next
174 (3'b1 << IDLE)
175 (3'b1 << DATA)
176 (3'b1 << DEQ) */
177
178
179 // >>>>>>>>>>>>>>>>>>>>>>>>> RTL/Behavioral Model <<<<<<<<<<<<<<<<<<<<<<<<<<<
180
181 //---------------------------------------------------------------------
182 // FSM
183 //---------------------------------------------------------------------
184
185 // summit state_vector xfr_state enum xfr_enum
186
187 // present xfr_state
188 always @ (posedge clk)
189 if (!rst_l) begin
190 xfr_state <= {STATE_NUM{1'b0}};
191 xfr_state[IDLE] <= 1'b1;
192 end
193 else
194 xfr_state <= nxt_xfr_state;
195
196 // next xfr_state logic
197 assign rcd_has_payld = rcd_is_msi | rcd_is_cpld | rcd_is_dmawr;
198 assign diu_no_space = (rcd_is_dmawr & diu_dma_full) |
199 ((rcd_is_msg | rcd_is_msi) & diu_int_full);
200
201 always @ (xfr_state or rcd_empty or data_inprogress or rm2tm_rcd_full or
202 rcd_has_payld or diu_no_space)
203 begin
204 nxt_xfr_state = {STATE_NUM{1'b0}};
205 case (1'b1) // 0in < case -full // synopsys parallel_case
206
207 xfr_state[IDLE],
208 xfr_state[DEQ]:
209 casez ({rcd_empty, diu_no_space, rm2tm_rcd_full, rcd_has_payld, data_inprogress}) // 0in < case -parallel -full
210 5'b1zzzz,
211 5'b01zzz,
212 5'b00111,
213 5'b0010z,
214 5'b00011: nxt_xfr_state[IDLE] = 1'b1;
215
216 5'b00110: nxt_xfr_state[DATA] = 1'b1;
217
218 5'b00010,
219 5'b0000z: nxt_xfr_state[DEQ] = 1'b1;
220 endcase // casez({rcd_empty, diu_no_space, rm2tm_rcd_full, rcd_has_payld, data_inprogress})
221
222 xfr_state[DATA]:
223 if (rm2tm_rcd_full)
224 begin
225 nxt_xfr_state[DATA] = 1'b1;
226 end
227 else
228 begin
229 nxt_xfr_state[DEQ] = 1'b1;
230 end
231
232 endcase // case(1'b1)
233 end
234
235 // outputs
236 assign rcd_deq = nxt_xfr_state[DEQ];
237 assign tm2rm_rcd_enq = xfr_state[DEQ];
238 assign k2y_rcd_deq = xfr_state[DEQ];
239
240 assign int_cl_req = nxt_xfr_state[DEQ] & (rcd_is_msi | rcd_is_msg);
241
242 assign data_start = (rcd_has_payld & nxt_xfr_state[DEQ] & (~xfr_state[DATA])) |
243 (nxt_xfr_state[DATA] & (~xfr_state[DATA]));
244
245
246 //---------------------------------------------------------------------
247 // data_inprogress flop
248 //---------------------------------------------------------------------
249 always @ (posedge clk)
250 if (!rst_l) data_inprogress <= 1'b0;
251 else if (data_start ^ data_done)
252 if (data_start) data_inprogress <= 1'b1;
253 else data_inprogress <= 1'b0;
254
255
256 //---------------------------------------------------------------------
257 // debug
258 //---------------------------------------------------------------------
259
260 always @ (low_dbg_sel_a or low_dbg_sel_b) begin
261 dbg_sel[0] = low_dbg_sel_a;
262 dbg_sel[1] = low_dbg_sel_b;
263 end
264
265 always @ (dbg_sel[0] or dbg_sel[1] or xfr_state or rcd_has_payld
266 or data_inprogress or rcd_empty or rm2tm_rcd_full or data_done
267 or diu_no_space or rcd_is_dmawr or diu_dma_full or rcd_is_msg
268 or rcd_is_msi or diu_int_full or tmu_is_idle)
269 begin
270 for (i = 0; i < 2; i = i + 1)
271 begin
272 case (dbg_sel[i]) // synopsys infer_mux
273 3'b000: nxt_dbg_bus[i] = {xfr_state, rcd_is_dmawr, diu_dma_full,
274 rcd_is_msg, rcd_is_msi, diu_int_full};
275 3'b001: nxt_dbg_bus[i] = {1'b0, tmu_is_idle, rcd_has_payld,
276 data_inprogress, rcd_empty,
277 rm2tm_rcd_full, diu_no_space, data_done};
278 3'b010: nxt_dbg_bus[i] = 8'h00;
279 3'b011: nxt_dbg_bus[i] = 8'h00;
280 3'b100: nxt_dbg_bus[i] = 8'h00;
281 3'b101: nxt_dbg_bus[i] = 8'h00;
282 3'b110: nxt_dbg_bus[i] = 8'h00;
283 3'b111: nxt_dbg_bus[i] = 8'h00;
284 endcase
285 end
286 end
287
288 assign xfrfsm_dbg_a = dbg_bus[0];
289 assign xfrfsm_dbg_b = dbg_bus[1];
290
291 always @ (posedge clk)
292 if(~rst_l) begin : dbg_rst
293// integer i;
294 for (i = 0; i < 2; i = i + 1) begin
295 dbg_bus[i] <= 8'h00;
296 end
297 end
298 else begin
299 for (j = 0; j < 2; j = j + 1) begin
300 dbg_bus[j] <= nxt_dbg_bus[j];
301 end
302 end
303
304 //---------------------------------------------------------------------
305 // idle check
306 //---------------------------------------------------------------------
307 assign xfrfsm_is_idle = xfr_state[IDLE];
308
309 // >>>>>>>>>>>>>>>>>>>>>>>>> Instantiations <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
310
311endmodule // dmu_tmu_dim_xfrfsm
312
313
314
315