]> jspc29.x-matter.uni-frankfurt.de Git - trbnet.git/commitdiff
DHCP works in simulation but fails in hardware
authorMichael Boehmer <mboehmer@ph.tum.de>
Thu, 3 Nov 2022 18:52:08 +0000 (19:52 +0100)
committerMichael Boehmer <mboehmer@ph.tum.de>
Thu, 3 Nov 2022 18:52:08 +0000 (19:52 +0100)
13 files changed:
gbe_trb/base/gbe_frame_constr.vhd
gbe_trb/base/gbe_frame_receiver.vhd
gbe_trb/base/gbe_logic_wrapper.vhd
gbe_trb/base/gbe_main_control.vhd
gbe_trb/base/gbe_protocol_selector.vhd
gbe_trb/base/gbe_receive_control.vhd
gbe_trb/base/gbe_transmit_control.vhd
gbe_trb/base/gbe_wrapper_fifo.vhd
gbe_trb/protocols/gbe_response_constructor_ARP.vhd
gbe_trb/protocols/gbe_response_constructor_DHCP.vhd
gbe_trb/protocols/gbe_response_constructor_Forward.vhd
gbe_trb/protocols/gbe_response_constructor_Ping.vhd
gbe_trb/protocols/gbe_response_constructor_SCTRL.vhd

index e2a141420156699591edb87161b52e3ddb3966c3..80fd234c26412a9ce234be2b1547401626b9c550 100644 (file)
@@ -5,14 +5,13 @@ use IEEE.std_logic_UNSIGNED.ALL;
 \r
 library work;\r
 use work.trb_net_std.all;\r
-use work.trb_net_components.all;\r
 \r
 entity gbe_frame_constr is\r
-  port( \r
+  port(\r
     -- ports for user logic\r
     RESET                   : in  std_logic;\r
     CLK                     : in  std_logic; -- 125MHz clock\r
-    LINK_OK_IN              : in  std_logic; \r
+    LINK_OK_IN              : in  std_logic;\r
     -- frame stuff\r
     WR_EN_IN                : in  std_logic;\r
     DATA_IN                 : in  std_logic_vector(7 downto 0);\r
@@ -214,8 +213,8 @@ begin
 end process THE_CONSTRUCT_PROC;\r
 \r
 --find next state of construct machine\r
-constructMachine: process( constructCurrentState, delay_ctr, FRAME_DELAY_IN, START_OF_DATA_IN, \r
-                          END_OF_DATA_IN, headers_int_counter, put_udp_headers, CUR_MAX, \r
+constructMachine: process( constructCurrentState, delay_ctr, FRAME_DELAY_IN, START_OF_DATA_IN,\r
+                          END_OF_DATA_IN, headers_int_counter, put_udp_headers, CUR_MAX,\r
                           FRAME_TYPE_IN, DEST_UDP_PORT_IN)\r
 begin\r
   constructNextState <= constructCurrentState;\r
@@ -230,7 +229,7 @@ begin
       when SRC_MAC_ADDR =>\r
         constructNextState <= FRAME_TYPE_S;\r
       when FRAME_TYPE_S =>\r
-        if( FRAME_TYPE_IN = x"0008" ) then \r
+        if( FRAME_TYPE_IN = x"0008" ) then\r
           constructNextState <= VERSION;\r
         else  -- otherwise transmit data as pure ethernet frame\r
           constructNextState <= SAVE_DATA;\r
@@ -279,7 +278,7 @@ begin
         else\r
           constructNextState <= DELAY;\r
         end if;\r
-    \r
+\r
       when others =>\r
         constructNextState <= IDLE;\r
     end case;\r
index 52b1e9a0192e66e5d403d39b532d22057a3da09e..1f07d0f8d824ebee6e35812442a260188f1edaf3 100644 (file)
@@ -60,8 +60,8 @@ entity gbe_frame_receiver is
   );\r
 end gbe_frame_receiver;\r
 \r
--- This entity receives frames from the MAC. The MAC will send the frames once they are received \r
--- from SGMII core. Start of frame is marked by 'new_frame' signal. The incoming frame will be \r
+-- This entity receives frames from the MAC. The MAC will send the frames once they are received\r
+-- from SGMII core. Start of frame is marked by 'new_frame' signal. The incoming frame will be\r
 -- reviewed, and checked if it should be forwarded to the next level.\r
 -- First check is MAC address: only broadcast frames and frames with the board's MAC address are accepted.\r
 -- VLAN tagged frames are handled, but will be checked later.\r
@@ -90,8 +90,6 @@ architecture gbe_frame_receiver_arch of gbe_frame_receiver is
 \r
   signal rec_fifo_empty                       : std_logic;\r
   signal rec_fifo_full                        : std_logic;\r
---  signal sizes_fifo_full                      : std_logic;\r
---  signal sizes_fifo_empty                     : std_logic;\r
 \r
   signal remove_ctr                           : unsigned(7 downto 0);\r
   signal new_frame                            : std_logic;\r
@@ -133,16 +131,18 @@ architecture gbe_frame_receiver_arch of gbe_frame_receiver is
 \r
   signal oob_select_x                         : std_logic;\r
   signal oob_select                           : std_logic;\r
-  \r
+\r
   signal proto_select                         : std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0);\r
 \r
   signal set_proto_x                          : std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0);\r
 \r
+  signal fucking_vhdl                         : std_logic_vector(1 downto 0);\r
+\r
 begin\r
 \r
   -- Debug lines\r
   DEBUG_OUT(31 downto 26) <= (others => '0');\r
-  \r
+\r
   DEBUG_OUT(15)           <= frame_valid_q;\r
   DEBUG_OUT(14)           <= fifo_wr_en;\r
   DEBUG_OUT(13)           <= frame_type_valid;\r
@@ -181,7 +181,7 @@ begin
   end process PROC_FILTER_FSM;\r
 \r
   PROC_FILTER_TRANSITIONS : process( filter_current_state, saved_frame_type, LINK_OK_IN, saved_proto, MY_MAC_IN,\r
-                                     saved_dest_mac, remove_ctr, new_frame, MAC_RX_EOF_IN, frame_type_valid, ALLOW_RX_IN )\r
+                                     saved_dest_mac, remove_ctr, new_frame, MAC_RX_EOF_IN, frame_type_valid, ALLOW_RX_IN)\r
   begin\r
     set_proto_x <= (others => '0');\r
     oob_select_x <= '0';\r
@@ -222,7 +222,7 @@ begin
       when REMOVE_TYPE =>\r
         state <= x"5";\r
         if( remove_ctr = x"0b" ) then\r
-          case saved_frame_type is \r
+          case saved_frame_type is\r
             when x"0800" =>\r
               -- IPv4 frame, to be investigated\r
               filter_next_state <= REMOVE_IP;\r
@@ -248,7 +248,7 @@ begin
               -- UDP, to be investigated\r
               filter_next_state <= REMOVE_UDP;\r
             when x"01" =>\r
-              -- ICMP, to be stored \r
+              -- ICMP, to be stored\r
               filter_next_state <= DELAY;\r
               set_proto_x(4) <= '1';\r
             when others =>\r
@@ -466,7 +466,7 @@ begin
     end if;\r
   end process PROC_SAVED_DEST_UDP;\r
 \r
-  PROC_FRAME_TYPE_VALID: process( CLK, RESET ) \r
+  PROC_FRAME_TYPE_VALID: process( CLK, RESET )\r
   begin\r
     if   ( RESET = '1' ) then\r
       frame_type_valid <= '0';\r
@@ -497,10 +497,10 @@ begin
   PROC_KILLER_PING: process( CLK )\r
   begin\r
     if( rising_edge(CLK) ) then\r
-      if( (filter_current_state = SAVE_FRAME) and \r
-          (saved_proto = x"01") and \r
+      if( (filter_current_state = SAVE_FRAME) and\r
+          (saved_proto = x"01") and\r
           (saved_frame_type = x"0800") and\r
-          (rx_bytes_ctr = x"001A") and \r
+          (rx_bytes_ctr = x"001A") and\r
           (rx_data(7 downto 0) = MY_TRBNET_ADDRESS_IN(7 downto 0)) and\r
           (MAC_RXD_IN = MY_TRBNET_ADDRESS_IN(15 downto 8)) ) then\r
         ISSUE_REBOOT_OUT <= '1';\r
@@ -510,14 +510,14 @@ begin
     end if;\r
   end process PROC_KILLER_PING;\r
 \r
-  -- BROKEN!!!\r
+  -- secret register\r
   PROC_SECRET_FRAME: process( CLK )\r
   begin\r
     if( rising_edge(CLK) ) then\r
-      if( (oob_select = '1') and \r
-          (saved_proto = x"11") and \r
+      if( (oob_select = '1') and\r
+          (saved_proto = x"11") and\r
           (saved_frame_type = x"0800") and\r
-          (saved_dest_udp = x"d903") and \r
+          (saved_dest_udp = x"d903") and\r
           (saved_src_udp = x"2b67") ) then\r
         oob_write <= '1';\r
       else\r
@@ -600,7 +600,7 @@ begin
     Q(47 downto 0)      => fr_dest_mac,\r
     Q(63 downto 48)     => fr_dest_udp,\r
     Q(69 downto 64)     => fr_ps,\r
-    Q(71 downto 70)     => open,\r
+    Q(71 downto 70)     => fucking_vhdl, --open,\r
     Empty               => open,\r
     Full                => open\r
   );\r
index b39514ce161fc166752fed95f6da47815617cf61..5a28c0c8b267ef7c569d37f2b76076cd48bb9a3d 100644 (file)
@@ -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;
index 4b1c52c5055885830e498e4e11457557093734c1..ceaa08692d8b11f02b24b6b0937b29b12ab5c131 100644 (file)
-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;\r
+  use ieee.std_logic_1164.all;\r
+  use ieee.numeric_std.all;\r
+\r
+library work;\r
+  use work.trb_net_std.all;\r
+  use work.gbe_protocols.all;\r
+\r
+entity gbe_main_control is\r
+  generic(\r
+    INCLUDE_SLOWCTRL     : std_logic := '0';\r
+    INCLUDE_DHCP         : std_logic := '0';\r
+    INCLUDE_ARP          : std_logic := '0';\r
+    INCLUDE_PING         : std_logic := '0';\r
+    INCLUDE_FWD          : std_logic := '0';\r
+    --\r
+    SLOWCTRL_BUFFER_SIZE : integer range 1 to 4 := 1\r
+  );\r
+  port(\r
+    CLK                           : in  std_logic; -- system clock\r
+    CLK_125                       : in  std_logic;\r
+    RESET                         : in  std_logic;\r
+    --\r
+    MC_LINK_OK_OUT                : out std_logic; -- remark: set to '1' internally\r
+    MC_DHCP_DONE_OUT              : out std_logic;\r
+    MY_IP_OUT                     : out std_logic_vector(31 downto 0);\r
+    MC_MY_MAC_IN                  : in  std_logic_vector(47 downto 0);\r
+    MY_TRBNET_ADDRESS_IN          : in  std_logic_vector(15 downto 0);\r
+    ISSUE_REBOOT_OUT              : out std_logic;\r
+    -- signals to/from receive controller\r
+    RC_FRAME_WAITING_IN           : in  std_logic;\r
+    RC_LOADING_DONE_OUT           : out std_logic;\r
+    RC_DATA_IN                    : in  std_logic_vector(8 downto 0);\r
+    RC_RD_EN_OUT                  : out std_logic;\r
+    RC_FRAME_SIZE_IN              : in  std_logic_vector(15 downto 0);\r
+    RC_FRAME_PROTO_IN             : in  std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0);\r
+    --\r
+    RC_SRC_MAC_ADDRESS_IN         : in  std_logic_vector(47 downto 0);\r
+    RC_DEST_MAC_ADDRESS_IN        : in  std_logic_vector(47 downto 0);\r
+    RC_SRC_IP_ADDRESS_IN          : in  std_logic_vector(31 downto 0);\r
+    RC_DEST_IP_ADDRESS_IN         : in  std_logic_vector(31 downto 0);\r
+    RC_SRC_UDP_PORT_IN            : in  std_logic_vector(15 downto 0);\r
+    RC_DEST_UDP_PORT_IN           : in  std_logic_vector(15 downto 0);\r
+    -- signals to/from transmit controller\r
+    TC_TRANSMIT_CTRL_OUT          : out std_logic;\r
+    TC_DATA_OUT                   : out std_logic_vector(8 downto 0);\r
+    TC_RD_EN_IN                   : in  std_logic;\r
+    TC_FRAME_SIZE_OUT             : out std_logic_vector(15 downto 0);\r
+    TC_FRAME_TYPE_OUT             : out std_logic_vector(15 downto 0);\r
+    TC_DEST_MAC_OUT               : out std_logic_vector(47 downto 0);\r
+    TC_DEST_IP_OUT                : out std_logic_vector(31 downto 0);\r
+    TC_DEST_UDP_OUT               : out std_logic_vector(15 downto 0);\r
+    TC_SRC_MAC_OUT                : out std_logic_vector(47 downto 0);\r
+    TC_SRC_IP_OUT                 : out std_logic_vector(31 downto 0);\r
+    TC_SRC_UDP_OUT                : out std_logic_vector(15 downto 0);\r
+    TC_FLAGS_OFFSET_OUT           : out std_logic_vector(15 downto 0);\r
+    TC_IP_PROTOCOL_OUT            : out std_logic_vector(7 downto 0);\r
+    TC_IDENT_OUT                  : out std_logic_vector(15 downto 0);\r
+    TC_TRANSMIT_DONE_IN           : in  std_logic;\r
+    -- signals to/from media interface\r
+    LINK_ACTIVE_IN                : in  std_logic;\r
+    -- signals to/from hub\r
+    GSC_CLK_IN                    : in  std_logic;\r
+    GSC_INIT_DATAREADY_OUT        : out std_logic;\r
+    GSC_INIT_DATA_OUT             : out std_logic_vector(15 downto 0);\r
+    GSC_INIT_PACKET_NUM_OUT       : out std_logic_vector(2 downto 0);\r
+    GSC_INIT_READ_IN              : in  std_logic;\r
+    GSC_REPLY_DATAREADY_IN        : in  std_logic;\r
+    GSC_REPLY_DATA_IN             : in  std_logic_vector(15 downto 0);\r
+    GSC_REPLY_PACKET_NUM_IN       : in  std_logic_vector(2 downto 0);\r
+    GSC_REPLY_READ_OUT            : out std_logic;\r
+    GSC_BUSY_IN                   : in  std_logic;\r
+    CFG_MAX_REPLY_SIZE_IN         : in  std_logic_vector(31 downto 0);\r
+    --\r
+    RESET_TRBNET_IN               : in  std_logic;\r
+    RESET_SCTRL_IN                : in  std_logic;\r
+    MAKE_RESET_OUT                : out std_logic;\r
+    -- Forwarder\r
+    FWD_DST_MAC_IN                : in  std_logic_vector(47 downto 0);\r
+    FWD_DST_IP_IN                 : in  std_logic_vector(31 downto 0);\r
+    FWD_DST_UDP_IN                : in  std_logic_vector(15 downto 0);\r
+    FWD_DATA_IN                   : in  std_logic_vector(7 downto 0);\r
+    FWD_DATA_VALID_IN             : in  std_logic;\r
+    FWD_SOP_IN                    : in  std_logic;\r
+    FWD_EOP_IN                    : in  std_logic;\r
+    FWD_READY_OUT                 : out std_logic;\r
+    FWD_FULL_OUT                  : out std_logic;\r
+    --\r
+    MONITOR_SELECT_REC_OUT        : out std_logic_vector(c_MAX_PROTOCOLS * 32 - 1 downto 0);\r
+    MONITOR_SELECT_REC_BYTES_OUT  : out std_logic_vector(c_MAX_PROTOCOLS * 32 - 1 downto 0);\r
+    MONITOR_SELECT_SENT_BYTES_OUT : out std_logic_vector(c_MAX_PROTOCOLS * 32 - 1 downto 0);\r
+    MONITOR_SELECT_SENT_OUT       : out std_logic_vector(c_MAX_PROTOCOLS * 32 - 1 downto 0);\r
+    --\r
+    DEBUG_OUT                     : out std_logic_vector(63 downto 0)\r
+  );\r
+end gbe_main_control;\r
+\r
+architecture gbe_main_control_arch of gbe_main_control is\r
+\r
+  attribute syn_encoding : string;\r
+\r
+  type FSM_LINK_STATES is (LINK_DOWN, LINK_ACTIVE, LINK_UP);\r
+  signal LINK_STATE_CS, LINK_STATE_NS: FSM_LINK_STATES;\r
+  attribute syn_encoding of LINK_STATE_CS : signal is "onehot";\r
+\r
+  signal link_state           : std_logic_vector(3 downto 0);\r
+  signal dhcp_start_x         : std_logic;\r
+  signal dhcp_start           : std_logic;\r
+  signal dhcp_done           : std_logic;\r
+  signal incl_dhcp           : std_logic;\r
+\r
+  type FSM_REDIRECT_STATES is (IDLE, CHECK_TYPE, DROP, CHECK_BUSY, LOAD, BUSY, WAIT_ONE, FINISH, CLEANUP);\r
+  signal REDIRECT_CS, REDIRECT_NS : FSM_REDIRECT_STATES;\r
+  attribute syn_encoding of REDIRECT_CS : signal is "onehot";\r
+\r
+  signal redirect_state      : std_logic_vector(3 downto 0);\r
+  signal rc_rd_en            : std_logic;\r
+\r
+  -----------------------------------------------------------------------\r
+\r
+  type flow_states is (IDLE, TRANSMIT_CTRL, WAIT_FOR_FC, CLEANUP);\r
+  signal FLOW_CS, FLOW_NS : flow_states;\r
+  attribute syn_encoding of FLOW_CS : signal is "onehot";\r
+\r
+  signal flow_state          : std_logic_vector(3 downto 0);\r
+\r
+  signal ps_wr_en            : std_logic;\r
+  signal ps_response_ready   : std_logic;\r
+  signal ps_busy             : std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0);\r
+  signal loaded_bytes_ctr    : unsigned(15 downto 0);\r
+\r
+  signal rc_data_local       : std_logic_vector(8 downto 0);\r
+\r
+  signal ps_wr_en_q          : std_logic;\r
+  signal ps_wr_en_qq         : std_logic;\r
+\r
+  signal tc_data             : std_logic_vector(8 downto 0);\r
+\r
+  attribute syn_preserve : boolean;\r
+  attribute syn_keep : boolean;\r
+  attribute syn_keep of link_state, redirect_state, dhcp_done : signal is true;\r
+  attribute syn_preserve of link_state, redirect_state, dhcp_done : signal is true;\r
+\r
+  signal mc_busy             : std_logic;\r
+  signal selector_debug      : std_logic_vector(63 downto 0);\r
+\r
+begin\r
+\r
+  -----------------------------------------------------------------------\r
+  -- Debug signals\r
+  -----------------------------------------------------------------------\r
+  DEBUG_OUT(63 downto 28)  <= (others => '0');\r
+\r
+  DEBUG_OUT(27 downto 24) <= link_state;\r
+  DEBUG_OUT(23 downto 20) <= redirect_state;\r
+  DEBUG_OUT(19 downto 16) <= flow_state;\r
+  DEBUG_OUT(15 downto 0)  <= selector_debug(15 downto 0);\r
+\r
+  -----------------------------------------------------------------------\r
+  -- Link state machine, high level. Handles DHCP basically\r
+  -----------------------------------------------------------------------\r
+  PROC_LINK_STATE_FSM: process( CLK, RESET )\r
+  begin\r
+    if   ( RESET = '1' ) then\r
+      LINK_STATE_CS <= LINK_DOWN;\r
+      dhcp_start <= '0';\r
+    elsif( rising_edge(CLK) ) then\r
+      LINK_STATE_CS <= LINK_STATE_NS;\r
+      dhcp_start <= dhcp_start_x;\r
+    end if;\r
+  end process PROC_LINK_STATE_FSM;\r
+\r
+  PROC_LINK_STATE_TRANSITIONS: process( LINK_STATE_CS, LINK_ACTIVE_IN, dhcp_done, incl_dhcp )\r
+  begin\r
+    dhcp_start_x <= '0';\r
+\r
+    case LINK_STATE_CS is\r
+      when LINK_DOWN =>\r
+        link_state <= x"0";\r
+        if   ( (LINK_ACTIVE_IN = '1') and (incl_dhcp = '1') ) then\r
+          -- PHY and MAC are operational, DHCP is used\r
+          LINK_STATE_NS <= LINK_ACTIVE;\r
+          dhcp_start_x <= '1';\r
+        elsif( (LINK_ACTIVE_IN = '0') and (incl_dhcp = '0') ) then\r
+          -- PHY and MAC are operational, DHCP is not used\r
+          LINK_STATE_NS <= LINK_UP;\r
+        else\r
+          -- no link partner, or AN in progress\r
+          LINK_STATE_NS <= LINK_DOWN;\r
+        end if;\r
+      when LINK_ACTIVE =>\r
+        link_state <= x"1";\r
+        if   ( LINK_ACTIVE_IN = '0' ) then\r
+          -- link lost\r
+          LINK_STATE_NS <= LINK_DOWN;\r
+        elsif( dhcp_done = '1' ) then\r
+          -- DHCP done\r
+          LINK_STATE_NS <= LINK_UP;\r
+          dhcp_start_x <= '1';\r
+        else\r
+          -- wait for DHCP\r
+          LINK_STATE_NS <= LINK_ACTIVE;\r
+          dhcp_start_x <= '1';\r
+        end if;\r
+      when LINK_UP =>\r
+        link_state <= x"2";\r
+        if( LINK_ACTIVE_IN = '0' ) then\r
+          -- link lost\r
+          LINK_STATE_NS <= LINK_DOWN;\r
+        else\r
+          -- all fine :)\r
+          LINK_STATE_NS <= LINK_UP;\r
+          dhcp_start_x <= '1';\r
+        end if;\r
+\r
+      when others =>\r
+        LINK_STATE_NS <= LINK_DOWN;\r
+    end case;\r
+  end process PROC_LINK_STATE_TRANSITIONS;\r
+\r
+  MC_DHCP_DONE_OUT <= '1' when (LINK_STATE_CS = LINK_UP) else '0';\r
+\r
+  MC_LINK_OK_OUT   <= '1' when (LINK_STATE_CS = LINK_UP) else '0'; -- TAKE CARE! MIGHT INTERFERE WITH PACKET TRANSMISSION!\r
+\r
+  -----------------------------------------------------------------------\r
+  -- handles frame loading or dropping\r
+  -----------------------------------------------------------------------\r
+  PROC_REDIRECT_FSM: process( CLK, RESET )\r
+  begin\r
+    if   ( RESET = '1' ) then\r
+      REDIRECT_CS <= IDLE;\r
+    elsif( rising_edge(CLK) ) then\r
+      REDIRECT_CS <= REDIRECT_NS;\r
+    end if;\r
+  end process PROC_REDIRECT_FSM;\r
+\r
+  PROC_REDIRECT_TRANSITIONS: process( REDIRECT_CS, LINK_STATE_CS, RC_FRAME_WAITING_IN,\r
+                                      RC_FRAME_PROTO_IN, RC_FRAME_SIZE_IN, ps_busy, loaded_bytes_ctr )\r
+  begin\r
+    redirect_state <= x"0";\r
+\r
+    case REDIRECT_CS is\r
+      when IDLE =>\r
+        redirect_state <= x"1";\r
+        if( (RC_FRAME_WAITING_IN = '1') ) then\r
+          -- frame waiting, check what we can do\r
+          REDIRECT_NS <= CHECK_TYPE;\r
+        else\r
+          REDIRECT_NS <= IDLE;\r
+        end if;\r
+\r
+      when CHECK_TYPE =>\r
+        redirect_state <= x"2";\r
+        if   ( LINK_STATE_CS = LINK_UP ) then\r
+          -- DHPC done, or fixed IP, so we are fully accepting frames\r
+          REDIRECT_NS <= CHECK_BUSY;\r
+        elsif( (LINK_STATE_CS = LINK_ACTIVE) and (RC_FRAME_PROTO_IN(1 downto 0) = "10") ) then\r
+          -- DHCP in progress, so only DHCP frames are accepted\r
+          REDIRECT_NS <= CHECK_BUSY;\r
+        else\r
+          -- link lost, drop frame\r
+          REDIRECT_NS <= DROP;\r
+        end if;\r
+\r
+      when DROP =>\r
+        redirect_state <= x"3";\r
+        if( loaded_bytes_ctr = unsigned(RC_FRAME_SIZE_IN) - 1 ) then\r
+          -- frame has been loaded\r
+          REDIRECT_NS <= WAIT_ONE;\r
+        else\r
+          REDIRECT_NS <= DROP;\r
+        end if;\r
+\r
+      when CHECK_BUSY =>\r
+        redirect_state <= x"4";\r
+        if( or_all(ps_busy and RC_FRAME_PROTO_IN) = '0' ) then\r
+          -- selected protocol is ready\r
+          REDIRECT_NS <= LOAD;\r
+        else\r
+          REDIRECT_NS <= BUSY;\r
+        end if;\r
+\r
+      when LOAD =>\r
+        redirect_state <= x"5";\r
+        if( loaded_bytes_ctr = unsigned(RC_FRAME_SIZE_IN) - 1 ) then\r
+          -- all bytes loaded\r
+          REDIRECT_NS <= WAIT_ONE;\r
+        else\r
+          REDIRECT_NS <= LOAD;\r
+        end if;\r
+\r
+      when BUSY =>\r
+        redirect_state <= x"6";\r
+        if( or_all(ps_busy and RC_FRAME_PROTO_IN) = '0' ) then\r
+          -- selected protocol is ready\r
+          REDIRECT_NS <= LOAD;\r
+        else\r
+          -- wait for selected protocol to be idle\r
+          REDIRECT_NS <= BUSY;\r
+        end if;\r
+\r
+      when WAIT_ONE =>\r
+        redirect_state      <= x"7";\r
+        REDIRECT_NS <= FINISH;\r
+\r
+      when FINISH =>\r
+        redirect_state      <= x"8";\r
+        REDIRECT_NS <= CLEANUP;\r
+\r
+      when CLEANUP =>\r
+        redirect_state      <= x"9";\r
+        REDIRECT_NS <= IDLE;\r
+\r
+      when others => REDIRECT_NS <= IDLE;\r
+\r
+    end case;\r
+  end process PROC_REDIRECT_TRANSITIONS;\r
+\r
+  INCL_DHCP_GEN: if( INCLUDE_DHCP = '1' ) generate\r
+    incl_dhcp <= '1';\r
+  end generate INCL_DHCP_GEN;\r
+  NOINCL_DHCP_GEN: if( INCLUDE_DHCP = '0' ) generate\r
+    incl_dhcp <= '0';\r
+  end generate NOINCL_DHCP_GEN;\r
+\r
+  rc_rd_en     <= '1' when ( (REDIRECT_CS = LOAD) or (REDIRECT_CS = DROP) ) else '0';\r
+  RC_RD_EN_OUT <= rc_rd_en;\r
+\r
+  -----------------------------------------------------------------------\r
+  -----------------------------------------------------------------------\r
+  PROC_FLOW_FSM: process( CLK, RESET )\r
+  begin\r
+    if   ( RESET = '1' ) then\r
+      FLOW_CS <= IDLE;\r
+    elsif( rising_edge(CLK) ) then\r
+      FLOW_CS <= FLOW_NS;\r
+    end if;\r
+  end process PROC_FLOW_FSM;\r
+\r
+  PROC_FLOW_TRANSITIONS: process(FLOW_CS, TC_TRANSMIT_DONE_IN, ps_response_ready, tc_data)\r
+  begin\r
+    flow_state <= x"0";\r
+\r
+    case FLOW_CS is\r
+      when IDLE =>\r
+        flow_state <= x"1";\r
+        if( ps_response_ready = '1' ) then\r
+          FLOW_NS <= TRANSMIT_CTRL;\r
+        else\r
+          FLOW_NS <= IDLE;\r
+        end if;\r
+\r
+      when TRANSMIT_CTRL =>\r
+        flow_state <= x"2";\r
+        if( tc_data(8) = '1' ) then\r
+          FLOW_NS <= WAIT_FOR_FC;\r
+        else\r
+          FLOW_NS <= TRANSMIT_CTRL;\r
+        end if;\r
+\r
+      when WAIT_FOR_FC =>\r
+        flow_state <= x"3";\r
+        if( TC_TRANSMIT_DONE_IN = '1' ) then\r
+          FLOW_NS <= CLEANUP;\r
+        else\r
+          FLOW_NS <= WAIT_FOR_FC;\r
+        end if;\r
+\r
+      when CLEANUP =>\r
+        flow_state      <= x"4";\r
+        FLOW_NS <= IDLE;\r
+\r
+      when others =>\r
+        FLOW_NS <= IDLE;\r
+\r
+    end case;\r
+  end process PROC_FLOW_TRANSITIONS;\r
+\r
+  PROC_BUSY: process( CLK )\r
+  begin\r
+    if rising_edge(CLK) then\r
+      if( (FLOW_CS = IDLE) and (ps_response_ready = '1') )then\r
+        TC_TRANSMIT_CTRL_OUT <= '1';\r
+      else\r
+        TC_TRANSMIT_CTRL_OUT <= '0';\r
+      end if;\r
+\r
+      if( (FLOW_CS = TRANSMIT_CTRL) or (FLOW_CS = WAIT_FOR_FC) ) then\r
+        mc_busy <= '1';\r
+      else\r
+        mc_busy <= '0';\r
+      end if;\r
+    end if;\r
+  end process PROC_BUSY;\r
+\r
+  -----------------------------------------------------------------------\r
+  -- Protocol selector\r
+  -----------------------------------------------------------------------\r
+  THE_PROTOCOL_SELECTOR: entity work.gbe_protocol_selector\r
+    generic map(\r
+      INCLUDE_SLOWCTRL     => INCLUDE_SLOWCTRL,\r
+      INCLUDE_DHCP         => INCLUDE_DHCP,\r
+      INCLUDE_ARP          => INCLUDE_ARP,\r
+      INCLUDE_PING         => INCLUDE_PING,\r
+      INCLUDE_FWD          => INCLUDE_FWD,\r
+      SLOWCTRL_BUFFER_SIZE => SLOWCTRL_BUFFER_SIZE\r
+    )\r
+    port map(\r
+      CLK                           => CLK,\r
+      RESET                         => RESET,\r
+      PS_DATA_IN                    => rc_data_local,\r
+      PS_WR_EN_IN                   => ps_wr_en_qq,\r
+      PS_PROTO_SELECT_IN            => RC_FRAME_PROTO_IN,\r
+      PS_BUSY_OUT                   => ps_busy,\r
+      PS_FRAME_SIZE_IN              => RC_FRAME_SIZE_IN,\r
+      PS_RESPONSE_READY_OUT         => ps_response_ready,\r
+      PS_SRC_MAC_ADDRESS_IN         => RC_SRC_MAC_ADDRESS_IN,\r
+      PS_DEST_MAC_ADDRESS_IN        => RC_DEST_MAC_ADDRESS_IN,\r
+      PS_SRC_IP_ADDRESS_IN          => RC_SRC_IP_ADDRESS_IN,\r
+      PS_DEST_IP_ADDRESS_IN         => RC_DEST_IP_ADDRESS_IN,\r
+      PS_SRC_UDP_PORT_IN            => RC_SRC_UDP_PORT_IN,\r
+      PS_DEST_UDP_PORT_IN           => RC_DEST_UDP_PORT_IN,\r
+      TC_DATA_OUT                   => tc_data,\r
+      TC_RD_EN_IN                   => TC_RD_EN_IN,\r
+      TC_FRAME_SIZE_OUT             => TC_FRAME_SIZE_OUT,\r
+      TC_FRAME_TYPE_OUT             => TC_FRAME_TYPE_OUT,\r
+      TC_IP_PROTOCOL_OUT            => TC_IP_PROTOCOL_OUT,\r
+      TC_IDENT_OUT                  => TC_IDENT_OUT,\r
+      TC_DEST_MAC_OUT               => TC_DEST_MAC_OUT,\r
+      TC_DEST_IP_OUT                => TC_DEST_IP_OUT,\r
+      TC_DEST_UDP_OUT               => TC_DEST_UDP_OUT,\r
+      TC_SRC_MAC_OUT                => TC_SRC_MAC_OUT,\r
+      TC_SRC_IP_OUT                 => TC_SRC_IP_OUT,\r
+      TC_SRC_UDP_OUT                => TC_SRC_UDP_OUT,\r
+      MC_BUSY_IN                    => mc_busy,\r
+      MY_MAC_IN                     => MC_MY_MAC_IN,\r
+      MY_IP_OUT                     => MY_IP_OUT,\r
+      DHCP_START_IN                 => dhcp_start,\r
+      DHCP_DONE_OUT                 => dhcp_done,\r
+      GSC_CLK_IN                    => GSC_CLK_IN,\r
+      GSC_INIT_DATAREADY_OUT        => GSC_INIT_DATAREADY_OUT,\r
+      GSC_INIT_DATA_OUT             => GSC_INIT_DATA_OUT,\r
+      GSC_INIT_PACKET_NUM_OUT       => GSC_INIT_PACKET_NUM_OUT,\r
+      GSC_INIT_READ_IN              => GSC_INIT_READ_IN,\r
+      GSC_REPLY_DATAREADY_IN        => GSC_REPLY_DATAREADY_IN,\r
+      GSC_REPLY_DATA_IN             => GSC_REPLY_DATA_IN,\r
+      GSC_REPLY_PACKET_NUM_IN       => GSC_REPLY_PACKET_NUM_IN,\r
+      GSC_REPLY_READ_OUT            => GSC_REPLY_READ_OUT,\r
+      GSC_BUSY_IN                   => GSC_BUSY_IN,\r
+      MAKE_RESET_OUT                => MAKE_RESET_OUT,\r
+\r
+      MY_TRBNET_ADDRESS_IN          => MY_TRBNET_ADDRESS_IN,\r
+\r
+      CFG_MAX_REPLY_SIZE_IN         => CFG_MAX_REPLY_SIZE_IN,\r
+\r
+      FWD_DST_MAC_IN                => FWD_DST_MAC_IN,\r
+      FWD_DST_IP_IN                 => FWD_DST_IP_IN,\r
+      FWD_DST_UDP_IN                => FWD_DST_UDP_IN,\r
+      FWD_DATA_IN                   => FWD_DATA_IN,\r
+      FWD_DATA_VALID_IN             => FWD_DATA_VALID_IN,\r
+      FWD_SOP_IN                    => FWD_SOP_IN,\r
+      FWD_EOP_IN                    => FWD_EOP_IN,\r
+      FWD_READY_OUT                 => FWD_READY_OUT,\r
+      FWD_FULL_OUT                  => FWD_FULL_OUT,\r
+\r
+      -- input for statistics from outside\r
+      MONITOR_SELECT_REC_OUT        => MONITOR_SELECT_REC_OUT,\r
+      MONITOR_SELECT_REC_BYTES_OUT  => MONITOR_SELECT_REC_BYTES_OUT,\r
+      MONITOR_SELECT_SENT_BYTES_OUT => MONITOR_SELECT_SENT_BYTES_OUT,\r
+      MONITOR_SELECT_SENT_OUT       => MONITOR_SELECT_SENT_OUT,\r
+      DEBUG_OUT                     => selector_debug\r
+    );\r
+\r
+  TC_DATA_OUT <= tc_data;\r
+\r
+  -- warning\r
+  PROC_SYNC: process( CLK )\r
+  begin\r
+    if( rising_edge(CLK) ) then\r
+      rc_data_local <= RC_DATA_IN;\r
+    end if;\r
+  end process PROC_SYNC;\r
+\r
+\r
+  PROC_LOADING_DONE: process( CLK )\r
+  begin\r
+    if rising_edge(CLK) then\r
+      if (RC_DATA_IN(8) = '1' and ps_wr_en_q = '1') then\r
+        RC_LOADING_DONE_OUT <= '1';\r
+      else\r
+        RC_LOADING_DONE_OUT <= '0';\r
+      end if;\r
+    end if;\r
+  end process PROC_LOADING_DONE;\r
+\r
+  PROC_PS_WR_EN: process( CLK )\r
+  begin\r
+    if rising_edge(CLK) then\r
+      ps_wr_en    <= rc_rd_en;\r
+      ps_wr_en_q  <= ps_wr_en;\r
+      ps_wr_en_qq <= ps_wr_en_q;\r
+    end if;\r
+  end process PROC_PS_WR_EN;\r
+\r
+  PROC_LOADED_BYTES_CTR: process( CLK )\r
+  begin\r
+    if rising_edge(CLK) then\r
+      if   ( REDIRECT_CS = IDLE) then\r
+        loaded_bytes_ctr <= (others => '0');\r
+      elsif( ((REDIRECT_CS = LOAD) or (REDIRECT_CS = DROP)) ) then\r
+        loaded_bytes_ctr <= loaded_bytes_ctr + 1;\r
+      end if;\r
+    end if;\r
+  end process PROC_LOADED_BYTES_CTR;\r
+\r
+end gbe_main_control_arch;\r
index 240403b155d570d77aa7c83efa1c1f0ccac0498a..27cb48ae588685317003ada2983e22e5d932361c 100644 (file)
@@ -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;
index 99c521c481988932bc8c440c1fabb5f186ef3a64..53948c2398b5fddced068d95956581fb58db7019 100644 (file)
@@ -75,7 +75,7 @@ begin
   RC_DEST_IP_ADDRESS_OUT  <= FR_DEST_IP_ADDRESS_IN;\r
   RC_SRC_UDP_PORT_OUT     <= FR_SRC_UDP_PORT_IN;\r
   RC_DEST_UDP_PORT_OUT    <= FR_DEST_UDP_PORT_IN;\r
-       RC_FRAME_PROTO_OUT      <= FR_PS_IN when (load_current_state /= IDLE) else (others => '0');\r
+  RC_FRAME_PROTO_OUT      <= FR_PS_IN when (load_current_state /= IDLE) else (others => '0');\r
 \r
   LOAD_MACHINE_PROC: process( CLK, RESET )\r
   begin\r
@@ -101,7 +101,7 @@ begin
       when PREPARE =>  -- prepare frame size\r
         state <= x"2";\r
         load_next_state <= WAIT_ONE;\r
-        \r
+\r
       when WAIT_ONE =>\r
         load_next_state <= READY;\r
 \r
@@ -151,7 +151,7 @@ begin
     elsif( rising_edge(CLK) ) then\r
       if( RC_LOADING_DONE_IN = '1' ) then\r
         frames_readout_ctr <= frames_readout_ctr + 1;\r
-      end if;    \r
+      end if;\r
     end if;\r
   end process FRAMES_READOUT_CTR_PROC;\r
 \r
@@ -162,7 +162,7 @@ begin
       bytes_rec_ctr <= (others => '0');\r
     elsif( rising_edge(CLK) ) then\r
       if( FR_FRAME_VALID_IN = '1' ) then\r
-        bytes_rec_ctr <= bytes_rec_ctr + unsigned(FR_FRAME_SIZE_IN);    \r
+        bytes_rec_ctr <= bytes_rec_ctr + unsigned(FR_FRAME_SIZE_IN);\r
       end if;\r
     end if;\r
   end process BYTES_REC_CTR_PROC;\r
index 53d1c9a650414941ed3a4f457e61a1d9ddd1a721..20394b8d8075e7ed12ddb66cd77eb2dadbb13e95 100644 (file)
@@ -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;
 
 
index ce0dcdedfb3952d8196f246e04e47e77bdbc0237..8f0d475b3f3e91aa8eab168117b08a954a4858b9 100644 (file)
@@ -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
index 6e26a70cd8034802b930a38409c5d0fb776a6a1c..4e988c434c379c2befaec8914905901776eefced 100644 (file)
@@ -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
index c5291f14169fe8d06835b6cfbfb20c8532e5216f..45f11624d58bdfa57deedd94f7361adfb01187b6 100644 (file)
-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;\r
+  use ieee.std_logic_1164.all;\r
+  use ieee.numeric_std.all;\r
+\r
+library work;\r
+  use work.gbe_protocols.all;\r
+\r
+entity gbe_response_constructor_DHCP is\r
+  port(\r
+    CLK                    : in  std_logic;  -- system clock\r
+    RESET                  : in  std_logic;\r
+  -- INTERFACE\r
+    MY_MAC_IN              : in  std_logic_vector(47 downto 0);\r
+    MY_IP_IN               : in  std_logic_vector(31 downto 0);\r
+    PS_DATA_IN             : in  std_logic_vector(8 downto 0);\r
+    PS_WR_EN_IN            : in  std_logic;\r
+    PS_ACTIVATE_IN         : in  std_logic;\r
+    PS_RESPONSE_READY_OUT  : out std_logic;\r
+    PS_BUSY_OUT            : out std_logic;\r
+    PS_SELECTED_IN         : in  std_logic;\r
+    PS_SRC_MAC_ADDRESS_IN  : in  std_logic_vector(47 downto 0);\r
+    PS_DEST_MAC_ADDRESS_IN : in  std_logic_vector(47 downto 0);\r
+    PS_SRC_IP_ADDRESS_IN   : in  std_logic_vector(31 downto 0);\r
+    PS_DEST_IP_ADDRESS_IN  : in  std_logic_vector(31 downto 0);\r
+    PS_SRC_UDP_PORT_IN     : in  std_logic_vector(15 downto 0);\r
+    PS_DEST_UDP_PORT_IN    : in  std_logic_vector(15 downto 0);\r
+  --\r
+    TC_RD_EN_IN            : in  std_logic;\r
+    TC_DATA_OUT            : out std_logic_vector(8 downto 0);\r
+    TC_FRAME_SIZE_OUT      : out std_logic_vector(15 downto 0);\r
+    TC_FRAME_TYPE_OUT      : out std_logic_vector(15 downto 0);\r
+    TC_IP_PROTOCOL_OUT     : out std_logic_vector(7 downto 0);\r
+    TC_IDENT_OUT           : out std_logic_vector(15 downto 0);\r
+    TC_DEST_MAC_OUT        : out std_logic_vector(47 downto 0);\r
+    TC_DEST_IP_OUT         : out std_logic_vector(31 downto 0);\r
+    TC_DEST_UDP_OUT        : out std_logic_vector(15 downto 0);\r
+    TC_SRC_MAC_OUT         : out std_logic_vector(47 downto 0);\r
+    TC_SRC_IP_OUT          : out std_logic_vector(31 downto 0);\r
+    TC_SRC_UDP_OUT         : out std_logic_vector(15 downto 0);\r
+  -- END OF INTERFACE\r
+    MY_IP_OUT              : out std_logic_vector(31 downto 0);\r
+    DHCP_START_IN          : in  std_logic;\r
+    DHCP_DONE_OUT          : out std_logic;\r
+  -- debug\r
+    DEBUG_OUT              : out  std_logic_vector(63 downto 0)\r
+  );\r
+end gbe_response_constructor_DHCP;\r
+\r
+\r
+architecture gbe_response_constructor_DHCP_arch of gbe_response_constructor_DHCP is\r
+\r
+  attribute syn_encoding  : string;\r
+\r
+  type main_states is (BOOTING, DELAY, SENDING_DISCOVER, WAITING_FOR_OFFER, SENDING_REQUEST, WAITING_FOR_ACK, ESTABLISHED);\r
+  signal main_current_state, main_next_state : main_states;\r
+  attribute syn_encoding of main_current_state: signal is "onehot";\r
+\r
+  type receive_states is (IDLE, DISCARD, CLEANUP, SAVE_VALUES);\r
+  signal receive_current_state, receive_next_state : receive_states;\r
+  attribute syn_encoding of receive_current_state: signal is "onehot";\r
+\r
+  type discover_states is (IDLE, WAIT_FOR_LOAD, BOOTP_HEADERS, CLIENT_IP, YOUR_IP, ZEROS1, MY_MAC, ZEROS2, VENDOR_VALS, VENDOR_VALS2, TERMINATION, CLEANUP);\r
+  signal construct_current_state, construct_next_state : discover_states;\r
+  attribute syn_encoding of construct_current_state: signal is "onehot";\r
+\r
+  type stats_states is (IDLE, LOAD_SENT, LOAD_RECEIVED, LOAD_DISCARDED, CLEANUP);\r
+  signal stats_current_state, stats_next_state : stats_states;\r
+  attribute syn_encoding of stats_current_state : signal is "onehot";\r
+\r
+  signal state                    : std_logic_vector(3 downto 0);\r
+  signal rec_frames               : std_logic_vector(15 downto 0);\r
+  signal sent_frames              : unsigned(15 downto 0);\r
+\r
+  signal wait_ctr                 : unsigned(31 downto 0);  -- wait for 5 sec before sending request\r
+  signal load_ctr                 : integer range 0 to 600 := 0;\r
+\r
+  signal bootp_hdr                : std_logic_vector(95 downto 0);\r
+\r
+  signal tc_data                  : std_logic_vector(8 downto 0);\r
+  signal vendor_values            : std_logic_vector(175 downto 0);\r
+  signal save_ctr                 : integer range 0 to 600 := 0;\r
+  signal saved_transaction_id     : std_logic_vector(31 downto 0);\r
+  signal saved_proposed_ip        : std_logic_vector(31 downto 0);\r
+  signal saved_dhcp_type          : std_logic_vector(23 downto 0);\r
+  signal saved_true_ip            : std_logic_vector(31 downto 0);\r
+  signal transaction_id           : std_logic_vector(31 downto 0);\r
+  signal client_ip_reg            : std_logic_vector(31 downto 0);\r
+  signal your_ip_reg              : std_logic_vector(31 downto 0);\r
+  signal saved_server_mac         : std_logic_vector(47 downto 0);\r
+  signal saved_server_ip          : std_logic_vector(31 downto 0);\r
+  signal state2                   : std_logic_vector(3 downto 0);\r
+  signal state3                   : std_logic_vector(3 downto 0);\r
+  signal vendor_values2           : std_logic_vector(47 downto 0);\r
+\r
+  signal discarded_ctr            : std_logic_vector(15 downto 0);\r
+\r
+  signal stat_data_temp           : std_logic_vector(31 downto 0);\r
+\r
+  attribute syn_preserve : boolean;\r
+  attribute syn_keep : boolean;\r
+  attribute syn_keep of state, state2 : signal is true;\r
+  attribute syn_preserve of state, state2 : signal is true;\r
+\r
+  signal wait_value : unsigned(31 downto 0);\r
+\r
+  signal my_ip : std_logic_vector(31 downto 0);\r
+\r
+begin\r
+\r
+  -- ****\r
+  -- fixing the constant values for DHCP request headers\r
+  TC_DEST_MAC_OUT               <= x"ffffffffffff" when (main_current_state = BOOTING or main_current_state = SENDING_DISCOVER) else saved_server_mac;\r
+  TC_DEST_IP_OUT                <= x"ffffffff" when (main_current_state = BOOTING or main_current_state = SENDING_DISCOVER) else saved_server_ip;\r
+  TC_DEST_UDP_OUT               <= x"4300";\r
+  TC_SRC_MAC_OUT                <= MY_MAC_IN;\r
+  TC_SRC_IP_OUT                 <= x"00000000" when (main_current_state = BOOTING or main_current_state = SENDING_DISCOVER) else saved_proposed_ip;\r
+  TC_SRC_UDP_OUT                <= x"4400";\r
+  TC_IP_PROTOCOL_OUT            <= x"11"; -- udp\r
+  bootp_hdr(7 downto 0)         <= x"01";  -- message type(request)\r
+  bootp_hdr(15 downto 8)        <= x"01";  -- hardware type (eth)\r
+  bootp_hdr(23 downto 16)       <= x"06";  -- hardware address length\r
+  bootp_hdr(31 downto 24)       <= x"00";  -- hops\r
+  bootp_hdr(63 downto 32)       <= transaction_id;  -- transaction id;\r
+  bootp_hdr(95 downto 64)       <= x"0000_0000";  -- seconds elapsed/flags\r
+  transaction_id                <= x"cefa" & MY_MAC_IN(47 downto 40) & MY_MAC_IN(23 downto 16);\r
+  vendor_values(31 downto 0)    <= x"63538263"; -- magic cookie (dhcp message)\r
+  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\r
+  vendor_values(79 downto 56)   <= x"01073d"; -- client identifier\r
+  vendor_values(127 downto 80)  <= MY_MAC_IN;  -- client identifier\r
+  vendor_values(143 downto 128) <= x"040c";  -- client name\r
+  vendor_values(175 downto 144) <= x"33425254";  -- client name (TRB3)\r
+  --vendor_values(175 downto 144) <= x"6f72694b";  -- client name (Kiro)\r
+  vendor_values2(15 downto 0)   <= x"0436";  -- server identifier\r
+  vendor_values2(47 downto 16)  <= saved_server_ip;\r
+\r
+  --*****************\r
+  -- setting of global variable for IP address\r
+  my_ip <= saved_true_ip when main_current_state = ESTABLISHED else (others => '0');\r
+  MY_IP_OUT <= my_ip;\r
+  --\r
+  --*****************\r
+\r
+  PROC_SAVE_SERVER_ADDR: process( CLK )\r
+  begin\r
+    if( rising_edge(CLK) ) then\r
+      if   ( main_current_state = BOOTING ) then\r
+        saved_server_mac <= (others => '0');\r
+        saved_server_ip  <= (others => '0');\r
+      elsif( (main_current_state = WAITING_FOR_OFFER) and (receive_current_state = SAVE_VALUES and save_ctr = 1) ) then\r
+        saved_server_mac <= PS_SRC_MAC_ADDRESS_IN;\r
+        saved_server_ip  <= PS_SRC_IP_ADDRESS_IN;\r
+      end if;\r
+    end if;\r
+  end process PROC_SAVE_SERVER_ADDR;\r
+\r
+\r
+  -- **** MAIN MACHINE PART\r
+\r
+  PROC_MAIN_FSM: process( CLK, RESET)\r
+  begin\r
+    if   ( RESET = '1' ) then\r
+      main_current_state <= BOOTING;\r
+    elsif( rising_edge(CLK) ) then\r
+      main_current_state <= main_next_state;\r
+    end if;\r
+  end process PROC_MAIN_FSM;\r
+\r
+  wait_value <= x"2000_0000";\r
+--  wait_value <= x"0000_2000";\r
+\r
+  PROC_MAIN_TRANSITIONS : process(main_current_state, DHCP_START_IN, construct_current_state, wait_ctr, receive_current_state, PS_DATA_IN, wait_value)\r
+  begin\r
+    state2 <= x"0";\r
+\r
+    case (main_current_state) is\r
+\r
+      when BOOTING =>\r
+        state2 <= x"1";\r
+        if (DHCP_START_IN = '1') then\r
+          main_next_state <= DELAY;\r
+        else\r
+          main_next_state <= BOOTING;\r
+        end if;\r
+\r
+      when DELAY =>\r
+        state2 <= x"2";\r
+        if (wait_ctr = wait_value) then\r
+          main_next_state <= SENDING_DISCOVER;\r
+        else\r
+          main_next_state <= DELAY;\r
+        end if;\r
+\r
+      when SENDING_DISCOVER =>\r
+        state2 <= x"3";\r
+        if (construct_current_state = CLEANUP) then\r
+          main_next_state <= WAITING_FOR_OFFER;\r
+        else\r
+          main_next_state <= SENDING_DISCOVER;\r
+        end if;\r
+\r
+      when WAITING_FOR_OFFER =>\r
+        state2 <= x"4";\r
+        if (receive_current_state = SAVE_VALUES) and (PS_DATA_IN(8) = '1') then\r
+          main_next_state <= SENDING_REQUEST;\r
+        elsif (wait_ctr = x"2000_0000") then\r
+          main_next_state <= BOOTING;\r
+        else\r
+          main_next_state <= WAITING_FOR_OFFER;\r
+        end if;\r
+\r
+      when SENDING_REQUEST =>\r
+        state2 <= x"5";\r
+        if (construct_current_state = CLEANUP) then\r
+          main_next_state <= WAITING_FOR_ACK;\r
+        else\r
+          main_next_state <= SENDING_REQUEST;\r
+        end if;\r
+\r
+      when WAITING_FOR_ACK =>\r
+        state2 <= x"6";\r
+        if (receive_current_state = SAVE_VALUES) and (PS_DATA_IN(8) = '1') then\r
+          main_next_state <= ESTABLISHED;\r
+        elsif (wait_ctr = x"2000_0000") then\r
+          main_next_state <= BOOTING;\r
+        else\r
+          main_next_state <= WAITING_FOR_ACK;\r
+        end if;\r
+\r
+      when ESTABLISHED =>\r
+        state2 <= x"7";\r
+          if( DHCP_START_IN = '0' ) then\r
+            main_next_state <= BOOTING;\r
+          else\r
+            main_next_state <= ESTABLISHED;\r
+          end if;\r
+\r
+      when others => main_next_state <= BOOTING;\r
+\r
+    end case;\r
+\r
+  end process PROC_MAIN_TRANSITIONS;\r
+\r
+  PROC_WAIT_CTR: process( CLK )\r
+  begin\r
+    if( rising_edge(CLK) ) then\r
+      if   ( main_current_state = SENDING_DISCOVER or main_current_state = SENDING_REQUEST or main_current_state = BOOTING ) then\r
+        wait_ctr <= (others => '0');\r
+      elsif( main_current_state = WAITING_FOR_ACK and receive_current_state = SAVE_VALUES and PS_DATA_IN(8) = '1' ) then\r
+        wait_ctr <= (others => '0');\r
+      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\r
+        wait_ctr <= wait_ctr + 1;\r
+      end if;\r
+    end if;\r
+  end process PROC_WAIT_CTR;\r
+\r
+  DHCP_DONE_OUT <= '1' when main_current_state = ESTABLISHED else '0';\r
+\r
+  -- **** MESSAGES RECEIVING PART\r
+\r
+  PROC_RECEIVE_FSM: process( CLK, RESET )\r
+  begin\r
+    if   ( RESET = '1' ) then\r
+      receive_current_state <= IDLE;\r
+    elsif( rising_edge(CLK) ) then\r
+      receive_current_state <= receive_next_state;\r
+    end if;\r
+  end process PROC_RECEIVE_FSM;\r
+\r
+  PROC_RECEIVE_TRANSITIONS: process( receive_current_state, main_current_state, bootp_hdr, saved_dhcp_type, saved_transaction_id,\r
+                                     PS_DATA_IN, PS_DEST_MAC_ADDRESS_IN, MY_MAC_IN, PS_ACTIVATE_IN, PS_WR_EN_IN, save_ctr )\r
+  begin\r
+    state3 <= x"0";\r
+\r
+    case receive_current_state is\r
+\r
+      when IDLE =>\r
+        state3 <= x"1";\r
+        if (PS_ACTIVATE_IN = '1' and PS_WR_EN_IN = '1') then\r
+          if (main_current_state = WAITING_FOR_OFFER or main_current_state = WAITING_FOR_ACK) then  -- ready to receive dhcp frame\r
+            if (PS_DEST_MAC_ADDRESS_IN = MY_MAC_IN) then -- check if i'm the addressee (discards broadcasts also)\r
+              receive_next_state <= SAVE_VALUES;\r
+            else\r
+              receive_next_state <= DISCARD;  -- discard if the frame is not for me\r
+            end if;\r
+          else\r
+            receive_next_state <= DISCARD;  -- discard if the frame arrived at wrong time\r
+          end if;\r
+        else\r
+          receive_next_state <= IDLE;\r
+        end if;\r
+\r
+      when SAVE_VALUES =>\r
+        state3 <= x"2";\r
+        if (PS_DATA_IN(8) = '1') then\r
+          receive_next_state <= CLEANUP;\r
+        -- check if the same transaction\r
+        elsif (save_ctr = 9) and (saved_transaction_id /= bootp_hdr(63 downto 32)) then\r
+          receive_next_state <= DISCARD;\r
+        -- if the wrong message at the wrong time\r
+        elsif (main_current_state = WAITING_FOR_OFFER) and (save_ctr = 242) and (saved_dhcp_type /= x"020135") then\r
+          receive_next_state <= DISCARD;\r
+        -- if the wrong message at the wrong time\r
+        elsif (main_current_state = WAITING_FOR_ACK) and (save_ctr = 242) and (saved_dhcp_type /= x"050135") then\r
+          receive_next_state <= DISCARD;\r
+        else\r
+          receive_next_state <= SAVE_VALUES;\r
+        end if;\r
+\r
+      when DISCARD =>\r
+        state3 <= x"3";\r
+        if (PS_DATA_IN(8) = '1') then\r
+          receive_next_state <= CLEANUP;\r
+        else\r
+          receive_next_state <= DISCARD;\r
+        end if;\r
+\r
+      when CLEANUP =>\r
+        state3 <= x"4";\r
+        receive_next_state <= IDLE;\r
+\r
+      when others => receive_next_state <= IDLE;\r
+\r
+    end case;\r
+\r
+  end process PROC_RECEIVE_TRANSITIONS;\r
+\r
+  PROC_SAVE_CTR: process( CLK )\r
+  begin\r
+    if( rising_edge(CLK) ) then\r
+      if   ( receive_current_state = IDLE ) then\r
+        save_ctr <= 0;\r
+      elsif( receive_current_state = SAVE_VALUES and PS_WR_EN_IN = '1' and PS_ACTIVATE_IN = '1' ) then\r
+        save_ctr <= save_ctr + 1;\r
+      end if;\r
+    end if;\r
+  end process PROC_SAVE_CTR;\r
+\r
+  PROC_SAVE_VALUES: process( CLK )\r
+  begin\r
+    if( rising_edge(CLK) ) then\r
+      if   ( main_current_state = BOOTING ) then\r
+        saved_transaction_id <= (others => '0');\r
+        saved_proposed_ip    <= (others => '0');\r
+        saved_true_ip        <= (others => '0');\r
+        saved_dhcp_type      <= (others => '0');\r
+      -- dissection of DHCP Offer message\r
+      elsif( main_current_state = WAITING_FOR_OFFER and receive_current_state = SAVE_VALUES ) then\r
+\r
+        saved_true_ip <= saved_true_ip;\r
+\r
+        case save_ctr is\r
+\r
+          when 3 =>\r
+            saved_transaction_id(7 downto 0) <= PS_DATA_IN(7 downto 0);\r
+\r
+          when 4 =>\r
+            saved_transaction_id(15 downto 8) <= PS_DATA_IN(7 downto 0);\r
+\r
+          when 5 =>\r
+            saved_transaction_id(23 downto 16) <= PS_DATA_IN(7 downto 0);\r
+\r
+          when 6 =>\r
+            saved_transaction_id(31 downto 24) <= PS_DATA_IN(7 downto 0);\r
+\r
+\r
+          when 15 =>\r
+            saved_proposed_ip(7 downto 0) <= PS_DATA_IN(7 downto 0);\r
+\r
+          when 16 =>\r
+            saved_proposed_ip(15 downto 8) <= PS_DATA_IN(7 downto 0);\r
+\r
+          when 17 =>\r
+            saved_proposed_ip(23 downto 16) <= PS_DATA_IN(7 downto 0);\r
+\r
+          when 18 =>\r
+            saved_proposed_ip(31 downto 24) <= PS_DATA_IN(7 downto 0);\r
+\r
+\r
+          when 239 =>\r
+            saved_dhcp_type(7 downto 0) <= PS_DATA_IN(7 downto 0);\r
+\r
+          when 240 =>\r
+            saved_dhcp_type(15 downto 8) <= PS_DATA_IN(7 downto 0);\r
+\r
+          when 241 =>\r
+            saved_dhcp_type(23 downto 16) <= PS_DATA_IN(7 downto 0);\r
+\r
+          when others => null;\r
+\r
+        end case;\r
+      -- dissection on DHCP Ack message\r
+      elsif( main_current_state = WAITING_FOR_ACK and receive_current_state = SAVE_VALUES ) then\r
+\r
+        saved_proposed_ip <= saved_proposed_ip;\r
+\r
+        case save_ctr is\r
+\r
+          when 3 =>\r
+            saved_transaction_id(7 downto 0) <= PS_DATA_IN(7 downto 0);\r
+\r
+          when 4 =>\r
+            saved_transaction_id(15 downto 8) <= PS_DATA_IN(7 downto 0);\r
+\r
+          when 5 =>\r
+            saved_transaction_id(23 downto 16) <= PS_DATA_IN(7 downto 0);\r
+\r
+          when 6 =>\r
+            saved_transaction_id(31 downto 24) <= PS_DATA_IN(7 downto 0);\r
+\r
+\r
+          when 15 =>\r
+            saved_true_ip(7 downto 0) <= PS_DATA_IN(7 downto 0);\r
+\r
+          when 16 =>\r
+            saved_true_ip(15 downto 8) <= PS_DATA_IN(7 downto 0);\r
+\r
+          when 17 =>\r
+            saved_true_ip(23 downto 16) <= PS_DATA_IN(7 downto 0);\r
+\r
+          when 18 =>\r
+            saved_true_ip(31 downto 24) <= PS_DATA_IN(7 downto 0);\r
+\r
+\r
+          when 239 =>\r
+            saved_dhcp_type(7 downto 0) <= PS_DATA_IN(7 downto 0);\r
+\r
+          when 240 =>\r
+            saved_dhcp_type(15 downto 8) <= PS_DATA_IN(7 downto 0);\r
+\r
+          when 241 =>\r
+            saved_dhcp_type(23 downto 16) <= PS_DATA_IN(7 downto 0);\r
+\r
+          when others => null;\r
+\r
+        end case;\r
+      end if;\r
+    end if;\r
+  end process PROC_SAVE_VALUES;\r
+\r
+  -- **** MESSAGES CONSTRUCTING PART\r
+\r
+  PROC_CONSTRUCT_FSM: process( CLK, RESET )\r
+  begin\r
+    if   ( RESET = '1' ) then\r
+      construct_current_state <= IDLE;\r
+    elsif( rising_edge(CLK) ) then\r
+      if( main_current_state = BOOTING ) then\r
+        construct_current_state <= IDLE;\r
+      else\r
+        construct_current_state <= construct_next_state;\r
+      end if;\r
+    end if;\r
+  end process PROC_CONSTRUCT_FSM;\r
+\r
+  PROC_CONSTRUCT_TRANSITIONS: process( construct_current_state, main_current_state, load_ctr, PS_SELECTED_IN )\r
+  begin\r
+    state <= x"0";\r
+\r
+    case construct_current_state is\r
+\r
+      when IDLE =>\r
+        state <= x"1";\r
+        if (main_current_state = SENDING_DISCOVER) or (main_current_state = SENDING_REQUEST) then\r
+          construct_next_state <= WAIT_FOR_LOAD;\r
+        else\r
+          construct_next_state <= IDLE;\r
+        end if;\r
+\r
+      when WAIT_FOR_LOAD =>\r
+        state <= x"2";\r
+        if (PS_SELECTED_IN = '1') then\r
+          construct_next_state <= BOOTP_HEADERS;\r
+        else\r
+          construct_next_state <= WAIT_FOR_LOAD;\r
+        end if;\r
+\r
+\r
+      when BOOTP_HEADERS =>\r
+        state <= x"3";\r
+        if (load_ctr = 11) then\r
+          construct_next_state <= CLIENT_IP;\r
+        else\r
+          construct_next_state <= BOOTP_HEADERS;\r
+        end if;\r
+\r
+      when CLIENT_IP =>\r
+        state <= x"4";\r
+        if (load_ctr = 15) then\r
+          construct_next_state <= YOUR_IP;\r
+        else\r
+          construct_next_state <= CLIENT_IP;\r
+        end if;\r
+\r
+      when YOUR_IP =>\r
+        state <= x"5";\r
+        if (load_ctr = 19) then\r
+          construct_next_state <= ZEROS1;\r
+        else\r
+          construct_next_state <= YOUR_IP;\r
+        end if;\r
+\r
+      when ZEROS1 =>\r
+        state <= x"6";\r
+        if (load_ctr = 27) then\r
+          construct_next_state <= MY_MAC;\r
+        else\r
+          construct_next_state <= ZEROS1;\r
+        end if;\r
+\r
+      when MY_MAC =>\r
+        state <= x"7";\r
+        if (load_ctr = 33) then\r
+          construct_next_state <= ZEROS2;\r
+        else\r
+          construct_next_state <= MY_MAC;\r
+        end if;\r
+\r
+      when ZEROS2 =>\r
+        state <= x"8";\r
+        if (load_ctr = 235) then\r
+          construct_next_state <= VENDOR_VALS;\r
+        else\r
+          construct_next_state <= ZEROS2;\r
+        end if;\r
+\r
+      when VENDOR_VALS =>\r
+        state <= x"9";\r
+        if (load_ctr = 257) then\r
+          -- for discover it's enough of values\r
+          if (main_current_state = SENDING_DISCOVER) then\r
+            construct_next_state <= TERMINATION;\r
+          -- for request there is some more values needed\r
+          else\r
+            construct_next_state <= VENDOR_VALS2;\r
+          end if;\r
+        else\r
+          construct_next_state <= VENDOR_VALS;\r
+        end if;\r
+\r
+      when VENDOR_VALS2 =>\r
+        state <= x"a";\r
+        if (load_ctr = 263) then\r
+          construct_next_state <= TERMINATION;\r
+        else\r
+          construct_next_state <= VENDOR_VALS2;\r
+        end if;\r
+\r
+      when TERMINATION =>\r
+        state <= x"b";\r
+        construct_next_state <= CLEANUP;\r
+\r
+      when CLEANUP =>\r
+        state <= x"c";\r
+        construct_next_state <= IDLE;\r
+\r
+      when others => construct_next_state <= IDLE;\r
+\r
+    end case;\r
+  end process PROC_CONSTRUCT_TRANSITIONS;\r
+\r
+  PROC_LOAD_CTR: process( CLK )\r
+  begin\r
+    if( rising_edge(CLK) ) then\r
+      if   ( construct_current_state = IDLE ) then\r
+        load_ctr <= 0;\r
+      elsif( (TC_RD_EN_IN = '1') and (PS_SELECTED_IN = '1') ) then\r
+        load_ctr <= load_ctr + 1;\r
+      end if;\r
+    end if;\r
+  end process PROC_LOAD_CTR;\r
+\r
+  PROC_TC_DATA: process( CLK )\r
+  begin\r
+    if( rising_edge(CLK) ) then\r
+      case (construct_current_state) is\r
+\r
+        when BOOTP_HEADERS =>\r
+          for i in 0 to 7 loop\r
+            tc_data(i) <= bootp_hdr(load_ctr * 8 + i);\r
+          end loop;\r
+          tc_data(8) <= '0';\r
+\r
+        when CLIENT_IP =>\r
+          if (main_current_state = SENDING_DISCOVER) then\r
+            tc_data(7 downto 0) <= x"00";\r
+          elsif (main_current_state = SENDING_REQUEST) then\r
+            for i in 0 to 7 loop\r
+              tc_data(i) <= saved_proposed_ip((load_ctr - 12) * 8 + i);\r
+            end loop;\r
+          end if;\r
+          tc_data(8) <= '0';\r
+\r
+        when YOUR_IP =>\r
+          tc_data(7 downto 0) <= x"00";\r
+          tc_data(8) <= '0';\r
+\r
+        when ZEROS1 =>\r
+          tc_data(7 downto 0) <= x"00";\r
+          tc_data(8) <= '0';\r
+\r
+        when MY_MAC =>\r
+          for i in 0 to 7 loop\r
+            tc_data(i) <= MY_MAC_IN((load_ctr - 28) * 8 + i);\r
+          end loop;\r
+          tc_data(8) <= '0';\r
+\r
+        when ZEROS2 =>\r
+          tc_data(7 downto 0) <= x"00";\r
+          tc_data(8) <= '0';\r
+\r
+        when VENDOR_VALS =>\r
+          for i in 0 to 7 loop\r
+            tc_data(i) <= vendor_values((load_ctr - 236) * 8 + i);\r
+          end loop;\r
+          tc_data(8) <= '0';\r
+\r
+        -- needed only for DHCP Request message\r
+        when VENDOR_VALS2 =>\r
+          for i in 0 to 7 loop\r
+            tc_data(i) <= vendor_values2((load_ctr - 258) * 8 + i);\r
+          end loop;\r
+          tc_data(8) <= '0';\r
+\r
+        when TERMINATION =>\r
+          tc_data(7 downto 0) <= x"ff";\r
+          tc_data(8)          <= '1';\r
+\r
+        when others =>\r
+          tc_data(7 downto 0) <= x"00";\r
+          tc_data(8) <= '0';\r
+\r
+      end case;\r
+\r
+      TC_DATA_OUT  <= tc_data;\r
+\r
+    end if;\r
+  end process PROC_TC_DATA;\r
+\r
+  PROC_PS_RESPONSE_SYNC: process( CLK )\r
+  begin\r
+    if( rising_edge(CLK) ) then\r
+      if( construct_current_state = IDLE or construct_current_state = CLEANUP ) then\r
+        PS_RESPONSE_READY_OUT <= '0';\r
+      else\r
+        PS_RESPONSE_READY_OUT <= '1';\r
+      end if;\r
+\r
+      if( construct_current_state = IDLE ) then\r
+        PS_BUSY_OUT <= '0';\r
+      else\r
+        PS_BUSY_OUT <= '1';\r
+      end if;\r
+    end if;\r
+  end process PROC_PS_RESPONSE_SYNC;\r
+\r
+  -- fixed sizes for discover and request messages\r
+  TC_FRAME_SIZE_OUT   <= x"0103" when (main_current_state = SENDING_DISCOVER) else x"0109";\r
+  TC_FRAME_TYPE_OUT   <= x"0008";  -- frame type: ip\r
+  TC_IDENT_OUT        <= x"1" & std_logic_vector(sent_frames(11 downto 0));\r
+\r
+  PROC_SENT_FRAMES: process( CLK )\r
+  begin\r
+    if   ( RESET = '1') then\r
+      sent_frames <= (others => '0');\r
+    elsif( rising_edge(CLK) ) then\r
+      if( construct_current_state = CLEANUP ) then\r
+        sent_frames <= sent_frames + 1;\r
+      end if;\r
+    end if;\r
+  end process PROC_SENT_FRAMES;\r
+\r
+  -- **** debug\r
+--  PROC_DEBUG: process( CLK )\r
+--  begin\r
+--    if( rising_edge(CLK) ) then\r
+      DEBUG_OUT(3 downto 0)   <= state;\r
+      DEBUG_OUT(7 downto 4)   <= state2;\r
+      DEBUG_OUT(11 downto 8)  <= state3;\r
+--    end if;\r
+--  end process PROC_DEBUG;\r
+\r
+  -- ****\r
+\r
+end gbe_response_constructor_DHCP_arch;\r
index 04459c26b052fb913aa42cc682279ec9ced4316e..62bb918d95ec450381072ff984467c7ac54c75e2 100644 (file)
@@ -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,
index a9adacc2afb50a985a76556b12b2c738269ad775..4b603bde7c2a1236bab13d6cb5e61f1b4b86d5e1 100644 (file)
@@ -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));
index 58e8f2e7df004ba00137e67912060c269028036f..9922009d5a098f8ee3c4fcdbedd61480c3d21af3 100644 (file)
@@ -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 )