eFEX firmware  1.7.3
ATLAS l1-calo - electron and tau feature extraction firmware for eFEX boards

Back to eFEX documentation
T_TOBs_sorting.vhd
Go to the documentation of this file.
1 
20 
21 
22 library ieee;
23 use ieee.std_logic_1164.all;
24 use ieee.numeric_std.all;
25 
26 library UNISIM;
27 use UNISIM.VCOMPONENTS.ALL;
28 
29 library TOB_rdout_lib;
30 use TOB_rdout_lib.TOB_rdout_ip_pkg.ALL;
31 
33 entity T_TOBs_sorting is
34  Generic
35  (
37  FPGA_NUMBER : integer := 1
38  ) ;
39  Port (
41  L1A_in : in STD_LOGIC;
43  TOB_FIFO_sw_rst : in std_logic ;
45  TOBs_32b_in : in STD_LOGIC_VECTOR (31 downto 0);
47  TOBs_sync_in : in STD_LOGIC;
49  TOBs_valid_flg_in : in STD_LOGIC;
51  ALGO_TOB_BCN_in : in std_logic_vector(6 downto 0);
53  FIFO_rd_en : in STD_LOGIC;
55  clk_280M_in : in STD_LOGIC;
57  pre_ld_wr_addr_TOB : in STD_LOGIC_VECTOR (8 downto 0);
59  DPR_locations_to_rd : in STD_LOGIC_VECTOR (2 downto 0);
61  trigger_slice_in : in STD_LOGIC_VECTOR(3 downto 0) ;
63  TOBs_FIFO_pFULL_THRESH_assert : IN STD_LOGIC_VECTOR(8 DOWNTO 0);
65  TOBs_FIFO_pFULL_THRESH_negate : IN STD_LOGIC_VECTOR(8 DOWNTO 0);
67  rdout_T_TOB_209b : out STD_LOGIC_VECTOR (208 downto 0);
69  TOBs_FIFO_data_count : out STD_LOGIC_VECTOR (8 downto 0) ;
71  TOBs_data_full : out STD_LOGIC;
73  TOBs_data_empty : out STD_LOGIC;
75  TOBs_data_valid : out STD_LOGIC;
77  TOBs_data_prog_full : out STD_LOGIC;
79  tob_data_dpram_fsm : out STD_LOGIC_VECTOR (7 downto 0)
80 
81  );
82  end T_TOBs_sorting;
83 
85 architecture RTL of T_TOBs_sorting is
86 
87 --************************** Register Declarations ****************************
88 
89  signal clk_in_280M_i : STD_LOGIC;
90  -- Sorted TOBs signals
91  signal SIPO_T_TOB_out_i : STD_LOGIC_VECTOR (191 downto 0); -- T_TOBs 32b * 6 = 192
92  signal SIPO_T_TOB_sync_out_i : STD_LOGIC;
93  signal T_TOB_valid_out_i : STD_LOGIC_VECTOR (5 downto 0); -- T TOBs valid 6b (ignore 7th TOB)
94 
95  signal DPR_T_TOBs_in_i : STD_LOGIC_VECTOR (208 downto 0); -- 209b = 7b TOB_BCN +4b error+6b valid +192b data
96  signal DPR_T_TOBs_out_i : STD_LOGIC_VECTOR (208 downto 0); -- 209b = 7b TOB_BCN +4b error+6b valid +192b data
97  signal rdout_T_TOB_209b_i : STD_LOGIC_VECTOR (208 downto 0); -- 209b = 7b TOB_BCN +4b error+6b valid +192b data
98 
99  signal DPR_T_TOB_rd_addr_i : STD_LOGIC_VECTOR (8 downto 0);
100  signal DPR_T_TOB_wr_addr_i : STD_LOGIC_VECTOR (8 downto 0);
101  signal DRP_T_TOB_rd_en_i : std_logic ;
102 
103  signal SIPO_T_TOB_sync_vec_i : STD_LOGIC_VECTOR (0 downto 0);
104  signal FIFO_wr_en_i, L1A_in_i : std_logic;
105  signal FIFO_wr_en_tmp : std_logic ;
106 
107  signal ALGO_TOB_BCN_out_i : std_logic_vector (6 downto 0); -- sorted TOB BCN with delay through ALGO/sorting block
108  signal TOBs_FIFO_data_count_i :STD_LOGIC_VECTOR (8 downto 0) ;
109  signal tied_to_vcc_i : std_logic;
110  signal TOBs_data_valid_i : std_logic;
111  signal TOBs_data_prog_full_i, TOBs_data_full_i, TOBs_data_empty_i : std_logic;
112 
113 begin
114 
115  tied_to_vcc_i <= '1';
116 
117  clk_in_280M_i <= clk_280M_in ;
118 
119 -- output signals:
120  FIFO_wr_en_tmp <= FIFO_wr_en_i ;
121  L1A_in_i <= L1A_in ;
122 
123 -- register output of FIFO to remove timing violations - use ALGO Block 4 to be middle of FPGA
124 U6_TOB_clk280_proc : Process (clk_in_280M_i)
125 begin
126  if rising_edge (clk_in_280M_i) then
127  rdout_T_TOB_209b <= rdout_T_TOB_209b_i ;
128  TOBs_FIFO_data_count <= TOBs_FIFO_data_count_i ;
129  TOBs_data_full <= TOBs_data_full_i;
130  TOBs_data_empty <= TOBs_data_empty_i;
131  TOBs_data_valid <= TOBs_data_valid_i;
132  TOBs_data_prog_full <= TOBs_data_prog_full_i;
133  end if;
134 end process;
135 
136 -- SIPO for Sorted TOBs module is responsible for generating a parallel word,
137 -- consisting of 6 x 32-bit TOBs and 6 valid flags.
138 --
139 U1_TOBs_eg : entity TOB_rdout_lib.SIPO_TOPO_TOBs_unit -- convert 6*32b Topo TOBs into one 192b word for Circular DPR
140  Port map (
141  clk_in_280M => clk_in_280M_i,
142  TOBs_in => TOBs_32b_in, -- 32b TOPO TOB
145  ALGO_TOB_BCN_in => ALGO_TOB_BCN_in, -- input from top
146  TOPO_TOB_out => SIPO_T_TOB_out_i, -- 6 * 32b TOPO TOBs
147  TOPO_TOB_sync_out => SIPO_T_TOB_sync_out_i, -- plus Sync signal
148  TOPO_TOB_valid_out => T_TOB_valid_out_i, -- plus Valid signal
149  ALGO_TOB_BCN_out => ALGO_TOB_BCN_out_i
150  );
151 
152  -- L1A needs to be delayed by 1 clk so correct value is store just prior to another L1A increments the counter
153  -- 209b = 7b TOB_BCN + 0000 +6b valid +192b data
154  DPR_T_TOBs_in_i <= ALGO_TOB_BCN_out_i & "0000" & T_TOB_valid_out_i & SIPO_T_TOB_out_i;
155  SIPO_T_TOB_sync_vec_i(0) <= SIPO_T_TOB_sync_out_i ; -- active once every 7 clks
156 
157 -- This state machine is responsible for reading 6 x 32-bit TOBs and 6 valid flags from Circular DPRAM,
158 -- and storing them into de-randomisation FIFO for the TOBs..
159 
160 U3_TOBs_wr_FSM : entity TOB_rdout_lib.fsm_TOB_wr_to_FIFO
161  PORT map (
162  CLK_IN => clk_in_280M_i ,
163  TOB_FIFO_sw_rst => TOB_FIFO_sw_rst, -- RST OR TOB_FIFO_sw_rst
164  L1A_in => L1A_in_i ,
165  -- this is sync signal which enables WR addr to increase
166  -- can be either TOB_eg_sync_in or TOB_tau_sync_in as they are identical
169  DPR_locations_to_rd => DPR_locations_to_rd , -- number of DRP locations to read 1 to 5
171  DPR_rd_addr => DPR_T_TOB_rd_addr_i ,
172  DPR_wr_addr => DPR_T_TOB_wr_addr_i ,
173  DRP_rd_en => DRP_T_TOB_rd_en_i ,
174  FIFO_wr_en => FIFO_wr_en_i,
176  );
177 
178 -- This is Circular DPRAM for 192-bit sorted TOBs, 6-bit valid flags and 12-bit BCN
179 -- only 6 TOBs are written, 7th is ignored.
180 -- Each location of DPRAM stores all the TOBs for for one BCN.
181 
182 U4_T_TOB_DRP : DPR_209b_512 -- Topo TOBs into DPRAM
183  PORT map (
184  clka => clk_in_280M_i, -- runs at 280M but writes 1 in 7 clks
185  ena => tied_to_vcc_i ,
186  wea => SIPO_T_TOB_sync_vec_i , -- this is wr en using input sync sig
187  addra => DPR_T_TOB_wr_addr_i ,
188  dina => DPR_T_TOBs_in_i , -- this is TOBs together 209b = 7b+4b+6b+192b TOB_BCN+ERR+valid+T_TOB
189  clkb => clk_in_280M_i ,
190  enb => DRP_T_TOB_rd_en_i , -- clk/rst/addr en for DPRAM port B
191  addrb => DPR_T_TOB_rd_addr_i ,
192  doutb => DPR_T_TOBs_out_i -- TOB out 209b = 7b+4b+6b+192b TOB_BCN+ERR+valid+T_TOB
193  );
194 
195 --U5_ila_T_TOBs_fifo : ila_ipbus_fabric_rd_wr
196 --PORT MAP (
197 -- clk => clk_in_280M_i,
198 -- probe0(8 downto 0) => DPR_T_TOB_wr_addr_i, -- 36b
199 -- probe0(15 downto 9) => (others => '0') , -- 36b
200 -- probe0(24 downto 16) => DPR_T_TOB_rd_addr_i, -- 36b
201 -- probe0(35 downto 25) => (others => '0') , -- 36b
202 -- probe1 => DPR_T_TOBs_in_i(208 downto 173), -- 36b
203 -- probe2(0) => DRP_T_TOB_rd_en_i , -- 1b
204 -- probe3(0) => SIPO_T_TOB_sync_out_i, -- 1b
205 -- probe4(0) => L1A_in_i , -- 1b
206 -- probe5 => DPR_T_TOBs_out_i(208 downto 173), -- 36b
207 -- probe6 => DPR_T_TOBs_out_i(35 downto 0), -- 36b
208 -- probe7(0) => FIFO_rd_en, -- 1b
209 -- probe8(0) => FIFO_wr_en_tmp , -- 1b
210 -- probe9(0) => FIFO_wr_en_i -- 1b
211 --);
212 
213 
214 -- This is de-randomistion FIFO for 192-bit sorted TOBs, 4-bit errors, 6-bit valid flags and 7-bit BCN.
215 -- When an L1A arrives, the data associated with correct BCN is transferred from Circular DPRAM into de-randomistion FIFO.
216 --
217 U5_T_TOBs_fifo : FIFO_209b_512 -- Topo TOBs into FIFO on L1A
218  PORT MAP (
219  clk => clk_in_280M_i,
220  srst => TOB_FIFO_sw_rst, -- RST OR TOB_FIFO_sw_rst
221  din => DPR_T_TOBs_out_i , -- TOB out 209b = 7b+4b+6b+192b TOB_BCN+ERR+valid+T_TOB
222  wr_en => FIFO_wr_en_tmp, -- stop wrtie if prog FULL is set
223  rd_en => FIFO_rd_en,
224  dout => rdout_T_TOB_209b_i , -- TOB out 209b = 7b+4b+6b+192b TOB_BCN+ERR+valid+T_TOB
225  data_count => TOBs_FIFO_data_count_i, -- TOBs FIFO occupancy count
226  full => TOBs_data_full_i,
227  empty => TOBs_data_empty_i,
228  valid => TOBs_data_valid_i,
229  prog_full => TOBs_data_prog_full_i,
230  prog_full_thresh_assert => TOBs_FIFO_pFULL_THRESH_assert,
231  prog_full_thresh_negate => TOBs_FIFO_pFULL_THRESH_negate
232  );
233 
234 end RTL;
SIPO Sorting TOBs for process FPGA.
in TOBs_sync_in STD_LOGIC
TOB synch signal - indicating the start of the 7 TOB data words.
in TOBs_in STD_LOGIC_VECTOR( 31 downto 0)
32b sorted TOB in - 7 x 32b words in series
out ALGO_TOB_BCN_out std_logic_vector( 6 downto 0)
sorted TOB BCN with delay to match the delay on the TOBs through this block
out TOPO_TOB_valid_out STD_LOGIC_VECTOR( 5 downto 0)
6b sorted TOBs valid (ignore 7th TOB)
out TOPO_TOB_out STD_LOGIC_VECTOR( 191 downto 0)
6 * 32b sorted TOBs = 192b (ignore 7th TOB)
out TOPO_TOB_sync_out STD_LOGIC
1b sorted TOBs synch signal output
in TOB_valid_flg_in STD_LOGIC
1b valid signal - 7 x 1b valid in series
in clk_in_280M STD_LOGIC
280Mhz input signal
in ALGO_TOB_BCN_in std_logic_vector( 6 downto 0)
sorted TOB BCN with delay through ALGO/sorting block
Top of Sorting_TOBs module for process FPGA.
Top of Sorting_TOBs module for process FPGA.
in TOBs_sync_in STD_LOGIC
Sorted TOB synch signal - indicating the start of the 7 TOB data words.
in pre_ld_wr_addr_TOB STD_LOGIC_VECTOR( 8 downto 0)
Latency pre-load for TOB Circular DRPAM write address.
out TOBs_data_prog_full STD_LOGIC
Sorted TOBs FIFO prog full flag.
in trigger_slice_in STD_LOGIC_VECTOR( 3 downto 0)
Trigger slice number - on L1A.
in DPR_locations_to_rd STD_LOGIC_VECTOR( 2 downto 0)
Number of multi-slice locations to read from DPRAM.
in TOBs_32b_in STD_LOGIC_VECTOR( 31 downto 0)
Sorted TOBs 32b * 7 in series.
in TOBs_valid_flg_in STD_LOGIC
Sorted TOB valid signal - used to write TOBs into de-randomisation TOB FIFO.
in L1A_in STD_LOGIC
L1A signal input.
out rdout_T_TOB_209b STD_LOGIC_VECTOR( 208 downto 0)
Sorted TOBs output of fifo 209b = 7b TOB_BCN +4b error+6b valid +192b TOB data.
out TOBs_data_valid STD_LOGIC
Sorted TOBs FIFO data valid signal.
in FIFO_rd_en STD_LOGIC
Read sorted TOB data from de-randomisation TOB FIFO into TOB Link Output FIFO.
out TOBs_FIFO_data_count STD_LOGIC_VECTOR( 8 downto 0)
Sorted TOBs FIFO occupancy count.
FPGA_NUMBER integer := 1
Integer used to distinguish different FPGAs having a slightly different firmware.
out TOBs_data_full STD_LOGIC
Sorted TOBs FIFO full flag.
in TOB_FIFO_sw_rst std_logic
TOB Readout FIFO reset Pulsed by software command.
out tob_data_dpram_fsm STD_LOGIC_VECTOR( 7 downto 0)
Monitor state machine status register.
out TOBs_data_empty STD_LOGIC
Sorted TOBs FIFO empty flag.
in clk_280M_in STD_LOGIC
280Mhz input signal
in ALGO_TOB_BCN_in std_logic_vector( 6 downto 0)
Sorted TOB BCN with delay through ALGO/sorting block.
in TOBs_FIFO_pFULL_THRESH_negate STD_LOGIC_VECTOR( 8 DOWNTO 0)
Threshold to de-assert FIFO prog full flag.
in TOBs_FIFO_pFULL_THRESH_assert STD_LOGIC_VECTOR( 8 DOWNTO 0)
Threshold to assert FIFO prog full flag.
Top of fsm_TOB_wr_to_FIFO for process FPGA.
in trigger_slice_in STD_LOGIC_VECTOR( 3 downto 0)
Trigger slice number - on L1A.
in SIPO_sync_in STD_LOGIC
SIPO TOBs synch signal input.
in DPR_locations_to_rd STD_LOGIC_VECTOR( 2 downto 0)
number of multi-slice locations to read from DPRAM
out DPR_rd_addr STD_LOGIC_VECTOR( 8 downto 0)
DPRAM read address.
out DRP_rd_en STD_LOGIC
DPRAM read enable.
in pre_ld_wr_addr STD_LOGIC_VECTOR( 8 downto 0)
latency pre-load for DRPAM write address
out FIFO_wr_en STD_LOGIC
enable sorted TOBs write into derandomisatiion FIFO
in L1A_in STD_LOGIC
L1A signal input.
in CLK_IN STD_LOGIC
Clock input signal.
in TOB_FIFO_sw_rst std_logic
TOB Readout FIFO reset Pulse by software command.
out tob_data_dpram_fsm STD_LOGIC_VECTOR( 7 downto 0)
Monitor state machine status register.
out DPR_wr_addr STD_LOGIC_VECTOR( 8 downto 0)
DPRAM write address.