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

Back to eFEX documentation
XTOBs_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.data_type_pkg.all;
31 use TOB_rdout_lib.TOB_rdout_ip_pkg.all;
32 
33 library algolib;
34 use algolib.AlgoDataTypes.all;
35 
36 library Infrastructure_lib;
37 
39 entity XTOBs_sorting is
40  Generic
41  (
43  FPGA_NUMBER : integer := 1
44  ) ;
45  Port (
47  L1A_in : in STD_LOGIC;
49  XTOB_FIFO_sw_rst : in std_logic ;
51  XTOB_512b_in : in AlgoXOutput; -- array 8 x 64b words XTOBs
53  XTOB_Valid_flg_in : in STD_LOGIC_VECTOR (7 downto 0);
55  XTOB_sync_in : in STD_LOGIC;
57  ALGO_XTOB_BCN_in : in std_logic_vector(6 downto 0);
59  pre_ld_wr_addr_XTOB : in STD_LOGIC_VECTOR (8 downto 0);
61  DPR_locations_to_rd : in STD_LOGIC_VECTOR (2 downto 0);
63  trigger_slice_in : in STD_LOGIC_VECTOR(3 downto 0) ;
65  FIFO_rd_en : in STD_LOGIC;
67  clk_200M_in : in STD_LOGIC;
69  clk_280M_in : in STD_LOGIC;
71  XTOB_FIFO_pFULL_THRESH_assert : in STD_LOGIC_VECTOR (8 downto 0);
73  XTOB_FIFO_pFULL_THRESH_negate : in STD_LOGIC_VECTOR (8 downto 0);
75  FIFO_XTOB_data_out : out array_8_of_252b;
77  XTOB_FIFO_rd_data_count : out STD_LOGIC_VECTOR (8 downto 0);
79  XTOB_FIFO_valid : out STD_LOGIC;
81  XTOB_FIFO_full : out STD_LOGIC;
83  XTOB_FIFO_empty : out STD_LOGIC;
85  XTOB_FIFO_prog_full : out STD_LOGIC;
87  xtob_data_dpram_fsm : out STD_LOGIC_VECTOR (7 downto 0)
88  );
89  end XTOBs_sorting;
90 
92 architecture RTL of XTOBs_sorting is
93 
94 --***********************************Parameter Declarations********************
95  constant DLY : time := 0 ns;
96 --************************** Register Declarations ****************************
97 
98  -- XTOB signals
99  signal TOB_valid_out_i : array_8_of_5b; -- TOBs valid (8 * 5b)
100 -- signal SIPO_sync_vec_i : STD_LOGIC_VECTOR (0 downto 0);
101  signal SIPO_TOB_out_i : array_8_of_240b; -- array 8 of XTOBs 5* 48b = 240b
102  signal XTOB_sync_out_i : STD_LOGIC_VECTOR (7 downto 0);
103 
104  signal DPR_XTOBs_in_i : array_8_of_252b; -- array 8 of XTOBs (48b) * 5 + 5b valid + XTOB_BCN (7b)
105  signal DPR_XTOBs_out_i : array_8_of_252b; -- array 8 of XTOBs (48b) * 5 + 5b valid + XTOB_BCN (7b)
106  signal FIFO_XTOB_data_out_i : array_8_of_252b; -- array 8 of XTOBs (48b) * 5 + 5b valid + XTOB_BCN (7b)
107  signal XTOB_FIFO_wr_data_count_i : array_8_of_9b; -- array 8 of XTOBs FIFO count (9b) * 5
108  signal XTOB_FIFO_rd_data_count_i : array_8_of_9b; -- array 8 of XTOBs FIFO count (9b) * 5
109 
110  signal DPR_XTOB_rd_addr_i : STD_LOGIC_VECTOR (8 downto 0);
111  signal DPR_XTOB_wr_addr_i : STD_LOGIC_VECTOR (8 downto 0);
112  signal DRP_XTOB_rd_en_i : STD_LOGIC;
113  signal FIFO_XTOB_wr_en_i : STD_LOGIC;
114  signal FIFO_XTOB_rd_en_i : STD_LOGIC;
115  signal XTOB_FIFO_valid_i : STD_LOGIC_VECTOR (7 downto 0);
116  signal XTOB_FIFO_valid_tmp : STD_LOGIC;
117  signal XTOB_FIFO_full_i : STD_LOGIC_VECTOR (7 downto 0);
118  signal XTOB_FIFO_full_tmp : STD_LOGIC;
119  signal XTOB_FIFO_empty_i : STD_LOGIC_VECTOR (7 downto 0);
120  signal XTOB_FIFO_empty_tmp : STD_LOGIC;
121  signal XTOB_FIFO_prog_full_i : STD_LOGIC_VECTOR (7 downto 0);
122  signal XTOB_FIFO_prog_full_tmp : STD_LOGIC;
123  signal ALGO_XTOB_BCN_out_i : std_logic_vector (6 downto 0); -- sorted XTOB BCN with delay through ALGO/sorting block
124 
125 -- ####### Mark signals ########
126 --attribute mark_debug : string ;
127 -- attribute mark_debug of signal_name : signal is "true" ;
128  attribute TIG : string ;
129  attribute TIG of XTOB_FIFO_rd_data_count_i : signal is "true" ;
130 
131  attribute keep : string ;
132  attribute max_fanout : integer;
133  attribute keep of XTOB_sync_in : signal is "true" ;
134  attribute max_fanout of XTOB_sync_in : signal is 30;
135  attribute keep of XTOB_FIFO_prog_full_i : signal is "true" ;
136  attribute max_fanout of XTOB_FIFO_prog_full_i : signal is 30;
137 
138  attribute keep of XTOB_FIFO_valid_tmp : signal is "true" ;
139  attribute keep of XTOB_FIFO_full_tmp : signal is "true" ;
140  attribute keep of XTOB_FIFO_empty_tmp : signal is "true" ;
141  attribute keep of XTOB_FIFO_prog_full_tmp : signal is "true" ;
142 
143 -- #######################################
144 
145 begin
146 
147  FIFO_XTOB_rd_en_i <= FIFO_rd_en ;
148 
149  -- input signals
150 
151  XTOB_FIFO_rd_data_count <= XTOB_FIFO_rd_data_count_i(0) ; -- generated by 280MHz
152 
153  XTOB_FIFO_full <= XTOB_FIFO_full_tmp ;
154 
155 -- this FSM only control TOB data wr to DPRAM & FIFO
156 -- This state machine is responsible for reading 198-bit data (6 x 32-bit TOBs and 6 valid flags) from Circular DPRAM
157 -- and storing them into de-randomisation FIFO when the L1A signal is received.
158 -- It also controls multi-slice readout between 1 to 5 slices in sequence.
159 U1_TOBs_wr_FSM : entity TOB_rdout_lib.fsm_TOB_wr_to_FIFO
160  PORT map (
161  CLK_IN => clk_200M_in ,
162  TOB_FIFO_sw_rst => XTOB_FIFO_sw_rst, -- RST OR TOB_FIFO_sw_rst
163  L1A_in => L1A_in ,
164  -- this is sync signal which enables WR addr to increase
165  -- can be either TOB_eg_sync_in or TOB_tau_sync_in as they are identical
168  DPR_locations_to_rd => DPR_locations_to_rd , -- number of DRP locations to read 1 to 5
169  trigger_slice_in => trigger_slice_in, -- trigger slice number (on L1A)
170  DPR_rd_addr => DPR_XTOB_rd_addr_i ,
171  DPR_wr_addr => DPR_XTOB_wr_addr_i ,
172  DRP_rd_en => DRP_XTOB_rd_en_i ,
173  FIFO_wr_en => FIFO_XTOB_wr_en_i,
175  );
176 
177 U2_XTOB_BCN_Delay : entity Infrastructure_lib.GeneralDelay
178  generic map (
179  delay => 2, --generates delay of 2 + 1 clocks
180  size => 7)
181  port map (
182  clk => clk_200M_in,
183  data_in => ALGO_XTOB_BCN_in,
184  data_out => ALGO_XTOB_BCN_out_i
185  );
186 
187 
188 -- The GEN_XTOB_RAM loop, generates 8 copies firmware blocks within it,these are:
189 -- SIPO unit - to convert serial data from 5 x 48b words to a 240b parallel word with 5-bit valid flags.
190 -- Dual Port RAM - scrolling memory to store data on every bunch crossing
191 -- This is circular Dual Port RAM. It stores 325-bit words per Bunch number.
192 -- The Read and Write address have the correct offset in order to read the actual XTOB data
193 -- associated with the BCN at the time of arrival of L1A
194 -- Derandomisation FIFO - to store the correct data word upon receiving an L1A
195 -- This is Derandomisation FIFO. It stores 325-bit words per L1A, which are read out of Circular memory.
196 GEN_XTOB_RAM : for i in 0 to 7 GENERATE
197 
198  U2_XTOBs_eg : entity TOB_rdout_lib.SIPO_unit -- convert 5 x array of 48b XTOBs into one 240b words for Circular DPRAMs
199  Port map (
200  -- 48b XTOBs from 1 ALGO block - 5 in series only bits 47:0 have data, rest are ZERO
201  XTOB_in => XTOB_512b_in(i)(47 downto 0),
202  XTOB_valid_in => XTOB_Valid_flg_in(i), -- 1B valid signal - 5 in series
203  XTOB_sync_in => XTOB_sync_in, -- 1b sync in - at start of valid XTOBs
204  clk_in => clk_200M_in,
205  XTOB_sync_out => XTOB_sync_out_i(i), -- 1b sync out - at start of valid XTOBs
206  XTOB_valid_out => TOB_valid_out_i(i) , -- TOBs valid 5b from 1 ALGO block
207  XTOB_out => SIPO_TOB_out_i(i) -- XTOBs 5 * 48b = 240b out
208  );
209 
210 -- XTOBs (5*48b) + 5b valid + 7b XTOB_BCN
211  DPR_XTOBs_in_i(i) <= ALGO_XTOB_BCN_out_i & TOB_valid_out_i(i) & SIPO_TOB_out_i(i) ;
212 -- SIPO_sync_vec_i(0) <= XTOB_sync_out_i ; -- active once every 5 clks
213 
214  U3_XTOB_DRP : DPR_252b_512 -- XTOBs (5*48b) + 5b valid + 7b XTOB_BCN for 1 ALGO block into DPRAM
215  PORT map (
216  clka => clk_200M_in , -- runs at 280M but writes 1 in 7 clks
217  ena => '1' , --
218  wea => stdv(XTOB_sync_out_i(i)) , -- was SIPO_sync_vec_i -- this is wr en using input sync sig
219  addra => DPR_XTOB_wr_addr_i ,
220  dina => DPR_XTOBs_in_i(i) , -- this is XTOBs (5*48b) + 5b valid + 7b XTOB_BCN for 1 algo block
221  clkb => clk_200M_in ,
222  enb => DRP_XTOB_rd_en_i , -- clk/rst/addr en for DPRAM port B
223  addrb => DPR_XTOB_rd_addr_i ,
224  doutb => DPR_XTOBs_out_i(i) -- XTOBs (5*48b) + 5b valid + 7b XTOB_BCN for 1 algo block
225  );
226 
227  U5_XTOBs_FIFO : FIFO_252b_512 -- XXTOBs (5*48b) + 5b valid + 7b XTOB_BCN for 1 algo block into FIFO
228  PORT MAP (
229  rst => XTOB_FIFO_sw_rst, -- RST OR TOB_FIFO_sw_rst
230  wr_clk => clk_200M_in,
231  rd_clk => clk_280M_in,
232  din => DPR_XTOBs_out_i(i) , --this is XTOBs (5*48b) + 5b valid + 7b XTOB_BCN for 1 algo block
233  wr_en => FIFO_XTOB_wr_en_i,
234  rd_en => FIFO_XTOB_rd_en_i,
235  dout => FIFO_XTOB_data_out_i(i) , -- sorted XTOBs output of fifo XTOBs (5*48b) + 5b valid + 7b XTOB_BCN
236  prog_full_thresh_assert => XTOB_FIFO_pFULL_THRESH_assert ,
237  prog_full_thresh_negate => XTOB_FIFO_pFULL_THRESH_negate ,
238  wr_data_count => XTOB_FIFO_wr_data_count_i(i) , -- occupancy of XTOB FIFO, generated by 200MHz
239  rd_data_count => XTOB_FIFO_rd_data_count_i(i) , -- occupancy of XTOB FIFO, generated by 280MHz
240  full => XTOB_FIFO_full_i(i) ,
241  empty => XTOB_FIFO_empty_i(i) ,
242  valid => XTOB_FIFO_valid_i(i) ,
243  prog_full => XTOB_FIFO_prog_full_i(i)
244  );
245 
246  END GENERATE GEN_XTOB_RAM ;
247 
248 
249 --U2_ila_XTOB_BCN_in : ila_ipbus_fabric_rd_wr
250 --PORT MAP (
251 -- clk => clk_200M_in,
252 -- probe0(7 downto 0) => '0' & ALGO_XTOB_BCN_in(6 downto 0), -- 36b
253 -- probe0(15 downto 8) => '0' & ALGO_XTOB_BCN_out_i(6 downto 0) , -- 36b
254 -- probe0(24 downto 16) => DPR_XTOB_wr_addr_i (8 downto 0), -- 36b
255 -- probe0(33 downto 25) => DPR_XTOB_rd_addr_i (8 downto 0) , -- 36b
256 -- probe0(35 downto 34) => (others => '0') , -- 36b
257 -- probe1 => DPR_XTOBs_in_i(0)(181 downto 146), -- 36b
258 -- probe2(0) => XTOB_sync_out_i(0) , -- 1b
259 -- probe3(0) => DRP_XTOB_rd_en_i , -- 1b
260 -- probe4(0) => FIFO_XTOB_wr_en_i , -- 1b
261 -- probe5 => DPR_XTOBs_out_i(0)(181 downto 146), -- 36b
262 -- probe6 => FIFO_XTOB_data_out_i(0)(181 downto 146), -- 36b
263 -- probe7(0) => L1A_in, -- 1b
264 -- probe8(0) => FIFO_XTOB_rd_en_i , -- 1b
265 -- probe9(0) => XTOB_sync_in -- 1b
266 --);
267 
268 -- If Process FPGA 2 & 4, then assign the XTOB FIFO 6
269 -- If Process FPGA 1 & 3, then assign the XTOB FIFO 4
270 U6_gen :
271  if FPGA_NUMBER = 1 generate
272  XTOB_FIFO_valid_tmp <= XTOB_FIFO_valid_i(2) ;
273  XTOB_FIFO_full_tmp <= XTOB_FIFO_full_i(2) ;
274  XTOB_FIFO_empty_tmp <= XTOB_FIFO_empty_i(2) ;
275  XTOB_FIFO_prog_full_tmp <= XTOB_FIFO_prog_full_i(2) ;
276 
277  elsif FPGA_NUMBER = 4 generate
278  XTOB_FIFO_valid_tmp <= XTOB_FIFO_valid_i(3) ;
279  XTOB_FIFO_full_tmp <= XTOB_FIFO_full_i(3) ;
280  XTOB_FIFO_empty_tmp <= XTOB_FIFO_empty_i(3) ;
281  XTOB_FIFO_prog_full_tmp <= XTOB_FIFO_prog_full_i(3) ;
282 
283  elsif FPGA_NUMBER = 3 generate
284  XTOB_FIFO_valid_tmp <= XTOB_FIFO_valid_i(0) ;
285  XTOB_FIFO_full_tmp <= XTOB_FIFO_full_i(0) ;
286  XTOB_FIFO_empty_tmp <= XTOB_FIFO_empty_i(0) ;
287  XTOB_FIFO_prog_full_tmp <= XTOB_FIFO_prog_full_i(0) ;
288 
289  else generate
290  XTOB_FIFO_valid_tmp <= XTOB_FIFO_valid_i(4) ;
291  XTOB_FIFO_full_tmp <= XTOB_FIFO_full_i(4) ;
292  XTOB_FIFO_empty_tmp <= XTOB_FIFO_empty_i(4) ;
293  XTOB_FIFO_prog_full_tmp <= XTOB_FIFO_prog_full_i(4) ;
294  end generate U6_gen;
295 
296 -- register output of FIFO to remove timing violations - use ALGO Block 4 to be middle of FPGA
297 U6_XTOB_clk280_proc : Process (clk_280M_in)
298 begin
299  if rising_edge (clk_280M_in) then
300  FIFO_XTOB_data_out <= FIFO_XTOB_data_out_i ;
301  XTOB_FIFO_valid <= XTOB_FIFO_valid_tmp ;
302  XTOB_FIFO_empty <= XTOB_FIFO_empty_tmp ;
303  XTOB_FIFO_prog_full <= XTOB_FIFO_prog_full_tmp ;
304  end if;
305 end process;
306 
307 end RTL;
External data-types and functions.
( OUTPUT_TOBS- 1 downto 0) AlgoXTriggerObject AlgoXOutput
Algorithm XOUTPUT port.
Shift register for data delay.
XTOB SIPO for process FPGA.
Definition: SIPO_unit.vhd:16
in XTOB_sync_in STD_LOGIC
1b synch signal input
Definition: SIPO_unit.vhd:23
out XTOB_out STD_LOGIC_VECTOR( 239 downto 0)
5 XTOBs (34b) * 5 = 170b
Definition: SIPO_unit.vhd:32
out XTOB_sync_out STD_LOGIC
1b synch signal output
Definition: SIPO_unit.vhd:26
out XTOB_valid_out STD_LOGIC_VECTOR( 4 downto 0)
XTOBs valid signals 5b.
Definition: SIPO_unit.vhd:28
in XTOB_in STD_LOGIC_VECTOR( 47 downto 0)
33b XTOBs from 1 algo block
Definition: SIPO_unit.vhd:19
in XTOB_valid_in STD_LOGIC
1b XTOB valid signal
Definition: SIPO_unit.vhd:21
Top of Sorting XTOBs module for process FPGA.
Top of Sorting XTOBs module for process FPGA.
in XTOB_sync_in STD_LOGIC
XTOB sync signal.
out FIFO_XTOB_data_out array_8_of_252b
XTOBs output of fifo {array 8 of [(5*48b) + 5b valid] + 7b BCN}.
out XTOB_FIFO_empty STD_LOGIC
XTOBs FIFO empty 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
out XTOB_FIFO_prog_full STD_LOGIC
XTOBs FIFO prog full flag.
out XTOB_FIFO_valid STD_LOGIC
XTOBs FIFO data valid signal.
in XTOB_FIFO_pFULL_THRESH_negate STD_LOGIC_VECTOR( 8 downto 0)
Threshold to negate XTOB FIFO prog full flag.
out XTOB_FIFO_rd_data_count STD_LOGIC_VECTOR( 8 downto 0)
occupancy of XTOB derandomisation FIFO - read count
in XTOB_FIFO_sw_rst std_logic
TOB Readout FIFO reset Pulse by software command OR SYS_RST.
in L1A_in STD_LOGIC
L1A signal input.
in XTOB_512b_in AlgoXOutput
array 8 x 64b words XTOBs
in ALGO_XTOB_BCN_in std_logic_vector( 6 downto 0)
sorted XTOB BCN with delay through ALGO/sorting block
in FIFO_rd_en STD_LOGIC
read XTOB data into Shift Registers
in XTOB_FIFO_pFULL_THRESH_assert STD_LOGIC_VECTOR( 8 downto 0)
Threshold to assert XTOB FIFO prog full flag.
in clk_200M_in STD_LOGIC
200Mhz input signal
FPGA_NUMBER integer := 1
Integer used to distinguish different FPGAs having a slightly different firmware.
out XTOB_FIFO_full STD_LOGIC
XTOBs FIFO full flag.
in XTOB_Valid_flg_in STD_LOGIC_VECTOR( 7 downto 0)
8b XTOB has valid data
in pre_ld_wr_addr_XTOB STD_LOGIC_VECTOR( 8 downto 0)
latency pre-load for XTOB DRPAM write address
out xtob_data_dpram_fsm STD_LOGIC_VECTOR( 7 downto 0)
Monitor state machine status register.
in clk_280M_in STD_LOGIC
280Mhz input signal
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.