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

Subversion Repositories the_wizardry_project

[/] [the_wizardry_project/] [trunk/] [Wizardry/] [VHDL/] [Wizardry Top Level/] [Address Generation/] [NIDS Components/] [EmPAC/] [new_empac_top.vhd] - Blame information for rev 18

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 18 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
-- Design Name: Marlon Winder
23
-- Module Name: new_empac_top - Behavioral 
24
-- Project Name: Wizardry
25
-- Target Devices: Virtex 4 ML401
26
-- Tool versions: 
27
-- Description: Top-level structural description for EmPAC Component.
28
--
29
-- Dependencies: 
30
--
31
-- Revision: 
32
-- Revision 0.01 - File Created
33
-- Additional Comments: 
34
--
35
----------------------------------------------------------------------------------
36
library IEEE;
37
use IEEE.STD_LOGIC_1164.ALL;
38
use IEEE.STD_LOGIC_ARITH.ALL;
39
use IEEE.STD_LOGIC_UNSIGNED.ALL;
40
use work.port_block_constants.all;
41
---- Uncomment the following library declaration if instantiating
42
---- any Xilinx primitives in this code.
43
--library UNISIM;
44
--use UNISIM.VComponents.all;
45
 
46
entity new_empac_top is
47
port(
48
                sys_clock : in std_logic;                                       -- 100 Mhz clock
49
                clock : in std_logic;                                           -- 12.5 Mhz clock
50
                reset_100 : in std_logic;                                       -- 100 Mhz reset
51
                reset : in std_logic;                                           -- 12. 5 Mhz reset
52
                EmPAC_leds : out std_logic_vector(8 downto 0);  -- These LED's are used for debugging and are connected
53
                phy_data : in std_logic_vector(7 downto 0);  -- 8 bit phy data comming in at 12.5 Mhz
54
                phy_data_valid : in std_logic;               -- When asserted, indicates that the "phy_data" is valid
55
                field_data : out std_logic_vector(31 downto 0);          --  This is the parsed frame data.  Each 32 bit vector
56
                field_type : out std_logic_vector(7 downto 0);           --  corresponds to the "field_type" indicated.  
57
                                                                                                                                                        --  Each field type vector corresponds to a specific portion of the packet
58
                data_ready : out std_logic;                                                             --  When "data_ready" is asserted, the data on "field_data"
59
                                                                                                                                                        --  is valid.  The parsed frame data is the "primary" output
60
                                                                                                                                                        --  of this component.  EmPAC's output connects directly to 
61
                                                                                                                                                        --  eRCP's input (actually, there is a FIFO sitting between them :) )
62
 
63
                -- Wishbone compliant memory interface
64
                -- These signals connect to RDIC and provide a method for EmPAC to access the DDR SDRAM
65
                ack_i : in  STD_LOGIC;                                                                          --  Wishbone acknowledge
66
      dat_i : in  STD_LOGIC_vector(31 downto 0);                 --  Incoming data from Wishbone interface
67
      dat_o : out  STD_LOGIC_VECTOR (31 downto 0);                       --  etc...
68
      adr_o : out  STD_LOGIC_VECTOR (21 downto 0);
69
      we_o : out  STD_LOGIC;
70
      cyc_o : out  STD_LOGIC;
71
      stb_o : out  STD_LOGIC;
72
                lock_o : out std_logic;
73
                priority_o : out std_logic_vector(7 downto 0);           --  Indicates the access priority for this component.
74
                id_o : out std_logic_Vector(4 downto 0);                         --  This signal allows other components to refer to EmPAC's shared memory space,
75
                                                                                                                                                        --  thereby eliminating the need for other components to know which port EmPAC is connected to.
76
 
77
 
78
                fifo_empty_out : out std_logic;                                                 --  Debug output from the PPT below
79
                fifo_full_out : out std_logic;                                                  --  Debug output from the PPT below
80
                fifo_push_count : out std_logic_vector(11 downto 0);  --  Debug output from PPT below
81
                end_of_frame : out std_logic                                                            --  Signals to eRCP (or any other components that is processing the parsed frames)
82
                                                                                                                                                        --  that the frame is finished (i.e. the preamble inbetween packets was recieved by EmPAC).
83
 
84
                );
85
end new_empac_top;
86
 
87
architecture Behavioral of new_empac_top is
88
 
89
 
90
-- Signals that connect components of EmPAC
91
signal data_ready_s : std_logic;
92
signal valid : std_logic;
93
signal field_data_early : std_logic_Vector(31 downto 0);
94
signal length1 : std_logic_vector(17 downto 0);--integer;
95
signal port_ind : std_logic;
96
signal length_ind : std_logic;
97
signal protocol_ind : std_logic;
98
signal src_port_found_s : std_Logic;
99
signal dst_port_found_s : std_Logic;
100
signal opt : std_logic;
101
signal field_type_s : std_logic_Vector(7 downto 0);
102
signal TCP_type : std_logic;
103
signal UDP_type : std_logic;
104
signal ICMP_type : std_logic;
105
signal field_data_s : std_logic_Vector(31 downto 0);
106
signal field_type_late : std_logic_vector(7 downto 0);
107
signal frame_counters : frame_counters_type;
108
signal field_type_0 : std_logic_vector(7 downto 0);
109
signal field_type_early : std_logic_vector(7 downto 0);
110
 
111
--  The assembler (new_assembler) accepts 8-bit phy data input, and assembles them into 32-bit vectors.
112
--  This output vector, "field_data_early", is accompannied by a "valid" signsl
113
--  that indicates the the 32 bit vector is ready to be processed by the next component,
114
--  the "protocol_fsm".  Notice that this field data is not the actual field data that 
115
--  is connected to field data.
116
 
117
--  Yeah...I know that some of the component names are a bit odd.  They are just what we used when we coded 
118
--  and never went back to change them ;)
119
 
120
component new_assembler is
121
    Port ( clock : in  STD_LOGIC;
122
           phy_data : in  STD_LOGIC_VECTOR (7 downto 0);
123
           phy_data_valid : in  STD_LOGIC;
124
           field_data_early : out  STD_LOGIC_VECTOR (31 downto 0);
125
                          valid : out std_logic
126
                          );
127
end component;
128
 
129
 
130
--  The protocol FSM (protocol_fsm) is a state machine that has states that correspond to each portion of the packet.
131
--  With a 32-bit field data input from new_assembler, this components classifies each of the 32 bit vectors according 
132
--  to which part of the packet is is.  This component also has inputs from the the "length_saver" component.
133
 
134
component protocol_fsm is
135
port(clock : in std_logic;
136
          reset : in std_logic;
137
          EmPAC_leds : out std_logic_Vector(8 downto 0);
138
          phy_data_valid : in std_logic;
139
          field_data_early : in std_logic_vector(31 downto 0);
140
          opt : in std_logic;
141
          length1 : in std_logic_vector(17 downto 0);
142
          TCP_type : in std_Logic;
143
          UDP_type : in std_logic;
144
          icmp_type : in std_logic;
145
          protocol_ind : out std_logic;
146
          length_ind : out std_logic;
147
          port_ind : out std_logic;
148
          field_type_early : out std_logic_Vector(7 downto 0);
149
          data_ready : out std_logic;
150
          field_type_out : out std_logic_vector(7 downto 0);
151
          field_data : out std_logic_vector(31 downto 0);
152
          end_of_frame : out std_logic
153
          );
154
end component;
155
 
156
 
157
--  The protocol saver (protocol_saver) accepts the field data as input from the new_assembler.  This component identifies
158
--  each packet as either TCP, UDP, or ICMP, which in turn enables the protocol fsm to properly parse the packets.
159
component protocol_saver is
160
    Port ( clock : in std_logic;
161
                          reset : in std_logic;
162
                          Protocol_indicator : in  STD_LOGIC;
163
           Field_data : in  STD_LOGIC_VECTOR (31 downto 0);
164
                          Field_type : in std_logic_vector(7 downto 0);
165
                          TCP_type_out : out std_logic;
166
                          UDP_type_out : out std_logic;
167
                          ICMP_type_out : out std_logic);
168
 
169
end component;
170
 
171
 
172
--  The length saver informs the protocol_fsm on how big each packet is supposed to be.
173
component lengthsaver IS
174
PORT(
175
        clock   : IN    std_logic;
176
        field_data      : IN       std_logic_vector (31 DOWNTO 0);
177
        length_indicator        : IN       std_logic;
178
        field_type : IN       std_logic_vector (7 DOWNTO 0);
179
        reset   : IN       std_logic;
180
        optional        :       OUT     std_logic;
181
        length1 : OUT   std_logic_vector (17 DOWNTO 0)
182
);
183
END component;
184
 
185
 
186
--  Counts the total number of packets of each type (TCP, IPV6, etc)
187
component frame_counting is
188
    Port ( clock : in  STD_LOGIC;
189
                          sys_clock : in std_logic;
190
           reset : in  STD_LOGIC;
191
--                        icmp_type : in std_logic;
192
           field_type : in  STD_LOGIC_VECTOR (7 downto 0);
193
                          field_data : in std_logic_Vector(7 downto 0);
194
           data_ready : in  STD_LOGIC;
195
                          frame_counters : out frame_counters_type);
196
end component;
197
 
198
 
199
--  This components tracks the ports that have been encountered.  Each time a new port type comes in,
200
--  
201
component port_block is
202
    Port ( sys_clock : in std_logic;
203
                          clock : in  STD_LOGIC;
204
                          reset_100 : in std_logic;
205
           reset : in  STD_LOGIC;
206
                          fifo_empty_out : out std_logic;
207
                          fifo_full_out : out std_logic;
208
                          field_data : in std_logic_vector(31 downto 0);
209
                          field_type : in std_logic_vector(7 downto 0);
210
                          data_ready : in std_logic;
211
                          frame_counters : in frame_counters_type;
212
           ack_i : in  STD_LOGIC;
213
           dat_i : in  STD_LOGIC_vector(31 downto 0);
214
           dat_o : out  STD_LOGIC_VECTOR (31 downto 0);
215
           adr_o : out  STD_LOGIC_VECTOR (21 downto 0);
216
           we_o : out  STD_LOGIC;
217
           cyc_o : out  STD_LOGIC;
218
           stb_o : out  STD_LOGIC;
219
                          fifo_push_count : out std_logic_vector(11 downto 0));
220
end component;
221
 
222
begin
223
-- Register the field data, field type and data ready signals
224
process(clock)
225
begin
226
        if rising_edge(clock) then
227
                data_ready <= data_ready_s;
228
                field_data <= field_data_s;
229
                field_type <= field_type_s;
230
        end if;
231
end process;
232
 
233
lock_o <= '0';
234
priority_o <= "00000001";  -- Highest priority
235
id_o <= "00001";  --  Device ID,  make sure that all components have a defferent id !!!
236
process(clock)
237
begin
238
        if rising_edge(clock) then
239
                field_type_late <= field_type_s;
240
        end if;
241
end process;
242
 
243
 
244
assemble: new_assembler
245
Port map ( clock => clock,
246
           phy_data => phy_data,
247
           phy_data_valid => phy_data_valid,
248
           field_data_early => field_data_early,
249
                          valid => valid
250
                          );
251
 
252
fsm: protocol_fsm
253
port map(clock => clock,
254
          reset => reset,
255
          EmPAC_leds => EmPAC_leds,
256
          phy_data_valid => valid,
257
          field_data_early => field_data_early,
258
          opt => opt,
259
          length1 => length1,
260
          TCP_type => TCP_type,
261
          UDP_type => UDP_type,
262
          icmp_type => icmp_type,
263
          protocol_ind => protocol_ind,
264
          length_ind => length_ind,
265
          port_ind => port_ind,
266
          field_type_early => field_type_early,
267
          data_ready => data_ready_s,
268
          field_data => field_data_s,
269
          field_type_out => field_type_s,
270
          end_of_frame => end_of_frame
271
          );
272
 
273
 
274
prot_type : protocol_saver
275
Port map( clock => clock,
276
                          reset => reset,
277
                          Protocol_indicator => protocol_ind,
278
           Field_data => field_data_early,
279
                          Field_type => field_type_early,
280
                          TCP_type_out => TCP_type,
281
                          UDP_type_out => UDP_type,
282
                          ICMP_type_out => ICMP_type);
283
 
284
length_save : lengthsaver
285
PORT map(
286
        clock   => clock,
287
        field_data      => field_data_early,
288
        length_indicator        => length_ind,
289
        field_type => field_type_early,
290
        reset   => reset,
291
        optional        => opt,
292
        length1 => length1
293
);
294
 
295
counts: frame_counting
296
    Port map( clock => clock,
297
                          sys_clock => sys_clock,
298
           reset => reset,
299
           field_type => field_type_s,
300
                          field_data => field_data_s(7 downto 0),
301
           data_ready => data_ready_s,
302
                          frame_counters => frame_counters);
303
 
304
ppt: port_block
305
    Port map( sys_clock => sys_clock,
306
                          clock => clock,
307
           reset => reset,
308
                          reset_100 => reset_100,
309
                          fifo_empty_out => fifo_empty_out,
310
                          fifo_full_out => fifo_full_out,
311
                          field_data => field_data_s,
312
                          field_type => field_type_s,
313
                          data_ready => data_ready_s,
314
                          frame_counters => frame_counters,
315
           ack_i => ack_i,
316
           dat_i => dat_i,
317
           dat_o => dat_o,
318
           adr_o => adr_o,
319
           we_o => we_o,
320
           cyc_o => cyc_o,
321
           stb_o => stb_o,
322
                          fifo_push_count => fifo_push_count);
323
 
324
end Behavioral;
325
 

powered by: WebSVN 2.1.0

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