]> jspc29.x-matter.uni-frankfurt.de Git - trbnet.git/commitdiff
DHCP seems to work now, PING/ARP fails
authorMichael Boehmer <mboehmer@ph.tum.de>
Tue, 1 Nov 2022 09:29:22 +0000 (10:29 +0100)
committerMichael Boehmer <mboehmer@ph.tum.de>
Tue, 1 Nov 2022 09:29:22 +0000 (10:29 +0100)
14 files changed:
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_prioritizer.vhd
gbe_trb/base/gbe_receive_control.vhd
gbe_trb/base/gbe_sci_reader.vhd
gbe_trb/base/gbe_tx_fifo.vhd [new file with mode: 0644]
gbe_trb/base/inserter.vhd
gbe_trb/base/remover.vhd
gbe_trb/protocols/gbe_response_constructor_DHCP.vhd
gbe_trb/protocols/gbe_response_constructor_Forward.vhd
gbe_trb_ecp3/media/gbe_med_fifo.vhd
media_interfaces/sync/gbe_rx_reset.vhd [new file with mode: 0644]
trb_net16_regio_bus_handler_record.vhd

index 099db7705aed3055d9bfc1fddb924dc4d1fe2c9b..8b5967a0b7e265222fb5bfed6c6b3b7dc4d8a495 100644 (file)
@@ -5,7 +5,7 @@ USE IEEE.std_logic_UNSIGNED.ALL;
 \r
 library work;\r
 use work.trb_net_std.all;\r
-use work.trb_net_components.all;\r
+--use work.trb_net_components.all;\r
 use work.gbe_protocols.all;\r
 \r
 --********\r
@@ -19,699 +19,737 @@ use work.gbe_protocols.all;
 -- data by FR_FRAME_VALID_OUT.\r
 \r
 entity gbe_frame_receiver is\r
-port (\r
-  CLK                     : in  std_logic;  -- system clock\r
-  RESET                   : in  std_logic;\r
-  LINK_OK_IN              : in  std_logic;\r
-  ALLOW_RX_IN             : in  std_logic;\r
-  MY_MAC_IN               : in  std_logic_vector(47 downto 0);\r
--- killer ping\r
-  MY_TRBNET_ADDRESS_IN    : in  std_logic_vector(15 downto 0) := (others => '0');\r
-  ISSUE_REBOOT_OUT        : out std_logic;\r
--- input signals from TS_MAC\r
-  MAC_RX_EOF_IN           : in  std_logic; -- End Of Frame\r
-  MAC_RX_ER_IN            : in  std_logic; -- only for statistics\r
-  MAC_RXD_IN              : in  std_logic_vector(7 downto 0); -- RX data\r
-  MAC_RX_EN_IN            : in  std_logic; -- write signal\r
--- output signal to control logic\r
-  FR_Q_OUT                : out std_logic_vector(8 downto 0);\r
-  FR_RD_EN_IN             : in  std_logic;\r
-  FR_FRAME_VALID_OUT      : out std_logic;\r
-  FR_GET_FRAME_IN         : in  std_logic;\r
-  FR_FRAME_SIZE_OUT       : out std_logic_vector(15 downto 0);\r
-  FR_FRAME_PROTO_OUT      : out std_logic_vector(15 downto 0);\r
-  FR_IP_PROTOCOL_OUT      : out std_logic_vector(7 downto 0);\r
-  FR_ALLOWED_TYPES_IN     : in  std_logic_vector(31 downto 0);\r
-  FR_ALLOWED_IP_IN        : in  std_logic_vector(31 downto 0);\r
-  FR_ALLOWED_UDP_IN       : in  std_logic_vector(31 downto 0);\r
-  FR_VLAN_ID_IN           : in  std_logic_vector(31 downto 0);\r
---\r
-  FR_SRC_MAC_ADDRESS_OUT  : out std_logic_vector(47 downto 0);\r
-  FR_DEST_MAC_ADDRESS_OUT : out std_logic_vector(47 downto 0);\r
-  FR_SRC_IP_ADDRESS_OUT   : out std_logic_vector(31 downto 0);\r
-  FR_DEST_IP_ADDRESS_OUT  : out std_logic_vector(31 downto 0);\r
-  FR_SRC_UDP_PORT_OUT     : out std_logic_vector(15 downto 0);\r
-  FR_DEST_UDP_PORT_OUT    : out std_logic_vector(15 downto 0);\r
---\r
-  OOB_REGISTER_0_OUT      : out std_logic_vector(31 downto 0);\r
-  OOB_REGISTER_1_OUT      : out std_logic_vector(31 downto 0);\r
-  OOB_REGISTER_2_OUT      : out std_logic_vector(31 downto 0);\r
-  OOB_REGISTER_3_OUT      : out std_logic_vector(31 downto 0);\r
---\r
-  MONITOR_RX_BYTES_OUT    : out std_logic_vector(31 downto 0);\r
-  MONITOR_RX_FRAMES_OUT   : out std_logic_vector(31 downto 0);\r
-  MONITOR_DROPPED_OUT     : out std_logic_vector(31 downto 0);\r
-  DEBUG_OUT               : out std_logic_vector(15 downto 0)\r
-);\r
+  port(\r
+    CLK                     : in  std_logic;  -- system clock\r
+    RESET                   : in  std_logic;\r
+    LINK_OK_IN              : in  std_logic;\r
+    ALLOW_RX_IN             : in  std_logic;\r
+    MY_MAC_IN               : in  std_logic_vector(47 downto 0);\r
+  -- killer ping\r
+    MY_TRBNET_ADDRESS_IN    : in  std_logic_vector(15 downto 0) := (others => '0');\r
+    ISSUE_REBOOT_OUT        : out std_logic;\r
+  -- input signals from TS_MAC\r
+    MAC_RX_EOF_IN           : in  std_logic; -- End Of Frame\r
+    MAC_RX_ER_IN            : in  std_logic; -- only for statistics\r
+    MAC_RXD_IN              : in  std_logic_vector(7 downto 0); -- RX data\r
+    MAC_RX_EN_IN            : in  std_logic; -- write signal\r
+  -- output signal to control logic\r
+    FR_Q_OUT                : out std_logic_vector(8 downto 0); -- interconnect to gbe_receive_control\r
+    FR_RD_EN_IN             : in  std_logic; -- interconnect to gbe_receive_control\r
+    FR_FRAME_VALID_OUT      : out std_logic; -- interconnect to gbe_receive_control\r
+    FR_GET_FRAME_IN         : in  std_logic; -- interconnect to gbe_receive_control\r
+    FR_FRAME_SIZE_OUT       : out std_logic_vector(15 downto 0); -- interconnect to gbe_receive_control\r
+    FR_FRAME_PROTO_OUT      : out std_logic_vector(15 downto 0); -- interconnect to gbe_receive_control\r
+    FR_IP_PROTOCOL_OUT      : out std_logic_vector(7 downto 0); -- interconnect to gbe_receive_control\r
+    FR_PS_OUT               : out std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0);\r
+  --\r
+    FR_SRC_MAC_ADDRESS_OUT  : out std_logic_vector(47 downto 0);\r
+    FR_DEST_MAC_ADDRESS_OUT : out std_logic_vector(47 downto 0);\r
+    FR_SRC_IP_ADDRESS_OUT   : out std_logic_vector(31 downto 0);\r
+    FR_DEST_IP_ADDRESS_OUT  : out std_logic_vector(31 downto 0);\r
+    FR_SRC_UDP_PORT_OUT     : out std_logic_vector(15 downto 0);\r
+    FR_DEST_UDP_PORT_OUT    : out std_logic_vector(15 downto 0);\r
+  --\r
+    OOB_REGISTER_0_OUT      : out std_logic_vector(31 downto 0);\r
+    OOB_REGISTER_1_OUT      : out std_logic_vector(31 downto 0);\r
+    OOB_REGISTER_2_OUT      : out std_logic_vector(31 downto 0);\r
+    OOB_REGISTER_3_OUT      : out std_logic_vector(31 downto 0);\r
+  --\r
+    MONITOR_RX_BYTES_OUT    : out std_logic_vector(31 downto 0);\r
+    MONITOR_RX_FRAMES_OUT   : out std_logic_vector(31 downto 0);\r
+    MONITOR_DROPPED_OUT     : out std_logic_vector(31 downto 0);\r
+    DEBUG_OUT               : out std_logic_vector(31 downto 0)\r
+  );\r
 end gbe_frame_receiver;\r
 \r
-architecture gbe_frame_receiver_arch of gbe_frame_receiver is\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
+-- Second check is done inside gbe_type_validator: IPV4 UDP with correct port number are accepted,\r
+-- as well as ICMP inside IPv4. In addition, in gbe_protocols more accepted combinations can be defined.\r
+-- VLAN tagged frames are accepted, in case of tag == 0x0000, or if the VLAN tag is identical to one of the\r
+-- two stored ones.\r
 \r
-attribute syn_encoding  : string;\r
-type filter_states is (IDLE, REMOVE_DEST, REMOVE_SRC, REMOVE_TYPE, SAVE_FRAME, DROP_FRAME,\r
-                       REMOVE_VID, REMOVE_VTYPE, REMOVE_IP, REMOVE_UDP, DECIDE, CLEANUP);\r
-signal filter_current_state, filter_next_state : filter_states;\r
-attribute syn_encoding of filter_current_state : signal is "onehot";\r
-\r
-signal fifo_wr_en                           : std_logic;\r
-signal rx_bytes_ctr                         : std_logic_vector(15 downto 0);\r
-signal frame_valid_q                        : std_logic;\r
-signal delayed_frame_valid                  : std_logic;\r
-signal delayed_frame_valid_q                : std_logic;\r
-\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
-signal new_frame_lock                       : std_logic := '0';\r
-signal saved_frame_type                     : std_logic_vector(15 downto 0);\r
-signal saved_vid                            : std_logic_vector(15 downto 0) := (others => '0');\r
-signal saved_src_mac                        : std_logic_vector(47 downto 0);\r
-signal saved_dest_mac                       : std_logic_vector(47 downto 0);\r
-signal frame_type_valid                     : std_logic;\r
-signal saved_proto                          : std_logic_vector(7 downto 0);\r
-signal saved_src_ip                         : std_logic_vector(31 downto 0);\r
-signal saved_dest_ip                        : std_logic_vector(31 downto 0);\r
-signal saved_src_udp                        : std_logic_vector(15 downto 0);\r
-signal saved_dest_udp                       : std_logic_vector(15 downto 0);\r
-\r
-signal error_frames_ctr                     : unsigned(15 downto 0);\r
-signal dbg_rec_frames                       : unsigned(31 downto 0);\r
-signal dbg_drp_frames                       : unsigned(31 downto 0);\r
-signal mon_rec_bytes                        : unsigned(31 downto 0);\r
-\r
-signal state                                : std_logic_vector(3 downto 0);\r
-\r
-signal rx_data                              : std_logic_vector(8 downto 0);\r
-signal fr_q                                 : std_logic_vector(8 downto 0);\r
-\r
-signal fr_src_ip                            : std_logic_vector(31 downto 0);\r
-signal fr_dest_ip                           : std_logic_vector(31 downto 0);\r
-signal fr_dest_udp                          : std_logic_vector(15 downto 0);\r
-signal fr_src_udp                           : std_logic_vector(15 downto 0);\r
-signal fr_frame_size                        : std_logic_vector(15 downto 0);\r
-signal fr_frame_proto                       : std_logic_vector(15 downto 0);\r
-signal fr_dest_mac                          : std_logic_vector(47 downto 0);\r
-signal fr_src_mac                           : std_logic_vector(47 downto 0);\r
-signal fr_ip_proto                          : std_logic_vector(7 downto 0);\r
-\r
-signal xxx0                                 : std_logic_vector(7 downto 0);\r
-signal xxx1                                 : std_logic_vector(7 downto 0);\r
-\r
-signal oob_register_0_int                   : std_logic_vector(31 downto 0);\r
-signal oob_register_1_int                   : std_logic_vector(31 downto 0);\r
-signal oob_register_2_int                   : std_logic_vector(31 downto 0);\r
-signal oob_register_3_int                   : std_logic_vector(31 downto 0);\r
-signal oob_write                            : std_logic;\r
-\r
-attribute syn_preserve : boolean;\r
-attribute syn_keep : boolean;\r
-attribute syn_keep of rec_fifo_empty, rec_fifo_full, state, sizes_fifo_empty, sizes_fifo_full : signal is true;\r
-attribute syn_preserve of rec_fifo_empty, rec_fifo_full, state, sizes_fifo_empty, sizes_fifo_full : signal is true;\r
+-- BUG: MAC_RX_ERROR is not really used. Broken frames will not be discarded!\r
 \r
-begin\r
+-- BUG: no protection against overflow of FIFOs!\r
 \r
--- new_frame is asserted when first byte of the frame arrives\r
-THE_NEW_FRAME_PROC: process( CLK )\r
-begin\r
-  if( rising_edge(CLK) )then\r
-    if   ( (LINK_OK_IN = '0') or (MAC_RX_EOF_IN = '1') ) then\r
-      new_frame <= '0';\r
-      new_frame_lock <= '0';\r
-    elsif( (new_frame_lock = '0') and (MAC_RX_EN_IN = '1') ) then\r
-      new_frame <= '1';\r
-      new_frame_lock <= '1';\r
-    else\r
-      new_frame <= '0';\r
-    end if;\r
-  end if;\r
-end process THE_NEW_FRAME_PROC;\r
+architecture gbe_frame_receiver_arch of gbe_frame_receiver is\r
 \r
-THE_FILTER_MACHINE_PROC: process( CLK, RESET )\r
-begin\r
-  if   ( RESET = '1' ) then\r
-    filter_current_state <= IDLE;\r
-  elsif( rising_edge(CLK) ) then\r
-    filter_current_state <= filter_next_state;\r
-  end if;\r
-end process THE_FILTER_MACHINE_PROC;\r
+  attribute syn_encoding  : string;\r
+  type filter_states is (IDLE, REMOVE_DEST, REMOVE_SRC, REMOVE_TYPE, SAVE_FRAME, DROP_FRAME,\r
+                         REMOVE_IP, REMOVE_UDP, DELAY, CLEANUP);\r
+  signal filter_current_state, filter_next_state : filter_states;\r
+  attribute syn_encoding of filter_current_state : signal is "onehot";\r
+\r
+  signal fifo_wr_en                           : std_logic;\r
+  signal rx_bytes_ctr                         : std_logic_vector(15 downto 0);\r
+  signal frame_valid_q                        : std_logic;\r
+  signal delayed_frame_valid                  : std_logic;\r
+  signal delayed_frame_valid_q                : std_logic;\r
+\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
+  signal new_frame_lock                       : std_logic := '0';\r
+  signal saved_frame_type                     : std_logic_vector(15 downto 0);\r
+  signal saved_src_mac                        : std_logic_vector(47 downto 0);\r
+  signal saved_dest_mac                       : std_logic_vector(47 downto 0);\r
+  signal frame_type_valid                     : std_logic;\r
+  signal saved_proto                          : std_logic_vector(7 downto 0);\r
+  signal saved_src_ip                         : std_logic_vector(31 downto 0);\r
+  signal saved_dest_ip                        : std_logic_vector(31 downto 0);\r
+  signal saved_src_udp                        : std_logic_vector(15 downto 0);\r
+  signal saved_dest_udp                       : std_logic_vector(15 downto 0);\r
+\r
+  signal error_frames_ctr                     : unsigned(15 downto 0);\r
+  signal dbg_rec_frames                       : unsigned(31 downto 0);\r
+  signal dbg_drp_frames                       : unsigned(31 downto 0);\r
+  signal mon_rec_bytes                        : unsigned(31 downto 0);\r
+\r
+  signal state                                : std_logic_vector(3 downto 0);\r
+\r
+  signal rx_data                              : std_logic_vector(8 downto 0);\r
+  signal fr_q                                 : std_logic_vector(8 downto 0);\r
+\r
+  signal fr_src_ip                            : std_logic_vector(31 downto 0);\r
+  signal fr_dest_ip                           : std_logic_vector(31 downto 0);\r
+  signal fr_dest_udp                          : std_logic_vector(15 downto 0);\r
+  signal fr_src_udp                           : std_logic_vector(15 downto 0);\r
+  signal fr_frame_size                        : std_logic_vector(15 downto 0);\r
+  signal fr_frame_proto                       : std_logic_vector(15 downto 0);\r
+  signal fr_dest_mac                          : std_logic_vector(47 downto 0);\r
+  signal fr_src_mac                           : std_logic_vector(47 downto 0);\r
+  signal fr_ip_proto                          : std_logic_vector(7 downto 0);\r
+  signal fr_ps                                : std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0);\r
+\r
+  signal xxx0                                 : std_logic_vector(7 downto 0);\r
+  signal xxx1                                 : std_logic_vector(7 downto 0);\r
+\r
+  signal oob_register_0_int                   : std_logic_vector(31 downto 0);\r
+  signal oob_register_1_int                   : std_logic_vector(31 downto 0);\r
+  signal oob_register_2_int                   : std_logic_vector(31 downto 0);\r
+  signal oob_register_3_int                   : std_logic_vector(31 downto 0);\r
+  signal oob_write                            : std_logic;\r
+\r
+  signal proto_select_x                       : std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0);\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
-THE_FILTER_MACHINE : 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
 begin\r
-  case filter_current_state is\r
 \r
-    when IDLE =>\r
-      state <= x"1";\r
-      if( (new_frame = '1') and (ALLOW_RX_IN = '1') and (LINK_OK_IN = '1') ) then\r
-        filter_next_state <= REMOVE_DEST;\r
+  -- Debug lines\r
+  DEBUG_OUT(31 downto 26) <= (others => '0');\r
+  \r
+  DEBUG_OUT(15)           <= frame_valid_q;\r
+  DEBUG_OUT(14)           <= fifo_wr_en;\r
+  DEBUG_OUT(13)           <= frame_type_valid;\r
+  DEBUG_OUT(12)           <= new_frame_lock;\r
+  DEBUG_OUT(11)           <= new_frame;\r
+  DEBUG_OUT(10)           <= MAC_RX_ER_IN;\r
+  DEBUG_OUT(9)            <= MAC_RX_EOF_IN;\r
+  DEBUG_OUT(8)            <= MAC_RX_EN_IN;\r
+  DEBUG_OUT(7 downto 0)   <= MAC_RXD_IN;\r
+\r
+  -- new_frame is asserted when first byte of the frame arrives\r
+  PROC_NEW_FRAME: process( CLK )\r
+  begin\r
+    if( rising_edge(CLK) )then\r
+      if   ( (LINK_OK_IN = '0') or (MAC_RX_EOF_IN = '1') ) then\r
+        new_frame <= '0';\r
+        new_frame_lock <= '0';\r
+      elsif( (new_frame_lock = '0') and (MAC_RX_EN_IN = '1') ) then\r
+        new_frame <= '1';\r
+        new_frame_lock <= '1';\r
       else\r
-        filter_next_state <= IDLE;\r
+        new_frame <= '0';\r
       end if;\r
+    end if;\r
+  end process PROC_NEW_FRAME;\r
+\r
+  PROC_FILTER_FSM: process( CLK, RESET )\r
+  begin\r
+    if   ( RESET = '1' ) then\r
+      filter_current_state <= IDLE;\r
+    elsif( rising_edge(CLK) ) then\r
+      filter_current_state <= filter_next_state;\r
+    end if;\r
+  end process PROC_FILTER_FSM;\r
 \r
-    -- frames arrive without preamble!\r
-    when REMOVE_DEST =>\r
-      state <= x"3";\r
-      if( remove_ctr = x"03" ) then  -- counter starts with a delay that's why only 3\r
-        -- destination MAC address filtering here\r
-        if( (saved_dest_mac = MY_MAC_IN) or (saved_dest_mac = x"ffffffffffff") ) then  -- must accept broadcasts for ARP\r
-          filter_next_state <= REMOVE_SRC;\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
+  begin\r
+    set_proto_x <= (others => '0');\r
+\r
+    case filter_current_state is\r
+\r
+      when IDLE =>\r
+        state <= x"1";\r
+        if( (new_frame = '1') and (ALLOW_RX_IN = '1') and (LINK_OK_IN = '1') ) then\r
+          filter_next_state <= REMOVE_DEST;\r
         else\r
-          filter_next_state <= DECIDE;\r
+          filter_next_state <= IDLE;\r
         end if;\r
-      else\r
-        filter_next_state <= REMOVE_DEST;\r
-      end if;\r
 \r
-    when REMOVE_SRC =>\r
-      state <= x"4";\r
-      if( remove_ctr = x"09" ) then\r
-        filter_next_state <= REMOVE_TYPE;\r
-      else\r
-        filter_next_state <= REMOVE_SRC;\r
-      end if;\r
-\r
-    when REMOVE_TYPE =>\r
-      state <= x"5";\r
-      if( remove_ctr = x"0b" ) then\r
-        if( saved_frame_type = x"8100" ) then  -- VLAN tagged frame\r
-          filter_next_state <= REMOVE_VID;\r
-        else  -- no VLAN tag\r
-          if( saved_frame_type = x"0800" ) then  -- in case of IP continue removing headers\r
-            filter_next_state <= REMOVE_IP;\r
+      -- frames arrive without preamble!\r
+      when REMOVE_DEST =>\r
+        state <= x"3";\r
+        if( remove_ctr = x"03" ) then  -- counter starts with a delay that's why only 3\r
+          -- destination MAC address filtering here\r
+          if( (saved_dest_mac = MY_MAC_IN) or (saved_dest_mac = x"ffffffffffff") ) then  -- must accept broadcasts for ARP\r
+            filter_next_state <= REMOVE_SRC;\r
           else\r
-            filter_next_state <= DECIDE;\r
+            filter_next_state <= DROP_FRAME; -- wrong MAC, were are done\r
+            -- could be done in REMOVE_SRC to gain some clock cycles\r
           end if;\r
+        else\r
+          filter_next_state <= REMOVE_DEST;\r
         end if;\r
-      else\r
-        filter_next_state <= REMOVE_TYPE;\r
-      end if;\r
-\r
-    when REMOVE_VID =>\r
-      state <= x"a";\r
-      if( remove_ctr = x"0d" ) then\r
-        filter_next_state <= REMOVE_VTYPE;\r
-      else\r
-        filter_next_state <= REMOVE_VID;\r
-      end if;\r
 \r
-    when REMOVE_VTYPE =>\r
-      state <= x"b";\r
-      if( remove_ctr = x"0f" ) then\r
-        if( saved_frame_type = x"0800" ) then  -- in case of IP continue removing headers\r
-          filter_next_state <= REMOVE_IP;\r
+      when REMOVE_SRC =>\r
+        state <= x"4";\r
+        if( remove_ctr = x"09" ) then\r
+          filter_next_state <= REMOVE_TYPE;\r
         else\r
-          filter_next_state <= DECIDE;\r
+          filter_next_state <= REMOVE_SRC;\r
         end if;\r
-      else\r
-        filter_next_state <= REMOVE_VTYPE;\r
-      end if;\r
 \r
-    when REMOVE_IP =>\r
-      state <= x"c";\r
-      if( remove_ctr = x"11" ) then\r
-        if( saved_proto = x"11" ) then  -- forced to recognize udp only, TODO check all protocols\r
-          filter_next_state <= REMOVE_UDP;\r
+      when REMOVE_TYPE =>\r
+        state <= x"5";\r
+        if( remove_ctr = x"0b" ) then\r
+          case saved_frame_type is \r
+            when x"0800" =>\r
+              -- IPv4 frame, to be investigated\r
+              filter_next_state <= REMOVE_IP;\r
+            when x"0806" =>\r
+              -- ARP frame, to be stored\r
+              filter_next_state <= DELAY;\r
+              set_proto_x(0) <= '1';\r
+              -- NB: first two bytes of ARP frame are dropped silently\r
+            when others =>\r
+              filter_next_state <= DROP_FRAME;\r
+          end case;\r
         else\r
-          filter_next_state <= DECIDE;  -- changed from drop\r
+          filter_next_state <= REMOVE_TYPE;\r
         end if;\r
-      else\r
-        filter_next_state <= REMOVE_IP;\r
-      end if;\r
 \r
-    when REMOVE_UDP =>\r
-      state <= x"d";\r
-      if( remove_ctr = x"19" ) then\r
-        filter_next_state <= DECIDE;\r
-      else\r
-        filter_next_state <= REMOVE_UDP;\r
-      end if;\r
+      when REMOVE_IP =>\r
+        state <= x"c";\r
+        if( remove_ctr = x"11" ) then\r
+          -- BUG: add check for 0x45 (IP version, header length) here.\r
+          --      Drop frames which do not comply with this!\r
+          case saved_proto is\r
+            when x"11" =>\r
+              -- UDP, to be investigated\r
+              filter_next_state <= REMOVE_UDP;\r
+            when x"01" =>\r
+              -- ICMP, to be stored \r
+              filter_next_state <= DELAY;\r
+              set_proto_x(4) <= '1';\r
+            when others =>\r
+              filter_next_state <= DROP_FRAME;\r
+          end case;\r
+        else\r
+          filter_next_state <= REMOVE_IP;\r
+        end if;\r
 \r
-    when DECIDE =>\r
-      state <= x"6";\r
-      if   ( frame_type_valid = '1' ) then\r
-        filter_next_state <= SAVE_FRAME;\r
-      elsif( saved_frame_type = x"0806" ) then\r
-        -- ARP?\r
-        filter_next_state <= SAVE_FRAME;\r
-      else\r
-        filter_next_state <= DROP_FRAME;\r
-      end if;\r
+      when REMOVE_UDP =>\r
+        state <= x"d";\r
+        if( remove_ctr = x"19" ) then\r
+          case saved_dest_udp is\r
+            when x"0044" =>\r
+              -- DHCP frame, to be stored\r
+              filter_next_state <= DELAY;\r
+              set_proto_x(1) <= '1';\r
+            when x"6590" =>\r
+              -- SCTRL frame, to be stored\r
+              filter_next_state <= DELAY;\r
+              set_proto_x(2) <= '1';\r
+            when others =>\r
+              filter_next_state <= DROP_FRAME;\r
+            end case;\r
+        else\r
+          filter_next_state <= REMOVE_UDP;\r
+        end if;\r
 \r
-    when SAVE_FRAME =>\r
-      state <= x"7";\r
-      if( MAC_RX_EOF_IN = '1' ) then\r
-        filter_next_state <= CLEANUP;\r
-      else\r
+      when DELAY =>\r
+        state <= x"6";\r
         filter_next_state <= SAVE_FRAME;\r
-      end if;\r
 \r
-    when DROP_FRAME =>\r
-      state <= x"8";\r
-      if( MAC_RX_EOF_IN = '1' ) then\r
-        filter_next_state <= CLEANUP;\r
-      else\r
-        filter_next_state <= DROP_FRAME;\r
-      end if;\r
-\r
-    when CLEANUP =>\r
-      state <= x"9";\r
-      filter_next_state <= IDLE;\r
-\r
-    when others => null;\r
+      when SAVE_FRAME =>\r
+        state <= x"7";\r
+        if( MAC_RX_EOF_IN = '1' ) then\r
+          filter_next_state <= CLEANUP;\r
+        else\r
+          filter_next_state <= SAVE_FRAME;\r
+        end if;\r
 \r
-  end case;\r
-end process THE_FILTER_MACHINE;\r
+      when DROP_FRAME =>\r
+        state <= x"8";\r
+        if( MAC_RX_EOF_IN = '1' ) then\r
+          filter_next_state <= CLEANUP;\r
+        else\r
+          filter_next_state <= DROP_FRAME;\r
+        end if;\r
 \r
--- counts the bytes to be removed from the ethernet headers fields\r
-REMOVE_CTR_PROC: process( CLK )\r
-begin\r
-  if( rising_edge(CLK) ) then\r
-    if   ( (filter_current_state = IDLE) or\r
-           ((filter_current_state = REMOVE_VTYPE) and (remove_ctr = x"0f")) or\r
-           ((filter_current_state = REMOVE_TYPE) and (remove_ctr = x"0b") and (saved_frame_type /= x"8100")) ) then\r
-      remove_ctr <= (others => '1');\r
-    elsif( (MAC_RX_EN_IN = '1') and (filter_current_state /= IDLE) ) then\r
-      remove_ctr <= remove_ctr + 1;\r
-    end if;\r
- end if;\r
-end process REMOVE_CTR_PROC;\r
+      when CLEANUP =>\r
+        state <= x"9";\r
+        filter_next_state <= IDLE;\r
 \r
-THE_SAVED_PROTO_PROC: process( CLK )\r
-begin\r
-  if( rising_edge(CLK) ) then\r
-    if   ( filter_current_state = CLEANUP ) then\r
-      saved_proto <= (others => '0');\r
-    elsif( (filter_current_state = REMOVE_IP) and (remove_ctr = x"07") ) then\r
-      saved_proto <= MAC_RXD_IN;\r
+      when others => null;\r
+\r
+    end case;\r
+  end process PROC_FILTER_TRANSITIONS;\r
+\r
+  -- determine the protocol handler for later usage\r
+  -- ARP\r
+  proto_select_x(0) <= '1' when ( (saved_frame_type = x"0806") ) else '0';\r
+  -- DHCP\r
+  proto_select_x(1) <= '1' when ( (saved_frame_type = x"0800") and (saved_proto = x"11") and (saved_dest_udp = x"0044") ) else '0';\r
+  -- SCTRL\r
+  proto_select_x(2) <= '1' when ( (saved_frame_type = x"0800") and (saved_proto = x"11") and (saved_dest_udp = x"6590") ) else '0';\r
+  -- ???\r
+  proto_select_x(3) <= '0';\r
+  -- ICMP\r
+  proto_select_x(4) <= '1' when ( (saved_frame_type = x"0800") and (saved_proto = x"01") ) else '0';\r
+  -- FWD???\r
+  proto_select_x(5) <= '0';\r
+  -- TO BE INCLUDED INTO FSM!!!\r
+\r
+  -- protocol selection\r
+  PROC_PROTO_SEL: process( CLK, RESET )\r
+  begin\r
+    if   ( RESET = '1' ) then\r
+      proto_select <= (others => '0');\r
+    elsif( rising_edge(CLK) ) then\r
+      for I in c_MAX_PROTOCOLS - 1 downto 0 loop\r
+        if   ( set_proto_x(I) = '1' ) then\r
+          proto_select(I) <= '1';\r
+        elsif( filter_current_state = CLEANUP ) then\r
+          proto_select(I) <= '0';\r
+        end if;\r
+      end loop;\r
     end if;\r
+  end process PROC_PROTO_SEL;\r
+\r
+  -- counts the bytes to be removed from the ethernet headers fields\r
+  PROC_REMOVE_CTR: process( CLK )\r
+  begin\r
+    if( rising_edge(CLK) ) then\r
+      if   ( (filter_current_state = IDLE) or\r
+            ((filter_current_state = REMOVE_TYPE) and (remove_ctr = x"0b")) ) then\r
+        remove_ctr <= (others => '1');\r
+      elsif( (MAC_RX_EN_IN = '1') and (filter_current_state /= IDLE) ) then\r
+        remove_ctr <= remove_ctr + 1;\r
+      end if;\r
   end if;\r
-end process THE_SAVED_PROTO_PROC;\r
-\r
--- saves the destination mac address of the incoming frame\r
-THE_SAVED_DEST_MAC_PROC: process( CLK )\r
-begin\r
-  if( rising_edge(CLK) ) then\r
-    if   ( filter_current_state = CLEANUP ) then\r
-      saved_dest_mac <= (others => '0');\r
-    elsif( (filter_current_state = IDLE) and (MAC_RX_EN_IN = '1') and (new_frame = '0') ) then\r
-      saved_dest_mac(7 downto 0) <= MAC_RXD_IN;\r
-    elsif( (filter_current_state = IDLE) and (new_frame = '1') and (ALLOW_RX_IN = '1') ) then\r
-      saved_dest_mac(15 downto 8) <= MAC_RXD_IN;\r
-    elsif( (filter_current_state = REMOVE_DEST) and (remove_ctr = x"FF") ) then\r
-      saved_dest_mac(23 downto 16) <= MAC_RXD_IN;\r
-    elsif( (filter_current_state = REMOVE_DEST) and (remove_ctr = x"00") ) then\r
-      saved_dest_mac(31 downto 24) <= MAC_RXD_IN;\r
-    elsif( (filter_current_state = REMOVE_DEST) and (remove_ctr = x"01") ) then\r
-      saved_dest_mac(39 downto 32) <= MAC_RXD_IN;\r
-    elsif( (filter_current_state = REMOVE_DEST) and (remove_ctr = x"02") ) then\r
-      saved_dest_mac(47 downto 40) <= MAC_RXD_IN;\r
+  end process PROC_REMOVE_CTR;\r
+\r
+  -- saves the IP protocol\r
+  PROC_SAVED_PROTO: process( CLK )\r
+  begin\r
+    if( rising_edge(CLK) ) then\r
+      if   ( filter_current_state = CLEANUP ) then\r
+        saved_proto <= (others => '0');\r
+      elsif( (filter_current_state = REMOVE_IP) and (remove_ctr = x"07") ) then\r
+        saved_proto <= MAC_RXD_IN;\r
+      end if;\r
     end if;\r
-  end if;\r
-end process THE_SAVED_DEST_MAC_PROC;\r
-\r
--- saves the source mac address of the incoming frame\r
-THE_SAVED_SRC_MAC_PROC: process( CLK )\r
-begin\r
-  if( rising_edge(CLK) ) then\r
-    if   ( filter_current_state = CLEANUP ) then\r
-      saved_src_mac <= (others => '0');\r
-    elsif( (filter_current_state = REMOVE_DEST) and (remove_ctr = x"03") )then\r
-      saved_src_mac(7 downto 0) <= MAC_RXD_IN;\r
-    elsif( (filter_current_state = REMOVE_SRC) and (remove_ctr = x"04") ) then\r
-      saved_src_mac(15 downto 8) <= MAC_RXD_IN;\r
-    elsif( (filter_current_state = REMOVE_SRC) and (remove_ctr = x"05") ) then\r
-      saved_src_mac(23 downto 16) <= MAC_RXD_IN;\r
-    elsif( (filter_current_state = REMOVE_SRC) and (remove_ctr = x"06") ) then\r
-      saved_src_mac(31 downto 24) <= MAC_RXD_IN;\r
-    elsif( (filter_current_state = REMOVE_SRC) and (remove_ctr = x"07") ) then\r
-      saved_src_mac(39 downto 32) <= MAC_RXD_IN;\r
-    elsif( (filter_current_state = REMOVE_SRC) and (remove_ctr = x"08") ) then\r
-      saved_src_mac(47 downto 40) <= MAC_RXD_IN;\r
+  end process PROC_SAVED_PROTO;\r
+\r
+  -- saves the destination mac address of the incoming frame\r
+  PROC_SAVED_DEST_MAC: process( CLK )\r
+  begin\r
+    if( rising_edge(CLK) ) then\r
+      if   ( filter_current_state = CLEANUP ) then\r
+        saved_dest_mac <= (others => '0');\r
+      elsif( (filter_current_state = IDLE) and (MAC_RX_EN_IN = '1') and (new_frame = '0') ) then\r
+        saved_dest_mac(7 downto 0) <= MAC_RXD_IN;\r
+      elsif( (filter_current_state = IDLE) and (new_frame = '1') and (ALLOW_RX_IN = '1') ) then\r
+        saved_dest_mac(15 downto 8) <= MAC_RXD_IN;\r
+      elsif( (filter_current_state = REMOVE_DEST) and (remove_ctr = x"FF") ) then\r
+        saved_dest_mac(23 downto 16) <= MAC_RXD_IN;\r
+      elsif( (filter_current_state = REMOVE_DEST) and (remove_ctr = x"00") ) then\r
+        saved_dest_mac(31 downto 24) <= MAC_RXD_IN;\r
+      elsif( (filter_current_state = REMOVE_DEST) and (remove_ctr = x"01") ) then\r
+        saved_dest_mac(39 downto 32) <= MAC_RXD_IN;\r
+      elsif( (filter_current_state = REMOVE_DEST) and (remove_ctr = x"02") ) then\r
+        saved_dest_mac(47 downto 40) <= MAC_RXD_IN;\r
+      end if;\r
     end if;\r
-  end if;\r
-end process THE_SAVED_SRC_MAC_PROC;\r
-\r
--- saves the frame type of the incoming frame for futher check\r
-THE_SAVED_FRAME_TYPE_PROC: process( CLK )\r
-begin\r
-  if( rising_edge(CLK) ) then\r
-    if   ( filter_current_state = CLEANUP ) then\r
-      saved_frame_type <= (others => '0');\r
-    elsif( (filter_current_state = REMOVE_SRC) and (remove_ctr = x"09") ) then\r
-      saved_frame_type(15 downto 8) <= MAC_RXD_IN;\r
-    elsif( (filter_current_state = REMOVE_TYPE) and (remove_ctr = x"0a") ) then\r
-      saved_frame_type(7 downto 0) <= MAC_RXD_IN;\r
-    -- two more cases for VLAN tagged frame\r
-    elsif( (filter_current_state = REMOVE_VID) and (remove_ctr = x"0d") ) then\r
-      saved_frame_type(15 downto 8) <= MAC_RXD_IN;\r
-    elsif( (filter_current_state = REMOVE_VTYPE) and (remove_ctr = x"0e") ) then\r
-      saved_frame_type(7 downto 0) <= MAC_RXD_IN;\r
+  end process PROC_SAVED_DEST_MAC;\r
+\r
+  -- saves the source mac address of the incoming frame\r
+  PROC_SAVED_SRC_MAC: process( CLK )\r
+  begin\r
+    if( rising_edge(CLK) ) then\r
+      if   ( filter_current_state = CLEANUP ) then\r
+        saved_src_mac <= (others => '0');\r
+      elsif( (filter_current_state = REMOVE_DEST) and (remove_ctr = x"03") )then\r
+        saved_src_mac(7 downto 0) <= MAC_RXD_IN;\r
+      elsif( (filter_current_state = REMOVE_SRC) and (remove_ctr = x"04") ) then\r
+        saved_src_mac(15 downto 8) <= MAC_RXD_IN;\r
+      elsif( (filter_current_state = REMOVE_SRC) and (remove_ctr = x"05") ) then\r
+        saved_src_mac(23 downto 16) <= MAC_RXD_IN;\r
+      elsif( (filter_current_state = REMOVE_SRC) and (remove_ctr = x"06") ) then\r
+        saved_src_mac(31 downto 24) <= MAC_RXD_IN;\r
+      elsif( (filter_current_state = REMOVE_SRC) and (remove_ctr = x"07") ) then\r
+        saved_src_mac(39 downto 32) <= MAC_RXD_IN;\r
+      elsif( (filter_current_state = REMOVE_SRC) and (remove_ctr = x"08") ) then\r
+        saved_src_mac(47 downto 40) <= MAC_RXD_IN;\r
+      end if;\r
     end if;\r
-  end if;\r
-end process THE_SAVED_FRAME_TYPE_PROC;\r
-\r
-THE_SAVED_SRC_IP_PROC: process( CLK )\r
-begin\r
-  if( rising_edge(CLK) ) then\r
-    if   ( filter_current_state = CLEANUP ) then\r
-      saved_src_ip <= (others => '0');\r
-    elsif( (filter_current_state = REMOVE_IP) and (remove_ctr = x"0a") ) then\r
-      saved_src_ip(7 downto 0) <= MAC_RXD_IN;\r
-    elsif( (filter_current_state = REMOVE_IP) and (remove_ctr = x"0b") ) then\r
-      saved_src_ip(15 downto 8) <= MAC_RXD_IN;\r
-    elsif( (filter_current_state = REMOVE_IP) and (remove_ctr = x"0c") ) then\r
-      saved_src_ip(23 downto 16) <= MAC_RXD_IN;\r
-    elsif( (filter_current_state = REMOVE_IP) and (remove_ctr = x"0d") ) then\r
-      saved_src_ip(31 downto 24) <= MAC_RXD_IN;\r
+  end process PROC_SAVED_SRC_MAC;\r
+\r
+  -- saves the frame type of the incoming frame for futher check\r
+  PROC_SAVED_FRAME_TYPE: process( CLK )\r
+  begin\r
+    if( rising_edge(CLK) ) then\r
+      if   ( filter_current_state = CLEANUP ) then\r
+        saved_frame_type <= (others => '0');\r
+      elsif( (filter_current_state = REMOVE_SRC) and (remove_ctr = x"09") ) then\r
+        saved_frame_type(15 downto 8) <= MAC_RXD_IN;\r
+      elsif( (filter_current_state = REMOVE_TYPE) and (remove_ctr = x"0a") ) then\r
+        saved_frame_type(7 downto 0) <= MAC_RXD_IN;\r
+      end if;\r
     end if;\r
-  end if;\r
-end process THE_SAVED_SRC_IP_PROC;\r
-\r
-THE_SAVED_DEST_IP_PROC: process( CLK )\r
-begin\r
-  if( rising_edge(CLK) ) then\r
-    if   ( filter_current_state = CLEANUP ) then\r
-      saved_dest_ip <= (others => '0');\r
-    elsif( (filter_current_state = REMOVE_IP) and (remove_ctr = x"0e") ) then\r
-      saved_dest_ip(7 downto 0) <= MAC_RXD_IN;\r
-    elsif( (filter_current_state = REMOVE_IP) and (remove_ctr = x"0f") ) then\r
-      saved_dest_ip(15 downto 8) <= MAC_RXD_IN;\r
-    elsif( (filter_current_state = REMOVE_IP) and (remove_ctr = x"10") ) then\r
-      saved_dest_ip(23 downto 16) <= MAC_RXD_IN;\r
-    elsif( (filter_current_state = REMOVE_IP) and (remove_ctr = x"11") ) then\r
-      saved_dest_ip(31 downto 24) <= MAC_RXD_IN;\r
+  end process PROC_SAVED_FRAME_TYPE;\r
+\r
+  PROC_SAVED_SRC_IP: process( CLK )\r
+  begin\r
+    if( rising_edge(CLK) ) then\r
+      if   ( filter_current_state = CLEANUP ) then\r
+        saved_src_ip <= (others => '0');\r
+      elsif( (filter_current_state = REMOVE_IP) and (remove_ctr = x"0a") ) then\r
+        saved_src_ip(7 downto 0) <= MAC_RXD_IN;\r
+      elsif( (filter_current_state = REMOVE_IP) and (remove_ctr = x"0b") ) then\r
+        saved_src_ip(15 downto 8) <= MAC_RXD_IN;\r
+      elsif( (filter_current_state = REMOVE_IP) and (remove_ctr = x"0c") ) then\r
+        saved_src_ip(23 downto 16) <= MAC_RXD_IN;\r
+      elsif( (filter_current_state = REMOVE_IP) and (remove_ctr = x"0d") ) then\r
+        saved_src_ip(31 downto 24) <= MAC_RXD_IN;\r
+      end if;\r
     end if;\r
-  end if;\r
-end process THE_SAVED_DEST_IP_PROC;\r
-\r
-THE_SAVED_SRC_UDP_PROC: process( CLK )\r
-begin\r
-  if( rising_edge(CLK) ) then\r
-    if   ( filter_current_state = CLEANUP ) then\r
-      saved_src_udp <= (others => '0');\r
-    elsif( (filter_current_state = REMOVE_UDP) and (remove_ctr = x"12") ) then\r
-      saved_src_udp(15 downto 8) <= MAC_RXD_IN;\r
-    elsif( (filter_current_state = REMOVE_UDP) and (remove_ctr = x"13") ) then\r
-      saved_src_udp(7 downto 0) <= MAC_RXD_IN;\r
+  end process PROC_SAVED_SRC_IP;\r
+\r
+  PROC_SAVED_DEST_IP: process( CLK )\r
+  begin\r
+    if( rising_edge(CLK) ) then\r
+      if   ( filter_current_state = CLEANUP ) then\r
+        saved_dest_ip <= (others => '0');\r
+      elsif( (filter_current_state = REMOVE_IP) and (remove_ctr = x"0e") ) then\r
+        saved_dest_ip(7 downto 0) <= MAC_RXD_IN;\r
+      elsif( (filter_current_state = REMOVE_IP) and (remove_ctr = x"0f") ) then\r
+        saved_dest_ip(15 downto 8) <= MAC_RXD_IN;\r
+      elsif( (filter_current_state = REMOVE_IP) and (remove_ctr = x"10") ) then\r
+        saved_dest_ip(23 downto 16) <= MAC_RXD_IN;\r
+      elsif( (filter_current_state = REMOVE_IP) and (remove_ctr = x"11") ) then\r
+        saved_dest_ip(31 downto 24) <= MAC_RXD_IN;\r
+      end if;\r
     end if;\r
-  end if;\r
-end process THE_SAVED_SRC_UDP_PROC;\r
-\r
-THE_SAVED_DEST_UDP_PROC: process( CLK )\r
-begin\r
-  if( rising_edge(CLK) ) then\r
-    if   ( filter_current_state = CLEANUP ) then\r
-      saved_dest_udp <= (others => '0');\r
-    elsif( (filter_current_state = REMOVE_UDP) and (remove_ctr = x"14") ) then\r
-      saved_dest_udp(15 downto 8) <= MAC_RXD_IN;\r
-    elsif( (filter_current_state = REMOVE_UDP) and (remove_ctr = x"15") ) then\r
-      saved_dest_udp(7 downto 0) <= MAC_RXD_IN;\r
+  end process PROC_SAVED_DEST_IP;\r
+\r
+  PROC_SAVED_SRC_UDP: process( CLK )\r
+  begin\r
+    if( rising_edge(CLK) ) then\r
+      if   ( filter_current_state = CLEANUP ) then\r
+        saved_src_udp <= (others => '0');\r
+      elsif( (filter_current_state = REMOVE_UDP) and (remove_ctr = x"12") ) then\r
+        saved_src_udp(15 downto 8) <= MAC_RXD_IN;\r
+      elsif( (filter_current_state = REMOVE_UDP) and (remove_ctr = x"13") ) then\r
+        saved_src_udp(7 downto 0) <= MAC_RXD_IN;\r
+      end if;\r
     end if;\r
-  end if;\r
-end process THE_SAVED_DEST_UDP_PROC;\r
+  end process PROC_SAVED_SRC_UDP;\r
+\r
+  PROC_SAVED_DEST_UDP: process( CLK )\r
+  begin\r
+    if( rising_edge(CLK) ) then\r
+      if   ( filter_current_state = CLEANUP ) then\r
+        saved_dest_udp <= (others => '0');\r
+      elsif( (filter_current_state = REMOVE_UDP) and (remove_ctr = x"14") ) then\r
+        saved_dest_udp(15 downto 8) <= MAC_RXD_IN;\r
+      elsif( (filter_current_state = REMOVE_UDP) and (remove_ctr = x"15") ) then\r
+        saved_dest_udp(7 downto 0) <= MAC_RXD_IN;\r
+      end if;\r
+    end if;\r
+  end process PROC_SAVED_DEST_UDP;\r
 \r
--- saves VLAN id when tagged frame spotted\r
-THE_SAVED_VID_PROC: process( CLK )\r
-begin\r
-  if( rising_edge(CLK) ) then\r
-    if   ( filter_current_state = CLEANUP ) then\r
-      saved_vid <= (others => '0');\r
-    elsif( (filter_current_state = REMOVE_TYPE) and (remove_ctr = x"0b") and (saved_frame_type = x"8100") ) then\r
-      saved_vid(15 downto 8) <= MAC_RXD_IN;\r
-    elsif( (filter_current_state = REMOVE_VID) and (remove_ctr = x"0c") ) then\r
-      saved_vid(7 downto 0) <= MAC_RXD_IN;\r
+  PROC_FRAME_TYPE_VALID: process( CLK, RESET ) \r
+  begin\r
+    if   ( RESET = '1' ) then\r
+      frame_type_valid <= '0';\r
+    elsif( rising_edge(CLK) ) then\r
+      if   ( filter_current_state = SAVE_FRAME ) then\r
+        frame_type_valid <= '1';\r
+      elsif( filter_current_state = CLEANUP ) then\r
+        frame_type_valid <= '0';\r
+      end if;\r
     end if;\r
-  end if;\r
-end process THE_SAVED_VID_PROC;\r
-\r
-THE_TYPE_VALIDATOR: entity gbe_type_validator\r
-port map(\r
-  CLK                      => CLK,\r
-  RESET                    => RESET,\r
-  FRAME_TYPE_IN            => saved_frame_type,\r
-  ALLOWED_TYPES_IN         => FR_ALLOWED_TYPES_IN,\r
-  SAVED_VLAN_ID_IN         => saved_vid,\r
-  VLAN_ID_IN               => FR_VLAN_ID_IN,\r
-  -- IP level\r
-  IP_PROTOCOLS_IN          => saved_proto,\r
-  ALLOWED_IP_PROTOCOLS_IN  => FR_ALLOWED_IP_IN,\r
-  -- UDP level\r
-  UDP_PROTOCOL_IN          => saved_dest_udp,\r
-  ALLOWED_UDP_PROTOCOLS_IN => FR_ALLOWED_UDP_IN,\r
-  --\r
-  VALID_OUT                => frame_type_valid\r
-);\r
-\r
-THE_RECEIVE_FIFO: entity fifo_4096x9\r
-port map(\r
-  Data      => rx_data,\r
-  WrClock   => CLK,\r
-  RdClock   => CLK,\r
-  WrEn      => fifo_wr_en,\r
-  RdEn      => FR_RD_EN_IN,\r
-  Reset     => RESET,\r
-  RPReset   => RESET,\r
-  Q         => fr_q,\r
-  Empty     => rec_fifo_empty,\r
-  Full      => rec_fifo_full\r
-);\r
-\r
--- killer ping\r
-THE_KILLER_PING_PROC: 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
-        (saved_frame_type = x"0800") 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
-    else\r
-      ISSUE_REBOOT_OUT <= '0';\r
+  end process PROC_FRAME_TYPE_VALID;\r
+\r
+  THE_RECEIVE_FIFO: entity work.fifo_4096x9\r
+  port map(\r
+    Data      => rx_data,\r
+    WrClock   => CLK,\r
+    RdClock   => CLK,\r
+    WrEn      => fifo_wr_en,\r
+    RdEn      => FR_RD_EN_IN,\r
+    Reset     => RESET,\r
+    RPReset   => RESET,\r
+    Q         => fr_q,\r
+    Empty     => rec_fifo_empty,\r
+    Full      => rec_fifo_full\r
+  );\r
+\r
+  -- killer ping\r
+  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
+          (saved_frame_type = x"0800") 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
+      else\r
+        ISSUE_REBOOT_OUT <= '0';\r
+      end if;\r
     end if;\r
-  end if;\r
-end process THE_KILLER_PING_PROC;\r
-\r
-THE_SECRET_FRAME_PROC: process( CLK )\r
-begin\r
-  if( rising_edge(CLK) ) then\r
-    if( (filter_current_state = DECIDE) and \r
-        (saved_proto = x"11") and \r
-        (saved_frame_type = x"0800") and\r
-        (saved_dest_udp = x"d903") and \r
-        (saved_src_udp = x"2b67") ) then\r
-      oob_write <= '1';\r
-    else\r
-      oob_write <= '0';\r
+  end process PROC_KILLER_PING;\r
+\r
+  PROC_SECRET_FRAME: process( CLK )\r
+  begin\r
+    if( rising_edge(CLK) ) then\r
+      if( (filter_current_state = DELAY) and \r
+          (saved_proto = x"11") and \r
+          (saved_frame_type = x"0800") and\r
+          (saved_dest_udp = x"d903") and \r
+          (saved_src_udp = x"2b67") ) then\r
+        oob_write <= '1';\r
+      else\r
+        oob_write <= '0';\r
+      end if;\r
     end if;\r
-  end if;\r
-end process THE_SECRET_FRAME_PROC;\r
-\r
-THE_REGISTERS_PROC: process( CLK )\r
-begin\r
-  if( rising_edge(CLK) ) then\r
-    if( oob_write = '1' ) then\r
-      case saved_src_ip(1 downto 0) is\r
-        when b"00"  => oob_register_0_int <= saved_dest_ip;\r
-        when b"01"  => oob_register_1_int <= saved_dest_ip;\r
-        when b"10"  => oob_register_2_int <= saved_dest_ip;\r
-        when others => oob_register_3_int <= saved_dest_ip;\r
-      end case;\r
+  end process PROC_SECRET_FRAME;\r
+\r
+  PROC_SECRET_REGISTERS: process( CLK )\r
+  begin\r
+    if( rising_edge(CLK) ) then\r
+      if( oob_write = '1' ) then\r
+        case saved_src_ip(1 downto 0) is\r
+          when b"00"  => oob_register_0_int <= saved_dest_ip;\r
+          when b"01"  => oob_register_1_int <= saved_dest_ip;\r
+          when b"10"  => oob_register_2_int <= saved_dest_ip;\r
+          when others => oob_register_3_int <= saved_dest_ip;\r
+        end case;\r
+      end if;\r
     end if;\r
-  end if;\r
-end process THE_REGISTERS_PROC;\r
+  end process PROC_SECRET_REGISTERS;\r
 \r
-OOB_REGISTER_0_OUT <= oob_register_0_int;\r
-OOB_REGISTER_1_OUT <= oob_register_1_int;\r
-OOB_REGISTER_2_OUT <= oob_register_2_int;\r
-OOB_REGISTER_3_OUT <= oob_register_3_int;\r
+  OOB_REGISTER_0_OUT <= oob_register_0_int;\r
+  OOB_REGISTER_1_OUT <= oob_register_1_int;\r
+  OOB_REGISTER_2_OUT <= oob_register_2_int;\r
+  OOB_REGISTER_3_OUT <= oob_register_3_int;\r
 \r
-THE_RX_FIFO_SYNC: process( CLK )\r
-begin\r
-  if rising_edge(CLK) then\r
+  PROC_RX_FIFO_SYNC: process( CLK )\r
+  begin\r
+    if rising_edge(CLK) then\r
 \r
-    rx_data(8)          <= MAC_RX_EOF_IN;\r
-    rx_data(7 downto 0) <= MAC_RXD_IN;\r
+      rx_data(8)          <= MAC_RX_EOF_IN;\r
+      rx_data(7 downto 0) <= MAC_RXD_IN;\r
 \r
-    if( MAC_RX_EN_IN = '1' ) then\r
-      if   ( filter_current_state = SAVE_FRAME ) then\r
-        fifo_wr_en <= '1';\r
---      elsif( (filter_current_state = REMOVE_VTYPE) and (remove_ctr = x"0f") ) then\r
---        fifo_wr_en <= '1';\r
-      elsif( (filter_current_state = DECIDE) and (frame_type_valid = '1') ) then\r
-        fifo_wr_en <= '1';\r
+      if( MAC_RX_EN_IN = '1' ) then\r
+        if   ( filter_current_state = SAVE_FRAME ) then\r
+          fifo_wr_en <= '1';\r
+        elsif( (filter_current_state = DELAY) ) then\r
+          fifo_wr_en <= '1';\r
+        else\r
+          fifo_wr_en <= '0';\r
+        end if;\r
       else\r
         fifo_wr_en <= '0';\r
       end if;\r
-    else\r
-      fifo_wr_en <= '0';\r
-    end if;\r
-\r
-  end if;\r
-end process THE_RX_FIFO_SYNC;\r
-\r
-THE_SIZES_FIFO: entity fifo_512x32\r
-port map(\r
-  Data(15 downto 0)   => rx_bytes_ctr,\r
-  Data(31 downto 16)  => saved_frame_type,\r
-  WrClock             => CLK,\r
-  RdClock             => CLK,\r
-  WrEn                => frame_valid_q,\r
-  RdEn                => FR_GET_FRAME_IN,\r
-  Reset               => RESET,\r
-  RPReset             => RESET,\r
-  Q(15 downto 0)      => fr_frame_size,\r
-  Q(31 downto 16)     => fr_frame_proto,\r
-  Empty               => sizes_fifo_empty,\r
-  Full                => sizes_fifo_full\r
-);\r
-\r
-THE_MACS_FIFO: entity fifo_512x72\r
-port map(\r
-  Data(47 downto 0)   => saved_src_mac,\r
-  Data(63 downto 48)  => saved_src_udp,\r
-  Data(71 downto 64)  => (others => '0'),\r
-  WrClock             => CLK,\r
-  RdClock             => CLK,\r
-  WrEn                => frame_valid_q,\r
-  RdEn                => FR_GET_FRAME_IN,\r
-  Reset               => RESET,\r
-  RPReset             => RESET,\r
-  Q(47 downto 0)      => fr_src_mac,\r
-  Q(63 downto 48)     => fr_src_udp,\r
-  Q(71 downto 64)     => xxx0, --open,\r
-  Empty               => open,\r
-  Full                => open\r
-);\r
-\r
-THE_MACD_FIFO: entity fifo_512x72\r
-port map(\r
-  Data(47 downto 0)   => saved_dest_mac,\r
-  Data(63 downto 48)  => saved_dest_udp,\r
-  Data(71 downto 64)  => (others => '0'),\r
-  WrClock             => CLK,\r
-  RdClock             => CLK,\r
-  WrEn                => frame_valid_q,\r
-  RdEn                => FR_GET_FRAME_IN,\r
-  Reset               => RESET,\r
-  RPReset             => RESET,\r
-  Q(47 downto 0)      => fr_dest_mac,\r
-  Q(63 downto 48)     => fr_dest_udp,\r
-  Q(71 downto 64)     => xxx1, --open,\r
-  Empty               => open,\r
-  Full                => open\r
-);\r
-\r
-THE_IP_FIFO: entity fifo_512x72\r
-port map(\r
-  Data(31 downto 0)   => saved_src_ip,\r
-  Data(63 downto 32)  => saved_dest_ip,\r
-  Data(71 downto 64)  => saved_proto,\r
-  WrClock             => CLK,\r
-  RdClock             => CLK,\r
-  WrEn                => frame_valid_q,\r
-  RdEn                => FR_GET_FRAME_IN,\r
-  Reset               => RESET,\r
-  RPReset             => RESET,\r
-  Q(31 downto 0)      => fr_src_ip,\r
-  Q(63 downto 32)     => fr_dest_ip,\r
-  Q(71 downto 64)     => fr_ip_proto,\r
-  Empty               => open,\r
-  Full                => open\r
-);\r
-\r
-THE_SYNC_PROC: process( CLK )\r
-begin\r
-  if( rising_edge(CLK) ) then\r
-    FR_SRC_IP_ADDRESS_OUT   <= fr_src_ip;\r
-    FR_DEST_IP_ADDRESS_OUT  <= fr_dest_ip;\r
-    FR_IP_PROTOCOL_OUT      <= fr_ip_proto;\r
-    FR_DEST_UDP_PORT_OUT    <= fr_dest_udp;\r
-    FR_DEST_MAC_ADDRESS_OUT <= fr_dest_mac;\r
-    FR_SRC_MAC_ADDRESS_OUT  <= fr_src_mac;\r
-    FR_SRC_UDP_PORT_OUT     <= fr_src_udp;\r
-    FR_FRAME_PROTO_OUT      <= fr_frame_proto;\r
-    FR_FRAME_SIZE_OUT       <= fr_frame_size;\r
-    FR_Q_OUT                <= fr_q;\r
-    --\r
-    delayed_frame_valid     <= MAC_RX_EOF_IN;\r
-    delayed_frame_valid_q   <= delayed_frame_valid;\r
-  end if;\r
-end process THE_SYNC_PROC;\r
 \r
-THE_FRAME_VALID_PROC: process( CLK )\r
-begin\r
-  if( rising_edge(CLK) ) then\r
-    if( (MAC_RX_EOF_IN = '1') and (ALLOW_RX_IN = '1') and (frame_type_valid = '1') ) then\r
-      frame_valid_q <= '1';\r
-    else\r
-      frame_valid_q <= '0';\r
     end if;\r
-  end if;\r
-end process THE_FRAME_VALID_PROC;\r
+  end process PROC_RX_FIFO_SYNC;\r
+\r
+  THE_SIZES_FIFO: entity work.fifo_512x32\r
+  port map(\r
+    Data(15 downto 0)   => rx_bytes_ctr,\r
+    Data(31 downto 16)  => saved_frame_type,\r
+    WrClock             => CLK,\r
+    RdClock             => CLK,\r
+    WrEn                => frame_valid_q,\r
+    RdEn                => FR_GET_FRAME_IN,\r
+    Reset               => RESET,\r
+    RPReset             => RESET,\r
+    Q(15 downto 0)      => fr_frame_size,\r
+    Q(31 downto 16)     => fr_frame_proto,\r
+    Empty               => sizes_fifo_empty,\r
+    Full                => sizes_fifo_full\r
+  );\r
+\r
+  THE_MACS_FIFO: entity work.fifo_512x72\r
+  port map(\r
+    Data(47 downto 0)   => saved_src_mac,\r
+    Data(63 downto 48)  => saved_src_udp,\r
+    Data(71 downto 64)  => (others => '0'),\r
+    WrClock             => CLK,\r
+    RdClock             => CLK,\r
+    WrEn                => frame_valid_q,\r
+    RdEn                => FR_GET_FRAME_IN,\r
+    Reset               => RESET,\r
+    RPReset             => RESET,\r
+    Q(47 downto 0)      => fr_src_mac,\r
+    Q(63 downto 48)     => fr_src_udp,\r
+    Q(71 downto 64)     => xxx0, --open,\r
+    Empty               => open,\r
+    Full                => open\r
+  );\r
+\r
+  THE_MACD_FIFO: entity work.fifo_512x72\r
+  port map(\r
+    Data(47 downto 0)   => saved_dest_mac,\r
+    Data(63 downto 48)  => saved_dest_udp,\r
+--    Data(71 downto 64)  => (others => '0'),\r
+    Data(69 downto 64)  => proto_select,\r
+    Data(71 downto 70)  => (others => '0'),\r
+    WrClock             => CLK,\r
+    RdClock             => CLK,\r
+    WrEn                => frame_valid_q,\r
+    RdEn                => FR_GET_FRAME_IN,\r
+    Reset               => RESET,\r
+    RPReset             => RESET,\r
+    Q(47 downto 0)      => fr_dest_mac,\r
+    Q(63 downto 48)     => fr_dest_udp,\r
+--    Q(71 downto 64)     => xxx1, --open,\r
+    Q(69 downto 64)     => fr_ps, --open,\r
+    Q(71 downto 70)     => xxx1(1 downto 0), --open,\r
+    Empty               => open,\r
+    Full                => open\r
+  );\r
+\r
+  THE_IP_FIFO: entity work.fifo_512x72\r
+  port map(\r
+    Data(31 downto 0)   => saved_src_ip,\r
+    Data(63 downto 32)  => saved_dest_ip,\r
+    Data(71 downto 64)  => saved_proto,\r
+    WrClock             => CLK,\r
+    RdClock             => CLK,\r
+    WrEn                => frame_valid_q,\r
+    RdEn                => FR_GET_FRAME_IN,\r
+    Reset               => RESET,\r
+    RPReset             => RESET,\r
+    Q(31 downto 0)      => fr_src_ip,\r
+    Q(63 downto 32)     => fr_dest_ip,\r
+    Q(71 downto 64)     => fr_ip_proto,\r
+    Empty               => open,\r
+    Full                => open\r
+  );\r
+\r
+  PROC_SYNC: process( CLK )\r
+  begin\r
+    if( rising_edge(CLK) ) then\r
+      FR_SRC_IP_ADDRESS_OUT   <= fr_src_ip;\r
+      FR_DEST_IP_ADDRESS_OUT  <= fr_dest_ip;\r
+      FR_IP_PROTOCOL_OUT      <= fr_ip_proto;\r
+      FR_DEST_UDP_PORT_OUT    <= fr_dest_udp;\r
+      FR_DEST_MAC_ADDRESS_OUT <= fr_dest_mac;\r
+      FR_SRC_MAC_ADDRESS_OUT  <= fr_src_mac;\r
+      FR_SRC_UDP_PORT_OUT     <= fr_src_udp;\r
+      FR_FRAME_PROTO_OUT      <= fr_frame_proto;\r
+      FR_FRAME_SIZE_OUT       <= fr_frame_size;\r
+      FR_Q_OUT                <= fr_q;\r
+      FR_PS_OUT               <= fr_ps;\r
+      --\r
+      delayed_frame_valid     <= MAC_RX_EOF_IN;\r
+      delayed_frame_valid_q   <= delayed_frame_valid;\r
+--      proto_select            <= proto_select_x;\r
+    end if;\r
+  end process PROC_SYNC;\r
+\r
+  -- Signal used to store auxiliary FIFO data at the end of frame\r
+  PROC_FRAME_VALID: process( CLK )\r
+  begin\r
+    if( rising_edge(CLK) ) then\r
+      if( (MAC_RX_EOF_IN = '1') and (ALLOW_RX_IN = '1') and (frame_type_valid = '1') ) then\r
+        frame_valid_q <= '1';\r
+      else\r
+        frame_valid_q <= '0';\r
+      end if;\r
+    end if;\r
+  end process PROC_FRAME_VALID;\r
 \r
-THE_RX_BYTES_CTR_PROC: process( CLK, RESET )\r
-begin\r
-  if   ( RESET = '1' ) then\r
-    rx_bytes_ctr <= x"0001";\r
-  elsif( rising_edge(CLK) ) then\r
-    if( delayed_frame_valid_q = '1' ) then\r
+  PROC_RX_BYTES_CTR: process( CLK, RESET )\r
+  begin\r
+    if   ( RESET = '1' ) then\r
       rx_bytes_ctr <= x"0001";\r
-    elsif( fifo_wr_en = '1' ) then\r
-      rx_bytes_ctr <= rx_bytes_ctr + 1;\r
+    elsif( rising_edge(CLK) ) then\r
+      if( delayed_frame_valid_q = '1' ) then\r
+        rx_bytes_ctr <= x"0001";\r
+      elsif( fifo_wr_en = '1' ) then\r
+        rx_bytes_ctr <= rx_bytes_ctr + 1;\r
+      end if;\r
     end if;\r
-  end if;\r
-end process THE_RX_BYTES_CTR_PROC;\r
-\r
-THE_ERROR_FRAMES_CTR_PROC: process( CLK, RESET )\r
-begin\r
-  if   ( RESET = '1' ) then\r
-    error_frames_ctr <= (others => '0');\r
-  elsif( rising_edge(CLK) ) then\r
-    error_frames_ctr <= error_frames_ctr + 1;\r
-  end if;\r
-end process THE_ERROR_FRAMES_CTR_PROC;\r
-\r
-FR_FRAME_VALID_OUT <= frame_valid_q when rising_edge(CLK);\r
-\r
-THE_RECEIVED_FRAMES_CTR: process( CLK, RESET )\r
-begin\r
-  if   ( RESET = '1' ) then\r
-    dbg_rec_frames <= (others => '0');\r
-  elsif( rising_edge(CLK) ) then\r
-    dbg_rec_frames <= dbg_rec_frames + 1;\r
-  end if;\r
-end process THE_RECEIVED_FRAMES_CTR;\r
-\r
-THE_DROPPED_FRAMES_CTR: process( CLK, RESET )\r
-begin\r
-  if   ( RESET = '1' ) then\r
-    dbg_drp_frames <= (others => '0');\r
-  elsif( rising_edge(CLK) ) then\r
-    if( (filter_current_state = DECIDE) and (frame_type_valid = '0') ) then\r
-      dbg_drp_frames <= dbg_drp_frames + 1;\r
+  end process PROC_RX_BYTES_CTR;\r
+\r
+  -- Bullshit counter. Count condition is missing.\r
+  PROC_ERROR_FRAMES_CTR: process( CLK, RESET )\r
+  begin\r
+    if   ( RESET = '1' ) then\r
+      error_frames_ctr <= (others => '0');\r
+    elsif( rising_edge(CLK) ) then\r
+      error_frames_ctr <= error_frames_ctr + 1;\r
     end if;\r
-  end if;\r
-end process THE_DROPPED_FRAMES_CTR;\r
+  end process PROC_ERROR_FRAMES_CTR;\r
 \r
-MONITOR_DROPPED_OUT   <= std_logic_vector(dbg_drp_frames);\r
-MONITOR_RX_FRAMES_OUT <= std_logic_vector(dbg_rec_frames);\r
-MONITOR_RX_BYTES_OUT  <= std_logic_vector(mon_rec_bytes);\r
+  FR_FRAME_VALID_OUT <= frame_valid_q when rising_edge(CLK);\r
 \r
-THE_MON_REC_BYTES_PROC: process( CLK, RESET )\r
-begin\r
-  if   ( RESET = '1' ) then\r
-    mon_rec_bytes <= (others => '0');\r
-  elsif( rising_edge(CLK) ) then\r
-    if( fifo_wr_en = '1' ) then\r
-      mon_rec_bytes <= mon_rec_bytes + x"1";\r
+  -- Bullshit counter. Count condition is missing.\r
+  PROC_RECEIVED_FRAMES_CTR: process( CLK, RESET )\r
+  begin\r
+    if   ( RESET = '1' ) then\r
+      dbg_rec_frames <= (others => '0');\r
+    elsif( rising_edge(CLK) ) then\r
+      dbg_rec_frames <= dbg_rec_frames + 1;\r
     end if;\r
-  end if;\r
-end process;\r
+  end process PROC_RECEIVED_FRAMES_CTR;\r
+\r
+  -- Counts dropped frames.\r
+  PROC_DROPPED_FRAMES_CTR: process( CLK, RESET )\r
+  begin\r
+    if   ( RESET = '1' ) then\r
+      dbg_drp_frames <= (others => '0');\r
+    elsif( rising_edge(CLK) ) then\r
+      if( (filter_current_state = DELAY) and (frame_type_valid = '0') ) then\r
+        dbg_drp_frames <= dbg_drp_frames + 1;\r
+      end if;\r
+    end if;\r
+  end process PROC_DROPPED_FRAMES_CTR;\r
+\r
+  MONITOR_DROPPED_OUT   <= std_logic_vector(dbg_drp_frames);\r
+  MONITOR_RX_FRAMES_OUT <= std_logic_vector(dbg_rec_frames);\r
+  MONITOR_RX_BYTES_OUT  <= std_logic_vector(mon_rec_bytes);\r
+\r
+  -- Counts received bytes as payload.\r
+  PROC_MON_REC_BYTES: process( CLK, RESET )\r
+  begin\r
+    if   ( RESET = '1' ) then\r
+      mon_rec_bytes <= (others => '0');\r
+    elsif( rising_edge(CLK) ) then\r
+      if( fifo_wr_en = '1' ) then\r
+        mon_rec_bytes <= mon_rec_bytes + x"1";\r
+      end if;\r
+    end if;\r
+  end process PROC_MON_REC_BYTES;\r
 \r
 end gbe_frame_receiver_arch;\r
index 852f3f0c86177477cf060e43eeb3d14636ef7e32..b16e447324a84dbcde25201c831208451d78480a 100644 (file)
@@ -104,7 +104,6 @@ architecture gbe_logic_wrapper_arch of gbe_logic_wrapper is
   signal rc_frame_size          : std_logic_vector(15 downto 0);
   signal mc_frame_size          : std_logic_vector(15 downto 0);
   signal rc_bytes_rec           : std_logic_vector(31 downto 0);
-  signal rc_debug               : std_logic_vector(63 downto 0);
   signal mc_transmit_ctrl       : std_logic;
   signal rc_loading_done        : std_logic;
   signal fr_get_frame           : std_logic;
@@ -169,6 +168,8 @@ architecture gbe_logic_wrapper_arch of gbe_logic_wrapper is
   signal make_reset             : std_logic;
   signal frame_pause            : std_logic_vector(31 downto 0);
 
+  signal fr_ps_int              : std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0);
+
 begin
 
   fc_ihl_version <= x"45";
@@ -254,8 +255,8 @@ begin
       FWD_READY_OUT                 => FWD_READY_OUT,
       FWD_FULL_OUT                  => FWD_FULL_OUT,
       --
-      DEBUG_OUT(31 downto 0)        => DEBUG_OUT
-      DEBUG_OUT(63 downto 32)       => open, 
+      DEBUG_OUT(15 downto 0)        => DEBUG_OUT(31 downto 16)
+      DEBUG_OUT(63 downto 16)       => open, 
       --
       MONITOR_SELECT_GEN_DBG_OUT    => dbg_select_gen
     );
@@ -353,6 +354,7 @@ begin
       FR_FRAME_SIZE_IN        => fr_frame_size,
       FR_FRAME_PROTO_IN       => fr_frame_proto,
       FR_IP_PROTOCOL_IN       => fr_ip_proto,
+      FR_PS_IN                => fr_ps_int,
       FR_SRC_MAC_ADDRESS_IN   => fr_src_mac,
       FR_DEST_MAC_ADDRESS_IN  => fr_dest_mac,
       FR_SRC_IP_ADDRESS_IN    => fr_src_ip,
@@ -375,9 +377,9 @@ begin
       -- statistics
       FRAMES_RECEIVED_OUT     => rc_frames_rec_ctr,
       BYTES_RECEIVED_OUT      => rc_bytes_rec,
-      DEBUG_OUT               => rc_debug
+      DEBUG_OUT               => open
     );
-
+    
   THE_FRAME_RECEIVER: entity work.gbe_frame_receiver
     port map(
       CLK                     => CLK_125_IN,
@@ -401,10 +403,11 @@ begin
       FR_FRAME_SIZE_OUT       => fr_frame_size,
       FR_FRAME_PROTO_OUT      => fr_frame_proto,
       FR_IP_PROTOCOL_OUT      => fr_ip_proto,
-      FR_ALLOWED_TYPES_IN     => (others => '1'), --fr_allowed_types,
-      FR_ALLOWED_IP_IN        => (others => '1'), --fr_allowed_ip,
-      FR_ALLOWED_UDP_IN       => (others => '1'), --fr_allowed_udp,
-      FR_VLAN_ID_IN           => (others => '0'), --vlan_id,
+      FR_PS_OUT               => fr_ps_int,
+--      FR_ALLOWED_TYPES_IN     => (others => '1'), --fr_allowed_types,
+--      FR_ALLOWED_IP_IN        => (others => '1'), --fr_allowed_ip,
+--      FR_ALLOWED_UDP_IN       => (others => '1'), --fr_allowed_udp,
+--      FR_VLAN_ID_IN           => (others => '0'), --vlan_id,
       --
       FR_SRC_MAC_ADDRESS_OUT  => fr_src_mac,
       FR_DEST_MAC_ADDRESS_OUT => fr_dest_mac,
@@ -420,7 +423,10 @@ begin
       --
       MONITOR_RX_BYTES_OUT    => monitor_rx_bytes,
       MONITOR_RX_FRAMES_OUT   => monitor_rx_frames,
-      MONITOR_DROPPED_OUT     => monitor_dropped
+      MONITOR_DROPPED_OUT     => monitor_dropped,
+      --
+      DEBUG_OUT(15 downto 0)  => DEBUG_OUT(15 downto 0), --open
+      DEBUG_OUT(31 downto 16) => open
     );
 
   MONITOR_RX_FRAMES_OUT  <= monitor_rx_frames;
index 7658760c8c64f8dc155bf2d103373f306ab84de9..c364922582a795457e5b890b4b01b118d087ef1d 100644 (file)
@@ -150,6 +150,15 @@ architecture gbe_main_control_arch of gbe_main_control is
   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)            <= '0';
+  DEBUG_OUT(6)            <= disable_redirect;
+  DEBUG_OUT(5 downto 0)   <= RC_FRAME_PROTO_IN;
+  
   THE_PROTOCOL_SELECTOR: entity work.gbe_protocol_selector
     generic map(
       INCLUDE_SLOWCTRL     => INCLUDE_SLOWCTRL,
@@ -231,8 +240,9 @@ begin
 
   -- gk 07.11.11
   -- do not select any response constructors when dropping a frame
-  proto_select <= RC_FRAME_PROTO_IN when disable_redirect = '0' else (others => '0');
-
+--  proto_select <= RC_FRAME_PROTO_IN when disable_redirect = '0' else (others => '0');
+  proto_select <= RC_FRAME_PROTO_IN;
+  
   -- gk 07.11.11
   -- we do not answer at all, unless we are in either ACTIVE or GET_ADDRESS state.
   -- in GET_ADDRESS state, we only answer on DHCP frames.
@@ -312,6 +322,7 @@ begin
 
       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
@@ -371,8 +382,8 @@ 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
-        loaded_bytes_ctr <= loaded_bytes_ctr + x"1";
+      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;
@@ -586,6 +597,6 @@ begin
   -- END OF LINK STATE CONTROL
   --*************
 
-  DEBUG_OUT <= selector_debug;
+  --DEBUG_OUT <= selector_debug;
 
 end gbe_main_control_arch;
index 612d1225d1e1c8c1b30065697488aa6f64b58e6c..956f7250947597a9734246c2bd69b7e9bb01ace3 100644 (file)
@@ -5,7 +5,7 @@ USE IEEE.std_logic_UNSIGNED.ALL;
 
 library work;
 use work.trb_net_std.all;
-use work.trb_net_components.all;
+--use work.trb_net_components.all;
 use work.gbe_protocols.all;
 
 --********
@@ -53,7 +53,7 @@ begin
               CODE_OUT <= (others => '0');
             end if;
           -- No. 3 = ICMP 
-          elsif( PROTOCOL_CODE_IN = x"01") then -- ICMP
+          elsif( PROTOCOL_CODE_IN = x"01" ) then -- ICMP
             CODE_OUT(4) <= '1';
           else
             CODE_OUT <= (others => '0');
index 4620fbfbf1d39f334334369044dbe6ce74a33d23..2e3d504a1be407fddb2e2a29603d5d0106e853d3 100644 (file)
@@ -5,200 +5,200 @@ 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_receive_control is
-port (
-  CLK                      : in  std_logic;  -- system clock
-  RESET                    : in  std_logic;
--- signals to/from frame_receiver
-  RC_DATA_IN               : in  std_logic_vector(8 downto 0);
-  FR_RD_EN_OUT             : out std_logic;
-  FR_FRAME_VALID_IN        : in  std_logic;
-  FR_GET_FRAME_OUT         : out std_logic;
-  FR_FRAME_SIZE_IN         : in  std_logic_vector(15 downto 0);
-  FR_FRAME_PROTO_IN        : in  std_logic_vector(15 downto 0);
-  FR_IP_PROTOCOL_IN        : in  std_logic_vector(7 downto 0);
-  
-  FR_SRC_MAC_ADDRESS_IN    : in  std_logic_vector(47 downto 0);
-  FR_DEST_MAC_ADDRESS_IN   : in  std_logic_vector(47 downto 0);
-  FR_SRC_IP_ADDRESS_IN     : in  std_logic_vector(31 downto 0);
-  FR_DEST_IP_ADDRESS_IN    : in  std_logic_vector(31 downto 0);
-  FR_SRC_UDP_PORT_IN       : in  std_logic_vector(15 downto 0);
-  FR_DEST_UDP_PORT_IN      : in  std_logic_vector(15 downto 0);
-  -- signals to/from main controller
-  RC_RD_EN_IN              : in  std_logic;
-  RC_Q_OUT                 : out std_logic_vector(8 downto 0);
-  RC_FRAME_WAITING_OUT     : out std_logic;
-  RC_LOADING_DONE_IN       : in  std_logic;
-  RC_FRAME_SIZE_OUT        : out std_logic_vector(15 downto 0);
-  RC_FRAME_PROTO_OUT       : out std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0);
-  RC_SRC_MAC_ADDRESS_OUT   : out std_logic_vector(47 downto 0);
-  RC_DEST_MAC_ADDRESS_OUT  : out std_logic_vector(47 downto 0);
-  RC_SRC_IP_ADDRESS_OUT    : out std_logic_vector(31 downto 0);
-  RC_DEST_IP_ADDRESS_OUT   : out std_logic_vector(31 downto 0);
-  RC_SRC_UDP_PORT_OUT      : out std_logic_vector(15 downto 0);
-  RC_DEST_UDP_PORT_OUT     : out std_logic_vector(15 downto 0);
-  -- statistics
-  FRAMES_RECEIVED_OUT      : out std_logic_vector(31 downto 0);
-  BYTES_RECEIVED_OUT       : out std_logic_vector(31 downto 0);
-  --
-  DEBUG_OUT                : out std_logic_vector(63 downto 0)
-);
+  port (
+    CLK                      : in  std_logic;  -- system clock
+    RESET                    : in  std_logic;
+  -- signals to/from frame_receiver
+    RC_DATA_IN               : in  std_logic_vector(8 downto 0);
+    FR_RD_EN_OUT             : out std_logic;
+    FR_FRAME_VALID_IN        : in  std_logic;
+    FR_GET_FRAME_OUT         : out std_logic;
+    FR_FRAME_SIZE_IN         : in  std_logic_vector(15 downto 0);
+    FR_FRAME_PROTO_IN        : in  std_logic_vector(15 downto 0);
+    FR_IP_PROTOCOL_IN        : in  std_logic_vector(7 downto 0);
+    FR_PS_IN                 : in  std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0);
+    FR_SRC_MAC_ADDRESS_IN    : in  std_logic_vector(47 downto 0);
+    FR_DEST_MAC_ADDRESS_IN   : in  std_logic_vector(47 downto 0);
+    FR_SRC_IP_ADDRESS_IN     : in  std_logic_vector(31 downto 0);
+    FR_DEST_IP_ADDRESS_IN    : in  std_logic_vector(31 downto 0);
+    FR_SRC_UDP_PORT_IN       : in  std_logic_vector(15 downto 0);
+    FR_DEST_UDP_PORT_IN      : in  std_logic_vector(15 downto 0);
+    -- signals to/from main controller
+    RC_RD_EN_IN              : in  std_logic;
+    RC_Q_OUT                 : out std_logic_vector(8 downto 0);
+    RC_FRAME_WAITING_OUT     : out std_logic;
+    RC_LOADING_DONE_IN       : in  std_logic;
+    RC_FRAME_SIZE_OUT        : out std_logic_vector(15 downto 0);
+    RC_FRAME_PROTO_OUT       : out std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0);
+    RC_SRC_MAC_ADDRESS_OUT   : out std_logic_vector(47 downto 0);
+    RC_DEST_MAC_ADDRESS_OUT  : out std_logic_vector(47 downto 0);
+    RC_SRC_IP_ADDRESS_OUT    : out std_logic_vector(31 downto 0);
+    RC_DEST_IP_ADDRESS_OUT   : out std_logic_vector(31 downto 0);
+    RC_SRC_UDP_PORT_OUT      : out std_logic_vector(15 downto 0);
+    RC_DEST_UDP_PORT_OUT     : out std_logic_vector(15 downto 0);
+    -- statistics
+    FRAMES_RECEIVED_OUT      : out std_logic_vector(31 downto 0);
+    BYTES_RECEIVED_OUT       : out std_logic_vector(31 downto 0);
+    --
+    DEBUG_OUT                : out std_logic_vector(63 downto 0)
+  );
 end gbe_receive_control;
 
 architecture gbe_receive_control_arch of gbe_receive_control is
 
-attribute syn_encoding : string;
+  attribute syn_encoding : string;
 
-type load_states is (IDLE, PREPARE, WAIT_ONE, READY);
-signal load_current_state, load_next_state : load_states;
-attribute syn_encoding of load_current_state : signal is "onehot";
+  type load_states is (IDLE, PREPARE, WAIT_ONE, READY);
+  signal load_current_state, load_next_state : load_states;
+  attribute syn_encoding of load_current_state : signal is "onehot";
 
-signal frames_received_ctr       : unsigned(31 downto 0);
-signal frames_readout_ctr        : unsigned(31 downto 0);
-signal bytes_rec_ctr             : unsigned(31 downto 0);
+  signal frames_received_ctr       : unsigned(31 downto 0);
+  signal frames_readout_ctr        : unsigned(31 downto 0);
+  signal bytes_rec_ctr             : unsigned(31 downto 0);
 
-signal state                     : std_logic_vector(3 downto 0);
-signal proto_code                : std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0);
-signal reset_prioritizer         : std_logic;
-signal frame_waiting             : std_logic;
+  signal state                     : std_logic_vector(3 downto 0);
+  signal proto_code                : std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0);
+  signal reset_prioritizer         : std_logic;
 
--- debug only
-signal saved_proto               : std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0);
+  -- debug only
+  signal saved_proto               : std_logic_vector(c_MAX_PROTOCOLS - 1 downto 0);
 
 begin
 
-FR_RD_EN_OUT            <= RC_RD_EN_IN;
-RC_Q_OUT                <= RC_DATA_IN;
-RC_FRAME_SIZE_OUT       <= FR_FRAME_SIZE_IN;
-RC_SRC_MAC_ADDRESS_OUT  <= FR_SRC_MAC_ADDRESS_IN;
-RC_DEST_MAC_ADDRESS_OUT <= FR_DEST_MAC_ADDRESS_IN;
-RC_SRC_IP_ADDRESS_OUT   <= FR_SRC_IP_ADDRESS_IN;
-RC_DEST_IP_ADDRESS_OUT  <= FR_DEST_IP_ADDRESS_IN;
-RC_SRC_UDP_PORT_OUT     <= FR_SRC_UDP_PORT_IN;
-RC_DEST_UDP_PORT_OUT    <= FR_DEST_UDP_PORT_IN;
-
-protocol_prioritizer: entity gbe_protocol_prioritizer
-port map(
-  CLK              => CLK,
-  RESET            => reset_prioritizer,
-  --
-  FRAME_TYPE_IN    => FR_FRAME_PROTO_IN,
-  PROTOCOL_CODE_IN => FR_IP_PROTOCOL_IN,
-  UDP_PROTOCOL_IN  => FR_DEST_UDP_PORT_IN,
-  --
-  CODE_OUT         => proto_code
-);
-
-reset_prioritizer <= '1' when load_current_state = IDLE else '0';
-
-RC_FRAME_PROTO_OUT <= proto_code;  -- no more ones as the incorrect value, last slot for Trash
-
-LOAD_MACHINE_PROC: process( CLK, RESET )
-begin
-  if   ( RESET = '1' ) then
-    load_current_state <= IDLE;
-  elsif( rising_edge(CLK) ) then
-    load_current_state <= load_next_state;
-  end if;
-end process LOAD_MACHINE_PROC;
-
-LOAD_MACHINE: process( load_current_state, frames_readout_ctr, frames_received_ctr, RC_LOADING_DONE_IN )
-begin
-  case load_current_state is
+  FR_RD_EN_OUT            <= RC_RD_EN_IN;
+  RC_Q_OUT                <= RC_DATA_IN;
+  RC_FRAME_SIZE_OUT       <= FR_FRAME_SIZE_IN;
+  RC_SRC_MAC_ADDRESS_OUT  <= FR_SRC_MAC_ADDRESS_IN;
+  RC_DEST_MAC_ADDRESS_OUT <= FR_DEST_MAC_ADDRESS_IN;
+  RC_SRC_IP_ADDRESS_OUT   <= FR_SRC_IP_ADDRESS_IN;
+  RC_DEST_IP_ADDRESS_OUT  <= FR_DEST_IP_ADDRESS_IN;
+  RC_SRC_UDP_PORT_OUT     <= FR_SRC_UDP_PORT_IN;
+  RC_DEST_UDP_PORT_OUT    <= FR_DEST_UDP_PORT_IN;
+
+--  protocol_prioritizer: entity work.gbe_protocol_prioritizer
+--  port map(
+--    CLK              => CLK,
+--    RESET            => reset_prioritizer,
+--    --
+--    FRAME_TYPE_IN    => FR_FRAME_PROTO_IN,
+--    PROTOCOL_CODE_IN => FR_IP_PROTOCOL_IN,
+--    UDP_PROTOCOL_IN  => FR_DEST_UDP_PORT_IN,
+--    --
+--    CODE_OUT         => proto_code
+--  );
+--
+--  reset_prioritizer <= '1' when load_current_state = IDLE else '0';
+--
+--  RC_FRAME_PROTO_OUT <= proto_code;  -- no more ones as the incorrect value, last slot for Trash
+\r
+       RC_FRAME_PROTO_OUT <= FR_PS_IN when (load_current_state /= IDLE) else (others => '0');\r
+
+  LOAD_MACHINE_PROC: process( CLK, RESET )
+  begin
+    if   ( RESET = '1' ) then
+      load_current_state <= IDLE;
+    elsif( rising_edge(CLK) ) then
+      load_current_state <= load_next_state;
+    end if;
+  end process LOAD_MACHINE_PROC;
+
+  LOAD_MACHINE: process( load_current_state, frames_readout_ctr, frames_received_ctr, RC_LOADING_DONE_IN )
+  begin
+    case load_current_state is
+
+      when IDLE =>
+        state <= x"1";
+        if( frames_readout_ctr /= frames_received_ctr ) then -- frame is still waiting in frame_receiver
+          load_next_state <= PREPARE;
+        else
+          load_next_state <= IDLE;
+        end if;
+
+      when PREPARE =>  -- prepare frame size
+        state <= x"2";
+        load_next_state <= WAIT_ONE;
+        
+      when WAIT_ONE =>
+        load_next_state <= READY;
 
-    when IDLE =>
-      state <= x"1";
-      if( frames_readout_ctr /= frames_received_ctr ) then -- frame is still waiting in frame_receiver
-        load_next_state <= PREPARE;
+      when READY => -- wait for reading out the whole frame
+        state <= x"3";
+        if( RC_LOADING_DONE_IN = '1' ) then
+          load_next_state <= IDLE;
+        else
+          load_next_state <= READY;
+        end if;
+
+    end case;
+  end process LOAD_MACHINE;
+
+  process( CLK )
+  begin
+    if( rising_edge(CLK) ) then
+      if( load_current_state = PREPARE ) then
+        FR_GET_FRAME_OUT <= '1';
       else
-        load_next_state <= IDLE;
+        FR_GET_FRAME_OUT <= '0';
       end if;
 
-    when PREPARE =>  -- prepare frame size
-      state <= x"2";
-      load_next_state <= WAIT_ONE;
-      
-    when WAIT_ONE =>
-       load_next_state <= READY;
-
-    when READY => -- wait for reading out the whole frame
-      state <= x"3";
-      if( RC_LOADING_DONE_IN = '1' ) then
-        load_next_state <= IDLE;
+      if( (load_current_state = READY) and (RC_LOADING_DONE_IN = '0') ) then
+        RC_FRAME_WAITING_OUT <= '1';
       else
-        load_next_state <= READY;
+        RC_FRAME_WAITING_OUT <= '0';
       end if;
-
-  end case;
-end process LOAD_MACHINE;
-
-process( CLK )
-begin
-  if( rising_edge(CLK) ) then
-    if( load_current_state = PREPARE ) then
-      FR_GET_FRAME_OUT <= '1';
-    else
-      FR_GET_FRAME_OUT <= '0';
     end if;
-
-    if( (load_current_state = READY) and (RC_LOADING_DONE_IN = '0') ) then
-      RC_FRAME_WAITING_OUT <= '1';
-    else
-      RC_FRAME_WAITING_OUT <= '0';
+  end process;
+
+  FRAMES_REC_CTR_PROC: process( CLK, RESET )
+  begin
+    if   ( RESET = '1' ) then
+      frames_received_ctr <= (others => '0');
+    elsif( rising_edge(CLK) ) then
+      if( FR_FRAME_VALID_IN = '1' ) then
+        frames_received_ctr <= frames_received_ctr + 1;
+      end if;
     end if;
-  end if;
-end process;
+  end process FRAMES_REC_CTR_PROC;
 
-FRAMES_REC_CTR_PROC: process( CLK, RESET )
-begin
-  if   ( RESET = '1' ) then
-    frames_received_ctr <= (others => '0');
-  elsif( rising_edge(CLK) ) then
-    if( FR_FRAME_VALID_IN = '1' ) then
-      frames_received_ctr <= frames_received_ctr + 1;
+  FRAMES_READOUT_CTR_PROC: process( CLK, RESET )
+  begin
+    if   ( RESET = '1' ) then
+      frames_readout_ctr <= (others => '0');
+    elsif( rising_edge(CLK) ) then
+      if( RC_LOADING_DONE_IN = '1' ) then
+        frames_readout_ctr <= frames_readout_ctr + 1;
+      end if;    
     end if;
-  end if;
-end process FRAMES_REC_CTR_PROC;
-
-FRAMES_READOUT_CTR_PROC: process( CLK, RESET )
-begin
-  if   ( RESET = '1' ) then
-    frames_readout_ctr <= (others => '0');
-  elsif( rising_edge(CLK) ) then
-    if( RC_LOADING_DONE_IN = '1' ) then
-      frames_readout_ctr <= frames_readout_ctr + 1;
-    end if;    
-  end if;
-end process FRAMES_READOUT_CTR_PROC;
-
--- debug only
-BYTES_REC_CTR_PROC : process( CLK )
-begin
-  if   ( RESET = '1' ) then
-    bytes_rec_ctr <= (others => '0');
-  elsif( rising_edge(CLK) ) then
-    if( FR_FRAME_VALID_IN = '1' ) then
-      bytes_rec_ctr <= bytes_rec_ctr + unsigned(FR_FRAME_SIZE_IN);    
+  end process FRAMES_READOUT_CTR_PROC;
+
+  -- debug only
+  BYTES_REC_CTR_PROC : process( CLK )
+  begin
+    if   ( RESET = '1' ) then
+      bytes_rec_ctr <= (others => '0');
+    elsif( rising_edge(CLK) ) then
+      if( FR_FRAME_VALID_IN = '1' ) then
+        bytes_rec_ctr <= bytes_rec_ctr + unsigned(FR_FRAME_SIZE_IN);    
+      end if;
     end if;
-  end if;
-end process BYTES_REC_CTR_PROC;
-
-SAVED_PROTO_PROC : process( CLK )
-begin
-  if( rising_edge(CLK) ) then
-    if( load_current_state = READY ) then
-      if( and_all(proto_code) = '0' ) then
-        saved_proto <= proto_code;
+  end process BYTES_REC_CTR_PROC;
+
+  SAVED_PROTO_PROC : process( CLK )
+  begin
+    if( rising_edge(CLK) ) then
+      if( load_current_state = READY ) then
+        if( and_all(proto_code) = '0' ) then
+          saved_proto <= proto_code;
+        else
+          saved_proto <= (others => '0');
+        end if;
       else
-        saved_proto <= (others => '0');
+        saved_proto <= saved_proto;
       end if;
-    else
-      saved_proto <= saved_proto;
     end if;
-  end if;
-end process SAVED_PROTO_PROC;
+  end process SAVED_PROTO_PROC;
 
 end gbe_receive_control_arch;
index f1adca5875576f85f1dd2bf0fcf187c21094dea0..22c910aea791e0e2cccb68be9ed9f628c412e482 100644 (file)
@@ -2,10 +2,7 @@ library ieee;
   use ieee.std_logic_1164.all;
   use ieee.numeric_std.all;
   
-library work;
-  use work.trb_net_components.all;
-  use work.trb_net_std.all;
-  use work.trb3_components.all;
+library work;  use work.trb_net_std.all;
   use work.config.all;
 
 entity gbe_sci_reader is
diff --git a/gbe_trb/base/gbe_tx_fifo.vhd b/gbe_trb/base/gbe_tx_fifo.vhd
new file mode 100644 (file)
index 0000000..37c0764
--- /dev/null
@@ -0,0 +1,122 @@
+library ieee;\r
+use ieee.std_logic_1164.all;\r
+use ieee.numeric_std.all;\r
+\r
+library work;\r
+\r
+-- BUG: if no frame is stored in FIFO, and filling the FIFO triggers FIFOFULL,\r
+--      the frame must be written completely but dropped.\r
+--      Otherwise we experience a deadlock in data transfer.\r
+\r
+-- BUG: use dynamic ALMOSTFULL to accommodate for pipelining inside the data\r
+--      multiplexer of hub.\r
+-- FIX: ALMOSTFULL is set at 4092, so we have at least three clocks\r
+\r
+-- OPTIMIZE: we can start transfering data to the MAC once 16bytes (or similar)\r
+--           have been written.\r
+--           The MAC needs a preread and then a continous data stream.\r
+\r
+entity gbe_tx_fifo is\r
+  port(\r
+    CLK               : in  std_logic;\r
+    RESET             : in  std_logic;\r
+    -- MAC interface\r
+    MAC_TX_DATA_OUT   : out std_logic_vector(7 downto 0);\r
+    MAC_TX_READ_IN    : in  std_logic;\r
+    MAC_FIFOEOF_OUT   : out std_logic; -- end of frame marker\r
+    MAC_FIFOEMPTY_OUT : out std_logic; -- must never happen during TX\r
+    MAC_FIFOAVAIL_OUT : out std_logic; -- starts TX process in MAC\r
+    MAC_TX_DONE_IN    : in  std_logic; -- frame sent\r
+    -- FIFO interface\r
+    FIFO_FULL_OUT     : out std_logic;\r
+    FIFO_WR_IN        : in  std_logic;\r
+    FIFO_D_IN         : in  std_logic_vector(8 downto 0);\r
+    -- Link stuff\r
+    FRAME_START_IN    : in  std_logic;\r
+    LINK_ACTIVE_IN    : in  std_logic\r
+  );\r
+end entity gbe_tx_fifo;\r
+\r
+architecture gbe_tx_fifo_arch of gbe_tx_fifo is\r
+\r
+-- state machine signals\r
+\r
+-- Signals\r
+  signal frames_avail      : unsigned(7 downto 0);\r
+  signal frame_written_x   : std_logic;\r
+  signal frame_written     : std_logic;\r
+  signal frame_read        : std_logic;\r
+  signal mac_fifoeof       : std_logic;\r
+  signal mac_tx_read       : std_logic;\r
+  signal frame_active      : std_logic;\r
+  signal fifo_wr           : std_logic;\r
+  signal no_frames_x       : std_logic;\r
+\r
+begin\r
+\r
+  -- FrameActice signal - used to inhibit acceptance of runt frames\r
+  PROC_FRAME_ACTIVE: process( CLK, RESET )\r
+  begin\r
+    if   ( RESET = '1' ) then\r
+      frame_active <= '0';\r
+    elsif( rising_edge(CLK) ) then\r
+      if   ( FRAME_START_IN = '1' ) then\r
+        frame_active <= LINK_ACTIVE_IN;\r
+      elsif( frame_written = '1' ) then\r
+        frame_active <= '0';\r
+      end if;\r
+    end if;\r
+  end process PROC_FRAME_ACTIVE;\r
+\r
+  fifo_wr <= FIFO_WR_IN and frame_active;\r
+\r
+  -- TX FIFO storing full outgoing frames\r
+  THE_TX_FIFO: entity work.fifo_4k_9\r
+  port map(\r
+    DATA          => FIFO_D_IN,\r
+    CLOCK         => CLK,\r
+    WREN          => fifo_wr,\r
+    RDEN          => MAC_TX_READ_IN,\r
+    RESET         => RESET,\r
+    Q(8)          => mac_fifoeof, -- potential bug!!!!\r
+    Q(7 downto 0) => MAC_TX_DATA_OUT,\r
+    EMPTY         => MAC_FIFOEMPTY_OUT, \r
+    FULL          => open,\r
+    ALMOSTFULL    => FIFO_FULL_OUT\r
+  );\r
+\r
+  MAC_FIFOEOF_OUT <= mac_fifoeof;\r
+\r
+  mac_tx_read <= MAC_TX_READ_IN when rising_edge(CLK);\r
+\r
+  -- one frame written to FIFO\r
+  frame_written_x <= '1' when (FIFO_D_IN(8) = '1') and (FIFO_WR_IN = '1') and (frame_active = '1') else '0'; -- HERE\r
+\r
+  frame_written   <= frame_written_x when rising_edge(CLK);\r
+  \r
+  -- one frame read from FIFO\r
+  frame_read <= '1' when (mac_fifoeof = '1') and (mac_tx_read = '1') else '0';\r
+\r
+  -- FramesAvailable counter\r
+  PROC_FRAMES_AVAIL: process( CLK, RESET )\r
+  begin\r
+    if   ( RESET = '1' ) then\r
+      frames_avail <= (others => '0');\r
+    elsif( rising_edge(CLK) ) then\r
+      if   ( (frame_written = '1') and (frame_read = '0') ) then\r
+        -- one frame written successfully\r
+        frames_avail <= frames_avail + 1;\r
+      elsif( (frame_written = '0') and (frame_read = '1') ) then\r
+        -- one frame read successfully\r
+        frames_avail <= frames_avail - 1;\r
+      end if;\r
+    end if;\r
+  end process PROC_FRAMES_AVAIL;\r
+\r
+  MAC_FIFOAVAIL_OUT <= '1' when (frames_avail /= x"00") else '0';\r
+\r
+  -- Bugfix: dropped partially stored frame, if it is the only frame and we run into FIFO full condition\r
+  no_frames_x <= '1' when (frames_avail = x"00") else '0';\r
+  \r
+  \r
+end architecture;\r
index c93874d233fe31cc11ca7bbf7dbf97ed2d817fdb..f2098bea86c3c81f3ced2d1ebb0a843eed5060f9 100644 (file)
@@ -27,22 +27,6 @@ end entity inserter;
 \r
 architecture inserter_arch of inserter is\r
         \r
--- Components\r
-  component fifo_inserter\r
-  port(\r
-    DATA        : in  std_logic_vector(9 downto 0); \r
-    CLOCK       : in  std_logic; \r
-    WREN        : in  std_logic; \r
-    RDEN        : in  std_logic; \r
-    RESET       : in  std_logic; \r
-    WCNT        : out std_logic_vector(4 downto 0);\r
-    Q           : out std_logic_vector(9 downto 0); \r
-    EMPTY       : out std_logic;\r
-    FULL        : out std_logic;\r
-    ALMOSTEMPTY : out std_logic\r
-  );\r
-  end component fifo_inserter;\r
-\r
 -- Signals\r
   signal tx_cd_int        : std_logic;\r
   signal tx_k_int         : std_logic;\r
@@ -92,7 +76,7 @@ begin
   DEBUG_OUT(15 downto 9) <= (others => '0');\r
 \r
   -- Syncing and delaying signals for /I/ recognition\r
-  THE_SYNC_PROC: process( CLK )\r
+  PROC_SYNC: process( CLK )\r
   begin\r
     if( rising_edge(CLK) ) then\r
       -- synced active signal\r
@@ -109,7 +93,7 @@ begin
       idle_int    <= idle_x;\r
       remove_int  <= remove_x;\r
     end if;\r
-  end process THE_SYNC_PROC;\r
+  end process PROC_SYNC;\r
 \r
   -- sync reset\r
   rst_n_int   <=     active_int(2);\r
@@ -121,7 +105,7 @@ begin
              else '0';\r
 \r
   -- insert counter\r
-  THE_INSERT_COUNTER_PROC: process( CLK )\r
+  PROC_INSERT_COUNTER: process( CLK )\r
   begin\r
     if( rising_edge(CLK) ) then\r
       if   ( rst_int = '1' ) then\r
@@ -132,10 +116,10 @@ begin
         ins_cnt <= ins_cnt - 1;\r
       end if;\r
     end if;\r
-  end process THE_INSERT_COUNTER_PROC;\r
+  end process PROC_INSERT_COUNTER;\r
 \r
   -- store the payload\r
-  THE_PAYLOAD_PROC: process( CLK )\r
+  PROC_PAYLOAD: process( CLK )\r
   begin\r
     if( rising_edge(CLK) ) then\r
       if   ( rst_int = '1' ) then\r
@@ -144,7 +128,7 @@ begin
         payload <= DLM_DATA_IN;\r
       end if;\r
     end if;\r
-  end process THE_PAYLOAD_PROC;\r
+  end process PROC_PAYLOAD;\r
   \r
   -- we need to drop at least one /I/\r
   drop_req_x <= '1' when (ins_cnt /= b"000") else '0';\r
@@ -154,7 +138,7 @@ begin
   fifo_wr_x  <= '0' when ((remove_x = '1') or (remove_int = '1')) else '1';\r
 \r
   -- FIFO\r
-  THE_FIFO: fifo_inserter\r
+  THE_FIFO: entity work.fifo_inserter\r
   port map(\r
     DATA          => delay_qqq,\r
     CLOCK         => CLK,\r
index 3fc16785a3be467ae504ef1e7cb823827dfdca1f..8c1996bae19f7b398e0557a70ea0416577252c69 100644 (file)
@@ -25,22 +25,6 @@ end entity remover;
 \r
 architecture remover_arch of remover is\r
 \r
--- Components\r
-  component fifo_remover\r
-  port(\r
-    DATA        : in  std_logic_vector(8 downto 0);\r
-    CLOCK       : in  std_logic;\r
-    WREN        : in  std_logic;\r
-    RDEN        : in  std_logic;\r
-    RESET       : in  std_logic;\r
-    Q           : out std_logic_vector(8 downto 0);\r
-    WCNT        : out std_logic_vector(4 downto 0);\r
-    EMPTY       : out std_logic;\r
-    FULL        : out std_logic;\r
-    ALMOSTFULL  : out std_logic\r
-  );\r
-  end component fifo_remover;\r
-\r
 -- state machine signals\r
   type state_t is (FILL, IDLE, ONE, TWO, THREE);\r
   signal STATE, NEXT_STATE    : state_t;\r
@@ -81,13 +65,13 @@ begin
   DEBUG_OUT(15 downto 6) <= (others => '0');\r
 \r
   -- Syncing\r
-  THE_SYNC_PROC: process( CLK )\r
+  PROC_SYNC: process( CLK )\r
   begin\r
     if( rising_edge(CLK) ) then\r
       -- synced active signal\r
       active_int          <= active_int(1 downto 0) & ACTIVE_IN;\r
     end if;\r
-  end process THE_SYNC_PROC;\r
+  end process PROC_SYNC;\r
 \r
   -- sync reset\r
   rst_n_int   <=     active_int(2);\r
@@ -104,7 +88,7 @@ begin
 \r
   DLM_FOUND_OUT <= dlm_found when rising_edge(CLK); -- needed to have valid data\r
 \r
-  THE_STORE_PROC: process( CLK )\r
+  PROC_STORE: process( CLK )\r
   begin\r
     if( rising_edge(CLK) ) then\r
       if   ( rst_int = '1' ) then\r
@@ -113,7 +97,7 @@ begin
         dlm_data_int <= rx_d_int;\r
       end if;\r
     end if;\r
-  end process THE_STORE_PROC;\r
+  end process PROC_STORE;\r
 \r
   DLM_DATA_OUT <= dlm_data_int;\r
 \r
@@ -121,7 +105,7 @@ begin
   fifo_wr_x <= '0' when ((dlm_found_x = '1') or (dlm_found = '1')) else '1';\r
  \r
   -- FIFO\r
-  THE_FIFO: fifo_remover\r
+  THE_FIFO: entity work.fifo_remover\r
   port map(\r
     DATA(8)           => rx_k_int,\r
     DATA(7 downto 0)  => rx_d_int,\r
@@ -158,7 +142,7 @@ begin
   -----------------------------------------------------------\r
   -- statemachine: clocked process\r
   -----------------------------------------------------------\r
-  THE_FSM: process( CLK )\r
+  PROC_FSM: process( CLK )\r
   begin\r
     if( rising_edge(CLK) ) then\r
       if( rst_int = '1' ) then\r
@@ -171,12 +155,12 @@ begin
         replace_d <= replace_d_x;\r
       end if;\r
     end if;\r
-  end process THE_FSM;\r
+  end process PROC_FSM;\r
 \r
   -----------------------------------------------------------\r
   -- staemachine: transitions\r
   -----------------------------------------------------------\r
-  THE_STATE_TRANSITIONS: process( STATE, RX_D_IN, RX_K_IN, phy_k_fifo, phy_d_fifo, fifofull )\r
+  PROC_STATE_TRANSITIONS: process( STATE, RX_D_IN, RX_K_IN, phy_k_fifo, phy_d_fifo, fifofull )\r
   begin\r
     replace_k_x <= '0';\r
     replace_d_x <= '0';\r
@@ -219,6 +203,6 @@ begin
       when others =>\r
         NEXT_STATE <= IDLE;\r
     end case;\r
-  end process THE_STATE_TRANSITIONS;\r
+  end process PROC_STATE_TRANSITIONS;\r
 \r
 end architecture;\r
index a9ffaf97f19fee030559b66abc815e1d242a79d0..c5291f14169fe8d06835b6cfbfb20c8532e5216f 100644 (file)
@@ -128,8 +128,8 @@ begin
   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_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;
 
index 0ed6aa4714313a3b8b43417f6402138181221410..04459c26b052fb913aa42cc682279ec9ced4316e 100644 (file)
@@ -86,16 +86,16 @@ architecture gbe_response_constructor_Forward_arch of gbe_response_constructor_F
 
   begin
 
-  DISSECT_MACHINE_PROC: process( CLK, RESET )
+  PROC_DISSECT_FSM: process( CLK, RESET )
   begin
-    if( RESET = '1' ) then
+    if   ( RESET = '1' ) then
       dissect_current_state <= IDLE;
     elsif( rising_edge(CLK) ) then
       dissect_current_state <= dissect_next_state;
     end if;
-  end process DISSECT_MACHINE_PROC;
+  end process PROC_DISSECT_FSM;
 
-  DISSECT_MACHINE: process(dissect_current_state, FWD_SOP_IN, FWD_EOP_IN, ff_q, ff_rd_lock, PS_SELECTED_IN)
+  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
     
@@ -136,15 +136,13 @@ architecture gbe_response_constructor_Forward_arch of gbe_response_constructor_F
         dissect_next_state <= IDLE;
     
     end case;
-  end process DISSECT_MACHINE;
+  end process PROC_DISSECT_TRANSITIONS;
 
   PS_BUSY_OUT <= '0' when dissect_current_state = IDLE else '1';
+  ff_wr_en    <= '1' when (FWD_DATA_VALID_IN = '1') else '0';
+  local_eop   <= '1' when (dissect_current_state = SAVE and FWD_EOP_IN = '1' and FWD_DATA_VALID_IN = '1') else '0';
 
-  ff_wr_en <= '1' when (FWD_DATA_VALID_IN = '1') else '0';
-
-  local_eop <= '1' when (dissect_current_state = SAVE and FWD_EOP_IN = '1' and FWD_DATA_VALID_IN = '1') else '0';
-
-  FF_RD_LOCK_PROC: process( CLK, RESET )
+  PROC_FF_RD_LOCK: process( CLK, RESET )
   begin
     if   ( RESET = '1' ) then
       ff_rd_lock <= '1';
@@ -155,9 +153,9 @@ architecture gbe_response_constructor_Forward_arch of gbe_response_constructor_F
         ff_rd_lock <= '1';
       end if;
     end if;
-  end process FF_RD_LOCK_PROC;
+  end process PROC_FF_RD_LOCK;
 
-  FRAME_FIFO: entity fifo_4096x9
+  THE_FRAME_FIFO: entity fifo_4096x9
   port map( 
     Data(7 downto 0)    => FWD_DATA_IN,
     Data(8)             => local_eop,
@@ -174,14 +172,11 @@ architecture gbe_response_constructor_Forward_arch of gbe_response_constructor_F
 
   ff_rd_en <= '1' when (TC_RD_EN_IN = '1' and PS_SELECTED_IN = '1') else '0';
 
-  --TC_DATA_OUT <= ff_q; -- BUG?!?
   TC_DATA_OUT <= ff_q when rising_edge(CLK);
 
   PS_RESPONSE_READY_OUT <= '1' when (dissect_current_state = LOAD) else '0';
 
-  --TC_FRAME_SIZE_OUT <= resp_bytes_ctr + x"1"; -- BUG?!?
-  TC_FRAME_SIZE_OUT <= resp_bytes_ctr;
-
+  TC_FRAME_SIZE_OUT  <= resp_bytes_ctr;
   TC_FRAME_TYPE_OUT  <= x"0008";
   TC_DEST_MAC_OUT    <= FWD_DST_MAC_IN;
   TC_DEST_IP_OUT     <= FWD_DST_IP_IN;
@@ -192,7 +187,7 @@ architecture gbe_response_constructor_Forward_arch of gbe_response_constructor_F
   TC_IP_PROTOCOL_OUT <= x"11";
   TC_IDENT_OUT       <= x"6" & sent_frames(11 downto 0);
 
-  RESP_BYTES_CTR_PROC: process( CLK, RESET )
+  PROC_RESP_BYTES_CTR: process( CLK, RESET )
   begin
     if   ( RESET = '1' ) then
       resp_bytes_ctr <= (others => '0');
@@ -212,9 +207,9 @@ architecture gbe_response_constructor_Forward_arch of gbe_response_constructor_F
       end if;
 
     end if;
-  end process RESP_BYTES_CTR_PROC;
+  end process PROC_RESP_BYTES_CTR;
 
-  REC_FRAMES_PROC: process( CLK, RESET )
+  PROC_REC_FRAMES: process( CLK, RESET )
   begin
     if   ( RESET = '1' ) then
       rec_frames <= (others => '0');
@@ -223,9 +218,9 @@ architecture gbe_response_constructor_Forward_arch of gbe_response_constructor_F
         rec_frames <= rec_frames + x"1";
       end if;
     end if;
-  end process REC_FRAMES_PROC;
+  end process PROC_REC_FRAMES;
 
-  SENT_FRAMES_PROC: process( CLK, RESET )
+  PROC_SENT_FRAMES: process( CLK, RESET )
   begin
     if   ( RESET = '1' ) then
       sent_frames <= (others => '0');
@@ -234,7 +229,7 @@ architecture gbe_response_constructor_Forward_arch of gbe_response_constructor_F
         sent_frames <= sent_frames + x"1";
       end if;
     end if;
-  end process SENT_FRAMES_PROC;
+  end process PROC_SENT_FRAMES;
 
   RECEIVED_FRAMES_OUT <= rec_frames;
   SENT_FRAMES_OUT     <= sent_frames;
index 4054fb4f7fc46f9c32108e2008f64e9bc59705e9..d10a6979312bcb0a32a36a81006b3f117d06c28c 100644 (file)
@@ -363,7 +363,7 @@ begin
 -------------------------------------------------
 -- SerDes quad
 -------------------------------------------------
-  gbe_serdes: entity serdes_gbe_4ch_ds
+  THE_GBE_SERDES: entity work.serdes_gbe_4ch_ds
   port map(
     -- CH0 --
     hdinp_ch0           => SD_RXD_P_IN(0),
@@ -524,7 +524,7 @@ begin
   WAP_OUT <= wa_position_i;
   
   -- in case we have no uplink port, no local port is generated
-  NO_LOCAL_GEN: if (quad_mode < 8) generate
+  NO_LOCAL_GEN: if( quad_mode < 8 ) generate
     MAC_RX_DATA_OUT  <= (others => '0');
     MAC_RX_WRITE_OUT <= '0';
     MAC_RX_EOF_OUT   <= '0';
@@ -532,9 +532,9 @@ begin
   end generate NO_LOCAL_GEN;
 
   -- generate master and slave channel, i.e. active SerDes connections
-  CHANNEL_GEN : for i in 0 to 3 generate
+  CHANNEL_GEN: for i in 0 to 3 generate
     
-    CHANNEL_ACTIVE_GEN : if ((LINK_MODE(i) = c_IS_SLAVE) or (LINK_MODE(i) = c_IS_MASTER)) generate
+    CHANNEL_ACTIVE_GEN: if( (LINK_MODE(i) = c_IS_SLAVE) or (LINK_MODE(i) = c_IS_MASTER) ) generate
 
       -- Debug signals, MSB to LSB
       DEBUG_OUT(i * 32 + 31) <= '0'; -- (31)
@@ -575,7 +575,7 @@ begin
     
       -- RSL for RX of SerDes, based on extRSL logic
       -- CAVEAT: reset signals MUST BE sync'ed to recovered RX clock!
-      THE_MAIN_RX_RST: main_rx_reset_RS 
+      THE_GBE_RX_RST: entity work.gbe_rx_reset
       port map(
         CLEAR             => CLEAR,
         CLK_REF           => CLK_125, -- needs always to run on local clock
@@ -611,7 +611,7 @@ begin
       --- Trudy and Eve ------------------------------------------
       ------------------------------------------------------------  
       TRUDY_AND_EVE: if INCLUDE_DLM(i) = 1 generate 
-        THE_TRUDY: entity inserter
+        THE_TRUDY: entity work.inserter
         port map(
           CLK           => MASTER_CLK_IN,
           CLEAR         => CLEAR, -- MUST NOT BE RESET!
@@ -631,7 +631,7 @@ begin
           DEBUG_OUT     => open
         );
 
-        THE_EVE: entity remover
+        THE_EVE: entity work.remover
         port map(
           CLK           => sd_rx_clk(i),
           CLEAR         => CLEAR, -- MUST NOT BE RESET!
@@ -659,7 +659,7 @@ begin
       end generate NO_TRUDY_AND_EVE;
       
       -- SGMII core
-      SGMII_GBE_PCS : sgmii_gbe_pcs42
+      THE_SGMII_GBE_PCS: sgmii_gbe_pcs42
       port map(
         rst_n                   => CLEAR_N, --RESET_N, -- CHECKIFWORKS
         signal_detect           => serdes_active(i),
@@ -712,7 +712,7 @@ begin
       );
 
       -- TSMAC core
-      MAC: tsmac41
+      THE_MAC: tsmac41
       port map(
       ----------------- clock and reset port declarations ------------------
         hclk            => MASTER_CLK_IN,
@@ -766,7 +766,7 @@ begin
       );
       
       -- responsible for loading the TSMAC registers
-      THE_GBE_MAC_CONTROL: entity gbe_mac_control
+      THE_GBE_MAC_CONTROL: entity work.gbe_mac_control
       port map(
         CLK                 => MASTER_CLK_IN,
         RESET               => CLEAR, --RESET, -- CHECKIFWORKS
@@ -787,7 +787,7 @@ begin
       );
       
       -- initializes MAC after AN is complete 
-      THE_FW_GBE_LSM: entity gbe_lsm
+      THE_FW_GBE_LSM: entity work.gbe_lsm
       port map(
         CLK                  => MASTER_CLK_IN,
         RESET                => CLEAR, --RESET, -- CHECKIFWORKS
@@ -825,7 +825,7 @@ begin
       );
       
       -- TX FIFO
-      THE_FW_FIFO: entity tx_fifo
+      THE_FW_FIFO: entity work.gbe_tx_fifo
       port map(
         CLK               => MASTER_CLK_IN,
         RESET             => CLEAR, --RESET, -- CHECKIFWORKS
diff --git a/media_interfaces/sync/gbe_rx_reset.vhd b/media_interfaces/sync/gbe_rx_reset.vhd
new file mode 100644 (file)
index 0000000..7e947d1
--- /dev/null
@@ -0,0 +1,250 @@
+library ieee;\r
+use ieee.std_logic_1164.all;\r
+USE IEEE.numeric_std.all;\r
+\r
+entity gbe_rx_reset is\r
+  port (\r
+    CLEAR             : in  std_logic; -- do not use\r
+    CLK_REF           : in  std_logic; -- usually local oscillator sourced\r
+    CDR_LOL_IN        : in  std_logic;\r
+    CV_IN             : in  std_logic;\r
+    LSM_IN            : in  std_logic;\r
+    LOS_IN            : in  std_logic;\r
+    WAP_ZERO_IN       : in  std_logic;\r
+    -- outputs\r
+    WAP_REQ_OUT       : out std_logic;\r
+    RX_SERDES_RST_OUT : out std_logic;\r
+    RX_PCS_RST_OUT    : out std_logic;\r
+    LINK_RX_READY_OUT : out std_logic;\r
+    STATE_OUT         : out std_logic_vector(3 downto 0)\r
+  );\r
+end entity gbe_rx_reset;  \r
+\r
+architecture gbe_rx_reset_arch of gbe_rx_reset is\r
+\r
+  attribute syn_keep : boolean;\r
+\r
+-- Remark: work of Christian Michel. Just re-edited to reflect necessary changes for ECP3.\r
+-- Without this piece of code, many things would have been a real pain.\r
+\r
+  constant Tshort_bit : integer := 4; -- count up to 2^4 = 16\r
+  constant Tplol_bit  : integer := 22;\r
+  constant Tcdr_bit   : integer := 22;\r
+  constant Tviol_bit  : integer := 22;\r
+\r
+  signal cdr_lol_s    : std_logic;\r
+  signal cv_s         : std_logic;\r
+  signal lsm_s        : std_logic;\r
+  signal los_s        : std_logic;\r
+  signal wap_zero_s   : std_logic;\r
+\r
+  signal cnt          : unsigned(31 downto 0);\r
+\r
+  type rx_sm_state is (POWERUP, APPLY_CDR_RST, WAIT_CDR_LOCK, TEST_CDR, \r
+                       APPLY_RXPCS_RST, WAIT_RXPCS_LOCK, TEST_RXPCS, \r
+                       CHECK_WAP, NORMAL_OP);\r
+\r
+  signal rx_sm : rx_sm_state;\r
+  \r
+  attribute syn_keep of rx_sm : signal is true;\r
+\r
+begin\r
+\r
+-- Remark: on ECP3, rx_serdes_rst sets RX_CDR_LOL. Deadlocks on POWERUP.\r
+-- Remark: syncing is done here by one FF only. Might be dangerous.\r
+\r
+------------------------------------------------------------------\r
+  PROC_RX_RESET: process( CLEAR, CLK_REF )\r
+  begin\r
+    if( CLEAR = '1' ) then\r
+      cdr_lol_s         <= '1';\r
+      cv_s              <= '1';\r
+      lsm_s             <= '0';\r
+      los_s             <= '1';\r
+      wap_zero_s        <= '0';\r
+\r
+      RX_SERDES_RST_OUT <= '1';\r
+      RX_PCS_RST_OUT    <= '1';\r
+      LINK_RX_READY_OUT <= '0';\r
+      WAP_REQ_OUT       <= '0';\r
+\r
+      rx_sm         <= POWERUP;\r
+      STATE_OUT     <= x"f";\r
+      cnt           <= (others => '0');  \r
+    elsif( rising_edge(CLK_REF) ) then\r
+      cdr_lol_s     <= CDR_LOL_IN;\r
+      cv_s          <= CV_IN;    \r
+      lsm_s         <= LSM_IN;    \r
+      los_s         <= LOS_IN; \r
+      wap_zero_s    <= WAP_ZERO_IN;\r
+  \r
+      case rx_sm is\r
+        when POWERUP =>\r
+          STATE_OUT <= x"0";\r
+          RX_SERDES_RST_OUT <= '0'; -- needed for RX_LOS to be active\r
+          RX_PCS_RST_OUT    <= '1';\r
+          LINK_RX_READY_OUT <= '0';\r
+          WAP_REQ_OUT       <= '0';\r
+          if( (los_s = '1') ) then -- seems to work\r
+            cnt <= (others => '0');\r
+          else\r
+            if( cnt(Tplol_bit) = '1' ) then\r
+              cnt <= (others => '0');\r
+              rx_sm <= APPLY_CDR_RST;\r
+            else\r
+              cnt <= cnt + 1;\r
+            end if;\r
+          end if;\r
+\r
+        when APPLY_CDR_RST =>\r
+          STATE_OUT <= x"1";\r
+          RX_SERDES_RST_OUT <= '1';\r
+          RX_PCS_RST_OUT    <= '1';\r
+          LINK_RX_READY_OUT <= '0';\r
+          WAP_REQ_OUT       <= '0';\r
+          if( cnt(Tshort_bit) = '1' ) then\r
+            cnt <= (others => '0');\r
+            rx_sm <= WAIT_CDR_LOCK;\r
+          else\r
+            cnt <= cnt + 1;\r
+          end if;\r
+      \r
+        when WAIT_CDR_LOCK =>\r
+          STATE_OUT <= x"2";\r
+          RX_SERDES_RST_OUT <= '0';\r
+          RX_PCS_RST_OUT    <= '1';\r
+          LINK_RX_READY_OUT <= '0';\r
+          WAP_REQ_OUT       <= '0';\r
+          if( cnt(Tcdr_bit) = '1' ) then\r
+            cnt <= (others => '0');\r
+            rx_sm <= TEST_CDR;\r
+          else\r
+            cnt <= cnt + 1;\r
+          end if;\r
+\r
+        when TEST_CDR =>\r
+          STATE_OUT <= x"3";\r
+          RX_SERDES_RST_OUT <= '0';\r
+          RX_PCS_RST_OUT    <= '1';\r
+          LINK_RX_READY_OUT <= '0';\r
+          WAP_REQ_OUT       <= '0';\r
+          if  ( los_s = '1' ) then\r
+            rx_sm <= POWERUP;      \r
+            cnt <= (others => '0');\r
+          elsif( cdr_lol_s = '1' ) then\r
+            cnt <= (others => '0');\r
+            rx_sm <= APPLY_CDR_RST;\r
+          else\r
+            if( cnt(Tcdr_bit) = '1' ) then\r
+              cnt <= (others => '0');\r
+              rx_sm <= APPLY_RXPCS_RST;\r
+            else\r
+              cnt <= cnt + 1;\r
+            end if;\r
+          end if;\r
+\r
+        when APPLY_RXPCS_RST =>\r
+          STATE_OUT <= x"4";\r
+          RX_SERDES_RST_OUT <= '0';\r
+          RX_PCS_RST_OUT    <= '1';\r
+          LINK_RX_READY_OUT <= '0';\r
+          WAP_REQ_OUT       <= '0';\r
+          if   ( los_s = '1' ) then\r
+            rx_sm <= POWERUP;      \r
+            cnt <= (others => '0');\r
+          elsif( cnt(Tshort_bit) = '1' ) then\r
+            cnt <= (others => '0');\r
+            rx_sm <= WAIT_RXPCS_LOCK;\r
+          else\r
+            cnt <= cnt + 1;\r
+          end if;\r
+\r
+        when WAIT_RXPCS_LOCK =>\r
+          STATE_OUT <= x"5";\r
+          RX_SERDES_RST_OUT <= '0';\r
+          RX_PCS_RST_OUT    <= '0';\r
+          LINK_RX_READY_OUT <= '0';\r
+          WAP_REQ_OUT       <= '0';\r
+          if  ( los_s = '1' ) then\r
+            rx_sm <= POWERUP;      \r
+            cnt <= (others => '0');\r
+          elsif( cnt(Tviol_bit) = '1' ) then\r
+            cnt <= (others => '0');\r
+            rx_sm <= TEST_RXPCS;\r
+          else\r
+            cnt <= cnt + 1;\r
+          end if;\r
+\r
+        when TEST_RXPCS =>\r
+          STATE_OUT <= x"6";\r
+          RX_SERDES_RST_OUT <= '0';\r
+          RX_PCS_RST_OUT    <= '0';\r
+          LINK_RX_READY_OUT <= '0';\r
+          WAP_REQ_OUT       <= '1';\r
+          if   ( los_s = '1' ) then\r
+            rx_sm <= POWERUP;      \r
+            cnt <= (others => '0');\r
+          elsif( (lsm_s = '0') or (cv_s = '1') ) then\r
+            cnt <= (others => '0');\r
+            rx_sm <= APPLY_RXPCS_RST;\r
+          else\r
+            if( cnt(Tviol_bit) = '1' ) then\r
+              cnt <= (others => '0');\r
+              rx_sm <= CHECK_WAP;\r
+            else\r
+              cnt <= cnt + 1;\r
+            end if;\r
+          end if;\r
+\r
+        when CHECK_WAP =>\r
+          STATE_OUT <= x"7";\r
+          RX_SERDES_RST_OUT <= '0';\r
+          RX_PCS_RST_OUT    <= '0';\r
+          LINK_RX_READY_OUT <= '0';\r
+          WAP_REQ_OUT       <= '0';\r
+          cnt <= (others => '0');\r
+          if   ( los_s = '1' ) then\r
+            rx_sm <= POWERUP;      \r
+            cnt <= (others => '0');\r
+          elsif( cnt(Tshort_bit) = '1' ) then\r
+            cnt <= (others => '0');\r
+            if( wap_zero_s = '1' ) then\r
+              rx_sm <= NORMAL_OP;\r
+            else\r
+              rx_sm <= APPLY_CDR_RST;\r
+            end if;\r
+          else\r
+            cnt <= cnt + 1;\r
+            rx_sm <= CHECK_WAP;\r
+          end if;\r
+     \r
+        when NORMAL_OP =>\r
+          STATE_OUT <= x"8";\r
+          RX_SERDES_RST_OUT <= '0';\r
+          RX_PCS_RST_OUT    <= '0';\r
+          LINK_RX_READY_OUT <= '1';\r
+          WAP_REQ_OUT       <= '0';\r
+          cnt <= (others => '0');\r
+          if   ( los_s = '1' ) then\r
+            rx_sm <= POWERUP;      \r
+            cnt <= (others => '0');\r
+          elsif( (lsm_s = '0') or (cv_s = '1') ) then -- DANGEROUS\r
+            rx_sm <= APPLY_RXPCS_RST;      \r
+          end if;\r
+\r
+        when others =>\r
+          -- just in case\r
+          STATE_OUT <= x"f";\r
+          RX_SERDES_RST_OUT <= '0';\r
+          RX_PCS_RST_OUT    <= '0';\r
+          LINK_RX_READY_OUT <= '0';\r
+          WAP_REQ_OUT       <= '0';\r
+          rx_sm <= POWERUP;\r
+          cnt <= (others => '0');\r
+\r
+      end case;\r
+\r
+    end if;\r
+  end process PROC_RX_RESET;\r
+  \r
+end architecture gbe_rx_reset_arch;\r
index 2f47e922e4ca26157a4a5d9306d75e70c8a40d2c..6d9a3d0b1b0ba05f5bc8eb767e89589cc15ab676 100644 (file)
@@ -11,7 +11,7 @@ entity trb_net16_regio_bus_handler_record is
     PORT_ADDRESSES : c_BUS_HANDLER_ADDR_t := (others => (others => '0'));
     PORT_ADDR_MASK : c_BUS_HANDLER_WIDTH_t := (others => 0);
     PORT_MASK_ENABLE : integer range 0 to 1 := 0
-    );
+  );
   port(
     CLK                   : in  std_logic;
     RESET                 : in  std_logic;
@@ -23,8 +23,8 @@ entity trb_net16_regio_bus_handler_record is
     BUS_TX                : in  ctrlbus_tx_array_t(0 to PORT_NUMBER-1);
     
     STAT_DEBUG            : out std_logic_vector(31 downto 0)
-    );
-end entity;
+  );
+end entity trb_net16_regio_bus_handler_record;
 
 
 --   type CTRLBUS_TX is record
@@ -75,84 +75,78 @@ begin
 --Decode Addresses
 ---------------------------------------------------------------------
 
-  proc_port_select : process(REGIO_RX.addr)
-    begin
-      next_port_select_int <= PORT_NUMBER;
-      gen_port_select : for i in 0 to PORT_NUMBER-1 loop
-        if (PORT_ADDR_MASK(i) = 16 or
-            (REGIO_RX.addr(15 downto PORT_ADDR_MASK(i)) = PORT_ADDRESSES(i)(15 downto PORT_ADDR_MASK(i)))) then
-          next_port_select_int <= i;
-        end if;
-      end loop;
-    end process;
+  PROC_PORT_SELECT: process( REGIO_RX.addr )
+   begin
+    next_port_select_int <= PORT_NUMBER;
+    GEN_PORT_SELECT : for i in 0 to PORT_NUMBER-1 loop
+      if (PORT_ADDR_MASK(i) = 16 or
+          (REGIO_RX.addr(15 downto PORT_ADDR_MASK(i)) = PORT_ADDRESSES(i)(15 downto PORT_ADDR_MASK(i)))) then
+        next_port_select_int <= i;
+      end if;
+    end loop;
+    end process PROC_PORT_SELECT;
 
 ---------------------------------------------------------------------
 --Generate R/W strobes
 ---------------------------------------------------------------------
 
-  proc_rw_signals : process(CLK)
-    begin
-      if rising_edge(CLK) then
---         if RESET = '1' then
---           buf_BUS_READ_OUT  <= (others => '0');
---           buf_BUS_WRITE_OUT <= (others => '0');
---           port_select_int <= PORT_NUMBER;
---         else
-          buf_BUS_READ_OUT  <= (others => '0');
-          buf_BUS_WRITE_OUT <= (others => '0');
-          if REGIO_RX.write = '1' or REGIO_RX.read = '1' then
-            buf_BUS_DATA_OUT  <= REGIO_RX.data;
-            buf_BUS_ADDR_OUT  <= REGIO_RX.addr;
-            port_select_int   <= next_port_select_int;
-          end if;
-          if REGIO_RX.read = '1' then
-            buf_BUS_READ_OUT(next_port_select_int) <= '1';
-          end if;
-          if REGIO_RX.write = '1' then
-            buf_BUS_WRITE_OUT(next_port_select_int) <= '1';
-          end if;
-          if (buf_BUS_DATAREADY_IN(port_select_int) or 
-              buf_BUS_WRITE_ACK_IN(port_select_int) or
-              buf_BUS_UNKNOWN_ADDR_IN(port_select_int) or
-              buf_BUS_NO_MORE_DATA_IN(port_select_int)) = '1' then
-            port_select_int <= PORT_NUMBER;
-          end if;  
-        end if;
---       end if;
-    end process;
+  PROC_RW_SIGNALS: process( CLK )
+  begin
+    if( rising_edge(CLK) ) then
+      buf_BUS_READ_OUT  <= (others => '0');
+      buf_BUS_WRITE_OUT <= (others => '0');
+      if REGIO_RX.write = '1' or REGIO_RX.read = '1' then
+        buf_BUS_DATA_OUT  <= REGIO_RX.data;
+        buf_BUS_ADDR_OUT  <= REGIO_RX.addr;
+        port_select_int   <= next_port_select_int;
+      end if;
+      if REGIO_RX.read = '1' then
+        buf_BUS_READ_OUT(next_port_select_int) <= '1';
+      end if;
+      if REGIO_RX.write = '1' then
+        buf_BUS_WRITE_OUT(next_port_select_int) <= '1';
+      end if;
+      if (buf_BUS_DATAREADY_IN(port_select_int) or 
+          buf_BUS_WRITE_ACK_IN(port_select_int) or
+          buf_BUS_UNKNOWN_ADDR_IN(port_select_int) or
+          buf_BUS_NO_MORE_DATA_IN(port_select_int)) = '1' then
+        port_select_int <= PORT_NUMBER;
+      end if;  
+    end if;
+  end process PROC_RW_SIGNALS;
 
 ---------------------------------------------------------------------
 --Map Data Outputs
 ---------------------------------------------------------------------
 
-  gen_outputs  : for i in 0 to PORT_NUMBER-1 generate
+  GEN_OUTPUTS: for i in 0 to PORT_NUMBER-1 generate
     BUS_RX(i).read    <= buf_BUS_READ_OUT(i);
     BUS_RX(i).write   <= buf_BUS_WRITE_OUT(i);
     BUS_RX(i).data    <= buf_BUS_DATA_OUT;
     BUS_RX(i).timeout <= REGIO_RX.timeout;
-    port_mask_disabled : if PORT_MASK_ENABLE = 0 generate
+    PORT_MASK_DISABLED: if PORT_MASK_ENABLE = 0 generate
       BUS_RX(i).addr  <= buf_BUS_ADDR_OUT;
     end generate;   
-    port_mask_enabled : if PORT_MASK_ENABLE = 1 and PORT_ADDR_MASK(i) /= 0 generate
+    PORT_MASK_ENABLED: if PORT_MASK_ENABLE = 1 and PORT_ADDR_MASK(i) /= 0 generate
       BUS_RX(i).addr(PORT_ADDR_MASK(i)-1 downto 0)  <= buf_BUS_ADDR_OUT(PORT_ADDR_MASK(i)-1 downto 0);
       BUS_RX(i).addr(15 downto PORT_ADDR_MASK(i))   <= (others => '0');
     end generate;
-    port_mask_enabled_2 : if PORT_MASK_ENABLE = 1 and PORT_ADDR_MASK(i) = 0 generate
+    PORT_MASK_ENABLED_2 : if PORT_MASK_ENABLE = 1 and PORT_ADDR_MASK(i) = 0 generate
       BUS_RX(i).addr(15 downto 0)   <= (others => '0');
     end generate;
-  end generate;
+  end generate GEN_OUTPUTS;
 
 ---------------------------------------------------------------------
 --Pack Data Inputs and Dummy Input
 ---------------------------------------------------------------------
 
-  gen_inputs  : for i in 0 to PORT_NUMBER-1 generate
+  GEN_INPUTS: for i in 0 to PORT_NUMBER-1 generate
     buf_BUS_DATA_IN(i*32+31 downto i*32) <= BUS_TX(i).data;
     buf_BUS_DATAREADY_IN(i)              <= BUS_TX(i).ack or BUS_TX(i).rack;
     buf_BUS_WRITE_ACK_IN(i)              <= BUS_TX(i).ack or BUS_TX(i).wack;
     buf_BUS_NO_MORE_DATA_IN(i)           <= BUS_TX(i).nack;
     buf_BUS_UNKNOWN_ADDR_IN(i)           <= BUS_TX(i).unknown; 
-  end generate;
+  end generate GEN_INPUTS;
 
   buf_BUS_DATA_IN(PORT_NUMBER*32+31 downto PORT_NUMBER*32) <= (others => '0');
   buf_BUS_DATAREADY_IN(PORT_NUMBER) <= '0';
@@ -160,20 +154,19 @@ begin
   buf_BUS_NO_MORE_DATA_IN(PORT_NUMBER) <= '0';
   buf_BUS_UNKNOWN_ADDR_IN(PORT_NUMBER) <= buf_BUS_READ_OUT(PORT_NUMBER) or buf_BUS_WRITE_OUT(PORT_NUMBER);
 
-
 ---------------------------------------------------------------------
 --Multiplex Data Output
 ---------------------------------------------------------------------
 
-  proc_reg_output_signals : process(CLK)
-    begin
-      if rising_edge(CLK) then
-        REGIO_TX.data         <= buf_BUS_DATA_IN(port_select_int*32+31 downto port_select_int*32);
-        REGIO_TX.ack          <= buf_BUS_DATAREADY_IN(port_select_int) or buf_BUS_WRITE_ACK_IN(port_select_int);
-        REGIO_TX.nack         <= buf_BUS_NO_MORE_DATA_IN(port_select_int);
-        REGIO_TX.unknown      <= buf_BUS_UNKNOWN_ADDR_IN(port_select_int);
-      end if;
-    end process;
+  PROC_REG_OUTPUT_SIGNALS: process( CLK )
+  begin
+    if rising_edge(CLK) then
+      REGIO_TX.data         <= buf_BUS_DATA_IN(port_select_int*32+31 downto port_select_int*32);
+      REGIO_TX.ack          <= buf_BUS_DATAREADY_IN(port_select_int) or buf_BUS_WRITE_ACK_IN(port_select_int);
+      REGIO_TX.nack         <= buf_BUS_NO_MORE_DATA_IN(port_select_int);
+      REGIO_TX.unknown      <= buf_BUS_UNKNOWN_ADDR_IN(port_select_int);
+    end if;
+  end process PROC_REG_OUTPUT_SIGNALS;
 
 ---------------------------------------------------------------------
 --Debugging