1 |
2 |
boa_a_m |
library IEEE;
|
2 |
|
|
use IEEE.STD_LOGIC_1164.all;
|
3 |
|
|
use IEEE.NUMERIC_STD.all;
|
4 |
|
|
use IEEE.std_logic_unsigned.all;
|
5 |
|
|
|
6 |
|
|
library work;
|
7 |
|
|
--use work.signal_Package.all;
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
entity IPv4_TX is
|
11 |
|
|
generic (
|
12 |
|
|
g_GENERATE_ARP_MODULE : boolean := true;
|
13 |
|
|
g_DEFAULT_DST_MAC_ADDR : std_logic_vector (47 downto 0) := x"AABBCCDDEEFF"
|
14 |
|
|
);
|
15 |
|
|
port (
|
16 |
|
|
i_tx_clk : in std_logic;
|
17 |
|
|
i_reset : in std_logic;
|
18 |
|
|
|
19 |
|
|
--for IP Header
|
20 |
|
|
i_protocol : in std_logic_vector (7 downto 0);
|
21 |
|
|
i_data_length : in std_logic_vector (15 downto 0); -- app data + 8(udp header)
|
22 |
|
|
i_ip_tx_fragmantation : in std_logic_vector (15 downto 0):=x"4000"; --DF
|
23 |
|
|
i_our_ip_addr : in std_logic_vector (31 downto 0);
|
24 |
|
|
i_our_mac_addr : in std_logic_vector (47 downto 0);
|
25 |
|
|
i_dst_ip_addr : in std_logic_vector (31 downto 0);
|
26 |
|
|
|
27 |
|
|
-- for receive data from udp layer
|
28 |
|
|
i_ip_tx_start : in std_logic;
|
29 |
|
|
o_ip_tx_ready : out std_logic;
|
30 |
|
|
i_data_in : in std_logic_vector (7 downto 0);
|
31 |
|
|
|
32 |
|
|
-- for transfer & receive data with arp block
|
33 |
|
|
o_lookup_req : out std_logic;
|
34 |
|
|
o_lookup_ip : out std_logic_vector (31 downto 0);
|
35 |
|
|
i_lookup_mac_addr : in std_logic_vector (47 downto 0);
|
36 |
|
|
i_lookup_mac_got : in std_logic;
|
37 |
|
|
i_lookup_mac_err : in std_logic;
|
38 |
|
|
|
39 |
|
|
-- for transfer data to mac layer
|
40 |
|
|
o_mac_tx_req : out std_logic;
|
41 |
|
|
i_mac_tx_granted : in std_logic;
|
42 |
|
|
i_mac_tready : in std_logic;
|
43 |
|
|
o_mac_tvalid : out std_logic;
|
44 |
|
|
o_mac_tlast : out std_logic;
|
45 |
|
|
o_mac_tdata : out std_logic_vector (7 downto 0);
|
46 |
|
|
s_TX_LL_SOF_N_0 : out std_logic;
|
47 |
|
|
--error status
|
48 |
|
|
o_ip_tx_err_out : out std_logic_vector (3 downto 0)
|
49 |
|
|
|
50 |
|
|
);
|
51 |
|
|
end IPv4_TX;
|
52 |
|
|
|
53 |
|
|
|
54 |
|
|
architecture Behavioral of IPv4_TX is
|
55 |
|
|
--================================= Constant ===========================================================
|
56 |
|
|
--Generate Block Conditional Constants
|
57 |
|
|
constant c_GENERATE_PING_MODULE : boolean := true; --if Ping Block is not Used,Value is False
|
58 |
|
|
constant c_GENERATE_ARP_MODULE : boolean := true; --if ARP Block is not Used,Value is False
|
59 |
|
|
constant c_DEFAULT_DST_MAC_ADDR : std_logic_vector (47 downto 0) := x"F46D04962225"; --if ARP Block is not Used,Copy PC MAC Address to This Value
|
60 |
|
|
|
61 |
|
|
|
62 |
|
|
--Application Layer Data Length
|
63 |
|
|
constant c_PACKET_LENGTH : std_logic_vector (15 downto 0):= x"05c0"; --1472 (Maximum Application Layer Packet Length)
|
64 |
|
|
constant c_udp_tx_src_ip : std_logic_vector (31 downto 0):= x"C0A86403"; --192.168.100.3(FPGA IP Adress)
|
65 |
|
|
constant c_udp_tx_dst_ip : std_logic_vector (31 downto 0):= x"C0A86402"; --192.168.100.2(PC IP Address)
|
66 |
|
|
constant c_udp_tx_protocol : std_logic_vector (7 downto 0) := x"11"; --UDP Protocol
|
67 |
|
|
constant c_udp_tx_src_mac : std_logic_vector (47 downto 0):= x"112233445566"; --FPGA MAC Address
|
68 |
|
|
constant c_udp_tx_checksum : std_logic_vector (15 downto 0):= x"0000"; --UDP Checksum(Value For This Constant is not Importanat)
|
69 |
|
|
constant c_udp_tx_src_port : std_logic_vector (15 downto 0):= x"0401"; --UDP Src Port(Value For This Constant is not Importanat)
|
70 |
|
|
constant c_udp_tx_dst_port : std_logic_vector (15 downto 0):= x"0FF5"; --UDP Dst Port(Value For This Constant is not Importanat)
|
71 |
|
|
|
72 |
|
|
|
73 |
|
|
--ARP Constants
|
74 |
|
|
constant c_TIME_OUT_LOOKUP_TABLE_ARP : std_logic_vector (31 downto 0) := x"9502F900"; --20S(Value/125MHz = 20 )
|
75 |
|
|
constant c_TIME_OUT_WAIT_FOR_ARP_REPLY : std_logic_vector (31 downto 0) := x"07735940"; --1S (Value/125MHz = 1 )
|
76 |
|
|
constant c_RE_SEND_ARP_REQUEST : std_logic_vector (3 downto 0) := x"A"; --10
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
--IP Constants
|
80 |
|
|
constant c_IP_TTL : std_logic_vector (7 downto 0) := x"80"; -- IP Packet Time to live
|
81 |
|
|
constant c_IP_BC_ADDR : std_logic_vector (31 downto 0) := x"ffffffff"; -- Broadcast IP Address
|
82 |
|
|
constant c_MAC_BC_ADDR : std_logic_vector (47 downto 0) := x"ffffffffffff"; -- Broadcast MAC Address
|
83 |
|
|
--======================================================================================================
|
84 |
|
|
|
85 |
|
|
--===================== Reset_gen Signals ==============================================================
|
86 |
|
|
signal s_cnt_rst : std_logic_vector(15 downto 0):=(others=>'0');
|
87 |
|
|
--======================================================================================================
|
88 |
|
|
|
89 |
|
|
--================================ Ethernet 1g Signals =================================================
|
90 |
|
|
signal s_gtx_clk : std_logic;
|
91 |
|
|
signal s_tx_clk : std_logic;
|
92 |
|
|
signal s_rx_clk : std_logic;
|
93 |
|
|
signal s_rstn : std_logic;
|
94 |
|
|
signal s_rx_reset : std_logic;
|
95 |
|
|
signal s_tx_reset : std_logic;
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
--mac to gmii_if signals
|
99 |
|
|
signal s_mac_gmii_rxd : std_logic_vector(7 downto 0);
|
100 |
|
|
signal s_mac_gmii_rx_dv : std_logic;
|
101 |
|
|
signal s_mac_gmii_rx_er : std_logic;
|
102 |
|
|
|
103 |
|
|
signal s_mac_gmii_txd : std_logic_vector(7 downto 0);
|
104 |
|
|
signal s_mac_gmii_tx_en : std_logic;
|
105 |
|
|
signal s_mac_gmii_tx_er : std_logic;
|
106 |
|
|
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
--ip to mac signals
|
110 |
|
|
signal s_mac_tx_tready : std_logic;
|
111 |
|
|
signal s_mac_tx_tdata : std_logic_vector(7 downto 0);
|
112 |
|
|
signal s_mac_tx_tvalid : std_logic;
|
113 |
|
|
signal s_mac_tx_tlast : std_logic;
|
114 |
|
|
|
115 |
|
|
signal s_mac_rx_tdata : std_logic_vector(7 downto 0);
|
116 |
|
|
signal s_mac_rx_tvalid : std_logic;
|
117 |
|
|
signal s_mac_rx_tlast : std_logic;
|
118 |
|
|
--======================================================================================================
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
--================================ UDP Signals =========================================================
|
122 |
|
|
-------- for transfer Rx data from IP to UDP layer----------------
|
123 |
|
|
signal s_ip_rx_dout : std_logic_vector(7 downto 0);
|
124 |
|
|
signal s_ip_rx_dout_rdy : std_logic;
|
125 |
|
|
signal s_ip_rx_dout_last : std_logic;
|
126 |
|
|
|
127 |
|
|
-------- for transfer Rx status data from IP to UDP layer---------
|
128 |
|
|
signal s_ip_rx_src_ip : std_logic_vector(31 downto 0);
|
129 |
|
|
signal s_ip_rx_dst_ip : std_logic_vector(31 downto 0);
|
130 |
|
|
signal s_ip_rx_data_len : std_logic_vector(15 downto 0);
|
131 |
|
|
signal s_ip_rx_protocol : std_logic_vector(7 downto 0);
|
132 |
|
|
signal s_ip_rx_broadcast : std_logic;
|
133 |
|
|
signal s_ip_rx_err_out_udp : std_logic_vector (3 downto 0);
|
134 |
|
|
signal s_ip_tx_err_out_udp : std_logic_vector (3 downto 0);
|
135 |
|
|
signal s_arp_rx_err_out_udp : std_logic_vector (3 downto 0);
|
136 |
|
|
|
137 |
|
|
-------- for transfer Tx data from UDP to IP layer---------------
|
138 |
|
|
signal s_ip_tx_start : std_logic;
|
139 |
|
|
signal s_ip_tx_rdy : std_logic;
|
140 |
|
|
signal s_ip_tx_din : std_logic_vector(7 downto 0);
|
141 |
|
|
|
142 |
|
|
-------- for transfer Tx header data from UDP to IP layer--------
|
143 |
|
|
signal s_ip_tx_src_ip : std_logic_vector(31 downto 0);
|
144 |
|
|
signal s_ip_tx_dst_ip : std_logic_vector(31 downto 0);
|
145 |
|
|
signal s_ip_tx_src_mac : std_logic_vector(47 downto 0);
|
146 |
|
|
signal s_ip_tx_data_len : std_logic_vector(15 downto 0);
|
147 |
|
|
signal s_ip_tx_protocol : std_logic_vector(7 downto 0);
|
148 |
|
|
-----------------------------------------------------------------
|
149 |
|
|
--======================================================================================================
|
150 |
|
|
|
151 |
|
|
|
152 |
|
|
|
153 |
|
|
--============================= IP Signals =============================================================
|
154 |
|
|
signal s_ip_mac_tx_tvalid : std_logic;
|
155 |
|
|
signal s_ip_mac_tx_tlast : std_logic;
|
156 |
|
|
signal s_ip_mac_tx_tdata : std_logic_vector(7 downto 0);
|
157 |
|
|
signal s_ip_mac_tx_req : std_logic;
|
158 |
|
|
signal s_ip_mac_tx_granted : std_logic;
|
159 |
|
|
|
160 |
|
|
signal s_arp_mac_tx_tvalid : std_logic;
|
161 |
|
|
signal s_arp_mac_tx_tlast : std_logic;
|
162 |
|
|
signal s_arp_mac_tx_tdata : std_logic_vector(7 downto 0);
|
163 |
|
|
signal s_arp_mac_tx_req : std_logic;
|
164 |
|
|
signal s_arp_mac_tx_granted : std_logic;
|
165 |
|
|
|
166 |
|
|
signal s_ping_mac_tx_tvalid : std_logic;
|
167 |
|
|
signal s_ping_mac_tx_tlast : std_logic;
|
168 |
|
|
signal s_ping_mac_tx_tdata : std_logic_vector(7 downto 0);
|
169 |
|
|
signal s_ping_mac_tx_req : std_logic;
|
170 |
|
|
signal s_ping_mac_tx_granted : std_logic;
|
171 |
|
|
|
172 |
|
|
signal s_lookup_req : std_logic;
|
173 |
|
|
signal s_lookup_ip : std_logic_vector(31 downto 0);
|
174 |
|
|
signal s_lookup_mac_addr : std_logic_vector(47 downto 0);
|
175 |
|
|
signal s_lookup_mac_got : std_logic;
|
176 |
|
|
signal s_lookup_mac_err : std_logic;
|
177 |
|
|
|
178 |
|
|
|
179 |
|
|
|
180 |
|
|
signal s_no_ping_packet : std_logic;
|
181 |
|
|
signal s_ip_rx_err_out : std_logic_vector(3 downto 0);
|
182 |
|
|
--======================================================================================================
|
183 |
|
|
|
184 |
|
|
|
185 |
|
|
|
186 |
|
|
|
187 |
|
|
|
188 |
|
|
|
189 |
|
|
|
190 |
|
|
|
191 |
|
|
|
192 |
|
|
|
193 |
|
|
|
194 |
|
|
|
195 |
|
|
|
196 |
|
|
|
197 |
|
|
|
198 |
|
|
|
199 |
|
|
|
200 |
|
|
|
201 |
|
|
|
202 |
|
|
|
203 |
|
|
--============================ IP4_RX Signals============================================================
|
204 |
|
|
type t_rx_ip_state_type is (IDLE,ETH_H,IP_H,USER_DATA,WAIT_END);
|
205 |
|
|
signal st_RX_IP_STATE : t_rx_ip_state_type:=IDLE;
|
206 |
|
|
signal s_cnt_ip_rx : std_logic_vector (15 downto 0):=x"0001";
|
207 |
|
|
|
208 |
|
|
signal s_src_ip_ip_rx : std_logic_vector (31 downto 0):=(others=>'0');
|
209 |
|
|
signal s_dst_ip_ip_rx : std_logic_vector (31 downto 0):=(others=>'0');
|
210 |
|
|
signal s_data_len_ip_rx : std_logic_vector (15 downto 0):=(others=>'0');
|
211 |
|
|
signal s_protocol_ip_rx : std_logic_vector (7 downto 0) :=(others=>'0');
|
212 |
|
|
signal s_broadcast_ip_rx : std_logic;
|
213 |
|
|
--========================================================================================================
|
214 |
|
|
|
215 |
|
|
|
216 |
|
|
|
217 |
|
|
|
218 |
|
|
|
219 |
|
|
|
220 |
|
|
|
221 |
|
|
|
222 |
|
|
|
223 |
|
|
|
224 |
|
|
|
225 |
|
|
--==================================== ARP Signals ==========================================================
|
226 |
|
|
type t_arp_state_type is (IDLE,LOOK_UP,WAIT_PC_REPLY);
|
227 |
|
|
signal st_ARP_STATE : t_arp_state_type:=IDLE;
|
228 |
|
|
signal s_timeout_wait_reply_cnt : std_logic_vector(31 downto 0):=(others=>'0');
|
229 |
|
|
signal s_error_cnt : std_logic_vector(3 downto 0):=(others=>'0');
|
230 |
|
|
|
231 |
|
|
--ARP_TX Signals
|
232 |
|
|
signal s_dst_ip_addr_pc : std_logic_vector(31 downto 0):=(others=>'0');
|
233 |
|
|
signal s_dst_mac_addr_pc : std_logic_vector(47 downto 0):=(others=>'0');
|
234 |
|
|
signal s_dst_ip_addr_lookup : std_logic_vector(31 downto 0):=(others=>'0');
|
235 |
|
|
signal s_fpga_req_tx : std_logic:='0';
|
236 |
|
|
signal s_pc_req_tx : std_logic:='0';
|
237 |
|
|
|
238 |
|
|
|
239 |
|
|
--ARP_RX Signals
|
240 |
|
|
signal s_ip_addr0 : std_logic_vector(31 downto 0);
|
241 |
|
|
signal s_mac_addr0 : std_logic_vector(47 downto 0);
|
242 |
|
|
signal s_addr_valid0 : std_logic;
|
243 |
|
|
signal s_pc_reply_rx : std_logic;
|
244 |
|
|
signal s_pc_req_rx : std_logic;
|
245 |
|
|
--===========================================================================================================
|
246 |
|
|
|
247 |
|
|
|
248 |
|
|
|
249 |
|
|
|
250 |
|
|
|
251 |
|
|
|
252 |
|
|
|
253 |
|
|
|
254 |
|
|
|
255 |
|
|
|
256 |
|
|
|
257 |
|
|
--=============================== ARP RX Signals ============================================================
|
258 |
|
|
type t_rx_arp_state_type is (IDLE,ETH_H,ARP_DATA,WAIT_END);
|
259 |
|
|
signal st_RX_ARP_STATE : t_rx_arp_state_type:=IDLE;
|
260 |
|
|
signal s_cnt_arp_rx : std_logic_vector (15 downto 0):=x"0001";
|
261 |
|
|
|
262 |
|
|
|
263 |
|
|
signal s_dst_ip : std_logic_vector (31 downto 0):=(others=>'0');
|
264 |
|
|
signal s_operation : std_logic_vector (15 downto 0):=(others=>'0');
|
265 |
|
|
signal s_addr_valid : std_logic:='0';
|
266 |
|
|
signal s_pc_req : std_logic:='0';
|
267 |
|
|
signal s_pc_reply : std_logic:='0';
|
268 |
|
|
|
269 |
|
|
|
270 |
|
|
signal s_src_mac_arp_rx : std_logic_vector (47 downto 0):=(others=>'0');
|
271 |
|
|
signal s_src_ip_arp_rx : std_logic_vector (31 downto 0):=(others=>'0');
|
272 |
|
|
signal s_addr_valid_pulse : std_logic:='0';
|
273 |
|
|
signal s_pc_req_pulse : std_logic:='0';
|
274 |
|
|
signal s_pc_reply_pulse : std_logic:='0';
|
275 |
|
|
signal s_trans_data_pulse : std_logic:='0';
|
276 |
|
|
--===========================================================================================================
|
277 |
|
|
|
278 |
|
|
|
279 |
|
|
|
280 |
|
|
|
281 |
|
|
|
282 |
|
|
|
283 |
|
|
|
284 |
|
|
|
285 |
|
|
|
286 |
|
|
|
287 |
|
|
|
288 |
|
|
|
289 |
|
|
--=================================== ARP LOOKUP_TABLE Signals ==============================================
|
290 |
|
|
signal s_timeout_lookup_table_cnt : std_logic_vector(31 downto 0):=(others=>'0');
|
291 |
|
|
|
292 |
|
|
signal s_din : std_logic_vector(82 downto 0):=(others=>'0');
|
293 |
|
|
signal s_wr_en : std_logic;
|
294 |
|
|
signal s_dout : std_logic_vector(82 downto 0):=(others=>'0');
|
295 |
|
|
signal s_valid : std_logic;
|
296 |
|
|
signal s_empty : std_logic;
|
297 |
|
|
signal s_notempty : std_logic;
|
298 |
|
|
|
299 |
|
|
|
300 |
|
|
signal s_mac_addr_out : std_logic_vector(47 downto 0):=(others=>'0');
|
301 |
|
|
signal s_ip_addr_out : std_logic_vector(31 downto 0):=(others=>'0');
|
302 |
|
|
signal s_addr_valid_out : std_logic:='0';
|
303 |
|
|
signal s_request_out : std_logic:='0';
|
304 |
|
|
signal s_reply_out : std_logic:='0';
|
305 |
|
|
--============================================================================================================
|
306 |
|
|
|
307 |
|
|
|
308 |
|
|
|
309 |
|
|
|
310 |
|
|
|
311 |
|
|
|
312 |
|
|
|
313 |
|
|
|
314 |
|
|
|
315 |
|
|
|
316 |
|
|
|
317 |
|
|
--============================ ARP TX Signals ================================================================
|
318 |
|
|
type t_arp_tx_state_type is (IDLE,WAIT_CHN,SEND_DATA);
|
319 |
|
|
signal st_tx_arp_state : t_arp_tx_state_type:=IDLE;
|
320 |
|
|
signal s_cnt_arp_tx : std_logic_vector (7 downto 0):=(others=>'0');
|
321 |
|
|
signal s_arp_type : std_logic_vector (15 downto 0):=(others=>'0');
|
322 |
|
|
signal s_dst_ip_addr : std_logic_vector (31 downto 0):=(others=>'0');
|
323 |
|
|
signal s_dst_mac_addr1 : std_logic_vector (47 downto 0):=(others=>'0');
|
324 |
|
|
signal s_dst_mac_addr2 : std_logic_vector (47 downto 0):=(others=>'0');
|
325 |
|
|
--============================================================================================================
|
326 |
|
|
|
327 |
|
|
|
328 |
|
|
|
329 |
|
|
|
330 |
|
|
|
331 |
|
|
|
332 |
|
|
|
333 |
|
|
|
334 |
|
|
|
335 |
|
|
|
336 |
|
|
|
337 |
|
|
|
338 |
|
|
--============================== PING Signals =================================================================
|
339 |
|
|
--for Delayed Inputs
|
340 |
|
|
signal s_mac_data_in_r : std_logic_vector (7 downto 0);
|
341 |
|
|
signal s_mac_data_in_valid_r : std_logic;
|
342 |
|
|
signal s_mac_data_in_last_r : std_logic;
|
343 |
|
|
|
344 |
|
|
|
345 |
|
|
--Sync_fifo_ping Signals
|
346 |
|
|
signal s_ip_rx_in : std_logic_vector(14 downto 0);
|
347 |
|
|
signal s_ip_rx_out : std_logic_vector(14 downto 0):=(others=>'0');
|
348 |
|
|
signal s_mac_data_in : std_logic_vector(7 downto 0);
|
349 |
|
|
signal s_mac_data_in_valid : std_logic;
|
350 |
|
|
signal s_mac_data_in_last : std_logic;
|
351 |
|
|
signal s_mac_data_in_last_d : std_logic;
|
352 |
|
|
signal s_ip_rx_err_in : std_logic_vector(3 downto 0);
|
353 |
|
|
signal s_no_ping_data : std_logic;
|
354 |
|
|
signal s_empty_sync_fifo : std_logic:='0';
|
355 |
|
|
signal s_not_empty_sync_fifo: std_logic;
|
356 |
|
|
|
357 |
|
|
|
358 |
|
|
--Data_fifo_ping Signals
|
359 |
|
|
signal s_rst_fifo_ping : std_logic:='1';
|
360 |
|
|
signal s_wr_en_fifo_ping : std_logic:='0';
|
361 |
|
|
signal s_din_fifo_ping : std_logic_vector(7 downto 0):=(others=>'0');
|
362 |
|
|
signal s_rd_en_fifo_ping : std_logic;
|
363 |
|
|
signal s_dout_fifo_ping : std_logic_vector(7 downto 0);
|
364 |
|
|
|
365 |
|
|
|
366 |
|
|
--Checksum Signals
|
367 |
|
|
signal s_checksum_data_out : std_logic_vector(15 downto 0);
|
368 |
|
|
signal s_checksum_data_in : std_logic_vector(7 downto 0);
|
369 |
|
|
signal s_checksum_start_calc : std_logic:='0';
|
370 |
|
|
signal s_checksum_stop_calc : std_logic:='0';
|
371 |
|
|
|
372 |
|
|
|
373 |
|
|
--st_PING_STATE Machine Process Signals
|
374 |
|
|
type t_ping_state is (IDLE,ACQUIRE_DATA,WAIT_END,WAIT_CHN,SEND_DATA);
|
375 |
|
|
signal st_PING_STATE : t_ping_state:=IDLE;
|
376 |
|
|
signal s_wr_cnt : std_logic_vector(7 downto 0):=(others=>'0');
|
377 |
|
|
signal s_rd_cnt : std_logic_vector(7 downto 0):=(others=>'0');
|
378 |
|
|
signal s_start_send : std_logic;
|
379 |
|
|
|
380 |
|
|
|
381 |
|
|
signal s_src_mac_ping : std_logic_vector(47 downto 0):=(others=>'0');
|
382 |
|
|
signal s_dst_mac_ping : std_logic_vector(47 downto 0):=(others=>'0');
|
383 |
|
|
signal s_src_ip_ping : std_logic_vector(31 downto 0):=(others=>'0');
|
384 |
|
|
signal s_dst_ip_ping : std_logic_vector(31 downto 0):=(others=>'0');
|
385 |
|
|
--=================================================================================================================
|
386 |
|
|
|
387 |
|
|
|
388 |
|
|
|
389 |
|
|
|
390 |
|
|
|
391 |
|
|
|
392 |
|
|
|
393 |
|
|
|
394 |
|
|
|
395 |
|
|
|
396 |
|
|
|
397 |
|
|
|
398 |
|
|
--================================= Ping Checksum Calc Signals ====================================================
|
399 |
|
|
type t_checksum_state is (IDLE,CALC);
|
400 |
|
|
signal st_checksum_state : t_checksum_state:=IDLE;
|
401 |
|
|
|
402 |
|
|
signal s_flag : std_logic:='0';
|
403 |
|
|
signal s_din_r : std_logic_vector(7 downto 0);
|
404 |
|
|
signal s_sum : std_logic_vector(31 downto 0):=(others=>'0');
|
405 |
|
|
--=================================================================================================================
|
406 |
|
|
|
407 |
|
|
|
408 |
|
|
|
409 |
|
|
|
410 |
|
|
|
411 |
|
|
|
412 |
|
|
|
413 |
|
|
|
414 |
|
|
|
415 |
|
|
|
416 |
|
|
|
417 |
|
|
--============================ TX_Arbitior Signals =====================================================================
|
418 |
|
|
type t_state_type is (IDLE,DATA_REQ,ARP_REQ,PING_REQ);
|
419 |
|
|
signal st_STATE : t_state_type:=IDLE;
|
420 |
|
|
--======================================================================================================================
|
421 |
|
|
|
422 |
|
|
|
423 |
|
|
|
424 |
|
|
|
425 |
|
|
|
426 |
|
|
|
427 |
|
|
|
428 |
|
|
|
429 |
|
|
|
430 |
|
|
|
431 |
|
|
|
432 |
|
|
|
433 |
|
|
--============================ UDP RX Signals ===========================================================================
|
434 |
|
|
type t_rx_udp_state_type is (IDLE, UDP_HDR, USER_DATA, WAIT_END);
|
435 |
|
|
signal st_RX_UDP_STATE : t_rx_udp_state_type:=IDLE;
|
436 |
|
|
signal s_cnt_udp_rx : std_logic_vector (15 downto 0):=x"0001";
|
437 |
|
|
|
438 |
|
|
signal s_src_ip_udp_rx : std_logic_vector (31 downto 0):=(others=>'0');
|
439 |
|
|
signal s_src_port : std_logic_vector (15 downto 0):=(others=>'0');
|
440 |
|
|
signal s_dst_port : std_logic_vector (15 downto 0):=(others=>'0');
|
441 |
|
|
signal s_data_len_udp_rx : std_logic_vector (15 downto 0):=(others=>'0');
|
442 |
|
|
signal s_err_out : std_logic_vector (3 downto 0) :=(others=>'0');
|
443 |
|
|
--=======================================================================================================================
|
444 |
|
|
|
445 |
|
|
|
446 |
|
|
|
447 |
|
|
|
448 |
|
|
|
449 |
|
|
|
450 |
|
|
|
451 |
|
|
|
452 |
|
|
|
453 |
|
|
|
454 |
|
|
|
455 |
|
|
--============================ UDP TX Signals =============================================================================
|
456 |
|
|
type t_tx_udp_state_type is (IDLE,SEND_DATA);
|
457 |
|
|
signal st_tx_udp_state : t_tx_udp_state_type:=IDLE;
|
458 |
|
|
|
459 |
|
|
signal s_cnt_udp_tx : std_logic_vector (15 downto 0):=(others=>'0');
|
460 |
|
|
signal s_ip_data_len : std_logic_vector (15 downto 0);
|
461 |
|
|
signal s_udp_header : std_logic_vector (7 downto 0):=(others=>'0');
|
462 |
|
|
--==========================================================================================================================
|
463 |
|
|
|
464 |
|
|
|
465 |
|
|
|
466 |
|
|
|
467 |
|
|
|
468 |
|
|
|
469 |
|
|
|
470 |
|
|
|
471 |
|
|
|
472 |
|
|
|
473 |
|
|
|
474 |
|
|
--============================ PHY_Interface Signals =======================================================================
|
475 |
|
|
signal s_gmii_col_reg : std_logic;
|
476 |
|
|
signal s_gmii_col_reg_reg : std_logic;
|
477 |
|
|
signal s_gmii_rx_clk : std_logic;
|
478 |
|
|
--==========================================================================================================================
|
479 |
|
|
|
480 |
|
|
|
481 |
|
|
|
482 |
|
|
|
483 |
|
|
|
484 |
|
|
|
485 |
|
|
|
486 |
|
|
|
487 |
|
|
|
488 |
|
|
|
489 |
|
|
|
490 |
|
|
--=========================== Ping_Pong Fifo Signals =======================================================================
|
491 |
|
|
signal s_empty1 : std_logic;
|
492 |
|
|
signal s_empty2 : std_logic;
|
493 |
|
|
signal s_notempty1 : std_logic;
|
494 |
|
|
signal s_notempty2 : std_logic;
|
495 |
|
|
|
496 |
|
|
|
497 |
|
|
signal s_data_m : std_logic_vector(7 downto 0);
|
498 |
|
|
signal s_valid_m : std_logic;
|
499 |
|
|
signal s_last_m : std_logic;
|
500 |
|
|
|
501 |
|
|
|
502 |
|
|
signal s_wr_en_a : std_logic:='0';
|
503 |
|
|
signal s_din_a : std_logic_vector(7 downto 0):=(others=>'0');
|
504 |
|
|
signal s_rd_en_a : std_logic;
|
505 |
|
|
signal s_dout_a : std_logic_vector(7 downto 0);
|
506 |
|
|
signal s_valid_a : std_logic;
|
507 |
|
|
signal s_empty_a : std_logic;
|
508 |
|
|
|
509 |
|
|
signal s_wr_en_b : std_logic:='0';
|
510 |
|
|
signal s_din_b : std_logic_vector(7 downto 0):=(others=>'0');
|
511 |
|
|
signal s_rd_en_b : std_logic;
|
512 |
|
|
signal s_dout_b : std_logic_vector(7 downto 0);
|
513 |
|
|
signal s_valid_b : std_logic;
|
514 |
|
|
signal s_empty_b : std_logic;
|
515 |
|
|
|
516 |
|
|
|
517 |
|
|
signal s_cnt_a : std_logic_vector(15 downto 0):=(others=>'0');
|
518 |
|
|
signal s_cnt_b : std_logic_vector(15 downto 0):=(others=>'0');
|
519 |
|
|
signal s_rd_cnt_a : std_logic_vector(15 downto 0):=(others=>'0');
|
520 |
|
|
signal s_rd_cnt_b : std_logic_vector(15 downto 0):=(others=>'0');
|
521 |
|
|
|
522 |
|
|
signal s_busy_a : std_logic:='0';
|
523 |
|
|
signal s_busy_b : std_logic:='0';
|
524 |
|
|
|
525 |
|
|
signal s_last_a : std_logic:='0';
|
526 |
|
|
signal s_last_b : std_logic:='0';
|
527 |
|
|
|
528 |
|
|
signal s_dout_len : std_logic_vector(15 downto 0);
|
529 |
|
|
|
530 |
|
|
type t_pingpong_state is (wait_data,rd_fifo_a,rd_fifo_b);
|
531 |
|
|
signal st_ping_pong_state : t_pingpong_state:=wait_data;
|
532 |
|
|
--=========================================================================================================================
|
533 |
|
|
--============================= IP4_TX Signals ==========================================================
|
534 |
|
|
type t_tx_ip_state_type is (IDLE,WAIT_MAC_ADDR,WAIT_CHN,SEND_DATA);
|
535 |
|
|
type t_crc_state_type is (IDLE, TOT_LEN, ID, FLAGS, TTL, CKS, SAH, SAL, DAH, DAL, ADDOVF, FINAL, WAIT_END);
|
536 |
|
|
signal st_crc_state : t_crc_state_type:=IDLE;
|
537 |
|
|
signal s_tx_hdr_cks : std_logic_vector (23 downto 0):=(others=>'0');
|
538 |
|
|
signal s_cal_cheksum : std_logic:='0';
|
539 |
|
|
|
540 |
|
|
|
541 |
|
|
signal st_tx_ip_state : t_tx_ip_state_type:=IDLE;
|
542 |
|
|
signal s_cnt_ip_tx : std_logic_vector (15 downto 0):=(others=>'0');
|
543 |
|
|
signal s_dst_mac_addr : std_logic_vector (47 downto 0); -- arp block updats this signal
|
544 |
|
|
signal s_total_length : std_logic_vector (15 downto 0); -- s_total_length is i_data_length+20(ip header)
|
545 |
|
|
|
546 |
|
|
|
547 |
|
|
signal s_ip_header : std_logic_vector (7 downto 0):=(others=>'0');
|
548 |
|
|
--========================================================================================================
|
549 |
|
|
|
550 |
|
|
constant c_Flag_and_offset : std_logic_vector (15 downto 0):=x"4000"; -- Flag & offset
|
551 |
|
|
|
552 |
|
|
signal s_ip_tx_fragmantation : std_logic_vector (15 downto 0):=x"0000";
|
553 |
|
|
|
554 |
|
|
|
555 |
|
|
--========================== Function for IP_Checksum Calculate ========================================
|
556 |
|
|
function inv_if_one(s1 : std_logic_vector; en : std_logic) return std_logic_vector is
|
557 |
|
|
variable Z : std_logic_vector(s1'high downto s1'low);
|
558 |
|
|
begin
|
559 |
|
|
for i in (s1'low) to s1'high loop
|
560 |
|
|
Z(i) := en xor s1(i);
|
561 |
|
|
end loop;
|
562 |
|
|
return Z;
|
563 |
|
|
end inv_if_one;
|
564 |
|
|
--======================================================================================================
|
565 |
|
|
|
566 |
|
|
begin
|
567 |
|
|
--======================== immediate transfering data to mac & udp layers ==============================
|
568 |
|
|
o_mac_tdata <= s_ip_header when (s_cnt_ip_tx<=34) else i_data_in when (s_cnt_ip_tx > 34 and s_cnt_ip_tx <=(34+i_data_length)) else (others=>'0');
|
569 |
|
|
o_ip_tx_ready <= i_mac_tready when (s_cnt_ip_tx >= 34 and s_cnt_ip_tx <(34+i_data_length)) else '0';
|
570 |
|
|
s_total_length <= std_logic_vector(unsigned(i_data_length) + 20);
|
571 |
|
|
--======================================================================================================
|
572 |
|
|
--s_ip_tx_fragmantation <= "00" & i_ip_tx_fragmantation(13 downto 0);
|
573 |
|
|
s_ip_tx_fragmantation <= i_ip_tx_fragmantation;
|
574 |
|
|
--=================================== Transmit IP Data =================================================
|
575 |
|
|
p_transmission_data:process(i_tx_clk)
|
576 |
|
|
begin
|
577 |
|
|
if(rising_edge(i_tx_clk)) then
|
578 |
|
|
if (i_reset='1') then
|
579 |
|
|
|
580 |
|
|
st_tx_ip_state <=IDLE;
|
581 |
|
|
s_cnt_ip_tx <=(others=>'0');
|
582 |
|
|
s_cal_cheksum <= '0';
|
583 |
|
|
|
584 |
|
|
--for arp
|
585 |
|
|
o_lookup_req <= '0';
|
586 |
|
|
o_lookup_ip <=(others=>'0');
|
587 |
|
|
s_dst_mac_addr <=(others=>'0');
|
588 |
|
|
|
589 |
|
|
--for mac
|
590 |
|
|
o_mac_tx_req <= '0';
|
591 |
|
|
o_mac_tvalid <= '0';
|
592 |
|
|
o_mac_tlast <= '0';
|
593 |
|
|
s_ip_header <=(others=>'0');
|
594 |
|
|
s_TX_LL_SOF_N_0 <= '1';
|
595 |
|
|
|
596 |
|
|
--Error status
|
597 |
|
|
o_ip_tx_err_out <=(others=>'0');
|
598 |
|
|
|
599 |
|
|
else
|
600 |
|
|
|
601 |
|
|
case st_tx_ip_state is
|
602 |
|
|
when IDLE =>
|
603 |
|
|
|
604 |
|
|
s_cnt_ip_tx <=(others=>'0');
|
605 |
|
|
s_cal_cheksum <= '0';
|
606 |
|
|
|
607 |
|
|
--for arp
|
608 |
|
|
o_lookup_req <= '0';
|
609 |
|
|
o_lookup_ip <=(others=>'0');
|
610 |
|
|
s_dst_mac_addr <=(others=>'0');
|
611 |
|
|
|
612 |
|
|
--for mac
|
613 |
|
|
o_mac_tx_req <= '0';
|
614 |
|
|
o_mac_tvalid <= '0';
|
615 |
|
|
s_TX_LL_SOF_N_0 <= '1';
|
616 |
|
|
o_mac_tlast <= '0';
|
617 |
|
|
s_ip_header <=(others=>'0');
|
618 |
|
|
|
619 |
|
|
--error status
|
620 |
|
|
o_ip_tx_err_out <=(others=>'0');
|
621 |
|
|
|
622 |
|
|
if i_ip_tx_start = '1' then
|
623 |
|
|
s_cal_cheksum <= '1';
|
624 |
|
|
-------------------------------------
|
625 |
|
|
if (i_dst_ip_addr = c_IP_BC_ADDR) then
|
626 |
|
|
s_dst_mac_addr <= c_MAC_BC_ADDR;
|
627 |
|
|
o_mac_tx_req <= '1';
|
628 |
|
|
st_tx_ip_state <= WAIT_CHN;
|
629 |
|
|
else
|
630 |
|
|
o_lookup_req <= '1';
|
631 |
|
|
o_lookup_ip <= i_dst_ip_addr;
|
632 |
|
|
st_tx_ip_state <= WAIT_MAC_ADDR;
|
633 |
|
|
end if;
|
634 |
|
|
|
635 |
|
|
if (unsigned(i_data_length) > 1480) then
|
636 |
|
|
o_ip_tx_err_out <= x"1";
|
637 |
|
|
s_cal_cheksum <= '0';
|
638 |
|
|
st_tx_ip_state <= IDLE;
|
639 |
|
|
end if;
|
640 |
|
|
--------------------------------------
|
641 |
|
|
end if;
|
642 |
|
|
|
643 |
|
|
when WAIT_MAC_ADDR => -- wait for achieve s_dst_mac_addr by arp block
|
644 |
|
|
|
645 |
|
|
s_cal_cheksum <= '0';
|
646 |
|
|
o_lookup_req <= '0';
|
647 |
|
|
|
648 |
|
|
--use ARP Block
|
649 |
|
|
if (g_GENERATE_ARP_MODULE) then
|
650 |
|
|
-- if i_lookup_mac_got = '1' then
|
651 |
|
|
s_dst_mac_addr <= i_lookup_mac_addr;
|
652 |
|
|
o_mac_tx_req <= '1';
|
653 |
|
|
st_tx_ip_state <= WAIT_CHN;
|
654 |
|
|
-- end if;
|
655 |
|
|
if i_lookup_mac_err = '1' then
|
656 |
|
|
o_ip_tx_err_out <= x"2";
|
657 |
|
|
-- st_tx_ip_state <= IDLE;
|
658 |
|
|
end if;
|
659 |
|
|
|
660 |
|
|
--use Defualt MAC Addr
|
661 |
|
|
else
|
662 |
|
|
s_dst_mac_addr <= g_DEFAULT_DST_MAC_ADDR;
|
663 |
|
|
o_mac_tx_req <= '1';
|
664 |
|
|
st_tx_ip_state <= WAIT_CHN;
|
665 |
|
|
end if;
|
666 |
|
|
|
667 |
|
|
when WAIT_CHN =>
|
668 |
|
|
|
669 |
|
|
s_cal_cheksum <= '0';
|
670 |
|
|
if i_mac_tx_granted = '1' then
|
671 |
|
|
st_tx_ip_state <= SEND_DATA;
|
672 |
|
|
end if;
|
673 |
|
|
|
674 |
|
|
when SEND_DATA =>
|
675 |
|
|
|
676 |
|
|
s_TX_LL_SOF_N_0 <= '1';
|
677 |
|
|
|
678 |
|
|
if (s_cnt_ip_tx=x"0000") then
|
679 |
|
|
s_ip_header <= s_dst_mac_addr (47 downto 40);
|
680 |
|
|
s_cnt_ip_tx <= s_cnt_ip_tx+1;
|
681 |
|
|
o_mac_tvalid <= '1';
|
682 |
|
|
s_TX_LL_SOF_N_0 <= '0';
|
683 |
|
|
|
684 |
|
|
end if;
|
685 |
|
|
|
686 |
|
|
|
687 |
|
|
if (i_mac_tready='1') then
|
688 |
|
|
--**************************************************************************************
|
689 |
|
|
s_cnt_ip_tx <= s_cnt_ip_tx+1;
|
690 |
|
|
case s_cnt_ip_tx is
|
691 |
|
|
when X"0001" => s_ip_header <= s_dst_mac_addr (39 downto 32);
|
692 |
|
|
when X"0002" => s_ip_header <= s_dst_mac_addr (31 downto 24);
|
693 |
|
|
when X"0003" => s_ip_header <= s_dst_mac_addr (23 downto 16);
|
694 |
|
|
when X"0004" => s_ip_header <= s_dst_mac_addr (15 downto 8);
|
695 |
|
|
when X"0005" => s_ip_header <= s_dst_mac_addr (7 downto 0);
|
696 |
|
|
when X"0006" => s_ip_header <= i_our_mac_addr (47 downto 40);
|
697 |
|
|
when X"0007" => s_ip_header <= i_our_mac_addr (39 downto 32);
|
698 |
|
|
when X"0008" => s_ip_header <= i_our_mac_addr (31 downto 24);
|
699 |
|
|
when X"0009" => s_ip_header <= i_our_mac_addr (23 downto 16);
|
700 |
|
|
when X"000A" => s_ip_header <= i_our_mac_addr (15 downto 8);
|
701 |
|
|
when X"000B" => s_ip_header <= i_our_mac_addr (7 downto 0);
|
702 |
|
|
when X"000C" => s_ip_header <= x"08"; --ip farme type
|
703 |
|
|
when X"000D" => s_ip_header <= x"00"; --ip frame type
|
704 |
|
|
when X"000E" => s_ip_header <= x"45"; --ip i_protocol type(ipv4)
|
705 |
|
|
when X"000F" => s_ip_header <= x"00"; --identification
|
706 |
|
|
when X"0010" => s_ip_header <= s_total_length(15 downto 8); --s_total_length is udpdata+20(ip header)
|
707 |
|
|
when X"0011" => s_ip_header <= s_total_length(7 downto 0); --s_total_length is udpdata+20(ip header)
|
708 |
|
|
when X"0012" => s_ip_header <= x"00"; --identification
|
709 |
|
|
when X"0013" => s_ip_header <= x"00"; --identification
|
710 |
|
|
when X"0014" => s_ip_header <= s_ip_tx_fragmantation (15 downto 8); --fragmention
|
711 |
|
|
when X"0015" => s_ip_header <= s_ip_tx_fragmantation (7 downto 0); --fragmention
|
712 |
|
|
when X"0016" => s_ip_header <= c_IP_TTL; --time to live
|
713 |
|
|
when X"0017" => s_ip_header <= i_protocol; --udp i_protocol
|
714 |
|
|
when X"0018" => s_ip_header <= s_tx_hdr_cks (15 downto 8);
|
715 |
|
|
when X"0019" => s_ip_header <= s_tx_hdr_cks (7 downto 0);
|
716 |
|
|
when X"001A" => s_ip_header <= i_our_ip_addr (31 downto 24);
|
717 |
|
|
when X"001B" => s_ip_header <= i_our_ip_addr (23 downto 16);
|
718 |
|
|
when X"001C" => s_ip_header <= i_our_ip_addr (15 downto 8);
|
719 |
|
|
when X"001D" => s_ip_header <= i_our_ip_addr (7 downto 0);
|
720 |
|
|
when X"001E" => s_ip_header <= i_dst_ip_addr (31 downto 24);
|
721 |
|
|
when X"001F" => s_ip_header <= i_dst_ip_addr (23 downto 16);
|
722 |
|
|
when X"0020" => s_ip_header <= i_dst_ip_addr (15 downto 8);
|
723 |
|
|
when X"0021" => s_ip_header <= i_dst_ip_addr (7 downto 0);
|
724 |
|
|
when others => null;
|
725 |
|
|
end case;
|
726 |
|
|
|
727 |
|
|
if (s_cnt_ip_tx=i_data_length+34-1) then --i_data_length is udp data length
|
728 |
|
|
o_mac_tlast <= '1';
|
729 |
|
|
end if;
|
730 |
|
|
--*********************************************************************************************
|
731 |
|
|
end if;
|
732 |
|
|
|
733 |
|
|
if (s_cnt_ip_tx=i_data_length+34) then
|
734 |
|
|
s_cnt_ip_tx <= (others=>'0');
|
735 |
|
|
o_mac_tx_req <= '0';
|
736 |
|
|
o_mac_tvalid <= '0';
|
737 |
|
|
o_mac_tlast <= '0';
|
738 |
|
|
s_ip_header <= (others=>'0');
|
739 |
|
|
st_tx_ip_state <= IDLE;
|
740 |
|
|
end if;
|
741 |
|
|
|
742 |
|
|
END CASE;
|
743 |
|
|
|
744 |
|
|
end if;
|
745 |
|
|
end if;
|
746 |
|
|
end process p_transmission_data;
|
747 |
|
|
--===========================================================================================================================
|
748 |
|
|
|
749 |
|
|
--=========================== IP_Checksum Calculate =========================================================================
|
750 |
|
|
crc : process (i_tx_clk)
|
751 |
|
|
begin
|
752 |
|
|
if rising_edge(i_tx_clk) then
|
753 |
|
|
if (i_reset='1') then
|
754 |
|
|
st_crc_state <=IDLE;
|
755 |
|
|
s_tx_hdr_cks <=(others=>'0');
|
756 |
|
|
else
|
757 |
|
|
case st_crc_state is
|
758 |
|
|
when IDLE =>
|
759 |
|
|
if s_cal_cheksum = '1' then
|
760 |
|
|
s_tx_hdr_cks <= x"004500";
|
761 |
|
|
st_crc_state <= TOT_LEN;
|
762 |
|
|
end if;
|
763 |
|
|
|
764 |
|
|
when TOT_LEN =>
|
765 |
|
|
s_tx_hdr_cks <= std_logic_vector (unsigned(s_tx_hdr_cks) + unsigned(s_total_length));
|
766 |
|
|
st_crc_state <= ID;
|
767 |
|
|
|
768 |
|
|
when ID =>
|
769 |
|
|
s_tx_hdr_cks <= (x"00"&x"0000") + s_tx_hdr_cks;
|
770 |
|
|
st_crc_state <= FLAGS;
|
771 |
|
|
|
772 |
|
|
when FLAGS =>
|
773 |
|
|
s_tx_hdr_cks <= (x"00"&s_ip_tx_fragmantation) + s_tx_hdr_cks;
|
774 |
|
|
st_crc_state <= TTL;
|
775 |
|
|
|
776 |
|
|
when TTL =>
|
777 |
|
|
s_tx_hdr_cks <= std_logic_vector (unsigned(s_tx_hdr_cks) + unsigned(c_IP_TTL & i_protocol));
|
778 |
|
|
st_crc_state <= CKS;
|
779 |
|
|
|
780 |
|
|
when CKS =>
|
781 |
|
|
s_tx_hdr_cks <= s_tx_hdr_cks;
|
782 |
|
|
st_crc_state <= SAH;
|
783 |
|
|
|
784 |
|
|
when SAH =>
|
785 |
|
|
s_tx_hdr_cks <= std_logic_vector (unsigned(s_tx_hdr_cks) + unsigned(i_our_ip_addr(31 downto 16)));
|
786 |
|
|
st_crc_state <= SAL;
|
787 |
|
|
|
788 |
|
|
when SAL =>
|
789 |
|
|
s_tx_hdr_cks <= std_logic_vector (unsigned(s_tx_hdr_cks) + unsigned(i_our_ip_addr(15 downto 0)));
|
790 |
|
|
st_crc_state <= DAH;
|
791 |
|
|
|
792 |
|
|
when DAH =>
|
793 |
|
|
s_tx_hdr_cks <= std_logic_vector (unsigned(s_tx_hdr_cks) + unsigned(i_dst_ip_addr(31 downto 16)));
|
794 |
|
|
st_crc_state <= DAL;
|
795 |
|
|
|
796 |
|
|
when DAL =>
|
797 |
|
|
s_tx_hdr_cks <= std_logic_vector (unsigned(s_tx_hdr_cks) + unsigned(i_dst_ip_addr(15 downto 0)));
|
798 |
|
|
st_crc_state <= ADDOVF;
|
799 |
|
|
|
800 |
|
|
when ADDOVF =>
|
801 |
|
|
s_tx_hdr_cks <= std_logic_vector ((unsigned(s_tx_hdr_cks) and x"00ffff")+ unsigned(s_tx_hdr_cks(23 downto 16)));
|
802 |
|
|
st_crc_state <= FINAL;
|
803 |
|
|
|
804 |
|
|
when FINAL =>
|
805 |
|
|
s_tx_hdr_cks <= inv_if_one(std_logic_vector (unsigned(s_tx_hdr_cks) + unsigned(s_tx_hdr_cks(23 downto 16))), '1');
|
806 |
|
|
st_crc_state <= WAIT_END;
|
807 |
|
|
|
808 |
|
|
when WAIT_END =>
|
809 |
|
|
s_tx_hdr_cks <= s_tx_hdr_cks;
|
810 |
|
|
if s_cal_cheksum = '0' then
|
811 |
|
|
st_crc_state <= IDLE;
|
812 |
|
|
else
|
813 |
|
|
st_crc_state <= WAIT_END;
|
814 |
|
|
end if;
|
815 |
|
|
|
816 |
|
|
end case;
|
817 |
|
|
end if;
|
818 |
|
|
end if;
|
819 |
|
|
end process;
|
820 |
|
|
--===========================================================================================================================
|
821 |
|
|
|
822 |
|
|
end Behavioral;
|