]> jspc29.x-matter.uni-frankfurt.de Git - trb3.git/commitdiff
extend multiplicity logic to 64 channels
authorJan Michel <j.michel@gsi.de>
Mon, 16 Mar 2020 12:43:15 +0000 (13:43 +0100)
committerJan Michel <j.michel@gsi.de>
Mon, 16 Mar 2020 12:43:15 +0000 (13:43 +0100)
base/code/input_to_trigger_logic_record.vhd

index 6a2c0e98fa81dc8bc714b0a2b3189ad517cc3477..6d4ca786522b4d6e7598c87dfed8aa7d01b56d84 100644 (file)
@@ -47,10 +47,11 @@ signal got_any_edge : std_logic_vector(OUTPUTS-1 downto 0) := (others => '0');
 signal got_coincidence : std_logic;
 signal got_simplecoin  : std_logic;
 signal coin_enable  : std_logic  := '0';
-signal current_multiplicity, set_multiplicity : unsigned(7 downto 0);
+signal current_multiplicity0, current_multiplicity1 : unsigned(7 downto 0);
+signal current_multiplicity, set_multiplicity       : unsigned(7 downto 0);
 signal multiplicity_trigger : std_logic := '0';
-signal multiplicity_enable  : std_logic_vector(31 downto 0);
-signal mult_gated           : std_logic_vector(31 downto 0);
+signal multiplicity_enable  : std_logic_vector(INPUTS-1 downto 0);
+signal mult_gated           : std_logic_vector(INPUTS-1 downto 0);
 
 signal set_output_coin, set_output_mult, set_output_simplecoin : std_logic_vector(7 downto 0);
 signal edge_enable  : std_logic_vector(7 downto 0) := (others => '0');
@@ -111,13 +112,14 @@ begin
     elsif BUS_RX.addr(6 downto 0) = "0110010" then
       set_multiplicity <= unsigned(BUS_RX.data(23 downto 16));
     elsif BUS_RX.addr(6 downto 0) = "0110011" then
-      multiplicity_enable <= BUS_RX.data;
+      multiplicity_enable(31 downto 0) <= BUS_RX.data;
     elsif BUS_RX.addr(6 downto 0) = "0110100" then
       set_output_simplecoin <= BUS_RX.data(7 downto 0);
       set_output_mult <= BUS_RX.data(15 downto 8);
       set_output_coin <= BUS_RX.data(23 downto 16);
       edge_enable     <= BUS_RX.data(31 downto 24);
-
+    elsif BUS_RX.addr(6 downto 0) = "0110101" and INPUTS >= 32 then
+      multiplicity_enable(63 downto 32) <= BUS_RX.data;
     else
       BUS_TX.nack <= '1'; 
       BUS_TX.ack  <= '0';
@@ -178,9 +180,11 @@ begin
     elsif BUS_RX.addr(6 downto 0) = "0110010" then
       BUS_TX.data                 <= x"00" & std_logic_vector(set_multiplicity) & x"00" & std_logic_vector(current_multiplicity);
     elsif BUS_RX.addr(6 downto 0) = "0110011" then
-      BUS_TX.data                 <= multiplicity_enable;
+      BUS_TX.data                 <= multiplicity_enable(31 downto 0);
     elsif BUS_RX.addr(6 downto 0) = "0110100" then
       BUS_TX.data <= edge_enable & set_output_coin & set_output_mult & set_output_simplecoin;
+    elsif BUS_RX.addr(6 downto 0) = "0110101" and INPUTS >= 32 then
+      BUS_TX.data                 <= multiplicity_enable(63 downto 32);
     else  
       BUS_TX.nack <= '1'; 
       BUS_TX.ack  <= '0';
@@ -242,13 +246,13 @@ got_simplecoin    <= coin_in_1 and coin_in_2 and coin_enable when rising_edge(CL
 
 -- gen_mult : if OUTPUTS >= 2 generate
   PROC_MULT : process 
-    variable m : integer range 0 to INPUTS-1;
-    variable numchan : integer range 0 to 31;
+    variable m : integer range 0 to 32;
+    variable numchan : integer range 0 to 63;
   begin
     wait until rising_edge(CLK);
     numchan := minimum(INPUTS-1,31);
     
-    mult_gated(numchan downto 0) <= inp_verylong(numchan downto 0) and multiplicity_enable(numchan downto 0);
+    mult_gated(INPUTS-1 downto 0) <= inp_verylong(INPUTS-1 downto 0) and multiplicity_enable(INPUTS-1 downto 0);
     
     m := 0;
     for i in 0 to numchan loop  --was INPUTS-1 @ 09.17
@@ -256,13 +260,25 @@ got_simplecoin    <= coin_in_1 and coin_in_2 and coin_enable when rising_edge(CL
         m := m + 1;
       end if;  
     end loop;
-    current_multiplicity <= to_unsigned(m,8);
+    current_multiplicity0 <= to_unsigned(m,8);
+
+    if(INPUTS >= 32) then
+      m := 0;
+      numchan := minimum(INPUTS-1,63);
+      for i in 32 to numchan loop  --was INPUTS-1 @ 09.17
+        if mult_gated(i) = '1' then
+          m := m + 1;
+        end if;  
+      end loop;
+      current_multiplicity1 <= to_unsigned(m,8);    
+    end if;  
     
-    if current_multiplicity >= set_multiplicity and set_multiplicity > 0 then
+    if current_multiplicity0 + current_multiplicity1 >= set_multiplicity and set_multiplicity > 0 then
       multiplicity_trigger <= '1';
     else
       multiplicity_trigger <= '0';
     end if;
+    current_multiplicity <= current_multiplicity0 + current_multiplicity1;
   end process;
 -- end generate;  
 -- gen_no_mult : if OUTPUTS < 2 generate