1 |
145 |
lanttu |
-- ***************************************************
|
2 |
|
|
-- File: udp_flood_example_dm9000a.vhd
|
3 |
157 |
lanttu |
-- Creation date: 18.01.2013
|
4 |
|
|
-- Creation time: 12:46:22
|
5 |
145 |
lanttu |
-- Description: Simple example to test the connection FPGA -> PC.
|
6 |
|
|
--
|
7 |
|
|
-- Flooder unit sends all the time, UDP/IP block transfers them to PC. Designer can use netstat, netcat, wireshark or similar to catch the packet at the PC's end.
|
8 |
157 |
lanttu |
-- Created by: matilail
|
9 |
145 |
lanttu |
-- This file was generated with Kactus2 vhdl generator.
|
10 |
|
|
-- ***************************************************
|
11 |
|
|
library IEEE;
|
12 |
|
|
library work;
|
13 |
|
|
use IEEE.std_logic_1164.all;
|
14 |
|
|
use work.all;
|
15 |
|
|
|
16 |
|
|
entity udp_flood_example_dm9000a is
|
17 |
|
|
|
18 |
|
|
port (
|
19 |
|
|
|
20 |
|
|
-- Interface: clk_in
|
21 |
|
|
-- Clock input.
|
22 |
|
|
clk_in_CLK : in std_logic;
|
23 |
|
|
|
24 |
|
|
-- Interface: DM9000A
|
25 |
|
|
-- Connection to DM9000A chip (Ethernet PHY) found e.g. in DE2 board. Expects 25 MHz clock.
|
26 |
|
|
DM9000A_eth_interrupt_in : in std_logic;
|
27 |
|
|
DM9000A_eth_chip_sel_out : out std_logic;
|
28 |
|
|
DM9000A_eth_clk_out : out std_logic;
|
29 |
|
|
DM9000A_eth_cmd_out : out std_logic;
|
30 |
|
|
DM9000A_eth_read_out : out std_logic;
|
31 |
|
|
DM9000A_eth_reset_out : out std_logic;
|
32 |
|
|
DM9000A_eth_write_out : out std_logic;
|
33 |
|
|
DM9000A_eth_data_inout : inout std_logic_vector(15 downto 0);
|
34 |
|
|
|
35 |
|
|
-- Interface: link_up_out
|
36 |
|
|
-- 1-bit status
|
37 |
|
|
link_up_out_gpio_out : out std_logic;
|
38 |
|
|
|
39 |
|
|
-- Interface: rst_n
|
40 |
|
|
-- Active-low reset
|
41 |
|
|
rst_n_RESETn : in std_logic
|
42 |
|
|
);
|
43 |
|
|
|
44 |
|
|
end udp_flood_example_dm9000a;
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
architecture kactusHierarchical of udp_flood_example_dm9000a is
|
48 |
|
|
|
49 |
|
|
signal pll_flooderCLK : std_logic;
|
50 |
|
|
signal udp_flooderrxdest_port_out : std_logic_vector(15 downto 0);
|
51 |
|
|
signal floodertx_udpfatal_error_out : std_logic;
|
52 |
|
|
signal floodertx_udplink_up_out : std_logic;
|
53 |
|
|
signal udp_flooderrxnew_rx_out : std_logic;
|
54 |
|
|
signal floodertx_udpnew_tx_in : std_logic;
|
55 |
|
|
signal floodertx_udpno_arp_target_MAC_in : std_logic_vector(47 downto 0);
|
56 |
|
|
signal udp_flooderrxrx_data_out : std_logic_vector(15 downto 0);
|
57 |
|
|
signal udp_flooderrxrx_data_valid_out : std_logic;
|
58 |
|
|
signal udp_flooderrxrx_erroneous_out : std_logic;
|
59 |
|
|
signal udp_flooderrxrx_error_out : std_logic;
|
60 |
|
|
signal udp_flooderrxrx_len_out : std_logic_vector(10 downto 0);
|
61 |
|
|
signal udp_flooderrxrx_re_in : std_logic;
|
62 |
|
|
signal udp_flooderrxsource_addr_out : std_logic_vector(31 downto 0);
|
63 |
|
|
signal udp_flooderrxsource_port_out : std_logic_vector(15 downto 0);
|
64 |
|
|
signal floodertx_udpsource_port_in : std_logic_vector(15 downto 0);
|
65 |
|
|
signal floodertx_udptarget_addr_in : std_logic_vector(31 downto 0);
|
66 |
|
|
signal floodertx_udptarget_port_in : std_logic_vector(15 downto 0);
|
67 |
|
|
signal floodertx_udptx_data_in : std_logic_vector(15 downto 0);
|
68 |
|
|
signal floodertx_udptx_data_valid_in : std_logic;
|
69 |
|
|
signal floodertx_udptx_len_in : std_logic_vector(10 downto 0);
|
70 |
|
|
signal floodertx_udptx_re_out : std_logic;
|
71 |
|
|
|
72 |
|
|
-- Connect to UDP/IP controller. Creates TX operations as quickly as possible. Sends running numbers.
|
73 |
|
|
-- Destination and packet size are configurable by using generics.
|
74 |
|
|
component simple_udp_flood_example
|
75 |
|
|
generic (
|
76 |
|
|
data_width_g : integer := 16;
|
77 |
|
|
disable_arp_g : integer := 0;
|
78 |
|
|
packet_len_g : integer := 1000;
|
79 |
|
|
source_ip_port_g : integer := 6000;
|
80 |
|
|
target_MAC_addr_g : std_logic_vector(47 downto 0) := x"ACDCABBACD01";
|
81 |
|
|
target_ip_addr_g : std_logic_vector(31 downto 0) := x"0A000001";
|
82 |
|
|
target_ip_port_g : integer := 5000
|
83 |
|
|
|
84 |
|
|
);
|
85 |
|
|
port (
|
86 |
|
|
|
87 |
|
|
-- Interface: clk
|
88 |
|
|
-- Clock 25 MHz synchronous to UDP/IP/ETH clock.
|
89 |
|
|
clk : in std_logic;
|
90 |
|
|
|
91 |
|
|
-- Interface: link_up_out
|
92 |
|
|
-- Connect a LED here; rises a few seconds after the autonegotiation process is done.
|
93 |
|
|
link_up_out : out std_logic;
|
94 |
|
|
|
95 |
|
|
-- Interface: rst_n
|
96 |
|
|
-- rst_n
|
97 |
|
|
rst_n : in std_logic;
|
98 |
|
|
|
99 |
|
|
-- There ports are contained in many interfaces
|
100 |
|
|
fatal_error_in : in std_logic;
|
101 |
|
|
link_up_in : in std_logic;
|
102 |
|
|
|
103 |
|
|
-- Interface: udp_ip_rx
|
104 |
|
|
-- Optional, this example flooder just accepts all incoming data but does nothing with it.
|
105 |
|
|
dest_port_in : in std_logic_vector(15 downto 0);
|
106 |
|
|
new_rx_in : in std_logic;
|
107 |
|
|
rx_data_in : in std_logic_vector(15 downto 0);
|
108 |
|
|
rx_data_valid_in : in std_logic;
|
109 |
|
|
rx_erroneous_in : in std_logic;
|
110 |
|
|
rx_error_in : in std_logic;
|
111 |
|
|
rx_len_in : in std_logic_vector(10 downto 0);
|
112 |
|
|
source_addr_in : in std_logic_vector(31 downto 0);
|
113 |
|
|
source_port_in : in std_logic_vector(15 downto 0);
|
114 |
|
|
rx_re_out : out std_logic;
|
115 |
|
|
|
116 |
|
|
-- Interface: udp_ip_tx
|
117 |
|
|
-- Flooder sends
|
118 |
|
|
tx_re_in : in std_logic;
|
119 |
|
|
new_tx_out : out std_logic;
|
120 |
|
|
no_arp_target_MAC_out : out std_logic_vector(47 downto 0);
|
121 |
|
|
source_port_out : out std_logic_vector(15 downto 0);
|
122 |
|
|
target_addr_out : out std_logic_vector(31 downto 0);
|
123 |
|
|
target_port_out : out std_logic_vector(15 downto 0);
|
124 |
|
|
tx_data_out : out std_logic_vector(15 downto 0);
|
125 |
|
|
tx_data_valid_out : out std_logic;
|
126 |
|
|
tx_len_out : out std_logic_vector(10 downto 0)
|
127 |
|
|
|
128 |
|
|
);
|
129 |
|
|
end component;
|
130 |
|
|
|
131 |
|
|
-- DM9000A controller and UDP/IP.
|
132 |
|
|
component udp_ip_dm9000a
|
133 |
|
|
generic (
|
134 |
|
|
disable_arp_g : integer := 0;
|
135 |
|
|
disable_rx_g : integer := 0
|
136 |
|
|
|
137 |
|
|
);
|
138 |
|
|
port (
|
139 |
|
|
|
140 |
|
|
-- Interface: app_rx
|
141 |
|
|
-- Application receive operations
|
142 |
|
|
rx_re_in : in std_logic;
|
143 |
|
|
dest_port_out : out std_logic_vector(15 downto 0);
|
144 |
|
|
new_rx_out : out std_logic;
|
145 |
|
|
rx_data_out : out std_logic_vector(15 downto 0);
|
146 |
|
|
rx_data_valid_out : out std_logic;
|
147 |
|
|
rx_erroneous_out : out std_logic;
|
148 |
|
|
rx_error_out : out std_logic;
|
149 |
|
|
rx_len_out : out std_logic_vector(10 downto 0);
|
150 |
|
|
source_addr_out : out std_logic_vector(31 downto 0);
|
151 |
|
|
source_port_out : out std_logic_vector(15 downto 0);
|
152 |
|
|
|
153 |
|
|
-- Interface: app_tx
|
154 |
|
|
-- Application transmit operations
|
155 |
|
|
new_tx_in : in std_logic;
|
156 |
|
|
no_arp_target_MAC_in : in std_logic_vector(47 downto 0);
|
157 |
|
|
source_port_in : in std_logic_vector(15 downto 0);
|
158 |
|
|
target_addr_in : in std_logic_vector(31 downto 0);
|
159 |
|
|
target_port_in : in std_logic_vector(15 downto 0);
|
160 |
|
|
tx_data_in : in std_logic_vector(15 downto 0);
|
161 |
|
|
tx_data_valid_in : in std_logic;
|
162 |
|
|
tx_len_in : in std_logic_vector(10 downto 0);
|
163 |
|
|
tx_re_out : out std_logic;
|
164 |
|
|
|
165 |
|
|
-- Interface: clk
|
166 |
|
|
-- Clock 25 MHz in.
|
167 |
|
|
clk : in std_logic;
|
168 |
|
|
|
169 |
|
|
-- Interface: DM9000A
|
170 |
|
|
-- Connection to the DM9000A chip via IO pins.
|
171 |
|
|
eth_interrupt_in : in std_logic;
|
172 |
|
|
eth_chip_sel_out : out std_logic;
|
173 |
|
|
eth_clk_out : out std_logic;
|
174 |
|
|
eth_cmd_out : out std_logic;
|
175 |
|
|
eth_read_out : out std_logic;
|
176 |
|
|
eth_reset_out : out std_logic;
|
177 |
|
|
eth_write_out : out std_logic;
|
178 |
|
|
eth_data_inout : inout std_logic_vector(15 downto 0);
|
179 |
|
|
|
180 |
|
|
-- Interface: rst_n
|
181 |
|
|
-- Asynchronous reset active-low.
|
182 |
|
|
rst_n : in std_logic;
|
183 |
|
|
|
184 |
|
|
-- There ports are contained in many interfaces
|
185 |
|
|
fatal_error_out : out std_logic;
|
186 |
|
|
link_up_out : out std_logic
|
187 |
|
|
|
188 |
|
|
);
|
189 |
|
|
end component;
|
190 |
|
|
|
191 |
|
|
-- 25 MHz Altera ALTPLL instantiation for Cyclone II FPGA's with input clk of 50 MHz (mul = 1, div = 2)
|
192 |
|
|
component altera_de2_pll_25
|
193 |
|
|
port (
|
194 |
|
|
|
195 |
|
|
-- Interface: clk_in
|
196 |
|
|
-- Input clock (50 MHz, DE2 PIN_N2)
|
197 |
|
|
inclk0 : in std_logic;
|
198 |
|
|
|
199 |
|
|
-- Interface: clk_out
|
200 |
|
|
-- Output clock: input clock divided by 2.
|
201 |
|
|
c0 : out std_logic
|
202 |
|
|
|
203 |
|
|
);
|
204 |
|
|
end component;
|
205 |
|
|
|
206 |
|
|
-- You can write vhdl code after this tag and it is saved through the generator.
|
207 |
|
|
-- ##KACTUS2_BLACK_BOX_DECLARATIONS_BEGIN##
|
208 |
|
|
-- ##KACTUS2_BLACK_BOX_DECLARATIONS_END##
|
209 |
|
|
-- Stop writing your code after this tag.
|
210 |
|
|
|
211 |
|
|
|
212 |
|
|
begin
|
213 |
|
|
|
214 |
|
|
-- You can write vhdl code after this tag and it is saved through the generator.
|
215 |
|
|
-- ##KACTUS2_BLACK_BOX_ASSIGNMENTS_BEGIN##
|
216 |
|
|
-- ##KACTUS2_BLACK_BOX_ASSIGNMENTS_END##
|
217 |
|
|
-- Stop writing your code after this tag.
|
218 |
|
|
|
219 |
|
|
altera_de2_pll_25_1 : altera_de2_pll_25
|
220 |
|
|
port map (
|
221 |
|
|
c0 => pll_flooderCLK,
|
222 |
|
|
inclk0 => clk_in_CLK
|
223 |
|
|
);
|
224 |
|
|
|
225 |
|
|
simple_udp_flood_example_1 : simple_udp_flood_example
|
226 |
|
|
port map (
|
227 |
|
|
clk => pll_flooderCLK,
|
228 |
|
|
dest_port_in(15 downto 0) => udp_flooderrxdest_port_out(15 downto 0),
|
229 |
|
|
fatal_error_in => floodertx_udpfatal_error_out,
|
230 |
|
|
link_up_in => floodertx_udplink_up_out,
|
231 |
|
|
link_up_out => link_up_out_gpio_out,
|
232 |
|
|
new_rx_in => udp_flooderrxnew_rx_out,
|
233 |
|
|
new_tx_out => floodertx_udpnew_tx_in,
|
234 |
|
|
no_arp_target_MAC_out(47 downto 0) => floodertx_udpno_arp_target_MAC_in(47 downto 0),
|
235 |
|
|
rst_n => rst_n_RESETn,
|
236 |
|
|
rx_data_in(15 downto 0) => udp_flooderrxrx_data_out(15 downto 0),
|
237 |
|
|
rx_data_valid_in => udp_flooderrxrx_data_valid_out,
|
238 |
|
|
rx_erroneous_in => udp_flooderrxrx_erroneous_out,
|
239 |
|
|
rx_error_in => udp_flooderrxrx_error_out,
|
240 |
|
|
rx_len_in(10 downto 0) => udp_flooderrxrx_len_out(10 downto 0),
|
241 |
|
|
rx_re_out => udp_flooderrxrx_re_in,
|
242 |
|
|
source_addr_in(31 downto 0) => udp_flooderrxsource_addr_out(31 downto 0),
|
243 |
|
|
source_port_in(15 downto 0) => udp_flooderrxsource_port_out(15 downto 0),
|
244 |
|
|
source_port_out(15 downto 0) => floodertx_udpsource_port_in(15 downto 0),
|
245 |
|
|
target_addr_out(31 downto 0) => floodertx_udptarget_addr_in(31 downto 0),
|
246 |
|
|
target_port_out(15 downto 0) => floodertx_udptarget_port_in(15 downto 0),
|
247 |
|
|
tx_data_out(15 downto 0) => floodertx_udptx_data_in(15 downto 0),
|
248 |
|
|
tx_data_valid_out => floodertx_udptx_data_valid_in,
|
249 |
|
|
tx_len_out(10 downto 0) => floodertx_udptx_len_in(10 downto 0),
|
250 |
|
|
tx_re_in => floodertx_udptx_re_out
|
251 |
|
|
);
|
252 |
|
|
|
253 |
|
|
udp_ip_dm9000a_1 : udp_ip_dm9000a
|
254 |
|
|
port map (
|
255 |
|
|
clk => pll_flooderCLK,
|
256 |
|
|
dest_port_out(15 downto 0) => udp_flooderrxdest_port_out(15 downto 0),
|
257 |
|
|
eth_chip_sel_out => DM9000A_eth_chip_sel_out,
|
258 |
|
|
eth_clk_out => DM9000A_eth_clk_out,
|
259 |
|
|
eth_cmd_out => DM9000A_eth_cmd_out,
|
260 |
|
|
eth_data_inout(15 downto 0) => DM9000A_eth_data_inout(15 downto 0),
|
261 |
|
|
eth_interrupt_in => DM9000A_eth_interrupt_in,
|
262 |
|
|
eth_read_out => DM9000A_eth_read_out,
|
263 |
|
|
eth_reset_out => DM9000A_eth_reset_out,
|
264 |
|
|
eth_write_out => DM9000A_eth_write_out,
|
265 |
|
|
fatal_error_out => floodertx_udpfatal_error_out,
|
266 |
|
|
link_up_out => floodertx_udplink_up_out,
|
267 |
|
|
new_rx_out => udp_flooderrxnew_rx_out,
|
268 |
|
|
new_tx_in => floodertx_udpnew_tx_in,
|
269 |
|
|
no_arp_target_MAC_in(47 downto 0) => floodertx_udpno_arp_target_MAC_in(47 downto 0),
|
270 |
|
|
rst_n => rst_n_RESETn,
|
271 |
|
|
rx_data_out(15 downto 0) => udp_flooderrxrx_data_out(15 downto 0),
|
272 |
|
|
rx_data_valid_out => udp_flooderrxrx_data_valid_out,
|
273 |
|
|
rx_erroneous_out => udp_flooderrxrx_erroneous_out,
|
274 |
|
|
rx_error_out => udp_flooderrxrx_error_out,
|
275 |
|
|
rx_len_out(10 downto 0) => udp_flooderrxrx_len_out(10 downto 0),
|
276 |
|
|
rx_re_in => udp_flooderrxrx_re_in,
|
277 |
|
|
source_addr_out(31 downto 0) => udp_flooderrxsource_addr_out(31 downto 0),
|
278 |
|
|
source_port_in(15 downto 0) => floodertx_udpsource_port_in(15 downto 0),
|
279 |
|
|
source_port_out(15 downto 0) => udp_flooderrxsource_port_out(15 downto 0),
|
280 |
|
|
target_addr_in(31 downto 0) => floodertx_udptarget_addr_in(31 downto 0),
|
281 |
|
|
target_port_in(15 downto 0) => floodertx_udptarget_port_in(15 downto 0),
|
282 |
|
|
tx_data_in(15 downto 0) => floodertx_udptx_data_in(15 downto 0),
|
283 |
|
|
tx_data_valid_in => floodertx_udptx_data_valid_in,
|
284 |
|
|
tx_len_in(10 downto 0) => floodertx_udptx_len_in(10 downto 0),
|
285 |
|
|
tx_re_out => floodertx_udptx_re_out
|
286 |
|
|
);
|
287 |
|
|
|
288 |
|
|
end kactusHierarchical;
|
289 |
|
|
|