OpenCores
URL https://opencores.org/ocsvn/loadbalancer/loadbalancer/trunk

Subversion Repositories loadbalancer

[/] [loadbalancer/] [trunk/] [Classfier/] [open_header.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 atalla
--------------------------------------------------------
2
 
3
        LIBRARY IEEE;
4
        USE IEEE.STD_LOGIC_1164.ALL;
5
        use ieee.numeric_std.all;
6
        use IEEE.STD_LOGIC_ARITH.ALL;
7
        use IEEE.STD_LOGIC_UNSIGNED.ALL;
8
        USE WORK.CONFIG.ALL;
9
-------------------------------
10
        ENTITY open_header IS
11
        GENERIC(DATA_WIDTH :INTEGER := 64;
12
                        CTRL_WIDTH :INTEGER := 8);
13
        PORT(
14
        SIGNAL          in_data                         :       IN      STD_LOGIC_VECTOR(63 DOWNTO 0)    ;
15
        SIGNAL          in_ctrl                         :       IN      STD_LOGIC_VECTOR(7 DOWNTO 0)     ;
16
    SIGNAL              in_wr                           :       IN              STD_LOGIC       ;
17
 
18
        SIGNAL          pkt_type                        :       OUT     STD_LOGIC_VECTOR(7 DOWNTO 0)     ;
19
        SIGNAL          pkt_type_rdy            :       OUT     STD_LOGIC       ;
20
        SIGNAL          pkt_type_rdy_ack                :       IN      STD_LOGIC       ;
21
    --- Misc
22
 
23
    SIGNAL              reset                           :       IN              STD_LOGIC       ;
24
    SIGNAL              clk                             :       IN              STD_LOGIC
25
        );
26
        END ENTITY;
27
 
28
 ------------------------------------------------------
29
        ARCHITECTURE behavior OF open_header IS
30
------------ one hot encoding state definition
31
        TYPE state_type is (READ_HEADER, READ_WORD_1, READ_WORD_2, READ_WORD_3,READ_WORD_4,
32
                                                READ_WORD_5,READ_WORD_6,READ_WORD_7);
33
        ATTRIBUTE enum_encoding: STRING;
34
        ATTRIBUTE enum_encoding of state_type : type is "onehot";
35
 
36
        SIGNAL state, state_NEXT : state_type;
37
---------------internal signals
38
   --- ethr  header
39
    ---SOURCE PORT
40
        SIGNAL          source_port                     :       STD_LOGIC_VECTOR(1 DOWNTO 0);--just four ports
41
-----------signal to check if it ARP request
42
 
43
        SIGNAL          arp_ok                          :       STD_LOGIC;
44
        SIGNAL          arp_dest_mac_ok         :       STD_LOGIC; --DEST MAC = FF:FF:FF:FF:FF:FF
45
        SIGNAL          arp_port_ok             :       STD_LOGIC; -- ARP PORT = X0806
46
        SIGNAL          arp_HTYPE_ok            :       STD_LOGIC; --htype = 1 ETHERNET 
47
        SIGNAL          arp_PTYPE_ok            :       STD_LOGIC;--PTYPE = 4  IPv4
48
        SIGNAL          arp_HLEN_ok             :       STD_LOGIC; -- HLEN =6 OCTETS MAC ADDRESS
49
        SIGNAL          arp_PLEN_ok             :       STD_LOGIC;--PLEN = 4 OCTETS IP ADDRESS
50
        SIGNAL          arp_operation_ok        :       STD_LOGIC; -- ARP REQUEST  = 1
51
        SIGNAL          arp_ip1_int_ok          :       STD_LOGIC;
52
        SIGNAL          arp_ip2_int_ok          :       STD_LOGIC;
53
        SIGNAL          arp_ip1_ext_ok          :       STD_LOGIC;
54
        SIGNAL          arp_ip2_ext_ok          :       STD_LOGIC;
55
        SIGNAL          arp_dest_mac_ok_p       :       STD_LOGIC;
56
        SIGNAL          arp_port_ok_p           :       STD_LOGIC;
57
        SIGNAL          arp_HTYPE_ok_p          :       STD_LOGIC;
58
        SIGNAL          arp_PTYPE_ok_p          :       STD_LOGIC;
59
        SIGNAL          arp_HLEN_ok_p           :       STD_LOGIC;
60
        SIGNAL          arp_PLEN_ok_p           :       STD_LOGIC;
61
        SIGNAL          arp_operation_ok_p      :       STD_LOGIC;
62
        SIGNAL          arp_ip1_int_ok_p                :       STD_LOGIC;
63
        SIGNAL          arp_ip2_int_ok_p                :       STD_LOGIC;
64
        SIGNAL          arp_ip1_ext_ok_p                :       STD_LOGIC;
65
        SIGNAL          arp_ip2_ext_ok_p                :       STD_LOGIC;
66
-----------signal to check Balance Traffic Module ---------------
67
        SIGNAL          my_mac                          :       STD_LOGIC_VECTOR(47 DOWNTO 0); ------This is A Register to Store my MAC Address
68
        SIGNAL          my_mac_ok                       :       STD_LOGIC;
69
        SIGNAL          my_mac_ok_p             :       STD_LOGIC;---pipe line version of my_mac_ok.
70
        SIGNAL          balance_ok              :       STD_LOGIC;
71
-------------------------------------------
72
-----------signal to check Router Traffic Module ---------------
73
        SIGNAL          ip_packet_ok            :       STD_LOGIC       ;
74
        SIGNAL          udp_ok                          :       STD_LOGIC       ;
75
        SIGNAL          tcp_ok                          :       STD_LOGIC       ;
76
        SIGNAL          ospf_proto_ok           :       STD_LOGIC       ;
77
        SIGNAL          rip_port_ok             :       STD_LOGIC       ;
78
        SIGNAL          bgp_port_ok             :       STD_LOGIC       ;
79
        SIGNAL          ip_packet_ok_p          :       STD_LOGIC       ;
80
        SIGNAL          udp_ok_p                        :       STD_LOGIC       ;
81
        SIGNAL          tcp_ok_p                        :       STD_LOGIC       ;
82
        SIGNAL          ospf_proto_ok_p         :       STD_LOGIC       ;
83
        SIGNAL          rip_port_ok_p           :       STD_LOGIC       ;
84
        SIGNAL          bgp_port_ok_p           :       STD_LOGIC       ;
85
        SIGNAL          router_ok                       :       STD_LOGIC       ;
86
-------------------------------------------
87
    SIGNAL              classifier_start        :       STD_LOGIC;
88
        SIGNAL          classifier_done         :       STD_LOGIC;
89
        SIGNAL          classifier_done_p       :       STD_LOGIC;
90
------------------------------------------------------- 
91
        SIGNAL          manage_ok                       :       STD_LOGIC;
92
        SIGNAL          manage_ip_packet_ok :   STD_LOGIC;
93
        SIGNAL          manage_udp_ok           :       STD_LOGIC;
94
        SIGNAL          manage_ip_addmulti_p1_ok :      STD_LOGIC;
95
        SIGNAL          manage_ip_addmulti_p2_ok :      STD_LOGIC;
96
        SIGNAL          manage_ip_adduni_p1_ok :        STD_LOGIC;
97
        SIGNAL          manage_ip_adduni_p2_ok :        STD_LOGIC;
98
        SIGNAL          manage_port_ok          :       STD_LOGIC;
99
        SIGNAL          manage_hello_ok         :       STD_LOGIC;
100
        SIGNAL          manage_ip_packet_ok_p :         STD_LOGIC;
101
        SIGNAL          manage_ip_addmulti_p1_ok_p :    STD_LOGIC;
102
        SIGNAL          manage_ip_addmulti_p2_ok_p :    STD_LOGIC;
103
        SIGNAL          manage_ip_adduni_p1_ok_p :      STD_LOGIC;
104
        SIGNAL          manage_ip_adduni_p2_ok_p :      STD_LOGIC;
105
        SIGNAL          manage_udp_ok_p         :       STD_LOGIC;
106
        SIGNAL          manage_port_ok_p                :       STD_LOGIC;
107
        SIGNAL          manage_hello_ok_p       :       STD_LOGIC;
108
        ---------------------------------------------------
109
        SIGNAL          internal_ok             :       STD_LOGIC;
110
        SIGNAL          int_ok_p                :       STD_LOGIC;
111
        SIGNAL          int_ok  :       STD_LOGIC;
112
        ----------------------------------------------------
113
        SIGNAL          pkt_type_i                      :               STD_LOGIC_VECTOR(7 DOWNTO 0)     ;
114
        SIGNAL          pkt_type_rdy_i          :       STD_LOGIC       ;
115
        BEGIN
116
--------------read the source port process
117
        PROCESS(clk)
118
                BEGIN
119
 
120
                        IF RISING_EDGE( clk )THEN
121
                                        IF( in_wr = '1' AND in_ctrl=X"FF"  ) THEN
122
                                                IF in_data(31 DOWNTO 16)=X"0000" THEN
123
                                                                source_port <= "00";
124
                                                        ELSIF in_data(31 DOWNTO 16)=X"0002" THEN
125
                                                                source_port <= "01";
126
                                                        ELSIF in_data(31 DOWNTO 16)=X"0004" THEN
127
                                                                source_port <= "10";
128
                                                        ELSIF in_data(31 DOWNTO 16)=X"0006" THEN
129
                                                                source_port <= "11";
130
                                                END IF;
131
                                        END IF;
132
                        END IF;
133
                END PROCESS;
134
 
135
---------------------------------------------   
136
                PROCESS(reset,clk)
137
                BEGIN
138
 
139
                        IF clk'EVENT AND clk ='1' THEN
140
                                pkt_type_rdy <= pkt_type_rdy_i  ;
141
                        END IF;
142
                END PROCESS;
143
 
144
 
145
 
146
 
147
                PROCESS(reset,clk)
148
                BEGIN
149
                        IF (reset ='1') THEN
150
                                state <=READ_HEADER;
151
                        ELSIF clk'EVENT AND clk ='1' THEN
152
                                state<=state_next;
153
                        END IF;
154
                END PROCESS;
155
 
156
                PROCESS(state , in_ctrl , in_wr)
157
                BEGIN
158
                                                                         pkt_type_rdy_i <='0';
159
                                                                         pkt_type <="00000000";
160
                                                                         pkt_type(7) <= (NOT balance_ok )AND ( NOT router_ok) and  (not internal_ok ) AND ( NOT manage_ok) and (not arp_ok) ;
161
                                                                         pkt_type(4) <= internal_ok AND ( NOT manage_ok) and (not arp_ok);--AND (NOT manage_ok) AND NOT (arp_ok);
162
                                                                    pkt_type(3) <= manage_ok;
163
                                                                         pkt_type(2) <= router_ok   and (not arp_ok);
164
                                                                         pkt_type(1) <= balance_ok  AND ( NOT router_ok) and (not arp_ok)  ;
165
                                                                         pkt_type(0) <= arp_ok;
166
                                                                         classifier_start                               <='0';
167
                                                                         state_next                                <=  state;
168
                        CASE state IS
169
                                WHEN READ_HEADER =>
170
                                        IF( in_wr = '1' AND in_ctrl=X"FF"  ) THEN
171
                                                                                                        classifier_start                                <='1';
172
                                                                                                        state_next                 <=  READ_WORD_1;
173
                                        END IF;
174
 
175
                                WHEN READ_WORD_1 =>
176
                                        IF( in_wr = '1') THEN
177
 
178
                                                                                                        state_next                <=  READ_WORD_2;
179
 
180
                                                END IF;
181
 
182
                                WHEN READ_WORD_2 =>
183
 
184
                                        IF(in_wr = '1' ) THEN
185
                                                                                                        state_next                <= READ_WORD_3;
186
 
187
                                        END IF;
188
 
189
                                WHEN READ_WORD_3 =>
190
 
191
                                        IF(in_wr = '1' ) THEN
192
                                                                                                        state_next               <= READ_WORD_4;
193
 
194
                                        END IF;
195
                                WHEN READ_WORD_4 =>
196
 
197
                                        IF(in_wr = '1' ) THEN
198
 
199
                                                                                                        state_next               <= READ_WORD_5;
200
 
201
                                        END IF;
202
                                WHEN READ_WORD_5 =>
203
 
204
                                        IF(in_wr = '1' ) THEN
205
 
206
                                                                                                        state_next               <= READ_WORD_6;
207
 
208
                                        END IF;
209
                                WHEN READ_WORD_6 =>
210
 
211
                                        IF(in_wr = '1' ) THEN
212
 
213
                                                                                                        state_next               <= READ_WORD_7;
214
 
215
                                        END IF;
216
                                WHEN READ_WORD_7 =>
217
                                        IF(in_wr = '1'  ) THEN pkt_type_rdy_i <='1';
218
                                                                                                        state_next               <= READ_HEADER;
219
                                        END IF;
220
                                WHEN OTHERS =>
221
                                                                                                        state_next              <= READ_HEADER;
222
                        END CASE;
223
                END PROCESS;
224
 
225
--------------------------------ARP Check-------------
226
PROCESS(state, in_wr, in_ctrl, in_data)
227
                BEGIN
228
                                                                                         arp_dest_mac_ok                   <= '0'; --DEST MAC = FF:FF:FF:FF:FF:FF
229
                                                                                         arp_port_ok                       <= '0'; -- ARP PORT = X0806
230
                                                                                         arp_HTYPE_ok                      <= '0'; --htype = 1 ETHERNET 
231
                                                                                         arp_PTYPE_ok                      <= '0';--PTYPE = 4  IPv4
232
                                                                                         arp_HLEN_ok                       <= '0'; -- HLEN =6 OCTETS MAC ADDRESS
233
                                                                                         arp_PLEN_ok                       <= '0';--PLEN = 4 OCTETS IP ADDRESS
234
                                                                                         arp_operation_ok               <= '0'; -- ARP REQUEST  = 1
235
                                                                                         arp_ip1_int_ok         <= '0';
236
                                                                                         arp_ip2_int_ok             <= '0';
237
                                                                                         arp_ip1_ext_ok         <= '0';
238
                                                                                         arp_ip2_ext_ok             <= '0';
239
                        CASE state IS
240
 
241
                                WHEN READ_WORD_1 =>
242
 
243
                                                IF (in_data(63 DOWNTO 16)=X"FFFFFFFFFFFF")THEN  arp_dest_mac_ok                 <= '1'; END IF;
244
                                WHEN READ_WORD_2 =>
245
 
246
                                                IF (in_data(31 DOWNTO 16)=X"0806")THEN  arp_port_ok     <= '1'; END IF;
247
                                                IF (in_data(15 DOWNTO 0)=X"0001")THEN  arp_HTYPE_ok      <= '1'; END IF;
248
 
249
 
250
                                WHEN READ_WORD_3 =>
251
 
252
 
253
                                                IF (in_data(63 DOWNTO 48)=X"0800")THEN  arp_PTYPE_ok            <= '1'; END IF;
254
                                                IF (in_data(47 DOWNTO 40)=X"06")THEN  arp_HLEN_ok               <= '1'; END IF;
255
                                                IF (in_data(39 DOWNTO 32)=X"04")THEN  arp_PLEN_ok               <= '1'; END IF;
256
                                                IF (in_data(31 DOWNTO 16)=X"0001")THEN  arp_Operation_ok                <= '1'; END IF;
257
 
258
                                WHEN READ_WORD_5 =>
259
                                IF status_array(CONV_INTEGER(source_port))='0' THEN
260
                                IF (in_data(15 DOWNTO 0)=ip_array(CONV_INTEGER(source_port))(31 downto 16))THEN
261
                                                                                                arp_ip1_ext_ok          <= '1'; END IF;
262
                                ELSE
263
                                IF (in_data(15 DOWNTO 0)=DIST_UNICAST_LB(31 downto 16))THEN
264
                                                                                                arp_ip1_int_ok          <= '1'; END IF;
265
                                END IF;
266
                                WHEN READ_WORD_6 =>
267
                                IF status_array(CONV_INTEGER(source_port))='0' THEN
268
                                IF (in_data(63 DOWNTO 48)=ip_array(CONV_INTEGER(source_port))(15 downto 0))THEN
269
                                                                                                arp_ip2_ext_ok          <= '1'; END IF;
270
                                ELSE
271
                                IF (in_data(63 DOWNTO 48)=DIST_UNICAST_LB(15 downto 0))THEN
272
                                                                                                arp_ip2_int_ok          <= '1'; END IF;
273
                                END IF;
274
--                              WHEN READ_WORD_5 =>
275
--                              IF (in_data(15 DOWNTO 0)=X"C0A8")THEN  
276
--                                                                                              arp_ip1_ok              <= '1'; END IF;
277
--                              WHEN READ_WORD_6 =>     
278
--                              IF (in_data(63 DOWNTO 48)=X"0101")THEN
279
--                                                                                              arp_ip2_ok              <= '1'; END IF;
280
                                WHEN OTHERS =>
281
 
282
                        END CASE;
283
                END PROCESS;
284
 
285
 
286
                PROCESS(classifier_start, clk)
287
                BEGIN
288
                IF (classifier_start ='1') THEN
289
                                                                                                        classifier_done_p<='0';
290
                                                                                                        arp_dest_mac_ok_p               <= '0';
291
                                                                                                        arp_port_ok_p                   <= '0';
292
                                                                                                        arp_HTYPE_ok_p                  <= '0';
293
                                                                                                        arp_PTYPE_ok_p                  <= '0';
294
                                                                                                        arp_HLEN_ok_p                   <= '0';
295
                                                                                                        arp_PLEN_ok_p                   <= '0';
296
                                                                                                        arp_operation_ok_p              <= '0';
297
                                                                                                        arp_ip1_int_ok_p                <= '0';
298
                                                                                                        arp_ip2_int_ok_p            <= '0';
299
                                                                                                        arp_ip1_ext_ok_p                <= '0';
300
                                                                                                        arp_ip2_ext_ok_p            <= '0';
301
 
302
                ELSIF clk'EVENT AND clk =       '1' THEN
303
                        IF classifier_done      =       '1'     THEN    classifier_done_p               <= '1'; END IF;
304
                        IF arp_dest_mac_ok      =       '1'     THEN    arp_dest_mac_ok_p               <= '1'; END IF;
305
                        IF arp_port_ok          =       '1'     THEN    arp_port_ok_p                   <= '1'; END IF;
306
                        IF arp_HTYPE_ok         =       '1'             THEN    arp_HTYPE_ok_p                  <= '1'; END IF;
307
                        IF arp_PTYPE_ok         =       '1'             THEN    arp_PTYPE_ok_p                  <= '1'; END IF;
308
                        IF arp_HLEN_ok          =       '1'     THEN    arp_HLEN_ok_p                   <= '1'; END IF;
309
                        IF arp_PLEN_ok          =       '1'     THEN    arp_PLEN_ok_p                   <= '1'; END IF;
310
                        IF arp_operation_ok =   '1'     THEN    arp_operation_ok_p      <= '1'; END IF;
311
                        IF arp_ip1_int_ok               =       '1'     THEN    arp_ip1_int_ok_p                    <= '1';     END IF;
312
                        IF arp_ip2_int_ok               =       '1'     THEN    arp_ip2_int_ok_p                    <= '1';     END IF;
313
                        IF arp_ip1_ext_ok               =       '1'     THEN    arp_ip1_ext_ok_p                    <= '1';     END IF;
314
                        IF arp_ip2_ext_ok               =       '1'     THEN    arp_ip2_ext_ok_p                    <= '1';     END IF;
315
                END IF;
316
                END PROCESS;
317
                arp_ok <=  arp_port_ok_p AND arp_HTYPE_ok_p AND arp_PTYPE_ok_p AND arp_HLEN_ok_p
318
                AND arp_PLEN_ok_p AND arp_operation_ok_p
319
                AND ((arp_ip1_int_ok_p and arp_ip2_int_ok_p) OR (arp_ip1_ext_ok_p and arp_ip2_ext_ok_p));
320
-------------------------------------------------------------------
321
-----------Process  to check Balance Traffic Module ---------------
322
-------------------------------------------------------------------
323
 
324
 
325
 
326
                PROCESS(state,  in_data)
327
                BEGIN
328
                                my_mac_ok               <= '0';
329
                        CASE state IS
330
                                WHEN READ_WORD_1 =>
331
                IF (status_array(CONV_INTEGER(source_port))='0') THEN
332
                                        IF (in_data(63 DOWNTO 16)=mac_array(CONV_INTEGER(source_port)))THEN  my_mac_ok          <= '1'; END IF;
333
--              IF (in_data(63 DOWNTO 16)=X"CCCCCCCCCCCC")THEN  my_mac_ok               <= '1'; END IF; 
334
                                END IF;
335
                                WHEN OTHERS =>                                                             my_mac_ok            <= '0';
336
 
337
                        END CASE;
338
                END PROCESS;
339
PROCESS(classifier_start, clk)
340
                BEGIN
341
                IF (classifier_start ='1') THEN
342
                                                                                                                          my_mac_ok_p           <='0';
343
 
344
                ELSIF clk'EVENT AND clk =       '1' THEN
345
                        IF my_mac_ok    =       '1'     THEN                              my_mac_ok_p           <='1'; END IF;
346
                END IF;
347
                END PROCESS;
348
                                                        balance_ok <= my_mac_ok_p;
349
---------------------------------------------------------------------
350
-------------Process  to check Balance Traffic Module ---------------
351
---------------------------------------------------------------------
352
--
353
---------------------------------------------------------------------
354
-------------Process  to check Router Traffic Module ---------------
355
---------------------------------------------------------------------
356
--      
357
----               Proto     Protocol_Num      TCP Port      UDP Port
358
----            ------------|---------------|--------------|-----------
359
----            1.RIP V1           17             NO           520 
360
----            ------------|---------------|--------------|-----------
361
----            2.OSPF             89              NO           NO 
362
----            ------------|---------------|--------------|-----------
363
----            6.BGP              6             179            NO 
364
----            ------------|---------------|--------------|-----------
365
--      
366
                PROCESS(state,  in_data)
367
                                BEGIN
368
                                                                                        ip_packet_ok    <= '0';
369
                                                                                        udp_ok                  <= '0';
370
                                                                                        tcp_ok                  <= '0';
371
                                                                                        ospf_proto_ok   <= '0';
372
                                                                                        rip_port_ok     <= '0';
373
                                                                                        bgp_port_ok     <= '0';
374
                        CASE state IS
375
                                WHEN READ_WORD_1 =>
376
                                --Dest MAC Address{6 Bytes}
377
                                --Src MAC(47..32){2 Bytes}                                                      
378
 
379
                                WHEN READ_WORD_2 =>
380
                                --Src MAC(31 ..0){4 Bytes}
381
                                --Ethernet Type{2 Bytes}
382
                                --Start IP Packet.---------
383
                                --Version(4..0) Header_length(4..0)     Differentiated_Services(7..0){2 Bytes}
384
                                                IF (status_array(CONV_INTEGER(source_port))='0') THEN
385
                                                IF (in_data(31 DOWNTO 16)=X"0800")THEN  ip_packet_ok            <= '1'; END IF;--IP packet
386
                                                END IF;
387
                                WHEN READ_WORD_3 =>
388
                                --Total_Length(15..0){2 Bytes}                                          
389
                                --Identification(15..0){2 Bytes}
390
                                --Flags(4..0)   Fragment_Offse(11..0){2 Bytes}
391
                                --Time to Live(7:0){1 Bytes}    
392
                                --Protocol(7:0){1 Bytes}                                                
393
                                        IF (in_data(7 DOWNTO 0)=X"11")THEN  udp_ok               <= '1'; END IF;--17
394
                                        IF (in_data(7 DOWNTO 0)=X"06")THEN  tcp_ok               <= '1'; END IF;--6
395
                                        IF (in_data(7 DOWNTO 0)=X"59")THEN  ospf_proto_ok                <= '1'; END IF;--89     
396
                                WHEN READ_WORD_4 =>
397
                                --Header Checksum(15:0){2 Bytes}
398
                                --Source Address(31:0){4 Bytes}
399
                                --Destination Address(31:16){2 Bytes}
400
 
401
                                WHEN READ_WORD_5 =>
402
                                --Destination Address(15:0)     {2 Bytes}
403
                                --Option 
404
                                --TCP AND UDP ---
405
                                --Source_Port(15:0)     Destination_Port(15:0){4 Bytes}
406
                                 IF (in_data(47 DOWNTO 32)=X"0208")THEN    rip_port_ok          <= '1'; END IF;--17
407
                                 IF (in_data(47 DOWNTO 32)=X"00B3")  THEN    bgp_port_ok        <= '1'; END IF;--6
408
 
409
                                WHEN OTHERS =>
410
 
411
                        END CASE;
412
                END PROCESS;
413
PROCESS(classifier_start, clk)
414
                BEGIN
415
                IF (classifier_start ='1') THEN
416
                                                                                                                                ip_packet_ok_p          <= '0';
417
                                                                                                                                udp_ok_p                        <= '0';
418
                                                                                                                                tcp_ok_p                        <= '0';
419
                                                                                                                                ospf_proto_ok_p         <= '0';
420
                                                                                                                                rip_port_ok_p           <= '0';
421
                                                                                                                                bgp_port_ok_p           <= '0';
422
 
423
                ELSIF clk'EVENT AND clk =        '1' THEN
424
                        IF ip_packet_ok         =        '1'    THEN                            ip_packet_ok_p          <='1'; END IF;
425
                        IF udp_ok                       =        '1'    THEN                            udp_ok_p                        <='1'; END IF;
426
                        IF tcp_ok                       =        '1'    THEN                            tcp_ok_p                        <='1'; END IF;
427
                        IF ospf_proto_ok        =        '1'    THEN                            ospf_proto_ok_p         <='1'; END IF;
428
                        IF rip_port_ok      =    '1'    THEN                            rip_port_ok_p           <='1'; END IF;
429
                        IF bgp_port_ok  =        '1'    THEN                            bgp_port_ok_p           <='1'; END IF;
430
                END IF;
431
                END PROCESS;
432
router_ok <=    (ip_packet_ok_p AND udp_ok_p AND rip_port_ok_p)--RIP
433
                         OR (ip_packet_ok_p AND tcp_ok_p AND bgp_port_ok_p)--BGP
434
                         OR (ip_packet_ok_p AND ospf_proto_ok_p ); --OSPF
435
---------------------------------------------------------------------
436
-------------Process  to check Router Traffic Module ---------------
437
---------------------------------------------------------------------
438
------------Process  to check Manager Traffic Module ---------------
439
---------------------------------------------------------------------
440
 
441
                PROCESS(state,  in_data)
442
                BEGIN
443
                                                                                                        manage_ip_packet_ok             <= '0';
444
                                                                                                        manage_udp_ok                           <= '0';
445
                                                                                                        manage_ip_addmulti_p1_ok        <= '0';
446
                                                                                                        manage_ip_addmulti_p2_ok        <= '0';
447
                                                                                                        manage_ip_adduni_p1_ok      <= '0';
448
                                                                                                        manage_ip_adduni_p2_ok      <= '0';
449
                                                                                                        manage_port_ok                          <= '0';
450
                                                                                                        manage_hello_ok                         <= '0';
451
                CASE state IS
452
                        WHEN READ_WORD_2 =>
453
                                        IF (status_array(CONV_INTEGER(source_port))='1')        THEN
454
                        IF (in_data(31 DOWNTO 16)=X"0800")THEN  manage_ip_packet_ok             <= '1'; END IF;
455
                        END IF;
456
                        WHEN READ_WORD_3 =>
457
                        IF (in_data(7 DOWNTO 0)=X"11")THEN       manage_udp_ok                   <= '1'; END IF;--17
458
                        WHEN READ_WORD_4 =>
459
                        IF (in_data(15 DOWNTO 0)=DIST_MULTICAST_LB(31 DOWNTO 16))        THEN
460
                                                                                                        manage_ip_addmulti_p1_ok        <= '1'; END IF;
461
                        IF      (in_data(15 DOWNTO 0)=DIST_UNICAST_LB(31 DOWNTO 16)      )       THEN
462
                                                                                                        manage_ip_adduni_p1_ok  <= '1'; END IF;
463
                                --Destination Address(31:16){2 Bytes}
464
                        WHEN READ_WORD_5 =>
465
                                --Destination Address(15:0)     {2 Bytes}
466
                        IF (in_data(63 DOWNTO 48)=DIST_MULTICAST_LB(15 DOWNTO 0))        THEN
467
                                                                                                        manage_ip_addmulti_p2_ok        <= '1'; END IF;
468
                        IF      (in_data(63 DOWNTO 48)=DIST_UNICAST_LB(15 DOWNTO 0)      )       THEN
469
                                                                                                        manage_ip_adduni_p2_ok          <= '1'; END IF;
470
                                --Source_Port(15:0)     Destination_Port(15:0){4 Bytes}
471
                        IF (in_data(47 DOWNTO 32)=DIST_PORT AND in_data(31 DOWNTO 16)=DIST_PORT) THEN
472
                                                                                                    manage_port_ok                              <= '1'; END IF;
473
--                              --DIST Message Version and Type
474
--                      IF (in_data(15 DOWNTO 8)=DIST_VER AND in_data(7 DOWNTO 0)=DIST_MSGTYPE) THEN
475
--                                                                                                  manage_hello_ok                     <= '1'; END IF;
476
 
477
                        WHEN READ_WORD_6 =>
478
                                --DIST Message Version and Type
479
                        IF (in_data(47 DOWNTO 40)=DIST_VER AND in_data(39 DOWNTO 32)=DIST_MSGTYPE) THEN
480
                                                                                                    manage_hello_ok                     <= '1'; END IF;
481
                        WHEN OTHERS =>
482
 
483
 
484
                        END CASE;
485
                END PROCESS;
486
PROCESS(classifier_start, clk)
487
                BEGIN
488
                IF (classifier_start ='1') THEN
489
                                                                                                                manage_ip_packet_ok_p           <= '0';
490
                                                                                                                manage_udp_ok_p                         <= '0';
491
                                                                                                                manage_ip_addmulti_p1_ok_p      <= '0';
492
                                                                                                                manage_ip_addmulti_p2_ok_p      <= '0';
493
                                                                                                                manage_ip_adduni_p1_ok_p        <= '0';
494
                                                                                                                manage_ip_adduni_p2_ok_p        <= '0';
495
                                                                                                                manage_port_ok_p                        <= '0';
496
                                                                                                                manage_hello_ok_p                       <= '0';
497
 
498
                ELSIF clk'EVENT AND clk =       '1' THEN
499
                        IF manage_ip_packet_ok  =       '1' THEN                manage_ip_packet_ok_p           <='1'; END IF;
500
                        IF manage_udp_ok                =       '1' THEN                manage_udp_ok_p                         <='1'; END IF;
501
                        IF manage_ip_addmulti_p1_ok     =       '1' THEN        manage_ip_addmulti_p1_ok_p      <='1'; END IF;
502
                        IF manage_ip_addmulti_p2_ok     =       '1' THEN        manage_ip_addmulti_p2_ok_p      <='1'; END IF;
503
                        IF manage_ip_adduni_p1_ok       =       '1' THEN        manage_ip_adduni_p1_ok_p        <='1'; END IF;
504
                        IF manage_ip_adduni_p2_ok       =       '1' THEN        manage_ip_adduni_p2_ok_p        <='1'; END IF;
505
                        IF manage_port_ok       =       '1' THEN                        manage_port_ok_p                        <='1'; END IF;
506
                        IF manage_hello_ok      =       '1' THEN                        manage_hello_ok_p                       <='1'; END IF;
507
 
508
                END IF;
509
                END PROCESS;
510
                                                        manage_ok <= manage_ip_packet_ok_p AND manage_udp_ok_p AND
511
                                                                                ((manage_ip_addmulti_p1_ok_p AND manage_ip_addmulti_p2_ok_p)
512
                                                                        OR      (manage_ip_adduni_p1_ok_p AND manage_ip_adduni_p2_ok_p))        AND
513
                                                                                 manage_port_ok_p AND manage_hello_ok_p ;
514
 
515
                -------------------INT => EXT -------------
516
 
517
                PROCESS(state,  in_data)
518
                BEGIN
519
                                int_ok          <= '0';
520
                        CASE state IS
521
                                WHEN READ_WORD_1 =>
522
 
523
                                                IF (status_array(CONV_INTEGER(source_port))='1')THEN  int_ok            <= '1'; END IF;
524
                                WHEN OTHERS =>                                                             int_ok               <= '0';
525
 
526
                        END CASE;
527
                END PROCESS;
528
        PROCESS(classifier_start, clk)
529
                        BEGIN
530
                        IF (classifier_start ='1') THEN
531
                                                                                                                                  int_ok_p              <='0';
532
 
533
                        ELSIF clk'EVENT AND clk =       '1' THEN
534
                                IF int_ok       =       '1'     THEN                                      int_ok_p              <='1'; END IF;
535
                        END IF;
536
                        END PROCESS;
537
                                                        internal_ok <= int_ok_p;
538
 
539
END behavior;
540
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.