From f5f5fcb3bf33cda78b84524af053d960fb1a0d2f Mon Sep 17 00:00:00 2001 From: Michael Boehmer Date: Fri, 11 Nov 2022 12:06:55 +0100 Subject: [PATCH] reduced number of FIFOs in gbe_frame_receiver --- gbe_trb/base/gbe_frame_receiver.vhd | 215 +++++++++++++----- gbe_trb/base/gbe_logic_wrapper.vhd | 35 +-- gbe_trb/base/gbe_main_control.vhd | 4 + gbe_trb/base/gbe_protocol_selector.vhd | 6 +- gbe_trb/base/gbe_receive_control.vhd | 26 +-- .../gbe_response_constructor_DHCP.vhd | 26 +-- .../gbe_response_constructor_SCTRL.vhd | 10 +- 7 files changed, 208 insertions(+), 114 deletions(-) diff --git a/gbe_trb/base/gbe_frame_receiver.vhd b/gbe_trb/base/gbe_frame_receiver.vhd index ef131e0..3caef26 100644 --- a/gbe_trb/base/gbe_frame_receiver.vhd +++ b/gbe_trb/base/gbe_frame_receiver.vhd @@ -14,6 +14,7 @@ entity gbe_frame_receiver is LINK_OK_IN : in std_logic; ALLOW_RX_IN : in std_logic; MY_MAC_IN : in std_logic_vector(47 downto 0); + MY_IP_IN : in std_logic_vector(31 downto 0); -- killer ping MY_TRBNET_ADDRESS_IN : in std_logic_vector(15 downto 0) := (others => '0'); ISSUE_REBOOT_OUT : out std_logic; @@ -29,6 +30,7 @@ entity gbe_frame_receiver is FR_GET_FRAME_IN : in std_logic; -- interconnect to gbe_receive_control FR_FRAME_SIZE_OUT : out std_logic_vector(15 downto 0); -- interconnect to gbe_receive_control FR_PS_OUT : out std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0); + FR_INFO_OUT : out std_logic_vector(7 downto 0); -- FR_SRC_MAC_ADDRESS_OUT : out std_logic_vector(47 downto 0); FR_DEST_MAC_ADDRESS_OUT : out std_logic_vector(47 downto 0); @@ -51,7 +53,7 @@ end gbe_frame_receiver; architecture gbe_frame_receiver_arch of gbe_frame_receiver is - signal mac_rxd_q : std_logic_vector(7 downto 0); + signal mac_rxd_q : std_logic_vector(7 downto 0); signal mac_rx_en_q : std_logic; signal mac_rx_er_q : std_logic; signal mac_rx_eof_q : std_logic; @@ -63,15 +65,18 @@ architecture gbe_frame_receiver_arch of gbe_frame_receiver is signal decode_fsm : std_logic_vector(3 downto 0); signal decode_ctr : unsigned(7 downto 0); - signal is_my_mac_x : std_logic; - signal is_broadcast_x : std_logic; - signal is_arp_x : std_logic; - signal is_ipv4_x : std_logic; - signal is_version_x : std_logic; - signal is_udp_x : std_logic; - signal is_icmp_x : std_logic; - signal is_dhcp_x : std_logic; - signal is_sctrl_x : std_logic; + signal is_my_mac_x : std_logic; -- MAC match, no broadcast + signal is_broadcast_x : std_logic; -- broadcast MAC detected + signal is_arp_x : std_logic; -- ARP frame detected + signal is_ipv4_x : std_logic; -- IPv4 frame detected + signal is_version_x : std_logic; -- correct IP version and header length + signal is_udp_x : std_logic; -- UDP detected + signal is_icmp_x : std_logic; -- ICMP detected + signal is_dhcp_x : std_logic; -- DHCP detected + signal is_sctrl_x : std_logic; -- SCTRL detected + signal is_my_ip_x : std_logic; -- IP match, no broadcast + signal is_broadcast_ip_x : std_logic; -- broadcast IP detected + signal is_empty_payload_x : std_logic; -- empty payload detected (for frames stored!) signal stored_src_mac : std_logic_vector(47 downto 0); signal stored_dst_mac : std_logic_vector(47 downto 0); @@ -107,6 +112,7 @@ architecture gbe_frame_receiver_arch of gbe_frame_receiver is signal fr_src_mac : std_logic_vector(47 downto 0); signal fr_ps : std_logic_vector(7 downto 0); signal fr_q : std_logic_vector(8 downto 0); + signal fr_info : std_logic_vector(7 downto 0); signal oob_register_0_int : std_logic_vector(31 downto 0); signal oob_register_1_int : std_logic_vector(31 downto 0); @@ -116,6 +122,9 @@ architecture gbe_frame_receiver_arch of gbe_frame_receiver is signal drop_frame_x : std_logic; signal drop_frame : std_logic; + signal fifo_one_q : std_logic_vector(71 downto 0); + signal fifo_two_q : std_logic_vector(71 downto 0); + begin -- buffer incoming signals @@ -203,17 +212,37 @@ begin -- correct IPv4 header if( (is_udp_x = '1') ) then -- UDP header - if ( (is_dhcp_x = '1') or (is_sctrl_x = '1') ) then - -- DHCP, SCTRL - if( (mac_rx_eof_q = '0') ) then - -- payload available - DECODE_NS <= STORE_FRAME; - else - -- empty payload, store raw frame, check that later? - DECODE_NS <= LAST_BYTE; - fifo_hd_wr_x <= '1'; - end if; - end if; +-- if ( (is_dhcp_x = '1') or (is_sctrl_x = '1') ) then +-- -- DHCP, SCTRL +-- if( (mac_rx_eof_q = '0') ) then +-- -- payload available +-- DECODE_NS <= STORE_FRAME; +-- else +-- -- empty payload, store raw frame, check that later? +-- DECODE_NS <= LAST_BYTE; +-- fifo_hd_wr_x <= '1'; +-- end if; +-- end if; + if( (is_dhcp_x = '1') ) then + -- DHCP + if( (mac_rx_eof_q = '0') ) then + -- payload available + DECODE_NS <= STORE_FRAME; + else + -- empty payload, must never happen with DHCP, so we drop it + DECODE_NS <= LAST_BYTE; + end if; + end if; + if( (is_sctrl_x = '1') ) then + -- SCTRL + if( (mac_rx_eof_q = '0') ) then + -- payload available + DECODE_NS <= STORE_FRAME; + else + -- empty payload, must never happen with SCTRL, so we drop it + DECODE_NS <= LAST_BYTE; + end if; + end if; end if; end if; @@ -235,7 +264,7 @@ begin -- we need an emergency exit in case frame is "strange"! if( (mac_rx_eof_qq = '1') ) then - DECODE_NS <= WRITE_HDR; + DECODE_NS <= WRITE_HDR; -- really? end if; when IGNORE_FRAME => @@ -248,7 +277,8 @@ begin when STORE_FRAME => decode_fsm <= x"3"; - if( MAC_RX_EOF_IN = '1' ) then + -- second term is needed for payload of one byte! + if( (MAC_RX_EOF_IN = '1') or (mac_rx_eof_q = '1') ) then DECODE_NS <= LAST_BYTE; fifo_hd_wr_x <= '1'; else @@ -380,15 +410,18 @@ begin end process PROC_STORE_INFO; -- checks to filter frames, and distribute them to the correct handlers - is_my_mac_x <= '1' when (stored_dst_mac = MY_MAC_IN) else '0'; - is_broadcast_x <= '1' when (stored_dst_mac = x"ffffffffffff") else '0'; - is_arp_x <= '1' when (stored_ethertype = x"0806") else '0'; - is_ipv4_x <= '1' when (stored_ethertype = x"0800") else '0'; - is_version_x <= '1' when (stored_version = x"45") else '0'; - is_udp_x <= '1' when (stored_protocol = x"11") else '0'; - is_icmp_x <= '1' when (stored_protocol = x"01") else '0'; - is_dhcp_x <= '1' when (stored_dst_port = x"0044") else '0'; - is_sctrl_x <= '1' when (stored_dst_port = x"6590") else '0'; + is_my_mac_x <= '1' when (stored_dst_mac = MY_MAC_IN) else '0'; + is_broadcast_x <= '1' when (stored_dst_mac = x"ffffffffffff") else '0'; + is_arp_x <= '1' when (stored_ethertype = x"0806") else '0'; + is_ipv4_x <= '1' when (stored_ethertype = x"0800") else '0'; + is_version_x <= '1' when (stored_version = x"45") else '0'; + is_udp_x <= '1' when (stored_protocol = x"11") else '0'; + is_icmp_x <= '1' when (stored_protocol = x"01") else '0'; + is_dhcp_x <= '1' when (stored_dst_port = x"0044") else '0'; + is_sctrl_x <= '1' when (stored_dst_port = x"6590") else '0'; + is_my_ip_x <= '1' when (stored_dst_ip = MY_IP_IN) else '0'; + is_broadcast_ip_x <= '1' when (stored_dst_ip = x"ffffffff") else '0'; + is_empty_payload_x <= '1' when (rx_bytes_ctr = 0) else '0'; -- syncing signals PROC_SYNC_SIGNALS: process( CLK ) @@ -439,57 +472,118 @@ begin -- Three is fine, two fails - data arrives late. -- Happens when main control tries to read a frame directly when it was written. + -- OPTIMIZE: two 512x72 instead of three. + -- to be removed: dst port + -- to be reduced: dst mac -> 2bit (is_my_mac_x, is_broadcast_x) + -- dst ip -> 2bit (is_my_ip_x, is_ip_broadcast_x) + -- to be used: proto sel -> 8bit + +-------------------------------------------------------------------------------------------- +-------------------------------------------------------------------------------------------- -- FIFO for header information - THE_FIRST_FIFO: entity work.fifo_512x72_s + THE_FIFO_ONE: entity work.fifo_512x72_s port map( Data(47 downto 0) => stored_src_mac, Data(63 downto 48) => stored_src_port, - Data(71 downto 64) => std_logic_vector(rx_bytes_ctr(7 downto 0)), - Clock => CLK, - WrEn => fifo_hd_wr_q, - RdEn => FR_GET_FRAME_IN, - Reset => RESET, - Q(47 downto 0) => fr_src_mac, - Q(63 downto 48) => fr_src_udp, - Q(71 downto 64) => fr_frame_size(7 downto 0), - Empty => open, -- BUG - Full => open -- BUG - ); - - -- FIFO for header information - THE_SECOND_FIFO: entity work.fifo_512x72_s - port map( - Data(47 downto 0) => stored_dst_mac, - Data(63 downto 48) => stored_dst_port, - Data(71 downto 64) => protocol_select, + Data(71 downto 64) => (others => '0'), Clock => CLK, WrEn => fifo_hd_wr_q, RdEn => FR_GET_FRAME_IN, Reset => RESET, - Q(47 downto 0) => fr_dest_mac, - Q(63 downto 48) => fr_dest_udp, - Q(71 downto 64) => fr_ps, + Q => fifo_one_q, Empty => open, -- BUG Full => open -- BUG ); -- FIFO for header information - THE_THIRD_FIFO: entity work.fifo_512x72_s + THE_FIFO_TWO: entity work.fifo_512x72_s port map( Data(31 downto 0) => stored_src_ip, - Data(63 downto 32) => stored_dst_ip, - Data(71 downto 64) => std_logic_vector(rx_bytes_ctr(15 downto 8)), + Data(47 downto 32) => std_logic_vector(rx_bytes_ctr), + Data(55 downto 48) => protocol_select, + Data(56) => is_my_mac_x, + Data(57) => is_broadcast_x, + Data(58) => is_my_ip_x, + Data(59) => is_broadcast_ip_x, + Data(60) => is_empty_payload_x, + Data(61) => '0', -- reserved + Data(62) => '0', -- reserved + Data(63) => '0', -- reserved + Data(71 downto 64) => (others => '0'), Clock => CLK, WrEn => fifo_hd_wr_q, RdEn => FR_GET_FRAME_IN, Reset => RESET, - Q(31 downto 0) => fr_src_ip, - Q(63 downto 32) => fr_dest_ip, - Q(71 downto 64) => fr_frame_size(15 downto 8), + Q => fifo_two_q, Empty => open, -- BUG Full => open -- BUG ); + -- decode fifo_one_q and fifo_two_q + fr_dest_mac <= (others => '0'); + fr_src_mac <= fifo_one_q(47 downto 0); + fr_dest_ip <= (others => '0'); + fr_src_ip <= fifo_two_q(31 downto 0); + fr_dest_udp <= (others => '0'); + fr_src_udp <= fifo_one_q(63 downto 48); + fr_frame_size <= fifo_two_q(47 downto 32); + fr_ps <= fifo_two_q(55 downto 48); + fr_info <= fifo_two_q(63 downto 56); + + +-------------------------------------------------------------------------------------------- +-------------------------------------------------------------------------------------------- +-- -- FIFO for header information +-- THE_FIRST_FIFO: entity work.fifo_512x72_s +-- port map( +-- Data(47 downto 0) => stored_src_mac, +-- Data(63 downto 48) => stored_src_port, +-- Data(71 downto 64) => std_logic_vector(rx_bytes_ctr(7 downto 0)), +-- Clock => CLK, +-- WrEn => fifo_hd_wr_q, +-- RdEn => FR_GET_FRAME_IN, +-- Reset => RESET, +-- Q(47 downto 0) => fr_src_mac, +-- Q(63 downto 48) => fr_src_udp, +-- Q(71 downto 64) => fr_frame_size(7 downto 0), +-- Empty => open, -- BUG +-- Full => open -- BUG +-- ); +-- +-- -- FIFO for header information +-- THE_SECOND_FIFO: entity work.fifo_512x72_s +-- port map( +-- Data(47 downto 0) => stored_dst_mac, +-- Data(63 downto 48) => stored_dst_port, +-- Data(71 downto 64) => protocol_select, +-- Clock => CLK, +-- WrEn => fifo_hd_wr_q, +-- RdEn => FR_GET_FRAME_IN, +-- Reset => RESET, +-- Q(47 downto 0) => fr_dest_mac, +-- Q(63 downto 48) => fr_dest_udp, +-- Q(71 downto 64) => fr_ps, +-- Empty => open, -- BUG +-- Full => open -- BUG +-- ); +-- +-- -- FIFO for header information +-- THE_THIRD_FIFO: entity work.fifo_512x72_s +-- port map( +-- Data(31 downto 0) => stored_src_ip, +-- Data(63 downto 32) => stored_dst_ip, +-- Data(71 downto 64) => std_logic_vector(rx_bytes_ctr(15 downto 8)), +-- Clock => CLK, +-- WrEn => fifo_hd_wr_q, +-- RdEn => FR_GET_FRAME_IN, +-- Reset => RESET, +-- Q(31 downto 0) => fr_src_ip, +-- Q(63 downto 32) => fr_dest_ip, +-- Q(71 downto 64) => fr_frame_size(15 downto 8), +-- Empty => open, -- BUG +-- Full => open -- BUG +-- ); + PROC_OUT_SYNC: process( CLK ) begin if( rising_edge(CLK) ) then @@ -502,6 +596,7 @@ begin FR_FRAME_SIZE_OUT <= fr_frame_size; FR_Q_OUT <= fr_q; FR_PS_OUT <= fr_ps(c_MAX_PROTOCOLS - 1 downto 0); + FR_INFO_OUT <= fr_info; end if; end process PROC_OUT_SYNC; diff --git a/gbe_trb/base/gbe_logic_wrapper.vhd b/gbe_trb/base/gbe_logic_wrapper.vhd index 5fa5cc8..783ad37 100644 --- a/gbe_trb/base/gbe_logic_wrapper.vhd +++ b/gbe_trb/base/gbe_logic_wrapper.vhd @@ -147,12 +147,15 @@ architecture gbe_logic_wrapper_arch of gbe_logic_wrapper is signal mc_ident : std_logic_vector(15 downto 0); signal link_ok : std_logic; - signal dhcp_done : std_logic; + signal dhcp_done : std_logic; + signal my_ip : std_logic_vector(31 downto 0); signal make_reset : std_logic; signal frame_pause : std_logic_vector(31 downto 0); - signal fr_ps_int : std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0); + signal fr_ps : std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0); + signal fr_frame_info : std_logic_vector(7 downto 0); + signal rc_frame_info : std_logic_vector(7 downto 0); signal debug_main : std_logic_vector(63 downto 0); signal debug_fr : std_logic_vector(31 downto 0); @@ -166,12 +169,12 @@ architecture gbe_logic_wrapper_arch of gbe_logic_wrapper is -- DEBUG_OUT(31 downto 28) <= debug_fr(31 downto 28); -- frame receiver state -- DEBUG_OUT(27 downto 24) <= debug_rc(3 downto 0); -- receive control state -- DEBUG_OUT(23 downto 20) <= debug_main(23 downto 20); -- redirect state --- DEBUG_OUT(19 downto 16) <= fr_ps_int(3 downto 0); --debug_main(27 downto 24); -- link state +-- DEBUG_OUT(19 downto 16) <= fr_ps(3 downto 0); --debug_main(27 downto 24); -- link state -- DEBUG_OUT(15) <= rc_loading_done; -- DEBUG_OUT(14) <= rc_frame_ready; --- DEBUG_OUT(13) <= fr_ps_int(4); --rc_frame_proto(4); -- ICMP --- DEBUG_OUT(12) <= fr_ps_int(1); --rc_frame_proto(1); -- DHCP --- DEBUG_OUT(11) <= fr_ps_int(0); --rc_frame_proto(0); -- ARP +-- DEBUG_OUT(13) <= fr_ps(4); --rc_frame_proto(4); -- ICMP +-- DEBUG_OUT(12) <= fr_ps(1); --rc_frame_proto(1); -- DHCP +-- DEBUG_OUT(11) <= fr_ps(0); --rc_frame_proto(0); -- ARP -- DEBUG_OUT(10) <= fr_get_frame; -- DEBUG_OUT(9) <= fr_frame_valid; -- DEBUG_OUT(8) <= fr_rd_en; @@ -184,7 +187,8 @@ architecture gbe_logic_wrapper_arch of gbe_logic_wrapper is --------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------- - DHCP_DONE_OUT <= dhcp_done; + DHCP_DONE_OUT <= dhcp_done; + MY_IP_OUT <= my_ip; THE_GBE_MAIN_CONTROL: entity work.gbe_main_control generic map( @@ -201,7 +205,7 @@ architecture gbe_logic_wrapper_arch of gbe_logic_wrapper is RESET => RESET, MC_LINK_OK_OUT => link_ok, MC_DHCP_DONE_OUT => dhcp_done, - MY_IP_OUT => MY_IP_OUT, + MY_IP_OUT => my_ip, --MY_IP_OUT, MC_MY_MAC_IN => MY_MAC_IN, MY_TRBNET_ADDRESS_IN => MY_TRBNET_ADDRESS_IN, ISSUE_REBOOT_OUT => open, --ISSUE_REBOOT_OUT, @@ -211,7 +215,8 @@ architecture gbe_logic_wrapper_arch of gbe_logic_wrapper is RC_DATA_IN => rc_q, RC_RD_EN_OUT => rc_rd_en, RC_FRAME_SIZE_IN => rc_frame_size, - RC_FRAME_PROTO_IN => rc_frame_proto, + RC_FRAME_PROTO_IN => rc_frame_proto, + RC_FRAME_INFO_IN => rc_frame_info, RC_SRC_MAC_ADDRESS_IN => rc_src_mac, RC_DEST_MAC_ADDRESS_IN => rc_dest_mac, RC_SRC_IP_ADDRESS_IN => rc_src_ip, @@ -355,7 +360,8 @@ architecture gbe_logic_wrapper_arch of gbe_logic_wrapper is FR_FRAME_VALID_IN => fr_frame_valid, FR_GET_FRAME_OUT => fr_get_frame, FR_FRAME_SIZE_IN => fr_frame_size, - FR_PS_IN => fr_ps_int, + FR_PS_IN => fr_ps, + FR_INFO_IN => fr_frame_info, FR_SRC_MAC_ADDRESS_IN => fr_src_mac, FR_DEST_MAC_ADDRESS_IN => fr_dest_mac, FR_SRC_IP_ADDRESS_IN => fr_src_ip, @@ -374,7 +380,8 @@ architecture gbe_logic_wrapper_arch of gbe_logic_wrapper is RC_SRC_IP_ADDRESS_OUT => rc_src_ip, RC_DEST_IP_ADDRESS_OUT => rc_dest_ip, RC_SRC_UDP_PORT_OUT => rc_src_udp, - RC_DEST_UDP_PORT_OUT => rc_dest_udp, + RC_DEST_UDP_PORT_OUT => rc_dest_udp, + RC_INFO_OUT => rc_frame_info, -- statistics FRAMES_RECEIVED_OUT => rc_frames_rec_ctr, BYTES_RECEIVED_OUT => rc_bytes_rec, @@ -387,7 +394,8 @@ architecture gbe_logic_wrapper_arch of gbe_logic_wrapper is RESET => RESET, LINK_OK_IN => LINK_ACTIVE_IN, ALLOW_RX_IN => CFG_ALLOW_RX_IN, - MY_MAC_IN => MY_MAC_IN, + MY_MAC_IN => MY_MAC_IN, + MY_IP_IN => my_ip, -- MY_TRBNET_ADDRESS_IN => MY_TRBNET_ADDRESS_IN, ISSUE_REBOOT_OUT => ISSUE_REBOOT_OUT, @@ -402,7 +410,8 @@ architecture gbe_logic_wrapper_arch of gbe_logic_wrapper is FR_FRAME_VALID_OUT => fr_frame_valid, FR_GET_FRAME_IN => fr_get_frame, FR_FRAME_SIZE_OUT => fr_frame_size, - FR_PS_OUT => fr_ps_int, + FR_PS_OUT => fr_ps, + FR_INFO_OUT => fr_frame_info, -- FR_SRC_MAC_ADDRESS_OUT => fr_src_mac, FR_DEST_MAC_ADDRESS_OUT => fr_dest_mac, diff --git a/gbe_trb/base/gbe_main_control.vhd b/gbe_trb/base/gbe_main_control.vhd index bc61143..8e7bc1d 100644 --- a/gbe_trb/base/gbe_main_control.vhd +++ b/gbe_trb/base/gbe_main_control.vhd @@ -34,6 +34,7 @@ entity gbe_main_control is RC_RD_EN_OUT : out std_logic; RC_FRAME_SIZE_IN : in std_logic_vector(15 downto 0); RC_FRAME_PROTO_IN : in std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0); + RC_FRAME_INFO_IN : in std_logic_vector(7 downto 0); -- RC_SRC_MAC_ADDRESS_IN : in std_logic_vector(47 downto 0); RC_DEST_MAC_ADDRESS_IN : in std_logic_vector(47 downto 0); @@ -265,6 +266,7 @@ begin when DROP => redirect_state <= x"3"; + -- BUG: fails with empty payload! if( loaded_bytes_ctr = unsigned(RC_FRAME_SIZE_IN) - 1 ) then -- frame has been loaded REDIRECT_NS <= WAIT_ONE; @@ -283,6 +285,7 @@ begin when LOAD => redirect_state <= x"5"; + -- BUG: fails with empty payload! if( loaded_bytes_ctr = unsigned(RC_FRAME_SIZE_IN) - 1 ) then -- all bytes loaded REDIRECT_NS <= WAIT_ONE; @@ -414,6 +417,7 @@ begin PS_PROTO_SELECT_IN => RC_FRAME_PROTO_IN, PS_BUSY_OUT => ps_busy, PS_FRAME_SIZE_IN => RC_FRAME_SIZE_IN, + PS_FRAME_INFO_IN => RC_FRAME_INFO_IN, PS_RESPONSE_READY_OUT => ps_response_ready, PS_SRC_MAC_ADDRESS_IN => RC_SRC_MAC_ADDRESS_IN, PS_DEST_MAC_ADDRESS_IN => RC_DEST_MAC_ADDRESS_IN, diff --git a/gbe_trb/base/gbe_protocol_selector.vhd b/gbe_trb/base/gbe_protocol_selector.vhd index 95043c1..27fc4f8 100644 --- a/gbe_trb/base/gbe_protocol_selector.vhd +++ b/gbe_trb/base/gbe_protocol_selector.vhd @@ -22,7 +22,8 @@ entity gbe_protocol_selector is PS_WR_EN_IN : in std_logic; PS_PROTO_SELECT_IN : in std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0); PS_BUSY_OUT : out std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0); - PS_FRAME_SIZE_IN : in std_logic_vector(15 downto 0); + PS_FRAME_SIZE_IN : in std_logic_vector(15 downto 0); + PS_FRAME_INFO_IN : in std_logic_vector(7 downto 0); PS_RESPONSE_READY_OUT : out std_logic; PS_SRC_MAC_ADDRESS_IN : in std_logic_vector(47 downto 0); PS_DEST_MAC_ADDRESS_IN : in std_logic_vector(47 downto 0); @@ -202,7 +203,8 @@ begin PS_SRC_IP_ADDRESS_IN => PS_SRC_IP_ADDRESS_IN, PS_DEST_IP_ADDRESS_IN => PS_DEST_IP_ADDRESS_IN, PS_SRC_UDP_PORT_IN => PS_SRC_UDP_PORT_IN, - PS_DEST_UDP_PORT_IN => PS_DEST_UDP_PORT_IN, + PS_DEST_UDP_PORT_IN => PS_DEST_UDP_PORT_IN, + PS_FRAME_INFO_IN => PS_FRAME_INFO_IN, TC_RD_EN_IN => TC_RD_EN_IN, TC_DATA_OUT => tc_data(2 * 9 - 1 downto 1 * 9), TC_FRAME_SIZE_OUT => tc_size(2 * 16 - 1 downto 1 * 16), diff --git a/gbe_trb/base/gbe_receive_control.vhd b/gbe_trb/base/gbe_receive_control.vhd index 1282b74..04b86a5 100644 --- a/gbe_trb/base/gbe_receive_control.vhd +++ b/gbe_trb/base/gbe_receive_control.vhd @@ -7,6 +7,9 @@ library work; use work.trb_net_std.all; use work.gbe_protocols.all; +-- BUG: use (not FIFO_EMPTY) from gbe_frame_receiver to indicate +-- frames in queue. + entity gbe_receive_control is port ( CLK : in std_logic; -- system clock @@ -17,7 +20,8 @@ entity gbe_receive_control is FR_FRAME_VALID_IN : in std_logic; FR_GET_FRAME_OUT : out std_logic; FR_FRAME_SIZE_IN : in std_logic_vector(15 downto 0); - FR_PS_IN : in std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0); + FR_PS_IN : in std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0); + FR_INFO_IN : in std_logic_vector(7 downto 0); FR_SRC_MAC_ADDRESS_IN : in std_logic_vector(47 downto 0); FR_DEST_MAC_ADDRESS_IN : in std_logic_vector(47 downto 0); FR_SRC_IP_ADDRESS_IN : in std_logic_vector(31 downto 0); @@ -37,6 +41,7 @@ entity gbe_receive_control is RC_DEST_IP_ADDRESS_OUT : out std_logic_vector(31 downto 0); RC_SRC_UDP_PORT_OUT : out std_logic_vector(15 downto 0); RC_DEST_UDP_PORT_OUT : out std_logic_vector(15 downto 0); + RC_INFO_OUT : out std_logic_vector(7 downto 0); -- statistics FRAMES_RECEIVED_OUT : out std_logic_vector(31 downto 0); BYTES_RECEIVED_OUT : out std_logic_vector(31 downto 0); @@ -58,15 +63,12 @@ architecture gbe_receive_control_arch of gbe_receive_control is signal bytes_rec_ctr : unsigned(31 downto 0); signal state : std_logic_vector(3 downto 0); - signal proto_code : std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0); - signal reset_prioritizer : std_logic; - signal saved_proto : std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0); begin DEBUG_OUT(31 downto 4) <= (others => '0'); DEBUG_OUT(3 downto 0) <= state; - + FR_RD_EN_OUT <= RC_RD_EN_IN; RC_Q_OUT <= RC_DATA_IN; RC_FRAME_SIZE_OUT <= FR_FRAME_SIZE_IN; @@ -76,6 +78,7 @@ begin RC_DEST_IP_ADDRESS_OUT <= FR_DEST_IP_ADDRESS_IN; RC_SRC_UDP_PORT_OUT <= FR_SRC_UDP_PORT_IN; RC_DEST_UDP_PORT_OUT <= FR_DEST_UDP_PORT_IN; + RC_INFO_OUT <= FR_INFO_IN; RC_FRAME_PROTO_OUT <= FR_PS_IN when (load_current_state /= IDLE) else (others => '0'); LOAD_MACHINE_PROC: process( CLK, RESET ) @@ -169,17 +172,4 @@ begin end if; end process BYTES_REC_CTR_PROC; - SAVED_PROTO_PROC : process( CLK ) - begin - if( rising_edge(CLK) ) then - if( load_current_state = READY ) then - if( and_all(proto_code) = '0' ) then - saved_proto <= proto_code; - else - saved_proto <= (others => '0'); - end if; - end if; - end if; - end process SAVED_PROTO_PROC; - end gbe_receive_control_arch; diff --git a/gbe_trb/protocols/gbe_response_constructor_DHCP.vhd b/gbe_trb/protocols/gbe_response_constructor_DHCP.vhd index e0ac074..526696f 100644 --- a/gbe_trb/protocols/gbe_response_constructor_DHCP.vhd +++ b/gbe_trb/protocols/gbe_response_constructor_DHCP.vhd @@ -24,6 +24,7 @@ entity gbe_response_constructor_DHCP is PS_DEST_IP_ADDRESS_IN : in std_logic_vector(31 downto 0); PS_SRC_UDP_PORT_IN : in std_logic_vector(15 downto 0); PS_DEST_UDP_PORT_IN : in std_logic_vector(15 downto 0); + PS_FRAME_INFO_IN : in std_logic_vector(7 downto 0); -- TC_RD_EN_IN : in std_logic; TC_DATA_OUT : out std_logic_vector(8 downto 0); @@ -99,8 +100,8 @@ architecture gbe_response_constructor_DHCP_arch of gbe_response_constructor_DHCP -- signal wait_value : unsigned(31 downto 0); - signal long_delay_bit : integer range 0 to 31 := 29; - signal short_delay_bit : integer range 0 to 31 := 12; + signal long_delay_bit : integer range 0 to 31 := 29; + signal short_delay_bit : integer range 0 to 31 := 3; --12 begin @@ -166,11 +167,6 @@ begin end if; end process PROC_MAIN_FSM; - -- wait time between link active and start of DHCP process --- wait_value <= x"2000_0000"; --- wait_value <= x"0000_2000"; - --- PROC_MAIN_TRANSITIONS : process( MAIN_CS, DHCP_START_IN, CONSTRUCT_CS, wait_ctr, RECEIVE_CS, PS_DATA_IN, wait_value ) PROC_MAIN_TRANSITIONS : process( MAIN_CS, DHCP_START_IN, CONSTRUCT_CS, wait_ctr, RECEIVE_CS, PS_DATA_IN ) begin main_state <= x"0"; @@ -187,7 +183,6 @@ begin when DELAY => main_state <= x"2"; --- if( wait_ctr = wait_value ) then if( wait_ctr(short_delay_bit) = '1' ) then MAIN_NS <= SENDING_DISCOVER; else @@ -207,7 +202,6 @@ begin -- BUG: fails on empty payload if ( (RECEIVE_CS = SAVE_VALUES) and (PS_DATA_IN(8) = '1') ) then MAIN_NS <= SENDING_REQUEST; --- elsif( wait_ctr = x"2000_0000" ) then elsif( wait_ctr(long_delay_bit) = '1' ) then MAIN_NS <= BOOTING; else @@ -227,7 +221,6 @@ begin -- BUG: fails on empty payload if ( (RECEIVE_CS = SAVE_VALUES) and (PS_DATA_IN(8) = '1') ) then MAIN_NS <= ESTABLISHED; --- elsif( wait_ctr = x"2000_0000" ) then elsif( wait_ctr(long_delay_bit) = '1' ) then MAIN_NS <= BOOTING; else @@ -242,7 +235,7 @@ begin MAIN_NS <= ESTABLISHED; end if; - when others => + when others => MAIN_NS <= BOOTING; end case; @@ -276,7 +269,7 @@ begin end if; end process PROC_RECEIVE_FSM; - PROC_RECEIVE_TRANSITIONS: process( RECEIVE_CS, MAIN_CS, bootp_hdr, saved_dhcp_type, saved_transaction_id, + PROC_RECEIVE_TRANSITIONS: process( RECEIVE_CS, MAIN_CS, bootp_hdr, saved_dhcp_type, saved_transaction_id, PS_FRAME_INFO_IN, PS_DATA_IN, PS_DEST_MAC_ADDRESS_IN, MY_MAC_IN, PS_ACTIVATE_IN, PS_WR_EN_IN, save_ctr ) begin recv_state <= x"0"; @@ -287,7 +280,8 @@ begin recv_state <= x"1"; if( (PS_ACTIVATE_IN = '1') and (PS_WR_EN_IN = '1') ) then if( (MAIN_CS = WAITING_FOR_OFFER) or (MAIN_CS = WAITING_FOR_ACK) ) then -- ready to receive dhcp frame - if( PS_DEST_MAC_ADDRESS_IN = MY_MAC_IN ) then -- check if i'm the addressee (discards broadcasts also) +-- if( PS_DEST_MAC_ADDRESS_IN = MY_MAC_IN ) then -- check if i'm the addressee (discards broadcasts also) + if( PS_FRAME_INFO_IN(0) = '1' ) then -- check if i'm the addressee (discards broadcasts also) RECEIVE_NS <= SAVE_VALUES; else RECEIVE_NS <= DISCARD; -- discard if the frame is not for me @@ -330,7 +324,7 @@ begin recv_state <= x"4"; RECEIVE_NS <= IDLE; - when others => + when others => RECEIVE_NS <= IDLE; end case; @@ -441,7 +435,7 @@ begin when 241 => saved_dhcp_type(23 downto 16) <= PS_DATA_IN(7 downto 0); - when others => + when others => null; end case; @@ -564,7 +558,7 @@ begin cons_state <= x"c"; CONSTRUCT_NS <= IDLE; - when others => + when others => CONSTRUCT_NS <= IDLE; end case; diff --git a/gbe_trb/protocols/gbe_response_constructor_SCTRL.vhd b/gbe_trb/protocols/gbe_response_constructor_SCTRL.vhd index 9ff54bf..6608027 100644 --- a/gbe_trb/protocols/gbe_response_constructor_SCTRL.vhd +++ b/gbe_trb/protocols/gbe_response_constructor_SCTRL.vhd @@ -132,7 +132,7 @@ architecture gbe_response_constructor_SCTRL_arch of gbe_response_constructor_SCT signal saved_dst_mac : std_logic_vector(47 downto 0); signal store_mac_x : std_logic; signal store_mac : std_logic; - + attribute syn_preserve : boolean; attribute syn_keep : boolean; attribute syn_keep of rx_fifo_wr, rx_fifo_rd, gsc_init_dataready, tx_fifo_wr, tx_fifo_rd, gsc_reply_read, state : signal is true; @@ -155,7 +155,7 @@ begin DEBUG_OUT(11) <= GSC_REPLY_DATAREADY_IN; DEBUG_OUT(10 downto 8) <= GSC_REPLY_PACKET_NUM_IN; DEBUG_OUT(7 downto 0) <= GSC_REPLY_DATA_IN(7 downto 0); - + MAKE_RESET_OUT <= make_reset; -- TEST @@ -169,7 +169,7 @@ begin end if; end if; end process PROC_STORE_MAC; - + -- stores incoming TRBnet requests THE_RECEIVE_FIFO: entity work.fifo_2kx9x18_wcnt port map( @@ -509,7 +509,7 @@ begin else DISSECT_NS <= DELAY; end if; - + when WAIT_FOR_LOAD => state <= x"7"; if( PS_SELECTED_IN = '1' ) then @@ -549,7 +549,7 @@ begin -- delay_done <= std_logic(delay_ctr(13)); delay_done <= std_logic(delay_ctr(4)); - + -- reset request packet detection RESET_DETECTED_PROC: process( CLK ) begin -- 2.43.0