Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / design / sys / iop / niu / rtl / niu_ipp_ffl_arbiter.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: niu_ipp_ffl_arbiter.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/**********************************************************
37***********************************************************
38
39 Project : Niu
40
41 File name : niu_ipp_ffl_arbiter.v
42
43 Module(s) name : niu_ipp_ffl_arbiter
44 Original: : ipp_arbiter.v main.32, label: IPP_RTL_2.3 IPP_VERIF_2.5
45
46 Parent modules : niu_ipp_top.v
47
48 Child modules :
49
50 Author's name : Jonathan Shen, George Chu
51
52 Date : Jan. 2002
53
54 Description : 4_to_1 round-robin arbiter for fflp.
55
56 Synthesis Notes:
57
58 Modification History:
59
60 Date Description
61 ---- -----------
62
63************************************************************
64***********************************************************/
65
66module niu_ipp_ffl_arbiter(
67/****** input ******/
68 ipp_ffl_req0,
69 ipp_fflp_data0,
70 ipp_fflp_mac_default0,
71 ipp_fflp_dvalid0,
72 ipp_ffl_req1,
73 ipp_fflp_data1,
74 ipp_fflp_mac_default1,
75 ipp_fflp_dvalid1,
76`ifdef NEPTUNE
77 ipp_ffl_req2,
78 ipp_fflp_data2,
79 ipp_fflp_mac_default2,
80 ipp_fflp_dvalid2,
81 ipp_ffl_req3,
82 ipp_fflp_data3,
83 ipp_fflp_mac_default3,
84 ipp_fflp_dvalid3,
85`endif
86 reset, clk,
87/****** output ******/
88 ffl_arb_ack0,
89 ffl_arb_ack1,
90`ifdef NEPTUNE
91 ffl_arb_ack2,
92 ffl_arb_ack3,
93`endif
94 ipp_fflp_dvalid,
95 ipp_fflp_data,
96 ipp_fflp_port,
97 ipp_fflp_mac_default
98 );
99
100/* Zin arbiter
101 -req ipp_ffl_req0 ipp_ffl_req1 ipp_ffl_req2 ipp_ffl_req3
102 -gnt ffl_arb_ack0_pre ffl_arb_ack1_pre ffl_arb_ack2_pre ffl_arb_ack3_pre
103 -clock clk -reset reset -message "IPP_FFL arbiter"
104*/
105
106input ipp_ffl_req0;
107input [127:0] ipp_fflp_data0;
108input [11:0] ipp_fflp_mac_default0;
109input ipp_fflp_dvalid0;
110
111input ipp_ffl_req1;
112input [127:0] ipp_fflp_data1;
113input [11:0] ipp_fflp_mac_default1;
114input ipp_fflp_dvalid1;
115
116`ifdef NEPTUNE
117input ipp_ffl_req2;
118input [127:0] ipp_fflp_data2;
119input [11:0] ipp_fflp_mac_default2;
120input ipp_fflp_dvalid2;
121
122input ipp_ffl_req3;
123input [127:0] ipp_fflp_data3;
124input [11:0] ipp_fflp_mac_default3;
125input ipp_fflp_dvalid3;
126`endif
127
128input reset;
129input clk;
130
131output ffl_arb_ack0;
132output ffl_arb_ack1;
133`ifdef NEPTUNE
134output ffl_arb_ack2;
135output ffl_arb_ack3;
136`endif
137
138output ipp_fflp_dvalid;
139output [127:0] ipp_fflp_data;
140output [1:0] ipp_fflp_port;
141output [11:0] ipp_fflp_mac_default;
142
143reg ffl_arb_ack0_pre;
144reg ffl_arb_ack1_pre;
145`ifdef NEPTUNE
146reg ffl_arb_ack2_pre;
147reg ffl_arb_ack3_pre;
148`endif
149reg ipp_fflp_dvalid_pre;
150reg [127:0] ipp_fflp_data_pre;
151reg [1:0] ipp_fflp_port_pre;
152reg [11:0] ipp_fflp_mac_default_pre;
153
154wire ffl_arb_ack0;
155wire ffl_arb_ack1;
156`ifdef NEPTUNE
157wire ffl_arb_ack2;
158wire ffl_arb_ack3;
159`endif
160wire ipp_fflp_dvalid;
161wire [127:0] ipp_fflp_data;
162wire [1:0] ipp_fflp_port;
163wire [11:0] ipp_fflp_mac_default;
164
165`ifdef NEPTUNE
166reg [1:0] cur_state;
167reg [1:0] nex_state;
168
169wire [3:0] sel;
170assign sel[0] = ffl_arb_ack0;
171assign sel[1] = ffl_arb_ack1;
172assign sel[2] = ffl_arb_ack2;
173assign sel[3] = ffl_arb_ack3;
174
175parameter
176StIpp0 = 2'h0,
177StIpp1 = 2'h1,
178StIpp2 = 2'h2,
179StIpp3 = 2'h3;
180
181/****** state machine ******/
182// comb part
183
184always @ (ipp_ffl_req0 or ipp_ffl_req1 or ipp_ffl_req2 or
185 ipp_ffl_req3 or cur_state)
186 begin
187 ffl_arb_ack0_pre = 0;
188 ffl_arb_ack1_pre = 0;
189 ffl_arb_ack2_pre = 0;
190 ffl_arb_ack3_pre = 0;
191
192 case (cur_state) // synopsys parallel_case full_case
193
194 StIpp0:
195 if (ipp_ffl_req0 == 1'h1)
196 begin
197 ffl_arb_ack0_pre = 1;
198 nex_state = cur_state;
199 end
200 else if (ipp_ffl_req1 == 1'h1)
201 nex_state = StIpp1;
202 else if (ipp_ffl_req2 == 1'h1)
203 nex_state = StIpp2;
204 else if (ipp_ffl_req3 == 1'h1)
205 nex_state = StIpp3;
206 else
207 nex_state = StIpp0;
208
209 StIpp1:
210 if (ipp_ffl_req1 == 1'h1)
211 begin
212 ffl_arb_ack1_pre = 1;
213 nex_state = cur_state;
214 end
215 else if (ipp_ffl_req2 == 1'h1)
216 nex_state = StIpp2;
217 else if (ipp_ffl_req3 == 1'h1)
218 nex_state = StIpp3;
219 else if (ipp_ffl_req0 == 1'h1)
220 nex_state = StIpp0;
221 else
222 nex_state = StIpp1;
223
224 StIpp2:
225 if (ipp_ffl_req2 == 1'h1)
226 begin
227 ffl_arb_ack2_pre = 1;
228 nex_state = cur_state;
229 end
230 else if (ipp_ffl_req3 == 1'h1)
231 nex_state = StIpp3;
232 else if (ipp_ffl_req0 == 1'h1)
233 nex_state = StIpp0;
234 else if (ipp_ffl_req1 == 1'h1)
235 nex_state = StIpp1;
236 else
237 nex_state = StIpp2;
238
239 StIpp3:
240 if (ipp_ffl_req3 == 1'h1)
241 begin
242 ffl_arb_ack3_pre = 1;
243 nex_state = cur_state;
244 end
245 else if (ipp_ffl_req0 == 1'h1)
246 nex_state = StIpp0;
247 else if (ipp_ffl_req1 == 1'h1)
248 nex_state = StIpp1;
249 else if (ipp_ffl_req2 == 1'h1)
250 nex_state = StIpp2;
251 else
252 nex_state = StIpp3;
253
254 endcase
255 end
256
257// seq part
258always @ (posedge clk)
259 if (reset)
260 cur_state[1:0] <= 2'h0;
261 else
262 cur_state[1:0] <= nex_state[1:0];
263
264/****** end of state machine ******/
265
266/****** 4:1 mux for ipp_fflp_dvalid ******/
267always @ (sel or ipp_fflp_dvalid0 or ipp_fflp_dvalid1 or ipp_fflp_dvalid2
268 or ipp_fflp_dvalid3)
269 case (sel[3:0]) // synopsys parallel_case full_case
270 4'b0001: ipp_fflp_dvalid_pre = ipp_fflp_dvalid0;
271 4'b0010: ipp_fflp_dvalid_pre = ipp_fflp_dvalid1;
272 4'b0100: ipp_fflp_dvalid_pre = ipp_fflp_dvalid2;
273 4'b1000: ipp_fflp_dvalid_pre = ipp_fflp_dvalid3;
274 default: ipp_fflp_dvalid_pre = ipp_fflp_dvalid0;
275 endcase
276
277/****** 4:1 mux for data ******/
278always @ (sel or ipp_fflp_data0 or ipp_fflp_data1 or ipp_fflp_data2
279 or ipp_fflp_data3)
280 case (sel[3:0]) // synopsys parallel_case full_case
281 4'b0001: ipp_fflp_data_pre[127:0] = ipp_fflp_data0[127:0];
282 4'b0010: ipp_fflp_data_pre[127:0] = ipp_fflp_data1[127:0];
283 4'b0100: ipp_fflp_data_pre[127:0] = ipp_fflp_data2[127:0];
284 4'b1000: ipp_fflp_data_pre[127:0] = ipp_fflp_data3[127:0];
285 default: ipp_fflp_data_pre[127:0] = ipp_fflp_data0[127:0];
286 endcase
287
288/****** 4:1 mux port ******/
289always @ (sel)
290 case (sel[3:0]) // synopsys parallel_case full_case
291 4'b0001: ipp_fflp_port_pre[1:0] = 2'b00;
292 4'b0010: ipp_fflp_port_pre[1:0] = 2'b01;
293 4'b0100: ipp_fflp_port_pre[1:0] = 2'b10;
294 4'b1000: ipp_fflp_port_pre[1:0] = 2'b11;
295 default: ipp_fflp_port_pre[1:0] = 2'b00;
296 endcase
297
298/****** 4:1 mux for mac_default ******/
299always @ (sel or ipp_fflp_mac_default0 or ipp_fflp_mac_default1 or
300 ipp_fflp_mac_default2 or ipp_fflp_mac_default3)
301 case (sel[3:0]) // synopsys parallel_case full_case
302 4'b0001: ipp_fflp_mac_default_pre[11:0] = ipp_fflp_mac_default0[11:0];
303 4'b0010: ipp_fflp_mac_default_pre[11:0] = ipp_fflp_mac_default1[11:0];
304 4'b0100: ipp_fflp_mac_default_pre[11:0] = ipp_fflp_mac_default2[11:0];
305 4'b1000: ipp_fflp_mac_default_pre[11:0] = ipp_fflp_mac_default3[11:0];
306 default: ipp_fflp_mac_default_pre[11:0] = ipp_fflp_mac_default0[11:0];
307 endcase
308
309 assign ffl_arb_ack0 = ffl_arb_ack0_pre;
310 assign ffl_arb_ack1 = ffl_arb_ack1_pre;
311 assign ffl_arb_ack2 = ffl_arb_ack2_pre;
312 assign ffl_arb_ack3 = ffl_arb_ack3_pre;
313`else
314reg cur_state;
315reg nex_state;
316
317wire [1:0] sel;
318assign sel[0] = ffl_arb_ack0;
319assign sel[1] = ffl_arb_ack1;
320
321parameter
322StIpp0 = 1'h0,
323StIpp1 = 1'h1;
324
325/****** state machine ******/
326// comb part
327
328always @ (ipp_ffl_req0 or ipp_ffl_req1 or
329 cur_state)
330 begin
331 ffl_arb_ack0_pre = 0;
332 ffl_arb_ack1_pre = 0;
333
334 case (cur_state) // synopsys parallel_case full_case
335
336 StIpp0:
337 if (ipp_ffl_req0 == 1'h1)
338 begin
339 ffl_arb_ack0_pre = 1;
340 nex_state = cur_state;
341 end
342 else if (ipp_ffl_req1 == 1'h1)
343 nex_state = StIpp1;
344 else
345 nex_state = StIpp0;
346
347 StIpp1:
348 if (ipp_ffl_req1 == 1'h1)
349 begin
350 ffl_arb_ack1_pre = 1;
351 nex_state = cur_state;
352 end
353 else if (ipp_ffl_req0 == 1'h1)
354 nex_state = StIpp0;
355 else
356 nex_state = StIpp1;
357 endcase
358 end
359
360// seq part
361always @ (posedge clk)
362 if (reset)
363 cur_state <= 1'h0;
364 else
365 cur_state <= nex_state;
366
367/****** end of state machine ******/
368
369/****** 2:1 mux for ipp_fflp_dvalid ******/
370always @ (sel or ipp_fflp_dvalid0 or ipp_fflp_dvalid1)
371 case (sel[1:0]) // synopsys parallel_case
372 2'b01: ipp_fflp_dvalid_pre = ipp_fflp_dvalid0;
373 2'b10: ipp_fflp_dvalid_pre = ipp_fflp_dvalid1;
374 default: ipp_fflp_dvalid_pre = ipp_fflp_dvalid0;
375 endcase
376
377/****** 2:1 mux for data ******/
378always @ (sel or ipp_fflp_data0 or ipp_fflp_data1)
379 case (sel[1:0]) // synopsys parallel_case
380 2'b01: ipp_fflp_data_pre[127:0] = ipp_fflp_data0[127:0];
381 2'b10: ipp_fflp_data_pre[127:0] = ipp_fflp_data1[127:0];
382 default: ipp_fflp_data_pre[127:0] = ipp_fflp_data0[127:0];
383 endcase
384
385/****** 2:1 mux port ******/
386always @ (sel)
387 case (sel[1:0]) // synopsys parallel_case
388 2'b01: ipp_fflp_port_pre[1:0] = 2'b0;
389 2'b10: ipp_fflp_port_pre[1:0] = 2'b1;
390 default: ipp_fflp_port_pre[1:0] = 2'b0;
391 endcase
392
393/****** 2:1 mux for mac_default ******/
394always @ (sel or ipp_fflp_mac_default0 or ipp_fflp_mac_default1)
395 case (sel[1:0]) // synopsys parallel_case full_case
396 2'b01: ipp_fflp_mac_default_pre[11:0] = ipp_fflp_mac_default0[11:0];
397 2'b10: ipp_fflp_mac_default_pre[11:0] = ipp_fflp_mac_default1[11:0];
398 default: ipp_fflp_mac_default_pre[11:0] = ipp_fflp_mac_default0[11:0];
399 endcase
400
401 assign ffl_arb_ack0 = ffl_arb_ack0_pre;
402 assign ffl_arb_ack1 = ffl_arb_ack1_pre;
403`endif
404
405 ipp_reg_r_1 reg_r_1_dva (.di(ipp_fflp_dvalid_pre), .rs(reset),.ck(clk),.qo(ipp_fflp_dvalid));
406 ipp_reg_r_128 reg_r_128_dat (.di(ipp_fflp_data_pre[127:0]), .rs(reset),.ck(clk),.qo(ipp_fflp_data[127:0]));
407 ipp_reg_r_2 reg_r_2_por (.di(ipp_fflp_port_pre[1:0]), .rs(reset),.ck(clk),.qo(ipp_fflp_port[1:0]));
408 ipp_reg_r_12 reg_r_12_def (.di(ipp_fflp_mac_default_pre[11:0]),.rs(reset),.ck(clk),.qo(ipp_fflp_mac_default[11:0]));
409
410endmodule