]> jspc29.x-matter.uni-frankfurt.de Git - trbv2.git/commitdiff
lvl1 code and trigger counter for stand alone system
authorpalka <palka>
Thu, 21 Feb 2008 15:03:44 +0000 (15:03 +0000)
committerpalka <palka>
Thu, 21 Feb 2008 15:03:44 +0000 (15:03 +0000)
tdc_interface.vhd

index 5d867e8cc7d099a04e537f5d2ac78b5f2bde5f46..236dc00bed4390a3a77d1a2225a5ba13080c468b 100755 (executable)
@@ -59,6 +59,7 @@ entity tdc_interface is
     TDC_REGISTER_02                 : out std_logic_vector(31 downto 0);
     TDC_REGISTER_03                 : out std_logic_vector(31 downto 0);
     TDC_REGISTER_04                 : out std_logic_vector(31 downto 0);
+    TDC_REGISTER_05                 : in  std_logic_vector(31 downto 0);
     BUNCH_RESET              : out std_logic;
     EVENT_RESET              : out std_logic;
     READ_ADRESS_END_UP       : out  std_logic;  --here
@@ -201,6 +202,8 @@ architecture tdc_interface of tdc_interface is
   signal lvl1_fifo_rd_en_fsm : std_logic;
   signal tdc_data_valid_i_fsm : std_logic;
   signal lvl1_data_counter : std_logic_vector(15 downto 0):=(others => '0');
+  signal trigger_counter : std_logic_vector(7 downto 0);
+  signal lvl1_code_i : std_logic_vector(3 downto 0);
 begin
    READ_ADRESS_END_UP <=   lvl2_busy_end_pulse;  --here
    TDC_REGISTER : process (CLK, RESET)
@@ -589,11 +592,25 @@ begin
        end if;
      end if;
    end process COUNT_WORDS_IN_EVENT;
+   TRIGGER_COUNTER_PROC : process (CLK, RESET)
+   begin
+     if rising_edge(CLK) then 
+       if RESET = '1' then      
+         trigger_counter <= (others => '1');
+       elsif trigger_with_gen_pulse = '1' then
+         trigger_counter <= trigger_counter + 1;
+       else
+         trigger_counter <= trigger_counter;
+       end if;
+     end if;
+   end process TRIGGER_COUNTER_PROC;
  --  words_in_event <= x"0001" + HOW_MANY_ADD_DATA + 2 + lvl1_buffer_counter;
-   lvl1_tag_minus1 <= LVL1_TAG - 1;
-   first_header  <= x"0" & LVL1_CODE & lvl1_tag_minus1 &  words_in_event;
-   second_header <= x"030000" & HOW_MANY_ADD_DATA;
+   lvl1_tag_minus1 <= trigger_counter when TRIGGER_WITH_GEN_EN = '1' else LVL1_TAG - 1;
+   lvl1_code_i <= x"1" when  TRIGGER_WITH_GEN_EN = '1'else LVL1_CODE;
+--   first_header  <= x"0" & LVL1_CODE & lvl1_tag_minus1 &  words_in_event;
+--   second_header <= x"030000" & HOW_MANY_ADD_DATA;
+   first_header  <= x"0" & lvl1_code_i & lvl1_tag_minus1 &  words_in_event;
+   second_header <= TDC_REGISTER_05(7 downto 0) & x"0000" & HOW_MANY_ADD_DATA;
   -----------------------------------------------------------------------------
   ----------------------------------------------------------------------------
   -- LVL2 logic (only CLK domain)