1 |
19 |
mcwaccent |
----------------------------------------------------------------------------------
|
2 |
|
|
--
|
3 |
|
|
-- This file is a part of Technica Corporation Wizardry Project
|
4 |
|
|
--
|
5 |
|
|
-- Copyright (C) 2004-2009, Technica Corporation
|
6 |
|
|
--
|
7 |
|
|
-- This program is free software: you can redistribute it and/or modify
|
8 |
|
|
-- it under the terms of the GNU General Public License as published by
|
9 |
|
|
-- the Free Software Foundation, either version 3 of the License, or
|
10 |
|
|
-- (at your option) any later version.
|
11 |
|
|
--
|
12 |
|
|
-- This program is distributed in the hope that it will be useful,
|
13 |
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
|
|
-- GNU General Public License for more details.
|
16 |
|
|
--
|
17 |
|
|
-- You should have received a copy of the GNU General Public License
|
18 |
|
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19 |
|
|
--
|
20 |
|
|
----------------------------------------------------------------------------------
|
21 |
|
|
----------------------------------------------------------------------------------
|
22 |
|
|
-- Module Name: frame_counting - Behavioral
|
23 |
|
|
-- Project Name: Wizardry
|
24 |
|
|
-- Target Devices: Virtex 4 ML401
|
25 |
|
|
-- Description: Contains several counters that keep track of the number of packets
|
26 |
|
|
-- received of each protocol type.
|
27 |
|
|
-- Revision: 1.0
|
28 |
|
|
-- Additional Comments:
|
29 |
|
|
--
|
30 |
|
|
----------------------------------------------------------------------------------
|
31 |
|
|
library IEEE;
|
32 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
33 |
|
|
use IEEE.STD_LOGIC_ARITH.ALL;
|
34 |
|
|
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
35 |
|
|
use work.port_block_constants.all;
|
36 |
|
|
|
37 |
|
|
entity frame_counting is
|
38 |
|
|
Port ( clock : in STD_LOGIC;
|
39 |
|
|
sys_clock : in std_logic;
|
40 |
|
|
reset : in STD_LOGIC;
|
41 |
|
|
-- ICMP_type : in std_logic;
|
42 |
|
|
field_type : in STD_LOGIC_VECTOR (7 downto 0);
|
43 |
|
|
field_data : in std_logic_vector(7 downto 0);
|
44 |
|
|
data_ready : in STD_LOGIC;
|
45 |
|
|
frame_counters : out frame_counters_type);
|
46 |
|
|
-- total_count : out STD_LOGIC_VECTOR (31 downto 0);
|
47 |
|
|
-- ipv4_count : out STD_LOGIC_VECTOR (31 downto 0);
|
48 |
|
|
-- ipv6_count : out STD_LOGIC_VECTOR (31 downto 0);
|
49 |
|
|
-- tcp_count : out STD_LOGIC_VECTOR (31 downto 0);
|
50 |
|
|
-- udp_count : out STD_LOGIC_VECTOR (31 downto 0);
|
51 |
|
|
-- arp_count : out STD_LOGIC_VECTOR (31 downto 0);
|
52 |
|
|
-- unknown_count : out STD_LOGIC_VECTOR (31 downto 0));
|
53 |
|
|
end frame_counting;
|
54 |
|
|
|
55 |
|
|
architecture Behavioral of frame_counting is
|
56 |
|
|
|
57 |
|
|
signal total_frame_count_s : std_logic_vector(31 downto 0);
|
58 |
|
|
signal ipv4_frame_count_s : std_logic_vector(31 downto 0);
|
59 |
|
|
signal ipv6_frame_count_s : std_logic_vector(31 downto 0);
|
60 |
|
|
signal tcp_frame_count_s : std_logic_Vector(31 downto 0);
|
61 |
|
|
signal udp_frame_count_s : std_logic_Vector(31 downto 0);
|
62 |
|
|
signal arp_frame_count_s : std_logic_Vector(31 downto 0);
|
63 |
|
|
signal unknown_packet_count_s : std_logic_vector(31 downto 0);
|
64 |
|
|
signal icmp_frame_count_s : std_logic_vector(31 downto 0);
|
65 |
|
|
begin
|
66 |
|
|
|
67 |
|
|
process(sys_clock)
|
68 |
|
|
begin
|
69 |
|
|
if rising_edge(sys_clock) then
|
70 |
|
|
frame_counters.count0 <= total_frame_count_s;
|
71 |
|
|
end if;
|
72 |
|
|
end process;
|
73 |
|
|
|
74 |
|
|
process(sys_clock)
|
75 |
|
|
begin
|
76 |
|
|
if rising_Edge(sys_clock) then
|
77 |
|
|
frame_counters.count1 <= ipv4_frame_count_s;
|
78 |
|
|
end if;
|
79 |
|
|
end process;
|
80 |
|
|
|
81 |
|
|
process(sys_clock)
|
82 |
|
|
begin
|
83 |
|
|
if rising_edge(sys_clock) then
|
84 |
|
|
frame_counters.count2 <= ipv6_frame_count_s;
|
85 |
|
|
end if;
|
86 |
|
|
end process;
|
87 |
|
|
|
88 |
|
|
process(sys_clock)
|
89 |
|
|
begin
|
90 |
|
|
if rising_Edge(sys_clock) then
|
91 |
|
|
frame_counters.count3 <= tcp_frame_count_s;
|
92 |
|
|
end if;
|
93 |
|
|
end process;
|
94 |
|
|
|
95 |
|
|
process(sys_clock)
|
96 |
|
|
begin
|
97 |
|
|
if rising_edge(sys_clock) then
|
98 |
|
|
frame_counters.count4 <= udp_frame_count_s;
|
99 |
|
|
end if;
|
100 |
|
|
end process;
|
101 |
|
|
|
102 |
|
|
process(sys_clock)
|
103 |
|
|
begin
|
104 |
|
|
if rising_edge(sys_clock) then
|
105 |
|
|
frame_counters.count5 <= arp_frame_count_s;
|
106 |
|
|
end if;
|
107 |
|
|
end process;
|
108 |
|
|
|
109 |
|
|
process(sys_clock)
|
110 |
|
|
begin
|
111 |
|
|
if rising_edge(sys_clock) then
|
112 |
|
|
frame_counters.count6 <= unknown_packet_count_s;
|
113 |
|
|
end if;
|
114 |
|
|
end process;
|
115 |
|
|
|
116 |
|
|
process(sys_clock)
|
117 |
|
|
begin
|
118 |
|
|
if rising_edge(sys_clock) then
|
119 |
|
|
frame_counters.count7 <= ICMP_frame_count_s;
|
120 |
|
|
end if;
|
121 |
|
|
end process;
|
122 |
|
|
|
123 |
|
|
total_frame_count_s <= tcp_frame_count_s + udp_frame_count_s + arp_frame_count_s + unknown_packet_count_s;
|
124 |
|
|
--tot_cnt:process(reset,data_ready,field_type)
|
125 |
|
|
--begin
|
126 |
|
|
---- if rising_edge(clock) then
|
127 |
|
|
-- if reset = '1' then
|
128 |
|
|
-- total_frame_count_s <= (others => '0');
|
129 |
|
|
-- elsif data_ready'event and data_ready = '1' then
|
130 |
|
|
-- if field_type = X"05" then
|
131 |
|
|
-- total_frame_count_s <= total_frame_count_s + 1;
|
132 |
|
|
-- else
|
133 |
|
|
-- total_frame_count_s <= total_frame_count_s;
|
134 |
|
|
-- end if;
|
135 |
|
|
-- end if;
|
136 |
|
|
---- end if;
|
137 |
|
|
--end process;
|
138 |
|
|
|
139 |
|
|
ipv4_cnt:process(clock,reset,data_ready,field_type)
|
140 |
|
|
variable ipv4 : std_logic_vector(31 downto 0);
|
141 |
|
|
begin
|
142 |
|
|
-- if rising_edge(clock) then
|
143 |
|
|
if reset = '1' then
|
144 |
|
|
ipv4 := (others => '0');
|
145 |
|
|
elsif rising_edge(clock) then
|
146 |
|
|
if data_ready = '1' and field_type = X"1C" then
|
147 |
|
|
ipv4 := ipv4 + 1;
|
148 |
|
|
else
|
149 |
|
|
ipv4 := ipv4;
|
150 |
|
|
end if;
|
151 |
|
|
else
|
152 |
|
|
ipv4 := ipv4;
|
153 |
|
|
end if;
|
154 |
|
|
ipv4_frame_count_s <= ipv4;
|
155 |
|
|
-- end if;
|
156 |
|
|
end process;
|
157 |
|
|
|
158 |
|
|
ipv6_cnt:process(clock,reset,data_ready,field_type)
|
159 |
|
|
variable ipv6 : std_logic_Vector(31 downto 0);
|
160 |
|
|
begin
|
161 |
|
|
-- if rising_edge(clock) then
|
162 |
|
|
if reset = '1' then
|
163 |
|
|
ipv6 := (others => '0');
|
164 |
|
|
elsif rising_edge(clock) then
|
165 |
|
|
if data_ready = '1' and field_type = X"33" then
|
166 |
|
|
ipv6 := ipv6 + 1;
|
167 |
|
|
else
|
168 |
|
|
ipv6 := ipv6;
|
169 |
|
|
end if;
|
170 |
|
|
else
|
171 |
|
|
ipv6 := ipv6;
|
172 |
|
|
end if;
|
173 |
|
|
ipv6_frame_count_s <= ipv6;
|
174 |
|
|
-- end if;
|
175 |
|
|
end process;
|
176 |
|
|
|
177 |
|
|
tcp_cnt:process(clock,reset,data_ready,field_type)
|
178 |
|
|
variable tcp : std_logic_Vector(31 downto 0);
|
179 |
|
|
begin
|
180 |
|
|
-- if rising_edge(clock) then
|
181 |
|
|
if reset = '1' then
|
182 |
|
|
tcp := (others => '0');
|
183 |
|
|
elsif rising_edge(clock) then
|
184 |
|
|
if data_ready = '1' and field_type = X"25" then
|
185 |
|
|
tcp := tcp + 1;
|
186 |
|
|
else
|
187 |
|
|
tcp := tcp;
|
188 |
|
|
end if;
|
189 |
|
|
else
|
190 |
|
|
tcp := tcp;
|
191 |
|
|
end if;
|
192 |
|
|
tcp_frame_count_s <= tcp;
|
193 |
|
|
-- end if;
|
194 |
|
|
end process;
|
195 |
|
|
|
196 |
|
|
udp_cnt:process(clock,reset,data_ready,field_type)
|
197 |
|
|
variable udp : std_logic_Vector(31 downto 0);
|
198 |
|
|
begin
|
199 |
|
|
-- if rising_edge(clock) then
|
200 |
|
|
if reset = '1' then
|
201 |
|
|
udp := (others => '0');
|
202 |
|
|
elsif rising_edge(clock) then
|
203 |
|
|
if data_ready = '1' and field_type = X"2F" then
|
204 |
|
|
udp := udp + 1;
|
205 |
|
|
else
|
206 |
|
|
udp := udp;
|
207 |
|
|
end if;
|
208 |
|
|
else
|
209 |
|
|
udp := udp;
|
210 |
|
|
end if;
|
211 |
|
|
udp_frame_count_s <= udp;
|
212 |
|
|
-- end if;
|
213 |
|
|
end process;
|
214 |
|
|
|
215 |
|
|
arp_cnt:process(clock,reset,data_ready,field_type)
|
216 |
|
|
variable arp : std_logic_Vector(31 downto 0);
|
217 |
|
|
begin
|
218 |
|
|
-- if rising_edge(clock) then
|
219 |
|
|
if reset = '1' then
|
220 |
|
|
arp := (others => '0');
|
221 |
|
|
elsif rising_edge(clock) then
|
222 |
|
|
if data_ready = '1' and field_type = X"07" then
|
223 |
|
|
arp := arp + 1;
|
224 |
|
|
else
|
225 |
|
|
arp := arp;
|
226 |
|
|
end if;
|
227 |
|
|
else
|
228 |
|
|
arp := arp;
|
229 |
|
|
end if;
|
230 |
|
|
arp_frame_count_s <= arp;
|
231 |
|
|
-- end if;
|
232 |
|
|
end process;
|
233 |
|
|
|
234 |
|
|
icmp_cnt: process(clock,reset,data_ready,field_type)
|
235 |
|
|
variable icmp : std_logic_vector(31 downto 0);
|
236 |
|
|
begin
|
237 |
|
|
if rising_edge(clock) then
|
238 |
|
|
if reset = '1' then
|
239 |
|
|
icmp := (others => '0');
|
240 |
|
|
elsif data_ready = '1' and field_type = X"43" then-- AND icmp_type = '1' then
|
241 |
|
|
icmp := icmp + 1;
|
242 |
|
|
else
|
243 |
|
|
icmp := icmp;
|
244 |
|
|
end if;
|
245 |
|
|
end if;
|
246 |
|
|
icmp_frame_count_s <= icmp;
|
247 |
|
|
end process;
|
248 |
|
|
------------Marlon's version that works----------------------------------
|
249 |
|
|
--icmp_cnt: process(clock,reset,data_ready,field_type,icmp_type)
|
250 |
|
|
--variable icmp : std_logic_vector(31 downto 0);
|
251 |
|
|
--begin
|
252 |
|
|
-- if rising_edge(clock) then
|
253 |
|
|
-- if reset = '1' then
|
254 |
|
|
-- icmp := (others => '0');
|
255 |
|
|
-- elsif data_ready = '1' and field_type = X"1F" AND icmp_type = '1' then
|
256 |
|
|
-- icmp := icmp + 1;
|
257 |
|
|
-- else
|
258 |
|
|
-- icmp := icmp;
|
259 |
|
|
-- end if;
|
260 |
|
|
-- end if;
|
261 |
|
|
--icmp_frame_count_s <= icmp;
|
262 |
|
|
--end process;
|
263 |
|
|
----------------end Marlon's version--------------------------------------
|
264 |
|
|
------------Stacie's version that doesn't work----------------------------------
|
265 |
|
|
--icmp_cnt: process(clock,reset,data_ready,field_type,field_data)
|
266 |
|
|
--variable icmp : std_logic_vector(31 downto 0);
|
267 |
|
|
--begin
|
268 |
|
|
-- if reset = '1' then
|
269 |
|
|
-- icmp := (others => '0');
|
270 |
|
|
-- elsif rising_edge(clock) then
|
271 |
|
|
-- if data_ready = '1' and field_type = X"1F" then
|
272 |
|
|
-- if field_data = X"01" then
|
273 |
|
|
-- icmp := icmp + 1;
|
274 |
|
|
-- else
|
275 |
|
|
-- icmp := icmp;
|
276 |
|
|
-- end if;
|
277 |
|
|
-- else
|
278 |
|
|
-- icmp := icmp;
|
279 |
|
|
-- end if;
|
280 |
|
|
-- end if;
|
281 |
|
|
--icmp_frame_count_s <= icmp;
|
282 |
|
|
--end process;
|
283 |
|
|
----------------end Stacie's version--------------------------------------
|
284 |
|
|
unk_cnt:process(clock,reset,field_type,data_ready)
|
285 |
|
|
variable count_once : std_logic := '0';
|
286 |
|
|
variable unknown : std_Logic_Vector(31 downto 0);
|
287 |
|
|
begin
|
288 |
|
|
-- if rising_edge(clock) then
|
289 |
|
|
if reset = '1' then
|
290 |
|
|
unknown := (others => '0');
|
291 |
|
|
count_once := '0';
|
292 |
|
|
elsif rising_edge(clock) then
|
293 |
|
|
if data_ready = '1' and field_type = X"42" and count_once = '0' then
|
294 |
|
|
unknown := unknown + 1;
|
295 |
|
|
count_once := '1';
|
296 |
|
|
elsif field_type = X"03" then-- and count_once = '1' then
|
297 |
|
|
count_once := '0';
|
298 |
|
|
unknown := unknown;
|
299 |
|
|
else
|
300 |
|
|
count_once := count_once;
|
301 |
|
|
unknown := unknown;
|
302 |
|
|
end if;
|
303 |
|
|
else
|
304 |
|
|
unknown := unknown;
|
305 |
|
|
count_once := count_once;
|
306 |
|
|
end if;
|
307 |
|
|
-- end if;
|
308 |
|
|
-- end if;
|
309 |
|
|
unknown_packet_count_s <= unknown;
|
310 |
|
|
end process;
|
311 |
|
|
|
312 |
|
|
|
313 |
|
|
--ipv4_cnt:process(reset,data_ready,field_type)
|
314 |
|
|
--begin
|
315 |
|
|
---- if rising_edge(clock) then
|
316 |
|
|
-- if reset = '1' then
|
317 |
|
|
-- IPv4_frame_count_s <= (others => '0');
|
318 |
|
|
-- elsif data_ready'event and data_ready = '1' then
|
319 |
|
|
-- if field_type = X"1C" then
|
320 |
|
|
-- IPv4_frame_count_s <= IPv4_frame_count_s + 1;
|
321 |
|
|
-- else
|
322 |
|
|
-- IPv4_frame_count_s <= IPv4_frame_count_s;
|
323 |
|
|
-- end if;
|
324 |
|
|
-- end if;
|
325 |
|
|
---- end if;
|
326 |
|
|
--end process;
|
327 |
|
|
--
|
328 |
|
|
--ipv6_cnt:process(reset,data_ready,field_type)
|
329 |
|
|
--begin
|
330 |
|
|
---- if rising_edge(clock) then
|
331 |
|
|
-- if reset = '1' then
|
332 |
|
|
-- IPv6_frame_count_s <= (others => '0');
|
333 |
|
|
-- elsif data_ready'event and data_ready = '1' then
|
334 |
|
|
-- if field_type = X"33" then
|
335 |
|
|
-- IPv6_frame_count_s <= IPv6_frame_count_s + 1;
|
336 |
|
|
-- else
|
337 |
|
|
-- IPv6_frame_count_s <= IPv6_frame_count_s;
|
338 |
|
|
-- end if;
|
339 |
|
|
-- end if;
|
340 |
|
|
---- end if;
|
341 |
|
|
--end process;
|
342 |
|
|
--
|
343 |
|
|
--tcp_cnt:process(reset,data_ready,field_type)
|
344 |
|
|
--begin
|
345 |
|
|
---- if rising_edge(clock) then
|
346 |
|
|
-- if reset = '1' then
|
347 |
|
|
-- tcp_frame_count_s <= (others => '0');
|
348 |
|
|
-- elsif data_ready'event and data_ready = '1' then
|
349 |
|
|
-- if field_type = X"25" then
|
350 |
|
|
-- tcp_frame_count_s <= tcp_frame_count_s + 1;
|
351 |
|
|
-- else
|
352 |
|
|
-- tcp_frame_count_s <= tcp_frame_count_s;
|
353 |
|
|
-- end if;
|
354 |
|
|
-- end if;
|
355 |
|
|
---- end if;
|
356 |
|
|
--end process;
|
357 |
|
|
--
|
358 |
|
|
--udp_cnt:process(reset,data_ready,field_type)
|
359 |
|
|
--begin
|
360 |
|
|
---- if rising_edge(clock) then
|
361 |
|
|
-- if reset = '1' then
|
362 |
|
|
-- udp_frame_count_s <= (others => '0');
|
363 |
|
|
-- elsif data_ready'event and data_ready = '1' then
|
364 |
|
|
-- if field_type = X"2F" then
|
365 |
|
|
-- udp_frame_count_s <= udp_frame_count_s + 1;
|
366 |
|
|
-- else
|
367 |
|
|
-- udp_frame_count_s <= udp_frame_count_s;
|
368 |
|
|
-- end if;
|
369 |
|
|
-- end if;
|
370 |
|
|
---- end if;
|
371 |
|
|
--end process;
|
372 |
|
|
--
|
373 |
|
|
--arp_cnt:process(reset,data_ready,field_type)
|
374 |
|
|
--variable arp : std_logic_Vector(31 downto 0);
|
375 |
|
|
--begin
|
376 |
|
|
---- if rising_edge(clock) then
|
377 |
|
|
-- if reset = '1' then
|
378 |
|
|
-- ARP_frame_count_s <= (others => '0');
|
379 |
|
|
-- elsif data_ready'event and data_ready = '1' then
|
380 |
|
|
-- if field_type = X"07" then
|
381 |
|
|
-- ARP_frame_count_s <= ARP_frame_count_s + 1;
|
382 |
|
|
-- else
|
383 |
|
|
-- ARP_frame_count_s <= ARP_frame_count_s;
|
384 |
|
|
-- end if;
|
385 |
|
|
-- end if;
|
386 |
|
|
---- end if;
|
387 |
|
|
--end process;
|
388 |
|
|
--
|
389 |
|
|
--unk_cnt:process(clock,reset,field_type,data_ready)
|
390 |
|
|
--variable count_once : std_logic := '0';
|
391 |
|
|
--begin
|
392 |
|
|
-- if rising_edge(clock) then
|
393 |
|
|
-- if reset = '1' then
|
394 |
|
|
-- unknown_packet_count_s <= (others => '0');
|
395 |
|
|
-- count_once := '0';
|
396 |
|
|
-- elsif data_ready = '1' then
|
397 |
|
|
-- if field_type = X"42" and count_once = '0' then
|
398 |
|
|
-- unknown_packet_count_s <= unknown_packet_count_s + 1;
|
399 |
|
|
-- count_once := '1';
|
400 |
|
|
-- elsif field_type = X"03" then-- and count_once = '1' then
|
401 |
|
|
-- count_once := '0';
|
402 |
|
|
-- unknown_packet_count_s <= unknown_packet_count_s;
|
403 |
|
|
-- else
|
404 |
|
|
-- count_once := count_once;
|
405 |
|
|
-- unknown_packet_count_s <= unknown_packet_count_s;
|
406 |
|
|
-- end if;
|
407 |
|
|
-- else
|
408 |
|
|
-- unknown_packet_count_s <= unknown_packet_count_s;
|
409 |
|
|
-- count_once := count_once;
|
410 |
|
|
-- end if;
|
411 |
|
|
---- end if;
|
412 |
|
|
-- end if;
|
413 |
|
|
--end process;
|
414 |
|
|
|
415 |
|
|
end Behavioral;
|
416 |
|
|
|