23 use IEEE.STD_LOGIC_1164.
ALL;
24 use IEEE.NUMERIC_STD.
ALL;
25 use IEEE.STD_LOGIC_UNSIGNED.
ALL;
27 use work.ipbus_decode_L1CaloHubRodTTCRegisters.
all;
41 ipb_clk : in std_logic;
42 ipb_rst : in std_logic;
44 ipb_out : out ipb_rbus;
46 pp_clock : in std_logic;
47 clk_125 : in std_logic;
49 ttc_chan_stat : in STD_LOGIC_VECTOR (31 downto 0);
50 ttc_fifo_level : in STD_LOGIC_VECTOR (15 downto 0);
51 L1ID_error : in std_logic;
52 CTTC_CRC_error : in std_logic;
53 cttc_user_clk : in std_logic;
54 seq : in STD_LOGIC_VECTOR(1 DOWNTO 0);
56 ttc_reset : out std_logic;
57 hub_link_reset : out std_logic;
58 ttc_ignore : out std_logic;
59 TTC_CRC_ignore : out std_logic;
60 TTC_fifo_rst : out std_logic;
61 header_sequence : out STD_LOGIC_VECTOR (11 downto 0);
62 header_type : out STD_LOGIC_VECTOR (3 downto 0);
63 det_spec_evnt_sel : out STD_LOGIC_VECTOR (3 downto 0);
64 ttc_reg : in STD_LOGIC_VECTOR(63 DOWNTO 0);
65 event_sel : out STD_LOGIC_VECTOR (2 downto 0);
66 event_count : in STD_LOGIC_VECTOR(31 DOWNTO 0);
67 orbit_count : in STD_LOGIC_VECTOR(15 DOWNTO 0);
68 flx_backpressure : in std_logic_vector(11 downto 0);
69 event_count_reset : out std_logic;
70 orbit_count_reset : out std_logic;
71 bcn_adjustment : out std_logic_vector(11 downto 0);
73 l1id_continuity_control : out std_logic_vector(31 downto 0);
74 l1id_continuity_status : in STD_LOGIC_vector (31 downto 0);
75 l1id_local_miss : in STD_LOGIC_vector (31 downto 0);
76 l1id_ttc_miss : in STD_LOGIC_vector (31 downto 0);
77 l1id_error_count : in STD_LOGIC_vector (31 downto 0);
78 timeout_threshold : out std_logic_vector(31 downto 0);
79 repeat_counter : in STD_LOGIC_vector(31 downto 0)
86 COMPONENT ttc_regs_ila
90 probe0 :
IN STD_LOGIC_VECTOR(
1 DOWNTO 0);
91 probe1 :
IN STD_LOGIC_VECTOR(
0 DOWNTO 0);
92 probe2 :
IN STD_LOGIC_VECTOR(
0 DOWNTO 0);
93 probe3 :
IN STD_LOGIC_VECTOR(
0 DOWNTO 0);
94 probe4 :
IN STD_LOGIC_VECTOR(
15 DOWNTO 0)
99 signal ipbw: ipb_wbus_array(N_SLAVES - 1 downto 0);
100 signal ipbr: ipb_rbus_array(N_SLAVES - 1 downto 0);
102 signal ttc_rst_stb : std_logic;
103 signal ttc_reset_reg : std_logic_vector (31 downto 0);
104 signal ttc_rst_rst : std_logic;
105 signal ccc_rst_stb : std_logic;
106 signal ccc_rst_rst : std_logic;
108 signal ttc_fifo_control : std_logic_vector (31 downto 0);
109 signal TTC_fifo_status : std_logic_vector (31 downto 0);
110 signal TTC_fifo_fill_level : std_logic_vector (31 downto 0);
111 signal TTC_fifo_busy_Count : std_logic_vector (31 downto 0);
112 signal ttc_fifo_busy_threshold : STD_LOGIC_VECTOR (31 downto 0);
113 signal CTTC_link_status : STD_LOGIC_VECTOR (31 downto 0);
115 signal BCN : STD_LOGIC_VECTOR (31 downto 0);
116 signal L1ID : STD_LOGIC_VECTOR (23 downto 0);
117 signal ECRID : STD_LOGIC_VECTOR (7 downto 0);
118 signal rxdisperr : std_logic;
119 signal rxnotintable : std_logic;
120 signal rxresetdone : std_logic;
121 signal cpllfbclklost : std_logic;
122 signal cplllock : std_logic;
123 signal rxfsmresetdone : std_logic;
124 signal cpllrefclklost : std_logic;
125 signal disp_err_count : STD_LOGIC_VECTOR (7 downto 0);
126 signal table_err_count : STD_LOGIC_VECTOR (7 downto 0);
127 signal crc_error_count : STD_LOGIC_VECTOR (7 downto 0);
129 signal ttc_watermark_reset : std_logic;
130 signal ttc_watermark : std_logic_vector (15 downto 0);
131 signal ttc_control : std_logic_vector (31 downto 0);
132 signal pkt_hdr_info : std_logic_vector (31 downto 0);
134 signal run_event_count_reset : std_logic;
135 signal event_count_reset_i : std_logic;
136 signal orbit_count_reset_i : std_logic;
137 signal run_event_count : std_logic_vector (35 downto 0);
138 signal bcn_adjust_i : std_logic_vector(31 downto 0);
139 signal cpll_lock_delay_1 : std_logic;
140 signal cpll_lock_delay_2 : std_logic;
141 signal cpll_lock_lost : std_logic;
145 fabric:
entity work.ipbus_fabric_sel
148 SEL_WIDTH => IPBUS_SEL_WIDTH
)
152 sel => ipbus_sel_L1CaloHubRodTTCRegisters
(ipb_in.ipb_addr
),
153 ipb_to_slaves => ipbw,
154 ipb_from_slaves => ipbr
158 BCN(11 downto 0) <= ttc_reg(11 downto 0);
159 BCN(31 downto 12) <= (others => '0');
160 L1ID <= ttc_reg(35 downto 12);
161 ECRID <= ttc_reg(43 downto 36);
164 cpllrefclklost <= ttc_chan_stat(6);
165 rxdisperr <= ttc_chan_stat(5);
166 rxnotintable <= ttc_chan_stat(4);
167 rxresetdone <= ttc_chan_stat(3);
168 cpllfbclklost <= ttc_chan_stat(2);
169 cplllock <= ttc_chan_stat(1);
170 rxfsmresetdone <= ttc_chan_stat(0);
173 process (clk_125)
begin
174 if rising_edge (clk_125) then
175 cpll_lock_delay_1 <= cplllock;
176 cpll_lock_delay_2 <= cpll_lock_delay_1;
180 process (clk_125)
begin
181 if rising_edge (clk_125) then
182 if (ttc_reset_reg(2) = '1') then
183 cpll_lock_lost <= '0';
184 elsif (cpll_lock_delay_1 = '0') and (cpll_lock_delay_2 = '1') then
185 cpll_lock_lost <= '1';
187 cpll_lock_lost <= cpll_lock_lost;
192 TTC_fifo_control_reg:
entity work.ipbus_reg_v
196 ipbus_in => ipbw
(N_SLV_TTC_fifo_control
),
197 ipbus_out => ipbr
(N_SLV_TTC_fifo_control
),
198 q
(0) => ttc_fifo_control
205 TTC_reset_register:
entity work.ipbus_reg_v
208 reset => ttc_rst_rst,
209 ipbus_in => ipbw
(N_SLV_TTC_reset
),
210 ipbus_out => ipbr
(N_SLV_TTC_reset
),
211 stb
(0) => ttc_rst_stb,
212 q
(0) => ttc_reset_reg
214 ttc_rst_rst <= ttc_rst_stb or ipb_rst;
216 ttc_fifo_rst <= ttc_reset_reg(0);
218 TTC_fifo_status_reg:
entity work.ipbus_syncreg_v
226 ipb_in => ipbw
(N_SLV_TTC_fifo_status
),
227 ipb_out => ipbr
(N_SLV_TTC_fifo_status
),
229 d
(0) => TTC_fifo_status,
230 qmask =>
(others =>
(others => '1'
)),
235 TTC_fifo_status(0) <= '1' WHEN (ttc_fifo_level > x"fff") ELSE '0';
236 TTC_fifo_status(1) <= '1' WHEN (ttc_fifo_level > ttc_fifo_busy_threshold) ELSE '0';
241 TTC_fifo_fill_level_reg :
entity work.ipbus_syncreg_v
249 ipb_in => ipbw
(N_SLV_TTC_fifo_fill_level
),
250 ipb_out => ipbr
(N_SLV_TTC_fifo_fill_level
),
252 d
(0) => TTC_fifo_fill_level,
253 qmask =>
(others =>
(others => '1'
)),
258 TTC_fifo_fill_level(15 downto 0) <= ttc_fifo_level;
259 TTC_fifo_fill_level(31 downto 16) <= ttc_watermark;
261 ttc_fifo_watermark :
entity work.
watermark
263 watermark_width =>
16
267 level => ttc_fifo_level,
268 reset => ttc_watermark_reset,
269 watermark => ttc_watermark
272 ttc_watermark_reset <= (ipb_rst or ttc_reset_reg(1));
279 TTC_fifo_busy_Count_reg :
entity work.ipbus_syncreg_v
287 ipb_in => ipbw
(N_SLV_TTC_fifo_busy_count
),
288 ipb_out => ipbr
(N_SLV_TTC_fifo_busy_count
),
290 d
(0) => TTC_fifo_busy_count,
291 qmask =>
(others =>
(others => '1'
)),
299 reset => ttc_reset_reg
(2),
300 threshold => ttc_fifo_busy_threshold
(15 downto 0),
301 level => ttc_fifo_level,
302 above_count => TTC_fifo_busy_Count
306 felix_backpressure_reg :
entity work.ipbus_syncreg_v
314 ipb_in => ipbw
(N_SLV_FELIX_BACKPRESSURE
),
315 ipb_out => ipbr
(N_SLV_FELIX_BACKPRESSURE
),
317 d
(0) =>
(x"00000" & flx_backpressure
),
318 qmask =>
(others =>
(others => '1'
)),
326 TTC_fifo_busy_threshold_reg:
entity work.ipbus_reg_v
330 ipbus_in => ipbw
(N_SLV_TTC_FIFO_BUSY_THRESHOLD
),
331 ipbus_out => ipbr
(N_SLV_TTC_FIFO_BUSY_THRESHOLD
),
332 q
(0) => TTC_FIFO_BUSY_THRESHOLD
335 L1ID_Value_reg :
entity work.ipbus_syncreg_v
343 ipb_in => ipbw
(N_SLV_TTC_L1ID
),
344 ipb_out => ipbr
(N_SLV_TTC_L1ID
),
345 slv_clk => cttc_user_clk,
346 d
(0) => ttc_reg
(43 downto 12),
347 qmask =>
(others =>
(others => '1'
)),
352 BCN_reg :
entity work.ipbus_syncreg_v
360 ipb_in => ipbw
(N_SLV_TTC_BCN
),
361 ipb_out => ipbr
(N_SLV_TTC_BCN
),
362 slv_clk => cttc_user_clk,
364 qmask =>
(others =>
(others => '1'
)),
369 bcn_adjust_reg :
entity work.ipbus_reg_v
373 ipbus_in => ipbw
(N_SLV_BCN_ADJUST
),
374 ipbus_out => ipbr
(N_SLV_BCN_ADJUST
),
378 BCN_adjustment <= bcn_adjust_i(11 downto 0);
380 CTTC_link_stat_reg :
entity work.ipbus_syncreg_v
388 ipb_in => ipbw
(N_SLV_CTTC_link_stat
),
389 ipb_out => ipbr
(N_SLV_CTTC_link_stat
),
390 slv_clk => cttc_user_clk,
391 d
(0) => CTTC_link_status,
392 qmask =>
(others =>
(others => '1'
)),
398 TTC_control_reg:
entity work.ipbus_reg_v
402 ipbus_in => ipbw
(N_SLV_TTC_control
),
403 ipbus_out => ipbr
(N_SLV_TTC_control
),
407 TTC_ignore <= ttc_control(0);
408 TTC_CRC_ignore <= ttc_control(1);
409 event_sel(2 downto 0) <= ttc_control(6 downto 4);
411 packet_header_info:
entity work.ipbus_reg_v
415 ipbus_in => ipbw
(N_SLV_Packet_Header_Info
),
416 ipbus_out => ipbr
(N_SLV_Packet_Header_Info
),
420 header_sequence <= pkt_hdr_info(15 downto 4);
421 header_type <= pkt_hdr_info(3 downto 0);
422 det_spec_evnt_sel<= pkt_hdr_info(19 downto 16);
429 total_event_count_reg :
entity work.ipbus_syncreg_v
436 rst => run_event_count_reset,
437 ipb_in => ipbw
(N_SLV_total_event_count
),
438 ipb_out => ipbr
(N_SLV_total_event_count
),
439 slv_clk => cttc_user_clk,
440 d
(0) => run_event_count
(31 downto 0),
441 qmask =>
(others =>
(others => '1'
)),
446 total_event_count_msb :
entity work.ipbus_syncreg_v
453 rst => run_event_count_reset,
454 ipb_in => ipbw
(N_SLV_total_event_count_msb
),
455 ipb_out => ipbr
(N_SLV_total_event_count_msb
),
456 slv_clk => cttc_user_clk,
457 d
(0) => x"0000000" & run_event_count
(35 downto 32),
458 qmask =>
(others =>
(others => '1'
)),
463 event_count_reg :
entity work.ipbus_syncreg_v
470 rst => event_count_reset,
471 ipb_in => ipbw
(N_SLV_event_count
),
472 ipb_out => ipbr
(N_SLV_event_count
),
473 slv_clk => cttc_user_clk,
474 d
(0) => event_count
(31 downto 0),
476 qmask =>
(others =>
(others => '1'
)),
485 orbit_reg :
entity work.ipbus_syncreg_v
492 rst => orbit_count_reset,
493 ipb_in => ipbw
(N_SLV_orbit
),
494 ipb_out => ipbr
(N_SLV_orbit
),
495 slv_clk => cttc_user_clk,
496 d
(0) => x"0000" & orbit_count ,
497 qmask =>
(others =>
(others => '1'
)),
503 event_count_reset <= ttc_reset_reg(8) or ipb_rst;
504 run_event_count_reset <= ttc_reset_reg(9) or ipb_rst;
505 orbit_count_reset <= ttc_reset_reg(10) or ipb_rst;
510 process (cttc_user_clk, run_event_count_reset)
begin
511 if (run_event_count_reset = '1') then
512 run_event_count <= X"000000000";
513 elsif rising_edge (cttc_user_clk) then
514 if (L1A = '1') and (seq = "01") then
515 run_event_count <= (run_event_count + 1);
517 run_event_count <= run_event_count;
544 clock => cttc_user_clk,
545 counter_reset => ttc_reset_reg
(2),
546 system_reset => ipb_rst,
548 error_count => disp_err_count
556 clock => cttc_user_clk,
557 counter_reset => ttc_reset_reg
(2),
558 system_reset => ipb_rst,
559 error => rxnotintable,
560 error_count => table_err_count
565 CTTC_link_status <= crc_error_count & disp_err_count & table_err_count & "00" & cpll_lock_lost & cpllrefclklost & cplllock & cpllfbclklost & rxresetdone & rxfsmresetdone;
567 ttc_reset <= ttc_reset_reg(4);
568 hub_link_reset <= ttc_reset_reg(5);
575 clock => cttc_user_clk,
576 counter_reset => ttc_reset_reg
(2),
577 system_reset => ipb_rst,
578 error => CTTC_CRC_error,
579 error_count => crc_error_count
584 L1id_Continuity_Capture_Control:
entity work.ipbus_reg_v
587 reset => ccc_rst_rst,
588 ipbus_in => ipbw
(N_SLV_L1id_Continuity_Capture_Control
),
589 ipbus_out => ipbr
(N_SLV_L1id_Continuity_Capture_Control
),
590 stb
(0) => ccc_rst_stb,
591 q
(0) => l1id_continuity_control
593 ccc_rst_rst <= ccc_rst_stb or ipb_rst;
596 L1id_Capture_Status_reg:
entity work.ipbus_syncreg_v
604 ipb_in => ipbw
(N_SLV_L1ID_CAPTURE_STATUS
),
605 ipb_out => ipbr
(N_SLV_L1ID_CAPTURE_STATUS
),
606 slv_clk => cttc_user_clk,
607 d
(0) => l1id_continuity_status,
608 qmask =>
(others =>
(others => '1'
)),
613 Local_Counter_Miss_reg:
entity work.ipbus_syncreg_v
621 ipb_in => ipbw
(N_SLV_LOCAL_COUNTER_MISS
),
622 ipb_out => ipbr
(N_SLV_LOCAL_COUNTER_MISS
),
623 slv_clk => cttc_user_clk,
624 d
(0) => l1id_local_miss,
625 qmask =>
(others =>
(others => '1'
)),
630 TTC_Miss_reg:
entity work.ipbus_syncreg_v
638 ipb_in => ipbw
(N_SLV_TTC_MISS
),
639 ipb_out => ipbr
(N_SLV_TTC_MISS
),
640 slv_clk => cttc_user_clk,
641 d
(0) => l1id_ttc_miss,
642 qmask =>
(others =>
(others => '1'
)),
647 Mismatch_err_reg:
entity work.ipbus_syncreg_v
655 ipb_in => ipbw
(N_SLV_MISMATCH_ERROR_COUNT
),
656 ipb_out => ipbr
(N_SLV_MISMATCH_ERROR_COUNT
),
657 slv_clk => cttc_user_clk,
658 d
(0) => l1id_error_count,
659 qmask =>
(others =>
(others => '1'
)),
664 Timeout_threshold_reg:
entity work.ipbus_reg_v
668 ipbus_in => ipbw
(N_SLV_TIMEOUT_THRESHOLD
),
669 ipbus_out => ipbr
(N_SLV_TIMEOUT_THRESHOLD
),
670 q
(0) => timeout_threshold
673 Duplicate_L1ID_Count_reg:
entity work.ipbus_syncreg_v
681 ipb_in => ipbw
(N_SLV_DUPLICATE_L1ID_COUNT
),
682 ipb_out => ipbr
(N_SLV_DUPLICATE_L1ID_COUNT
),
683 slv_clk => cttc_user_clk,
684 d
(0) => repeat_counter,
685 qmask =>
(others =>
(others => '1'
)),