1 |
2 |
pjf |
----------------------------------------------------------------------------------
|
2 |
|
|
-- Company:
|
3 |
|
|
-- Engineer:
|
4 |
|
|
--
|
5 |
|
|
-- Create Date: 17:51:18 06/11/2011
|
6 |
|
|
-- Design Name:
|
7 |
|
|
-- Module Name: UDP_Complete - Behavioral
|
8 |
|
|
-- Project Name:
|
9 |
|
|
-- Target Devices:
|
10 |
|
|
-- Tool versions:
|
11 |
|
|
-- Description:
|
12 |
|
|
--
|
13 |
|
|
-- Dependencies:
|
14 |
|
|
--
|
15 |
|
|
-- Revision:
|
16 |
|
|
-- Revision 0.01 - File Created
|
17 |
|
|
-- Revision 0.02 - separated RX and TX clocks
|
18 |
|
|
-- Additional Comments:
|
19 |
|
|
--
|
20 |
|
|
----------------------------------------------------------------------------------
|
21 |
|
|
library IEEE;
|
22 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
23 |
|
|
use IEEE.NUMERIC_STD.ALL;
|
24 |
|
|
use work.axi.all;
|
25 |
|
|
use work.ipv4_types.all;
|
26 |
|
|
use work.arp_types.all;
|
27 |
|
|
|
28 |
|
|
entity UDP_Complete is
|
29 |
|
|
Port (
|
30 |
|
|
-- UDP TX signals
|
31 |
|
|
udp_tx_start : in std_logic; -- indicates req to tx UDP
|
32 |
|
|
udp_txi : in udp_tx_type; -- UDP tx cxns
|
33 |
|
|
udp_tx_result : out std_logic_vector (1 downto 0);-- tx status (changes during transmission)
|
34 |
|
|
udp_tx_data_out_ready: out std_logic; -- indicates udp_tx is ready to take data
|
35 |
|
|
-- UDP RX signals
|
36 |
|
|
udp_rx_start : out std_logic; -- indicates receipt of udp header
|
37 |
|
|
udp_rxo : out udp_rx_type;
|
38 |
|
|
-- IP RX signals
|
39 |
|
|
ip_rx_hdr : out ipv4_rx_header_type;
|
40 |
|
|
-- system signals
|
41 |
|
|
clk_in_p : in std_logic; -- 200MHz clock input from board
|
42 |
|
|
clk_in_n : in std_logic;
|
43 |
|
|
clk_out : out std_logic;
|
44 |
|
|
reset : in STD_LOGIC;
|
45 |
|
|
our_ip_address : in STD_LOGIC_VECTOR (31 downto 0);
|
46 |
|
|
our_mac_address : in std_logic_vector (47 downto 0);
|
47 |
|
|
-- status signals
|
48 |
|
|
arp_pkt_count : out STD_LOGIC_VECTOR(7 downto 0); -- count of arp pkts received
|
49 |
|
|
ip_pkt_count : out STD_LOGIC_VECTOR(7 downto 0); -- number of IP pkts received for us
|
50 |
|
|
-- GMII Interface
|
51 |
|
|
phy_resetn : out std_logic;
|
52 |
|
|
gmii_txd : out std_logic_vector(7 downto 0);
|
53 |
|
|
gmii_tx_en : out std_logic;
|
54 |
|
|
gmii_tx_er : out std_logic;
|
55 |
|
|
gmii_tx_clk : out std_logic;
|
56 |
|
|
gmii_rxd : in std_logic_vector(7 downto 0);
|
57 |
|
|
gmii_rx_dv : in std_logic;
|
58 |
|
|
gmii_rx_er : in std_logic;
|
59 |
|
|
gmii_rx_clk : in std_logic;
|
60 |
|
|
gmii_col : in std_logic;
|
61 |
|
|
gmii_crs : in std_logic;
|
62 |
|
|
mii_tx_clk : in std_logic
|
63 |
|
|
);
|
64 |
|
|
end UDP_Complete;
|
65 |
|
|
|
66 |
|
|
architecture structural of UDP_Complete is
|
67 |
|
|
|
68 |
|
|
------------------------------------------------------------------------------
|
69 |
|
|
-- Component Declaration for UDP complete no mac
|
70 |
|
|
------------------------------------------------------------------------------
|
71 |
|
|
|
72 |
|
|
COMPONENT UDP_Complete_nomac
|
73 |
|
|
PORT(
|
74 |
|
|
-- UDP TX signals
|
75 |
|
|
udp_tx_start : in std_logic; -- indicates req to tx UDP
|
76 |
|
|
udp_txi : in udp_tx_type; -- UDP tx cxns
|
77 |
|
|
udp_tx_result : out std_logic_vector (1 downto 0);-- tx status (changes during transmission)
|
78 |
|
|
udp_tx_data_out_ready: out std_logic; -- indicates udp_tx is ready to take data
|
79 |
|
|
-- UDP RX signals
|
80 |
|
|
udp_rx_start : out std_logic; -- indicates receipt of udp header
|
81 |
|
|
udp_rxo : out udp_rx_type;
|
82 |
|
|
-- IP RX signals
|
83 |
|
|
ip_rx_hdr : out ipv4_rx_header_type;
|
84 |
|
|
-- system signals
|
85 |
|
|
rx_clk : in STD_LOGIC;
|
86 |
|
|
tx_clk : in STD_LOGIC;
|
87 |
|
|
reset : in STD_LOGIC;
|
88 |
|
|
our_ip_address : in STD_LOGIC_VECTOR (31 downto 0);
|
89 |
|
|
our_mac_address : in std_logic_vector (47 downto 0);
|
90 |
|
|
-- status signals
|
91 |
|
|
arp_pkt_count : out STD_LOGIC_VECTOR(7 downto 0); -- count of arp pkts received
|
92 |
|
|
ip_pkt_count : out STD_LOGIC_VECTOR(7 downto 0); -- number of IP pkts received for us
|
93 |
|
|
-- MAC Transmitter
|
94 |
|
|
mac_tx_tdata : out std_logic_vector(7 downto 0); -- data byte to tx
|
95 |
|
|
mac_tx_tvalid : out std_logic; -- tdata is valid
|
96 |
|
|
mac_tx_tready : in std_logic; -- mac is ready to accept data
|
97 |
4 |
pjf |
mac_tx_tfirst : out std_logic; -- indicates first byte of frame
|
98 |
2 |
pjf |
mac_tx_tlast : out std_logic; -- indicates last byte of frame
|
99 |
|
|
-- MAC Receiver
|
100 |
|
|
mac_rx_tdata : in std_logic_vector(7 downto 0); -- data byte received
|
101 |
|
|
mac_rx_tvalid : in std_logic; -- indicates tdata is valid
|
102 |
|
|
mac_rx_tready : out std_logic; -- tells mac that we are ready to take data
|
103 |
|
|
mac_rx_tlast : in std_logic -- indicates last byte of the trame
|
104 |
|
|
);
|
105 |
|
|
END COMPONENT;
|
106 |
|
|
|
107 |
|
|
|
108 |
|
|
------------------------------------------------------------------------------
|
109 |
|
|
-- Component Declaration for the MAC layer
|
110 |
|
|
------------------------------------------------------------------------------
|
111 |
|
|
component mac_layer
|
112 |
|
|
port (
|
113 |
|
|
-- System controls
|
114 |
|
|
------------------
|
115 |
|
|
glbl_rst : in std_logic; -- asynchronous reset
|
116 |
|
|
mac_reset : in std_logic; -- reset mac layer
|
117 |
|
|
clk_in_p : in std_logic; -- 200MHz clock input from board
|
118 |
|
|
clk_in_n : in std_logic;
|
119 |
|
|
|
120 |
|
|
-- MAC Transmitter (AXI-S) Interface
|
121 |
|
|
---------------------------------------------
|
122 |
|
|
mac_tx_clock : out std_logic; -- data sampled on rising edge
|
123 |
|
|
mac_tx_tdata : in std_logic_vector(7 downto 0); -- data byte to tx
|
124 |
|
|
mac_tx_tvalid : in std_logic; -- tdata is valid
|
125 |
|
|
mac_tx_tready : out std_logic; -- mac is ready to accept data
|
126 |
|
|
mac_tx_tlast : in std_logic; -- indicates last byte of frame
|
127 |
|
|
|
128 |
|
|
-- MAC Receiver (AXI-S) Interface
|
129 |
|
|
------------------------------------------
|
130 |
|
|
mac_rx_clock : out std_logic; -- data valid on rising edge
|
131 |
|
|
mac_rx_tdata : out std_logic_vector(7 downto 0); -- data byte received
|
132 |
|
|
mac_rx_tvalid : out std_logic; -- indicates tdata is valid
|
133 |
|
|
mac_rx_tready : in std_logic; -- tells mac that we are ready to take data
|
134 |
|
|
mac_rx_tlast : out std_logic; -- indicates last byte of the trame
|
135 |
|
|
|
136 |
|
|
-- GMII Interface
|
137 |
|
|
-----------------
|
138 |
|
|
phy_resetn : out std_logic;
|
139 |
|
|
gmii_txd : out std_logic_vector(7 downto 0);
|
140 |
|
|
gmii_tx_en : out std_logic;
|
141 |
|
|
gmii_tx_er : out std_logic;
|
142 |
|
|
gmii_tx_clk : out std_logic;
|
143 |
|
|
gmii_rxd : in std_logic_vector(7 downto 0);
|
144 |
|
|
gmii_rx_dv : in std_logic;
|
145 |
|
|
gmii_rx_er : in std_logic;
|
146 |
|
|
gmii_rx_clk : in std_logic;
|
147 |
|
|
gmii_col : in std_logic;
|
148 |
|
|
gmii_crs : in std_logic;
|
149 |
|
|
mii_tx_clk : in std_logic
|
150 |
|
|
);
|
151 |
|
|
end component;
|
152 |
|
|
|
153 |
|
|
|
154 |
|
|
---------------------------
|
155 |
|
|
-- Signals
|
156 |
|
|
---------------------------
|
157 |
|
|
|
158 |
|
|
-- MAC RX bus
|
159 |
|
|
signal mac_rx_clock : std_logic;
|
160 |
|
|
signal mac_rx_tdata : std_logic_vector (7 downto 0);
|
161 |
|
|
signal mac_rx_tvalid : std_logic;
|
162 |
|
|
signal mac_rx_tready : std_logic;
|
163 |
|
|
signal mac_rx_tlast : std_logic;
|
164 |
|
|
-- MAC TX bus
|
165 |
|
|
signal mac_tx_clock : std_logic;
|
166 |
|
|
signal mac_tx_tdata : std_logic_vector (7 downto 0);
|
167 |
|
|
signal mac_tx_tvalid : std_logic;
|
168 |
|
|
signal mac_tx_tready : std_logic;
|
169 |
|
|
signal mac_tx_tlast : std_logic;
|
170 |
|
|
-- control signals
|
171 |
|
|
signal mac_tx_tready_int : std_logic;
|
172 |
|
|
signal mac_tx_granted_int : std_logic;
|
173 |
|
|
|
174 |
|
|
|
175 |
|
|
begin
|
176 |
|
|
|
177 |
|
|
|
178 |
|
|
process (mac_tx_clock)
|
179 |
|
|
begin
|
180 |
|
|
-- output followers
|
181 |
|
|
clk_out <= mac_tx_clock;
|
182 |
|
|
end process;
|
183 |
|
|
|
184 |
|
|
------------------------------------------------------------------------------
|
185 |
|
|
-- Instantiate the UDP layer
|
186 |
|
|
------------------------------------------------------------------------------
|
187 |
|
|
|
188 |
|
|
udp_block: UDP_Complete_nomac PORT MAP (
|
189 |
|
|
-- UDP TX signals
|
190 |
|
|
udp_tx_start => udp_tx_start,
|
191 |
|
|
udp_txi => udp_txi,
|
192 |
|
|
udp_tx_result => udp_tx_result,
|
193 |
|
|
udp_tx_data_out_ready => udp_tx_data_out_ready,
|
194 |
|
|
-- UDP RX signals
|
195 |
|
|
udp_rx_start => udp_rx_start,
|
196 |
|
|
udp_rxo => udp_rxo,
|
197 |
|
|
-- IP RX signals
|
198 |
|
|
ip_rx_hdr => ip_rx_hdr,
|
199 |
|
|
-- system signals
|
200 |
|
|
rx_clk => mac_rx_clock,
|
201 |
|
|
tx_clk => mac_tx_clock,
|
202 |
|
|
reset => reset,
|
203 |
|
|
our_ip_address => our_ip_address,
|
204 |
|
|
our_mac_address => our_mac_address,
|
205 |
|
|
-- status signals
|
206 |
|
|
arp_pkt_count => arp_pkt_count,
|
207 |
|
|
ip_pkt_count => ip_pkt_count,
|
208 |
|
|
|
209 |
|
|
-- MAC Transmitter
|
210 |
|
|
mac_tx_tready => mac_tx_tready_int,
|
211 |
|
|
mac_tx_tvalid => mac_tx_tvalid,
|
212 |
4 |
pjf |
mac_tx_tfirst => open,
|
213 |
2 |
pjf |
mac_tx_tlast => mac_tx_tlast,
|
214 |
|
|
mac_tx_tdata => mac_tx_tdata,
|
215 |
|
|
-- MAC Receiver
|
216 |
|
|
mac_rx_tdata => mac_rx_tdata,
|
217 |
|
|
mac_rx_tvalid => mac_rx_tvalid,
|
218 |
|
|
mac_rx_tready => mac_rx_tready,
|
219 |
|
|
mac_rx_tlast => mac_rx_tlast
|
220 |
|
|
);
|
221 |
|
|
|
222 |
|
|
|
223 |
|
|
------------------------------------------------------------------------------
|
224 |
|
|
-- Instantiate the MAC layer
|
225 |
|
|
------------------------------------------------------------------------------
|
226 |
|
|
mac_block : mac_layer
|
227 |
|
|
Port map(
|
228 |
|
|
-- System controls
|
229 |
|
|
------------------
|
230 |
|
|
glbl_rst => reset,
|
231 |
|
|
mac_reset => '0',
|
232 |
|
|
clk_in_p => clk_in_p,
|
233 |
|
|
clk_in_n => clk_in_n,
|
234 |
|
|
|
235 |
|
|
-- MAC Transmitter (AXI-S) Interface
|
236 |
|
|
---------------------------------------------
|
237 |
|
|
mac_tx_clock => mac_tx_clock,
|
238 |
|
|
mac_tx_tdata => mac_tx_tdata,
|
239 |
|
|
mac_tx_tvalid => mac_tx_tvalid,
|
240 |
|
|
mac_tx_tready => mac_tx_tready_int,
|
241 |
|
|
mac_tx_tlast => mac_tx_tlast,
|
242 |
|
|
|
243 |
|
|
-- MAC Receiver (AXI-S) Interface
|
244 |
|
|
------------------------------------------
|
245 |
|
|
mac_rx_clock => mac_rx_clock,
|
246 |
|
|
mac_rx_tdata => mac_rx_tdata,
|
247 |
|
|
mac_rx_tvalid => mac_rx_tvalid,
|
248 |
|
|
mac_rx_tready => mac_rx_tready,
|
249 |
|
|
mac_rx_tlast => mac_rx_tlast,
|
250 |
|
|
|
251 |
|
|
-- GMII Interface
|
252 |
|
|
-----------------
|
253 |
|
|
phy_resetn => phy_resetn,
|
254 |
|
|
gmii_txd => gmii_txd,
|
255 |
|
|
gmii_tx_en => gmii_tx_en,
|
256 |
|
|
gmii_tx_er => gmii_tx_er,
|
257 |
|
|
gmii_tx_clk => gmii_tx_clk,
|
258 |
|
|
gmii_rxd => gmii_rxd,
|
259 |
|
|
gmii_rx_dv => gmii_rx_dv,
|
260 |
|
|
gmii_rx_er => gmii_rx_er,
|
261 |
|
|
gmii_rx_clk => gmii_rx_clk,
|
262 |
|
|
gmii_col => gmii_col,
|
263 |
|
|
gmii_crs => gmii_crs,
|
264 |
|
|
mii_tx_clk => mii_tx_clk
|
265 |
|
|
);
|
266 |
|
|
|
267 |
|
|
|
268 |
|
|
end structural;
|
269 |
|
|
|