39 use IEEE.STD_LOGIC_1164.
ALL;
43 use IEEE.NUMERIC_STD.
ALL;
44 use ieee.std_logic_unsigned.
all;
54 pp_clk : in STD_LOGIC;
55 cttc_user_clk : in STD_LOGIC;
56 seq : in STD_LOGIC_VECTOR (1 downto 0);
58 ttc_word_0 : in STD_LOGIC_VECTOR (31 downto 0);
59 ttc_word_1 : in STD_LOGIC_VECTOR (31 downto 0);
60 ttc_word_2 : in STD_LOGIC_VECTOR (31 downto 0);
61 ttc_word_3 : in STD_LOGIC_VECTOR (31 downto 0);
63 L1ID_error : out STD_LOGIC;
64 CTTC_CRC_error : out STD_LOGIC;
65 TTC_CRC_ignore : in std_logic;
66 TTC_fifo_rst : in STD_LOGIC;
67 header_read_en : in STD_LOGIC;
68 header_fifo_valid : out STD_LOGIC;
69 header_fifo_full : out STD_LOGIC;
70 header_fifo_empty : out STD_LOGIC;
71 header_fifo_level : out STD_LOGIC_VECTOR (8 downto 0);
72 master_header : out STD_LOGIC_VECTOR (63 downto 0);
74 bulk_L1ID_error : out STD_LOGIC;
75 bulk_CTTC_CRC_error : out STD_LOGIC;
76 bulk_header_read_en : in STD_LOGIC;
77 bulk_header_fifo_valid : out STD_LOGIC;
78 bulk_header_fifo_full : out STD_LOGIC;
79 bulk_header_fifo_empty : out STD_LOGIC;
80 bulk_header_fifo_level : out STD_LOGIC_VECTOR (8 downto 0);
81 bulk_master_header : out STD_LOGIC_VECTOR (63 downto 0);
83 event_sel : in STD_LOGIC_VECTOR (1 downto 0);
84 rod_slot : in std_logic;
86 ttc_reg : out STD_LOGIC_VECTOR(63 DOWNTO 0);
88 L1A_delay_out : out STD_LOGIC;
89 l1id_mis_stretch : in std_logic;
90 event_count : out STD_LOGIC_VECTOR(31 DOWNTO 0);
91 orbit_count : out STD_LOGIC_VECTOR(15 DOWNTO 0);
92 event_count_reset : in std_logic;
93 orbit_count_reset : in std_logic;
95 flx_backpressure : out STD_LOGIC_VECTOR(11 DOWNTO 0);
96 bcn_adjustment : in STD_LOGIC_VECTOR(11 DOWNTO 0);
98 timeout_threshold : in STD_LOGIC_vector(31 downto 0);
99 l1id_continuity_control : in STD_LOGIC_vector (31 downto 0);
100 l1id_continuity_status : out STD_LOGIC_vector (31 downto 0);
101 l1id_local_miss : out STD_LOGIC_vector (31 downto 0);
102 l1id_ttc_miss : out STD_LOGIC_vector (31 downto 0);
103 l1id_error_count : out STD_LOGIC_vector(31 downto 0);
104 repeat_counter : out STD_LOGIC_vector(31 downto 0)
116 COMPONENT ttc_header_fifo
119 wr_clk :
IN STD_LOGIC;
120 rd_clk :
IN STD_LOGIC;
121 din :
IN STD_LOGIC_VECTOR(
63 DOWNTO 0);
122 wr_en :
IN STD_LOGIC;
123 rd_en :
IN STD_LOGIC;
124 dout :
OUT STD_LOGIC_VECTOR(
63 DOWNTO 0);
125 full :
OUT STD_LOGIC;
126 almost_full :
OUT STD_LOGIC;
127 empty :
OUT STD_LOGIC;
128 underflow :
OUT STD_LOGIC;
129 valid :
OUT STD_LOGIC;
130 rd_data_count :
OUT STD_LOGIC_VECTOR(
8 DOWNTO 0)
136 clock :
in std_logic;
138 crc_start :
in std_logic;
139 d_in :
in std_logic_vector(
31 downto 0);
141 crc_out :
out std_logic_vector(
8 downto 0));
148 clock :
in STD_LOGIC;
149 reset :
in STD_LOGIC;
153 L1id :
in STD_LOGIC_vector(
23 downto 0);
154 ECRid :
in STD_LOGIC_vector(
7 downto 0);
155 timeout_threshold :
in STD_LOGIC_vector(
31 downto 0);
156 l1id_continuity_control :
in STD_LOGIC_vector (
31 downto 0);
157 l1id_continuity_status :
out STD_LOGIC_vector (
31 downto 0);
158 l1id_local_miss :
out STD_LOGIC_vector (
31 downto 0);
159 l1id_ttc_miss :
out STD_LOGIC_vector (
31 downto 0);
160 l1id_error_count :
out STD_LOGIC_vector(
31 downto 0);
161 repeat_counter :
out STD_LOGIC_vector(
31 downto 0)
173 probe0 :
IN STD_LOGIC_VECTOR(
1 DOWNTO 0);
174 probe1 :
IN STD_LOGIC_VECTOR(
0 DOWNTO 0);
175 probe2 :
IN STD_LOGIC_VECTOR(
0 DOWNTO 0);
176 probe3 :
IN STD_LOGIC_VECTOR(
23 DOWNTO 0);
177 probe4 :
IN STD_LOGIC_VECTOR(
11 DOWNTO 0);
178 probe5 :
IN STD_LOGIC_VECTOR(
7 DOWNTO 0);
179 probe6 :
IN STD_LOGIC_VECTOR(
15 DOWNTO 0);
180 probe7 :
IN STD_LOGIC_VECTOR(
31 DOWNTO 0);
181 probe8 :
IN STD_LOGIC_VECTOR(
31 DOWNTO 0);
182 probe9 :
IN STD_LOGIC_VECTOR(
31 DOWNTO 0);
183 probe10 :
IN STD_LOGIC_VECTOR(
31 DOWNTO 0);
185 probe11 :
IN STD_LOGIC_VECTOR(
31 DOWNTO 0);
186 probe12 :
IN STD_LOGIC_VECTOR(
0 DOWNTO 0);
187 probe13:
IN STD_LOGIC_VECTOR(
8 DOWNTO 0);
188 probe14:
IN STD_LOGIC_VECTOR(
8 DOWNTO 0);
189 probe15:
IN STD_LOGIC_VECTOR(
0 DOWNTO 0);
190 probe16:
IN STD_LOGIC_VECTOR(
0 DOWNTO 0)
195 COMPONENT ila_ttc_out
199 probe0 :
IN STD_LOGIC_VECTOR(
1 DOWNTO 0);
200 probe1 :
IN STD_LOGIC_VECTOR(
0 DOWNTO 0);
201 probe2 :
IN STD_LOGIC_VECTOR(
0 DOWNTO 0);
202 probe3 :
IN STD_LOGIC_VECTOR(
0 DOWNTO 0);
203 probe4 :
IN STD_LOGIC_VECTOR(
8 DOWNTO 0);
204 probe5 :
IN STD_LOGIC_VECTOR(
0 DOWNTO 0);
205 probe6 :
IN STD_LOGIC_VECTOR(
63 DOWNTO 0);
206 probe7 :
IN STD_LOGIC_VECTOR(
0 DOWNTO 0)
210 component ila_bulk_ttc
213 probe0 :
IN STD_LOGIC_VECTOR(
1 DOWNTO 0);
214 probe1 :
IN STD_LOGIC_VECTOR(
0 DOWNTO 0);
215 probe2 :
IN STD_LOGIC_VECTOR(
0 DOWNTO 0);
216 probe3 :
IN STD_LOGIC_VECTOR(
0 DOWNTO 0);
217 probe4 :
IN STD_LOGIC_VECTOR(
0 DOWNTO 0);
218 probe5 :
IN STD_LOGIC_VECTOR(
0 DOWNTO 0);
219 probe6 :
IN STD_LOGIC_VECTOR(
0 DOWNTO 0);
220 probe7 :
IN STD_LOGIC_VECTOR(
0 DOWNTO 0);
221 probe8 :
IN STD_LOGIC_VECTOR(
0 DOWNTO 0);
222 probe9 :
IN STD_LOGIC_VECTOR(
0 DOWNTO 0);
223 probe10 :
IN STD_LOGIC_VECTOR(
0 DOWNTO 0);
224 probe11 :
IN STD_LOGIC_VECTOR(
0 DOWNTO 0);
225 probe12 :
IN STD_LOGIC_VECTOR(
8 DOWNTO 0);
226 probe13 :
IN STD_LOGIC_VECTOR(
23 DOWNTO 0)
231 signal version : STD_LOGIC_VECTOR(3 DOWNTO 0);
233 signal L1A_delay : STD_LOGIC;
234 signal L1A_delay_2 : STD_LOGIC;
235 signal BCR : STD_LOGIC;
236 signal BCR_delay : STD_LOGIC;
237 signal ECR : STD_LOGIC;
238 signal trig_type : STD_LOGIC;
240 signal L1ID : STD_LOGIC_VECTOR(23 DOWNTO 0);
241 signal link_reset : STD_LOGIC_VECTOR(3 DOWNTO 0);
242 signal ROD_busy : STD_LOGIC;
243 signal link_enable : STD_LOGIC;
244 signal shelf_num : STD_LOGIC_VECTOR(2 DOWNTO 0);
246 signal crc : STD_LOGIC_VECTOR(8 DOWNTO 0);
247 signal BCN : STD_LOGIC_VECTOR(11 DOWNTO 0);
248 signal BCN_count : STD_LOGIC_VECTOR(11 DOWNTO 0);
249 signal Event_Counter : STD_LOGIC_VECTOR(31 DOWNTO 0);
251 signal Orbit : STD_LOGIC_VECTOR(15 DOWNTO 0);
252 signal header_fifo_wen : STD_LOGIC;
253 signal dset_header_fifo_wen : STD_LOGIC;
254 signal ttc_crc_ok : STD_LOGIC;
255 signal ECR_delay : STD_LOGIC;
256 signal ECRID : STD_LOGIC_VECTOR(7 DOWNTO 0);
257 signal cttc_word : STD_LOGIC_VECTOR(31 DOWNTO 0);
258 signal crc_start : STD_LOGIC;
259 signal crc_gen : STD_LOGIC_VECTOR(8 DOWNTO 0);
260 signal L1ID_32 : STD_LOGIC_VECTOR(31 DOWNTO 0);
262 signal ttc_fifo_valid : STD_LOGIC;
263 signal header_fifo_empty_i : STD_LOGIC;
265 signal master_header_i : STD_LOGIC_VECTOR(63 DOWNTO 0);
266 signal header_fifo_level_i : STD_LOGIC_VECTOR(8 DOWNTO 0);
267 signal header_fifo_full_i : STD_LOGIC;
269 signal bulk_ttc_fifo_valid : STD_LOGIC;
270 signal bulk_header_fifo_empty_i : STD_LOGIC;
272 signal ttc_reg_i : STD_LOGIC_VECTOR(63 DOWNTO 0);
274 signal proposed_crc : STD_LOGIC_VECTOR(8 DOWNTO 0);
275 signal fifo_reset : STD_LOGIC;
276 signal event_en : STD_LOGIC;
278 signal bulk_fifo_count : STD_LOGIC_VECTOR(8 DOWNTO 0);
279 signal bulk_header_fifo_full_i : STD_LOGIC;
280 signal bulk_master_header_i : STD_LOGIC_VECTOR(63 DOWNTO 0);
281 signal bulk_header_fifo_underflow : STD_LOGIC;
282 signal crc_word_0 : STD_LOGIC_VECTOR(31 DOWNTO 0);
283 signal crc_word_3 : STD_LOGIC_VECTOR(31 DOWNTO 0);
285 signal flx_bp_sync_0 : STD_LOGIC_VECTOR(11 DOWNTO 0);
286 signal flx_bp_sync_1 : STD_LOGIC_VECTOR(11 DOWNTO 0);
288 attribute async_reg : string;
289 attribute async_reg of flx_bp_sync_0 : signal is "true";
290 attribute async_reg of flx_bp_sync_1 : signal is "true";
291 attribute dont_touch : string;
292 attribute dont_touch of flx_bp_sync_0 : signal is "true";
293 attribute dont_touch of flx_bp_sync_1 : signal is "true";
298 version(3 downto 0) <= ttc_word_0(11 downto 8);
299 L1A <= ttc_word_0(16);
300 BCR <= ttc_word_0(17);
301 ECR <= ttc_word_0(18);
303 L1ID <= ttc_word_1(23 downto 0);
304 ECRID <= ttc_word_1(31 downto 24);
305 L1ID_32 <= ttc_word_1;
306 link_reset <= ttc_word_3(3 downto 0);
307 ROD_busy <= ttc_word_3(4);
308 link_enable <= ttc_word_3(4);
309 shelf_num <= ttc_word_3(22 downto 20);
310 proposed_crc <= ttc_word_3(31 downto 23);
312 process (cttc_user_clk)
begin
313 if rising_edge (cttc_user_clk) then
320 L1A_delay_2 <= L1A_delay;
326 L1A_delay_out <= L1A_delay_2;
351 process (cttc_user_clk)
begin
352 if rising_edge (cttc_user_clk) then
355 elsif (BCR_delay = '1')and (seq = "01") and (ttc_crc_ok = '1') then
357 elsif (BCN = X"DEB") and (seq = "01") then
359 elsif seq = "01" then
360 BCN_count <= (BCN_count + 1);
362 BCN_count <= BCN_count;
367 BCN <= BCN_count + bcn_adjustment;
374 process (cttc_user_clk, reset, event_count_reset)
begin
375 if ((reset or event_count_reset) = '1') then
376 Event_Counter <= X"00000000";
377 elsif rising_edge (cttc_user_clk) then
380 Event_Counter <= X"FFFFFFFF";
381 elsif (L1A = '1') and (seq = "01") then
382 Event_Counter <= (Event_Counter + 1);
384 Event_Counter <= Event_Counter;
389 event_count <= Event_Counter;
396 process (cttc_user_clk)
begin
397 if rising_edge (cttc_user_clk) then
399 if ((reset or orbit_count_reset) ='1') then
401 elsif BCN = X"DEB" then
402 Orbit <= (Orbit + 1);
408 process (cttc_user_clk)
begin
409 if rising_edge (cttc_user_clk) then
435 process (cttc_user_clk)
begin
436 if rising_edge (cttc_user_clk) then
437 if (reset ='1') or (L1ID_32 = Event_Counter) then
439 elsif (L1ID_32 /= Event_Counter) then
448 ttc_crc_ok <= '1' when ((proposed_crc = crc_gen) and (seq = "01")) else '0';
449 CTTC_CRC_error <= not ttc_crc_ok and not seq(1) and seq(0);
463 header_fifo_wen <= L1A_delay and not seq(1) and seq(0) and event_en and (ttc_crc_ok or TTC_CRC_ignore);
466 dset_header_fifo_wen <= L1A_delay and not seq(1) and seq(0) and (ttc_crc_ok or TTC_CRC_ignore);
471 fifo_reset <= reset or TTC_fifo_rst;
473 ttc_fifo : ttc_header_fifo
477 wr_clk => cttc_user_clk,
479 din
(11 downto 0) => BCN,
480 din
(35 downto 12) => L1ID,
481 din
(43 downto 36) => ECRID,
482 din
(59 downto 44) => orbit,
483 din
(63 downto 60) => x"0",
484 wr_en => header_fifo_wen,
485 rd_en => header_read_en,
486 dout => master_header_i,
487 full => header_fifo_full_i,
489 empty => header_fifo_empty_i,
490 valid => ttc_fifo_valid,
492 rd_data_count => header_fifo_level_i
495 header_fifo_valid <= ttc_fifo_valid and not header_fifo_empty_i;
496 header_fifo_empty <= header_fifo_empty_i;
500 bulk_ttc_fifo : ttc_header_fifo
504 wr_clk => cttc_user_clk,
506 din
(11 downto 0) => BCN,
507 din
(35 downto 12) => L1ID,
508 din
(43 downto 36) => ECRID,
509 din
(59 downto 44) => orbit,
510 din
(63 downto 60) => x"0",
511 wr_en => DSET_header_fifo_wen,
512 rd_en => bulk_header_read_en,
513 dout => bulk_master_header_i,
514 full => bulk_header_fifo_full_i,
515 empty => bulk_header_fifo_empty_i,
516 valid => bulk_ttc_fifo_valid,
517 underflow => bulk_header_fifo_underflow,
518 rd_data_count => bulk_fifo_count
521 bulk_header_fifo_valid <= bulk_ttc_fifo_valid and not bulk_header_fifo_empty_i;
522 bulk_header_fifo_empty <= bulk_header_fifo_empty_i;
523 bulk_header_fifo_full <= bulk_header_fifo_full_i;
524 bulk_master_header <= bulk_master_header_i;
527 ila_bulk_ttc_fifo: ila_bulk_ttc
532 probe2
(0) => DSET_header_fifo_wen,
533 probe3
(0) => bulk_header_read_en,
534 probe4
(0) => L1A_delay,
535 probe5
(0) => event_en,
536 probe6
(0) => ttc_crc_ok,
537 probe7
(0) => TTC_CRC_ignore,
538 probe8
(0) => bulk_header_fifo_full,
539 probe9
(0) => bulk_header_fifo_empty_i,
540 probe10
(0) => bulk_header_fifo_underflow,
541 probe11
(0) => bulk_ttc_fifo_valid,
542 probe12 => bulk_fifo_count,
543 probe13 => bulk_master_header_i
(35 downto 12)
548 process (cttc_user_clk)
begin
549 if rising_edge (cttc_user_clk) then
550 if header_fifo_wen = '1' then
551 ttc_reg_i(11 downto 0) <= BCN;
552 ttc_reg_i(35 downto 12) <= L1ID;
553 ttc_reg_i(43 downto 36) <= ECRID;
559 ttc_reg <= ttc_reg_i;
560 orbit_count <= orbit;
565 clock => cttc_user_clk,
566 crc_start => crc_start,
572 crc_word_0 <= ttc_word_0(31 downto 8) & "00000000";
573 crc_word_3 <= "000000000" & ttc_word_3(22 downto 0);
576 cttc_word <= crc_word_0 when "01",
577 ttc_word_1 when "10",
578 ttc_word_2 when "11",
581 crc_word_3 when "00",
582 (others => '-') when others;
584 crc_start <= (not seq(1)) and seq(0);
586 master_header <= master_header_i;
587 header_fifo_level <= header_fifo_level_i;
588 header_fifo_full <= header_fifo_full_i;
602 process (event_sel(
1), event_sel(
0), rod_slot, L1ID(
0))
603 variable sel_bus : std_logic_vector(2 downto 0);
605 sel_bus := event_sel(1) & event_sel(0) & rod_slot;
608 event_en <= not (L1ID(0));
610 event_en <= (L1ID(0));
614 event_en <= not L1ID(0);
615 when "100" | "101" =>
626 clk => cttc_user_clk,
629 probe2
(0) => header_fifo_wen,
636 probe7 => ttc_word_0,
637 probe8 => ttc_word_1,
638 probe9 => ttc_word_2,
639 probe10 => ttc_word_3,
641 probe11 => cttc_word,
642 probe12
(0) => crc_start,
644 probe14 => proposed_crc,
645 probe15
(0) => ttc_crc_ok,
646 probe16
(0) => CTTC_CRC_error
650 ila_ttc_fifo_out: ila_ttc_out
port map (
654 probe2
(0) => header_read_en,
655 probe3
(0) => header_fifo_full_i,
656 probe4 =>header_fifo_level_i,
657 probe5
(0) =>ttc_fifo_valid,
658 probe6 =>master_header_i,
659 probe7
(0) =>l1id_mis_stretch
667 clock => cttc_user_clk,
674 timeout_threshold => timeout_threshold,
675 l1id_continuity_control => l1id_continuity_control,
676 l1id_continuity_status => l1id_continuity_status,
677 l1id_local_miss => l1id_local_miss,
678 l1id_ttc_miss => l1id_ttc_miss,
680 l1id_error_count => l1id_error_count,
681 repeat_counter => repeat_counter
687 process (pp_clk)
begin
688 if (rising_edge(pp_clk)) then
689 flx_bp_sync_0 <= ttc_word_0(31 downto 20);
690 flx_bp_sync_1 <= flx_bp_sync_0;
694 flx_backpressure <= flx_bp_sync_1;
ila_ttc_in ila_ttc_fifo_inila_ttc_fifo_in