Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: niu_ipp_load.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 | Project : Niu | |
39 | ||
40 | File name : niu_ipp_load.v | |
41 | ||
42 | Module(s) name : niu_ipp_load | |
43 | Original: : ipp_load.v main.45, label: IPP_VERIF_1.84 | |
44 | ||
45 | Parent modules : niu_ipp.v | |
46 | ||
47 | Child modules : niu_ipp_lib.v | |
48 | ||
49 | Author's name : Jonathan Shen, George Chu | |
50 | ||
51 | Date : May 2001 | |
52 | ||
53 | Description : This module loads the 64 bit double word data from | |
54 | MAC/XMAC into ipp fifo. The data will be packed from | |
55 | 64-bit bus to 128-bit bus before loading in IPP Header fifo. | |
56 | The protocol between IPP, XMAC and IPP, big MAC are | |
57 | different. | |
58 | FFLP reads the header part. | |
59 | ||
60 | Synthesis Notes: | |
61 | ||
62 | Modification History: | |
63 | ||
64 | Date Description | |
65 | ---- ----------- | |
66 | ||
67 | ************************************************************ | |
68 | ***********************************************************/ | |
69 | ||
70 | module niu_ipp_load( | |
71 | // input | |
72 | clk, reset, | |
73 | ||
74 | // input from mac | |
75 | mac_ipp_req, xmac_ipp_ack, | |
76 | mac_ipp_data, mac_ipp_tag, | |
77 | mac_ipp_ctrl, mac_ipp_stat, | |
78 | ||
79 | // input from ffl | |
80 | ffl_ipp_ready, | |
81 | ffl_ipp_dvalid, | |
82 | fflp_ipp_sum, | |
83 | ||
84 | // input from ffl_arbiter | |
85 | ffl_arb_ack, | |
86 | ||
87 | port_id, | |
88 | ippfifo_rd_wr_ptr_bypass, | |
89 | ippfifo_wr_ptr_pio_wr_en, | |
90 | eop_from_hdr_fifo, | |
91 | pio_wr_data, | |
92 | fifo_wr_data_reg, | |
93 | fifo_wr_data_reg_wr_en_pls, | |
94 | ipp_enable, xmac_mode, | |
95 | bypass_ffl, | |
96 | vec_cycle1_wr_en, | |
97 | inc_hfifo_dat_rptr, | |
98 | ipp_hfifo_dat_rptr, | |
99 | n_ipp_unload_idle, | |
100 | clr_ipp_unload, | |
101 | ||
102 | // output | |
103 | // output to mac | |
104 | ipp_mac_ack, ipp_xmac_req, | |
105 | ||
106 | // output to ffl | |
107 | ipp_ffl_dvalid, | |
108 | ipp_ffl_mac_default, | |
109 | ||
110 | // outout to ffl_arbiter | |
111 | ipp_ffl_req, | |
112 | ||
113 | // output to ipp fifo | |
114 | fifo_wr_en, fifo_wr_ptr, | |
115 | ipp_hfifo_rden, ipp_hfifo_rptr, | |
116 | ipp_hfifo_dat_empty, | |
117 | fifo_data_in, | |
118 | ipp_ffl_dvalid_n, | |
119 | // output to ipp_post | |
120 | runt, | |
121 | // end of output to ipp post | |
122 | ipp_hfifo_over_run_r, ipp_hfifo_under_run_r, | |
123 | phase_state_xmac, phase_state, | |
124 | phase_state_1st_data, mac_ack_fsm_curstate, | |
125 | ipp_ffl_curstate, | |
126 | cur_pkt_hdr_base_ptr, cur_pkt_ffl_sum_info | |
127 | ); | |
128 | ||
129 | input clk; | |
130 | input reset; | |
131 | input mac_ipp_req; | |
132 | input xmac_ipp_ack; | |
133 | input [63:0] mac_ipp_data; | |
134 | input mac_ipp_tag; | |
135 | input mac_ipp_ctrl; | |
136 | input [22:0] mac_ipp_stat; | |
137 | input ffl_ipp_ready; // from ffl_top module | |
138 | input ffl_ipp_dvalid; // from ffl_top module | |
139 | input [13:0] fflp_ipp_sum; // from ffl_top module | |
140 | input ffl_arb_ack; // from ffl_arb module | |
141 | input ippfifo_rd_wr_ptr_bypass; // from slave | |
142 | input ippfifo_wr_ptr_pio_wr_en; // from slave | |
143 | input eop_from_hdr_fifo; // from ipp | |
144 | input [13:0] pio_wr_data; | |
145 | input [129:0] fifo_wr_data_reg; | |
146 | input fifo_wr_data_reg_wr_en_pls; | |
147 | input [1:0] port_id; | |
148 | input ipp_enable; | |
149 | input xmac_mode; | |
150 | input bypass_ffl; | |
151 | input vec_cycle1_wr_en; | |
152 | input inc_hfifo_dat_rptr; | |
153 | input [6:0] ipp_hfifo_dat_rptr; | |
154 | ||
155 | input n_ipp_unload_idle; | |
156 | input clr_ipp_unload; | |
157 | ||
158 | output ipp_mac_ack; | |
159 | output ipp_xmac_req; // if fifo not full, always high (xmac) | |
160 | output ipp_ffl_req; // to ffl_arb module | |
161 | output ipp_ffl_dvalid; // valid data from ipp to ffl | |
162 | output ipp_ffl_dvalid_n; // valid data from ipp to ffl for par | |
163 | output [11:0] ipp_ffl_mac_default; // control inf. to ffl | |
164 | output ipp_hfifo_dat_empty; | |
165 | output fifo_wr_en; // to ipp_fifo | |
166 | output [6:0] fifo_wr_ptr; // to ipp_fifo | |
167 | output ipp_hfifo_rden; // to ipp_hdr_fifo | |
168 | output [5:0] ipp_hfifo_rptr; // to ipp_hdr_fifo | |
169 | output [129:0] fifo_data_in; // to ipp_fifo | |
170 | output ipp_hfifo_over_run_r; | |
171 | output ipp_hfifo_under_run_r; | |
172 | output [2:0] phase_state_xmac; | |
173 | output [2:0] phase_state; | |
174 | output phase_state_1st_data; | |
175 | output [3:0] mac_ack_fsm_curstate; | |
176 | output [1:0] ipp_ffl_curstate; | |
177 | output runt; | |
178 | output [6:0] cur_pkt_hdr_base_ptr; | |
179 | output [13:0] cur_pkt_ffl_sum_info; | |
180 | ||
181 | wire ipp_hfifo_dat_empty; | |
182 | reg ipp_hfifo_over_run_r; | |
183 | reg ipp_hfifo_under_run_r; | |
184 | reg [6:0] cur_pkt_hdr_base_ptr; | |
185 | reg [13:0] cur_pkt_ffl_sum_info; | |
186 | ||
187 | wire [6:0] ipp_hfifo_dat_empty_space; | |
188 | wire ipp_hfifo_dat_full; | |
189 | wire ipp_hfifo_over_run, n_ipp_hfifo_over_run; | |
190 | wire ipp_hfifo_under_run, n_ipp_hfifo_under_run; | |
191 | wire n_ipp_hfifo_bad_mac_load; | |
192 | reg ipp_hfifo_bad_mac_load; | |
193 | ||
194 | reg ffl_ipp_dvalid_d; | |
195 | ||
196 | reg ipp_mac_ack; | |
197 | reg ipp_mac_ack_d; // use ack delay as internal signal | |
198 | reg ipp_mac_ack_reg1; | |
199 | reg xmac_ack; | |
200 | reg bmac_ack; | |
201 | reg ipp_xmac_req; | |
202 | reg [6:0] fifo_wr_ptr; | |
203 | reg [6:0] wr_base_ptr; // use for rewind pointer like run packet only | |
204 | reg [6:0] hdr_rd_ptr; | |
205 | reg [6:0] hdr_rd_ptr_n; | |
206 | ||
207 | reg [3:0] hdr_count; | |
208 | reg [3:0] hdr_count_n; | |
209 | reg ipp_ffl_req; | |
210 | reg ipp_ffl_req_n; | |
211 | wire ipp_ffl_dvalid; | |
212 | reg ipp_ffl_dvalid_n; | |
213 | wire ipp_ffl_dvalid_n_nxt; | |
214 | wire filtered_tag; | |
215 | wire bmac_ipp_tag; | |
216 | ||
217 | // pipeline register stuff | |
218 | reg [63:0] mac_ipp_data_reg1; | |
219 | reg [131:0] mac_ipp_data_reg2; | |
220 | reg [130:0] xmac_ipp_data_reg2; | |
221 | reg [63:0] mac_ipp_stat_reg; | |
222 | reg [11:0] mac_ipp_ctl_reg; // store the mac ctl word | |
223 | reg mac_ipp_ctrl_reg; // registered the control signal | |
224 | reg mac_ipp_tag_reg1; | |
225 | reg xmac_ipp_ack_d; | |
226 | reg xmac_ipp_ack_reg1; | |
227 | reg [63:0] stage0_dout; | |
228 | reg [63:0] stage1_dout; | |
229 | reg [63:0] xstage0_dout; | |
230 | reg [63:0] xstage1_dout; | |
231 | reg stage0_tout; | |
232 | reg stage1_tout; | |
233 | reg sel; | |
234 | wire valid2; | |
235 | wire valid2_xmac; | |
236 | wire valid2_xmac_pio; | |
237 | wire stat_wr_reg2; | |
238 | wire fifo_wr_en; | |
239 | wire ctlfifo_wr_en; | |
240 | ||
241 | wire load_fifo; | |
242 | wire xload_fifo; | |
243 | ||
244 | wire [129:0] fifo_data_in = (ippfifo_rd_wr_ptr_bypass && valid2) ? | |
245 | mac_ipp_data_reg2[129:0] : | |
246 | (ippfifo_rd_wr_ptr_bypass && valid2_xmac_pio) ? | |
247 | xmac_ipp_data_reg2[129:0] : | |
248 | ((xmac_mode == 1'b0) && (load_fifo == 1'b0)) ? | |
249 | 130'h0 : | |
250 | ((xmac_mode == 1'b1) && (xload_fifo == 1'b0)) ? | |
251 | 130'h0 : | |
252 | xmac_mode ? xmac_ipp_data_reg2[129:0] : | |
253 | mac_ipp_data_reg2[129:0]; | |
254 | ||
255 | wire [5:0] ipp_hfifo_hdr_rptr = hdr_rd_ptr_n[5:0]; // to FFL read ptr | |
256 | wire [5:0] ipp_hfifo_rptr = (n_ipp_unload_idle && !ippfifo_rd_wr_ptr_bypass) ? | |
257 | ipp_hfifo_hdr_rptr[5:0] : ipp_hfifo_dat_rptr[5:0]; | |
258 | wire ipp_hfifo_rden = ipp_ffl_dvalid_n_nxt || inc_hfifo_dat_rptr || | |
259 | ippfifo_rd_wr_ptr_bypass || reset; | |
260 | ||
261 | // for mac_ack_fsm | |
262 | wire n_tag; | |
263 | wire nn_tag; | |
264 | wire [2:0] phase_state; | |
265 | wire [2:0] phase_state_xmac; | |
266 | wire phase_state_1st_data; | |
267 | wire [3:0] mac_ack_fsm_curstate; | |
268 | reg [1:0] ipp_ffl_curstate; | |
269 | reg [1:0] nex_state; | |
270 | wire ipp_ack; | |
271 | // geo: wire mac_tag; | |
272 | reg nn_tag_d; | |
273 | wire tag_err_mac = nn_tag_d & ~bmac_ipp_tag; | |
274 | wire set_tag_err_mac; //geo: from Vega: No load now, leave it for future use | |
275 | ||
276 | // geo: wire fifo_rdy_4rd; | |
277 | wire fifo_rdy_4wr; | |
278 | wire runt; | |
279 | wire hdr_ok_2xfer; | |
280 | wire ctlfifo_rd_dn; | |
281 | wire wr_1st_data; | |
282 | wire swap; | |
283 | wire [1:0] eop_4_fifo; | |
284 | ||
285 | reg [4:0] hdr_ok_2xfer_cnt, n_hdr_ok_2xfer_cnt; | |
286 | wire dec_hdr_ok_2xfer_cnt; | |
287 | wire hdr_ok_2xfer_cnt_gt_eq_1 = |(hdr_ok_2xfer_cnt[4:1]); | |
288 | wire start_hdr_xfer; | |
289 | ||
290 | assign bmac_ipp_tag = xmac_mode ? 1'b0 : mac_ipp_tag; | |
291 | assign filtered_tag = xmac_mode ? (mac_ipp_tag & xmac_ipp_ack): | |
292 | (mac_ipp_tag & ipp_mac_ack_d); | |
293 | /* filtered_tag equals to the and function of tag and delayed ack | |
294 | */ | |
295 | assign valid2 = mac_ipp_data_reg2[130]; | |
296 | assign valid2_xmac = xmac_ack; | |
297 | assign valid2_xmac_pio = xmac_ipp_data_reg2[130]; | |
298 | assign stat_wr_reg2 = xmac_mode ? (xmac_ipp_data_reg2[128] & fifo_wr_en) : | |
299 | (mac_ipp_data_reg2[128] & fifo_wr_en); | |
300 | assign eop_4_fifo = xmac_mode ? xmac_ipp_data_reg2[129:128] : | |
301 | mac_ipp_data_reg2[129:128]; | |
302 | ||
303 | assign fifo_wr_en = ippfifo_rd_wr_ptr_bypass ? (valid2 || valid2_xmac_pio) : | |
304 | xmac_mode ? xload_fifo : load_fifo; | |
305 | ||
306 | //********************************************************** | |
307 | //***** mac_ipp_data pipe and associated control logic ***** | |
308 | //********************************************************** | |
309 | ||
310 | // 1st stage mac_ipp_data pipe | |
311 | wire [63:0] mac_ipp_data_next = (sel == 1'b1) ? mac_ipp_stat_reg[63:0] : | |
312 | mac_ipp_data[63:0]; | |
313 | wire xmac_ipp_ack_next = (sel == 1'b1) ? sel : | |
314 | xmac_ipp_ack; | |
315 | wire mac_ipp_tag_next = (sel == 1'b1) ? sel : | |
316 | filtered_tag; | |
317 | ||
318 | always @ (posedge clk) | |
319 | if (reset) begin | |
320 | xmac_ipp_ack_d <= 1'h0; | |
321 | ipp_mac_ack_d <= 1'h0; | |
322 | xmac_ipp_ack_reg1 <= 1'h0; | |
323 | ipp_mac_ack_reg1 <= 1'h0; | |
324 | mac_ipp_ctrl_reg <= 1'h0; | |
325 | mac_ipp_stat_reg <= 64'h0; | |
326 | //g mac_ipp_ctl_reg <= 12'h0; | |
327 | sel <= 1'h0; | |
328 | mac_ipp_data_reg1 <= 64'h0; | |
329 | mac_ipp_tag_reg1 <= 1'h0; | |
330 | end | |
331 | else | |
332 | begin | |
333 | xmac_ipp_ack_d <= xmac_ipp_ack_next; | |
334 | ipp_mac_ack_d <= ipp_mac_ack; | |
335 | xmac_ipp_ack_reg1 <= xmac_ipp_ack_d; | |
336 | ipp_mac_ack_reg1 <= ipp_mac_ack_d; | |
337 | mac_ipp_ctrl_reg <= mac_ipp_ctrl; | |
338 | ||
339 | if (filtered_tag & xmac_mode) | |
340 | mac_ipp_stat_reg[63:0] <= {41'b0, mac_ipp_stat[22:0]}; | |
341 | //g mac_ipp_ctl_reg[11:0] <= mac_ipp_stat[11:0]; | |
342 | sel <= (filtered_tag && xmac_mode)? 1'h1 : 1'h0; | |
343 | mac_ipp_data_reg1[63:0] <= mac_ipp_data_next[63:0]; | |
344 | mac_ipp_tag_reg1 <= mac_ipp_tag_next; | |
345 | end | |
346 | ||
347 | /******** geo ***********************************************************/ | |
348 | always @ (posedge clk) begin | |
349 | if (reset || mac_ipp_ctrl) begin | |
350 | mac_ipp_ctl_reg <= mac_ipp_stat[11:0] & {12{!reset}}; | |
351 | end | |
352 | else begin | |
353 | mac_ipp_ctl_reg <= mac_ipp_ctl_reg[11:0]; | |
354 | end | |
355 | end | |
356 | /************************************************************************/ | |
357 | ||
358 | // 2nd stage mac_data_in2 pipe, pack the data from 64-bit to 128-bit | |
359 | always @ (posedge clk) | |
360 | begin | |
361 | stage0_dout[63:0] <= mac_ipp_data_reg1[63:0]; | |
362 | stage1_dout[63:0] <= stage0_dout[63:0]; | |
363 | stage0_tout <= mac_ipp_tag_reg1; | |
364 | stage1_tout <= stage0_tout; | |
365 | xmac_ack <= xmac_ipp_ack_reg1; | |
366 | bmac_ack <= ipp_mac_ack_reg1; | |
367 | ||
368 | // for xmac only | |
369 | if (reset) | |
370 | begin | |
371 | xstage0_dout[63:0] <= 64'h0; | |
372 | end | |
373 | else if (xmac_ipp_ack_d) | |
374 | begin | |
375 | xstage0_dout[63:0] <= mac_ipp_data_reg1[63:0]; | |
376 | end | |
377 | else | |
378 | xstage0_dout[63:0] <= xstage0_dout[63:0]; | |
379 | ||
380 | if (reset) | |
381 | begin | |
382 | xstage1_dout[63:0] <= 64'h0; | |
383 | end | |
384 | else if (xmac_ipp_ack_reg1) | |
385 | begin | |
386 | xstage1_dout[63:0] <= xstage0_dout[63:0]; | |
387 | end | |
388 | else | |
389 | xstage1_dout[63:0] <= xstage1_dout[63:0]; | |
390 | ||
391 | if (reset) | |
392 | xmac_ipp_data_reg2[130:0] <= 131'b0; | |
393 | else if (fifo_wr_data_reg_wr_en_pls && xmac_mode) | |
394 | xmac_ipp_data_reg2[130:0] <= {1'b1, fifo_wr_data_reg[129:0]}; | |
395 | else if (xmac_ipp_ack_reg1) | |
396 | xmac_ipp_data_reg2[130:0] <= {1'b0, stage0_tout, stage1_tout, xstage0_dout[63:0], xstage1_dout[63:0]}; | |
397 | else if (xmac_ack & swap) // swap data | |
398 | xmac_ipp_data_reg2[130:0] <= {1'b0, stage0_tout, stage1_tout, xstage1_dout[63:0], xstage0_dout[63:0]}; | |
399 | else | |
400 | xmac_ipp_data_reg2[130:0] <= {1'b0, xmac_ipp_data_reg2[129:0]}; | |
401 | // end of for xmac only | |
402 | ||
403 | if (reset) | |
404 | mac_ipp_data_reg2[131:0] <= 132'h0; | |
405 | else if (fifo_wr_data_reg_wr_en_pls && (xmac_mode == 1'h0)) | |
406 | mac_ipp_data_reg2[131:0] <= {2'b01, fifo_wr_data_reg[129:0]}; | |
407 | else if ((stage0_tout == 1'b0) && (stage1_tout == 1'b1)) | |
408 | mac_ipp_data_reg2[131:0] <= {xmac_ack, bmac_ack, stage0_tout, stage1_tout, 64'h0, stage1_dout[63:0]}; | |
409 | else | |
410 | mac_ipp_data_reg2[131:0] <= {xmac_ack, bmac_ack, stage0_tout, stage1_tout, stage0_dout[63:0], stage1_dout[63:0]}; | |
411 | end | |
412 | ||
413 | //***** end of mac_data_in pipe ***** | |
414 | ||
415 | //***** phase_sm instantiation ***** | |
416 | phase_sm0 xmac_phase_sm_after_packing (.clk(clk), .reset(reset), | |
417 | .valid(valid2_xmac & (!ippfifo_rd_wr_ptr_bypass)), | |
418 | .eop(eop_4_fifo), .swap(swap), | |
419 | .load_fifo(xload_fifo), .phase_state(phase_state_xmac)); | |
420 | ||
421 | phase_sm bmac_phase_sm_after_packing (.clk(clk), .reset(reset), | |
422 | .valid(valid2 & (!ippfifo_rd_wr_ptr_bypass)), .eop(eop_4_fifo), | |
423 | .load_fifo(load_fifo), .phase_state(phase_state)); | |
424 | ||
425 | phase_sm3 phase_sm_1st_data (.clk(clk), .reset(reset), | |
426 | .valid((valid2 | valid2_xmac) & (!ippfifo_rd_wr_ptr_bypass)), | |
427 | .eop(stat_wr_reg2), .wr_1st_data(wr_1st_data), | |
428 | .phase_state(phase_state_1st_data)); | |
429 | ||
430 | //***** ipp_mac_ack shaper ***** | |
431 | mac_ack_fsm mac_ack_fsm_ack (.clk(clk), .reset(reset | ~ipp_enable), | |
432 | .ipp_enable(ipp_enable), | |
433 | .mac_ipp_req(mac_ipp_req), .mac_tag(bmac_ipp_tag), | |
434 | .fifo_rdy_4wr(fifo_rdy_4wr), | |
435 | .tag_err_mac(tag_err_mac), | |
436 | .n_tag(n_tag), .nn_tag(nn_tag), .set_tag_err_mac(set_tag_err_mac), | |
437 | .ipp_ack(ipp_ack), .cur_state(mac_ack_fsm_curstate[3:0])); | |
438 | ||
439 | //***** ack to mac & control signals from mac_ack_fsm ***** | |
440 | always @ (posedge clk) | |
441 | if (reset | (~ipp_enable)) | |
442 | begin | |
443 | ipp_mac_ack <= 0; | |
444 | nn_tag_d <=0; | |
445 | end | |
446 | else | |
447 | begin | |
448 | ipp_mac_ack <= ipp_ack; | |
449 | nn_tag_d <= nn_tag; | |
450 | end | |
451 | ||
452 | //***** end of ack behavior ***** | |
453 | ||
454 | ||
455 | //***** req to xmac ***** | |
456 | always @ (posedge clk) | |
457 | if (reset | (~fifo_rdy_4wr) | (~ipp_enable)) | |
458 | ipp_xmac_req <= 0; | |
459 | else if (fifo_rdy_4wr) | |
460 | ipp_xmac_req <= 1; | |
461 | else | |
462 | ipp_xmac_req <= ipp_xmac_req; | |
463 | //***** end of req behavior ***** | |
464 | ||
465 | //************************************************ | |
466 | //***** Ipp_hdr_fifo and associated control logic ***** | |
467 | //************************************************ | |
468 | ||
469 | //***** Ipp_hdr_fifo Write Pointer ***** | |
470 | always @ (posedge clk) | |
471 | if (reset) | |
472 | fifo_wr_ptr <= 0; | |
473 | else if (ippfifo_rd_wr_ptr_bypass) | |
474 | casex (ippfifo_wr_ptr_pio_wr_en) | |
475 | 1'b0: fifo_wr_ptr <= fifo_wr_ptr; // hold the value | |
476 | 1'b1: fifo_wr_ptr <= pio_wr_data[6:0]; | |
477 | endcase | |
478 | else if (runt) | |
479 | fifo_wr_ptr <= wr_base_ptr; // abort packet; rewind pointer | |
480 | else if (fifo_wr_en) | |
481 | fifo_wr_ptr <= fifo_wr_ptr + 1; // increment | |
482 | else | |
483 | fifo_wr_ptr <= fifo_wr_ptr; // hold the value | |
484 | ||
485 | //***** Ipp_hdr_fifo Write Base Pointer ***** | |
486 | always @ (posedge clk) | |
487 | if (reset) | |
488 | wr_base_ptr <= fifo_wr_ptr; | |
489 | else if (wr_1st_data) | |
490 | wr_base_ptr <= fifo_wr_ptr; // update count | |
491 | else | |
492 | wr_base_ptr <= wr_base_ptr; | |
493 | ||
494 | //***** Ipp_hdr_fifo Read Pointer ***** | |
495 | /****** geo: ****** | |
496 | input ippfifo_rd_ptr_pio_wr_en; // from slave | |
497 | always @ (posedge clk) | |
498 | if (reset) | |
499 | fifo_rd_ptr <= 7'b0; | |
500 | else if (ippfifo_rd_wr_ptr_bypass) | |
501 | casex (ippfifo_rd_ptr_pio_wr_en) | |
502 | 1'b0: fifo_rd_ptr <= fifo_rd_ptr; // hold the value | |
503 | 1'b1: fifo_rd_ptr <= pio_wr_data[6:0]; | |
504 | endcase | |
505 | else if (fifo_rd_en) | |
506 | fifo_rd_ptr <= fifo_rd_ptr_plus1[6:0]; // inc pointer | |
507 | else | |
508 | fifo_rd_ptr <= fifo_rd_ptr; // hold the value | |
509 | ******* geo: *****/ | |
510 | ||
511 | //*** 1K bytes Ipp_hdr_fifo Management (64-bit depth and 16 bytes(128-bit) wide) *** | |
512 | /****** geo: ****** | |
513 | wire [6:0] fifo_empty_space = (fifo_wr_ptr[6] == fifo_rd_ptr[6]) ? | |
514 | 7'd64 - (fifo_wr_ptr[5:0] - fifo_rd_ptr[5:0]): | |
515 | (fifo_rd_ptr[5:0] - fifo_wr_ptr[5:0]); | |
516 | ||
517 | wire fifo_full = (fifo_wr_ptr[6] == (!fifo_rd_ptr[6])) && | |
518 | (fifo_wr_ptr[5:0] == fifo_rd_ptr[5:0]); | |
519 | ||
520 | wire fifo_empty = (fifo_wr_ptr[6:0] == fifo_rd_ptr[6:0]); | |
521 | ||
522 | wire fifo_over_run = fifo_full & fifo_wr_en & (!ippfifo_rd_wr_ptr_bypass); | |
523 | ||
524 | wire fifo_under_run = fifo_empty & fifo_rd_en & (!ippfifo_rd_wr_ptr_bypass); | |
525 | ******* geo: *****/ | |
526 | ||
527 | // geo: | |
528 | assign ipp_hfifo_dat_empty_space = (fifo_wr_ptr[6] == ipp_hfifo_dat_rptr[6]) ? | |
529 | 7'd64 - {1'b0,(fifo_wr_ptr[5:0] - ipp_hfifo_dat_rptr[5:0])}: | |
530 | {1'b0,(ipp_hfifo_dat_rptr[5:0] - fifo_wr_ptr[5:0])}; | |
531 | assign ipp_hfifo_dat_full = (fifo_wr_ptr[6] == (!ipp_hfifo_dat_rptr[6]) ) && | |
532 | (fifo_wr_ptr[5:0] == ipp_hfifo_dat_rptr[5:0]); | |
533 | assign ipp_hfifo_dat_empty = (fifo_wr_ptr[6:0] == ipp_hfifo_dat_rptr[6:0]); | |
534 | assign ipp_hfifo_over_run = (ipp_hfifo_dat_full && fifo_wr_en || ipp_hfifo_bad_mac_load) && !ippfifo_rd_wr_ptr_bypass; | |
535 | assign ipp_hfifo_under_run = (ipp_hfifo_dat_empty && inc_hfifo_dat_rptr || ipp_hfifo_bad_mac_load) && !ippfifo_rd_wr_ptr_bypass; | |
536 | ||
537 | assign n_ipp_hfifo_over_run = (reset || clr_ipp_unload) ? 1'b0 : | |
538 | ipp_hfifo_over_run ? 1'b1 : | |
539 | ipp_hfifo_over_run_r; | |
540 | ||
541 | assign n_ipp_hfifo_under_run = (reset || clr_ipp_unload) ? 1'b0 : | |
542 | ipp_hfifo_under_run ? 1'b1 : | |
543 | ipp_hfifo_under_run_r; | |
544 | ||
545 | assign n_ipp_hfifo_bad_mac_load = xmac_mode && (phase_state_xmac[2:0]==3'h5) || // phase_sm0 ERROR state | |
546 | !xmac_mode && (phase_state[2:0]==3'h5) || // phase_sm ERROR state | |
547 | !xmac_mode && (mac_ack_fsm_curstate[3:0]==4'hB); // mac_ack_fsm error state | |
548 | ||
549 | always @ (posedge clk) | |
550 | begin | |
551 | ipp_hfifo_over_run_r <= n_ipp_hfifo_over_run; | |
552 | ipp_hfifo_under_run_r <= n_ipp_hfifo_under_run; | |
553 | ipp_hfifo_bad_mac_load<= n_ipp_hfifo_bad_mac_load; | |
554 | end | |
555 | ||
556 | // assign the sixteen byte data | |
557 | reg [11:0] sixteen_byte_count; | |
558 | always @ (posedge clk) | |
559 | if (reset | runt | stat_wr_reg2) | |
560 | sixteen_byte_count <= 0; | |
561 | else if (fifo_wr_en) | |
562 | sixteen_byte_count <= sixteen_byte_count + 1; // hold | |
563 | else | |
564 | sixteen_byte_count <= sixteen_byte_count; // inc. | |
565 | ||
566 | // assign the abort_wr | |
567 | reg abort_wr; | |
568 | always @ (posedge clk) | |
569 | if (stat_wr_reg2) | |
570 | if (xmac_mode) begin | |
571 | if (xmac_ipp_data_reg2[129]) | |
572 | abort_wr <= xmac_ipp_data_reg2[79]; | |
573 | else | |
574 | abort_wr <= xmac_ipp_data_reg2[15]; | |
575 | end | |
576 | else begin | |
577 | if (mac_ipp_data_reg2[129]) | |
578 | abort_wr <= mac_ipp_data_reg2[79]; | |
579 | else | |
580 | abort_wr <= mac_ipp_data_reg2[15]; | |
581 | end | |
582 | else | |
583 | abort_wr <= 1'b0; | |
584 | ||
585 | // definition of runt packet | |
586 | assign runt = ((sixteen_byte_count < 12'd4) | | |
587 | ((sixteen_byte_count == 12'd4) & abort_wr)) & stat_wr_reg2; | |
588 | ||
589 | // synopsys translate_off | |
590 | // For diagnostic purpose | |
591 | always @ (posedge clk) | |
592 | if (!reset) | |
593 | begin | |
594 | if (ipp_hfifo_over_run) | |
595 | $display("\n -> Warning at sim time = %d, ipp PortID=%d Ipp_hdr_fifo over run occurred.", $stime, port_id); | |
596 | else if (ipp_hfifo_under_run) | |
597 | $display("\n -> Warning at sim time = %d, ipp PortID=%d ipp Ipp_hdr_fifo under run occurred.", $stime, port_id); | |
598 | else ; | |
599 | end | |
600 | // synopsys translate_on | |
601 | ||
602 | // geo: wire [6:0] fifo_full_space = 7'd64 - ipp_hfifo_dat_empty_space[6:0]; | |
603 | ||
604 | // there are 5 stages of registers for mac/ipp interface | |
605 | // As John's request change 5 to 6 (2-3-3) | |
606 | ||
607 | wire [6:0] hfifo_space = xmac_mode ? 7'd5 : 7'd9; // geo | |
608 | ||
609 | assign fifo_rdy_4wr = (ipp_hfifo_dat_empty_space[6:0] > hfifo_space); | |
610 | ||
611 | //***** used by ipp_bmc_ctrl ***** | |
612 | //accumulate to 16-byte data (1) | |
613 | // geo: assign fifo_rdy_4rd = (fifo_full_space > 7'h0) & ~runt; | |
614 | ||
615 | ||
616 | //***** Ipp_hdr_fifo Header Read by FFL ***** | |
617 | // oThe2ndTagTime is the status word. Can not count as part of the | |
618 | // 64 byte payload requirement. | |
619 | // | |
620 | // look inside PktLength field of status word approach. | |
621 | //wire time_2_xfer_hdr =((fifo_data_in[13:0] == `SIXTY_FOUR) & oThe2ndTagTime)| | |
622 | // ((sixteen_byte_count == `THIRTY_TWO) & fifo_wr_en & ~oThe2ndTagTime); | |
623 | ||
624 | // independent ipp approach | |
625 | wire time_2_xfer_hdr = ((sixteen_byte_count == 12'd4) & // 64-byte | |
626 | (~abort_wr & stat_wr_reg2)) | | |
627 | ((sixteen_byte_count == 12'd5) & // 80- byte | |
628 | (~abort_wr & stat_wr_reg2)) | | |
629 | ((sixteen_byte_count == 12'd6) & // 96-byte | |
630 | (~abort_wr & stat_wr_reg2)) | | |
631 | ((sixteen_byte_count == 12'd7) & //112-byte | |
632 | (~abort_wr & stat_wr_reg2)) | | |
633 | ((sixteen_byte_count == 12'd8) & //128-byte | |
634 | ((~abort_wr & stat_wr_reg2) | | |
635 | (fifo_wr_en & ~stat_wr_reg2))); | |
636 | ||
637 | ipp_puls_gen puls_gen_hdr_xfer (.reset(reset), .clk(clk), | |
638 | .signal_in(time_2_xfer_hdr), .puls_out(hdr_ok_2xfer)); | |
639 | ||
640 | //********************************************* | |
641 | //***** header base pointer fifo (7 x 16) ***** | |
642 | //********************************************* | |
643 | ||
644 | reg [6:0] hdr_base_ptr_fifo [0:15]; // 7-bit by 16 deep | |
645 | reg [3:0] hdr_base_ptr_wr_ptr; | |
646 | reg [3:0] hdr_base_ptr_rd_ptr; | |
647 | ||
648 | //***** write to header base pointer fifo | |
649 | always @ (posedge clk) | |
650 | if (reset) | |
651 | begin | |
652 | hdr_base_ptr_fifo[0] <= 7'b0; | |
653 | hdr_base_ptr_fifo[1] <= 7'b0; | |
654 | hdr_base_ptr_fifo[2] <= 7'b0; | |
655 | hdr_base_ptr_fifo[3] <= 7'b0; | |
656 | hdr_base_ptr_fifo[4] <= 7'b0; | |
657 | hdr_base_ptr_fifo[5] <= 7'b0; | |
658 | hdr_base_ptr_fifo[6] <= 7'b0; | |
659 | hdr_base_ptr_fifo[7] <= 7'b0; | |
660 | hdr_base_ptr_fifo[8] <= 7'b0; | |
661 | hdr_base_ptr_fifo[9] <= 7'b0; | |
662 | hdr_base_ptr_fifo[10] <= 7'b0; | |
663 | hdr_base_ptr_fifo[11] <= 7'b0; | |
664 | hdr_base_ptr_fifo[12] <= 7'b0; | |
665 | hdr_base_ptr_fifo[13] <= 7'b0; | |
666 | hdr_base_ptr_fifo[14] <= 7'b0; | |
667 | hdr_base_ptr_fifo[15] <= 7'b0; | |
668 | end | |
669 | else if (wr_1st_data) | |
670 | hdr_base_ptr_fifo[hdr_base_ptr_wr_ptr] <= fifo_wr_ptr[6:0]; | |
671 | else | |
672 | hdr_base_ptr_fifo[hdr_base_ptr_wr_ptr] <= hdr_base_ptr_fifo[hdr_base_ptr_wr_ptr]; | |
673 | ||
674 | //***** header base pointer write pointer ***** | |
675 | always @ (posedge clk) | |
676 | if (reset) | |
677 | hdr_base_ptr_wr_ptr <= 4'h0; | |
678 | else | |
679 | casex ({wr_1st_data, runt}) | |
680 | 2'b00: hdr_base_ptr_wr_ptr <= hdr_base_ptr_wr_ptr; | |
681 | 2'b01: hdr_base_ptr_wr_ptr <= hdr_base_ptr_wr_ptr - 4'h1; // rewind | |
682 | 2'b10: hdr_base_ptr_wr_ptr <= hdr_base_ptr_wr_ptr + 4'h1; // increment | |
683 | 2'b11: hdr_base_ptr_wr_ptr <= hdr_base_ptr_wr_ptr; | |
684 | endcase | |
685 | ||
686 | //***** header base pointer read pointer ***** | |
687 | always @ (posedge clk) | |
688 | if (reset) | |
689 | hdr_base_ptr_rd_ptr <= 4'h0; | |
690 | else if (hdr_count == 4'd1) | |
691 | hdr_base_ptr_rd_ptr <= hdr_base_ptr_rd_ptr + 1; | |
692 | else | |
693 | hdr_base_ptr_rd_ptr <= hdr_base_ptr_rd_ptr; | |
694 | ||
695 | //***** header base pointer | |
696 | wire [6:0] hdr_base_ptr = hdr_base_ptr_fifo[hdr_base_ptr_rd_ptr]; | |
697 | ||
698 | // geo: | |
699 | always @ (posedge clk) | |
700 | if (reset) | |
701 | cur_pkt_hdr_base_ptr <= 7'h0; | |
702 | else if (hdr_count == 4'd1) | |
703 | cur_pkt_hdr_base_ptr <= hdr_base_ptr; | |
704 | else | |
705 | cur_pkt_hdr_base_ptr <= cur_pkt_hdr_base_ptr; | |
706 | //***** end of header base pointer fifo | |
707 | ||
708 | always @ (posedge clk) | |
709 | if (reset) | |
710 | cur_pkt_ffl_sum_info <= 14'h0; | |
711 | else if (ffl_ipp_dvalid && !ffl_ipp_dvalid_d) | |
712 | cur_pkt_ffl_sum_info <= fflp_ipp_sum[13:0]; | |
713 | else if (bypass_ffl && vec_cycle1_wr_en) | |
714 | cur_pkt_ffl_sum_info <= pio_wr_data[13:0]; | |
715 | else | |
716 | cur_pkt_ffl_sum_info <= cur_pkt_ffl_sum_info[13:0]; | |
717 | ||
718 | parameter | |
719 | Idle = 2'h0, | |
720 | Wait4rdy = 2'h1, | |
721 | Wait4ack = 2'h2, | |
722 | Hdr_xfer = 2'h3; | |
723 | ||
724 | always @ (start_hdr_xfer or ffl_ipp_ready or ffl_arb_ack or | |
725 | hdr_count or hdr_rd_ptr or hdr_base_ptr or ipp_ffl_dvalid_n or | |
726 | n_ipp_unload_idle or | |
727 | ipp_ffl_curstate) | |
728 | begin | |
729 | ipp_ffl_req_n = 0; | |
730 | // geo: ipp_ffl_dvalid_n = 0; | |
731 | hdr_count_n = 0; | |
732 | hdr_rd_ptr_n = 0; | |
733 | nex_state = ipp_ffl_curstate; | |
734 | ||
735 | case(ipp_ffl_curstate) // synopsys parallel_case full_case | |
736 | Idle: | |
737 | begin | |
738 | if ((start_hdr_xfer) && (~ffl_ipp_ready) && n_ipp_unload_idle) | |
739 | begin | |
740 | ipp_ffl_req_n = 1; | |
741 | nex_state = Wait4rdy; | |
742 | end | |
743 | else if ((start_hdr_xfer) && (ffl_ipp_ready) && n_ipp_unload_idle) | |
744 | begin | |
745 | ipp_ffl_req_n = 1; | |
746 | nex_state = Wait4ack; | |
747 | end | |
748 | else nex_state = ipp_ffl_curstate; | |
749 | end | |
750 | ||
751 | Wait4rdy: | |
752 | begin | |
753 | ipp_ffl_req_n = 1; | |
754 | ||
755 | if (ffl_ipp_ready) | |
756 | begin | |
757 | nex_state = Wait4ack; | |
758 | end | |
759 | else | |
760 | nex_state = ipp_ffl_curstate; | |
761 | end | |
762 | ||
763 | Wait4ack: | |
764 | begin | |
765 | ipp_ffl_req_n = 1; | |
766 | hdr_rd_ptr_n = hdr_base_ptr; | |
767 | ||
768 | if (ffl_arb_ack & ffl_ipp_ready) | |
769 | nex_state = Hdr_xfer; | |
770 | else | |
771 | nex_state = ipp_ffl_curstate; | |
772 | end | |
773 | ||
774 | Hdr_xfer: | |
775 | begin | |
776 | ipp_ffl_req_n = 1; | |
777 | // geo: ipp_ffl_dvalid_n = ((hdr_count == 3'd0) | (hdr_count == 3'd1) | | |
778 | // geo: (hdr_count == 3'd2) | | |
779 | // geo: ((3'd2 < hdr_count) && (hdr_count < 3'd6) && | |
780 | // geo: (~eop_from_hdr_fifo)) | |
781 | // geo: ); | |
782 | ||
783 | if (ipp_ffl_dvalid_n) | |
784 | begin | |
785 | hdr_count_n = hdr_count + 1; | |
786 | hdr_rd_ptr_n = hdr_rd_ptr + 1; | |
787 | nex_state = ipp_ffl_curstate; | |
788 | end | |
789 | else | |
790 | begin | |
791 | ipp_ffl_req_n = 0; | |
792 | hdr_count_n = 0; | |
793 | hdr_rd_ptr_n = hdr_rd_ptr; | |
794 | nex_state = Idle; | |
795 | end | |
796 | end | |
797 | endcase | |
798 | end // end of comb part | |
799 | ||
800 | // geo: | |
801 | assign ipp_ffl_dvalid_n_nxt = (nex_state==Hdr_xfer) && | |
802 | ((hdr_count_n == 4'd0) | (hdr_count_n == 4'd1) | | |
803 | (hdr_count_n == 4'd2) | | |
804 | ((4'd2 < hdr_count_n) && (hdr_count_n < 4'd8) && | |
805 | (~eop_from_hdr_fifo)) | |
806 | ); | |
807 | ||
808 | assign ipp_ffl_dvalid = ipp_ffl_dvalid_n; | |
809 | ||
810 | always @ (dec_hdr_ok_2xfer_cnt or hdr_ok_2xfer or hdr_ok_2xfer_cnt) | |
811 | case ({dec_hdr_ok_2xfer_cnt,hdr_ok_2xfer}) // synopsys parallel_case | |
812 | 2'b00: n_hdr_ok_2xfer_cnt = hdr_ok_2xfer_cnt; | |
813 | 2'b01: n_hdr_ok_2xfer_cnt = hdr_ok_2xfer_cnt + 5'h1; // get 1 | |
814 | 2'b10: n_hdr_ok_2xfer_cnt = hdr_ok_2xfer_cnt - 5'h1; // consume 1 | |
815 | 2'b11: n_hdr_ok_2xfer_cnt = hdr_ok_2xfer_cnt; | |
816 | default: n_hdr_ok_2xfer_cnt = hdr_ok_2xfer_cnt; | |
817 | endcase | |
818 | ||
819 | assign dec_hdr_ok_2xfer_cnt = (nex_state == Hdr_xfer) && (ipp_ffl_curstate != Hdr_xfer) && hdr_ok_2xfer_cnt_gt_eq_1; | |
820 | assign start_hdr_xfer = hdr_ok_2xfer || hdr_ok_2xfer_cnt_gt_eq_1; | |
821 | ||
822 | ||
823 | always @(posedge clk) | |
824 | if (reset) | |
825 | begin | |
826 | ipp_ffl_req <= 1'h0; | |
827 | //geo ipp_ffl_dvalid <= 1'h0; | |
828 | hdr_count <= 4'h0; | |
829 | hdr_rd_ptr <= 7'h0; | |
830 | ipp_ffl_curstate <= 2'h0; | |
831 | ipp_ffl_dvalid_n <= 1'h0; | |
832 | ffl_ipp_dvalid_d <= 1'h0; | |
833 | hdr_ok_2xfer_cnt <= 5'h0; | |
834 | end | |
835 | else | |
836 | begin | |
837 | ipp_ffl_req <= ipp_ffl_req_n; | |
838 | //geo ipp_ffl_dvalid <= ipp_ffl_dvalid_n; | |
839 | hdr_count <= hdr_count_n[3:0]; | |
840 | hdr_rd_ptr <= hdr_rd_ptr_n[6:0]; | |
841 | ipp_ffl_curstate <= nex_state[1:0]; | |
842 | ipp_ffl_dvalid_n <= ipp_ffl_dvalid_n_nxt; | |
843 | ffl_ipp_dvalid_d <= ffl_ipp_dvalid; | |
844 | hdr_ok_2xfer_cnt <= n_hdr_ok_2xfer_cnt; | |
845 | end | |
846 | ||
847 | //*********************************************** | |
848 | //***** Control Word FIFO and related logic ***** | |
849 | //*********************************************** | |
850 | // Control word fifo can maintain up to 16 minimum size packet(64 bytes) which | |
851 | // equals to 1k size fifo. | |
852 | ||
853 | reg [11:0] ctlfifo [0:15]; // 12-bit by 16 deep | |
854 | reg [3:0] ctlfifo_wr_ptr; | |
855 | reg [3:0] ctlfifo_rd_ptr; | |
856 | ||
857 | assign ctlfifo_wr_en = wr_1st_data; | |
858 | /******** geo ************************************************************ | |
859 | assign ctlfifo_wr_en = xmac_mode ? (mac_ipp_ctrl_reg & xmac_ipp_ack_d) : | |
860 | (mac_ipp_ctrl_reg & ipp_mac_ack_d); | |
861 | *************************************************************************/ | |
862 | ||
863 | ||
864 | //***** write to control word fifo | |
865 | always @ (posedge clk) | |
866 | if (reset) | |
867 | begin | |
868 | ctlfifo[0] <= 0; | |
869 | ctlfifo[1] <= 0; | |
870 | ctlfifo[2] <= 0; | |
871 | ctlfifo[3] <= 0; | |
872 | ctlfifo[4] <= 0; | |
873 | ctlfifo[5] <= 0; | |
874 | ctlfifo[6] <= 0; | |
875 | ctlfifo[7] <= 0; | |
876 | ctlfifo[8] <= 0; | |
877 | ctlfifo[9] <= 0; | |
878 | ctlfifo[10] <= 0; | |
879 | ctlfifo[11] <= 0; | |
880 | ctlfifo[12] <= 0; | |
881 | ctlfifo[13] <= 0; | |
882 | ctlfifo[14] <= 0; | |
883 | ctlfifo[15] <= 0; | |
884 | end | |
885 | else if (ctlfifo_wr_en) | |
886 | ctlfifo[ctlfifo_wr_ptr] <= mac_ipp_ctl_reg[11:0]; | |
887 | else | |
888 | ctlfifo[ctlfifo_wr_ptr] <= ctlfifo[ctlfifo_wr_ptr]; | |
889 | ||
890 | //***** control word write pointer ***** | |
891 | always @ (posedge clk) | |
892 | if (reset) | |
893 | ctlfifo_wr_ptr <= 0; | |
894 | else | |
895 | casex ({ctlfifo_wr_en, runt}) | |
896 | 2'b00: ctlfifo_wr_ptr <= ctlfifo_wr_ptr; | |
897 | 2'b01: ctlfifo_wr_ptr <= ctlfifo_wr_ptr - 1; // rewind | |
898 | 2'b10: ctlfifo_wr_ptr <= ctlfifo_wr_ptr + 1; // increment | |
899 | 2'b11: ctlfifo_wr_ptr <= ctlfifo_wr_ptr; | |
900 | endcase | |
901 | ||
902 | //***** control word read pointer by FFL ***** | |
903 | ipp_falling_edge_puls_gen falling_edge_puls_gen_ctlfifo_rd_dn (.reset(reset), | |
904 | .clk(clk), .signal_in(ipp_ffl_dvalid), | |
905 | .puls_out(ctlfifo_rd_dn)); | |
906 | ||
907 | always @ (posedge clk) | |
908 | if (reset | ~ipp_enable) | |
909 | ctlfifo_rd_ptr <= 0; | |
910 | else if (ctlfifo_rd_dn) | |
911 | ctlfifo_rd_ptr <= ctlfifo_rd_ptr + 1; | |
912 | else | |
913 | ctlfifo_rd_ptr <= ctlfifo_rd_ptr; | |
914 | ||
915 | // read from control word | |
916 | // {2'b00, mac_addr_index(6), defaultQPN(8), mode_bit(1), local_CPU(1), | |
917 | // ph_bit(1), mu_bit(1)} | |
918 | wire [11:0] ffl_ctl_word = ctlfifo[ctlfifo_rd_ptr]; | |
919 | wire [11:0] ipp_ffl_mac_default = ffl_ctl_word[11:0]; | |
920 | ||
921 | //***** end of control word fifo and related logic ***** | |
922 | ||
923 | `ifdef NEPTUNE | |
924 | wire [3:0] do_nad; | |
925 | wire [3:0] do_nor; | |
926 | wire [3:0] do_inv; | |
927 | wire [3:0] do_mux; | |
928 | wire [3:0] do_q; | |
929 | wire so; | |
930 | ||
931 | nep_spare_ipp spare_ipp_0 ( | |
932 | .di_nd3 ({1'h1, 1'h1, do_q[3]}), | |
933 | .di_nd2 ({1'h1, 1'h1, do_q[2]}), | |
934 | .di_nd1 ({1'h1, 1'h1, do_q[1]}), | |
935 | .di_nd0 ({1'h1, 1'h1, do_q[0]}), | |
936 | .di_nr3 ({1'h0, 1'h0}), | |
937 | .di_nr2 ({1'h0, 1'h0}), | |
938 | .di_nr1 ({1'h0, 1'h0}), | |
939 | .di_nr0 ({1'h0, 1'h0}), | |
940 | .di_inv (do_nad[3:0]), | |
941 | .di_mx3 ({1'h0, 1'h0}), | |
942 | .di_mx2 ({1'h0, 1'h0}), | |
943 | .di_mx1 ({1'h0, 1'h0}), | |
944 | .di_mx0 ({1'h0, 1'h0}), | |
945 | .mx_sel (do_nor[3:0]), | |
946 | .di_reg (do_inv[3:0]), | |
947 | .wt_ena (do_mux[3:0]), | |
948 | .rst ({reset,reset,reset,reset}), | |
949 | .si (1'h0), | |
950 | .se (1'h0), | |
951 | .clk (clk), | |
952 | .do_nad (do_nad[3:0]), | |
953 | .do_nor (do_nor[3:0]), | |
954 | .do_inv (do_inv[3:0]), | |
955 | .do_mux (do_mux[3:0]), | |
956 | .do_q (do_q[3:0]), | |
957 | .so (so) | |
958 | ); | |
959 | `endif | |
960 | ||
961 | `ifdef NEP_SIM_MAC_IPP_PKT_CNT | |
962 | ||
963 | // synopsys translate_off | |
964 | ||
965 | wire tag2_acked; | |
966 | wire [15:0] mac_ipp_pkt_cnt; | |
967 | ||
968 | ipp_tag_acked tag_acked_0 ( | |
969 | .filtered_tag (filtered_tag), | |
970 | .mac_ipp_ctrl (mac_ipp_ctrl), | |
971 | .xmac_mode (xmac_mode), | |
972 | .xmac_ipp_ack (xmac_ipp_ack), | |
973 | .ipp_mac_ack (ipp_mac_ack), | |
974 | .reset (reset), | |
975 | .clk (clk), | |
976 | .tag2_acked (tag2_acked), | |
977 | .mac_ipp_pkt_cnt (mac_ipp_pkt_cnt) | |
978 | ); | |
979 | // synopsys translate_on | |
980 | `endif | |
981 | ||
982 | ||
983 | endmodule // end of ipp_load | |
984 | //***** end of main program ************************************************ | |
985 | ||
986 | ||
987 | /************************************************************************** | |
988 | * mac_ack_fsm: Use this state machine to count phases before packing data. | |
989 | **************************************************************************/ | |
990 | module mac_ack_fsm (clk, reset, ipp_enable, | |
991 | mac_ipp_req, mac_tag, fifo_rdy_4wr, tag_err_mac, | |
992 | n_tag, nn_tag, set_tag_err_mac, | |
993 | ipp_ack, cur_state); | |
994 | input clk; | |
995 | input reset; | |
996 | input ipp_enable; | |
997 | input mac_ipp_req; | |
998 | input mac_tag; | |
999 | input fifo_rdy_4wr; | |
1000 | input tag_err_mac; | |
1001 | ||
1002 | output n_tag; | |
1003 | output nn_tag; | |
1004 | output set_tag_err_mac; | |
1005 | output ipp_ack; | |
1006 | output [3:0] cur_state; | |
1007 | ||
1008 | reg n_tag; | |
1009 | reg nn_tag; | |
1010 | reg set_tag_err_mac; | |
1011 | reg ipp_ack; | |
1012 | reg [3:0] cur_state, nex_state; | |
1013 | ||
1014 | parameter idle = 4'h0; | |
1015 | parameter load_bop = 4'h1; | |
1016 | parameter load_1 = 4'h2; | |
1017 | parameter load_2 = 4'h3; | |
1018 | parameter load_3 = 4'h4; | |
1019 | parameter load_4 = 4'h5; | |
1020 | parameter last_detect = 4'h6; | |
1021 | parameter wait_req = 4'h7; | |
1022 | parameter wait_req_stat_1 = 4'h8; | |
1023 | parameter load_stat = 4'h9; | |
1024 | parameter bubble_mac = 4'hA; | |
1025 | parameter error = 4'hB; | |
1026 | ||
1027 | // Comb part | |
1028 | always @ (cur_state or mac_tag or tag_err_mac or ipp_enable or fifo_rdy_4wr | |
1029 | or mac_ipp_req) | |
1030 | begin | |
1031 | ipp_ack = 0; | |
1032 | nex_state = idle; | |
1033 | n_tag = 0; | |
1034 | nn_tag = 0; | |
1035 | set_tag_err_mac = 0; | |
1036 | ||
1037 | casex (cur_state) // synopsys parallel_case full_case | |
1038 | idle: // 0 | |
1039 | if (tag_err_mac) | |
1040 | begin | |
1041 | set_tag_err_mac = 1; | |
1042 | nex_state = error; | |
1043 | end | |
1044 | else if (ipp_enable && fifo_rdy_4wr && mac_ipp_req) | |
1045 | begin | |
1046 | ipp_ack = 1; | |
1047 | nex_state = load_bop; | |
1048 | end | |
1049 | else | |
1050 | nex_state = idle; | |
1051 | ||
1052 | load_bop: // 1 | |
1053 | begin | |
1054 | ipp_ack = 1; | |
1055 | nex_state = load_2; | |
1056 | end | |
1057 | ||
1058 | load_1: // 2 | |
1059 | begin | |
1060 | ipp_ack = 1; | |
1061 | nex_state = load_2; // parallel with load_bop | |
1062 | end | |
1063 | ||
1064 | load_2: // 3 | |
1065 | begin | |
1066 | if (mac_tag) | |
1067 | begin | |
1068 | n_tag = 1; | |
1069 | nn_tag = 1; | |
1070 | nex_state = idle; | |
1071 | end | |
1072 | else | |
1073 | begin | |
1074 | ipp_ack = 1; | |
1075 | nex_state = load_3; | |
1076 | end | |
1077 | end | |
1078 | ||
1079 | load_3: // 4 | |
1080 | begin | |
1081 | if (mac_tag) | |
1082 | begin | |
1083 | n_tag = 1; | |
1084 | nn_tag = 1; | |
1085 | nex_state = idle; | |
1086 | end | |
1087 | else | |
1088 | begin | |
1089 | ipp_ack = 1; | |
1090 | nex_state = load_4; | |
1091 | end | |
1092 | end | |
1093 | ||
1094 | load_4: // 5 | |
1095 | begin | |
1096 | if (mac_tag) | |
1097 | begin | |
1098 | n_tag = 1; | |
1099 | nn_tag = 1; | |
1100 | nex_state = idle; | |
1101 | end | |
1102 | else | |
1103 | begin | |
1104 | nex_state = last_detect; | |
1105 | end | |
1106 | end | |
1107 | ||
1108 | last_detect: // 6 | |
1109 | begin | |
1110 | if (mac_tag) | |
1111 | begin | |
1112 | n_tag = 1; | |
1113 | nex_state = wait_req_stat_1; | |
1114 | end | |
1115 | else | |
1116 | nex_state = wait_req; | |
1117 | end | |
1118 | ||
1119 | wait_req: // 7 | |
1120 | begin | |
1121 | if (~ipp_enable) | |
1122 | nex_state = wait_req; | |
1123 | else if (fifo_rdy_4wr && mac_ipp_req) | |
1124 | begin | |
1125 | ipp_ack = 1; | |
1126 | nex_state = load_1; | |
1127 | end | |
1128 | else | |
1129 | nex_state = wait_req; | |
1130 | end | |
1131 | ||
1132 | wait_req_stat_1: // 8 | |
1133 | begin | |
1134 | if (~ipp_enable) | |
1135 | nex_state = wait_req_stat_1; | |
1136 | else if (fifo_rdy_4wr && mac_ipp_req) | |
1137 | begin | |
1138 | ipp_ack = 1; | |
1139 | nex_state = load_stat; | |
1140 | end | |
1141 | else | |
1142 | nex_state = wait_req_stat_1; | |
1143 | end | |
1144 | ||
1145 | load_stat: // 9 | |
1146 | begin | |
1147 | nn_tag = 1; | |
1148 | nex_state = bubble_mac; | |
1149 | end | |
1150 | ||
1151 | /* This state only exists because there is a bug in the big mac which no one | |
1152 | ** can fix. The MAC continues to assert request a cycle after the ack has been | |
1153 | ** asserted and deasserted. However, it does not want to transfer more data. | |
1154 | ** This bubble exists in order to ignore this extraneous request. | |
1155 | */ | |
1156 | bubble_mac: // A | |
1157 | if (tag_err_mac) | |
1158 | begin | |
1159 | set_tag_err_mac = 1; | |
1160 | nex_state = error; | |
1161 | end | |
1162 | else | |
1163 | nex_state = idle; | |
1164 | ||
1165 | error: // B | |
1166 | nex_state = error; | |
1167 | ||
1168 | /*geo*/ default: nex_state = idle; | |
1169 | ||
1170 | endcase | |
1171 | end // end of comb part | |
1172 | ||
1173 | // Seq part | |
1174 | always @ (posedge clk) | |
1175 | if (reset) | |
1176 | cur_state <= 4'b0; | |
1177 | else | |
1178 | cur_state <= nex_state; | |
1179 | ||
1180 | endmodule // end of mac_ack_fsm module | |
1181 | ||
1182 | ||
1183 | /********************************************************************** | |
1184 | * phase_sm0: Use this state machine to count phases after packing data. | |
1185 | and generate the load_fifo for xmac | |
1186 | **********************************************************************/ | |
1187 | module phase_sm0 (clk, reset, valid, eop, phase_state, load_fifo, swap); | |
1188 | ||
1189 | input clk; | |
1190 | input reset; | |
1191 | input valid; | |
1192 | input [1:0] eop; | |
1193 | output [2:0] phase_state; | |
1194 | output load_fifo; | |
1195 | output swap; | |
1196 | ||
1197 | reg [2:0] phase_state; | |
1198 | reg [2:0] nx_phase_state; | |
1199 | reg load_fifo; | |
1200 | reg swap; | |
1201 | ||
1202 | parameter NO_ACK = 3'h0; | |
1203 | parameter WAIT_2ND_TAG = 3'h1; | |
1204 | parameter WAIT_2ND_ACK = 3'h2; | |
1205 | parameter LAST_TAG = 3'h3; | |
1206 | parameter STATUS = 3'h4; | |
1207 | parameter ERROR = 3'h5; | |
1208 | ||
1209 | // Comb part | |
1210 | always @ (phase_state or valid or eop) | |
1211 | begin | |
1212 | load_fifo = 1'b0; | |
1213 | swap = 1'b0; | |
1214 | nx_phase_state = 3'b0; | |
1215 | ||
1216 | case (phase_state) // synopsys parallel_case full_case | |
1217 | NO_ACK: // 3'h0 | |
1218 | case (valid) | |
1219 | 1'b0: nx_phase_state = phase_state; // stay | |
1220 | 1'b1: begin | |
1221 | if (eop == 2'b00) | |
1222 | nx_phase_state = WAIT_2ND_ACK; // 3'h2 | |
1223 | else if (eop == 2'b10) | |
1224 | nx_phase_state = WAIT_2ND_TAG; // 3'h1 | |
1225 | else | |
1226 | nx_phase_state = ERROR; | |
1227 | // $display("Error: wrong state at NO_ACK of phase_sm at simtime = %d", $stime); | |
1228 | end | |
1229 | endcase | |
1230 | ||
1231 | WAIT_2ND_TAG: // 3'h1 | |
1232 | if (eop == 2'b01) | |
1233 | begin | |
1234 | load_fifo = 1'b1; | |
1235 | nx_phase_state = NO_ACK; // 3'h0 | |
1236 | end | |
1237 | else if ((valid) && (eop == 2'b11)) | |
1238 | begin | |
1239 | load_fifo = 1'b1; | |
1240 | nx_phase_state = NO_ACK; // 3'h0 | |
1241 | end | |
1242 | else | |
1243 | nx_phase_state = ERROR; | |
1244 | // $display("Error: wrong state at WAIT_2ND_TAG of phase_sm at simtime= %d", $stime); | |
1245 | ||
1246 | WAIT_2ND_ACK: // 3'h2 | |
1247 | case (valid) | |
1248 | 1'b0: nx_phase_state = phase_state; // stay | |
1249 | 1'b1: begin | |
1250 | load_fifo = 1'b1; | |
1251 | ||
1252 | if (eop == 2'b10) | |
1253 | nx_phase_state = LAST_TAG; // 3'h3 | |
1254 | else if (eop == 2'b00) | |
1255 | nx_phase_state = NO_ACK; // 3'h0 | |
1256 | else | |
1257 | nx_phase_state = ERROR; | |
1258 | // $display("Error: wrong state at WAIT_2ND_ACK of phase_sm at simtime = %d", $stime); | |
1259 | end | |
1260 | endcase | |
1261 | ||
1262 | LAST_TAG: // 3'h3 | |
1263 | case (valid) | |
1264 | 1'b0: begin | |
1265 | if (eop == 2'b01) | |
1266 | nx_phase_state = NO_ACK; // 3'h0 | |
1267 | else | |
1268 | nx_phase_state = phase_state; // stay | |
1269 | end | |
1270 | 1'b1: begin | |
1271 | if (eop == 2'b11) | |
1272 | begin | |
1273 | swap = 1'b1; | |
1274 | nx_phase_state = STATUS; // 3'h4 | |
1275 | end | |
1276 | else | |
1277 | nx_phase_state = ERROR; | |
1278 | // $display("Error: wrong state at LAST_TAG of phase_sm at simtime = %d", $stime); | |
1279 | end | |
1280 | endcase | |
1281 | ||
1282 | STATUS: // 3'h4 | |
1283 | begin | |
1284 | load_fifo = 1'b1; | |
1285 | nx_phase_state = NO_ACK; // 3'h0 | |
1286 | end | |
1287 | ||
1288 | ERROR: // 3'h5 | |
1289 | begin | |
1290 | // $display("E-rror: wrong state at phase_sm at simtime = %d", $stime); | |
1291 | nx_phase_state = ERROR; | |
1292 | end | |
1293 | ||
1294 | /*geo*/ default: nx_phase_state = NO_ACK; | |
1295 | ||
1296 | endcase // case(phase_state) | |
1297 | end // end of comb part | |
1298 | ||
1299 | // Seq part | |
1300 | ||
1301 | always @ (posedge clk) | |
1302 | if (reset) | |
1303 | phase_state <= 3'b0; | |
1304 | else | |
1305 | phase_state <= nx_phase_state; | |
1306 | ||
1307 | endmodule // end of phase_sm0 module | |
1308 | ||
1309 | ||
1310 | /********************************************************************** | |
1311 | * phase_sm: Use this state machine to count phases after packing data. | |
1312 | and generate the load_fifo for bmac | |
1313 | **********************************************************************/ | |
1314 | module phase_sm (clk, reset, valid, eop, phase_state, load_fifo); | |
1315 | ||
1316 | input clk; | |
1317 | input reset; | |
1318 | input valid; | |
1319 | input [1:0] eop; | |
1320 | output [2:0] phase_state; | |
1321 | output load_fifo; | |
1322 | ||
1323 | reg [2:0] phase_state; | |
1324 | reg [2:0] nx_phase_state; | |
1325 | reg load_fifo; | |
1326 | ||
1327 | parameter NO_ACK = 3'h0; | |
1328 | parameter WAIT_2ND_TAG = 3'h1; | |
1329 | parameter WAIT_2ND_ACK = 3'h2; | |
1330 | parameter LAST_TAG = 3'h3; | |
1331 | parameter STATUS = 3'h4; | |
1332 | parameter ERROR = 3'h5; | |
1333 | ||
1334 | // Comb part | |
1335 | always @ (phase_state or valid or eop) | |
1336 | begin | |
1337 | load_fifo = 1'b0; | |
1338 | nx_phase_state = 0; | |
1339 | ||
1340 | case (phase_state) // synopsys parallel_case full_case | |
1341 | NO_ACK: // 3'h0 | |
1342 | case (valid) | |
1343 | 1'b0: nx_phase_state = phase_state; // stay | |
1344 | 1'b1: begin | |
1345 | if (eop == 2'b00) | |
1346 | nx_phase_state = WAIT_2ND_ACK; // 3'h2 | |
1347 | else if (eop == 2'b10) | |
1348 | nx_phase_state = WAIT_2ND_TAG; // 3'h1 | |
1349 | else | |
1350 | nx_phase_state = ERROR; | |
1351 | // $display("Error: wrong state at NO_ACK of phase_sm at simtime = %d", $stime); | |
1352 | end | |
1353 | endcase | |
1354 | ||
1355 | WAIT_2ND_TAG: // 3'h1 | |
1356 | if (eop == 2'b01) | |
1357 | begin | |
1358 | load_fifo = 1'b1; | |
1359 | nx_phase_state = NO_ACK; // 3'h0 | |
1360 | end | |
1361 | else if ((valid) && (eop == 2'b11)) | |
1362 | begin | |
1363 | load_fifo = 1'b1; | |
1364 | nx_phase_state = NO_ACK; // 3'h0 | |
1365 | end | |
1366 | else | |
1367 | nx_phase_state = ERROR; | |
1368 | // $display("Error: wrong state at WAIT_2ND_TAG of phase_sm at simtime = %d", $stime); | |
1369 | ||
1370 | WAIT_2ND_ACK: // 3'h2 | |
1371 | case (valid) | |
1372 | 1'b0: nx_phase_state = phase_state; // stay | |
1373 | 1'b1: begin | |
1374 | load_fifo = 1'b1; | |
1375 | ||
1376 | if (eop == 2'b10) | |
1377 | nx_phase_state = LAST_TAG; // 3'h3 | |
1378 | else if (eop == 2'b00) | |
1379 | nx_phase_state = NO_ACK; // 3'h0 | |
1380 | else | |
1381 | nx_phase_state = ERROR; | |
1382 | // $display("Error: wrong state at WAIT_2ND_ACK of phase_sm at simtime = %d", $stime); | |
1383 | end | |
1384 | endcase | |
1385 | ||
1386 | LAST_TAG: // 3'h3 | |
1387 | case (valid) | |
1388 | 1'b0: begin | |
1389 | if (eop == 2'b01) | |
1390 | nx_phase_state = NO_ACK; // 3'h0 | |
1391 | else | |
1392 | nx_phase_state = phase_state; // stay | |
1393 | end | |
1394 | 1'b1: begin | |
1395 | if (eop == 2'b11) | |
1396 | nx_phase_state = STATUS; // 3'h4 | |
1397 | else | |
1398 | nx_phase_state = ERROR; | |
1399 | // $display("Error: wrong state at LAST_TAG of phase_sm at simtime = %d", $stime); | |
1400 | end | |
1401 | endcase | |
1402 | ||
1403 | STATUS: // 3'h4 | |
1404 | if (eop == 2'b01) | |
1405 | begin | |
1406 | load_fifo = 1'b1; | |
1407 | nx_phase_state = NO_ACK; // 3'h0 | |
1408 | end | |
1409 | else | |
1410 | nx_phase_state = ERROR; | |
1411 | // $display("Error: wrong state at STATUS of phase_sm at simtime = %d", $stime); | |
1412 | ||
1413 | ERROR: // 3'h5 | |
1414 | begin | |
1415 | // $display("E-rror: wrong state at phase_sm at simtime = %d", $stime); | |
1416 | nx_phase_state = ERROR; | |
1417 | end | |
1418 | ||
1419 | /*geo*/ default: nx_phase_state = NO_ACK; | |
1420 | ||
1421 | endcase // case(phase_state) | |
1422 | end // end of comb part | |
1423 | ||
1424 | // Seq part | |
1425 | ||
1426 | always @ (posedge clk) | |
1427 | if (reset) | |
1428 | phase_state <= 3'b0; | |
1429 | else | |
1430 | phase_state <= nx_phase_state; | |
1431 | ||
1432 | endmodule // end of phase_sm module | |
1433 | ||
1434 | ||
1435 | /********************************************************************** | |
1436 | * phase_sm3: Use this state machine to generate the wr_1st_data | |
1437 | **********************************************************************/ | |
1438 | module phase_sm3 (clk, reset, valid, eop, phase_state, wr_1st_data); | |
1439 | ||
1440 | input clk; | |
1441 | input reset; | |
1442 | input valid; | |
1443 | input eop; | |
1444 | output phase_state; | |
1445 | output wr_1st_data; | |
1446 | ||
1447 | reg phase_state; | |
1448 | reg nx_phase_state; | |
1449 | reg wr_1st_data; | |
1450 | ||
1451 | parameter IDLE = 1'b0; | |
1452 | parameter WAIT4TAG = 1'b1; | |
1453 | ||
1454 | // Comb part | |
1455 | always @ (phase_state or valid or eop ) | |
1456 | begin | |
1457 | wr_1st_data = 0; | |
1458 | nx_phase_state = 0; | |
1459 | ||
1460 | case (phase_state) // synopsys parallel_case full_case | |
1461 | IDLE: | |
1462 | casex (valid) | |
1463 | 1'b0: nx_phase_state = phase_state; // stay | |
1464 | 1'b1: begin | |
1465 | nx_phase_state = WAIT4TAG; | |
1466 | wr_1st_data = 1; | |
1467 | end | |
1468 | endcase | |
1469 | ||
1470 | WAIT4TAG: | |
1471 | casex (eop) | |
1472 | 1'b0: nx_phase_state = phase_state; // stay | |
1473 | 1'b1: nx_phase_state = IDLE; | |
1474 | endcase | |
1475 | ||
1476 | endcase // case(phase_state) | |
1477 | end // end of comb part | |
1478 | ||
1479 | // Seq part | |
1480 | ||
1481 | always @ (posedge clk) | |
1482 | if (reset) | |
1483 | phase_state <= 1'b0; | |
1484 | else | |
1485 | phase_state <= nx_phase_state; | |
1486 | ||
1487 | endmodule // end of phase_sm3 module | |
1488 | ||
1489 | ||
1490 | ////////////////////////////////////////////////////////////////// | |
1491 | `ifdef NEP_SIM_MAC_IPP_PKT_CNT | |
1492 | module ipp_tag_acked ( | |
1493 | filtered_tag, | |
1494 | mac_ipp_ctrl, | |
1495 | xmac_mode, | |
1496 | xmac_ipp_ack, | |
1497 | ipp_mac_ack, | |
1498 | reset, | |
1499 | clk, | |
1500 | tag2_acked, | |
1501 | mac_ipp_pkt_cnt | |
1502 | ); | |
1503 | ||
1504 | input filtered_tag; | |
1505 | input mac_ipp_ctrl; | |
1506 | input xmac_mode; | |
1507 | input xmac_ipp_ack; | |
1508 | input ipp_mac_ack; | |
1509 | input reset; | |
1510 | input clk; | |
1511 | output tag2_acked; | |
1512 | output [15:0] mac_ipp_pkt_cnt; | |
1513 | ||
1514 | wire tag2_acked; | |
1515 | reg [15:0] mac_ipp_pkt_cnt; | |
1516 | ||
1517 | wire [15:0] mac_ipp_pkt_cnt_nxt; | |
1518 | ||
1519 | reg [1:0] tag_acked_cnt; | |
1520 | reg [1:0] tag_acked_cnt_nxt; | |
1521 | ||
1522 | reg inc_mac_ipp_pkt_cnt; | |
1523 | reg inc_mac_ipp_pkt_cnt_nxt; | |
1524 | ||
1525 | wire macipp_ack = xmac_mode ? xmac_ipp_ack : ipp_mac_ack; | |
1526 | ||
1527 | always @ (filtered_tag or | |
1528 | xmac_mode or | |
1529 | tag_acked_cnt) begin | |
1530 | ||
1531 | tag_acked_cnt_nxt = 2'h0; | |
1532 | inc_mac_ipp_pkt_cnt_nxt = 1'h0; | |
1533 | ||
1534 | case (tag_acked_cnt) // synopsys parallel_case full_case | |
1535 | ||
1536 | 2'h0: begin | |
1537 | if (filtered_tag) begin | |
1538 | inc_mac_ipp_pkt_cnt_nxt = 1'h1; | |
1539 | tag_acked_cnt_nxt = xmac_mode ? 2'h2 : 2'h1; | |
1540 | end | |
1541 | else begin | |
1542 | tag_acked_cnt_nxt = tag_acked_cnt; | |
1543 | end | |
1544 | end | |
1545 | ||
1546 | 2'h1: begin | |
1547 | if (filtered_tag) begin | |
1548 | tag_acked_cnt_nxt = 2'h2; | |
1549 | end | |
1550 | else begin | |
1551 | tag_acked_cnt_nxt = tag_acked_cnt; | |
1552 | end | |
1553 | end | |
1554 | ||
1555 | 2'h2: begin | |
1556 | tag_acked_cnt_nxt = 2'h0; | |
1557 | end | |
1558 | ||
1559 | default: tag_acked_cnt_nxt = 2'h0; | |
1560 | ||
1561 | endcase | |
1562 | ||
1563 | end | |
1564 | ||
1565 | assign tag2_acked = tag_acked_cnt_nxt[1]; | |
1566 | assign mac_ipp_pkt_cnt_nxt = mac_ipp_pkt_cnt[15:0] + {15'h0,inc_mac_ipp_pkt_cnt}; | |
1567 | ||
1568 | always @(posedge clk) begin | |
1569 | if (reset || mac_ipp_ctrl && macipp_ack) begin | |
1570 | tag_acked_cnt <= #1 2'h0; | |
1571 | end | |
1572 | else begin | |
1573 | tag_acked_cnt <= #1 tag_acked_cnt_nxt[1:0]; | |
1574 | end | |
1575 | end | |
1576 | ||
1577 | always @(posedge clk) begin | |
1578 | if (reset) begin | |
1579 | inc_mac_ipp_pkt_cnt <= #1 1'h0; | |
1580 | mac_ipp_pkt_cnt <= #1 16'h0; | |
1581 | end | |
1582 | else begin | |
1583 | inc_mac_ipp_pkt_cnt <= #1 inc_mac_ipp_pkt_cnt_nxt; | |
1584 | mac_ipp_pkt_cnt <= #1 mac_ipp_pkt_cnt_nxt[15:0]; | |
1585 | end | |
1586 | end | |
1587 | ||
1588 | // synopsys translate_on | |
1589 | ||
1590 | endmodule | |
1591 | `endif |