Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: niu_ipp_sum_unit.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 | `timescale 1ns/10ps | |
37 | ||
38 | /********************************************************** | |
39 | *********************************************************** | |
40 | ||
41 | Project : Niu | |
42 | ||
43 | File name : niu_ipp_sum_unit.v | |
44 | ||
45 | Module(s) name : niu_ipp_sum_unit | |
46 | Original: : sum_unit.v main.5, label: | |
47 | ||
48 | Parent modules : niu_ipp_sum.v | |
49 | ||
50 | Child modules : niu_ipp_sum_lib.v, niu_ipp_sum.h, | |
51 | niu_ipp_sum_data.v, niu_ipp_sum_ctrl.v. | |
52 | ||
53 | Author's name : George Chu | |
54 | ||
55 | Date : March. 2004 | |
56 | ||
57 | Description : One unit of the ipp checksum. | |
58 | ||
59 | Synthesis Notes: | |
60 | ||
61 | Modification History: | |
62 | ||
63 | Date Description | |
64 | ---- ----------- | |
65 | ||
66 | ************************************************************ | |
67 | ***********************************************************/ | |
68 | ||
69 | module niu_ipp_sum_unit (ipp_din_dat, port_num, ipp_full_cksum, | |
70 | ipp_la4_prot, ipp_la3_vers, ipp_la2_opti, ip4_hdr_leng, | |
71 | ipp_info_valid, ipp_start_tcp, ipp_pkt_end, ipp_max_bytes, | |
72 | reset, clk, | |
73 | sum_prt_started, sum_prt_valid, | |
74 | sum_prt_fail, sum_prt_cksum, sum_prt_length, | |
75 | sum_prt_state); | |
76 | ||
77 | input [127:0] ipp_din_dat; // pkt data | |
78 | input port_num; // if 1, this sum_unit is enabled | |
79 | input ipp_full_cksum; // if 1, do the full check_sum | |
80 | input [1:0] ipp_la4_prot; // layer_4, protocol, 0:not_interested,1:Tcp,2:Udp,3:SCTP | |
81 | input [1:0] ipp_la3_vers; // layer_3, version, 0:not_interested,1:Ip4,2:Ip6,3:reser | |
82 | input [1:0] ipp_la2_opti; // layer_2, options {LLC,VLAN} | |
83 | input [3:0] ip4_hdr_leng; // layer_3, IPv4 header_length | |
84 | input ipp_info_valid; // pkt data valid | |
85 | input ipp_start_tcp; // start a tcp checksum | |
86 | input ipp_pkt_end; // end of the pkt data | |
87 | input [16:0] ipp_max_bytes; // pio program: maximum bytes for a pkt to pass checksum | |
88 | input reset; | |
89 | input clk; | |
90 | output sum_prt_started; // the sum_unit is busy, processing a pkt | |
91 | output sum_prt_valid; // the following checksum outputs are valid | |
92 | output sum_prt_fail; // the checked result is a failure | |
93 | output [15:0] sum_prt_cksum; // the check sum | |
94 | output [15:0] sum_prt_length; // the IPv4,6's IP length field | |
95 | output [31:0] sum_prt_state; // the states of the checksum_unit | |
96 | ||
97 | wire sum_prt_started; | |
98 | wire sum_prt_valid; | |
99 | wire sum_prt_fail; | |
100 | wire [15:0] sum_prt_cksum; | |
101 | wire [15:0] sum_prt_length; | |
102 | wire [31:0] sum_prt_state; | |
103 | ||
104 | /* ---------- sum data -------- */ | |
105 | wire c_dsum_fail; | |
106 | wire [15:0] tcp_prt_cksum; | |
107 | ||
108 | /* ---------- sum ctrl -------- */ | |
109 | wire clr; | |
110 | wire [3:0] hdr_off; | |
111 | wire [1:0] sel_awd; | |
112 | wire [7:0] sel_asw; | |
113 | wire [7:0] sel_bwd; | |
114 | wire sel_add; | |
115 | wire [15:0] byt_ena; | |
116 | wire [15:0] udp_dat_len_r; | |
117 | wire get_uln; | |
118 | wire add_uln; | |
119 | ||
120 | wire tcp_prt_fail; | |
121 | wire [15:0] tcp_prt_length; | |
122 | wire [31:0] tcp_prt_state; | |
123 | ||
124 | wire [127:0] din_wrd; | |
125 | wire [127:0] din_wrd_d; | |
126 | ||
127 | wire ipp_start = ipp_start_tcp; | |
128 | wire ipp_start_d; | |
129 | wire clr_prt = ipp_start && !ipp_start_d || reset; | |
130 | wire clr_sum; | |
131 | ||
132 | wire sum_prt_fail_d; | |
133 | wire [15:0] sum_prt_cksum_d; | |
134 | wire [15:0] sum_prt_length_d; | |
135 | ||
136 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
137 | ||
138 | assign sum_prt_fail = sum_prt_valid ? tcp_prt_fail : sum_prt_fail_d; | |
139 | assign sum_prt_cksum = sum_prt_valid ? tcp_prt_cksum[15:0] : sum_prt_cksum_d[15:0]; | |
140 | assign sum_prt_length = sum_prt_valid ? tcp_prt_length[15:0] : sum_prt_length_d[15:0]; | |
141 | ||
142 | niu_ipp_sum_data sum_data ( | |
143 | .din_wrd (din_wrd_d[127:0]), | |
144 | .hdr_off (hdr_off[3:0]), | |
145 | .byt_ena (byt_ena[15:0]), | |
146 | .sel_awd (sel_awd[1:0]), | |
147 | .sel_asw7 (sel_asw[7]), | |
148 | .sel_asw6 (sel_asw[6]), | |
149 | .sel_asw5 (sel_asw[5]), | |
150 | .sel_asw3 (sel_asw[3]), | |
151 | .sel_asw2 (sel_asw[2]), | |
152 | .sel_asw1 (sel_asw[1]), | |
153 | .sel_bwd7 (sel_bwd[7]), | |
154 | .sel_bwd5 (sel_bwd[5]), | |
155 | .sel_bwd4 (sel_bwd[4]), | |
156 | .sel_bwd3 (sel_bwd[3]), | |
157 | .sel_bwd1 (sel_bwd[1]), | |
158 | .sel_add (sel_add), | |
159 | .inp_uln (udp_dat_len_r[15:0]), | |
160 | .get_uln (get_uln), | |
161 | .add_uln (add_uln), | |
162 | .clr (clr_sum), | |
163 | .clk (clk), | |
164 | .sum_prt_cksum (tcp_prt_cksum[15:0]), | |
165 | .c_dsum_fail (c_dsum_fail) | |
166 | ); | |
167 | ||
168 | niu_ipp_sum_ctrl sum_ctrl ( | |
169 | .din_wrd (din_wrd[127:0]), | |
170 | .port_num (port_num), | |
171 | .ipp_full_cksum (ipp_full_cksum), | |
172 | .ipp_la4_prot (ipp_la4_prot[1:0]), | |
173 | .ipp_la3_vers (ipp_la3_vers[1:0]), | |
174 | .ipp_la2_opti (ipp_la2_opti[1:0]), | |
175 | .ip4_hdr_leng (ip4_hdr_leng[3:0]), | |
176 | .ipp_info_valid (ipp_info_valid), | |
177 | .ipp_start_cksum (ipp_start_tcp), | |
178 | .ipp_pkt_end (ipp_pkt_end), | |
179 | .ipp_max_bytes (ipp_max_bytes[16:0]), | |
180 | .c_dsum_fail (c_dsum_fail), | |
181 | .reset (reset), | |
182 | .clk (clk), | |
183 | .clr (clr), | |
184 | .hdr_off (hdr_off[3:0]), | |
185 | .sel_awd (sel_awd[1:0]), | |
186 | .sel_asw (sel_asw[7:0]), | |
187 | .sel_bwd (sel_bwd[7:0]), | |
188 | .sel_add (sel_add), | |
189 | .byt_ena (byt_ena[15:0]), | |
190 | .udp_dat_len_r (udp_dat_len_r[15:0]), | |
191 | .get_uln (get_uln), | |
192 | .add_uln (add_uln), | |
193 | .sum_prt_started (sum_prt_started), | |
194 | .sum_prt_valid (sum_prt_valid), | |
195 | .sum_prt_fail (tcp_prt_fail), | |
196 | .sum_prt_length (tcp_prt_length[15:0]), | |
197 | .sum_prt_state (tcp_prt_state[31:0]) | |
198 | ); | |
199 | ||
200 | assign din_wrd = | |
201 | {ipp_din_dat[007:000],ipp_din_dat[015:008],ipp_din_dat[023:016],ipp_din_dat[031:024], | |
202 | ipp_din_dat[039:032],ipp_din_dat[047:040],ipp_din_dat[055:048],ipp_din_dat[063:056], | |
203 | ipp_din_dat[071:064],ipp_din_dat[079:072],ipp_din_dat[087:080],ipp_din_dat[095:088], | |
204 | ipp_din_dat[103:096],ipp_din_dat[111:104],ipp_din_dat[119:112],ipp_din_dat[127:120]}; | |
205 | ||
206 | ipp_sum_reg_r_1 su_reg_r_1_clr (clr, reset, clk,clr_sum); | |
207 | ipp_sum_reg_r_1 su_reg_r_1_sta (ipp_start, reset, clk,ipp_start_d); | |
208 | ipp_sum_reg_r_128 su_reg_r_128_wrd(din_wrd[127:0], reset, clk,din_wrd_d[127:0]); | |
209 | ipp_sum_reg_r_1 su_reg_r_1_fai (sum_prt_fail, clr_prt,clk,sum_prt_fail_d); | |
210 | ipp_sum_reg_r_16 su_reg_r_16_sum (sum_prt_cksum[15:0], clr_prt,clk,sum_prt_cksum_d[15:0]); | |
211 | ipp_sum_reg_r_16 su_reg_r_16_len (sum_prt_length[15:0], clr_prt,clk,sum_prt_length_d[15:0]); | |
212 | ipp_sum_reg_r_9_s0 su_reg_w_r_9_s0 (tcp_prt_state[08:0], reset, clk,sum_prt_state[08:0]); | |
213 | ipp_sum_reg_w_r_23 su_reg_w_r_23_st(tcp_prt_state[31:9], sum_prt_started,clr_prt,clk,sum_prt_state[31:9]); | |
214 | ||
215 | ||
216 | endmodule |