2
2
-- Copyright (C) 2023 CESNET z. s. p. o.
3
3
-- Author(s): Daniel Kondys <[email protected] >
4
4
-- Vladislav Valek <[email protected] >
5
+ -- Jakub Cabal <[email protected] >
5
6
--
6
7
-- SPDX-License-Identifier: BSD-3-Clause
7
8
@@ -55,6 +56,7 @@ entity MFB_GENERATOR is
55
56
CTRL_MAC_SRC : in std_logic_vector (48 - 1 downto 0 );
56
57
CTRL_PKT_CNT_CLR : in std_logic ;
57
58
CTRL_PKT_CNT : out std_logic_vector (PKT_CNT_WIDTH- 1 downto 0 );
59
+ CTRL_SRC_IP_MASK : in std_logic_vector (32 - 1 downto 0 );
58
60
59
61
-- TX interface
60
62
TX_MFB_DATA : out std_logic_vector (REGIONS* REGION_SIZE* BLOCK_SIZE* ITEM_WIDTH- 1 downto 0 );
@@ -71,7 +73,7 @@ entity MFB_GENERATOR is
71
73
architecture BEHAV of MFB_GENERATOR is
72
74
73
75
constant CHANNELS : natural := 2 ** CHANNELS_WIDTH;
74
- constant ETHER_TYPE : std_logic_vector (15 downto 0 ) := X"B588 " ; -- local experimental ethertype
76
+ constant ETHER_TYPE : std_logic_vector (15 downto 0 ) := X"0008 " ; -- IPv4 ethertype
75
77
76
78
signal pkt_cnt : u_array_t(REGIONS downto 0 )(PKT_CNT_WIDTH- 1 downto 0 );
77
79
signal pkt_cnt_reg : unsigned (PKT_CNT_WIDTH- 1 downto 0 );
@@ -122,8 +124,17 @@ architecture BEHAV of MFB_GENERATOR is
122
124
signal meta : slv_array_t(REGIONS- 1 downto 0 )(CHANNELS_WIDTH+ LENGTH_WIDTH- 1 downto 0 );
123
125
signal data : slv_array_t(REGIONS- 1 downto 0 )(REGION_SIZE* BLOCK_SIZE* ITEM_WIDTH- 1 downto 0 );
124
126
125
- signal free_cnt : unsigned (16 - 1 downto 0 );
126
- signal eth_hdr_128b : std_logic_vector (128 - 1 downto 0 );
127
+ signal free_cnt : unsigned (32 - 1 downto 0 );
128
+ signal dip : slv_array_t(REGIONS- 1 downto 0 )(32 - 1 downto 0 );
129
+ signal sip : slv_array_t(REGIONS- 1 downto 0 )(32 - 1 downto 0 );
130
+ signal dport : slv_array_t(REGIONS- 1 downto 0 )(16 - 1 downto 0 );
131
+ signal sport : slv_array_t(REGIONS- 1 downto 0 )(16 - 1 downto 0 );
132
+ signal l3len : std_logic_vector (16 - 1 downto 0 );
133
+ signal l4len : std_logic_vector (16 - 1 downto 0 );
134
+ signal ipv4_hdr : slv_array_t(REGIONS- 1 downto 0 )((20 * 8 )- 1 downto 0 );
135
+ signal udp_hdr : slv_array_t(REGIONS- 1 downto 0 )((8 * 8 )- 1 downto 0 );
136
+ signal eth_hdr_384b : slv_array_t(REGIONS- 1 downto 0 )(384 - 1 downto 0 );
137
+
127
138
signal sof_pos_arr : slv_array_t(REGIONS- 1 downto 0 )(max(1 , log2 (REGION_SIZE))- 1 downto 0 );
128
139
signal sof_index : u_array_t(REGIONS- 1 downto 0 )(max(1 , log2 (REGIONS* REGION_SIZE))- 1 downto 0 );
129
140
signal data_word_plus : slv_array_t(2 * REGIONS* REGION_SIZE- 1 downto 0 )(BLOCK_SIZE* ITEM_WIDTH- 1 downto 0 );
@@ -447,12 +458,26 @@ begin
447
458
if (RST = '1' ) then
448
459
free_cnt <= (others => '0' );
449
460
elsif (dst_rdy = '1' ) then
450
- free_cnt <= free_cnt + 1 ;
461
+ free_cnt <= free_cnt + REGIONS ;
451
462
end if ;
452
463
end if ;
453
464
end process ;
454
465
455
- eth_hdr_128b <= std_logic_vector (free_cnt) & ETHER_TYPE & CTRL_MAC_SRC & CTRL_MAC_DST;
466
+ l3len <= std_logic_vector (resize ((unsigned (CTRL_LENGTH)- 14 ),16 ));
467
+ l4len <= std_logic_vector (resize ((unsigned (CTRL_LENGTH)- 34 ),16 ));
468
+
469
+ hdr_g : for i in 0 to REGIONS- 1 generate
470
+ dip(i) <= X"00000000" ;
471
+ sip(i) <= std_logic_vector (free_cnt + i) and CTRL_SRC_IP_MASK;
472
+ dport(i) <= X"0000" ;
473
+ sport(i) <= X"0000" ;
474
+
475
+ -- UDP proto, Time To Live, Identification+Flags+FragmentOffset, l3len, DSCP+ECN, IHL+version
476
+ ipv4_hdr(i) <= dip(i) & sip(i) & X"0000" & X"11" & X"FF" & X"00000000" & l3len(7 downto 0 ) & l3len(15 downto 8 ) & X"00" & X"45" ;
477
+ udp_hdr(i) <= X"0000" & l4len(7 downto 0 ) & l4len(15 downto 8 ) & dport(i) & sport(i);
478
+ eth_hdr_384b(i) <= X"000000000000" & udp_hdr(i) & ipv4_hdr(i) & ETHER_TYPE & CTRL_MAC_SRC & CTRL_MAC_DST;
479
+ end generate ;
480
+
456
481
sof_pos_arr <= slv_array_deser(sof_pos,REGIONS,max(1 , log2 (REGION_SIZE)));
457
482
458
483
process (all )
@@ -466,8 +491,12 @@ begin
466
491
for i in 0 to REGIONS- 1 loop
467
492
sof_index(i) <= resize (unsigned (sof_pos_arr(i)),log2 (REGIONS* REGION_SIZE)) + i* REGION_SIZE;
468
493
if (sof(i) = '1' ) then
469
- data_word_plus(to_integer (sof_index(i))) <= eth_hdr_128b(64 - 1 downto 0 );
470
- data_word_plus(to_integer (sof_index(i))+ 1 ) <= eth_hdr_128b(128 - 1 downto 64 );
494
+ data_word_plus(to_integer (sof_index(i))) <= eth_hdr_384b(i)(64 - 1 downto 0 );
495
+ data_word_plus(to_integer (sof_index(i))+ 1 ) <= eth_hdr_384b(i)(128 - 1 downto 64 );
496
+ data_word_plus(to_integer (sof_index(i))+ 2 ) <= eth_hdr_384b(i)(192 - 1 downto 128 );
497
+ data_word_plus(to_integer (sof_index(i))+ 3 ) <= eth_hdr_384b(i)(256 - 1 downto 192 );
498
+ data_word_plus(to_integer (sof_index(i))+ 4 ) <= eth_hdr_384b(i)(320 - 1 downto 256 );
499
+ data_word_plus(to_integer (sof_index(i))+ 5 ) <= eth_hdr_384b(i)(384 - 1 downto 320 );
471
500
end if ;
472
501
end loop ;
473
502
end process ;
0 commit comments