1 |
2 |
pjf |
--
|
2 |
|
|
--
|
3 |
|
|
-- Purpose: This package defines types for use in IPv4
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
library IEEE;
|
7 |
|
|
use IEEE.STD_LOGIC_1164.all;
|
8 |
|
|
use work.axi.all;
|
9 |
|
|
|
10 |
|
|
package ipv4_types is
|
11 |
|
|
|
12 |
6 |
pjf |
constant IP_BC_ADDR : std_logic_vector (31 downto 0) := x"ffffffff";
|
13 |
|
|
constant MAC_BC_ADDR : std_logic_vector (47 downto 0) := x"ffffffffffff";
|
14 |
|
|
|
15 |
2 |
pjf |
--------------
|
16 |
|
|
-- IPv4 TX --
|
17 |
|
|
--------------
|
18 |
|
|
|
19 |
|
|
-- coding for result in tx
|
20 |
|
|
constant IPTX_RESULT_NONE : std_logic_vector (1 downto 0) := "00";
|
21 |
|
|
constant IPTX_RESULT_SENDING : std_logic_vector (1 downto 0) := "01";
|
22 |
|
|
constant IPTX_RESULT_ERR : std_logic_vector (1 downto 0) := "10";
|
23 |
|
|
constant IPTX_RESULT_SENT : std_logic_vector (1 downto 0) := "11";
|
24 |
|
|
|
25 |
|
|
type ipv4_tx_header_type is record
|
26 |
|
|
protocol : std_logic_vector (7 downto 0);
|
27 |
|
|
data_length : STD_LOGIC_VECTOR (15 downto 0); -- user data size, bytes
|
28 |
|
|
dst_ip_addr : STD_LOGIC_VECTOR (31 downto 0);
|
29 |
|
|
end record;
|
30 |
|
|
|
31 |
|
|
type ipv4_tx_type is record
|
32 |
|
|
hdr : ipv4_tx_header_type; -- header to tx
|
33 |
|
|
data : axi_out_type; -- tx axi bus
|
34 |
|
|
end record;
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
--------------
|
38 |
|
|
-- IPv4 RX --
|
39 |
|
|
--------------
|
40 |
|
|
|
41 |
|
|
-- coding for last_error_code in rx hdr
|
42 |
|
|
constant RX_EC_NONE : std_logic_vector (3 downto 0) := x"0";
|
43 |
|
|
constant RX_EC_ET_ETH : std_logic_vector (3 downto 0) := x"1"; -- early termination in ETH hdr phase
|
44 |
|
|
constant RX_EC_ET_IP : std_logic_vector (3 downto 0) := x"2"; -- early termination in IP hdr phase
|
45 |
|
|
constant RX_EC_ET_USER : std_logic_vector (3 downto 0) := x"3"; -- early termination in USER DATA phase
|
46 |
|
|
|
47 |
|
|
type ipv4_rx_header_type is record
|
48 |
|
|
is_valid : std_logic;
|
49 |
|
|
protocol : std_logic_vector (7 downto 0);
|
50 |
|
|
data_length : STD_LOGIC_VECTOR (15 downto 0); -- user data size, bytes
|
51 |
|
|
src_ip_addr : STD_LOGIC_VECTOR (31 downto 0);
|
52 |
|
|
num_frame_errors : std_logic_vector (7 downto 0);
|
53 |
|
|
last_error_code : std_logic_vector (3 downto 0); -- see RX_EC_xxx constants
|
54 |
6 |
pjf |
is_broadcast : std_logic; -- set if the msg received is a broadcast
|
55 |
2 |
pjf |
end record;
|
56 |
|
|
|
57 |
|
|
type ipv4_rx_type is record
|
58 |
|
|
hdr : ipv4_rx_header_type; -- header received
|
59 |
|
|
data : axi_in_type; -- rx axi bus
|
60 |
|
|
end record;
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
------------
|
64 |
|
|
-- UDP TX --
|
65 |
|
|
------------
|
66 |
|
|
|
67 |
|
|
-- coding for result in tx
|
68 |
|
|
constant UDPTX_RESULT_NONE : std_logic_vector (1 downto 0) := "00";
|
69 |
|
|
constant UDPTX_RESULT_SENDING : std_logic_vector (1 downto 0) := "01";
|
70 |
|
|
constant UDPTX_RESULT_ERR : std_logic_vector (1 downto 0) := "10";
|
71 |
|
|
constant UDPTX_RESULT_SENT : std_logic_vector (1 downto 0) := "11";
|
72 |
|
|
|
73 |
|
|
type udp_tx_header_type is record
|
74 |
|
|
dst_ip_addr : STD_LOGIC_VECTOR (31 downto 0);
|
75 |
|
|
dst_port : STD_LOGIC_VECTOR (15 downto 0);
|
76 |
|
|
src_port : STD_LOGIC_VECTOR (15 downto 0);
|
77 |
|
|
data_length : STD_LOGIC_VECTOR (15 downto 0); -- user data size, bytes
|
78 |
|
|
checksum : STD_LOGIC_VECTOR (15 downto 0);
|
79 |
|
|
end record;
|
80 |
|
|
|
81 |
|
|
|
82 |
|
|
type udp_tx_type is record
|
83 |
|
|
hdr : udp_tx_header_type; -- header received
|
84 |
|
|
data : axi_out_type; -- tx axi bus
|
85 |
|
|
end record;
|
86 |
|
|
|
87 |
|
|
|
88 |
|
|
------------
|
89 |
|
|
-- UDP RX --
|
90 |
|
|
------------
|
91 |
|
|
|
92 |
|
|
type udp_rx_header_type is record
|
93 |
|
|
is_valid : std_logic;
|
94 |
|
|
src_ip_addr : STD_LOGIC_VECTOR (31 downto 0);
|
95 |
|
|
src_port : STD_LOGIC_VECTOR (15 downto 0);
|
96 |
|
|
dst_port : STD_LOGIC_VECTOR (15 downto 0);
|
97 |
|
|
data_length : STD_LOGIC_VECTOR (15 downto 0); -- user data size, bytes
|
98 |
|
|
end record;
|
99 |
|
|
|
100 |
|
|
|
101 |
|
|
type udp_rx_type is record
|
102 |
|
|
hdr : udp_rx_header_type; -- header received
|
103 |
|
|
data : axi_in_type; -- rx axi bus
|
104 |
|
|
end record;
|
105 |
|
|
|
106 |
|
|
type udp_addr_type is record
|
107 |
|
|
ip_addr : STD_LOGIC_VECTOR (31 downto 0);
|
108 |
|
|
port_num : STD_LOGIC_VECTOR (15 downto 0);
|
109 |
|
|
end record;
|
110 |
|
|
|
111 |
|
|
|
112 |
|
|
end ipv4_types;
|