]> jspc29.x-matter.uni-frankfurt.de Git - mdcoep.git/commitdiff
*** empty log message ***
authorhadeshyp <hadeshyp>
Mon, 20 Jul 2009 15:13:36 +0000 (15:13 +0000)
committerhadeshyp <hadeshyp>
Mon, 20 Jul 2009 15:13:36 +0000 (15:13 +0000)
design/tdc_readout_and_trb_interface.vhd

index fbfa3996a6b1c8ced61deb481ba2863851b2c376..4fecbc12c653ae4ddc2944baa4ca00b6767f6700 100644 (file)
@@ -1,6 +1,6 @@
 -------------------------------------------------------------------------------
 -- Attilio Tarantola
--- Create Date: 18/08/2007  
+-- Create Date: 18/08/2007
 -- Description: it it the top level design of:
 --1) fifo_0
 --2) tdc_readout: it builds the dataword
@@ -25,7 +25,7 @@ use ecp2m.components.all;
 entity tdc_readout_and_trb_interface is
  --  generic (width : integer := 16;
  --           bus_number: std_logic_vector(3 downto 0));
-  port (     
+  port (
     CLK                   : in  std_logic;
     RESET                 : in  std_logic;
 
@@ -35,7 +35,7 @@ entity tdc_readout_and_trb_interface is
     A_ADD                 : in  std_logic_vector(8 downto 0);
     A_RESERV              : in  std_logic;  --this is 11 bit of dataword
     A_AOD                 : in  std_logic;  --address or data
-    A_ACK                 : in  std_logic;  
+    A_ACK                 : in  std_logic;
     A_DST                 : in  std_logic;
     A_DRE                 : out std_logic;
     TOKEN_IN              : in  std_logic_vector(3 downto 0);
@@ -43,7 +43,7 @@ entity tdc_readout_and_trb_interface is
 
 -------------------------------------------------------------------------------
 -- tdc_readout_and_trb_interface
--------------------------------------------------------------------------------     
+-------------------------------------------------------------------------------
     DATA_TYPE_SELECT_IN : in  std_logic_vector(19 downto 0);
     TOKEN_TO_TRB_OUT      : out std_logic;
     REINIT_ROC1_IN        : in  std_logic;
@@ -53,7 +53,7 @@ entity tdc_readout_and_trb_interface is
     DEBUG_REGISTER_0      : out std_logic_vector(7 downto 0);
     DEBUG_REGISTER_1      : out std_logic_vector(7 downto 0);
     DEBUG_REGISTER_2      : out std_logic_vector(7 downto 0);
-    
+
 -------------------------------------------------------------------------------
 -- trbnet interface
 -------------------------------------------------------------------------------
@@ -64,7 +64,7 @@ entity tdc_readout_and_trb_interface is
     LVL1_TRG_INFORMATION_IN : in std_logic_vector(7 downto 0);
     LVL1_ERROR_PATTERN_OUT  : out  std_logic_vector(31 downto 0) := x"00000000";
     LVL1_TRG_RELEASE_OUT    : out  std_logic := '0';
-    
+
     --Data Port
     IPU_NUMBER_IN   : in std_logic_vector (15 downto 0);
     IPU_INFORMATION_IN  : in std_logic_vector (7 downto 0);
@@ -86,20 +86,20 @@ architecture behavioral of tdc_readout_and_trb_interface is
 ----------------------------------------------------------------------
 -- FSM_HEADER
 ----------------------------------------------------------------------
-  
+
   type state_type is (idle_state, wait_for_token,
                       send_second_header_state, send_data_state,
                       send_data_1_state,busy_header_state);
-  
+
   signal current_state, next_state : state_type;
-  
+
 ----------------------------------------------------------------------
 -- FSM_FIFO_MULTIPLEXER
 ----------------------------------------------------------------------
   type state_type_fsm_multiplexer is (idle_state_fsm_multiplexer,
                                       wait_for_complete_event_fsm_multiplexer,
                                       send_first_and_second_header_state_fsm_multiplexer,
-                                      
+
                                       send_data_state_fsm_multiplexer,
                                       end_of_event_transfer_fsm_multiplexer,
                                       dummy_wait_1_fsm_multiplexer,
@@ -107,9 +107,9 @@ architecture behavioral of tdc_readout_and_trb_interface is
                                       dummy_wait_4_fsm_multiplexer );
 
   signal current_state_fsm_multiplexer, next_state_fsm_multiplexer : state_type_fsm_multiplexer;
-  
+
   signal reg_fifo_data_in_i, next_fifo_data_in_i, fifo_data_in_i : std_logic_vector(31 downto 0);
-  signal reg_fifo_data_out_i, fifo_data_out_i : std_logic_vector(31 downto 0); 
+  signal reg_fifo_data_out_i, fifo_data_out_i : std_logic_vector(31 downto 0);
   signal reg_fifo_write_enable_i, next_fifo_write_enable_i : std_logic;
   signal reg_lvl1_busy_i, next_lvl1_busy_i : std_logic;
   signal init_tdc_readout_i : std_logic_vector(3 downto 0);
@@ -134,7 +134,7 @@ architecture behavioral of tdc_readout_and_trb_interface is
   signal pulse_init_tdc_readout : std_logic;
 
   signal next_debug_register_fsm_multiplexer : std_logic_vector(7 downto 0);
-  signal reg_debug_register_fsm_multiplexer : std_logic_vector(7 downto 0);  
+  signal reg_debug_register_fsm_multiplexer : std_logic_vector(7 downto 0);
   signal fee_data_fifo_out_i : std_logic_vector(35 downto 0);
   signal header_data_fifo_out_i : std_logic_vector(51 downto 0);
   signal next_data_to_trb_net : std_logic_vector(31 downto 0);
@@ -144,7 +144,7 @@ architecture behavioral of tdc_readout_and_trb_interface is
   signal reg_read_fee_data_fifo_i,next_read_fee_data_fifo_i, next_read_header_fifo_i, reg_read_header_fifo_i : std_logic;
 
   signal word_count_fee_data_fifo : std_logic_vector(13 downto 0);
-  signal word_count_header_fifo : std_logic_vector(9 downto 0);  
+  signal word_count_header_fifo : std_logic_vector(9 downto 0);
   signal reg_lvl1_trg_received, pulse_ipu_start_readout, reg_ipu_read : std_logic;
 
   signal reg_lvl1_trg_type : std_logic_vector(3 downto 0);
@@ -154,14 +154,14 @@ architecture behavioral of tdc_readout_and_trb_interface is
 
   signal reg_lvl1_error_pattern, next_lvl1_error_pattern : std_logic_vector (31 downto 0);
  -- signal reg_ipu_error_pattern, next_ipu_error_pattern : std_logic_vector (31 downto 0);
-    
+
   signal reg_lvl1_trg_release, next_lvl1_trg_release : std_logic;
   signal reg_ipu_data, next_ipu_data : std_logic_vector (31 downto 0);
   signal reg_ipu_data_ready, next_ipu_data_ready :  std_logic;
   signal reg_ipu_finished, next_ipu_finished : std_logic;
   signal how_many_complete_event_in_fifo_counter : std_logic_vector (31 downto 0);
   signal pulse_reg_lvl1_trg_received : std_logic;
-  signal reg_lvl1_trg_number : std_logic_vector(15 downto 0);   
+  signal reg_lvl1_trg_number : std_logic_vector(15 downto 0);
   signal read_header_fifo,read_fee_data_fifo : std_logic;
   signal counter_word_read_from_trbnet : std_logic_vector(3 downto 0);
   signal clear_counter_word_read_from_trbnet : std_logic;
@@ -169,6 +169,9 @@ architecture behavioral of tdc_readout_and_trb_interface is
   signal push_read_fee_data_i,push_read_header_data_i : std_logic;
   signal empty_flag_fee_data_fifo_i, empty_flag_header_data_fifo_i  : std_logic;
   signal reg_empty_flag_fee_data_fifo_i : std_logic;
+  signal reg_empty_flag_header_data_fifo_i : std_logic;
+  signal reg_reg_empty_flag_header_data_fifo_i : std_logic;
+  signal reg_reg_reg_empty_flag_header_data_fifo_i : std_logic;
   signal last_empty_flag_fee_data_fifo_i : std_logic;
   signal pulse_write_header_fifo_i, pulse_write_fee_data_fifo_i : std_logic;
   signal counter_pulse_write_header_fifo_i, counter_pulse_write_fee_data_fifo_i : std_logic_vector(15 downto 0);
@@ -273,8 +276,8 @@ begin  -- behavioral
 
   A_ADO_PULSE: edge_to_pulse
   port map (
-       CLOCK => CLK,               
-       ENABLE_CLK_IN =>'1', 
+       CLOCK => CLK,
+       ENABLE_CLK_IN =>'1',
        SIGNAL_IN => A_AOD,
        PULSE_OUT => pulse_a_aod_i);
 
@@ -313,7 +316,7 @@ begin  -- behavioral
       SIGNAL_IN     => write_fee_data_fifo_i,
       PULSE_OUT     => pulse_write_fee_data_fifo_i);
 
-    
+
 TDC_READOUT_INTERFACE : tdc_readout
     port map (
       CLK                   => CLK,
@@ -334,14 +337,14 @@ TDC_READOUT_INTERFACE : tdc_readout
                                                         --generator after send
                                                         --token
       FULL_FIFO_IN          => '0',
-      DATA_TYPE_SELECT_IN   => DATA_TYPE_SELECT_IN, 
+      DATA_TYPE_SELECT_IN   => DATA_TYPE_SELECT_IN,
       DEBUG_REGISTER_OUT    => debug_register_tdc_readout_i);
 
 -------------------------------------------------------------------------------
 -- OENP point test token back
 -------------------------------------------------------------------------------
 --data transmission to trbnet terminated
-  TOKEN_TO_TRB_OUT <= reg_pseudo_token;  
+  TOKEN_TO_TRB_OUT <= reg_pseudo_token;
 
   FEE_DATA_FIFO : fifo_8192depth_36width_dual_thresh_reg_out
     port map (
@@ -350,7 +353,7 @@ TDC_READOUT_INTERFACE : tdc_readout
       WrEn          => write_fee_data_fifo_i,
       RdEn          => read_fee_data_fifo,
       Reset         => RESET,
-      AmEmptySetThresh => "0000000000000", 
+      AmEmptySetThresh => "0000000000000",
       AmEmptyClrThresh => "0000000000000",
       Q             => fee_data_fifo_out_i,
       WCNT          => word_count_fee_data_fifo,
@@ -386,7 +389,7 @@ TDC_READOUT_INTERFACE : tdc_readout
 end process;
 
   read_fee_data_fifo <= (IPU_READ_IN and reg_read_fee_data_fifo_i) or
-                        pulse_not_empty_flag_fee_data_fifo_i;  
+                        pulse_not_empty_flag_fee_data_fifo_i;
 
 HEADER_FIFO: fifo_fall_through_512depth_52width_reg_out
     port map (
@@ -407,7 +410,7 @@ HEADER_FIFO: fifo_fall_through_512depth_52width_reg_out
 -------------------------------------------------------------------------------
 -- reg_ipu_read is setted by TRBNET,
 -- reg_read_header_fifo_i is defined by the state machine
--------------------------------------------------------------------------------  
+-------------------------------------------------------------------------------
 read_header_fifo <= (IPU_READ_IN and reg_read_header_fifo_i) or
                     push_read_header_data_i or
                     pulse_not_empty_flag_header_data_fifo_i;
@@ -415,9 +418,12 @@ read_header_fifo <= (IPU_READ_IN and reg_read_header_fifo_i) or
 -------------------------------------------------------------------------------
   not_empty_flag_header_data_fifo_i  <= not empty_flag_header_data_fifo_i;
 
-  process(CLK, counter_pulse_not_empty_header)
+  process(CLK)
   begin
     if rising_edge(CLK) then
+      reg_empty_flag_header_data_fifo_i <= empty_flag_header_data_fifo_i;
+      reg_reg_empty_flag_header_data_fifo_i <= reg_empty_flag_header_data_fifo_i;
+      reg_reg_reg_empty_flag_header_data_fifo_i <= reg_reg_empty_flag_header_data_fifo_i;
       if (counter_pulse_not_empty_header = x"0001") then
         pulse_not_empty_flag_header_data_fifo_i <= '0';
       else
@@ -441,36 +447,36 @@ end process;
 -------------------------------------------------------------------------------
 -- I WANT THE FIRST DATAWORD TO APPEAR AT FIFO HEADER
 -- OUTPUT
--------------------------------------------------------------------------------  
+-------------------------------------------------------------------------------
      process (CLK, RESET, pulse_write_header_fifo_i,counter_pulse_write_header_fifo_i)
      begin
        if rising_edge(CLK) then
-         if (RESET = '1') then 
+         if (RESET = '1') then
            push_read_header_data_i <= '0';
          elsif (pulse_write_header_fifo_i = '1' and counter_pulse_write_header_fifo_i = X"0000") then
            push_read_header_data_i <= '1';
           else
-            push_read_header_data_i <= '0';  
+            push_read_header_data_i <= '0';
          end if;
        end if;
      end process;
 
 -----------------------------------------------------------------------------
 -- register empty flag for fee data
------------------------------------------------------------------------------ 
+-----------------------------------------------------------------------------
    process (CLK, RESET)
     begin
       if rising_edge(CLK) then
          last_empty_flag_fee_data_fifo_i <= empty_flag_fee_data_fifo_i;
-         reg_empty_flag_fee_data_fifo_i <= last_empty_flag_fee_data_fifo_i; 
+         reg_empty_flag_fee_data_fifo_i <= last_empty_flag_fee_data_fifo_i;
       end if;
     end process;
 
-  
+
   process (CLK, pulse_write_header_fifo_i)
    begin
      if rising_edge(CLK) then
-       if (RESET = '1') then 
+       if (RESET = '1') then
          counter_pulse_write_header_fifo_i <= (others => '0');
        elsif (pulse_write_header_fifo_i = '1') then
          counter_pulse_write_header_fifo_i <= counter_pulse_write_header_fifo_i + 1;
@@ -480,20 +486,20 @@ end process;
        end if;
      end if;
    end process;
-   
+
 -------------------------------------------------------------------------------
 -- I WANT THE FIRST DATAWORD TO APPEAR AT FIFO DATA
 -- OUTPUT. this is important when I gather the first event
--------------------------------------------------------------------------------  
+-------------------------------------------------------------------------------
    process (CLK, RESET, pulse_write_fee_data_fifo_i, empty_flag_fee_data_fifo_i)
    begin
      if rising_edge(CLK) then
-       if (RESET = '1') then 
+       if (RESET = '1') then
          push_read_fee_data_i <= '0';
        elsif (counter_pulse_write_fee_data_fifo_i >= x"0001") then
          push_read_fee_data_i <= '0';
        elsif (pulse_write_fee_data_fifo_i = '1' and counter_pulse_write_fee_data_fifo_i = X"0000") then
-         push_read_fee_data_i <= '1';  
+         push_read_fee_data_i <= '1';
        else
          push_read_fee_data_i <= push_read_fee_data_i;
      end if;
@@ -503,7 +509,7 @@ end process;
   process (CLK, pulse_write_fee_data_fifo_i)
    begin
      if rising_edge(CLK) then
-       if (RESET = '1') then 
+       if (RESET = '1') then
          counter_pulse_write_fee_data_fifo_i <= (others => '0');
        elsif (pulse_write_fee_data_fifo_i = '1') then
          counter_pulse_write_fee_data_fifo_i <= counter_pulse_write_fee_data_fifo_i + 1;
@@ -521,13 +527,13 @@ end process;
 -- OUTPUT CONNECTIONS
 -------------------------------------------------------------------------------
   LVL1_ERROR_PATTERN_OUT <= x"00000000";
-  LVL1_TRG_RELEASE_OUT <= reg_empty_flag_fee_data_fifo_i and (not next_lvl1_busy_i); 
+  LVL1_TRG_RELEASE_OUT <= reg_empty_flag_fee_data_fifo_i and (not next_lvl1_busy_i);
 
   IPU_DATA_OUT <= next_data_to_trb_net(31 downto 0);
   IPU_DATAREADY_OUT <= (fee_data_fifo_data_valid and next_ipu_data_ready) when
                        (current_state_fsm_multiplexer=send_data_state_fsm_multiplexer) else
                        reg_ipu_data_ready;
-   
+
   IPU_READOUT_FINISHED_OUT <= reg_ipu_finished;
 
   IPU_LENGTH_OUT <= reg_first_header(51 downto 36);
@@ -582,7 +588,7 @@ end process;
    process (CLK, RESET,token_tdc_readout_i, reg_pseudo_token)
   begin
     if rising_edge(CLK) then
-      if (RESET = '1' or reg_pseudo_token ='1') then           
+      if (RESET = '1' or reg_pseudo_token ='1') then
         counter_token_back <= (others => '0');
       elsif (token_tdc_readout_i(0) = '1') then
         counter_token_back <= counter_token_back + 1;
@@ -591,10 +597,10 @@ end process;
       end if;
     end if;
   end process;
-  
+
  -- process init_signals
   process (CLK)
-  begin 
+  begin
     if rising_edge(CLK) then
       if RESET = '1' then
         current_state       <= idle_state;
@@ -618,12 +624,12 @@ end process;
   process(current_state, reg_lvl1_trg_received, token_tdc_readout_i,
           pulse_init_tdc_readout, INIT_TDC_READOUT_IN, almost_empty_flag_fee_data_fifo_i)
   begin
-    
+
     next_write_header_fifo_i       <= '0';
     next_debug_register_fsm_header <= (others => '0');
     next_lvl1_busy_i               <= '0';
     data_header_fifo_in_i <= reg_first_header;
-      
+
     case current_state is
 
       when idle_state =>
@@ -631,7 +637,7 @@ end process;
         next_write_header_fifo_i       <= '0';
         data_header_fifo_in_i          <= reg_first_header;
         next_lvl1_busy_i               <= '0';
-        if (INIT_TDC_READOUT_IN(0) = '1') then 
+        if (INIT_TDC_READOUT_IN(0) = '1') then
           next_state <= wait_for_token;
         else
           next_state                   <= idle_state;
@@ -656,7 +662,7 @@ end process;
         else
           next_state                   <= wait_for_token;
         end if;
-        
+
 -------------------------------------------------------------------------------
 -- SEND HEADER
 -------------------------------------------------------------------------------
@@ -680,7 +686,7 @@ end process;
         else
           next_state                   <= busy_header_state;
         end if;
-         
+
       when others =>
         next_debug_register_fsm_header <= x"00";
         next_write_header_fifo_i       <= '0';
@@ -691,7 +697,7 @@ end process;
   end process;
 
 -----------------------------------------------------------------------------
--- Syncronization and reset FSM_FIFO_MULTIPLEXER 
+-- Syncronization and reset FSM_FIFO_MULTIPLEXER
 -----------------------------------------------------------------------------
   process (CLK, RESET)
   begin
@@ -702,7 +708,7 @@ end process;
         reg_read_fee_data_fifo_i <= '0';
         reg_read_header_fifo_i <= '0';
         reg_lvl1_error_pattern <= (others => '0');
-        reg_lvl1_trg_release <= '0'; 
+        reg_lvl1_trg_release <= '0';
         reg_ipu_data <= (others => '0');
         reg_ipu_data_ready <= '0';
         reg_ipu_finished <= '0';
@@ -716,14 +722,14 @@ end process;
         reg_lvl1_error_pattern <= next_lvl1_error_pattern;
         reg_lvl1_trg_release <= next_lvl1_trg_release;
         reg_ipu_data <= next_ipu_data;
-        reg_ipu_data_ready <= next_ipu_data_ready; 
+        reg_ipu_data_ready <= next_ipu_data_ready;
         reg_ipu_finished <= next_ipu_finished;
         reg_pseudo_token <= next_pseudo_token;
       --  reg_ipu_error_pattern <=  next_ipu_error_pattern;
       end if;
     end if;
   end process;
-  
+
 -------------------------------------------------------------------------------
 -- FSM_FIFO_MULTIPLEXER:
 -- this fsm multiplex data and header into TRB net entity.
@@ -734,8 +740,8 @@ end process;
           word_count_header_fifo, fee_data_fifo_out_i, reg_ipu_read,
           reg_empty_flag_fee_data_fifo_i,reg_flag_in_header,read_header_fifo,
           pulse_ipu_start_readout,counter_token_back, reg_ipu_start_readout_in,
-          header_data_fifo_out_i )
-    
+          header_data_fifo_out_i, reg_reg_reg_empty_flag_header_data_fifo_i )
+
   begin
 
     next_debug_register_fsm_multiplexer <= (others => '0');
@@ -744,7 +750,7 @@ end process;
     next_read_header_fifo_i <= '0';
 
     next_lvl1_error_pattern <= (others => '0');
-    next_lvl1_trg_release <= '0'; 
+    next_lvl1_trg_release <= '0';
     next_ipu_data <= (others => '0');
     next_ipu_data_ready <= '0';
     next_ipu_finished <= '0';
@@ -752,12 +758,12 @@ end process;
     push_read_fee_data_1_i <= '0';
     next_pseudo_token <= '0';
   --  next_ipu_error_pattern <= (others => '0');
-    
+
     case current_state_fsm_multiplexer is
 
       when idle_state_fsm_multiplexer =>
         next_debug_register_fsm_multiplexer <= x"00";
-        next_read_fee_data_fifo_i <= '0';   
+        next_read_fee_data_fifo_i <= '0';
         next_read_header_fifo_i <= '0';
         next_ipu_data_ready <= '0';
         next_data_to_trb_net <= header_data_fifo_out_i(31 downto 0);
@@ -773,16 +779,16 @@ end process;
 -- at the beginning, after the token comes back). This check is important only
 -- if one event is written and the same event is read
 -------------------------------------------------------------------------------
-      when wait_for_complete_event_fsm_multiplexer => 
+      when wait_for_complete_event_fsm_multiplexer =>
         next_debug_register_fsm_multiplexer <= x"01";
-        next_read_fee_data_fifo_i <= '0'; 
+        next_read_fee_data_fifo_i <= '0';
         next_read_header_fifo_i <= '0';
         next_ipu_data_ready <= '0';
         next_data_to_trb_net <= header_data_fifo_out_i(31 downto 0);
 --here I wait only when the first token from the first event is back
 --in future I need to see there is one event at least in the header fifo
 --check if header is in the header fifo
-        if (empty_flag_header_data_fifo_i = '1') then
+        if (reg_reg_reg_empty_flag_header_data_fifo_i = '0') then
         --if (conv_integer(counter_token_back) >= 1) then
           next_state_fsm_multiplexer <= dummy_wait_4_fsm_multiplexer;
         else
@@ -800,9 +806,9 @@ end process;
 -- FIRST HEADER and SECOND : Connect header_fifo to trbnet.
 -- The first and second  headers can be sended.
 -- I check that the TRBNET read only ONE word than I switch the
--- to the data fifo 
+-- to the data fifo
 -------------------------------------------------------------------------------
-      when send_first_and_second_header_state_fsm_multiplexer => 
+      when send_first_and_second_header_state_fsm_multiplexer =>
         next_debug_register_fsm_multiplexer <= x"03";
         next_read_fee_data_fifo_i <= '0';
         next_read_header_fifo_i  <= '1';
@@ -819,18 +825,18 @@ end process;
         end if;
 
 --here register header flag
-        when dummy_wait_1_fsm_multiplexer => 
+        when dummy_wait_1_fsm_multiplexer =>
           next_debug_register_fsm_multiplexer <= x"04";
           next_read_fee_data_fifo_i <= '0';
           next_read_header_fifo_i  <= '0';
           next_ipu_data_ready <= '0';     --trbnet cannot read
           next_data_to_trb_net <= fee_data_fifo_out_i(31 downto 0);
           next_state_fsm_multiplexer <= send_data_state_fsm_multiplexer;
-             
+
 -------------------------------------------------------------------------------
 -- Connect fee_data_fifo to trbnet.
 -- I leave connected till the flag change to next event
--------------------------------------------------------------------------------        
+-------------------------------------------------------------------------------
        when send_data_state_fsm_multiplexer =>
         next_debug_register_fsm_multiplexer <= x"05";
         next_read_fee_data_fifo_i           <= '1';
@@ -841,15 +847,15 @@ end process;
         --event you are sending or if the fifo does not contain anymore data.
 --         if ( (fee_data_fifo_out_i(35 downto 32) /= reg_flag_in_header ) or
 --              (reg_empty_flag_fee_data_fifo_i = '1') ) then
-          if ( reg_empty_flag_fee_data_fifo_i = '1' ) then
+          if ( reg_empty_flag_fee_data_fifo_i = '1' and IPU_READ_IN = '1' ) then
             next_ipu_data_ready        <= '0';
             next_read_fee_data_fifo_i  <= '0';
             next_state_fsm_multiplexer <= end_of_event_transfer_fsm_multiplexer;
           else
             next_state_fsm_multiplexer <= send_data_state_fsm_multiplexer;
           end if;
-        
-  --stay if no tok back and fifo empty for 
+
+  --stay if no tok back and fifo empty for
       when end_of_event_transfer_fsm_multiplexer =>
         next_debug_register_fsm_multiplexer <= x"07";
         next_read_fee_data_fifo_i           <= '0';
@@ -859,14 +865,14 @@ end process;
         next_ipu_finished                   <= '1';  --transmission terminated
         clear_counter_word_read_from_trbnet <= '1';
         push_read_fee_data_1_i              <= '1';
-        
+
         if (reg_ipu_start_readout_in = '0') then
           next_pseudo_token <= '1';
           next_state_fsm_multiplexer        <= idle_state_fsm_multiplexer;
          else
           next_state_fsm_multiplexer        <= end_of_event_transfer_fsm_multiplexer;
          end if;
-        
+
       when others =>
         next_debug_register_fsm_multiplexer <= x"08";
         next_data_to_trb_net <= header_data_fifo_out_i(31 downto 0);
@@ -875,7 +881,7 @@ end process;
   end process;
 
 process (CLK)
-begin  
+begin
   if rising_edge(CLK) then
     last_read_fee_data_fifo <= read_fee_data_fifo;
      if last_read_fee_data_fifo = '1' and last_empty_flag_fee_data_fifo_i = '0' then
@@ -884,10 +890,10 @@ begin
        fee_data_fifo_data_valid <= '0';
      end if;
   end if;
-    
+
 
 end process;
-  
+
 -------------------------------------------------------------------------------
 -- EVENT FLAG GENERATOR:
 -- For each event I generate a flag (4 bits), which will be used to distinguish
@@ -929,7 +935,7 @@ end process;
 -- registering input from TRBnet
 -------------------------------------------------------------------------------
 -- process (CLK)
--- begin 
+-- begin
 --   if rising_edge(CLK) then
 --     if RESET = '1' then
 --       reg_LVL1_TRG_TYPE_IN <= (others => '0');  --4bit
@@ -957,7 +963,7 @@ first_header <= words_in_event_first_header &        --(15 downto 0)
 --number of dataword are counter in differet way if test data is enabled
 words_in_event_first_header <= words_in_event_test_data when (DATA_TYPE_SELECT_IN(3 downto 0) = x"2")
                                else words_in_event;
-                               
+
 --register header
 process (CLK)
  begin
@@ -969,7 +975,7 @@ process (CLK)
      end if;
      end if;
    end process;
-   
+
 DEBUG_REGISTER_0 <= x"0" & reg_debug_register_fsm_multiplexer(3 downto 0);
 
 -------------------------------------------------------------------------------
@@ -1031,16 +1037,16 @@ end process;
 -- PROCESS to count how many word the TRB net reads from the FIFO_HADER
 -------------------------------------------------------------------------------
 process (CLK, RESET, clear_counter_word_read_from_trbnet, reg_ipu_read, current_state_fsm_multiplexer)
-begin 
+begin
   if (rising_edge(CLK)) then
     if (RESET = '1' or clear_counter_word_read_from_trbnet = '1') then
       counter_word_read_from_trbnet <= (others => '0');
     elsif (reg_ipu_read = '1' and
            current_state_fsm_multiplexer = send_first_and_second_header_state_fsm_multiplexer) then
-      counter_word_read_from_trbnet <= counter_word_read_from_trbnet + 1;  
+      counter_word_read_from_trbnet <= counter_word_read_from_trbnet + 1;
     else
-      counter_word_read_from_trbnet <= counter_word_read_from_trbnet;  
-    end if;    
+      counter_word_read_from_trbnet <= counter_word_read_from_trbnet;
+    end if;
   end if;
 end process;
 
@@ -1066,7 +1072,7 @@ end process;
 
 
 -------------------------------------------------------------------------------
--- AVERAGE NUMBER OF DATAWORDS PER EVENT ON THIS BUS. 
+-- AVERAGE NUMBER OF DATAWORDS PER EVENT ON THIS BUS.
 -------------------------------------------------------------------------------
 
 end behavioral;