From 69e0cc5f142e6a914d7a5cff1529932547e15fba Mon Sep 17 00:00:00 2001 From: Michael Boehmer Date: Thu, 3 Nov 2022 19:52:08 +0100 Subject: [PATCH] DHCP works in simulation but fails in hardware --- gbe_trb/base/gbe_frame_constr.vhd | 13 +- gbe_trb/base/gbe_frame_receiver.vhd | 36 +- gbe_trb/base/gbe_logic_wrapper.vhd | 77 +- gbe_trb/base/gbe_main_control.vhd | 1096 +++++++------ gbe_trb/base/gbe_protocol_selector.vhd | 37 +- gbe_trb/base/gbe_receive_control.vhd | 8 +- gbe_trb/base/gbe_transmit_control.vhd | 39 +- gbe_trb/base/gbe_wrapper_fifo.vhd | 10 +- .../gbe_response_constructor_ARP.vhd | 40 +- .../gbe_response_constructor_DHCP.vhd | 1363 +++++++++-------- .../gbe_response_constructor_Forward.vhd | 23 +- .../gbe_response_constructor_Ping.vhd | 34 +- .../gbe_response_constructor_SCTRL.vhd | 74 +- 13 files changed, 1391 insertions(+), 1459 deletions(-) diff --git a/gbe_trb/base/gbe_frame_constr.vhd b/gbe_trb/base/gbe_frame_constr.vhd index e2a1414..80fd234 100644 --- a/gbe_trb/base/gbe_frame_constr.vhd +++ b/gbe_trb/base/gbe_frame_constr.vhd @@ -5,14 +5,13 @@ use IEEE.std_logic_UNSIGNED.ALL; library work; use work.trb_net_std.all; -use work.trb_net_components.all; entity gbe_frame_constr is - port( + port( -- ports for user logic RESET : in std_logic; CLK : in std_logic; -- 125MHz clock - LINK_OK_IN : in std_logic; + LINK_OK_IN : in std_logic; -- frame stuff WR_EN_IN : in std_logic; DATA_IN : in std_logic_vector(7 downto 0); @@ -214,8 +213,8 @@ begin end process THE_CONSTRUCT_PROC; --find next state of construct machine -constructMachine: process( constructCurrentState, delay_ctr, FRAME_DELAY_IN, START_OF_DATA_IN, - END_OF_DATA_IN, headers_int_counter, put_udp_headers, CUR_MAX, +constructMachine: process( constructCurrentState, delay_ctr, FRAME_DELAY_IN, START_OF_DATA_IN, + END_OF_DATA_IN, headers_int_counter, put_udp_headers, CUR_MAX, FRAME_TYPE_IN, DEST_UDP_PORT_IN) begin constructNextState <= constructCurrentState; @@ -230,7 +229,7 @@ begin when SRC_MAC_ADDR => constructNextState <= FRAME_TYPE_S; when FRAME_TYPE_S => - if( FRAME_TYPE_IN = x"0008" ) then + if( FRAME_TYPE_IN = x"0008" ) then constructNextState <= VERSION; else -- otherwise transmit data as pure ethernet frame constructNextState <= SAVE_DATA; @@ -279,7 +278,7 @@ begin else constructNextState <= DELAY; end if; - + when others => constructNextState <= IDLE; end case; diff --git a/gbe_trb/base/gbe_frame_receiver.vhd b/gbe_trb/base/gbe_frame_receiver.vhd index 52b1e9a..1f07d0f 100644 --- a/gbe_trb/base/gbe_frame_receiver.vhd +++ b/gbe_trb/base/gbe_frame_receiver.vhd @@ -60,8 +60,8 @@ entity gbe_frame_receiver is ); end gbe_frame_receiver; --- This entity receives frames from the MAC. The MAC will send the frames once they are received --- from SGMII core. Start of frame is marked by 'new_frame' signal. The incoming frame will be +-- This entity receives frames from the MAC. The MAC will send the frames once they are received +-- from SGMII core. Start of frame is marked by 'new_frame' signal. The incoming frame will be -- reviewed, and checked if it should be forwarded to the next level. -- First check is MAC address: only broadcast frames and frames with the board's MAC address are accepted. -- VLAN tagged frames are handled, but will be checked later. @@ -90,8 +90,6 @@ architecture gbe_frame_receiver_arch of gbe_frame_receiver is signal rec_fifo_empty : std_logic; signal rec_fifo_full : std_logic; --- signal sizes_fifo_full : std_logic; --- signal sizes_fifo_empty : std_logic; signal remove_ctr : unsigned(7 downto 0); signal new_frame : std_logic; @@ -133,16 +131,18 @@ architecture gbe_frame_receiver_arch of gbe_frame_receiver is signal oob_select_x : std_logic; signal oob_select : std_logic; - + signal proto_select : std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0); signal set_proto_x : std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0); + signal fucking_vhdl : std_logic_vector(1 downto 0); + begin -- Debug lines DEBUG_OUT(31 downto 26) <= (others => '0'); - + DEBUG_OUT(15) <= frame_valid_q; DEBUG_OUT(14) <= fifo_wr_en; DEBUG_OUT(13) <= frame_type_valid; @@ -181,7 +181,7 @@ begin end process PROC_FILTER_FSM; PROC_FILTER_TRANSITIONS : process( filter_current_state, saved_frame_type, LINK_OK_IN, saved_proto, MY_MAC_IN, - saved_dest_mac, remove_ctr, new_frame, MAC_RX_EOF_IN, frame_type_valid, ALLOW_RX_IN ) + saved_dest_mac, remove_ctr, new_frame, MAC_RX_EOF_IN, frame_type_valid, ALLOW_RX_IN) begin set_proto_x <= (others => '0'); oob_select_x <= '0'; @@ -222,7 +222,7 @@ begin when REMOVE_TYPE => state <= x"5"; if( remove_ctr = x"0b" ) then - case saved_frame_type is + case saved_frame_type is when x"0800" => -- IPv4 frame, to be investigated filter_next_state <= REMOVE_IP; @@ -248,7 +248,7 @@ begin -- UDP, to be investigated filter_next_state <= REMOVE_UDP; when x"01" => - -- ICMP, to be stored + -- ICMP, to be stored filter_next_state <= DELAY; set_proto_x(4) <= '1'; when others => @@ -466,7 +466,7 @@ begin end if; end process PROC_SAVED_DEST_UDP; - PROC_FRAME_TYPE_VALID: process( CLK, RESET ) + PROC_FRAME_TYPE_VALID: process( CLK, RESET ) begin if ( RESET = '1' ) then frame_type_valid <= '0'; @@ -497,10 +497,10 @@ begin PROC_KILLER_PING: process( CLK ) begin if( rising_edge(CLK) ) then - if( (filter_current_state = SAVE_FRAME) and - (saved_proto = x"01") and + if( (filter_current_state = SAVE_FRAME) and + (saved_proto = x"01") and (saved_frame_type = x"0800") and - (rx_bytes_ctr = x"001A") and + (rx_bytes_ctr = x"001A") and (rx_data(7 downto 0) = MY_TRBNET_ADDRESS_IN(7 downto 0)) and (MAC_RXD_IN = MY_TRBNET_ADDRESS_IN(15 downto 8)) ) then ISSUE_REBOOT_OUT <= '1'; @@ -510,14 +510,14 @@ begin end if; end process PROC_KILLER_PING; - -- BROKEN!!! + -- secret register PROC_SECRET_FRAME: process( CLK ) begin if( rising_edge(CLK) ) then - if( (oob_select = '1') and - (saved_proto = x"11") and + if( (oob_select = '1') and + (saved_proto = x"11") and (saved_frame_type = x"0800") and - (saved_dest_udp = x"d903") and + (saved_dest_udp = x"d903") and (saved_src_udp = x"2b67") ) then oob_write <= '1'; else @@ -600,7 +600,7 @@ begin Q(47 downto 0) => fr_dest_mac, Q(63 downto 48) => fr_dest_udp, Q(69 downto 64) => fr_ps, - Q(71 downto 70) => open, + Q(71 downto 70) => fucking_vhdl, --open, Empty => open, Full => open ); diff --git a/gbe_trb/base/gbe_logic_wrapper.vhd b/gbe_trb/base/gbe_logic_wrapper.vhd index b39514c..5a28c0c 100644 --- a/gbe_trb/base/gbe_logic_wrapper.vhd +++ b/gbe_trb/base/gbe_logic_wrapper.vhd @@ -23,8 +23,7 @@ entity gbe_logic_wrapper is MY_TRBNET_ADDRESS_IN : in std_logic_vector(15 downto 0); ISSUE_REBOOT_OUT : out std_logic; -- connection to MAC (link handling) - MAC_READY_CONF_IN : in std_logic; - MAC_AN_READY_IN : in std_logic; + LINK_ACTIVE_IN : in std_logic; -- TSMAC RX stuff MAC_RX_DATA_IN : in std_logic_vector(7 downto 0); MAC_RX_WRITE_IN : in std_logic; @@ -148,12 +147,9 @@ architecture gbe_logic_wrapper_arch of gbe_logic_wrapper is signal ft_tx_empty : std_logic; signal ft_start_of_packet : std_logic; --- signal fr_ip_proto : std_logic_vector(7 downto 0); signal mc_ip_proto : std_logic_vector(7 downto 0); signal mc_ident : std_logic_vector(15 downto 0); - - signal dbg_select_gen : std_logic_vector(2 * c_MAX_PROTOCOLS * 32 - 1 downto 0); - + signal link_ok : std_logic; signal dhcp_done : std_logic; @@ -169,32 +165,35 @@ architecture gbe_logic_wrapper_arch of gbe_logic_wrapper is signal fr_ps_int : std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0); - signal dbg_main : std_logic_vector(63 downto 0); + signal debug_main : std_logic_vector(63 downto 0); begin --------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------- --- DEBUG_OUT(31 downto 0) <= (others => '0'); - -- TX - DEBUG_OUT(31 downto 28) <= dbg_main(7 downto 4); - DEBUG_OUT(27) <= '0'; - DEBUG_OUT(26) <= mc_transmit_done; - DEBUG_OUT(25) <= mc_transmit_ctrl; - DEBUG_OUT(24) <= mc_wr_en; - DEBUG_OUT(23 downto 20) <= dbg_main(15 downto 12); - DEBUG_OUT(19 downto 16) <= dbg_main(11 downto 8); --- DEBUG_OUT(23 downto 16) <= mc_data(7 downto 0); - -- RX - DEBUG_OUT(15) <= rc_loading_done; - DEBUG_OUT(14) <= rc_frame_ready; - DEBUG_OUT(13) <= rc_frame_proto(4); -- ICMP - DEBUG_OUT(12) <= rc_frame_proto(1); -- DHCP - DEBUG_OUT(11) <= rc_frame_proto(0); -- ARP - DEBUG_OUT(10) <= fr_get_frame; - DEBUG_OUT(9) <= fr_frame_valid; - DEBUG_OUT(8) <= fr_rd_en; - DEBUG_OUT(7 downto 0) <= rc_q(7 downto 0); +---- DEBUG_OUT(31 downto 0) <= (others => '0'); +-- -- TX +-- DEBUG_OUT(31 downto 28) <= dbg_main(7 downto 4); +-- DEBUG_OUT(27) <= '0'; +-- DEBUG_OUT(26) <= mc_transmit_done; +-- DEBUG_OUT(25) <= mc_transmit_ctrl; +-- DEBUG_OUT(24) <= mc_wr_en; +-- DEBUG_OUT(23 downto 20) <= dbg_main(15 downto 12); +-- DEBUG_OUT(19 downto 16) <= dbg_main(11 downto 8); +---- DEBUG_OUT(23 downto 16) <= mc_data(7 downto 0); +-- -- RX +-- DEBUG_OUT(15) <= rc_loading_done; +-- DEBUG_OUT(14) <= rc_frame_ready; +-- DEBUG_OUT(13) <= rc_frame_proto(4); -- ICMP +-- DEBUG_OUT(12) <= rc_frame_proto(1); -- DHCP +-- DEBUG_OUT(11) <= rc_frame_proto(0); -- ARP +-- DEBUG_OUT(10) <= fr_get_frame; +-- DEBUG_OUT(9) <= fr_frame_valid; +-- DEBUG_OUT(8) <= fr_rd_en; +-- DEBUG_OUT(7 downto 0) <= rc_q(7 downto 0); +--------------------------------------------------------------------------------------------------- +--------------------------------------------------------------------------------------------------- + DEBUG_OUT(27 downto 0) <= debug_main(27 downto 0); --------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------- @@ -251,9 +250,8 @@ architecture gbe_logic_wrapper_arch of gbe_logic_wrapper is TC_SRC_IP_OUT => mc_src_ip, TC_SRC_UDP_OUT => mc_src_udp, TC_TRANSMIT_DONE_IN => mc_transmit_done, - -- signals to/from sgmii/gbe pcs_an_complete - PCS_AN_COMPLETE_IN => MAC_AN_READY_IN, - MAC_READY_CONF_IN => MAC_READY_CONF_IN, + -- signals to/from media interface + LINK_ACTIVE_IN => LINK_ACTIVE_IN, -- signals to/from hub GSC_CLK_IN => GSC_CLK_IN, GSC_INIT_DATAREADY_OUT => GSC_INIT_DATAREADY_OUT, @@ -281,11 +279,7 @@ architecture gbe_logic_wrapper_arch of gbe_logic_wrapper is FWD_READY_OUT => FWD_READY_OUT, FWD_FULL_OUT => FWD_FULL_OUT, -- - DEBUG_OUT => dbg_main, --- DEBUG_OUT(15 downto 0) => open, --- DEBUG_OUT(63 downto 16) => open, - -- - MONITOR_SELECT_GEN_DBG_OUT => dbg_select_gen + DEBUG_OUT => debug_main --open ); MAKE_RESET_OUT <= make_reset; @@ -293,7 +287,7 @@ architecture gbe_logic_wrapper_arch of gbe_logic_wrapper is THE_TRANSMIT_CONTROL: entity work.gbe_transmit_control port map( CLK => CLK_125_IN, - RESET => RESET, --global_reset, + RESET => RESET, -- signal to/from main controller TC_DATAREADY_IN => mc_transmit_ctrl, TC_RD_EN_OUT => mc_wr_en, @@ -334,9 +328,9 @@ architecture gbe_logic_wrapper_arch of gbe_logic_wrapper is THE_FRAME_CONSTR: entity work.gbe_frame_constr port map( - RESET => RESET, --global_reset, + RESET => RESET, CLK => CLK_125_IN, - LINK_OK_IN => '1', -- BUG + LINK_OK_IN => LINK_ACTIVE_IN, --'1', -- BUG WR_EN_IN => fc_wr_en, DATA_IN => fc_data, START_OF_DATA_IN => fc_sod, @@ -372,7 +366,7 @@ architecture gbe_logic_wrapper_arch of gbe_logic_wrapper is THE_RECEIVE_CONTROL: entity work.gbe_receive_control port map( CLK => CLK_125_IN, - RESET => RESET, --global_reset, + RESET => RESET, -- signals to/from frame_receiver RC_DATA_IN => fr_q, FR_RD_EN_OUT => fr_rd_en, @@ -408,8 +402,8 @@ architecture gbe_logic_wrapper_arch of gbe_logic_wrapper is THE_FRAME_RECEIVER: entity work.gbe_frame_receiver port map( CLK => CLK_125_IN, - RESET => RESET, --global_reset, - LINK_OK_IN => link_ok, + RESET => RESET, + LINK_OK_IN => LINK_ACTIVE_IN, ALLOW_RX_IN => CFG_ALLOW_RX_IN, MY_MAC_IN => MY_MAC_IN, -- @@ -455,6 +449,5 @@ architecture gbe_logic_wrapper_arch of gbe_logic_wrapper is MONITOR_TX_PACKETS_OUT <= monitor_tx_packets; MONITOR_DROPPED_OUT <= monitor_dropped; - MONITOR_GEN_DBG_OUT <= dbg_select_gen; end architecture gbe_logic_wrapper_arch; diff --git a/gbe_trb/base/gbe_main_control.vhd b/gbe_trb/base/gbe_main_control.vhd index 4b1c52c..ceaa086 100644 --- a/gbe_trb/base/gbe_main_control.vhd +++ b/gbe_trb/base/gbe_main_control.vhd @@ -1,580 +1,516 @@ -library ieee; - use ieee.std_logic_1164.all; - use ieee.numeric_std.all; - -library work; - use work.trb_net_std.all; - use work.gbe_protocols.all; - -entity gbe_main_control is - generic( - INCLUDE_SLOWCTRL : std_logic := '0'; - INCLUDE_DHCP : std_logic := '0'; - INCLUDE_ARP : std_logic := '0'; - INCLUDE_PING : std_logic := '0'; - INCLUDE_FWD : std_logic := '0'; - -- - SLOWCTRL_BUFFER_SIZE : integer range 1 to 4 - ); - port( - CLK : in std_logic; -- system clock - CLK_125 : in std_logic; - RESET : in std_logic; - -- - MC_LINK_OK_OUT : out std_logic; -- remark: set to '1' internally - MC_DHCP_DONE_OUT : out std_logic; -- remark: set if link_current_state = ACTIVE - MY_IP_OUT : out std_logic_vector(31 downto 0); - MC_MY_MAC_IN : in std_logic_vector(47 downto 0); - MY_TRBNET_ADDRESS_IN : in std_logic_vector(15 downto 0); - ISSUE_REBOOT_OUT : out std_logic; - -- signals to/from receive controller - RC_FRAME_WAITING_IN : in std_logic; - RC_LOADING_DONE_OUT : out std_logic; - RC_DATA_IN : in std_logic_vector(8 downto 0); - 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_SRC_MAC_ADDRESS_IN : in std_logic_vector(47 downto 0); - RC_DEST_MAC_ADDRESS_IN : in std_logic_vector(47 downto 0); - RC_SRC_IP_ADDRESS_IN : in std_logic_vector(31 downto 0); - RC_DEST_IP_ADDRESS_IN : in std_logic_vector(31 downto 0); - RC_SRC_UDP_PORT_IN : in std_logic_vector(15 downto 0); - RC_DEST_UDP_PORT_IN : in std_logic_vector(15 downto 0); - -- signals to/from transmit controller - TC_TRANSMIT_CTRL_OUT : out std_logic; - TC_DATA_OUT : out std_logic_vector(8 downto 0); - TC_RD_EN_IN : in std_logic; - TC_FRAME_SIZE_OUT : out std_logic_vector(15 downto 0); - TC_FRAME_TYPE_OUT : out std_logic_vector(15 downto 0); - TC_DEST_MAC_OUT : out std_logic_vector(47 downto 0); - TC_DEST_IP_OUT : out std_logic_vector(31 downto 0); - TC_DEST_UDP_OUT : out std_logic_vector(15 downto 0); - TC_SRC_MAC_OUT : out std_logic_vector(47 downto 0); - TC_SRC_IP_OUT : out std_logic_vector(31 downto 0); - TC_SRC_UDP_OUT : out std_logic_vector(15 downto 0); - TC_FLAGS_OFFSET_OUT : out std_logic_vector(15 downto 0); - TC_IP_PROTOCOL_OUT : out std_logic_vector(7 downto 0); - TC_IDENT_OUT : out std_logic_vector(15 downto 0); - TC_TRANSMIT_DONE_IN : in std_logic; - -- signals to/from sgmii/gbe pcs_an_complete - PCS_AN_COMPLETE_IN : in std_logic; - MAC_READY_CONF_IN : in std_logic; - -- signals to/from hub - GSC_CLK_IN : in std_logic; - GSC_INIT_DATAREADY_OUT : out std_logic; - GSC_INIT_DATA_OUT : out std_logic_vector(15 downto 0); - GSC_INIT_PACKET_NUM_OUT : out std_logic_vector(2 downto 0); - GSC_INIT_READ_IN : in std_logic; - GSC_REPLY_DATAREADY_IN : in std_logic; - GSC_REPLY_DATA_IN : in std_logic_vector(15 downto 0); - GSC_REPLY_PACKET_NUM_IN : in std_logic_vector(2 downto 0); - GSC_REPLY_READ_OUT : out std_logic; - GSC_BUSY_IN : in std_logic; - CFG_MAX_REPLY_SIZE_IN : in std_logic_vector(31 downto 0); - -- - RESET_TRBNET_IN : in std_logic; - RESET_SCTRL_IN : in std_logic; - MAKE_RESET_OUT : out std_logic; - -- Forwarder - FWD_DST_MAC_IN : in std_logic_vector(47 downto 0); - FWD_DST_IP_IN : in std_logic_vector(31 downto 0); - FWD_DST_UDP_IN : in std_logic_vector(15 downto 0); - FWD_DATA_IN : in std_logic_vector(7 downto 0); - FWD_DATA_VALID_IN : in std_logic; - FWD_SOP_IN : in std_logic; - FWD_EOP_IN : in std_logic; - FWD_READY_OUT : out std_logic; - FWD_FULL_OUT : out std_logic; - -- - MONITOR_SELECT_REC_OUT : out std_logic_vector(c_MAX_PROTOCOLS * 32 - 1 downto 0); - MONITOR_SELECT_REC_BYTES_OUT : out std_logic_vector(c_MAX_PROTOCOLS * 32 - 1 downto 0); - MONITOR_SELECT_SENT_BYTES_OUT : out std_logic_vector(c_MAX_PROTOCOLS * 32 - 1 downto 0); - MONITOR_SELECT_SENT_OUT : out std_logic_vector(c_MAX_PROTOCOLS * 32 - 1 downto 0); - MONITOR_SELECT_GEN_DBG_OUT : out std_logic_vector(2 * c_MAX_PROTOCOLS * 32 - 1 downto 0); - -- - DEBUG_OUT : out std_logic_vector(63 downto 0) - ); -end gbe_main_control; - -architecture gbe_main_control_arch of gbe_main_control is - - attribute syn_encoding : string; - - type link_states is (INACTIVE, ACTIVE, ENABLE_MAC, TIMEOUT, FINALIZE, WAIT_FOR_BOOT, GET_ADDRESS); - signal link_current_state, link_next_state : link_states; - attribute syn_encoding of link_current_state : signal is "onehot"; - - signal link_ok : std_logic; - signal link_ok_timeout_ctr : unsigned(15 downto 0); - - type flow_states is (IDLE, TRANSMIT_CTRL, WAIT_FOR_FC, CLEANUP); - signal flow_current_state, flow_next_state : flow_states; - attribute syn_encoding of flow_current_state : signal is "onehot"; - - signal state : std_logic_vector(3 downto 0); - signal link_state : std_logic_vector(3 downto 0); - signal redirect_state : std_logic_vector(3 downto 0); - - signal ps_wr_en : std_logic; - signal ps_response_ready : std_logic; - signal ps_busy : std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0); - signal rc_rd_en : std_logic; - signal proto_select : std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0); - signal loaded_bytes_ctr : unsigned(15 downto 0); - - signal dhcp_start : std_logic; - signal dhcp_done : std_logic; - signal wait_ctr : unsigned(31 downto 0); - - signal rc_data_local : std_logic_vector(8 downto 0); - - type redirect_states is (IDLE, CHECK_TYPE, DROP, CHECK_BUSY, LOAD, BUSY, WAIT_ONE, FINISH, CLEANUP); - signal redirect_current_state, redirect_next_state : redirect_states; - attribute syn_encoding of redirect_current_state : signal is "onehot"; - - signal ps_wr_en_q : std_logic; - signal ps_wr_en_qq : std_logic; - - signal tc_data : std_logic_vector(8 downto 0); - - attribute syn_preserve : boolean; - attribute syn_keep : boolean; - attribute syn_keep of link_state, redirect_state, dhcp_done : signal is true; - attribute syn_preserve of link_state, redirect_state, dhcp_done : signal is true; --- attribute syn_keep of link_state, state, redirect_state, dhcp_done : signal is true; --- attribute syn_preserve of link_state, state, redirect_state, dhcp_done : signal is true; - - signal mc_busy : std_logic; - signal incl_dhcp : std_logic; - signal flow_state : std_logic_vector(3 downto 0); - signal selector_debug : std_logic_vector(63 downto 0); - -begin - - DEBUG_OUT(63 downto 16) <= (others => '0'); - - DEBUG_OUT(15 downto 12) <= link_state; - DEBUG_OUT(11 downto 8) <= redirect_state; - DEBUG_OUT(7 downto 4) <= flow_state; - DEBUG_OUT(3 downto 0) <= (others => '0'); - - THE_PROTOCOL_SELECTOR: entity work.gbe_protocol_selector - generic map( - INCLUDE_SLOWCTRL => INCLUDE_SLOWCTRL, - INCLUDE_DHCP => INCLUDE_DHCP, - INCLUDE_ARP => INCLUDE_ARP, - INCLUDE_PING => INCLUDE_PING, - INCLUDE_FWD => INCLUDE_FWD, - SLOWCTRL_BUFFER_SIZE => SLOWCTRL_BUFFER_SIZE - ) - port map( - CLK => CLK, - RESET => RESET, - PS_DATA_IN => rc_data_local, - PS_WR_EN_IN => ps_wr_en_qq, - PS_PROTO_SELECT_IN => proto_select, - PS_BUSY_OUT => ps_busy, - PS_FRAME_SIZE_IN => RC_FRAME_SIZE_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, - PS_SRC_IP_ADDRESS_IN => RC_SRC_IP_ADDRESS_IN, - PS_DEST_IP_ADDRESS_IN => RC_DEST_IP_ADDRESS_IN, - PS_SRC_UDP_PORT_IN => RC_SRC_UDP_PORT_IN, - PS_DEST_UDP_PORT_IN => RC_DEST_UDP_PORT_IN, - TC_DATA_OUT => tc_data, - TC_RD_EN_IN => TC_RD_EN_IN, - TC_FRAME_SIZE_OUT => TC_FRAME_SIZE_OUT, - TC_FRAME_TYPE_OUT => TC_FRAME_TYPE_OUT, - TC_IP_PROTOCOL_OUT => TC_IP_PROTOCOL_OUT, - TC_IDENT_OUT => TC_IDENT_OUT, - TC_DEST_MAC_OUT => TC_DEST_MAC_OUT, - TC_DEST_IP_OUT => TC_DEST_IP_OUT, - TC_DEST_UDP_OUT => TC_DEST_UDP_OUT, - TC_SRC_MAC_OUT => TC_SRC_MAC_OUT, - TC_SRC_IP_OUT => TC_SRC_IP_OUT, - TC_SRC_UDP_OUT => TC_SRC_UDP_OUT, - MC_BUSY_IN => mc_busy, - MY_MAC_IN => MC_MY_MAC_IN, - MY_IP_OUT => MY_IP_OUT, - DHCP_START_IN => dhcp_start, - DHCP_DONE_OUT => dhcp_done, - GSC_CLK_IN => GSC_CLK_IN, - GSC_INIT_DATAREADY_OUT => GSC_INIT_DATAREADY_OUT, - GSC_INIT_DATA_OUT => GSC_INIT_DATA_OUT, - GSC_INIT_PACKET_NUM_OUT => GSC_INIT_PACKET_NUM_OUT, - GSC_INIT_READ_IN => GSC_INIT_READ_IN, - GSC_REPLY_DATAREADY_IN => GSC_REPLY_DATAREADY_IN, - GSC_REPLY_DATA_IN => GSC_REPLY_DATA_IN, - GSC_REPLY_PACKET_NUM_IN => GSC_REPLY_PACKET_NUM_IN, - GSC_REPLY_READ_OUT => GSC_REPLY_READ_OUT, - GSC_BUSY_IN => GSC_BUSY_IN, - MAKE_RESET_OUT => MAKE_RESET_OUT, - - MY_TRBNET_ADDRESS_IN => MY_TRBNET_ADDRESS_IN, --- ISSUE_REBOOT_OUT => ISSUE_REBOOT_OUT, - - CFG_MAX_REPLY_SIZE_IN => CFG_MAX_REPLY_SIZE_IN, - - FWD_DST_MAC_IN => FWD_DST_MAC_IN, - FWD_DST_IP_IN => FWD_DST_IP_IN, - FWD_DST_UDP_IN => FWD_DST_UDP_IN, - FWD_DATA_IN => FWD_DATA_IN, - FWD_DATA_VALID_IN => FWD_DATA_VALID_IN, - FWD_SOP_IN => FWD_SOP_IN, - FWD_EOP_IN => FWD_EOP_IN, - FWD_READY_OUT => FWD_READY_OUT, - FWD_FULL_OUT => FWD_FULL_OUT, - - -- input for statistics from outside - MONITOR_SELECT_REC_OUT => MONITOR_SELECT_REC_OUT, - MONITOR_SELECT_REC_BYTES_OUT => MONITOR_SELECT_REC_BYTES_OUT, - MONITOR_SELECT_SENT_BYTES_OUT => MONITOR_SELECT_SENT_BYTES_OUT, - MONITOR_SELECT_SENT_OUT => MONITOR_SELECT_SENT_OUT, - MONITOR_SELECT_GEN_DBG_OUT => MONITOR_SELECT_GEN_DBG_OUT, - DEBUG_OUT => selector_debug - ); - - TC_DATA_OUT <= tc_data; - --- proto_select <= RC_FRAME_PROTO_IN when disable_redirect = '0' else (others => '0'); - proto_select <= RC_FRAME_PROTO_IN; - - -- warning - PROC_SYNC: process( CLK ) - begin - if( rising_edge(CLK) ) then - rc_data_local <= RC_DATA_IN; - end if; - end process PROC_SYNC; - - PROC_REDIRECT_FSM: process( CLK, RESET ) - begin - if ( RESET = '1' ) then - redirect_current_state <= IDLE; - elsif( rising_edge(CLK) ) then - redirect_current_state <= redirect_next_state; - end if; - end process PROC_REDIRECT_FSM; - - PROC_REDIRECT_TRANSITIONS: process( redirect_current_state, link_current_state, RC_FRAME_WAITING_IN, - ps_busy, RC_FRAME_PROTO_IN, loaded_bytes_ctr, RC_FRAME_SIZE_IN ) - begin - redirect_state <= x"0"; - - case redirect_current_state is - when IDLE => - redirect_state <= x"1"; - if( RC_FRAME_WAITING_IN = '1' ) then - redirect_next_state <= CHECK_TYPE; - else - redirect_next_state <= IDLE; - end if; - - when CHECK_TYPE => - redirect_state <= x"2"; - if ( link_current_state = ACTIVE ) then - redirect_next_state <= CHECK_BUSY; - elsif( (link_current_state = GET_ADDRESS) and (RC_FRAME_PROTO_IN = "10") ) then - redirect_next_state <= CHECK_BUSY; - else - redirect_next_state <= DROP; - end if; - - when DROP => - redirect_state <= x"3"; - if( loaded_bytes_ctr = unsigned(RC_FRAME_SIZE_IN) - 1 ) then - redirect_next_state <= WAIT_ONE; - else - redirect_next_state <= DROP; - end if; - - when CHECK_BUSY => - redirect_state <= x"4"; - if( or_all(ps_busy and RC_FRAME_PROTO_IN) = '0' ) then - redirect_next_state <= LOAD; - else - redirect_next_state <= BUSY; - end if; - - when LOAD => - redirect_state <= x"5"; - -- BUG: why not used Q(8) as stop bit? - if( loaded_bytes_ctr = unsigned(RC_FRAME_SIZE_IN) - 1 ) then - redirect_next_state <= WAIT_ONE; - else - redirect_next_state <= LOAD; - end if; - - when BUSY => - redirect_state <= x"6"; - if( or_all(ps_busy and RC_FRAME_PROTO_IN) = '0' ) then - redirect_next_state <= LOAD; - else - redirect_next_state <= BUSY; - end if; - - when WAIT_ONE => - redirect_state <= x"7"; - redirect_next_state <= FINISH; - - when FINISH => - redirect_state <= x"8"; - redirect_next_state <= CLEANUP; - - when CLEANUP => - redirect_state <= x"9"; - redirect_next_state <= IDLE; - - when others => redirect_next_state <= IDLE; - - end case; - end process PROC_REDIRECT_TRANSITIONS; - - rc_rd_en <= '1' when redirect_current_state = LOAD or redirect_current_state = DROP else '0'; - RC_RD_EN_OUT <= rc_rd_en; - - PROC_LOADING_DONE: process( CLK ) - begin - if rising_edge(CLK) then - if (RC_DATA_IN(8) = '1' and ps_wr_en_q = '1') then - RC_LOADING_DONE_OUT <= '1'; - else - RC_LOADING_DONE_OUT <= '0'; - end if; - end if; - end process PROC_LOADING_DONE; - - PROC_PS_WR_EN: process( CLK ) - begin - if rising_edge(CLK) then - ps_wr_en <= rc_rd_en; - ps_wr_en_q <= ps_wr_en; - ps_wr_en_qq <= ps_wr_en_q; - end if; - end process PROC_PS_WR_EN; - - PROC_LOADED_BYTES_CTR: process( CLK ) - begin - if rising_edge(CLK) then - if ( redirect_current_state = IDLE) then - loaded_bytes_ctr <= (others => '0'); - elsif( ((redirect_current_state = LOAD) or (redirect_current_state = DROP)) and (rc_rd_en = '1') ) then -- STUPID HERE! is included already - loaded_bytes_ctr <= loaded_bytes_ctr + 1; - end if; - end if; - end process PROC_LOADED_BYTES_CTR; - - --********************* - -- DATA FLOW CONTROL - - PROC_FLOW_FSM: process( CLK, RESET ) - begin - if ( RESET = '1' ) then - flow_current_state <= IDLE; - elsif( rising_edge(CLK) ) then - flow_current_state <= flow_next_state; - end if; - end process PROC_FLOW_FSM; - - PROC_FLOW_TRANSITIONS: process(flow_current_state, TC_TRANSMIT_DONE_IN, ps_response_ready, tc_data) - begin - flow_state <= x"0"; - - case flow_current_state is - when IDLE => - flow_state <= x"1"; - if (ps_response_ready = '1') then - flow_next_state <= TRANSMIT_CTRL; - else - flow_next_state <= IDLE; - end if; - - when TRANSMIT_CTRL => - flow_state <= x"2"; - if (tc_data(8) = '1') then - flow_next_state <= WAIT_FOR_FC; - else - flow_next_state <= TRANSMIT_CTRL; - end if; - - when WAIT_FOR_FC => - flow_state <= x"3"; - if (TC_TRANSMIT_DONE_IN = '1') then - flow_next_state <= CLEANUP; - else - flow_next_state <= WAIT_FOR_FC; - end if; - - when CLEANUP => - flow_state <= x"4"; - flow_next_state <= IDLE; - - when others => flow_next_state <= IDLE; - - end case; - end process PROC_FLOW_TRANSITIONS; - - PROC_BUSY: process( CLK ) - begin - if rising_edge(CLK) then - if (flow_current_state = IDLE and ps_response_ready = '1') then - TC_TRANSMIT_CTRL_OUT <= '1'; - else - TC_TRANSMIT_CTRL_OUT <= '0'; - end if; - - if (flow_current_state = TRANSMIT_CTRL or flow_current_state = WAIT_FOR_FC) then - mc_busy <= '1'; - else - mc_busy <= '0'; - end if; - end if; - end process PROC_BUSY; - - --*********************** - -- LINK STATE CONTROL - - PROC_LINK_FSM: process( RESET, CLK ) - begin - if ( RESET = '1' ) then - link_current_state <= INACTIVE; - elsif( rising_edge(CLK) ) then - link_current_state <= link_next_state; - end if; - end process PROC_LINK_FSM; - - INCL_DHCP_GEN: if (INCLUDE_DHCP = '1') generate - incl_dhcp <= '1'; - end generate INCL_DHCP_GEN; - NOINCL_DHCP_GEN: if (INCLUDE_DHCP = '0') generate - incl_dhcp <= '0'; - end generate NOINCL_DHCP_GEN; - - -- to be reworked. link_ok_timer is not needed anymore! - PROC_LINK_TRANSITIONS: process( link_current_state, dhcp_done, wait_ctr, PCS_AN_COMPLETE_IN, incl_dhcp, MAC_READY_CONF_IN, link_ok_timeout_ctr ) - begin - link_state <= x"0"; - - case link_current_state is - when INACTIVE => - link_state <= x"1"; - if (PCS_AN_COMPLETE_IN = '1') then - link_next_state <= TIMEOUT; - else - link_next_state <= INACTIVE; - end if; - - when TIMEOUT => - link_state <= x"2"; - if (PCS_AN_COMPLETE_IN = '0') then - link_next_state <= INACTIVE; - else - if (link_ok_timeout_ctr = x"ffff") then - link_next_state <= ENABLE_MAC; - else - link_next_state <= TIMEOUT; - end if; - end if; - - when ENABLE_MAC => - link_state <= x"3"; - if (PCS_AN_COMPLETE_IN = '0') then - link_next_state <= INACTIVE; - elsif (MAC_READY_CONF_IN = '1') then - link_next_state <= FINALIZE; - else - link_next_state <= ENABLE_MAC; - end if; - - when FINALIZE => - link_state <= x"4"; - if (PCS_AN_COMPLETE_IN = '0') then - link_next_state <= INACTIVE; - else - link_next_state <= WAIT_FOR_BOOT; - end if; - - when WAIT_FOR_BOOT => - link_state <= x"5"; - if (PCS_AN_COMPLETE_IN = '0') then - link_next_state <= INACTIVE; - else - if (wait_ctr = x"0000_1000") then - if (incl_dhcp = '1') then - link_next_state <= GET_ADDRESS; - else - link_next_state <= ACTIVE; - end if; - else - link_next_state <= WAIT_FOR_BOOT; - end if; - end if; - - when GET_ADDRESS => - link_state <= x"6"; - if (PCS_AN_COMPLETE_IN = '0') then - link_next_state <= INACTIVE; - else - if (dhcp_done = '1') then - link_next_state <= ACTIVE; - else - link_next_state <= GET_ADDRESS; - end if; - end if; - - when ACTIVE => - link_state <= x"7"; - if (PCS_AN_COMPLETE_IN = '0') then - link_next_state <= INACTIVE; - else - link_next_state <= ACTIVE; - end if; - - when others => - link_next_state <= INACTIVE; - - end case; - end process PROC_LINK_TRANSITIONS; - - MC_DHCP_DONE_OUT <= '1' when link_current_state = ACTIVE else '0'; - - PROC_LINK_OK_CTR: process( CLK ) - begin - if( rising_edge(CLK) ) then - if ( link_current_state /= TIMEOUT ) then - link_ok_timeout_ctr <= (others => '0'); - elsif( link_current_state = TIMEOUT ) then - link_ok_timeout_ctr <= link_ok_timeout_ctr + 1; - end if; - - if( link_current_state = GET_ADDRESS ) then - dhcp_start <= '1'; - else - dhcp_start <= '0'; - end if; - end if; - end process PROC_LINK_OK_CTR; - - link_ok <= '1'; -- BUG - what the fuck? - - PROC_WAIT_CTR: process( CLK ) - begin - if( rising_edge(CLK) ) then - if( link_current_state = WAIT_FOR_BOOT ) then - wait_ctr <= wait_ctr + 1; - else - wait_ctr <= (others => '0'); - end if; - end if; - end process PROC_WAIT_CTR; - - MC_LINK_OK_OUT <= link_ok; - - -- END OF LINK STATE CONTROL - --************* - - --DEBUG_OUT <= selector_debug; - -end gbe_main_control_arch; +library ieee; + use ieee.std_logic_1164.all; + use ieee.numeric_std.all; + +library work; + use work.trb_net_std.all; + use work.gbe_protocols.all; + +entity gbe_main_control is + generic( + INCLUDE_SLOWCTRL : std_logic := '0'; + INCLUDE_DHCP : std_logic := '0'; + INCLUDE_ARP : std_logic := '0'; + INCLUDE_PING : std_logic := '0'; + INCLUDE_FWD : std_logic := '0'; + -- + SLOWCTRL_BUFFER_SIZE : integer range 1 to 4 := 1 + ); + port( + CLK : in std_logic; -- system clock + CLK_125 : in std_logic; + RESET : in std_logic; + -- + MC_LINK_OK_OUT : out std_logic; -- remark: set to '1' internally + MC_DHCP_DONE_OUT : out std_logic; + MY_IP_OUT : out std_logic_vector(31 downto 0); + MC_MY_MAC_IN : in std_logic_vector(47 downto 0); + MY_TRBNET_ADDRESS_IN : in std_logic_vector(15 downto 0); + ISSUE_REBOOT_OUT : out std_logic; + -- signals to/from receive controller + RC_FRAME_WAITING_IN : in std_logic; + RC_LOADING_DONE_OUT : out std_logic; + RC_DATA_IN : in std_logic_vector(8 downto 0); + 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_SRC_MAC_ADDRESS_IN : in std_logic_vector(47 downto 0); + RC_DEST_MAC_ADDRESS_IN : in std_logic_vector(47 downto 0); + RC_SRC_IP_ADDRESS_IN : in std_logic_vector(31 downto 0); + RC_DEST_IP_ADDRESS_IN : in std_logic_vector(31 downto 0); + RC_SRC_UDP_PORT_IN : in std_logic_vector(15 downto 0); + RC_DEST_UDP_PORT_IN : in std_logic_vector(15 downto 0); + -- signals to/from transmit controller + TC_TRANSMIT_CTRL_OUT : out std_logic; + TC_DATA_OUT : out std_logic_vector(8 downto 0); + TC_RD_EN_IN : in std_logic; + TC_FRAME_SIZE_OUT : out std_logic_vector(15 downto 0); + TC_FRAME_TYPE_OUT : out std_logic_vector(15 downto 0); + TC_DEST_MAC_OUT : out std_logic_vector(47 downto 0); + TC_DEST_IP_OUT : out std_logic_vector(31 downto 0); + TC_DEST_UDP_OUT : out std_logic_vector(15 downto 0); + TC_SRC_MAC_OUT : out std_logic_vector(47 downto 0); + TC_SRC_IP_OUT : out std_logic_vector(31 downto 0); + TC_SRC_UDP_OUT : out std_logic_vector(15 downto 0); + TC_FLAGS_OFFSET_OUT : out std_logic_vector(15 downto 0); + TC_IP_PROTOCOL_OUT : out std_logic_vector(7 downto 0); + TC_IDENT_OUT : out std_logic_vector(15 downto 0); + TC_TRANSMIT_DONE_IN : in std_logic; + -- signals to/from media interface + LINK_ACTIVE_IN : in std_logic; + -- signals to/from hub + GSC_CLK_IN : in std_logic; + GSC_INIT_DATAREADY_OUT : out std_logic; + GSC_INIT_DATA_OUT : out std_logic_vector(15 downto 0); + GSC_INIT_PACKET_NUM_OUT : out std_logic_vector(2 downto 0); + GSC_INIT_READ_IN : in std_logic; + GSC_REPLY_DATAREADY_IN : in std_logic; + GSC_REPLY_DATA_IN : in std_logic_vector(15 downto 0); + GSC_REPLY_PACKET_NUM_IN : in std_logic_vector(2 downto 0); + GSC_REPLY_READ_OUT : out std_logic; + GSC_BUSY_IN : in std_logic; + CFG_MAX_REPLY_SIZE_IN : in std_logic_vector(31 downto 0); + -- + RESET_TRBNET_IN : in std_logic; + RESET_SCTRL_IN : in std_logic; + MAKE_RESET_OUT : out std_logic; + -- Forwarder + FWD_DST_MAC_IN : in std_logic_vector(47 downto 0); + FWD_DST_IP_IN : in std_logic_vector(31 downto 0); + FWD_DST_UDP_IN : in std_logic_vector(15 downto 0); + FWD_DATA_IN : in std_logic_vector(7 downto 0); + FWD_DATA_VALID_IN : in std_logic; + FWD_SOP_IN : in std_logic; + FWD_EOP_IN : in std_logic; + FWD_READY_OUT : out std_logic; + FWD_FULL_OUT : out std_logic; + -- + MONITOR_SELECT_REC_OUT : out std_logic_vector(c_MAX_PROTOCOLS * 32 - 1 downto 0); + MONITOR_SELECT_REC_BYTES_OUT : out std_logic_vector(c_MAX_PROTOCOLS * 32 - 1 downto 0); + MONITOR_SELECT_SENT_BYTES_OUT : out std_logic_vector(c_MAX_PROTOCOLS * 32 - 1 downto 0); + MONITOR_SELECT_SENT_OUT : out std_logic_vector(c_MAX_PROTOCOLS * 32 - 1 downto 0); + -- + DEBUG_OUT : out std_logic_vector(63 downto 0) + ); +end gbe_main_control; + +architecture gbe_main_control_arch of gbe_main_control is + + attribute syn_encoding : string; + + type FSM_LINK_STATES is (LINK_DOWN, LINK_ACTIVE, LINK_UP); + signal LINK_STATE_CS, LINK_STATE_NS: FSM_LINK_STATES; + attribute syn_encoding of LINK_STATE_CS : signal is "onehot"; + + signal link_state : std_logic_vector(3 downto 0); + signal dhcp_start_x : std_logic; + signal dhcp_start : std_logic; + signal dhcp_done : std_logic; + signal incl_dhcp : std_logic; + + type FSM_REDIRECT_STATES is (IDLE, CHECK_TYPE, DROP, CHECK_BUSY, LOAD, BUSY, WAIT_ONE, FINISH, CLEANUP); + signal REDIRECT_CS, REDIRECT_NS : FSM_REDIRECT_STATES; + attribute syn_encoding of REDIRECT_CS : signal is "onehot"; + + signal redirect_state : std_logic_vector(3 downto 0); + signal rc_rd_en : std_logic; + + ----------------------------------------------------------------------- + + type flow_states is (IDLE, TRANSMIT_CTRL, WAIT_FOR_FC, CLEANUP); + signal FLOW_CS, FLOW_NS : flow_states; + attribute syn_encoding of FLOW_CS : signal is "onehot"; + + signal flow_state : std_logic_vector(3 downto 0); + + signal ps_wr_en : std_logic; + signal ps_response_ready : std_logic; + signal ps_busy : std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0); + signal loaded_bytes_ctr : unsigned(15 downto 0); + + signal rc_data_local : std_logic_vector(8 downto 0); + + signal ps_wr_en_q : std_logic; + signal ps_wr_en_qq : std_logic; + + signal tc_data : std_logic_vector(8 downto 0); + + attribute syn_preserve : boolean; + attribute syn_keep : boolean; + attribute syn_keep of link_state, redirect_state, dhcp_done : signal is true; + attribute syn_preserve of link_state, redirect_state, dhcp_done : signal is true; + + signal mc_busy : std_logic; + signal selector_debug : std_logic_vector(63 downto 0); + +begin + + ----------------------------------------------------------------------- + -- Debug signals + ----------------------------------------------------------------------- + DEBUG_OUT(63 downto 28) <= (others => '0'); + + DEBUG_OUT(27 downto 24) <= link_state; + DEBUG_OUT(23 downto 20) <= redirect_state; + DEBUG_OUT(19 downto 16) <= flow_state; + DEBUG_OUT(15 downto 0) <= selector_debug(15 downto 0); + + ----------------------------------------------------------------------- + -- Link state machine, high level. Handles DHCP basically + ----------------------------------------------------------------------- + PROC_LINK_STATE_FSM: process( CLK, RESET ) + begin + if ( RESET = '1' ) then + LINK_STATE_CS <= LINK_DOWN; + dhcp_start <= '0'; + elsif( rising_edge(CLK) ) then + LINK_STATE_CS <= LINK_STATE_NS; + dhcp_start <= dhcp_start_x; + end if; + end process PROC_LINK_STATE_FSM; + + PROC_LINK_STATE_TRANSITIONS: process( LINK_STATE_CS, LINK_ACTIVE_IN, dhcp_done, incl_dhcp ) + begin + dhcp_start_x <= '0'; + + case LINK_STATE_CS is + when LINK_DOWN => + link_state <= x"0"; + if ( (LINK_ACTIVE_IN = '1') and (incl_dhcp = '1') ) then + -- PHY and MAC are operational, DHCP is used + LINK_STATE_NS <= LINK_ACTIVE; + dhcp_start_x <= '1'; + elsif( (LINK_ACTIVE_IN = '0') and (incl_dhcp = '0') ) then + -- PHY and MAC are operational, DHCP is not used + LINK_STATE_NS <= LINK_UP; + else + -- no link partner, or AN in progress + LINK_STATE_NS <= LINK_DOWN; + end if; + when LINK_ACTIVE => + link_state <= x"1"; + if ( LINK_ACTIVE_IN = '0' ) then + -- link lost + LINK_STATE_NS <= LINK_DOWN; + elsif( dhcp_done = '1' ) then + -- DHCP done + LINK_STATE_NS <= LINK_UP; + dhcp_start_x <= '1'; + else + -- wait for DHCP + LINK_STATE_NS <= LINK_ACTIVE; + dhcp_start_x <= '1'; + end if; + when LINK_UP => + link_state <= x"2"; + if( LINK_ACTIVE_IN = '0' ) then + -- link lost + LINK_STATE_NS <= LINK_DOWN; + else + -- all fine :) + LINK_STATE_NS <= LINK_UP; + dhcp_start_x <= '1'; + end if; + + when others => + LINK_STATE_NS <= LINK_DOWN; + end case; + end process PROC_LINK_STATE_TRANSITIONS; + + MC_DHCP_DONE_OUT <= '1' when (LINK_STATE_CS = LINK_UP) else '0'; + + MC_LINK_OK_OUT <= '1' when (LINK_STATE_CS = LINK_UP) else '0'; -- TAKE CARE! MIGHT INTERFERE WITH PACKET TRANSMISSION! + + ----------------------------------------------------------------------- + -- handles frame loading or dropping + ----------------------------------------------------------------------- + PROC_REDIRECT_FSM: process( CLK, RESET ) + begin + if ( RESET = '1' ) then + REDIRECT_CS <= IDLE; + elsif( rising_edge(CLK) ) then + REDIRECT_CS <= REDIRECT_NS; + end if; + end process PROC_REDIRECT_FSM; + + PROC_REDIRECT_TRANSITIONS: process( REDIRECT_CS, LINK_STATE_CS, RC_FRAME_WAITING_IN, + RC_FRAME_PROTO_IN, RC_FRAME_SIZE_IN, ps_busy, loaded_bytes_ctr ) + begin + redirect_state <= x"0"; + + case REDIRECT_CS is + when IDLE => + redirect_state <= x"1"; + if( (RC_FRAME_WAITING_IN = '1') ) then + -- frame waiting, check what we can do + REDIRECT_NS <= CHECK_TYPE; + else + REDIRECT_NS <= IDLE; + end if; + + when CHECK_TYPE => + redirect_state <= x"2"; + if ( LINK_STATE_CS = LINK_UP ) then + -- DHPC done, or fixed IP, so we are fully accepting frames + REDIRECT_NS <= CHECK_BUSY; + elsif( (LINK_STATE_CS = LINK_ACTIVE) and (RC_FRAME_PROTO_IN(1 downto 0) = "10") ) then + -- DHCP in progress, so only DHCP frames are accepted + REDIRECT_NS <= CHECK_BUSY; + else + -- link lost, drop frame + REDIRECT_NS <= DROP; + end if; + + when DROP => + redirect_state <= x"3"; + if( loaded_bytes_ctr = unsigned(RC_FRAME_SIZE_IN) - 1 ) then + -- frame has been loaded + REDIRECT_NS <= WAIT_ONE; + else + REDIRECT_NS <= DROP; + end if; + + when CHECK_BUSY => + redirect_state <= x"4"; + if( or_all(ps_busy and RC_FRAME_PROTO_IN) = '0' ) then + -- selected protocol is ready + REDIRECT_NS <= LOAD; + else + REDIRECT_NS <= BUSY; + end if; + + when LOAD => + redirect_state <= x"5"; + if( loaded_bytes_ctr = unsigned(RC_FRAME_SIZE_IN) - 1 ) then + -- all bytes loaded + REDIRECT_NS <= WAIT_ONE; + else + REDIRECT_NS <= LOAD; + end if; + + when BUSY => + redirect_state <= x"6"; + if( or_all(ps_busy and RC_FRAME_PROTO_IN) = '0' ) then + -- selected protocol is ready + REDIRECT_NS <= LOAD; + else + -- wait for selected protocol to be idle + REDIRECT_NS <= BUSY; + end if; + + when WAIT_ONE => + redirect_state <= x"7"; + REDIRECT_NS <= FINISH; + + when FINISH => + redirect_state <= x"8"; + REDIRECT_NS <= CLEANUP; + + when CLEANUP => + redirect_state <= x"9"; + REDIRECT_NS <= IDLE; + + when others => REDIRECT_NS <= IDLE; + + end case; + end process PROC_REDIRECT_TRANSITIONS; + + INCL_DHCP_GEN: if( INCLUDE_DHCP = '1' ) generate + incl_dhcp <= '1'; + end generate INCL_DHCP_GEN; + NOINCL_DHCP_GEN: if( INCLUDE_DHCP = '0' ) generate + incl_dhcp <= '0'; + end generate NOINCL_DHCP_GEN; + + rc_rd_en <= '1' when ( (REDIRECT_CS = LOAD) or (REDIRECT_CS = DROP) ) else '0'; + RC_RD_EN_OUT <= rc_rd_en; + + ----------------------------------------------------------------------- + ----------------------------------------------------------------------- + PROC_FLOW_FSM: process( CLK, RESET ) + begin + if ( RESET = '1' ) then + FLOW_CS <= IDLE; + elsif( rising_edge(CLK) ) then + FLOW_CS <= FLOW_NS; + end if; + end process PROC_FLOW_FSM; + + PROC_FLOW_TRANSITIONS: process(FLOW_CS, TC_TRANSMIT_DONE_IN, ps_response_ready, tc_data) + begin + flow_state <= x"0"; + + case FLOW_CS is + when IDLE => + flow_state <= x"1"; + if( ps_response_ready = '1' ) then + FLOW_NS <= TRANSMIT_CTRL; + else + FLOW_NS <= IDLE; + end if; + + when TRANSMIT_CTRL => + flow_state <= x"2"; + if( tc_data(8) = '1' ) then + FLOW_NS <= WAIT_FOR_FC; + else + FLOW_NS <= TRANSMIT_CTRL; + end if; + + when WAIT_FOR_FC => + flow_state <= x"3"; + if( TC_TRANSMIT_DONE_IN = '1' ) then + FLOW_NS <= CLEANUP; + else + FLOW_NS <= WAIT_FOR_FC; + end if; + + when CLEANUP => + flow_state <= x"4"; + FLOW_NS <= IDLE; + + when others => + FLOW_NS <= IDLE; + + end case; + end process PROC_FLOW_TRANSITIONS; + + PROC_BUSY: process( CLK ) + begin + if rising_edge(CLK) then + if( (FLOW_CS = IDLE) and (ps_response_ready = '1') )then + TC_TRANSMIT_CTRL_OUT <= '1'; + else + TC_TRANSMIT_CTRL_OUT <= '0'; + end if; + + if( (FLOW_CS = TRANSMIT_CTRL) or (FLOW_CS = WAIT_FOR_FC) ) then + mc_busy <= '1'; + else + mc_busy <= '0'; + end if; + end if; + end process PROC_BUSY; + + ----------------------------------------------------------------------- + -- Protocol selector + ----------------------------------------------------------------------- + THE_PROTOCOL_SELECTOR: entity work.gbe_protocol_selector + generic map( + INCLUDE_SLOWCTRL => INCLUDE_SLOWCTRL, + INCLUDE_DHCP => INCLUDE_DHCP, + INCLUDE_ARP => INCLUDE_ARP, + INCLUDE_PING => INCLUDE_PING, + INCLUDE_FWD => INCLUDE_FWD, + SLOWCTRL_BUFFER_SIZE => SLOWCTRL_BUFFER_SIZE + ) + port map( + CLK => CLK, + RESET => RESET, + PS_DATA_IN => rc_data_local, + PS_WR_EN_IN => ps_wr_en_qq, + PS_PROTO_SELECT_IN => RC_FRAME_PROTO_IN, + PS_BUSY_OUT => ps_busy, + PS_FRAME_SIZE_IN => RC_FRAME_SIZE_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, + PS_SRC_IP_ADDRESS_IN => RC_SRC_IP_ADDRESS_IN, + PS_DEST_IP_ADDRESS_IN => RC_DEST_IP_ADDRESS_IN, + PS_SRC_UDP_PORT_IN => RC_SRC_UDP_PORT_IN, + PS_DEST_UDP_PORT_IN => RC_DEST_UDP_PORT_IN, + TC_DATA_OUT => tc_data, + TC_RD_EN_IN => TC_RD_EN_IN, + TC_FRAME_SIZE_OUT => TC_FRAME_SIZE_OUT, + TC_FRAME_TYPE_OUT => TC_FRAME_TYPE_OUT, + TC_IP_PROTOCOL_OUT => TC_IP_PROTOCOL_OUT, + TC_IDENT_OUT => TC_IDENT_OUT, + TC_DEST_MAC_OUT => TC_DEST_MAC_OUT, + TC_DEST_IP_OUT => TC_DEST_IP_OUT, + TC_DEST_UDP_OUT => TC_DEST_UDP_OUT, + TC_SRC_MAC_OUT => TC_SRC_MAC_OUT, + TC_SRC_IP_OUT => TC_SRC_IP_OUT, + TC_SRC_UDP_OUT => TC_SRC_UDP_OUT, + MC_BUSY_IN => mc_busy, + MY_MAC_IN => MC_MY_MAC_IN, + MY_IP_OUT => MY_IP_OUT, + DHCP_START_IN => dhcp_start, + DHCP_DONE_OUT => dhcp_done, + GSC_CLK_IN => GSC_CLK_IN, + GSC_INIT_DATAREADY_OUT => GSC_INIT_DATAREADY_OUT, + GSC_INIT_DATA_OUT => GSC_INIT_DATA_OUT, + GSC_INIT_PACKET_NUM_OUT => GSC_INIT_PACKET_NUM_OUT, + GSC_INIT_READ_IN => GSC_INIT_READ_IN, + GSC_REPLY_DATAREADY_IN => GSC_REPLY_DATAREADY_IN, + GSC_REPLY_DATA_IN => GSC_REPLY_DATA_IN, + GSC_REPLY_PACKET_NUM_IN => GSC_REPLY_PACKET_NUM_IN, + GSC_REPLY_READ_OUT => GSC_REPLY_READ_OUT, + GSC_BUSY_IN => GSC_BUSY_IN, + MAKE_RESET_OUT => MAKE_RESET_OUT, + + MY_TRBNET_ADDRESS_IN => MY_TRBNET_ADDRESS_IN, + + CFG_MAX_REPLY_SIZE_IN => CFG_MAX_REPLY_SIZE_IN, + + FWD_DST_MAC_IN => FWD_DST_MAC_IN, + FWD_DST_IP_IN => FWD_DST_IP_IN, + FWD_DST_UDP_IN => FWD_DST_UDP_IN, + FWD_DATA_IN => FWD_DATA_IN, + FWD_DATA_VALID_IN => FWD_DATA_VALID_IN, + FWD_SOP_IN => FWD_SOP_IN, + FWD_EOP_IN => FWD_EOP_IN, + FWD_READY_OUT => FWD_READY_OUT, + FWD_FULL_OUT => FWD_FULL_OUT, + + -- input for statistics from outside + MONITOR_SELECT_REC_OUT => MONITOR_SELECT_REC_OUT, + MONITOR_SELECT_REC_BYTES_OUT => MONITOR_SELECT_REC_BYTES_OUT, + MONITOR_SELECT_SENT_BYTES_OUT => MONITOR_SELECT_SENT_BYTES_OUT, + MONITOR_SELECT_SENT_OUT => MONITOR_SELECT_SENT_OUT, + DEBUG_OUT => selector_debug + ); + + TC_DATA_OUT <= tc_data; + + -- warning + PROC_SYNC: process( CLK ) + begin + if( rising_edge(CLK) ) then + rc_data_local <= RC_DATA_IN; + end if; + end process PROC_SYNC; + + + PROC_LOADING_DONE: process( CLK ) + begin + if rising_edge(CLK) then + if (RC_DATA_IN(8) = '1' and ps_wr_en_q = '1') then + RC_LOADING_DONE_OUT <= '1'; + else + RC_LOADING_DONE_OUT <= '0'; + end if; + end if; + end process PROC_LOADING_DONE; + + PROC_PS_WR_EN: process( CLK ) + begin + if rising_edge(CLK) then + ps_wr_en <= rc_rd_en; + ps_wr_en_q <= ps_wr_en; + ps_wr_en_qq <= ps_wr_en_q; + end if; + end process PROC_PS_WR_EN; + + PROC_LOADED_BYTES_CTR: process( CLK ) + begin + if rising_edge(CLK) then + if ( REDIRECT_CS = IDLE) then + loaded_bytes_ctr <= (others => '0'); + elsif( ((REDIRECT_CS = LOAD) or (REDIRECT_CS = DROP)) ) then + loaded_bytes_ctr <= loaded_bytes_ctr + 1; + end if; + end if; + end process PROC_LOADED_BYTES_CTR; + +end gbe_main_control_arch; diff --git a/gbe_trb/base/gbe_protocol_selector.vhd b/gbe_trb/base/gbe_protocol_selector.vhd index 240403b..27cb48a 100644 --- a/gbe_trb/base/gbe_protocol_selector.vhd +++ b/gbe_trb/base/gbe_protocol_selector.vhd @@ -73,12 +73,11 @@ entity gbe_protocol_selector is FWD_EOP_IN : in std_logic; FWD_READY_OUT : out std_logic; FWD_FULL_OUT : out std_logic; - -- input for statistics from outside + -- input for statistics from outside MONITOR_SELECT_REC_OUT : out std_logic_vector(c_MAX_PROTOCOLS * 32 - 1 downto 0); MONITOR_SELECT_REC_BYTES_OUT : out std_logic_vector(c_MAX_PROTOCOLS * 32 - 1 downto 0); MONITOR_SELECT_SENT_BYTES_OUT : out std_logic_vector(c_MAX_PROTOCOLS * 32 - 1 downto 0); MONITOR_SELECT_SENT_OUT : out std_logic_vector(c_MAX_PROTOCOLS * 32 - 1 downto 0); - MONITOR_SELECT_GEN_DBG_OUT : out std_logic_vector(2 * c_MAX_PROTOCOLS * 32 - 1 downto 0); DEBUG_OUT : out std_logic_vector(63 downto 0) ); end gbe_protocol_selector; @@ -123,10 +122,21 @@ architecture gbe_protocol_selector_arch of gbe_protocol_selector is signal my_ip : std_logic_vector(31 downto 0); signal select_state : std_logic_vector(3 downto 0); + signal debug_arp : std_logic_vector(63 downto 0); + signal debug_dhcp : std_logic_vector(63 downto 0); + signal debug_ping : std_logic_vector(63 downto 0); + signal debug_sctrl : std_logic_vector(63 downto 0); + signal debug_forward : std_logic_vector(63 downto 0); + begin zeros <= (others => '0'); MY_IP_OUT <= my_ip; + -- Debug lines + DEBUG_OUT(63 downto 16) <= (others => '0'); + DEBUG_OUT(15 downto 12) <= state; -- selector state + DEBUG_OUT(11 downto 0) <= debug_dhcp(11 downto 0); -- FSM states DHCP + ARP_GEN: if( INCLUDE_ARP = '1' ) generate -- protocol Nr. 1 ARP THE_ARP: entity work.gbe_response_constructor_ARP @@ -160,8 +170,8 @@ begin TC_SRC_MAC_OUT => tc_src_mac(1 * 48 - 1 downto 0 * 48), TC_SRC_IP_OUT => tc_src_ip(1 * 32 - 1 downto 0 * 32), TC_SRC_UDP_OUT => tc_src_udp(1 * 16 - 1 downto 0 * 16), - DEBUG_OUT => MONITOR_SELECT_GEN_DBG_OUT(1 * 64 - 1 downto 0 * 64) - -- END OF INTERFACE + DEBUG_OUT => debug_arp + -- END OF INTERFACE ); end generate ARP_GEN; @@ -176,7 +186,7 @@ begin port map( CLK => CLK, RESET => RESET, - -- INTERFACE + -- INTERFACE MY_MAC_IN => MY_MAC_IN, MY_IP_IN => my_ip, PS_DATA_IN => PS_DATA_IN, @@ -207,7 +217,7 @@ begin MY_IP_OUT => my_ip, DHCP_START_IN => DHCP_START_IN, DHCP_DONE_OUT => DHCP_DONE_OUT, - DEBUG_OUT => MONITOR_SELECT_GEN_DBG_OUT(2 * 64 - 1 downto 1 * 64) + DEBUG_OUT => debug_dhcp ); end generate DHCP_GEN; @@ -249,7 +259,7 @@ begin TC_SRC_MAC_OUT => tc_src_mac(5 * 48 - 1 downto 4 * 48), TC_SRC_IP_OUT => tc_src_ip(5 * 32 - 1 downto 4 * 32), TC_SRC_UDP_OUT => tc_src_udp(5 * 16 - 1 downto 4 * 16), - DEBUG_OUT => MONITOR_SELECT_GEN_DBG_OUT(5 * 64 - 1 downto 4 * 64) + DEBUG_OUT => debug_ping -- END OF INTERFACE ); end generate PING_GEN; @@ -261,13 +271,13 @@ begin SCTRL_GEN: if( INCLUDE_SLOWCTRL = '1' ) generate THE_SCTRL: entity work.gbe_response_constructor_SCTRL - generic map( + generic map( SLOWCTRL_BUFFER_SIZE => SLOWCTRL_BUFFER_SIZE ) port map( CLK => CLK, RESET => RESET, - -- INTERFACE + -- INTERFACE MY_MAC_IN => MY_MAC_IN, MY_IP_IN => my_ip, PS_DATA_IN => PS_DATA_IN, @@ -294,7 +304,7 @@ begin TC_SRC_MAC_OUT => tc_src_mac(3 * 48 - 1 downto 2 * 48), TC_SRC_IP_OUT => tc_src_ip(3 * 32 - 1 downto 2 * 32), TC_SRC_UDP_OUT => tc_src_udp(3 * 16 - 1 downto 2 * 16), - DEBUG_OUT => MONITOR_SELECT_GEN_DBG_OUT(3 * 64 - 1 downto 2 * 64), + DEBUG_OUT => debug_sctrl, -- END OF INTERFACE GSC_CLK_IN => GSC_CLK_IN, GSC_INIT_DATAREADY_OUT => GSC_INIT_DATAREADY_OUT, @@ -375,19 +385,16 @@ begin FWD_SOP_IN => FWD_SOP_IN, FWD_EOP_IN => FWD_EOP_IN, FWD_READY_OUT => FWD_READY_OUT, - FWD_FULL_OUT => FWD_FULL_OUT, - DEBUG_OUT => DEBUG_OUT(31 downto 0) --open + FWD_FULL_OUT => FWD_FULL_OUT, + DEBUG_OUT => debug_forward -- END OF INTERFACE ); end generate FWD_GEN; - DEBUG_OUT(63 downto 32) <= (others => '0'); - NO_FWD_GEN: if( INCLUDE_FWD = '0' ) generate resp_ready(5) <= '0'; busy(5) <= '0'; - DEBUG_OUT(31 downto 0) <= (others => '0'); end generate NO_FWD_GEN; PS_BUSY_OUT <= busy; diff --git a/gbe_trb/base/gbe_receive_control.vhd b/gbe_trb/base/gbe_receive_control.vhd index 99c521c..53948c2 100644 --- a/gbe_trb/base/gbe_receive_control.vhd +++ b/gbe_trb/base/gbe_receive_control.vhd @@ -75,7 +75,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_FRAME_PROTO_OUT <= FR_PS_IN when (load_current_state /= IDLE) else (others => '0'); + RC_FRAME_PROTO_OUT <= FR_PS_IN when (load_current_state /= IDLE) else (others => '0'); LOAD_MACHINE_PROC: process( CLK, RESET ) begin @@ -101,7 +101,7 @@ begin when PREPARE => -- prepare frame size state <= x"2"; load_next_state <= WAIT_ONE; - + when WAIT_ONE => load_next_state <= READY; @@ -151,7 +151,7 @@ begin elsif( rising_edge(CLK) ) then if( RC_LOADING_DONE_IN = '1' ) then frames_readout_ctr <= frames_readout_ctr + 1; - end if; + end if; end if; end process FRAMES_READOUT_CTR_PROC; @@ -162,7 +162,7 @@ begin bytes_rec_ctr <= (others => '0'); elsif( rising_edge(CLK) ) then if( FR_FRAME_VALID_IN = '1' ) then - bytes_rec_ctr <= bytes_rec_ctr + unsigned(FR_FRAME_SIZE_IN); + bytes_rec_ctr <= bytes_rec_ctr + unsigned(FR_FRAME_SIZE_IN); end if; end if; end process BYTES_REC_CTR_PROC; diff --git a/gbe_trb/base/gbe_transmit_control.vhd b/gbe_trb/base/gbe_transmit_control.vhd index 53d1c9a..20394b8 100644 --- a/gbe_trb/base/gbe_transmit_control.vhd +++ b/gbe_trb/base/gbe_transmit_control.vhd @@ -5,7 +5,6 @@ USE IEEE.std_logic_UNSIGNED.ALL; library work; use work.trb_net_std.all; -use work.trb_net_components.all; use work.gbe_protocols.all; entity gbe_transmit_control is @@ -18,7 +17,7 @@ port ( TC_DATA_IN : in std_logic_vector(7 downto 0); TC_FRAME_SIZE_IN : in std_logic_vector(15 downto 0); TC_FRAME_TYPE_IN : in std_logic_vector(15 downto 0); - TC_IP_PROTOCOL_IN : in std_logic_vector(7 downto 0); + TC_IP_PROTOCOL_IN : in std_logic_vector(7 downto 0); TC_DEST_MAC_IN : in std_logic_vector(47 downto 0); TC_DEST_IP_IN : in std_logic_vector(31 downto 0); TC_DEST_UDP_IN : in std_logic_vector(15 downto 0); @@ -50,7 +49,7 @@ port ( SRC_UDP_PORT_OUT : out std_logic_vector(15 downto 0); -- MONITOR_TX_PACKETS_OUT : out std_logic_vector(31 downto 0); --- +-- DEBUG_OUT : out std_logic_vector(63 downto 0) ); end gbe_transmit_control; @@ -69,7 +68,7 @@ signal local_end : std_logic_vector(15 downto 0); signal actual_frame_bytes, full_packet_size, ip_size, packet_loaded_bytes : std_logic_vector(15 downto 0); signal go_to_divide, more_fragments : std_logic; signal first_frame : std_logic; -signal mon_packets_sent_ctr : std_logic_vector(31 downto 0); +signal mon_packets_sent_ctr : std_logic_vector(31 downto 0); signal state : std_logic_vector(3 downto 0); begin @@ -87,7 +86,7 @@ TRANSMIT_MACHINE : process(transmit_current_state, FC_H_READY_IN, TC_DATAREADY_I begin state <= x"0"; case transmit_current_state is - + when IDLE => state <= x"1"; if (TC_DATAREADY_IN = '1') then @@ -95,11 +94,11 @@ begin else transmit_next_state <= IDLE; end if; - + when PREPARE_HEADERS => state <= x"2"; transmit_next_state<= WAIT_FOR_H; - + when WAIT_FOR_H => state <= x"3"; if (FC_H_READY_IN = '1') then @@ -107,7 +106,7 @@ begin else transmit_next_state <= WAIT_FOR_H; end if; - + when TRANSMIT => state <= x"4"; if (local_end = x"0000") then @@ -119,19 +118,19 @@ begin transmit_next_state <= TRANSMIT; end if; end if; - + when SEND_ONE => state <= x"5"; transmit_next_state <= SEND_TWO; - + when SEND_TWO => state <= x"6"; transmit_next_state <= CLOSE; - + when CLOSE => state <= x"7"; transmit_next_state <= WAIT_FOR_TRANS; - + when WAIT_FOR_TRANS => state <= x"8"; if (FC_READY_IN = '1') then @@ -143,15 +142,15 @@ begin else transmit_next_state <= WAIT_FOR_TRANS; end if; - + when DIVIDE => state <= x"9"; transmit_next_state <= PREPARE_HEADERS; - + when CLEANUP => state <= x"a"; transmit_next_state <= IDLE; - + end case; end process TRANSMIT_MACHINE; @@ -161,7 +160,7 @@ TC_RD_EN_OUT <= tc_rd; SYNC_PROC : process( CLK ) begin - if( rising_edge(CLK) ) then + if( rising_edge(CLK) ) then tc_rd_q <= tc_rd; tc_rd_qq <= tc_rd_q; FC_WR_EN_OUT <= tc_rd_qq; @@ -188,7 +187,7 @@ begin go_to_divide <= '1'; elsif( transmit_current_state = SEND_ONE and full_packet_size = packet_loaded_bytes ) then go_to_divide <= '0'; - end if; + end if; end if; end process GO_TO_DIVIDE_PROC; @@ -201,7 +200,7 @@ begin elsif( transmit_current_state = TRANSMIT ) then local_end <= local_end - x"1"; full_packet_size <= full_packet_size; - end if; + end if; end if; end process LOCAL_END_PROC; @@ -223,7 +222,7 @@ begin end if; end if; end process; -FC_IP_SIZE_OUT <= ip_size; +FC_IP_SIZE_OUT <= ip_size; FC_UDP_SIZE_OUT <= full_packet_size; FC_FLAGS_OFFSET_OUT(15 downto 14) <= "00"; @@ -263,7 +262,7 @@ begin elsif( transmit_current_state = DIVIDE ) then first_frame <= '0'; end if; - end if; + end if; end process FIRST_FRAME_PROC; diff --git a/gbe_trb/base/gbe_wrapper_fifo.vhd b/gbe_trb/base/gbe_wrapper_fifo.vhd index ce0dcde..8f0d475 100644 --- a/gbe_trb/base/gbe_wrapper_fifo.vhd +++ b/gbe_trb/base/gbe_wrapper_fifo.vhd @@ -32,7 +32,6 @@ entity gbe_wrapper_fifo is MAC_RX_EOF_IN : in std_logic; MAC_RX_ERROR_IN : in std_logic; -- - PCS_AN_READY_IN : in std_logic; LINK_ACTIVE_IN : in std_logic; -- SlowControl MY_TRBNET_ADDRESS_IN : in std_logic_vector(15 downto 0); @@ -141,10 +140,6 @@ begin ); ------------------------------------------------------------------------------------------------- --- debug(127 downto 64) are local --- debug(63 downto 0) are media interface --- DEBUG_OUT <= monitor_gen_dbg(95 downto 64); - mac <= MC_UNIQUE_ID_IN(15 downto 8) & MC_UNIQUE_ID_IN(23 downto 16) & MC_UNIQUE_ID_IN(31 downto 24) & x"0" & MC_UNIQUE_ID_IN(35 downto 32) & x"7ada"; MAKE_RESET_OUT <= '1' when make_reset = '1' else '0'; @@ -170,8 +165,7 @@ begin MY_IP_OUT => my_ip(31 downto 0), MY_TRBNET_ADDRESS_IN => MY_TRBNET_ADDRESS_IN, ISSUE_REBOOT_OUT => issue_reboot, - MAC_READY_CONF_IN => LINK_ACTIVE_IN, - MAC_AN_READY_IN => PCS_AN_READY_IN, + LINK_ACTIVE_IN => LINK_ACTIVE_IN, -- MAC RX stuff MAC_RX_DATA_IN => MAC_RX_DATA_IN, MAC_RX_WRITE_IN => MAC_RX_WRITE_IN, @@ -218,7 +212,7 @@ begin MONITOR_TX_BYTES_OUT => monitor_tx_bytes, MONITOR_TX_PACKETS_OUT => monitor_tx_packets, MONITOR_DROPPED_OUT => monitor_dropped, - MONITOR_GEN_DBG_OUT => monitor_gen_dbg, + MONITOR_GEN_DBG_OUT => open, -- MAKE_RESET_OUT => make_reset, DEBUG_OUT => DEBUG_OUT --open diff --git a/gbe_trb/protocols/gbe_response_constructor_ARP.vhd b/gbe_trb/protocols/gbe_response_constructor_ARP.vhd index 6e26a70..4e988c4 100644 --- a/gbe_trb/protocols/gbe_response_constructor_ARP.vhd +++ b/gbe_trb/protocols/gbe_response_constructor_ARP.vhd @@ -1,7 +1,7 @@ library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; - + library work; use work.gbe_protocols.all; @@ -9,7 +9,7 @@ entity gbe_response_constructor_ARP is port ( CLK : in std_logic; -- system clock RESET : in std_logic; --- INTERFACE +-- INTERFACE MY_MAC_IN : in std_logic_vector(47 downto 0); MY_IP_IN : in std_logic_vector(31 downto 0); PS_DATA_IN : in std_logic_vector(8 downto 0); @@ -29,8 +29,8 @@ entity gbe_response_constructor_ARP is TC_DATA_OUT : out std_logic_vector(8 downto 0); TC_FRAME_SIZE_OUT : out std_logic_vector(15 downto 0); TC_FRAME_TYPE_OUT : out std_logic_vector(15 downto 0); - TC_IP_PROTOCOL_OUT : out std_logic_vector(7 downto 0); - TC_IDENT_OUT : out std_logic_vector(15 downto 0); + TC_IP_PROTOCOL_OUT : out std_logic_vector(7 downto 0); + TC_IDENT_OUT : out std_logic_vector(15 downto 0); TC_DEST_MAC_OUT : out std_logic_vector(47 downto 0); TC_DEST_IP_OUT : out std_logic_vector(31 downto 0); TC_DEST_UDP_OUT : out std_logic_vector(15 downto 0); @@ -95,11 +95,11 @@ begin end if; end process PROC_DISSECT_FSM; - PROC_DISSECT_TRANSITIONS : process( dissect_current_state, MY_IP_IN, PS_WR_EN_IN, PS_ACTIVATE_IN, + PROC_DISSECT_TRANSITIONS : process( dissect_current_state, MY_IP_IN, PS_WR_EN_IN, PS_ACTIVATE_IN, PS_DATA_IN, data_ctr, PS_SELECTED_IN, saved_target_ip ) begin case dissect_current_state is - + when IDLE => state <= x"1"; if (PS_WR_EN_IN = '1' and PS_ACTIVATE_IN = '1') then @@ -107,7 +107,7 @@ begin else dissect_next_state <= IDLE; end if; - + when READ_FRAME => state <= x"2"; if (PS_DATA_IN(8) = '1') then @@ -115,7 +115,7 @@ begin else dissect_next_state <= READ_FRAME; end if; - + when DECIDE => state <= x"3"; if (saved_target_ip = MY_IP_IN) then @@ -124,7 +124,7 @@ begin else dissect_next_state <= IDLE; end if; - + when WAIT_FOR_LOAD => state <= x"4"; if (PS_SELECTED_IN = '1') then @@ -140,11 +140,11 @@ begin else dissect_next_state <= LOAD_FRAME; end if; - + when CLEANUP => state <= x"e"; dissect_next_state <= IDLE; - + end case; end process PROC_DISSECT_TRANSITIONS; @@ -178,7 +178,7 @@ begin elsif( rising_edge(CLK) ) then if (dissect_current_state = READ_FRAME) then case (data_ctr) is - + when 6 => saved_opcode(7 downto 0) <= PS_DATA_IN(7 downto 0); when 7 => @@ -199,7 +199,7 @@ begin saved_target_ip(23 downto 16) <= PS_DATA_IN(7 downto 0); when 26 => saved_target_ip(31 downto 24) <= PS_DATA_IN(7 downto 0); - + when others => null; end case; end if; @@ -210,7 +210,7 @@ begin begin if( rising_edge(CLK) ) then tc_data(8) <= '0'; - + if (dissect_current_state = LOAD_FRAME) then for i in 0 to 7 loop tc_data(i) <= values((data_ctr - 1) * 8 + i); @@ -220,12 +220,12 @@ begin tc_data(8) <= '1'; end if; else - tc_data(7 downto 0) <= (others => '0'); + tc_data(7 downto 0) <= (others => '0'); end if; - + TC_DATA_OUT <= tc_data; - - end if; + + end if; end process PROC_TC_DATA; PROC_PS_RESPONSE_SYNC: process( CLK ) @@ -236,13 +236,13 @@ begin else PS_RESPONSE_READY_OUT <= '0'; end if; - + if( dissect_current_state = IDLE ) then PS_BUSY_OUT <= '0'; else PS_BUSY_OUT <= '1'; end if; - end if; + end if; end process PROC_PS_RESPONSE_SYNC; TC_FRAME_SIZE_OUT <= x"001c"; -- fixed frame size diff --git a/gbe_trb/protocols/gbe_response_constructor_DHCP.vhd b/gbe_trb/protocols/gbe_response_constructor_DHCP.vhd index c5291f1..45f1162 100644 --- a/gbe_trb/protocols/gbe_response_constructor_DHCP.vhd +++ b/gbe_trb/protocols/gbe_response_constructor_DHCP.vhd @@ -1,679 +1,684 @@ -library ieee; - use ieee.std_logic_1164.all; - use ieee.numeric_std.all; - -library work; - use work.gbe_protocols.all; - -entity gbe_response_constructor_DHCP is - port( - CLK : in std_logic; -- system clock - RESET : in std_logic; - -- INTERFACE - MY_MAC_IN : in std_logic_vector(47 downto 0); - MY_IP_IN : in std_logic_vector(31 downto 0); - PS_DATA_IN : in std_logic_vector(8 downto 0); - PS_WR_EN_IN : in std_logic; - PS_ACTIVATE_IN : in std_logic; - PS_RESPONSE_READY_OUT : out std_logic; - PS_BUSY_OUT : out std_logic; - PS_SELECTED_IN : in 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); - PS_SRC_IP_ADDRESS_IN : in std_logic_vector(31 downto 0); - 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); - -- - TC_RD_EN_IN : in std_logic; - TC_DATA_OUT : out std_logic_vector(8 downto 0); - TC_FRAME_SIZE_OUT : out std_logic_vector(15 downto 0); - TC_FRAME_TYPE_OUT : out std_logic_vector(15 downto 0); - TC_IP_PROTOCOL_OUT : out std_logic_vector(7 downto 0); - TC_IDENT_OUT : out std_logic_vector(15 downto 0); - TC_DEST_MAC_OUT : out std_logic_vector(47 downto 0); - TC_DEST_IP_OUT : out std_logic_vector(31 downto 0); - TC_DEST_UDP_OUT : out std_logic_vector(15 downto 0); - TC_SRC_MAC_OUT : out std_logic_vector(47 downto 0); - TC_SRC_IP_OUT : out std_logic_vector(31 downto 0); - TC_SRC_UDP_OUT : out std_logic_vector(15 downto 0); - -- END OF INTERFACE - MY_IP_OUT : out std_logic_vector(31 downto 0); - DHCP_START_IN : in std_logic; - DHCP_DONE_OUT : out std_logic; - -- debug - DEBUG_OUT : out std_logic_vector(63 downto 0) - ); -end gbe_response_constructor_DHCP; - - -architecture gbe_response_constructor_DHCP_arch of gbe_response_constructor_DHCP is - - attribute syn_encoding : string; - - type main_states is (BOOTING, DELAY, SENDING_DISCOVER, WAITING_FOR_OFFER, SENDING_REQUEST, WAITING_FOR_ACK, ESTABLISHED); - signal main_current_state, main_next_state : main_states; - attribute syn_encoding of main_current_state: signal is "onehot"; - - type receive_states is (IDLE, DISCARD, CLEANUP, SAVE_VALUES); - signal receive_current_state, receive_next_state : receive_states; - attribute syn_encoding of receive_current_state: signal is "onehot"; - - type discover_states is (IDLE, WAIT_FOR_LOAD, BOOTP_HEADERS, CLIENT_IP, YOUR_IP, ZEROS1, MY_MAC, ZEROS2, VENDOR_VALS, VENDOR_VALS2, TERMINATION, CLEANUP); - signal construct_current_state, construct_next_state : discover_states; - attribute syn_encoding of construct_current_state: signal is "onehot"; - - type stats_states is (IDLE, LOAD_SENT, LOAD_RECEIVED, LOAD_DISCARDED, CLEANUP); - signal stats_current_state, stats_next_state : stats_states; - attribute syn_encoding of stats_current_state : signal is "onehot"; - - signal state : std_logic_vector(3 downto 0); - signal rec_frames : std_logic_vector(15 downto 0); - signal sent_frames : unsigned(15 downto 0); - - signal wait_ctr : unsigned(31 downto 0); -- wait for 5 sec before sending request - signal load_ctr : integer range 0 to 600 := 0; - - signal bootp_hdr : std_logic_vector(95 downto 0); - - signal tc_data : std_logic_vector(8 downto 0); - signal vendor_values : std_logic_vector(175 downto 0); - signal save_ctr : integer range 0 to 600 := 0; - signal saved_transaction_id : std_logic_vector(31 downto 0); - signal saved_proposed_ip : std_logic_vector(31 downto 0); - signal saved_dhcp_type : std_logic_vector(23 downto 0); - signal saved_true_ip : std_logic_vector(31 downto 0); - signal transaction_id : std_logic_vector(31 downto 0); - signal client_ip_reg : std_logic_vector(31 downto 0); - signal your_ip_reg : std_logic_vector(31 downto 0); - signal saved_server_mac : std_logic_vector(47 downto 0); - signal saved_server_ip : std_logic_vector(31 downto 0); - signal state2 : std_logic_vector(3 downto 0); - signal state3 : std_logic_vector(3 downto 0); - signal vendor_values2 : std_logic_vector(47 downto 0); - - signal discarded_ctr : std_logic_vector(15 downto 0); - - signal stat_data_temp : std_logic_vector(31 downto 0); - - attribute syn_preserve : boolean; - attribute syn_keep : boolean; - attribute syn_keep of state, state2 : signal is true; - attribute syn_preserve of state, state2 : signal is true; - - signal wait_value : unsigned(31 downto 0); - - signal my_ip : std_logic_vector(31 downto 0); - -begin - - -- **** - -- fixing the constant values for DHCP request headers - TC_DEST_MAC_OUT <= x"ffffffffffff" when (main_current_state = BOOTING or main_current_state = SENDING_DISCOVER) else saved_server_mac; - TC_DEST_IP_OUT <= x"ffffffff" when (main_current_state = BOOTING or main_current_state = SENDING_DISCOVER) else saved_server_ip; - TC_DEST_UDP_OUT <= x"4300"; - TC_SRC_MAC_OUT <= MY_MAC_IN; - TC_SRC_IP_OUT <= x"00000000" when (main_current_state = BOOTING or main_current_state = SENDING_DISCOVER) else saved_proposed_ip; - TC_SRC_UDP_OUT <= x"4400"; - TC_IP_PROTOCOL_OUT <= x"11"; -- udp - bootp_hdr(7 downto 0) <= x"01"; -- message type(request) - bootp_hdr(15 downto 8) <= x"01"; -- hardware type (eth) - bootp_hdr(23 downto 16) <= x"06"; -- hardware address length - bootp_hdr(31 downto 24) <= x"00"; -- hops - bootp_hdr(63 downto 32) <= transaction_id; -- transaction id; - bootp_hdr(95 downto 64) <= x"0000_0000"; -- seconds elapsed/flags - transaction_id <= x"cefa" & MY_MAC_IN(47 downto 40) & MY_MAC_IN(23 downto 16); - vendor_values(31 downto 0) <= x"63538263"; -- magic cookie (dhcp message) - vendor_values(55 downto 32) <= x"010135" when (main_current_state = BOOTING or main_current_state = SENDING_DISCOVER) else x"030135"; -- dhcp discover, then dhcp request - vendor_values(79 downto 56) <= x"01073d"; -- client identifier - vendor_values(127 downto 80) <= MY_MAC_IN; -- client identifier - vendor_values(143 downto 128) <= x"040c"; -- client name - vendor_values(175 downto 144) <= x"33425254"; -- client name (TRB3) - --vendor_values(175 downto 144) <= x"6f72694b"; -- client name (Kiro) - vendor_values2(15 downto 0) <= x"0436"; -- server identifier - vendor_values2(47 downto 16) <= saved_server_ip; - - --***************** - -- setting of global variable for IP address - my_ip <= saved_true_ip when main_current_state = ESTABLISHED else (others => '0'); - MY_IP_OUT <= my_ip; - -- - --***************** - - PROC_SAVE_SERVER_ADDR: process( CLK ) - begin - if( rising_edge(CLK) ) then - if ( main_current_state = BOOTING ) then - saved_server_mac <= (others => '0'); - saved_server_ip <= (others => '0'); - elsif( (main_current_state = WAITING_FOR_OFFER) and (receive_current_state = SAVE_VALUES and save_ctr = 1) ) then - saved_server_mac <= PS_SRC_MAC_ADDRESS_IN; - saved_server_ip <= PS_SRC_IP_ADDRESS_IN; - end if; - end if; - end process PROC_SAVE_SERVER_ADDR; - - - -- **** MAIN MACHINE PART - - PROC_MAIN_FSM: process( CLK, RESET) - begin - if ( RESET = '1' ) then - main_current_state <= BOOTING; - elsif( rising_edge(CLK) ) then - main_current_state <= main_next_state; - end if; - end process PROC_MAIN_FSM; - - wait_value <= x"2000_0000"; - - PROC_MAIN_TRANSITIONS : process(main_current_state, DHCP_START_IN, construct_current_state, wait_ctr, receive_current_state, PS_DATA_IN, wait_value) - begin - state2 <= x"0"; - - case (main_current_state) is - - when BOOTING => - state2 <= x"1"; - if (DHCP_START_IN = '1') then - main_next_state <= DELAY; - else - main_next_state <= BOOTING; - end if; - - when DELAY => - state2 <= x"2"; - if (wait_ctr = wait_value) then - main_next_state <= SENDING_DISCOVER; - else - main_next_state <= DELAY; - end if; - - when SENDING_DISCOVER => - state2 <= x"3"; - if (construct_current_state = CLEANUP) then - main_next_state <= WAITING_FOR_OFFER; - else - main_next_state <= SENDING_DISCOVER; - end if; - - when WAITING_FOR_OFFER => - state2 <= x"4"; - if (receive_current_state = SAVE_VALUES) and (PS_DATA_IN(8) = '1') then - main_next_state <= SENDING_REQUEST; - elsif (wait_ctr = x"2000_0000") then - main_next_state <= BOOTING; - else - main_next_state <= WAITING_FOR_OFFER; - end if; - - when SENDING_REQUEST => - state2 <= x"5"; - if (construct_current_state = CLEANUP) then - main_next_state <= WAITING_FOR_ACK; - else - main_next_state <= SENDING_REQUEST; - end if; - - when WAITING_FOR_ACK => - state2 <= x"6"; - if (receive_current_state = SAVE_VALUES) and (PS_DATA_IN(8) = '1') then - main_next_state <= ESTABLISHED; - elsif (wait_ctr = x"2000_0000") then - main_next_state <= BOOTING; - else - main_next_state <= WAITING_FOR_ACK; - end if; - - when ESTABLISHED => - state2 <= x"7"; - main_next_state <= ESTABLISHED; - - when others => main_next_state <= BOOTING; - - end case; - - end process PROC_MAIN_TRANSITIONS; - - PROC_WAIT_CTR: process( CLK ) - begin - if( rising_edge(CLK) ) then - if ( main_current_state = SENDING_DISCOVER or main_current_state = SENDING_REQUEST or main_current_state = BOOTING ) then - wait_ctr <= (others => '0'); - elsif( main_current_state = WAITING_FOR_ACK and receive_current_state = SAVE_VALUES and PS_DATA_IN(8) = '1' ) then - wait_ctr <= (others => '0'); - elsif( main_current_state = WAITING_FOR_ACK or main_current_state = WAITING_FOR_OFFER or main_current_state = DELAY or main_current_state = ESTABLISHED ) then - wait_ctr <= wait_ctr + 1; - end if; - end if; - end process PROC_WAIT_CTR; - - DHCP_DONE_OUT <= '1' when main_current_state = ESTABLISHED else '0'; - - -- **** MESSAGES RECEIVING PART - - PROC_RECEIVE_FSM: process( CLK, RESET ) - begin - if ( RESET = '1' ) then - receive_current_state <= IDLE; - elsif( rising_edge(CLK) ) then - receive_current_state <= receive_next_state; - end if; - end process PROC_RECEIVE_FSM; - - PROC_RECEIVE_TRANSITIONS: process( receive_current_state, main_current_state, bootp_hdr, saved_dhcp_type, saved_transaction_id, - PS_DATA_IN, PS_DEST_MAC_ADDRESS_IN, MY_MAC_IN, PS_ACTIVATE_IN, PS_WR_EN_IN, save_ctr ) - begin - state3 <= x"0"; - - case receive_current_state is - - when IDLE => - state3 <= x"1"; - if (PS_ACTIVATE_IN = '1' and PS_WR_EN_IN = '1') then - if (main_current_state = WAITING_FOR_OFFER or main_current_state = 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) - receive_next_state <= SAVE_VALUES; - else - receive_next_state <= DISCARD; -- discard if the frame is not for me - end if; - else - receive_next_state <= DISCARD; -- discard if the frame arrived at wrong time - end if; - else - receive_next_state <= IDLE; - end if; - - when SAVE_VALUES => - state3 <= x"2"; - if (PS_DATA_IN(8) = '1') then - receive_next_state <= CLEANUP; - -- check if the same transaction - elsif (save_ctr = 9) and (saved_transaction_id /= bootp_hdr(63 downto 32)) then - receive_next_state <= DISCARD; - -- if the wrong message at the wrong time - elsif (main_current_state = WAITING_FOR_OFFER) and (save_ctr = 242) and (saved_dhcp_type /= x"020135") then - receive_next_state <= DISCARD; - -- if the wrong message at the wrong time - elsif (main_current_state = WAITING_FOR_ACK) and (save_ctr = 242) and (saved_dhcp_type /= x"050135") then - receive_next_state <= DISCARD; - else - receive_next_state <= SAVE_VALUES; - end if; - - when DISCARD => - state3 <= x"3"; - if (PS_DATA_IN(8) = '1') then - receive_next_state <= CLEANUP; - else - receive_next_state <= DISCARD; - end if; - - when CLEANUP => - state3 <= x"4"; - receive_next_state <= IDLE; - - when others => receive_next_state <= IDLE; - - end case; - - end process PROC_RECEIVE_TRANSITIONS; - - PROC_SAVE_CTR: process( CLK ) - begin - if( rising_edge(CLK) ) then - if ( receive_current_state = IDLE ) then - save_ctr <= 0; - elsif( receive_current_state = SAVE_VALUES and PS_WR_EN_IN = '1' and PS_ACTIVATE_IN = '1' ) then - save_ctr <= save_ctr + 1; - end if; - end if; - end process PROC_SAVE_CTR; - - PROC_SAVE_VALUES: process( CLK ) - begin - if( rising_edge(CLK) ) then - if ( main_current_state = BOOTING ) then - saved_transaction_id <= (others => '0'); - saved_proposed_ip <= (others => '0'); - saved_true_ip <= (others => '0'); - saved_dhcp_type <= (others => '0'); - -- dissection of DHCP Offer message - elsif( main_current_state = WAITING_FOR_OFFER and receive_current_state = SAVE_VALUES ) then - - saved_true_ip <= saved_true_ip; - - case save_ctr is - - when 3 => - saved_transaction_id(7 downto 0) <= PS_DATA_IN(7 downto 0); - - when 4 => - saved_transaction_id(15 downto 8) <= PS_DATA_IN(7 downto 0); - - when 5 => - saved_transaction_id(23 downto 16) <= PS_DATA_IN(7 downto 0); - - when 6 => - saved_transaction_id(31 downto 24) <= PS_DATA_IN(7 downto 0); - - - when 15 => - saved_proposed_ip(7 downto 0) <= PS_DATA_IN(7 downto 0); - - when 16 => - saved_proposed_ip(15 downto 8) <= PS_DATA_IN(7 downto 0); - - when 17 => - saved_proposed_ip(23 downto 16) <= PS_DATA_IN(7 downto 0); - - when 18 => - saved_proposed_ip(31 downto 24) <= PS_DATA_IN(7 downto 0); - - - when 239 => - saved_dhcp_type(7 downto 0) <= PS_DATA_IN(7 downto 0); - - when 240 => - saved_dhcp_type(15 downto 8) <= PS_DATA_IN(7 downto 0); - - when 241 => - saved_dhcp_type(23 downto 16) <= PS_DATA_IN(7 downto 0); - - when others => null; - - end case; - -- dissection on DHCP Ack message - elsif( main_current_state = WAITING_FOR_ACK and receive_current_state = SAVE_VALUES ) then - - saved_proposed_ip <= saved_proposed_ip; - - case save_ctr is - - when 3 => - saved_transaction_id(7 downto 0) <= PS_DATA_IN(7 downto 0); - - when 4 => - saved_transaction_id(15 downto 8) <= PS_DATA_IN(7 downto 0); - - when 5 => - saved_transaction_id(23 downto 16) <= PS_DATA_IN(7 downto 0); - - when 6 => - saved_transaction_id(31 downto 24) <= PS_DATA_IN(7 downto 0); - - - when 15 => - saved_true_ip(7 downto 0) <= PS_DATA_IN(7 downto 0); - - when 16 => - saved_true_ip(15 downto 8) <= PS_DATA_IN(7 downto 0); - - when 17 => - saved_true_ip(23 downto 16) <= PS_DATA_IN(7 downto 0); - - when 18 => - saved_true_ip(31 downto 24) <= PS_DATA_IN(7 downto 0); - - - when 239 => - saved_dhcp_type(7 downto 0) <= PS_DATA_IN(7 downto 0); - - when 240 => - saved_dhcp_type(15 downto 8) <= PS_DATA_IN(7 downto 0); - - when 241 => - saved_dhcp_type(23 downto 16) <= PS_DATA_IN(7 downto 0); - - when others => null; - - end case; - end if; - end if; - end process PROC_SAVE_VALUES; - - -- **** MESSAGES CONSTRUCTING PART - - PROC_CONSTRUCT_FSM: process( CLK, RESET ) - begin - if ( RESET = '1' ) then - construct_current_state <= IDLE; - elsif( rising_edge(CLK) ) then - if( main_current_state = BOOTING ) then - construct_current_state <= IDLE; - else - construct_current_state <= construct_next_state; - end if; - end if; - end process PROC_CONSTRUCT_FSM; - - PROC_CONSTRUCT_TRANSITIONS: process( construct_current_state, main_current_state, load_ctr, PS_SELECTED_IN ) - begin - state <= x"0"; - - case construct_current_state is - - when IDLE => - state <= x"1"; - if (main_current_state = SENDING_DISCOVER) or (main_current_state = SENDING_REQUEST) then - construct_next_state <= WAIT_FOR_LOAD; - else - construct_next_state <= IDLE; - end if; - - when WAIT_FOR_LOAD => - state <= x"2"; - if (PS_SELECTED_IN = '1') then - construct_next_state <= BOOTP_HEADERS; - else - construct_next_state <= WAIT_FOR_LOAD; - end if; - - - when BOOTP_HEADERS => - state <= x"3"; - if (load_ctr = 11) then - construct_next_state <= CLIENT_IP; - else - construct_next_state <= BOOTP_HEADERS; - end if; - - when CLIENT_IP => - state <= x"4"; - if (load_ctr = 15) then - construct_next_state <= YOUR_IP; - else - construct_next_state <= CLIENT_IP; - end if; - - when YOUR_IP => - state <= x"5"; - if (load_ctr = 19) then - construct_next_state <= ZEROS1; - else - construct_next_state <= YOUR_IP; - end if; - - when ZEROS1 => - state <= x"6"; - if (load_ctr = 27) then - construct_next_state <= MY_MAC; - else - construct_next_state <= ZEROS1; - end if; - - when MY_MAC => - state <= x"7"; - if (load_ctr = 33) then - construct_next_state <= ZEROS2; - else - construct_next_state <= MY_MAC; - end if; - - when ZEROS2 => - state <= x"8"; - if (load_ctr = 235) then - construct_next_state <= VENDOR_VALS; - else - construct_next_state <= ZEROS2; - end if; - - when VENDOR_VALS => - state <= x"9"; - if (load_ctr = 257) then - -- for discover it's enough of values - if (main_current_state = SENDING_DISCOVER) then - construct_next_state <= TERMINATION; - -- for request there is some more values needed - else - construct_next_state <= VENDOR_VALS2; - end if; - else - construct_next_state <= VENDOR_VALS; - end if; - - when VENDOR_VALS2 => - state <= x"a"; - if (load_ctr = 263) then - construct_next_state <= TERMINATION; - else - construct_next_state <= VENDOR_VALS2; - end if; - - when TERMINATION => - state <= x"b"; - construct_next_state <= CLEANUP; - - when CLEANUP => - state <= x"c"; - construct_next_state <= IDLE; - - when others => construct_next_state <= IDLE; - - end case; - end process PROC_CONSTRUCT_TRANSITIONS; - - PROC_LOAD_CTR: process( CLK ) - begin - if( rising_edge(CLK) ) then - if ( construct_current_state = IDLE ) then - load_ctr <= 0; - elsif( (TC_RD_EN_IN = '1') and (PS_SELECTED_IN = '1') ) then - load_ctr <= load_ctr + 1; - end if; - end if; - end process PROC_LOAD_CTR; - - PROC_TC_DATA: process( CLK ) - begin - if( rising_edge(CLK) ) then - case (construct_current_state) is - - when BOOTP_HEADERS => - for i in 0 to 7 loop - tc_data(i) <= bootp_hdr(load_ctr * 8 + i); - end loop; - tc_data(8) <= '0'; - - when CLIENT_IP => - if (main_current_state = SENDING_DISCOVER) then - tc_data(7 downto 0) <= x"00"; - elsif (main_current_state = SENDING_REQUEST) then - for i in 0 to 7 loop - tc_data(i) <= saved_proposed_ip((load_ctr - 12) * 8 + i); - end loop; - end if; - tc_data(8) <= '0'; - - when YOUR_IP => - tc_data(7 downto 0) <= x"00"; - tc_data(8) <= '0'; - - when ZEROS1 => - tc_data(7 downto 0) <= x"00"; - tc_data(8) <= '0'; - - when MY_MAC => - for i in 0 to 7 loop - tc_data(i) <= MY_MAC_IN((load_ctr - 28) * 8 + i); - end loop; - tc_data(8) <= '0'; - - when ZEROS2 => - tc_data(7 downto 0) <= x"00"; - tc_data(8) <= '0'; - - when VENDOR_VALS => - for i in 0 to 7 loop - tc_data(i) <= vendor_values((load_ctr - 236) * 8 + i); - end loop; - tc_data(8) <= '0'; - - -- needed only for DHCP Request message - when VENDOR_VALS2 => - for i in 0 to 7 loop - tc_data(i) <= vendor_values2((load_ctr - 258) * 8 + i); - end loop; - tc_data(8) <= '0'; - - when TERMINATION => - tc_data(7 downto 0) <= x"ff"; - tc_data(8) <= '1'; - - when others => - tc_data(7 downto 0) <= x"00"; - tc_data(8) <= '0'; - - end case; - - TC_DATA_OUT <= tc_data; - - end if; - end process PROC_TC_DATA; - - PROC_PS_RESPONSE_SYNC: process( CLK ) - begin - if( rising_edge(CLK) ) then - if( construct_current_state = IDLE or construct_current_state = CLEANUP ) then - PS_RESPONSE_READY_OUT <= '0'; - else - PS_RESPONSE_READY_OUT <= '1'; - end if; - - if( construct_current_state = IDLE ) then - PS_BUSY_OUT <= '0'; - else - PS_BUSY_OUT <= '1'; - end if; - end if; - end process PROC_PS_RESPONSE_SYNC; - - -- fixed sizes for discover and request messages - TC_FRAME_SIZE_OUT <= x"0103" when (main_current_state = SENDING_DISCOVER) else x"0109"; - TC_FRAME_TYPE_OUT <= x"0008"; -- frame type: ip - TC_IDENT_OUT <= x"1" & std_logic_vector(sent_frames(11 downto 0)); - - PROC_SENT_FRAMES: process( CLK ) - begin - if ( RESET = '1') then - sent_frames <= (others => '0'); - elsif( rising_edge(CLK) ) then - if( construct_current_state = CLEANUP ) then - sent_frames <= sent_frames + 1; - end if; - end if; - end process PROC_SENT_FRAMES; - - -- **** debug - PROC_DEBUG: process( CLK ) - begin - if( rising_edge(CLK) ) then - DEBUG_OUT(3 downto 0) <= state; - DEBUG_OUT(7 downto 4) <= state2; - DEBUG_OUT(11 downto 8) <= state3; - end if; - end process PROC_DEBUG; - - -- **** - -end gbe_response_constructor_DHCP_arch; +library ieee; + use ieee.std_logic_1164.all; + use ieee.numeric_std.all; + +library work; + use work.gbe_protocols.all; + +entity gbe_response_constructor_DHCP is + port( + CLK : in std_logic; -- system clock + RESET : in std_logic; + -- INTERFACE + MY_MAC_IN : in std_logic_vector(47 downto 0); + MY_IP_IN : in std_logic_vector(31 downto 0); + PS_DATA_IN : in std_logic_vector(8 downto 0); + PS_WR_EN_IN : in std_logic; + PS_ACTIVATE_IN : in std_logic; + PS_RESPONSE_READY_OUT : out std_logic; + PS_BUSY_OUT : out std_logic; + PS_SELECTED_IN : in 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); + PS_SRC_IP_ADDRESS_IN : in std_logic_vector(31 downto 0); + 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); + -- + TC_RD_EN_IN : in std_logic; + TC_DATA_OUT : out std_logic_vector(8 downto 0); + TC_FRAME_SIZE_OUT : out std_logic_vector(15 downto 0); + TC_FRAME_TYPE_OUT : out std_logic_vector(15 downto 0); + TC_IP_PROTOCOL_OUT : out std_logic_vector(7 downto 0); + TC_IDENT_OUT : out std_logic_vector(15 downto 0); + TC_DEST_MAC_OUT : out std_logic_vector(47 downto 0); + TC_DEST_IP_OUT : out std_logic_vector(31 downto 0); + TC_DEST_UDP_OUT : out std_logic_vector(15 downto 0); + TC_SRC_MAC_OUT : out std_logic_vector(47 downto 0); + TC_SRC_IP_OUT : out std_logic_vector(31 downto 0); + TC_SRC_UDP_OUT : out std_logic_vector(15 downto 0); + -- END OF INTERFACE + MY_IP_OUT : out std_logic_vector(31 downto 0); + DHCP_START_IN : in std_logic; + DHCP_DONE_OUT : out std_logic; + -- debug + DEBUG_OUT : out std_logic_vector(63 downto 0) + ); +end gbe_response_constructor_DHCP; + + +architecture gbe_response_constructor_DHCP_arch of gbe_response_constructor_DHCP is + + attribute syn_encoding : string; + + type main_states is (BOOTING, DELAY, SENDING_DISCOVER, WAITING_FOR_OFFER, SENDING_REQUEST, WAITING_FOR_ACK, ESTABLISHED); + signal main_current_state, main_next_state : main_states; + attribute syn_encoding of main_current_state: signal is "onehot"; + + type receive_states is (IDLE, DISCARD, CLEANUP, SAVE_VALUES); + signal receive_current_state, receive_next_state : receive_states; + attribute syn_encoding of receive_current_state: signal is "onehot"; + + type discover_states is (IDLE, WAIT_FOR_LOAD, BOOTP_HEADERS, CLIENT_IP, YOUR_IP, ZEROS1, MY_MAC, ZEROS2, VENDOR_VALS, VENDOR_VALS2, TERMINATION, CLEANUP); + signal construct_current_state, construct_next_state : discover_states; + attribute syn_encoding of construct_current_state: signal is "onehot"; + + type stats_states is (IDLE, LOAD_SENT, LOAD_RECEIVED, LOAD_DISCARDED, CLEANUP); + signal stats_current_state, stats_next_state : stats_states; + attribute syn_encoding of stats_current_state : signal is "onehot"; + + signal state : std_logic_vector(3 downto 0); + signal rec_frames : std_logic_vector(15 downto 0); + signal sent_frames : unsigned(15 downto 0); + + signal wait_ctr : unsigned(31 downto 0); -- wait for 5 sec before sending request + signal load_ctr : integer range 0 to 600 := 0; + + signal bootp_hdr : std_logic_vector(95 downto 0); + + signal tc_data : std_logic_vector(8 downto 0); + signal vendor_values : std_logic_vector(175 downto 0); + signal save_ctr : integer range 0 to 600 := 0; + signal saved_transaction_id : std_logic_vector(31 downto 0); + signal saved_proposed_ip : std_logic_vector(31 downto 0); + signal saved_dhcp_type : std_logic_vector(23 downto 0); + signal saved_true_ip : std_logic_vector(31 downto 0); + signal transaction_id : std_logic_vector(31 downto 0); + signal client_ip_reg : std_logic_vector(31 downto 0); + signal your_ip_reg : std_logic_vector(31 downto 0); + signal saved_server_mac : std_logic_vector(47 downto 0); + signal saved_server_ip : std_logic_vector(31 downto 0); + signal state2 : std_logic_vector(3 downto 0); + signal state3 : std_logic_vector(3 downto 0); + signal vendor_values2 : std_logic_vector(47 downto 0); + + signal discarded_ctr : std_logic_vector(15 downto 0); + + signal stat_data_temp : std_logic_vector(31 downto 0); + + attribute syn_preserve : boolean; + attribute syn_keep : boolean; + attribute syn_keep of state, state2 : signal is true; + attribute syn_preserve of state, state2 : signal is true; + + signal wait_value : unsigned(31 downto 0); + + signal my_ip : std_logic_vector(31 downto 0); + +begin + + -- **** + -- fixing the constant values for DHCP request headers + TC_DEST_MAC_OUT <= x"ffffffffffff" when (main_current_state = BOOTING or main_current_state = SENDING_DISCOVER) else saved_server_mac; + TC_DEST_IP_OUT <= x"ffffffff" when (main_current_state = BOOTING or main_current_state = SENDING_DISCOVER) else saved_server_ip; + TC_DEST_UDP_OUT <= x"4300"; + TC_SRC_MAC_OUT <= MY_MAC_IN; + TC_SRC_IP_OUT <= x"00000000" when (main_current_state = BOOTING or main_current_state = SENDING_DISCOVER) else saved_proposed_ip; + TC_SRC_UDP_OUT <= x"4400"; + TC_IP_PROTOCOL_OUT <= x"11"; -- udp + bootp_hdr(7 downto 0) <= x"01"; -- message type(request) + bootp_hdr(15 downto 8) <= x"01"; -- hardware type (eth) + bootp_hdr(23 downto 16) <= x"06"; -- hardware address length + bootp_hdr(31 downto 24) <= x"00"; -- hops + bootp_hdr(63 downto 32) <= transaction_id; -- transaction id; + bootp_hdr(95 downto 64) <= x"0000_0000"; -- seconds elapsed/flags + transaction_id <= x"cefa" & MY_MAC_IN(47 downto 40) & MY_MAC_IN(23 downto 16); + vendor_values(31 downto 0) <= x"63538263"; -- magic cookie (dhcp message) + vendor_values(55 downto 32) <= x"010135" when (main_current_state = BOOTING or main_current_state = SENDING_DISCOVER) else x"030135"; -- dhcp discover, then dhcp request + vendor_values(79 downto 56) <= x"01073d"; -- client identifier + vendor_values(127 downto 80) <= MY_MAC_IN; -- client identifier + vendor_values(143 downto 128) <= x"040c"; -- client name + vendor_values(175 downto 144) <= x"33425254"; -- client name (TRB3) + --vendor_values(175 downto 144) <= x"6f72694b"; -- client name (Kiro) + vendor_values2(15 downto 0) <= x"0436"; -- server identifier + vendor_values2(47 downto 16) <= saved_server_ip; + + --***************** + -- setting of global variable for IP address + my_ip <= saved_true_ip when main_current_state = ESTABLISHED else (others => '0'); + MY_IP_OUT <= my_ip; + -- + --***************** + + PROC_SAVE_SERVER_ADDR: process( CLK ) + begin + if( rising_edge(CLK) ) then + if ( main_current_state = BOOTING ) then + saved_server_mac <= (others => '0'); + saved_server_ip <= (others => '0'); + elsif( (main_current_state = WAITING_FOR_OFFER) and (receive_current_state = SAVE_VALUES and save_ctr = 1) ) then + saved_server_mac <= PS_SRC_MAC_ADDRESS_IN; + saved_server_ip <= PS_SRC_IP_ADDRESS_IN; + end if; + end if; + end process PROC_SAVE_SERVER_ADDR; + + + -- **** MAIN MACHINE PART + + PROC_MAIN_FSM: process( CLK, RESET) + begin + if ( RESET = '1' ) then + main_current_state <= BOOTING; + elsif( rising_edge(CLK) ) then + main_current_state <= main_next_state; + end if; + end process PROC_MAIN_FSM; + + wait_value <= x"2000_0000"; +-- wait_value <= x"0000_2000"; + + PROC_MAIN_TRANSITIONS : process(main_current_state, DHCP_START_IN, construct_current_state, wait_ctr, receive_current_state, PS_DATA_IN, wait_value) + begin + state2 <= x"0"; + + case (main_current_state) is + + when BOOTING => + state2 <= x"1"; + if (DHCP_START_IN = '1') then + main_next_state <= DELAY; + else + main_next_state <= BOOTING; + end if; + + when DELAY => + state2 <= x"2"; + if (wait_ctr = wait_value) then + main_next_state <= SENDING_DISCOVER; + else + main_next_state <= DELAY; + end if; + + when SENDING_DISCOVER => + state2 <= x"3"; + if (construct_current_state = CLEANUP) then + main_next_state <= WAITING_FOR_OFFER; + else + main_next_state <= SENDING_DISCOVER; + end if; + + when WAITING_FOR_OFFER => + state2 <= x"4"; + if (receive_current_state = SAVE_VALUES) and (PS_DATA_IN(8) = '1') then + main_next_state <= SENDING_REQUEST; + elsif (wait_ctr = x"2000_0000") then + main_next_state <= BOOTING; + else + main_next_state <= WAITING_FOR_OFFER; + end if; + + when SENDING_REQUEST => + state2 <= x"5"; + if (construct_current_state = CLEANUP) then + main_next_state <= WAITING_FOR_ACK; + else + main_next_state <= SENDING_REQUEST; + end if; + + when WAITING_FOR_ACK => + state2 <= x"6"; + if (receive_current_state = SAVE_VALUES) and (PS_DATA_IN(8) = '1') then + main_next_state <= ESTABLISHED; + elsif (wait_ctr = x"2000_0000") then + main_next_state <= BOOTING; + else + main_next_state <= WAITING_FOR_ACK; + end if; + + when ESTABLISHED => + state2 <= x"7"; + if( DHCP_START_IN = '0' ) then + main_next_state <= BOOTING; + else + main_next_state <= ESTABLISHED; + end if; + + when others => main_next_state <= BOOTING; + + end case; + + end process PROC_MAIN_TRANSITIONS; + + PROC_WAIT_CTR: process( CLK ) + begin + if( rising_edge(CLK) ) then + if ( main_current_state = SENDING_DISCOVER or main_current_state = SENDING_REQUEST or main_current_state = BOOTING ) then + wait_ctr <= (others => '0'); + elsif( main_current_state = WAITING_FOR_ACK and receive_current_state = SAVE_VALUES and PS_DATA_IN(8) = '1' ) then + wait_ctr <= (others => '0'); + elsif( main_current_state = WAITING_FOR_ACK or main_current_state = WAITING_FOR_OFFER or main_current_state = DELAY or main_current_state = ESTABLISHED ) then + wait_ctr <= wait_ctr + 1; + end if; + end if; + end process PROC_WAIT_CTR; + + DHCP_DONE_OUT <= '1' when main_current_state = ESTABLISHED else '0'; + + -- **** MESSAGES RECEIVING PART + + PROC_RECEIVE_FSM: process( CLK, RESET ) + begin + if ( RESET = '1' ) then + receive_current_state <= IDLE; + elsif( rising_edge(CLK) ) then + receive_current_state <= receive_next_state; + end if; + end process PROC_RECEIVE_FSM; + + PROC_RECEIVE_TRANSITIONS: process( receive_current_state, main_current_state, bootp_hdr, saved_dhcp_type, saved_transaction_id, + PS_DATA_IN, PS_DEST_MAC_ADDRESS_IN, MY_MAC_IN, PS_ACTIVATE_IN, PS_WR_EN_IN, save_ctr ) + begin + state3 <= x"0"; + + case receive_current_state is + + when IDLE => + state3 <= x"1"; + if (PS_ACTIVATE_IN = '1' and PS_WR_EN_IN = '1') then + if (main_current_state = WAITING_FOR_OFFER or main_current_state = 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) + receive_next_state <= SAVE_VALUES; + else + receive_next_state <= DISCARD; -- discard if the frame is not for me + end if; + else + receive_next_state <= DISCARD; -- discard if the frame arrived at wrong time + end if; + else + receive_next_state <= IDLE; + end if; + + when SAVE_VALUES => + state3 <= x"2"; + if (PS_DATA_IN(8) = '1') then + receive_next_state <= CLEANUP; + -- check if the same transaction + elsif (save_ctr = 9) and (saved_transaction_id /= bootp_hdr(63 downto 32)) then + receive_next_state <= DISCARD; + -- if the wrong message at the wrong time + elsif (main_current_state = WAITING_FOR_OFFER) and (save_ctr = 242) and (saved_dhcp_type /= x"020135") then + receive_next_state <= DISCARD; + -- if the wrong message at the wrong time + elsif (main_current_state = WAITING_FOR_ACK) and (save_ctr = 242) and (saved_dhcp_type /= x"050135") then + receive_next_state <= DISCARD; + else + receive_next_state <= SAVE_VALUES; + end if; + + when DISCARD => + state3 <= x"3"; + if (PS_DATA_IN(8) = '1') then + receive_next_state <= CLEANUP; + else + receive_next_state <= DISCARD; + end if; + + when CLEANUP => + state3 <= x"4"; + receive_next_state <= IDLE; + + when others => receive_next_state <= IDLE; + + end case; + + end process PROC_RECEIVE_TRANSITIONS; + + PROC_SAVE_CTR: process( CLK ) + begin + if( rising_edge(CLK) ) then + if ( receive_current_state = IDLE ) then + save_ctr <= 0; + elsif( receive_current_state = SAVE_VALUES and PS_WR_EN_IN = '1' and PS_ACTIVATE_IN = '1' ) then + save_ctr <= save_ctr + 1; + end if; + end if; + end process PROC_SAVE_CTR; + + PROC_SAVE_VALUES: process( CLK ) + begin + if( rising_edge(CLK) ) then + if ( main_current_state = BOOTING ) then + saved_transaction_id <= (others => '0'); + saved_proposed_ip <= (others => '0'); + saved_true_ip <= (others => '0'); + saved_dhcp_type <= (others => '0'); + -- dissection of DHCP Offer message + elsif( main_current_state = WAITING_FOR_OFFER and receive_current_state = SAVE_VALUES ) then + + saved_true_ip <= saved_true_ip; + + case save_ctr is + + when 3 => + saved_transaction_id(7 downto 0) <= PS_DATA_IN(7 downto 0); + + when 4 => + saved_transaction_id(15 downto 8) <= PS_DATA_IN(7 downto 0); + + when 5 => + saved_transaction_id(23 downto 16) <= PS_DATA_IN(7 downto 0); + + when 6 => + saved_transaction_id(31 downto 24) <= PS_DATA_IN(7 downto 0); + + + when 15 => + saved_proposed_ip(7 downto 0) <= PS_DATA_IN(7 downto 0); + + when 16 => + saved_proposed_ip(15 downto 8) <= PS_DATA_IN(7 downto 0); + + when 17 => + saved_proposed_ip(23 downto 16) <= PS_DATA_IN(7 downto 0); + + when 18 => + saved_proposed_ip(31 downto 24) <= PS_DATA_IN(7 downto 0); + + + when 239 => + saved_dhcp_type(7 downto 0) <= PS_DATA_IN(7 downto 0); + + when 240 => + saved_dhcp_type(15 downto 8) <= PS_DATA_IN(7 downto 0); + + when 241 => + saved_dhcp_type(23 downto 16) <= PS_DATA_IN(7 downto 0); + + when others => null; + + end case; + -- dissection on DHCP Ack message + elsif( main_current_state = WAITING_FOR_ACK and receive_current_state = SAVE_VALUES ) then + + saved_proposed_ip <= saved_proposed_ip; + + case save_ctr is + + when 3 => + saved_transaction_id(7 downto 0) <= PS_DATA_IN(7 downto 0); + + when 4 => + saved_transaction_id(15 downto 8) <= PS_DATA_IN(7 downto 0); + + when 5 => + saved_transaction_id(23 downto 16) <= PS_DATA_IN(7 downto 0); + + when 6 => + saved_transaction_id(31 downto 24) <= PS_DATA_IN(7 downto 0); + + + when 15 => + saved_true_ip(7 downto 0) <= PS_DATA_IN(7 downto 0); + + when 16 => + saved_true_ip(15 downto 8) <= PS_DATA_IN(7 downto 0); + + when 17 => + saved_true_ip(23 downto 16) <= PS_DATA_IN(7 downto 0); + + when 18 => + saved_true_ip(31 downto 24) <= PS_DATA_IN(7 downto 0); + + + when 239 => + saved_dhcp_type(7 downto 0) <= PS_DATA_IN(7 downto 0); + + when 240 => + saved_dhcp_type(15 downto 8) <= PS_DATA_IN(7 downto 0); + + when 241 => + saved_dhcp_type(23 downto 16) <= PS_DATA_IN(7 downto 0); + + when others => null; + + end case; + end if; + end if; + end process PROC_SAVE_VALUES; + + -- **** MESSAGES CONSTRUCTING PART + + PROC_CONSTRUCT_FSM: process( CLK, RESET ) + begin + if ( RESET = '1' ) then + construct_current_state <= IDLE; + elsif( rising_edge(CLK) ) then + if( main_current_state = BOOTING ) then + construct_current_state <= IDLE; + else + construct_current_state <= construct_next_state; + end if; + end if; + end process PROC_CONSTRUCT_FSM; + + PROC_CONSTRUCT_TRANSITIONS: process( construct_current_state, main_current_state, load_ctr, PS_SELECTED_IN ) + begin + state <= x"0"; + + case construct_current_state is + + when IDLE => + state <= x"1"; + if (main_current_state = SENDING_DISCOVER) or (main_current_state = SENDING_REQUEST) then + construct_next_state <= WAIT_FOR_LOAD; + else + construct_next_state <= IDLE; + end if; + + when WAIT_FOR_LOAD => + state <= x"2"; + if (PS_SELECTED_IN = '1') then + construct_next_state <= BOOTP_HEADERS; + else + construct_next_state <= WAIT_FOR_LOAD; + end if; + + + when BOOTP_HEADERS => + state <= x"3"; + if (load_ctr = 11) then + construct_next_state <= CLIENT_IP; + else + construct_next_state <= BOOTP_HEADERS; + end if; + + when CLIENT_IP => + state <= x"4"; + if (load_ctr = 15) then + construct_next_state <= YOUR_IP; + else + construct_next_state <= CLIENT_IP; + end if; + + when YOUR_IP => + state <= x"5"; + if (load_ctr = 19) then + construct_next_state <= ZEROS1; + else + construct_next_state <= YOUR_IP; + end if; + + when ZEROS1 => + state <= x"6"; + if (load_ctr = 27) then + construct_next_state <= MY_MAC; + else + construct_next_state <= ZEROS1; + end if; + + when MY_MAC => + state <= x"7"; + if (load_ctr = 33) then + construct_next_state <= ZEROS2; + else + construct_next_state <= MY_MAC; + end if; + + when ZEROS2 => + state <= x"8"; + if (load_ctr = 235) then + construct_next_state <= VENDOR_VALS; + else + construct_next_state <= ZEROS2; + end if; + + when VENDOR_VALS => + state <= x"9"; + if (load_ctr = 257) then + -- for discover it's enough of values + if (main_current_state = SENDING_DISCOVER) then + construct_next_state <= TERMINATION; + -- for request there is some more values needed + else + construct_next_state <= VENDOR_VALS2; + end if; + else + construct_next_state <= VENDOR_VALS; + end if; + + when VENDOR_VALS2 => + state <= x"a"; + if (load_ctr = 263) then + construct_next_state <= TERMINATION; + else + construct_next_state <= VENDOR_VALS2; + end if; + + when TERMINATION => + state <= x"b"; + construct_next_state <= CLEANUP; + + when CLEANUP => + state <= x"c"; + construct_next_state <= IDLE; + + when others => construct_next_state <= IDLE; + + end case; + end process PROC_CONSTRUCT_TRANSITIONS; + + PROC_LOAD_CTR: process( CLK ) + begin + if( rising_edge(CLK) ) then + if ( construct_current_state = IDLE ) then + load_ctr <= 0; + elsif( (TC_RD_EN_IN = '1') and (PS_SELECTED_IN = '1') ) then + load_ctr <= load_ctr + 1; + end if; + end if; + end process PROC_LOAD_CTR; + + PROC_TC_DATA: process( CLK ) + begin + if( rising_edge(CLK) ) then + case (construct_current_state) is + + when BOOTP_HEADERS => + for i in 0 to 7 loop + tc_data(i) <= bootp_hdr(load_ctr * 8 + i); + end loop; + tc_data(8) <= '0'; + + when CLIENT_IP => + if (main_current_state = SENDING_DISCOVER) then + tc_data(7 downto 0) <= x"00"; + elsif (main_current_state = SENDING_REQUEST) then + for i in 0 to 7 loop + tc_data(i) <= saved_proposed_ip((load_ctr - 12) * 8 + i); + end loop; + end if; + tc_data(8) <= '0'; + + when YOUR_IP => + tc_data(7 downto 0) <= x"00"; + tc_data(8) <= '0'; + + when ZEROS1 => + tc_data(7 downto 0) <= x"00"; + tc_data(8) <= '0'; + + when MY_MAC => + for i in 0 to 7 loop + tc_data(i) <= MY_MAC_IN((load_ctr - 28) * 8 + i); + end loop; + tc_data(8) <= '0'; + + when ZEROS2 => + tc_data(7 downto 0) <= x"00"; + tc_data(8) <= '0'; + + when VENDOR_VALS => + for i in 0 to 7 loop + tc_data(i) <= vendor_values((load_ctr - 236) * 8 + i); + end loop; + tc_data(8) <= '0'; + + -- needed only for DHCP Request message + when VENDOR_VALS2 => + for i in 0 to 7 loop + tc_data(i) <= vendor_values2((load_ctr - 258) * 8 + i); + end loop; + tc_data(8) <= '0'; + + when TERMINATION => + tc_data(7 downto 0) <= x"ff"; + tc_data(8) <= '1'; + + when others => + tc_data(7 downto 0) <= x"00"; + tc_data(8) <= '0'; + + end case; + + TC_DATA_OUT <= tc_data; + + end if; + end process PROC_TC_DATA; + + PROC_PS_RESPONSE_SYNC: process( CLK ) + begin + if( rising_edge(CLK) ) then + if( construct_current_state = IDLE or construct_current_state = CLEANUP ) then + PS_RESPONSE_READY_OUT <= '0'; + else + PS_RESPONSE_READY_OUT <= '1'; + end if; + + if( construct_current_state = IDLE ) then + PS_BUSY_OUT <= '0'; + else + PS_BUSY_OUT <= '1'; + end if; + end if; + end process PROC_PS_RESPONSE_SYNC; + + -- fixed sizes for discover and request messages + TC_FRAME_SIZE_OUT <= x"0103" when (main_current_state = SENDING_DISCOVER) else x"0109"; + TC_FRAME_TYPE_OUT <= x"0008"; -- frame type: ip + TC_IDENT_OUT <= x"1" & std_logic_vector(sent_frames(11 downto 0)); + + PROC_SENT_FRAMES: process( CLK ) + begin + if ( RESET = '1') then + sent_frames <= (others => '0'); + elsif( rising_edge(CLK) ) then + if( construct_current_state = CLEANUP ) then + sent_frames <= sent_frames + 1; + end if; + end if; + end process PROC_SENT_FRAMES; + + -- **** debug +-- PROC_DEBUG: process( CLK ) +-- begin +-- if( rising_edge(CLK) ) then + DEBUG_OUT(3 downto 0) <= state; + DEBUG_OUT(7 downto 4) <= state2; + DEBUG_OUT(11 downto 8) <= state3; +-- end if; +-- end process PROC_DEBUG; + + -- **** + +end gbe_response_constructor_DHCP_arch; diff --git a/gbe_trb/protocols/gbe_response_constructor_Forward.vhd b/gbe_trb/protocols/gbe_response_constructor_Forward.vhd index 04459c2..62bb918 100644 --- a/gbe_trb/protocols/gbe_response_constructor_Forward.vhd +++ b/gbe_trb/protocols/gbe_response_constructor_Forward.vhd @@ -5,7 +5,6 @@ USE IEEE.std_logic_UNSIGNED.ALL; library work; use work.trb_net_std.all; -use work.trb_net_components.all; -- WARNING: data latency was wrong by one cycle (first byte not sent, last byte duplicated), and -- size was calculated wrong (one off). Works now FOR ME. To be tested carefully! @@ -16,7 +15,7 @@ entity gbe_response_constructor_Forward is port ( CLK : in std_logic; -- system clock RESET : in std_logic; - -- INTERFACE + -- INTERFACE MY_MAC_IN : in std_logic_vector(47 downto 0); MY_IP_IN : in std_logic_vector(31 downto 0); PS_DATA_IN : in std_logic_vector(8 downto 0); @@ -64,7 +63,7 @@ end gbe_response_constructor_Forward; architecture gbe_response_constructor_Forward_arch of gbe_response_constructor_Forward is - attribute syn_encoding : string; + attribute syn_encoding : string; type dissect_states is (IDLE, SAVE, WAIT_FOR_LOAD, LOAD, CLEANUP); signal dissect_current_state, dissect_next_state : dissect_states; @@ -98,7 +97,7 @@ architecture gbe_response_constructor_Forward_arch of gbe_response_constructor_F PROC_DISSECT_TRANSITIONS: process( dissect_current_state, FWD_SOP_IN, FWD_EOP_IN, ff_q, ff_rd_lock, PS_SELECTED_IN ) begin case dissect_current_state is - + when IDLE => state <= x"1"; if (FWD_SOP_IN = '1') then @@ -106,7 +105,7 @@ architecture gbe_response_constructor_Forward_arch of gbe_response_constructor_F else dissect_next_state <= IDLE; end if; - + when SAVE => state <= x"2"; if (FWD_EOP_IN = '1') then @@ -114,7 +113,7 @@ architecture gbe_response_constructor_Forward_arch of gbe_response_constructor_F else dissect_next_state <= SAVE; end if; - + when WAIT_FOR_LOAD => state <= x"3"; if (PS_SELECTED_IN = '0') then @@ -122,7 +121,7 @@ architecture gbe_response_constructor_Forward_arch of gbe_response_constructor_F else dissect_next_state <= WAIT_FOR_LOAD; end if; - + when LOAD => state <= x"4"; if (ff_q(8) = '1') and (ff_rd_lock = '0') then @@ -130,11 +129,11 @@ architecture gbe_response_constructor_Forward_arch of gbe_response_constructor_F else dissect_next_state <= LOAD; end if; - + when CLEANUP => state <= x"5"; dissect_next_state <= IDLE; - + end case; end process PROC_DISSECT_TRANSITIONS; @@ -149,14 +148,14 @@ architecture gbe_response_constructor_Forward_arch of gbe_response_constructor_F elsif( rising_edge(CLK) ) then if( dissect_current_state = LOAD and ff_rd_en = '1' ) then ff_rd_lock <= '0'; - else + else ff_rd_lock <= '1'; end if; end if; end process PROC_FF_RD_LOCK; - THE_FRAME_FIFO: entity fifo_4096x9 - port map( + THE_FRAME_FIFO: entity work.fifo_4096x9 + port map( Data(7 downto 0) => FWD_DATA_IN, Data(8) => local_eop, WrClock => CLK, diff --git a/gbe_trb/protocols/gbe_response_constructor_Ping.vhd b/gbe_trb/protocols/gbe_response_constructor_Ping.vhd index a9adacc..4b603bd 100644 --- a/gbe_trb/protocols/gbe_response_constructor_Ping.vhd +++ b/gbe_trb/protocols/gbe_response_constructor_Ping.vhd @@ -9,7 +9,7 @@ entity gbe_response_constructor_Ping is port( CLK : in std_logic; -- system clock RESET : in std_logic; - -- INTERFACE + -- INTERFACE MY_MAC_IN : in std_logic_vector(47 downto 0); MY_IP_IN : in std_logic_vector(31 downto 0); PS_DATA_IN : in std_logic_vector(8 downto 0); @@ -29,8 +29,8 @@ entity gbe_response_constructor_Ping is TC_DATA_OUT : out std_logic_vector(8 downto 0); TC_FRAME_SIZE_OUT : out std_logic_vector(15 downto 0); TC_FRAME_TYPE_OUT : out std_logic_vector(15 downto 0); - TC_IP_PROTOCOL_OUT : out std_logic_vector(7 downto 0); - TC_IDENT_OUT : out std_logic_vector(15 downto 0); + TC_IP_PROTOCOL_OUT : out std_logic_vector(7 downto 0); + TC_IDENT_OUT : out std_logic_vector(15 downto 0); TC_DEST_MAC_OUT : out std_logic_vector(47 downto 0); TC_DEST_IP_OUT : out std_logic_vector(31 downto 0); TC_DEST_UDP_OUT : out std_logic_vector(15 downto 0); @@ -87,38 +87,38 @@ begin PROC_DISSECT_TRANSITIONS: process( dissect_current_state, PS_WR_EN_IN, PS_SELECTED_IN, PS_ACTIVATE_IN, PS_DATA_IN, data_ctr, data_length ) begin case dissect_current_state is - + when IDLE => if (PS_WR_EN_IN = '1' and PS_ACTIVATE_IN = '1') then dissect_next_state <= READ_FRAME; else dissect_next_state <= IDLE; end if; - + when READ_FRAME => if (PS_DATA_IN(8) = '1') then dissect_next_state <= WAIT_FOR_LOAD; else dissect_next_state <= READ_FRAME; end if; - + when WAIT_FOR_LOAD => if (PS_SELECTED_IN = '1') then dissect_next_state <= LOAD_FRAME; else dissect_next_state <= WAIT_FOR_LOAD; end if; - + when LOAD_FRAME => if (data_ctr = data_length + 1) then dissect_next_state <= CLEANUP; else dissect_next_state <= LOAD_FRAME; end if; - + when CLEANUP => dissect_next_state <= IDLE; - + end case; end process PROC_DISSECT_TRANSITIONS; @@ -217,7 +217,7 @@ begin end if; end if; end process PROC_CS; - + checksum(7 downto 0) <= not std_logic_vector(checksum_rrr(7 downto 0) + checksum_lll(15 downto 8)); checksum(15 downto 8) <= not std_logic_vector(checksum_lll(7 downto 0) + checksum_rrr(15 downto 8)); @@ -225,7 +225,7 @@ begin begin if( rising_edge(CLK) ) then tc_data(8) <= '0'; - + if( dissect_current_state = LOAD_FRAME ) then if (data_ctr < 10) then -- headers for i in 0 to 7 loop @@ -235,18 +235,18 @@ begin for i in 0 to 7 loop tc_data(i) <= saved_data((data_ctr - 8 - 2) * 8 + i); end loop; - + -- mark the last byte if (data_ctr = data_length + 1) then tc_data(8) <= '1'; end if; end if; else - tc_data(7 downto 0) <= (others => '0'); + tc_data(7 downto 0) <= (others => '0'); end if; - + TC_DATA_OUT <= tc_data; - + end if; end process PROC_TC_DATA; @@ -258,13 +258,13 @@ begin else PS_RESPONSE_READY_OUT <= '0'; end if; - + if( dissect_current_state = IDLE ) then PS_BUSY_OUT <= '0'; else PS_BUSY_OUT <= '1'; end if; - end if; + end if; end process PROC_PS_RESPONSE_SYNC; TC_FRAME_SIZE_OUT <= std_logic_vector(to_unsigned(data_length, 16)); diff --git a/gbe_trb/protocols/gbe_response_constructor_SCTRL.vhd b/gbe_trb/protocols/gbe_response_constructor_SCTRL.vhd index 58e8f2e..9922009 100644 --- a/gbe_trb/protocols/gbe_response_constructor_SCTRL.vhd +++ b/gbe_trb/protocols/gbe_response_constructor_SCTRL.vhd @@ -7,13 +7,13 @@ library work; use work.gbe_protocols.all; entity gbe_response_constructor_SCTRL is - generic( + generic( SLOWCTRL_BUFFER_SIZE : integer range 1 to 4 := 1 ); port( CLK : in std_logic; -- system clock RESET : in std_logic; - -- INTERFACE + -- INTERFACE MY_MAC_IN : in std_logic_vector(47 downto 0); MY_IP_IN : in std_logic_vector(31 downto 0); PS_DATA_IN : in std_logic_vector(8 downto 0); @@ -28,13 +28,13 @@ entity gbe_response_constructor_SCTRL 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); --- +-- TC_RD_EN_IN : in std_logic; TC_DATA_OUT : out std_logic_vector(8 downto 0); TC_FRAME_SIZE_OUT : out std_logic_vector(15 downto 0); TC_FRAME_TYPE_OUT : out std_logic_vector(15 downto 0); - TC_IP_PROTOCOL_OUT : out std_logic_vector(7 downto 0); - TC_IDENT_OUT : out std_logic_vector(15 downto 0); + TC_IP_PROTOCOL_OUT : out std_logic_vector(7 downto 0); + TC_IDENT_OUT : out std_logic_vector(15 downto 0); TC_DEST_MAC_OUT : out std_logic_vector(47 downto 0); TC_DEST_IP_OUT : out std_logic_vector(31 downto 0); TC_DEST_UDP_OUT : out std_logic_vector(15 downto 0); @@ -58,16 +58,16 @@ entity gbe_response_constructor_SCTRL is MAKE_RESET_OUT : out std_logic; CFG_MAX_REPLY_SIZE_IN : in std_logic_vector(31 downto 0); -- end of protocol specific ports - MONITOR_SELECT_REC_OUT : out std_logic_vector(31 downto 0); - MONITOR_SELECT_REC_BYTES_OUT : out std_logic_vector(31 downto 0); - MONITOR_SELECT_SENT_BYTES_OUT : out std_logic_vector(31 downto 0); - MONITOR_SELECT_SENT_OUT : out std_logic_vector(31 downto 0) + MONITOR_SELECT_REC_OUT : out std_logic_vector(31 downto 0); + MONITOR_SELECT_REC_BYTES_OUT : out std_logic_vector(31 downto 0); + MONITOR_SELECT_SENT_BYTES_OUT : out std_logic_vector(31 downto 0); + MONITOR_SELECT_SENT_OUT : out std_logic_vector(31 downto 0) ); end entity gbe_response_constructor_SCTRL; architecture gbe_response_constructor_SCTRL_arch of gbe_response_constructor_SCTRL is - attribute syn_encoding : string; + attribute syn_encoding : string; type dissect_states is (IDLE, READ_FRAME, WAIT_FOR_HUB, LOAD_TO_HUB, WAIT_FOR_RESPONSE, SAVE_RESPONSE, LOAD_FRAME, WAIT_FOR_LOAD, CLEANUP); signal dissect_current_state, dissect_next_state : dissect_states; @@ -99,7 +99,7 @@ architecture gbe_response_constructor_SCTRL_arch of gbe_response_constructor_SCT signal tx_frame_loaded : std_logic_vector(15 downto 0); signal packet_num : unsigned(2 downto 0); - + -- signal init_ctr : std_logic_vector(15 downto 0); signal reply_ctr : unsigned(15 downto 0); signal rx_empty : std_logic; @@ -159,11 +159,11 @@ begin ); --TODO: change to synchronous - rx_fifo_rd <= '1' when (gsc_init_dataready = '1' and dissect_current_state = LOAD_TO_HUB) or + rx_fifo_rd <= '1' when (gsc_init_dataready = '1' and dissect_current_state = LOAD_TO_HUB) or (gsc_init_dataready = '1' and dissect_current_state = WAIT_FOR_HUB and GSC_INIT_READ_IN = '1') or (dissect_current_state = READ_FRAME and PS_DATA_IN(8) = '1') else '0'; -- preload first word - + PROC_RX_FIFO_WR_SYNC: process( CLK ) begin if( rising_edge(CLK) ) then @@ -173,7 +173,7 @@ begin else rx_fifo_wr <= '0'; end if; - + rx_fifo_data <= PS_DATA_IN; end if; end process PROC_RX_FIFO_WR_SYNC; @@ -209,10 +209,10 @@ begin GSC_INIT_DATA_OUT(15 downto 8) <= rx_fifo_q(7 downto 0); ------ TODO: change it to synchronous - GSC_INIT_PACKET_NUM_OUT <= packet_num; + GSC_INIT_PACKET_NUM_OUT <= std_logic_vector(packet_num); GSC_INIT_DATAREADY_OUT <= gsc_init_dataready; gsc_init_dataready <= '1' when (GSC_INIT_READ_IN = '1' and dissect_current_state = LOAD_TO_HUB) or --TODO Ob das so richtig ist, ohne auf fifo_rd zu schauen? - (dissect_current_state = WAIT_FOR_HUB) + (dissect_current_state = WAIT_FOR_HUB) else '0'; PROC_PACKET_NUM: process( CLK ) @@ -272,8 +272,8 @@ begin else tx_fifo_wr <= '0'; end if; - - if( saved_hdr_ctr = "010" ) then + + if( saved_hdr_ctr(2 downto 0) = "010" ) then tx_fifo_data <= '0' & PS_DATA_IN(7 downto 0) & '0' & x"02"; else tx_fifo_data(7 downto 0) <= GSC_REPLY_DATA_IN(15 downto 8); @@ -304,7 +304,7 @@ begin if( rising_edge(CLK) ) then TC_DATA_OUT(7 downto 0) <= tx_fifo_q(7 downto 0); - + if( tx_loaded_ctr = tx_data_ctr ) then TC_DATA_OUT(8) <= '1'; else @@ -370,13 +370,13 @@ begin PS_RESPONSE_READY_OUT <= '0'; end if; end if; - + if( dissect_current_state = IDLE or dissect_current_state = WAIT_FOR_RESPONSE ) then PS_BUSY_OUT <= '0'; else PS_BUSY_OUT <= '1'; end if; - end if; + end if; end process PS_RESPONSE_SYNC; TC_FRAME_TYPE_OUT <= x"0008"; @@ -390,7 +390,7 @@ begin TC_IP_PROTOCOL_OUT <= x"11"; TC_IDENT_OUT <= x"3" & std_logic_vector(reply_ctr(11 downto 0)); - TC_FRAME_SIZE_OUT <= tx_data_ctr; + TC_FRAME_SIZE_OUT <= std_logic_vector(tx_data_ctr); DISSECT_MACHINE_PROC: process( CLK, RESET ) begin @@ -401,8 +401,8 @@ begin end if; end process DISSECT_MACHINE_PROC; - DISSECT_MACHINE: process(dissect_current_state, reset_detected, too_much_data, PS_WR_EN_IN, PS_ACTIVATE_IN, - PS_DATA_IN, PS_SELECTED_IN, GSC_INIT_READ_IN, GSC_REPLY_DATAREADY_IN, tx_loaded_ctr, + DISSECT_MACHINE: process(dissect_current_state, reset_detected, too_much_data, PS_WR_EN_IN, PS_ACTIVATE_IN, + PS_DATA_IN, PS_SELECTED_IN, GSC_INIT_READ_IN, GSC_REPLY_DATAREADY_IN, tx_loaded_ctr, tx_data_ctr, rx_fifo_q, GSC_BUSY_IN) begin state <= x"0"; @@ -416,7 +416,7 @@ begin else dissect_next_state <= IDLE; end if; - + when READ_FRAME => state <= x"2"; if (PS_DATA_IN(8) = '1' and (GSC_INIT_READ_IN = '0')) then @@ -426,15 +426,15 @@ begin else dissect_next_state <= READ_FRAME; end if; - + when WAIT_FOR_HUB => state <= x"3"; if (GSC_INIT_READ_IN = '1') then dissect_next_state <= LOAD_TO_HUB; else dissect_next_state <= WAIT_FOR_HUB; - end if; - + end if; + when LOAD_TO_HUB => state <= x"4"; if ((rx_fifo_q(17) = '1') and (GSC_INIT_READ_IN = '1')) then @@ -445,8 +445,8 @@ begin end if; else dissect_next_state <= LOAD_TO_HUB; - end if; - + end if; + when WAIT_FOR_RESPONSE => state <= x"5"; if (GSC_REPLY_DATAREADY_IN = '1') then @@ -454,7 +454,7 @@ begin else dissect_next_state <= WAIT_FOR_RESPONSE; end if; - + when SAVE_RESPONSE => state <= x"6"; if (GSC_REPLY_DATAREADY_IN = '0' and GSC_BUSY_IN = '0') then @@ -465,7 +465,7 @@ begin end if; else dissect_next_state <= SAVE_RESPONSE; - end if; + end if; when WAIT_FOR_LOAD => state <= x"7"; @@ -503,7 +503,7 @@ begin end if; end if; end process RESET_DETECTED_PROC; - + MAKE_RESET_PROC: process( CLK ) begin if( rising_edge(CLK) ) then @@ -544,7 +544,7 @@ begin end if; end if; end process PROC_MRF; - MONITOR_SELECT_REC_OUT <= mon_rec_frames; + MONITOR_SELECT_REC_OUT <= std_logic_vector(mon_rec_frames); PROC_MRB: process( CLK, RESET ) begin @@ -556,7 +556,7 @@ begin end if; end if; end process PROC_MRB; - MONITOR_SELECT_REC_BYTES_OUT <= mon_rec_bytes; + MONITOR_SELECT_REC_BYTES_OUT <= std_logic_vector(mon_rec_bytes); PROC_MSF: process( CLK, RESET ) begin @@ -568,7 +568,7 @@ begin end if; end if; end process PROC_MSF; - MONITOR_SELECT_SENT_OUT <= mon_sent_frames; + MONITOR_SELECT_SENT_OUT <= std_logic_vector(mon_sent_frames); PROC_MSB: process( CLK, RESET ) begin @@ -580,7 +580,7 @@ begin end if; end if; end process PROC_MSB; - MONITOR_SELECT_SENT_BYTES_OUT <= mon_sent_bytes; + MONITOR_SELECT_SENT_BYTES_OUT <= std_logic_vector(mon_sent_bytes); -- needed for identification PROC_REPLY_CTR: process( CLK, RESET ) -- 2.43.0