Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: fflp_fwd_mstr.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_fwd_mstr */ | |
38 | /*description: FFLP forward decisions */ | |
39 | /* */ | |
40 | /*author name: Jeanne Cai */ | |
41 | /*date created: 16-03-2004 */ | |
42 | /* */ | |
43 | /* Copyright (c) 2004, Sun Microsystems, Inc. */ | |
44 | /* Sun Proprietary and Confidential */ | |
45 | /* */ | |
46 | /*modifications: */ | |
47 | /* */ | |
48 | /**********************************************************************/ | |
49 | ||
50 | module fflp_fwd_mstr | |
51 | ( | |
52 | cclk, | |
53 | reset, | |
54 | fc_fifo_ren_sync, | |
55 | disable_chksum, | |
56 | ext_fc_valid, | |
57 | fwd_info_bus_2, | |
58 | key_ecc_data_2, | |
59 | kick_off_ram_srch_5, | |
60 | matchout_5, | |
61 | cam_haddr_reg1_dout, | |
62 | am_din_reg_dout, | |
63 | hash_v1, | |
64 | hash_v2, | |
65 | ||
66 | ecc_parity_status, | |
67 | fc_fifo_space_avail, | |
68 | fc_fifo_empty, | |
69 | fc_fifo_dout | |
70 | ); | |
71 | ||
72 | ||
73 | input cclk; | |
74 | input reset; | |
75 | input fc_fifo_ren_sync; | |
76 | input disable_chksum; | |
77 | input[7:0] ext_fc_valid; | |
78 | input[445:0] fwd_info_bus_2; | |
79 | input[103:0] key_ecc_data_2; | |
80 | input kick_off_ram_srch_5; | |
81 | input matchout_5; | |
82 | input[9:0] cam_haddr_reg1_dout; | |
83 | input[41:0] am_din_reg_dout; | |
84 | input[19:0] hash_v1; | |
85 | input[15:0] hash_v2; | |
86 | ||
87 | output[25:0] ecc_parity_status; | |
88 | output fc_fifo_space_avail; | |
89 | output fc_fifo_empty; | |
90 | output[512:0] fc_fifo_dout; | |
91 | ||
92 | reg ext_valid; | |
93 | ||
94 | wire cam_match_r; | |
95 | wire drop_pkt_r; | |
96 | wire[1:0] valid_tres_r; | |
97 | wire valid_zcopy_r; | |
98 | wire[2:0] rdc_table_num_r; | |
99 | wire[4:0] rdc_table_offset_r; | |
100 | wire fc_lookup_r; | |
101 | wire err_all_r; | |
102 | wire[9:0] valid_cam_haddr_r; | |
103 | ||
104 | wire kick_off_ram_srch_6; | |
105 | ||
106 | wire[361:0] fwd_bus_flow_key; | |
107 | wire[83:0] fwd_bus_fwd_info; | |
108 | wire[2:0] fwd_bus_l2_rdc_num; | |
109 | wire fwd_bus_class_action_tsel; | |
110 | wire fwd_bus_class_action_disc; | |
111 | wire[1:0] fwd_bus_ether_type; | |
112 | wire[4:0] fwd_bus_class; | |
113 | wire fwd_bus_vlan_parity_err; | |
114 | ||
115 | wire[25:0] am_din_reg_dout_tmp; | |
116 | wire[129:0] key_assoc_ecc_data; | |
117 | wire assoc_zcopy_valid; | |
118 | wire[4:0] assoc_offset; | |
119 | wire[2:0] assoc_rdc_num; | |
120 | wire[1:0] assoc_tres; | |
121 | wire assoc_discard; | |
122 | wire assoc_ecc_check; | |
123 | wire[11:0] assoc_zcopy_id; | |
124 | wire[3:0] assoc_parity_bits; | |
125 | wire[15:0] assoc_ecc_syndrome; | |
126 | ||
127 | wire cam_match; | |
128 | wire cam_match_valid; | |
129 | wire drop_pkt; | |
130 | wire[1:0] valid_tres; | |
131 | wire valid_zcopy; | |
132 | wire[2:0] rdc_table_num; | |
133 | wire[4:0] rdc_table_offset; | |
134 | wire[9:0] valid_cam_haddr; | |
135 | wire l2_class; | |
136 | wire fc_lookup; | |
137 | wire[114:0] new_bus; | |
138 | ||
139 | wire[64:0] key_assoc_ecc_data1; | |
140 | wire[64:0] key_assoc_ecc_data2; | |
141 | wire[7:0] assoc_ecc_syndrome1; | |
142 | wire[7:0] assoc_ecc_syndrome2; | |
143 | wire[72:0] ecc_check_din1; | |
144 | wire[72:0] ecc_check_din2; | |
145 | ||
146 | wire[72:0] ecc_check_dout1; | |
147 | wire ecc_check_no_err1; | |
148 | wire ecc_check_err1; | |
149 | wire ecc_check_corr_err1; | |
150 | wire ecc_check_uncorr_err1; | |
151 | ||
152 | wire[72:0] ecc_check_dout2; | |
153 | wire ecc_check_no_err2; | |
154 | wire ecc_check_err2; | |
155 | wire ecc_check_corr_err2; | |
156 | wire ecc_check_uncorr_err2; | |
157 | ||
158 | wire[3:0] am_parity_bits; | |
159 | wire parity_err; | |
160 | ||
161 | wire do_ecc_check; | |
162 | wire ecc_check_err; | |
163 | //wire am_parity_err; | |
164 | wire ecc_parity_err; | |
165 | wire ecc_parity_err_r; | |
166 | wire ecc_parity_err_p; | |
167 | wire err_all; | |
168 | wire ecc_check_err1_r; | |
169 | wire ecc_check_err2_r; | |
170 | wire parity_err_r; | |
171 | wire[7:0] ecc_syndrome1; | |
172 | wire[7:0] ecc_syndrome2; | |
173 | wire[25:0] ecc_parity_status; | |
174 | ||
175 | wire[512:0] fc_fifo_din; | |
176 | wire fc_fifo_wen; | |
177 | wire fc_fifo_rd_sync_r; | |
178 | wire fc_fifo_ren; | |
179 | wire[512:0] fc_fifo_dout; | |
180 | wire fc_fifo_full; | |
181 | wire fc_fifo_empty; | |
182 | ||
183 | wire fc_fifo_space_avail; | |
184 | wire[2:0] fc_fifo_cnt_in; | |
185 | wire fc_fifo_cnt_en; | |
186 | wire[2:0] fc_fifo_cnt; | |
187 | ||
188 | assign fwd_bus_flow_key = fwd_info_bus_2[361:0]; | |
189 | assign fwd_bus_fwd_info = fwd_info_bus_2[445:362]; | |
190 | ||
191 | assign fwd_bus_l2_rdc_num = fwd_bus_fwd_info[2:0]; | |
192 | assign fwd_bus_class_action_tsel= fwd_bus_fwd_info[3]; | |
193 | assign fwd_bus_class_action_disc= fwd_bus_fwd_info[4]; | |
194 | assign fwd_bus_ether_type = fwd_bus_fwd_info[6:5]; | |
195 | assign fwd_bus_class = fwd_bus_fwd_info[17:13]; | |
196 | assign fwd_bus_vlan_parity_err = fwd_bus_fwd_info[83]; | |
197 | ||
198 | assign am_din_reg_dout_tmp = {am_din_reg_dout[25:1], 1'b0}; | |
199 | assign key_assoc_ecc_data = {am_din_reg_dout_tmp[25:0], key_ecc_data_2[103:0]}; | |
200 | ||
201 | assign assoc_zcopy_valid = am_din_reg_dout[1]; | |
202 | assign assoc_offset = am_din_reg_dout[6:2]; | |
203 | assign assoc_rdc_num = am_din_reg_dout[9:7]; | |
204 | assign assoc_tres = am_din_reg_dout[11:10]; | |
205 | assign assoc_discard = am_din_reg_dout[12]; | |
206 | assign assoc_ecc_check = am_din_reg_dout[13]; | |
207 | assign assoc_zcopy_id = am_din_reg_dout[25:14]; | |
208 | assign assoc_parity_bits = am_din_reg_dout[29:26]; | |
209 | assign assoc_ecc_syndrome = am_din_reg_dout[41:26]; | |
210 | ||
211 | assign cam_match = !(fwd_bus_class == 5'b0) & fwd_bus_class_action_tsel & !fwd_bus_vlan_parity_err & matchout_5; | |
212 | assign cam_match_valid = cam_match_r & !ecc_parity_err; | |
213 | assign drop_pkt = cam_match_valid & assoc_discard | fwd_bus_class_action_disc; | |
214 | assign valid_tres = cam_match_valid ? assoc_tres : 2'b00; | |
215 | ||
216 | `ifdef NEPTUNE | |
217 | assign valid_zcopy = (valid_tres == 2'b11) & assoc_zcopy_valid; | |
218 | `else | |
219 | assign valid_zcopy = 1'b0; | |
220 | `endif | |
221 | ||
222 | assign rdc_table_num = valid_tres[1] ? assoc_rdc_num : fwd_bus_l2_rdc_num; | |
223 | assign rdc_table_offset = valid_tres[0] ? assoc_offset : 5'b0; | |
224 | assign valid_cam_haddr = cam_match ? cam_haddr_reg1_dout : 10'b0; | |
225 | ||
226 | assign l2_class = (fwd_bus_class[4:2] == 3'b000) | fwd_bus_class[4]; | |
227 | assign fc_lookup = !(valid_tres[0] | l2_class) & ext_valid & !err_all; | |
228 | ||
229 | always @(rdc_table_num or | |
230 | ext_fc_valid) | |
231 | begin | |
232 | case (rdc_table_num) | |
233 | // 0in < case -full -parallel -message "0in ERROR: case check in fflp_fwd_mstr:ext_valid_1" | |
234 | 3'b000: ext_valid = ext_fc_valid[0]; | |
235 | 3'b001: ext_valid = ext_fc_valid[1]; | |
236 | 3'b010: ext_valid = ext_fc_valid[2]; | |
237 | 3'b011: ext_valid = ext_fc_valid[3]; | |
238 | 3'b100: ext_valid = ext_fc_valid[4]; | |
239 | 3'b101: ext_valid = ext_fc_valid[5]; | |
240 | 3'b110: ext_valid = ext_fc_valid[6]; | |
241 | 3'b111: ext_valid = ext_fc_valid[7]; | |
242 | default:ext_valid = 1'b0; | |
243 | endcase | |
244 | end | |
245 | ||
246 | dffr #(1) kick_off_ram_srch_6_reg(cclk, reset, kick_off_ram_srch_5, kick_off_ram_srch_6); | |
247 | dffre #(1) cam_match_r_reg (cclk, reset, kick_off_ram_srch_5, cam_match, cam_match_r); | |
248 | dffre #(10) valid_cam_haddr_reg (cclk, reset, kick_off_ram_srch_5, valid_cam_haddr, valid_cam_haddr_r); | |
249 | dffre #(1) drop_pkt_r_reg (cclk, reset, kick_off_ram_srch_6, drop_pkt, drop_pkt_r); | |
250 | dffre #(2) valid_tres_r_reg (cclk, reset, kick_off_ram_srch_6, valid_tres, valid_tres_r); | |
251 | dffre #(1) valid_zcopy_r_reg (cclk, reset, kick_off_ram_srch_6, valid_zcopy, valid_zcopy_r); | |
252 | dffre #(3) rdc_table_num_r_reg (cclk, reset, kick_off_ram_srch_6, rdc_table_num, rdc_table_num_r); | |
253 | dffre #(5) rdc_table_offset_r_reg (cclk, reset, kick_off_ram_srch_6, rdc_table_offset, rdc_table_offset_r); | |
254 | dffre #(1) fc_lookup_r_reg (cclk, reset, kick_off_ram_srch_6, fc_lookup, fc_lookup_r); | |
255 | dffre #(1) err_all_r_reg (cclk, reset, kick_off_ram_srch_6, err_all, err_all_r); | |
256 | ||
257 | ||
258 | /******************************/ | |
259 | //ECC/Parity Error | |
260 | /******************************/ | |
261 | assign key_assoc_ecc_data1 = key_assoc_ecc_data[64:0]; | |
262 | assign key_assoc_ecc_data2 = key_assoc_ecc_data[129:65]; | |
263 | assign assoc_ecc_syndrome1 = assoc_ecc_syndrome[7:0]; | |
264 | assign assoc_ecc_syndrome2 = assoc_ecc_syndrome[15:8]; | |
265 | assign ecc_check_din1 = {key_assoc_ecc_data1, assoc_ecc_syndrome1}; | |
266 | assign ecc_check_din2 = {key_assoc_ecc_data2, assoc_ecc_syndrome2}; | |
267 | ||
268 | niu_65data_ecc_check niu_65data_ecc_check_inst1 ( | |
269 | .din (ecc_check_din1), | |
270 | .dout (ecc_check_dout1), | |
271 | .no_error (ecc_check_no_err1), | |
272 | .error (ecc_check_err1), | |
273 | .corr_error (ecc_check_corr_err1), | |
274 | .uncorr_error (ecc_check_uncorr_err1) | |
275 | ); | |
276 | ||
277 | niu_65data_ecc_check niu_65data_ecc_check_inst2 ( | |
278 | .din (ecc_check_din2), | |
279 | .dout (ecc_check_dout2), | |
280 | .no_error (ecc_check_no_err2), | |
281 | .error (ecc_check_err2), | |
282 | .corr_error (ecc_check_corr_err2), | |
283 | .uncorr_error (ecc_check_uncorr_err2) | |
284 | ); | |
285 | ||
286 | ||
287 | assign am_parity_bits = {^am_din_reg_dout_tmp[25:24], ^am_din_reg_dout_tmp[23:16], | |
288 | ^am_din_reg_dout_tmp[15:8], ^am_din_reg_dout_tmp[7:0]}; | |
289 | assign parity_err = !(am_parity_bits == assoc_parity_bits); | |
290 | ||
291 | assign do_ecc_check = assoc_ecc_check & fwd_bus_ether_type[0]; | |
292 | assign ecc_check_err = (ecc_check_err1_r | ecc_check_err2_r) & cam_match_r & !disable_chksum & do_ecc_check; | |
293 | //assign am_parity_err = parity_err_r & cam_match_r & !disable_chksum & !do_ecc_check; | |
294 | assign ecc_parity_err = ((ecc_check_err1_r | ecc_check_err2_r) & do_ecc_check | (parity_err_r & !do_ecc_check)) & | |
295 | cam_match_r & !disable_chksum & kick_off_ram_srch_6; | |
296 | ||
297 | assign ecc_parity_err_p = ecc_parity_err & !ecc_parity_err_r; | |
298 | ||
299 | assign ecc_parity_status= {ecc_parity_err_p, ecc_check_err, valid_cam_haddr_r[7:0], ecc_syndrome2, ecc_syndrome1}; //26bits | |
300 | ||
301 | assign err_all = ecc_parity_err | fwd_bus_vlan_parity_err; | |
302 | ||
303 | dffre #(1) ecc_check_err1_r_reg (cclk, reset, kick_off_ram_srch_5, ecc_check_err1, ecc_check_err1_r); | |
304 | dffre #(1) ecc_check_err2_r_reg (cclk, reset, kick_off_ram_srch_5, ecc_check_err2, ecc_check_err2_r); | |
305 | dffre #(1) parity_err_r_reg (cclk, reset, kick_off_ram_srch_5, parity_err, parity_err_r); | |
306 | dffre #(8) ecc_syndrome2_reg (cclk, reset, kick_off_ram_srch_5, assoc_ecc_syndrome2[7:0], ecc_syndrome2); | |
307 | dffre #(8) ecc_syndrome1_reg (cclk, reset, kick_off_ram_srch_5, assoc_ecc_syndrome1[7:0], ecc_syndrome1); | |
308 | ||
309 | dffr #(1) ecc_parity_err_r_reg (cclk, reset, ecc_parity_err, ecc_parity_err_r); | |
310 | ||
311 | /******************************/ | |
312 | //FC FIFO DATA | |
313 | /******************************/ | |
314 | assign new_bus[2:0] = rdc_table_num_r; | |
315 | assign new_bus[3] = cam_match_r; | |
316 | assign new_bus[4] = drop_pkt_r; | |
317 | assign new_bus[80:5] = fwd_bus_fwd_info[80:5]; | |
318 | assign new_bus[85:81] = rdc_table_offset_r; | |
319 | assign new_bus[87:86] = valid_tres_r[1:0]; | |
320 | assign new_bus[88] = valid_zcopy_r; | |
321 | assign new_bus[98:89] = valid_cam_haddr_r[9:0]; | |
322 | assign new_bus[99] = err_all_r; | |
323 | assign new_bus[100] = fc_lookup_r; | |
324 | assign new_bus[102:101] = fwd_bus_fwd_info[82:81]; | |
325 | assign new_bus[114:103] = assoc_zcopy_valid ? assoc_zcopy_id : 12'b0; | |
326 | ||
327 | assign fc_fifo_din = {new_bus[114:0], fwd_bus_flow_key[361:0], hash_v2, hash_v1[19:0]}; //115+362+36=513 | |
328 | assign fc_fifo_ren = fc_fifo_ren_sync & !fc_fifo_rd_sync_r; | |
329 | ||
330 | dffr #(1) fc_fifo_wen_reg (cclk, reset, kick_off_ram_srch_6, fc_fifo_wen); | |
331 | dffr #(1) fc_fifo_ren_r_reg (cclk, reset, fc_fifo_ren_sync, fc_fifo_rd_sync_r); | |
332 | ||
333 | ||
334 | assign fc_fifo_space_avail = (fc_fifo_cnt < 3'b011); | |
335 | ||
336 | assign fc_fifo_cnt_in = fc_fifo_wen & fc_fifo_ren ? fc_fifo_cnt : | |
337 | fc_fifo_wen ? fc_fifo_cnt + 3'd1 : | |
338 | fc_fifo_ren ? fc_fifo_cnt - 3'd1 : | |
339 | fc_fifo_cnt; | |
340 | assign fc_fifo_cnt_en = fc_fifo_wen | fc_fifo_ren; | |
341 | ||
342 | dffre #(3) fc_fifo_cnt_reg (cclk, reset, fc_fifo_cnt_en, fc_fifo_cnt_in, fc_fifo_cnt); | |
343 | ||
344 | ||
345 | /* 0in fifo | |
346 | -enq fc_fifo_wen | |
347 | -deq fc_fifo_ren | |
348 | -depth 4 | |
349 | -enq_data fc_fifo_din | |
350 | -deq_data fc_fifo_dout | |
351 | -clock cclk | |
352 | -reset reset | |
353 | -message "ASSERTION : fifo : fflp_fwd_mstr: fc_fifo failed" | |
354 | */ | |
355 | ||
356 | ||
357 | fflp_flow_fifo #(513) fc_fifo_inst ( | |
358 | .clk (cclk), | |
359 | .reset (reset), | |
360 | .dout (fc_fifo_dout), | |
361 | .hdr_fifo_empty (fc_fifo_empty), | |
362 | .hdr_fifo_full (fc_fifo_full), | |
363 | .din (fc_fifo_din), | |
364 | .wen (fc_fifo_wen), | |
365 | .ren (fc_fifo_ren) | |
366 | ); | |
367 | ||
368 | ||
369 | endmodule | |
370 |