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

Back to eFEX documentation
fsm_RAW_to_muxPISO.vhd
Go to the documentation of this file.
1 
68 
69 library IEEE;
70 use IEEE.STD_LOGIC_1164.ALL;
71 
72 use IEEE.NUMERIC_STD.ALL;
73 
74 library TOB_rdout_lib;
75 use TOB_rdout_lib.TOB_rdout_ip_pkg.ALL;
76 use TOB_rdout_lib.data_type_pkg.all;
77 
80  Port (
81  RST : in std_logic ;
83  hw_addr : in STD_LOGIC_VECTOR(1 downto 0) ; -- FPGA Hardware Address
85  rdout_RAW_36b_in : in DPR_RAW_out_36_type;
87  valid_RAW_in : in t_49_arr_1b;
89  -- 1b FIFO_RAW_Data_prog_full_i + 0 + 1b Privilege Read + 12b BCN_ID_in + 8b ECID + 24b L1A_ID_in
90  bcn_fifo_47b_in : in STD_LOGIC_VECTOR(46 downto 0);
92  valid_BCN_in : in std_logic ;
94  FIFO_error_flags_54b : in STD_LOGIC_VECTOR(53 downto 0);
96  clk_280M_in : in STD_LOGIC;
98  RAW_FIFO_prog_full_in : in std_logic ;
100  LO_FIFO_prog_full_in : in std_logic ;
102  LO_FIFO_data_count_in : in STD_LOGIC_VECTOR (12 downto 0) ;
104  frame_cntr_en : out STD_LOGIC;
106  raw_rd_all_in : in STD_LOGIC;
108  RAW_rdout_fifo_rd_en_out : OUT t_49_arr_1b;
110  BCN_fifo_rd_en_out : out STD_LOGIC;
112  mgt_enable_in : in STD_LOGIC_VECTOR (48 downto 0) ;
114  BCN_FIFO_empty : in STD_LOGIC;
116  BCN_FIFO_prog_full_in : in STD_LOGIC;
118  link_err_FIFO_empty : in STD_LOGIC;
120  RAW_out_valid : out STD_LOGIC;
122  RAW_out_is_char : out STD_LOGIC;
124  RAW_out : out STD_LOGIC_VECTOR (31 downto 0);
126  RAW_safe_mode_out : out STD_LOGIC;
128  raw_data_mux_fsm : out STD_LOGIC_VECTOR (7 downto 0)
129  );
130 
132 
134 architecture Behavioral of fsm_RAW_to_muxPISO is
135 
136  type FPGA_mapping_array is array(3 downto 0) of std_logic_vector(1 downto 0);
137  constant FPGA_mapping : FPGA_mapping_array := ("10", "01", "11", "00") ; -- HW address to processor number
138  constant LO_almost_full_value : unsigned := X"1FF0" ;
139  signal RAW_out_valid_i : std_logic ;
140  signal RAW_rdout_fifo_rd_en_i : t_49_arr_1b ;
141  signal BCN_fifo_rd_en_out_i : std_logic;
142 
143  signal rec_err_flg_4b_i : STD_LOGIC_VECTOR (3 downto 0) ; -- recovered error flag for mgt link
144  signal rd_on_err_en_i : std_logic ; -- read on error enable
145  signal BCN_in_i : STD_LOGIC_VECTOR (11 downto 0) ;
146  signal valid_BCN_i : STD_LOGIC ;
147  signal L1A_ID_in_i : STD_LOGIC_VECTOR (23 downto 0) ;
148  signal L1A_ID_EXT_in_i : STD_LOGIC_VECTOR (7 downto 0) ;
149 
150 -- signal TTC_read_all_in : STD_LOGIC; -- privilege read
151  signal FIFO_RAW_Data_prog_full_i : STD_LOGIC; -- RAW DATA FIFO is pfull so operate in SAFE MODE
152  signal ORed_err_flg_i : STD_LOGIC; -- OR of all error flag for normal readout
153  signal mgt_disable_i : STD_LOGIC; -- mgt disable flag
154  signal RAW_out_i : STD_LOGIC_VECTOR(31 downto 0) ;
155 
156  signal RAW_out_is_char_i : std_logic ;
157 
158  signal CLK_280M_i : std_logic ;
159  signal RST_i : std_logic ;
160 
161  signal payld_cntr_rst : std_logic ;
162  signal payld_cntr_rst_i : std_logic ;
163  signal payld_cntr_en : std_logic ;
164  signal raw_payld_cntr_i : std_logic_vector(11 downto 0) ;
165 
166  signal frame_cntr_en_i : std_logic ;
167  signal write_in_LO_FIFO_i : std_logic ;
168 
169  signal RAW_in_i : DPR_RAW_out_36_type ; -- array 49 of 36b = err + data;
170  signal RAW_in_tmp : DPR_RAW_out_36_type ; -- array 49 of 36b = err + data;
171  signal RAW_in_valid_i : t_49_arr_1b ; -- 49 valid signals
172  signal RAW_in_valid_tmp : t_49_arr_1b ; -- 49 valid signals
173 
174  signal opt_link_num_i : std_logic_vector(7 downto 0) := "00000000" ;
175  signal fpga_num_i : std_logic_vector(1 downto 0) := "00" ;
176  signal raw_rd_all_in_i : std_logic ;
177  signal safe_mode_i : std_logic ;
178  signal BCN_FIFO_empty_i : std_logic ;
179  signal link_err_FIFO_empty_i : std_logic ;
180  signal BCN_FIFO_prog_full_in_i : std_logic ;
181 
182 -- signal OR_of_error_map_i : std_logic_vector(3 downto 0);
183  signal links_err_4b_in_i : std_logic_vector(3 downto 0); -- OR of all error bits of 49 channels
184  signal channel_error_map_i : STD_LOGIC_VECTOR (48 downto 0); -- 49-bit channel error map to input into RAW readout
185  signal channel_error_rdout_i : STD_LOGIC_VECTOR (48 downto 0); -- 49-bit mgt enable signal for data readout on error
186 
187  TYPE STATE_TYPE IS (
188  idle, wait_1, wait_2, wait_3, wait_4, wait_5, wait_6, wait_7, wait_8,
189  start, pause, hdr_sel, err_sop, err_eop, BCN_wait,
190  norm_sop_1, norm_sop_2, norm_tlr, norm_eop,
191  rd_bcn_fifo, empty_raw_fifo,
192  rdout_raw_1, rdout_raw_2, rdout_raw_3, rdout_raw_4, rdout_raw_5, rdout_raw_6, rdout_raw_7,
193  sub_trl_1, sub_trl_2
194  );
195 
196  SIGNAL current_state : STATE_TYPE;
197  signal i : integer range 0 to 50; -- used to index 49 FIFOs
198  signal ii : integer range 0 to 8; -- used to index 7 raw data words from each FIFO
199 
200 ---- ####### attributes ########
201  attribute keep : string ;
202  attribute max_fanout : integer;
203 
204  attribute keep of RAW_out_valid_i : signal is "true" ;
205  attribute max_fanout of RAW_out_valid_i : signal is 30;
206  attribute keep of rd_on_err_en_i : signal is "true" ;
207  attribute max_fanout of rd_on_err_en_i : signal is 30;
208  attribute keep of RAW_in_i : signal is "true" ;
209  attribute max_fanout of RAW_in_i : signal is 30;
210  attribute keep of RAW_rdout_fifo_rd_en_i : signal is "true" ;
211  attribute max_fanout of RAW_rdout_fifo_rd_en_i : signal is 30;
212  attribute keep of LO_FIFO_prog_full_in : signal is "true" ;
213  attribute max_fanout of LO_FIFO_prog_full_in : signal is 30;
214  attribute keep of RAW_FIFO_prog_full_in : signal is "true" ;
215  attribute max_fanout of RAW_FIFO_prog_full_in : signal is 30;
216  attribute keep of raw_rd_all_in_i : signal is "true" ;
217  attribute max_fanout of raw_rd_all_in_i : signal is 30;
218  attribute keep of safe_mode_i : signal is "true" ;
219  attribute max_fanout of safe_mode_i : signal is 30;
220  attribute keep of i : signal is "true" ;
221  attribute max_fanout of i : signal is 30;
222  attribute keep of ii : signal is "true" ;
223  attribute max_fanout of ii : signal is 30;
224 ---- #######################################
225 
226 begin
227 
228  -- input ports
229  CLK_280M_i <= CLK_280M_in ;
230  RST_i <= RST ;
231 
232  RAW_in_tmp <= rdout_RAW_36b_in; -- assign input data
233  RAW_in_valid_tmp <= valid_RAW_in;
234 
235 
236  -- output ports
237  RAW_rdout_fifo_rd_en_out <= RAW_rdout_fifo_rd_en_i ; -- enable FIFO read out
238  BCN_fifo_rd_en_out <= BCN_fifo_rd_en_out_i ; -- enable BCN LIA FIFO read out
239 
240  payld_cntr_rst <= RST_i OR payld_cntr_rst_i;
241 
242  RAW_safe_mode_out <= safe_mode_i;
243 
244 -- internal signal asssignments
245 
246 
247 -- raw_payld_length counter, counts the total number of payload data inserted between the Header and Trailer of a RAW Event.
248 --
249 U3_raw_payld_length : entity TOB_rdout_lib.cntr_generic
250  generic map(
251  width => 12
252  )
253  Port map (
254  CE => payld_cntr_en , -- count every valid data word (32b words)
255  CLK => CLK_280M_i ,
256  RST => payld_cntr_rst,
257  Q => raw_payld_cntr_i -- count every valid data word (divide by 2 to show no. of 64b words)
258  );
259 
260 -- This process disables writing to Link Output FIFO when the LO_FULL reaches a specific occupancy level of 0X1FF0.
261 --
262 U3A_proc1 : process (CLK_280M_i)
263 begin
264  if rising_edge (CLK_280M_i) then
265  if (unsigned(LO_FIFO_data_count_in) < X"1FF0") then
266  -- if LO_FIFO is nearly FULL then stop reading from de-randomistion FIFO
267  write_in_LO_FIFO_i <= '1';
268  else
269  write_in_LO_FIFO_i <= '0' ;
270  end if;
271  end if;
272  end process;
273 
274 -- This is the state machine that controls, and generates complete RAW Events.
275 -- A completed RAW Event is written to Link Output FIFO.
276 -- It also increments a local counter to indicate to the FSM responsible for reading the events,
277 -- that there are events waiting to be transmitted to Contol FPGA.
278 U4_rd_fsm : process (CLK_280M_i)
279  begin
280  if CLK_280M_i'event and CLK_280M_i = '1' then
281  BCN_FIFO_empty_i <= BCN_FIFO_empty ; -- register to remove timing error
282  link_err_FIFO_empty_i <= link_err_FIFO_empty ; -- register to remove timing error
283  -- pipeline the input from ERROR FIFO
284  ORed_err_flg_i <= FIFO_error_flags_54b(53) ; -- OR of all error flag to request RAW readout
285  links_err_4b_in_i <= FIFO_error_flags_54b(52 downto 49) ; -- 4-bit OR of all channel error map to input into RAW readout
286  channel_error_map_i <= FIFO_error_flags_54b(48 downto 0) ; -- 49-bit channel error map to input into RAW readout
287  channel_error_rdout_i <= FIFO_error_flags_54b(48 downto 0) ; -- 49-bit signal to enable data readout on error
288 -- channel_error_rdout_i <= FIFO_error_flags_54b(48 downto 0) AND mgt_enable_in ; -- 49-bit signal to enable data readout on error
289  BCN_FIFO_prog_full_in_i <= BCN_FIFO_prog_full_in ; -- pipeline to remove timing error
290 
291  -- BCN ID and L1A ID from FIFO
292  -- 1b FIFO_RAW_Data_prog_full_i + 1b ORed_err_flags + 1b Privilege Read + 12b BCN_ID_in + 8b ECID + 24b L1A_ID_in
293  FIFO_RAW_Data_prog_full_i <= bcn_fifo_47b_in(46) ; -- FIFO_RAW_Data_prog_full is set so operate in SAFE MODE
294 -- TTC_read_all_in <= bcn_fifo_47b_in(44) ; -- privilege read
295  BCN_in_i <= bcn_fifo_47b_in(43 downto 32); -- BCN from output of fifo
296  L1A_ID_EXT_in_i <= bcn_fifo_47b_in(31 downto 24) ; -- EXT L1A from output of fifo
297  L1A_ID_in_i <= bcn_fifo_47b_in(23 downto 0) ; -- L1A from output of fifo
298  valid_BCN_i <= valid_BCN_in ;
299  -- Read all fibres under these 2 conditions
300  raw_rd_all_in_i <= raw_rd_all_in OR bcn_fifo_47b_in(44);
301  -- input signals
302  RAW_in_i <= RAW_in_tmp; -- register input data to remove timing error
303  RAW_in_valid_i <= RAW_in_valid_tmp;
304  raw_data_mux_fsm <= x"00";
305  if RST_i = '1' then
306  current_state <= idle ;
307  RAW_out_i <= (others => '0') ;
308  safe_mode_i <= '0' ;
309  else
310  CASE current_state is
311  when idle =>
312  payld_cntr_rst_i <= '0' ;
313  frame_cntr_en_i <= '0' ;
314  RAW_rdout_fifo_rd_en_i <= (others => '0') ;
315  BCN_fifo_rd_en_out_i <= '0' ;
316  payld_cntr_en <= '0' ;
317  RAW_out_valid_i <= '0' ;
318  RAW_out_is_char_i <= '0' ;
319  i <= 0 ;
320  ii <= 0 ;
321  rd_on_err_en_i <= '0' ; -- clear flag
322  rec_err_flg_4b_i <= (others => '0') ; -- clear flag
323  current_state <= idle ;
324  raw_data_mux_fsm <= x"01";
325  if (write_in_LO_FIFO_i = '1' ) then -- if LO_FIFO is not full, less than X"1FF0"
326  if (BCN_FIFO_empty_i = '0') AND (link_err_FIFO_empty_i = '0') then -- if BCN & link error fifos are not empty
327  -- if LO_FIFO is partial FULL AND RAW_FIFO_prog_full NOT set, then pause
328  if (LO_FIFO_prog_full_in = '1' AND RAW_FIFO_prog_full_in = '0') then
329  current_state <= idle ;
330  BCN_fifo_rd_en_out_i <= '0';
331  RAW_out_valid_i <= '0' ;
332  else
333  if (BCN_FIFO_prog_full_in_i = '1') then -- if BCN FIFO is partial FULL, then SAFE MODE
334  safe_mode_i <= '1' ; -- enable safe mode flag
335  RAW_rdout_fifo_rd_en_i <= '1' & X"FFFFFFFFFFFF" ; -- read 1st word from all RAW FIFO
336  BCN_fifo_rd_en_out_i <= '1'; -- read data from BCN fifo
337  RAW_out_valid_i <= '0' ; -- do not save in FIFO
338  current_state <= norm_sop_1 ;
339  else -- else it is normal operation
340  BCN_fifo_rd_en_out_i <= '1' ; -- read data from BCN fifo
341  RAW_out_valid_i <= '0' ; -- do not save in FIFO
342  safe_mode_i <= '0' ; -- disable safe mode flag
343  current_state <= rd_bcn_fifo ;
344  end if;
345  end if;
346  end if;
347  end if;
348 
349  when rd_bcn_fifo => -- wait 1 clk for fifo output
350  RAW_rdout_fifo_rd_en_i <= (others => '0') ; -- stop RAW FIFO read
351  BCN_fifo_rd_en_out_i <= '0' ;
352  RAW_out_valid_i <= '0' ; -- do not save in FIFO
353  current_state <= rd_bcn_fifo ;
354  raw_data_mux_fsm <= x"02";
355  if valid_BCN_i = '1' then -- if BCN FIFO data are valid
356  if (raw_rd_all_in_i = '1' ) then -- if must read all RAW data
357  current_state <= norm_sop_1 ;
358  else
359  if (BCN_FIFO_prog_full_in_i = '1' OR ORed_err_flg_i = '0') then -- if RAW data FIFO is FULL or there are no errors, then empty buffers
360  RAW_rdout_fifo_rd_en_i <= '1' & X"FFFFFFFFFFFF" ; -- read 1st word from all RAW FIFO
361  safe_mode_i <= '1' ; -- enable safe mode flag
362  current_state <= norm_sop_1 ;
363  else
364  current_state <= norm_sop_1 ;
365  end if;
366  end if;
367  end if;
368 
369 -- when BCN_wait => -- wait 1 clk to register L1A_ID and BCN
370 -- current_state <= norm_sop_1 ;
371 -- if (raw_rd_all_in_i = '1' ) then -- if must read all RAW data
372 -- current_state <= norm_sop_1 ;
373 -- else
374 -- if (FIFO_RAW_Data_prog_full_i = '1' OR ORed_err_flg_i = '0') then -- if RAW data FIFO is FULL or there are no errors, then empty buffers
375 -- RAW_rdout_fifo_rd_en_i <= '1' & X"FFFFFFFFFFFF" ; -- read 1st word from all RAW FIFO
376 -- safe_mode_i <= '1' ; -- enable safe mode flag
377 -- end if;
378 -- end if;
379 
380  when norm_sop_1 => -- normal data header SOP 1
381  BCN_fifo_rd_en_out_i <= '0' ;
382  RAW_out_i <= X"000" & BCN_in_i & ch_sop2 ; -- 12b res + 12b BCN + K28.3 (0x7C)
383  RAW_out_is_char_i <= '1';
384  RAW_out_valid_i <= '1' ; -- save in FIFO
385  current_state <= norm_sop_2 ;
386  raw_data_mux_fsm <= x"03";
387  if ( safe_mode_i = '1' ) then -- if in SAFE MODE
388  RAW_rdout_fifo_rd_en_i <= '1' & X"FFFFFFFFFFFF" ; -- read 2nd word from all RAW FIFO
389  else
390  RAW_rdout_fifo_rd_en_i <= (others => '0') ; -- stop RAW FIFO read
391  end if;
392 
393  when norm_sop_2 => -- normal data header SOP 2
394  RAW_out_i <= L1A_ID_EXT_in_i & L1A_ID_in_i ; -- L1A_ID_EXT_in_i & L1A_ID_in_i 8b + 24b
395  RAW_out_is_char_i <= '0';
396  RAW_out_valid_i <= '1' ;
397  raw_data_mux_fsm <= x"04";
398  if ( safe_mode_i = '1' ) then -- if in SAFE MODE or Read on Error mode
399  RAW_rdout_fifo_rd_en_i <= '1' & X"FFFFFFFFFFFF" ; -- read 3rd word from all RAW FIFO
400  current_state <= empty_raw_fifo ; -- else empty de-randomisation fifo
401  else -- if in normal mode operation
402  current_state <= wait_1; -- was rdout_raw_1 ; -- read normal data
403  RAW_rdout_fifo_rd_en_i(i) <= '1' ; -- enable read out from RAW FIFO
404  end if ;
405 
406  when empty_raw_fifo => -- control FPGA not ready, empty RAW FIFO
407  RAW_out_valid_i <= '0' ;
408  raw_data_mux_fsm <= x"05";
409  if (ii = 4) then -- read 4 words from all RAW FIFO, exit
410  RAW_rdout_fifo_rd_en_i <= (others => '0') ;
411  ii <= 0 ;
412  if (ORed_err_flg_i = '0' ) then -- if in NO Read on Error cycle, generate Error Flags Payload only
413  safe_mode_i <= '0' ; -- clear safe mode flag as this is read on error
414  current_state <= sub_trl_1 ;
415  else
416  current_state <= norm_eop ; -- otherwise put out trailer with no payload
417  end if;
418  else
419  RAW_rdout_fifo_rd_en_i <= '1' & X"FFFFFFFFFFFF" ; -- read out from all RAW FIFO
420  current_state <= empty_raw_fifo ;
421  ii <= ii + 1 ;
422  end if;
423 
424  when wait_1 => -- for data to arrive
425  fpga_num_i <= FPGA_mapping(to_integer(unsigned(hw_addr)));
426  opt_link_num_i <= std_logic_vector(to_unsigned(i,8)) ; -- convert the optical link number to 8b word
427  payld_cntr_en <= '0'; -- was RAW_in_valid_i(i); -- count the data into link output fifo
428  RAW_out_valid_i <= '0'; -- was RAW_in_valid_i(i) ; -- on valid save in FIFO
429  current_state <= wait_2 ;
430  raw_data_mux_fsm <= x"06";
431 
432  when wait_2 => -- for data to arrive
433  payld_cntr_en <= '0'; -- was RAW_in_valid_i(i); -- count the data into link output fifo
434  RAW_out_valid_i <= '0'; -- was RAW_in_valid_i(i) ; -- on valid save in FIFO
435  current_state <= wait_3 ;
436 
437  when wait_3 => -- for data to arrive
438  payld_cntr_en <= '0'; -- was RAW_in_valid_i(i); -- count the data into link output fifo
439  RAW_out_valid_i <= '0'; -- was RAW_in_valid_i(i) ; -- on valid save in FIFO
440  current_state <= wait_4 ;
441 
442  when wait_4 => -- for data to arrive
443  RAW_rdout_fifo_rd_en_i(i) <= '1' ; -- enable read out from RAW FIFO
444  -- count the number of VALID data (as below) into link output fifo
445  payld_cntr_en <= (RAW_in_valid_i(i) AND (raw_rd_all_in_i OR channel_error_rdout_i(i) )) ;
446  -- on valid save in FIFO, AND error_en = '1' AND override register to read all RAW DATA
447  RAW_out_valid_i <= (RAW_in_valid_i(i) AND (raw_rd_all_in_i OR channel_error_rdout_i(i) )) ;
448  RAW_out_i <= RAW_in_i(i)(31 downto 0);
449  rd_on_err_en_i <= channel_error_rdout_i(i);
450  mgt_disable_i <= NOT(mgt_enable_in(i)); -- convert mgt_enable into mgt_disable
451  current_state <= rdout_raw_2 ;
452 
453  when rdout_raw_2 => -- normal input RAW rd out 7 clks
454  RAW_out_i <= RAW_in_i(i)(31 downto 0);
455  -- on valid save in FIFO, AND error_en = '1' AND override register to read all RAW DATA
456  RAW_out_valid_i <= ( RAW_in_valid_i(i) AND (raw_rd_all_in_i OR rd_on_err_en_i) );
457  -- count the number of VALID data (as above) into link output fifo
458  payld_cntr_en <= ( RAW_in_valid_i(i) AND (raw_rd_all_in_i OR rd_on_err_en_i) );
459  raw_data_mux_fsm <= x"07";
460  if (ii = 6) then -- 7 RAW data are read out, go to next link
461  ii <= 0 ;
462  current_state <= rdout_raw_3 ;
463  i <= i + 1 ; -- go to next FIFO read
464  RAW_rdout_fifo_rd_en_i(i) <= '0' ; -- end read out from RAW FIFO
465  rec_err_flg_4b_i <= RAW_in_i(i)(35 downto 32) ; -- zero + input_crc + input_disparity + not_in_table
466  else
467  if (ii > 1) then
468  RAW_rdout_fifo_rd_en_i(i) <= '0' ; -- stop read out from RAW FIFO
469  current_state <= rdout_raw_2 ;
470  ii <= ii + 1 ;
471  else
472  ii <= ii + 1 ;
473  RAW_rdout_fifo_rd_en_i(i) <= '1' ; -- enable read out from RAW FIFO
474 
475  end if;
476  end if;
477 
478  when rdout_raw_3 =>
479  -- count the number of VALID data (as above) into link output fifo
480  payld_cntr_en <= (raw_rd_all_in_i OR rd_on_err_en_i) ; -- if link output fifo is not full
481  -- raw data trlr = -- mgt_disable + input_crc + input_disparity + not_in_table + reserved 18b + fpga_num 2b + link_num 8b
482  RAW_out_i <= mgt_disable_i & rec_err_flg_4b_i(2 downto 0) & "00" & X"0000" & fpga_num_i & opt_link_num_i;
483  RAW_out_valid_i <= (raw_rd_all_in_i OR rd_on_err_en_i) ; -- if link output fifo is not full
484  raw_data_mux_fsm <= x"08";
485  if (i = 49) then -- 49 FIFOs are read out, exit
486  i <= 0 ;
487  current_state <= sub_trl_1 ;
488  else
489  current_state <= wait_1 ;
490 -- ii <= ii + 1 ;
491  RAW_rdout_fifo_rd_en_i(i) <= '1' ; -- enable read out from RAW FIFO
492  end if;
493 
494  when sub_trl_1 => -- 1st status trailer
495  payld_cntr_en <= '1' ; -- count 1st status trailer
496  RAW_out_i <= channel_error_map_i(31 downto 0); -- 32b channel error map
497  RAW_out_valid_i <= '1';
498  current_state <= sub_trl_2 ;
499  raw_data_mux_fsm <= x"09";
500 
501  when sub_trl_2 => -- 1st status trailer
502  payld_cntr_en <= '1' ; -- count 2nd status trailer
503  -- read_on_error & crc_err_all + disparity_all + not_in_table_all & & raw_rd_all & 10b & 17b channel error map
504  RAW_out_i <= ORed_err_flg_i & links_err_4b_in_i(2 downto 0) & raw_rd_all_in_i & "0000000000" & channel_error_map_i(48 downto 32);
505  RAW_out_valid_i <= '1';
506  current_state <= wait_5 ;
507 
508  when wait_5 => -- delay for the data counter raw_payld_cntr to update
509  payld_cntr_en <= '0' ; -- stop count
510  RAW_out_valid_i <= '0' ;
511  current_state <= norm_eop ;
512 
513  when norm_eop => -- normal end of packet
514  payld_cntr_rst_i <= '1' ; -- reset the payload counter
515  RAW_out_is_char_i <= '1';
516  RAW_out_i <= safe_mode_i & "000" & X"00" & raw_payld_cntr_i(11 downto 0) & ch_eop ; -- safe_mode + 11b + payld_cntr + 0xDC
517  RAW_out_valid_i <= '1' ;
518  i <= 0 ;
519  current_state <= wait_6 ;
520 
521  when wait_6 => -- delay for the data to write into fifo
522  payld_cntr_rst_i <= '0' ;
523  RAW_out_is_char_i <= '0';
524  RAW_out_valid_i <= '0' ;
525  current_state <= wait_7 ;
526 
527  when wait_7 => -- delay for the data to write into fifo
528  frame_cntr_en_i <= '1' ; -- increase frame counter by 1
529  current_state <= idle ;
530 
531  when others =>
532  NULL;
533  end case;
534  end if;
535  -- register following output signals to remove timing violations
536  RAW_out <= RAW_out_i ; -- data out to link output FIFO
537  RAW_out_valid <= RAW_out_valid_i ; -- data valid to link output FIFO
538  RAW_out_is_char <= RAW_out_is_char_i ; -- data is CHAR
539  frame_cntr_en <= frame_cntr_en_i ; -- complete frame in link output fifo
540  END IF;
541  end process;
542 
543 ------ generate for ILA ------
544 
545 --ila_RAW_error_flags : ila_ipbus_fabric_rd_wr
546 --PORT MAP (
547 -- clk => CLK_280M_i, -- input clock
548 -- probe0(23 downto 0) => L1A_ID_in_i, -- 36b
549 -- probe0(31 downto 24) => L1A_ID_EXT_in_i, -- 36b
550 -- probe1(3 downto 0) => link_err_4b_in_i, -- 36b
551 -- probe1(15 downto 4) => BCN_in_i, -- 36b
552 -- probe1(31 downto 16) => (others => '0'), -- 36b
553 -- probe2(0) => ORed_err_flg_i, -- 1b
554 -- probe3(0) => valid_BCN_i, -- 1b
555 -- probe4 => (others => '0') , -- 1b
556 -- probe5 => channel_error_map_i(31 downto 0), -- 36b
557 -- probe6(16 downto 0) => channel_error_map_i(48 downto 32) , -- 36b
558 -- probe6(31 downto 17) => (others => '0'), -- 1b
559 -- probe7 => (others => '0'), -- 1b
560 -- probe8(0) => TTC_read_all_in , -- 1b
561 -- probe9(0) => FIFO_RAW_Data_prog_full_i -- 1b
562 --);
563 
564 --ila_FIFO_RAW_Data : ila_ipbus_fabric_rd_wr
565 --PORT MAP (
566 -- clk => CLK_280M_i, -- input clock
567 -- probe0 => RAW_in_i(0)(31 downto 0), -- 36b
568 -- probe1(3 downto 0) => RAW_in_i(0)(35 downto 32), -- 36b
569 -- probe1(31 downto 4) => (others => '0'), -- 1b
570 -- probe2(0) => RAW_in_valid_i(0), -- 1b
571 -- probe3(0) => valid_BCN_i, -- 1b
572 -- probe4 => (others => '0') , -- 1b
573 -- probe5 => RAW_in_i(3)(31 downto 0), -- 36b
574 -- probe6(3 downto 0) => RAW_in_i(3)(35 downto 32) , -- 36b
575 -- probe6(31 downto 4) => (others => '0'), -- 1b
576 -- probe7(0) => RAW_in_valid_i(3), -- 1b
577 -- probe8 => (others => '0') , -- 1b
578 -- probe9 => (others => '0') -- 1b
579 --);
580 
581 end Behavioral;
Generic Counter for process FPGA.
in CLK STD_LOGIC
Clock signal input.
in CE STD_LOGIC
Enable signal input.
out Q STD_LOGIC_VECTOR( width- 1 downto 0)
Counter Output signal.
in RST STD_LOGIC
Reset signal input.
FSM to write RAW calolimeter data to Link Output FIFO for process FPGA.
FSM to write RAW calolimeter data to Link Output FIFO for process FPGA.
out raw_data_mux_fsm STD_LOGIC_VECTOR( 7 downto 0)
Monitor state machine status register.
out RAW_rdout_fifo_rd_en_out t_49_arr_1b
read enable signal to all RAW data FIFOs
in raw_rd_all_in STD_LOGIC
readout all raw data links
in bcn_fifo_47b_in STD_LOGIC_VECTOR( 46 downto 0)
BCN fifo data 47b = 1b FIFO_RAW_Data_prog_full_i + 0 + 1b Privilege Read + 12b BCN_ID_in + 32b L1A_ID...
in BCN_FIFO_prog_full_in STD_LOGIC
BCN & L1A FIFO prog full flag.
in FIFO_error_flags_54b STD_LOGIC_VECTOR( 53 downto 0)
Link Error FIFO = ZERO + 1-b request RAW data on error + ORed 3-bit link error + 49-bit channel error...
out BCN_fifo_rd_en_out STD_LOGIC
read enable signal to BCN & L1A FIFOs
in BCN_FIFO_empty STD_LOGIC
FIFO empty flag from BCN L1A FIFO.
out RAW_safe_mode_out STD_LOGIC
Safe Mode operation flag for RAW readout.
in mgt_enable_in STD_LOGIC_VECTOR( 48 downto 0)
MGT enable signals - use to enable readout on error.
in LO_FIFO_data_count_in STD_LOGIC_VECTOR( 12 downto 0)
Link Output FIFO data count.
out RAW_out_valid STD_LOGIC
RAW data valid signal to Link_outpout_FIFO.
in valid_RAW_in t_49_arr_1b
RAW data valid signal.
in RAW_FIFO_prog_full_in std_logic
RAW Input FIFO partial FULL flag.
in link_err_FIFO_empty STD_LOGIC
FIFO empty flag from link error FIFO.
in valid_BCN_in std_logic
RAW data valid signal.
in rdout_RAW_36b_in DPR_RAW_out_36_type
raw data 36b = 4b+32b ERR+RAW
in hw_addr STD_LOGIC_VECTOR( 1 downto 0)
FPGA Hardware Address.
in LO_FIFO_prog_full_in std_logic
Link Output FIFO partial FULL flag to receive RAW calorimeter data.
out RAW_out STD_LOGIC_VECTOR( 31 downto 0)
RAW data 32b to Link_outpout_FIFO.
out RAW_out_is_char STD_LOGIC
RAW data is CHAR signal to Link_outpout_FIFO.
out frame_cntr_en STD_LOGIC
Comp;leted frame counter enable.
in clk_280M_in STD_LOGIC
fabric 280MHz clock