AXI-Stream Ethernet Parser
- ENTITY AXIS_ETH_PARSER_GEN IS
The AXIS_ETH_PARSER_GEN component reads protocol headers from Ethernet frames. The frames pass unchanged from the RX to the TX interface.
The parser is a chain of stages. PROTOCOLS sets the protocol of each stage. A stage reads the header only when the previous headers announce its protocol. Otherwise the stage passes the announced protocol and its offset to the next stage. The order in PROTOCOLS must therefore follow the order of headers in a frame. The first stage must be PROTO_ETH.
For each frame, the parser outputs one item on the HDR_* interface. Item i contains the header that stage i read. The package axis_eth_parser_types provides functions that decode HDR_DATA. The parser reads only the first get_extract_bytes(PROTOCOLS(i)) bytes of a header. A header is reported as not found when the frame ends before all bytes that the stage reads.
A register stage between two parser stages shortens the critical path and adds one clock cycle of latency. STAGE_REG_AUTO and STAGE_REG select these register stages.
Generics
PortsGeneric
Type
Default
Description
AXI_TDATA_WIDTH
natural
512
Width of the AXI-Stream data bus in bits, a power of two (e.g., 256, 512)
PROTOCOLS
proto_array_t
(PROTO_ETH, PROTO_VLAN, PROTO_IPV4, PROTO_TCP, PROTO_UDP)
Protocols of the parser stages in pipeline order (see PROTO_* in axis_eth_parser_types)
STAGE_REG
std_logic_vector(MAX_STAGES-1 downto 0)
(others => ‘0’)
Bit i set: a register stage after parser stage i. Bits above the number of stages are not used.
STAGE_REG_AUTO
boolean
true
True: get_stage_reg_auto(PROTOCOLS) selects the register stages and STAGE_REG is not used
PKT_MTU
natural
2**14
Maximum packet size in bytes (determines offset field width)
FIFO_DEPTH
natural
64
Depth of internal FIFOs (number of packets that can be buffered), at least 3
DEVICE
string
“AGILEX”
Target device family for FIFO implementation (e.g., “AGILEX”, “ULTRASCALE”)
Port
Type
Mode
Description
CLK
std_logic
in
System clock
RESET
std_logic
in
Active-high synchronous reset
RX_AXI_TDATA
std_logic_vector(AXI_TDATA_WIDTH-1 downto 0)
in
RX AXI-Stream Interface
RX_AXI_TKEEP
std_logic_vector((AXI_TDATA_WIDTH/8)-1 downto 0)
in
RX_AXI_TLAST
std_logic
in
RX_AXI_TVALID
std_logic
in
RX_AXI_TREADY
std_logic
out
TX_AXI_TDATA
std_logic_vector(AXI_TDATA_WIDTH-1 downto 0)
out
TX AXI-Stream Interface
TX_AXI_TKEEP
std_logic_vector((AXI_TDATA_WIDTH/8)-1 downto 0)
out
TX_AXI_TLAST
std_logic
out
TX_AXI_TVALID
std_logic
out
TX_AXI_TREADY
std_logic
in
HDR_DATA
slv_array_t(PROTOCOLS’length-1 downto 0)(get_max_extract_bytes(PROTOCOLS)*8-1 downto 0)
out
Headers Output Interface, one item per frame Header bytes read by stage i, byte 0 of the header is in bits 7:0. Valid when HDR_FOUND(i) is set.
HDR_OFFSET
slv_array_t(PROTOCOLS’length-1 downto 0)(log2(PKT_MTU+1)-1 downto 0)
out
Byte offset of the header of stage i in the frame. Valid when HDR_FOUND(i) is set.
HDR_FOUND
std_logic_vector(PROTOCOLS’length-1 downto 0)
out
Bit i is set when stage i found its header and the frame contains all bytes that stage i reads
HDR_VLD
std_logic
out
HDR_READY
std_logic
in
- ENTITY AXIS_ETH_PARSER IS
The AXIS_ETH_PARSER component parses Ethernet frames and extracts the Ethernet, VLAN, IPv4, TCP and UDP headers. It contains AXIS_ETH_PARSER_GEN with one stage for each of these protocols, so it reads at most one VLAN tag. The headers are decoded into the extracted_headers_t record on the HEADERS output interface. The original frame data passes through unchanged to the TX interface.
Generics
PortsGeneric
Type
Default
Description
AXI_TDATA_WIDTH
natural
512
Width of the AXI-Stream data bus in bits (e.g., 256, 512)
PKT_MTU
natural
2**14
Maximum packet size in bytes (determines offset field width) Maximum supported value is 2**14.
FIFO_DEPTH
natural
64
Depth of internal FIFOs (number of packets that can be buffered)
DEVICE
string
“AGILEX”
Target device family for FIFO implementation (e.g., “AGILEX”, “ULTRASCALE”)
Port
Type
Mode
Description
CLK
std_logic
in
System clock
RESET
std_logic
in
Active-high synchronous reset
RX_AXI_TDATA
std_logic_vector(AXI_TDATA_WIDTH-1 downto 0)
in
RX AXI-Stream Interface
RX_AXI_TKEEP
std_logic_vector((AXI_TDATA_WIDTH/8)-1 downto 0)
in
RX_AXI_TLAST
std_logic
in
RX_AXI_TVALID
std_logic
in
RX_AXI_TREADY
std_logic
out
TX_AXI_TDATA
std_logic_vector(AXI_TDATA_WIDTH-1 downto 0)
out
TX AXI-Stream Interface
TX_AXI_TKEEP
std_logic_vector((AXI_TDATA_WIDTH/8)-1 downto 0)
out
TX_AXI_TLAST
std_logic
out
TX_AXI_TVALID
std_logic
out
TX_AXI_TREADY
std_logic
in
HEADERS
extracted_headers_t
out
Headers Output Interface
HEADERS_VLD
std_logic
out
HEADERS_READY
std_logic
in
Protocols
The package axis_eth_parser_types defines one PROTO_* constant for each protocol.
The table describes what a stage of each protocol reads and how it selects the next protocol.
The header offset is the position of the first header byte in the frame.
Protocol |
Bytes read |
Header length in bytes |
Next protocol |
|---|---|---|---|
|
14 |
14 |
Ethertype in bytes 12 and 13: 0x8100, 0x88A8 and 0x9100 select |
|
4 |
4 |
Ethertype in bytes 2 and 3, with the same values as |
|
5 |
4 |
|
|
20 |
IHL × 4, or 20 when IHL is less than 5 |
Protocol field: 6 selects |
|
40 |
40 |
Next header field: 6 selects |
|
8 |
(hdr_ext_len + 1) × 8 |
Next header field, with the same values as |
|
20 |
20 |
None |
|
8 |
8 |
None |
Any other value of the field ends the protocol chain. The stages after the end of the chain report their header as not found.
Limitations
The parser outputs only the bytes that the table lists. IPv4 options, TCP options and the data of IPv6 extension headers after byte 7 are not available.
A header is reported as not found when the frame ends before all bytes that the stage reads. The output does not show whether such a header is missing or cut. Bytes of the header after these bytes can be missing from the frame.
HDR_VLDis set only after the frame passesTX_AXI_TREADY. The TX side must not holdTX_AXI_TREADYlow untilHDR_VLDis set.When a frame contains more headers of one protocol than
PROTOCOLShas stages, the protocol chain ends after the last stage of this protocol.In an IPv4 or IPv6 fragment with a fragment offset other than 0, the frame contains no TCP or UDP header. The TCP and UDP stages then read data bytes of the fragment. Check
fragment_offsetof IPv4, or the IPv6 Fragment header (next header 44).The MPLS label stack does not announce the protocol after the last label. The
PROTO_MPLSstage reads the IP version field of the next header for this purpose.A next header that would start after
PKT_MTUends the protocol chain.
Register stages
A register stage after a parser stage delays the AXI data and the protocol chain by one clock cycle. It shortens the critical path from the header of one stage to the header extraction of the next stage.
With
STAGE_REG_AUTO = true,get_stage_reg_auto(PROTOCOLS)selects the register stages. It places them after eachPROTO_IPV4andPROTO_IPV6EXTstage, except after the last stage. These stages compute a variable header length, which makes the path longer.With
STAGE_REG_AUTO = false, bit i ofSTAGE_REGadds a register stage after stage i.
Each register stage adds one clock cycle of latency and registers for one AXI word.
Example
The example parses VLAN tagged IPv6 frames and decodes the IPv6 header.
constant PROTOCOLS : proto_array_t := (PROTO_ETH, PROTO_VLAN, PROTO_IPV6, PROTO_TCP, PROTO_UDP);
constant IPV6_I : natural := get_stage_index(PROTOCOLS, PROTO_IPV6);
...
ipv6_hdr <= decode_ipv6(hdr_data(IPV6_I));
ipv6_found <= hdr_found(IPV6_I);