]> jspc29.x-matter.uni-frankfurt.de Git - trb3.git/commitdiff
this version builds successfully. Needs to be tested.
authorTobias Weber <toweber86@gmail.com>
Fri, 6 Jul 2018 09:31:36 +0000 (11:31 +0200)
committerTobias Weber <toweber86@gmail.com>
Fri, 6 Jul 2018 09:31:36 +0000 (11:31 +0200)
base/trb3_periph_mupix8.lpf
mupix/Mupix8/sources/DataMuxWithConversion.vhd
mupix/Mupix8/sources/DatasourceSelector.vhd
mupix/Mupix8/sources/FrameGeneratorMux.vhd [moved from mupix/Mupix8/sources/FrameGenMux2.vhd with 98% similarity]
mupix/Mupix8/sources/MuPixDataLink_new.vhd
mupix/Mupix8/sources/MupixBoard.vhd
mupix/Mupix8/trb3_periph.prj

index 82b9d4336f44ad69c22b917ad6f853d17cb2b21b..179ceb0dae1dbc20f868e55adefd0dbee108975a 100644 (file)
@@ -112,7 +112,7 @@ IOBUF GROUP "LED_group" IO_TYPE=LVCMOS25 PULLMODE=NONE DRIVE=12;
 #################################################################
 #MuPix 8
 #################################################################
-LOCATE COMP "MupixBoard8_0/mupix_data_link/the_mupix_serdes/PCSD_INST" SITE "PCSB";
+LOCATE COMP "MupixBoard8_0/mupix_data_link/mupix_serdes_new/PCSD_INST" SITE "PCSB";
 
 LOCATE COMP "led_addon_0" SITE "P1";
 LOCATE COMP "led_addon_1" SITE "P2";
index 80d5a8cb15269196f1a7e319b4c560290de07227..2f5e702a9fb6a1ddef149c9462ce30bac0f1c02d 100644 (file)
@@ -39,7 +39,7 @@ end entity FiFoDataMuxWithConversion;
 architecture RTL of FiFoDataMuxWithConversion is
 
   signal ticks_counter    : unsigned(f_log2(g_clockspeed) - 1 downto 0) := (others => '0');
-  signal inword_counter   : t_counter32_array(0 to g_inputs - 1)          := (others => (others => '0'));
+  signal inword_counter   : t_counter32_array(0 to g_inputs - 1)        := (others => (others => '0'));
   signal increase_counter : std_logic_vector(g_inputs - 1 downto 0)     := (others => '0');
 
   signal fifo_full_i : std_logic;
@@ -63,18 +63,20 @@ architecture RTL of FiFoDataMuxWithConversion is
   end component RoundRobinArbiter;
 
   --data width converter signals
-  constant padding_0       : std_logic_vector(23 downto 0) := (others => '0');
-  constant padding_1       : std_logic_vector(15 downto 0) := (others => '0');
-  constant padding_2       : std_logic_vector(7 downto 0)  := (others => '0');
+  constant padding_0       : std_logic_vector(23 downto 0)                 := (others => '0');
+  constant padding_1       : std_logic_vector(15 downto 0)                 := (others => '0');
+  constant padding_2       : std_logic_vector(7 downto 0)                  := (others => '0');
   type convert_mem_type is array (0 to 1) of std_logic_vector(c_mupixhitsize - 1 downto 0);
-  signal data_shift        : convert_mem_type              := (others => (others => '0'));
-  signal conversioncounter : integer range 0 to 6          := 0;
-  signal empty_delay       : std_logic_vector(1 downto 0)  := (others => '0');
+  signal data_shift        : convert_mem_type                              := (others => (others => '0'));
+  signal data_select       : std_logic_vector(c_mupixhitsize - 1 downto 0) := (others => '0');
+  signal conversioncounter : integer range 0 to 6                          := 0;
+  signal empty_delay       : std_logic_vector(1 downto 0)                  := (others => '0');
 
 begin
 
   request_i <= not fifo_empty and fifo_mask;
 
+  -- arbitration of inputs
   arbiter_1 : component RoundRobinArbiter
     generic map(
       g_num_channels => g_inputs
@@ -84,6 +86,7 @@ begin
       requests => request_i,
       grant    => grant_i);
 
+  -- select fifo by grant from arbiter
   fifo_select_proc : process(grant_i) is
     variable sel : integer range -1 to g_inputs - 1;
   begin
@@ -106,6 +109,7 @@ begin
     fifo_full_i <= full;
   end process full_flag_proc;
 
+  -- measure input words per second of arbiter inputs
   input_freq : process (clk) is
   begin
     if rising_edge(clk) then
@@ -127,7 +131,59 @@ begin
     end if;
   end process input_freq;
 
+  -- purpose: select data from fifo data input (assume max of four inputs)
+  -- type   : combinational
+  data_sel_2 : if g_inputs = 2 generate
+    data_select_proc : process (fifo_datain, fifo_sel_reg) is
+    begin  -- process data_select
+      case fifo_sel_reg is
+        when 0 =>
+          data_select <= fifo_datain(g_datawidthfifo - 1 downto 0);
+        when 1 =>
+          data_select <= fifo_datain(2 * g_datawidthfifo - 1 downto g_datawidthfifo);
+        when others =>
+          data_select <= (others => '0');
+      end case;
+    end process data_select_proc;
+  end generate data_sel_2;
 
+  data_sel_3 : if g_inputs = 3 generate
+    data_select_proc : process (fifo_datain, fifo_sel_reg) is
+    begin  -- process data_select
+      case fifo_sel_reg is
+        when 0 =>
+          data_select <= fifo_datain(g_datawidthfifo - 1 downto 0);
+        when 1 =>
+          data_select <= fifo_datain(2 * g_datawidthfifo - 1 downto g_datawidthfifo);
+        when 2 =>
+          data_select <= fifo_datain(3 * g_datawidthfifo - 1 downto 2 * g_datawidthfifo);
+        when others =>
+          data_select <= (others => '0');
+      end case;
+    end process data_select_proc;
+  end generate data_sel_3;
+
+  data_sel_4 : if g_inputs = 4 generate
+    data_select_proc : process (fifo_datain, fifo_sel_reg) is
+    begin  -- process data_select
+      case fifo_sel_reg is
+        when 0 =>
+          data_select <= fifo_datain(g_datawidthfifo - 1 downto 0);
+        when 1 =>
+          data_select <= fifo_datain(2 * g_datawidthfifo - 1 downto g_datawidthfifo);
+        when 2 =>
+          data_select <= fifo_datain(3 * g_datawidthfifo - 1 downto 2 * g_datawidthfifo);
+        when 3 =>
+          data_select <= fifo_datain(4 * g_datawidthfifo - 1 downto 3 * g_datawidthfifo);
+        when others =>
+          data_select <= (others => '0');
+      end case;
+    end process data_select_proc;
+  end generate data_sel_4;
+
+
+  -- multiplexing of fifo data inputs into output and width conversion from
+  -- mupix hit word width to 32 bit
   mux_proc : process(clk) is
   begin
     if rising_edge(clk) then
@@ -162,7 +218,7 @@ begin
             -- width conversion
             conversioncounter              <= conversioncounter + 1;
             data_shift(1)                  <= data_shift(0);
-            data_shift(0)                  <= fifo_datain((fifo_sel_reg + 1)*g_datawidthfifo - 1 downto g_datawidthfifo*fifo_sel_reg);
+            data_shift(0)                  <= data_select;
             if empty_delay = "11" then
               mux_fsm <= idle;
             end if;
@@ -213,7 +269,6 @@ begin
     end if;
   end process mux_proc;
 
-
   fifo_full_o <= fifo_full_i;
 
 end architecture RTL;
index 7d135103bc555887f4499870629a2fe102bf5f17..d62da28acb000557c037a79e938f9dfc2f9ee196 100644 (file)
@@ -9,7 +9,7 @@ library IEEE;
 use IEEE.STD_LOGIC_1164.ALL;
 use IEEE.NUMERIC_STD.ALL;
 
-entity DataSel is
+entity DataSourceSelector is
     generic(
         constant WIDTH : natural := 32;
         constant DEPTH : natural := 256
@@ -45,9 +45,9 @@ entity DataSel is
         fifo_full : out std_logic_vector(3 downto 0);
         fifo_empty: out std_logic_vector(3 downto 0)
     );
-end DataSel;
+end DataSourceSelector;
 
-architecture Behavioral of DataSel is
+architecture Behavioral of DataSourceSelector is
 
 begin
 
similarity index 98%
rename from mupix/Mupix8/sources/FrameGenMux2.vhd
rename to mupix/Mupix8/sources/FrameGeneratorMux.vhd
index bbbcc4de43f9d92c5ef9478f6459ced708b96134..13e439f2fa06c7ca74c529185585e8a5b9cd8f67 100644 (file)
@@ -1,6 +1,7 @@
 ----------------------------------------------------------------------------------
 -- Pseudo Data Generator and Data Source Selector
--- René Hagdorn, Ruhr-Universität Bochum 
+-- René Hagdorn, Ruhr-Universität Bochum
+-- TODO: Number of channels as generic
 ----------------------------------------------------------------------------------
 
 
@@ -73,7 +74,7 @@ component STD_FIFO
     );
 end component STD_FIFO;
 
-component DataSel is
+component DataSourceSelector is
     generic(
         constant WIDTH : natural
     );
@@ -108,7 +109,7 @@ component DataSel is
         fifo_full : out std_logic_vector(3 downto 0);
         fifo_empty: out std_logic_vector(3 downto 0)
     );
-end component DataSel;
+end component DataSourceSelector;
 
 -- signal types
 type chan_type is array (0 to 3) of std_logic_vector(1 downto 0);
@@ -168,7 +169,7 @@ begin -- Behavioral
         );
     end generate Frame_Generator;
     
-    Mux: DataSel
+    Mux: DataSourceSelector
     generic map(
         WIDTH => DATAWIDTH
     )
index 35d7c04aa1b60ef45a0a8adbe0b0e6869ba98b6f..a180c641946cec6a11b88e74d6c1a3b8fd678198 100644 (file)
@@ -51,7 +51,7 @@ architecture rtl of MupixDataLinkWithUnpacker is
       sync_output : out std_logic_vector(width - 1 downto 0));
   end component InputSynchronizer;
 
-  component serdes_fifo
+  component serdes_fifo -- regenerate if number of mupix hit bits changes
     port (
       Data    : in  std_logic_vector(39 downto 0);
       WrClock : in  std_logic;
@@ -204,12 +204,8 @@ architecture rtl of MupixDataLinkWithUnpacker is
   signal rx_komma_sync     : std_logic_vector(3 downto 0);
 
   -- fifo signals
-  signal fifo_data_oi   : std_logic_vector(c_links*c_mupixhitsize - 1 downto 0);
   signal fifo_data_ii   : std_logic_vector(c_links*c_mupixhitsize - 1 downto 0);
-  signal fifo_empty_i   : std_logic_vector(c_links - 1 downto 0) := (others => '0');
-  signal fifo_full_i    : std_logic_vector(c_links - 1 downto 0) := (others => '0');
   signal fifo_wren_i    : std_logic_vector(c_links - 1 downto 0) := (others => '0');
-  signal fifo_rden_i    : std_logic_vector(c_links - 1 downto 0) := (others => '0');
   constant fifo_depth   : integer                                := 11;  -- fifo depth (change when regenerating FIFO IP core)
   signal fifo_readcnt_i : std_logic_vector(c_links*fifo_depth - 1 downto 0);
 
@@ -398,13 +394,13 @@ begin
         WrClock => clkrx(j),
         RdClock => sysclk,
         WrEn    => fifo_wren_i(j),
-        RdEn    => fifo_rden_i(j),
+        RdEn    => fifo_rden(j),
         Reset   => reset_fifos_i,
         RPReset => reset_fifos_i,
-        Q       => fifo_data_oi((j + 1)*c_mupixhitsize - 1 downto j*c_mupixhitsize),
+        Q       => fifo_data((j + 1)*c_mupixhitsize - 1 downto j*c_mupixhitsize),
         RCNT    => fifo_readcnt_i((j + 1)*fifo_depth - 1 downto j*fifo_depth),
-        Empty   => fifo_empty_i(j),
-        Full    => fifo_full_i(j));
+        Empty   => fifo_empty(j),
+        Full    => fifo_full(j));
   end generate generate_fifo;
 
   -- error counters (using gray counters because of possible clock domain
index 56e78458be4b899d3a808bb2b9b9eae9b00afa88..3de7ed73c659cca1207f51337190a5fd25be4ee4 100644 (file)
@@ -515,7 +515,7 @@ begin  -- Behavioral
 
   mupixreadout1 : entity work.MupixTRBReadout
     generic map(
-      g_mupix_links           => 4,
+      g_mupix_links           => c_links,
       g_cyc_mem_address_width => 12,
       g_datawidthfifo         => c_mupixhitsize,
       g_datawidthtrb          => 32
index 2aff52a6714bd2db5f48aa99335efbab965ae5f2..1b9a39b3b6cd7b98251de4c79988e8781f9ce7ce 100644 (file)
@@ -174,7 +174,7 @@ add_file -vhdl -lib "work" "sources/MuPixDataLink_new.vhd"
 add_file -vhdl -lib "work" "sources/TriggerHandler.vhd"
 add_file -vhdl -lib "work" "sources/Arbiter.vhd"
 add_file -vhdl -lib "work" "sources/DatasourceSelector.vhd"
-add_file -vhdl -lib "work" "sources/FrameGenMux2.vhd"
+add_file -vhdl -lib "work" "sources/FrameGeneratorMux.vhd"
 add_file -vhdl -lib "work" "sources/Generator3.vhd"
 add_file -vhdl -lib "work" "sources/DataMuxWithConversion.vhd"
 add_file -vhdl -lib "work" "sources/GrayCounter2.vhd"