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_L1CaloHubRodTobProc.
all;
40 timeout_1_default : std_logic_vector(15 downto 0) := x"0600";
41 timeout_n_default : std_logic_vector(15 downto 0) := x"0030";
42 wdog_thresh_default : std_logic_vector(15 downto 0) := x"2000"
45 ipb_clk : in std_logic;
46 ipb_rst : in std_logic;
48 ipb_out : out ipb_rbus;
50 pp_clock : in std_logic;
51 rt_clk : in std_logic;
53 event_fifo_level : in STD_LOGIC_VECTOR (15 downto 0);
54 debug_fifo_level : in STD_LOGIC_VECTOR (15 downto 0);
55 stage_fifo_level : in std_logic_vector (15 downto 0);
57 first_chan : in STD_LOGIC_vector (4 downto 0);
58 current_state : in STD_LOGIC_VECTOR (7 downto 0);
59 header_mark : in std_logic;
60 header_fifo_valid : in std_logic;
61 hdr_crc_error : in std_logic;
62 ttc_crc_error : in std_logic;
63 crc20_err : in STD_LOGIC;
64 crc9_err : in STD_LOGIC;
65 BCID_mismatch : in STD_LOGIC;
66 L1ID_mismatch : in STD_LOGIC;
67 timeout_err : in STD_LOGIC;
68 crc20_err_chan : in STD_LOGIC_VECTOR (4 downto 0);
71 full_mode_ctrl : out STD_LOGIC_VECTOR (31 downto 0);
72 full_mode_stat : in STD_LOGIC_VECTOR (31 downto 0);
73 FM_L1id_stat : in std_logic_vector (31 downto 0);
74 m_tdata : in STD_LOGIC_VECTOR (63 downto 0);
75 m_tvalid : in std_logic;
76 m_tlast : in std_logic;
77 m_header_marker : in std_logic;
79 L1ID_ttc_32_reg : in STD_LOGIC_VECTOR (31 downto 0);
81 s_tdata : in STD_LOGIC_VECTOR (63 downto 0);
82 s_tvalid : in std_logic;
83 s_tlast : in std_logic;
84 s_header_mark : in std_logic;
85 poll_chan : in std_logic;
87 stage_fifo_busy : out STD_LOGIC;
88 stage_fifo_xoff : out STD_LOGIC;
89 stage_fifo_full : in STD_LOGIC;
90 timeout_1_val : out STD_LOGIC_VECTOR (15 downto 0);
91 timeout_n_val : out STD_LOGIC_VECTOR (15 downto 0);
93 wdog_overflow : in STD_LOGIC;
94 wdog_threshold : out STD_LOGIC_VECTOR (15 downto 0);
95 wdog_disable : out STD_LOGIC;
96 wdog_fifo_reset : out STD_LOGIC;
97 l1id_resync_enable: out STD_LOGIC;
99 tob_timeout_1_disable : out STD_LOGIC;
100 tob_timeout_n_disable : out STD_LOGIC;
102 dbg_pkt_count : in STD_LOGIC_VECTOR (31 downto 0);
103 dbg_pkt_count_reset : out STD_LOGIC;
104 flx_backpressure : in STD_LOGIC_vector(11 downto 0);
105 flx_backpressure_bit : out STD_LOGIC;
106 stop_proc : out STD_LOGIC;
108 l1id_max_l1id : in std_logic_VECTOR (31 downto 0);
109 l1id_measure_max : in std_logic_VECTOR (31 downto 0);
110 l1id_measure_last : in std_logic_VECTOR (31 downto 0);
111 clr_pkt_wait_timer : out STD_LOGIC;
112 timeout_counter_max : in std_logic_VECTOR (15 downto 0);
113 max_chan : in std_logic_VECTOR (4 downto 0);
114 clr_max_timeout : out STD_LOGIC;
117 last_chan : in STD_LOGIC_vector (4 downto 0);
118 nxt_chan_0 : in STD_LOGIC;
119 chan_pointer_reset : in STD_LOGIC
133 ipb_clk :
in std_logic;
134 ipb_rst :
in std_logic;
135 ipb_in :
in ipb_wbus;
136 ipb_out :
out ipb_rbus;
137 pp_clock :
in std_logic;
139 full_mode_stat :
in STD_LOGIC_VECTOR (
31 downto 0);
140 m_tdata :
in STD_LOGIC_VECTOR (
63 downto 0);
141 m_tvalid :
in std_logic;
142 m_tlast :
in std_logic;
143 m_header_marker :
in std_logic
153 ipb_clk :
in std_logic;
154 ipb_rst :
in std_logic;
155 ipb_in :
in ipb_wbus;
156 ipb_out :
out ipb_rbus;
157 pp_clock :
in STD_LOGIC;
158 reset :
in STD_LOGIC;
159 s_tvalid :
in STD_LOGIC;
160 s_tlast :
in STD_LOGIC;
161 idle_state :
in STD_LOGIC;
162 l1id_ttc :
in STD_LOGIC_VECTOR(
31 downto 0);
163 l1id_pkt :
in STD_LOGIC_VECTOR(
31 downto 0);
164 current_chan :
in STD_LOGIC_VECTOR(
7 downto 0);
165 first_chan :
in STD_LOGIC_vector (
4 downto 0);
166 poll_chan :
in STD_LOGIC
178 ipb_clk :
in std_logic;
179 ipb_rst :
in std_logic;
180 ipb_in :
in ipb_wbus;
181 ipb_out :
out ipb_rbus;
182 pp_clock :
in std_logic;
183 current_chan :
in STD_LOGIC_VECTOR (
4 downto 0);
184 s_tdata :
in STD_LOGIC_VECTOR (
63 downto 0);
185 s_tvalid :
in std_logic;
186 s_tlast :
in std_logic;
187 s_header_mark :
in std_logic;
188 poll_chan :
in std_logic;
189 timeout_err :
in std_logic
197 ADDR_WIDTH:
positive :=
8;
198 DATA_WIDTH:
positive :=
32
201 ipb_clk :
in std_logic;
202 ipb_rst :
in std_logic;
203 ipb_in :
in ipb_wbus;
204 ipb_out :
out ipb_rbus;
206 pp_clock :
in STD_LOGIC;
207 reset :
in STD_LOGIC;
208 trace_input :
in STD_LOGIC_VECTOR (
23 downto 0);
209 state :
in STD_LOGIC_VECTOR (
7 downto 0);
210 wd_event :
in STD_LOGIC;
211 timeout_error :
in STD_LOGIC
219 cwidth:
positive :=
4
222 clock :
in STD_LOGIC;
223 counter_reset :
in STD_LOGIC;
224 system_reset :
in STD_LOGIC;
225 error :
in STD_LOGIC;
226 error_count :
out STD_LOGIC_VECTOR(cwidth
-1 downto 0)
236 clock :
in std_logic;
237 reset_0 :
in std_logic;
238 reset_1 :
in std_logic;
239 reset_2 :
in std_logic;
240 reset_3 :
in std_logic;
241 reset_4 :
in std_logic;
242 error_0 :
in std_logic;
243 error_1 :
in std_logic;
244 error_2 :
in std_logic;
245 error_3 :
in std_logic;
246 error_4 :
in std_logic;
247 sample_0 :
in std_logic;
248 sample_1 :
in std_logic;
249 sample_2 :
in std_logic;
250 sample_3 :
in std_logic;
251 sample_4 :
in std_logic;
252 chan_in :
in STD_LOGIC_VECTOR (
4 downto 0);
253 error_map_0 :
out STD_LOGIC_VECTOR (
23 downto 0);
254 error_map_1 :
out STD_LOGIC_VECTOR (
23 downto 0);
255 error_map_2 :
out STD_LOGIC_VECTOR (
23 downto 0);
256 error_map_3 :
out STD_LOGIC_VECTOR (
23 downto 0);
257 error_map_4 :
out STD_LOGIC_VECTOR (
23 downto 0)
261 COMPONENT default_reg_ila
265 probe0 :
IN STD_LOGIC_VECTOR(
31 DOWNTO 0);
266 probe1 :
IN STD_LOGIC_VECTOR(
31 DOWNTO 0);
267 probe2 :
IN STD_LOGIC_VECTOR(
0 DOWNTO 0);
268 probe3 :
IN STD_LOGIC_VECTOR(
0 DOWNTO 0)
276 generic ( start_state :
std_logic_vector := x"
02";
277 stop_state :
std_logic_vector := x"
11"
280 Port ( clock :
in STD_LOGIC;
281 reset :
in STD_LOGIC;
282 current_state :
in STD_LOGIC_vector (
7 downto 0);
285 event_time :
out std_logic_vector(
15 downto 0) ;
286 watermark :
out std_logic_vector(
15 downto 0);
287 avg_time :
out std_logic_vector(
15 downto 0)
296 signal ipbw: ipb_wbus_array(N_SLAVES - 1 downto 0);
297 signal ipbr: ipb_rbus_array(N_SLAVES - 1 downto 0);
299 signal event_fifo_rst_stb : std_logic;
300 signal event_fifo_rst_rst : std_logic;
301 SIGNAL event_fifo_control : std_logic_vector (31 downto 0);
302 signal event_fifo_reset : std_logic_vector (31 downto 0);
303 signal event_fifo_fill_level : std_logic_vector (31 downto 0);
304 signal event_watermark_reset : std_logic;
305 signal event_watermark : std_logic_vector (15 downto 0);
307 signal debug_fifo_rst_stb : std_logic;
308 signal debug_fifo_rst_rst : std_logic;
309 SIGNAL debug_fifo_control : std_logic_vector (31 downto 0);
310 signal debug_fifo_reset : std_logic_vector (31 downto 0);
311 signal debug_fifo_fill_level : std_logic_vector (31 downto 0);
312 signal debug_watermark_reset : std_logic;
313 signal debug_watermark : std_logic_vector (15 downto 0);
315 signal stage_watermark : std_logic_vector (15 downto 0);
316 signal stage_watermark_reset : std_logic;
317 signal stage_fifo_fill_level : std_logic_vector (31 downto 0);
319 signal fm_watermark : std_logic_vector (15 downto 0);
320 signal fm_watermark_reset : std_logic;
321 signal fm_fifo_fill_level : std_logic_vector (31 downto 0);
322 signal fm_L1id_i : std_logic_vector (31 downto 0);
323 signal full_mode_stat_i : std_logic_vector (31 downto 0);
324 signal fm_fifo_level : std_logic_vector (15 downto 0);
325 signal processor_status : std_logic_vector(31 downto 0);
327 signal staging_threshold : std_logic_vector(31 downto 0);
328 signal tob_stage_busy_thresh : std_logic_vector(15 downto 0);
329 signal tob_stage_xoff_thresh : std_logic_vector(15 downto 0);
331 signal staging_control : std_logic_vector(31 downto 0);
332 signal busy_enable : std_logic;
333 signal xoff_enable : std_logic;
334 signal force_busy : std_logic;
336 signal stage_fifo_rst_stb : std_logic;
337 signal stage_fifo_rst_rst : std_logic;
338 signal stage_fifo_reset_bits : std_logic_vector(31 downto 0);
339 signal stage_busy_thresh_reset : std_logic;
340 signal stage_xoff_thresh_reset : std_logic;
341 signal stage_fifo_reset : std_logic;
342 signal full_mode_stat_reset : std_logic;
344 signal Stage_fifo_busy_Count : std_logic_vector(31 downto 0);
345 signal Stage_fifo_xoff_Count : std_logic_vector(31 downto 0);
346 signal stage_fifo_busy_i : std_logic;
347 signal stage_fifo_xoff_i : std_logic;
348 signal stage_fifo_status : std_logic_vector(31 downto 0);
349 signal load_init_value : std_logic;
350 signal timeout_defaults : std_logic_vector(31 downto 0);
351 signal tob_timeouts : std_logic_vector(31 downto 0);
353 signal crc20_cnt : std_logic_vector(7 downto 0);
354 signal crc9_cnt : std_logic_vector(7 downto 0);
355 signal bcn_cnt : std_logic_vector(7 downto 0);
356 signal bad_l1id_cnt : std_logic_vector(7 downto 0);
357 signal clr_crc20_cnt : std_logic;
358 signal clr_crc9_cnt : std_logic;
359 signal clr_bcn_cnt : std_logic;
360 signal clr_l1id_cnt : std_logic;
361 signal clr_wdog_cnt : std_logic;
362 signal clr_timeout_err : std_logic;
363 signal tob_proc_rst_rst : std_logic;
364 signal tob_proc_rst_stb : std_logic;
365 signal tob_proc_reg_reset : std_logic_vector(31 downto 0);
367 signal load_defaults : std_logic;
369 signal watchdog_default : std_logic_vector(31 downto 0);
370 signal wdog_threshold_i : std_logic_vector(31 downto 0);
371 signal watchdog_control : std_logic_vector(31 downto 0);
372 signal wdog_overflow_count : std_logic_vector(31 downto 0);
373 signal wdog_fifo_reset_en : std_logic;
375 signal crc9_map : std_logic_vector(23 downto 0);
376 signal crc20_map : std_logic_vector(23 downto 0);
377 signal bcn_map : std_logic_vector(23 downto 0);
378 signal l1id_map : std_logic_vector(23 downto 0);
379 signal timeout_map : std_logic_vector(23 downto 0);
381 signal clr_crc9_cnt_s : std_logic;
382 signal clr_crc20_cnt_s : std_logic;
383 signal clr_BCN_cnt_s : std_logic;
384 signal clr_l1id_cnt_s : std_logic;
385 signal clr_timeout_s : std_logic;
387 signal clr_event_timer : std_logic;
388 signal event_time : std_logic_vector(15 downto 0) ;
389 signal max_event_time : std_logic_vector(15 downto 0);
390 signal avg_event_time : std_logic_vector(15 downto 0);
392 signal trace_input : std_logic_vector(23 downto 0);
393 signal full_mode_ctrl_i : std_logic_vector(31 downto 0);
395 signal flx_bp_count_reset : std_logic;
396 signal flx_bp_enable : std_logic;
397 signal flx_bp_time : std_logic_vector(31 downto 0);
399 signal idle_status : std_logic;
400 signal L1ID : std_logic_vector(23 downto 0);
401 signal ECRID : std_logic_vector(7 downto 0);
402 signal l1id_ttc : std_logic_vector(31 downto 0);
404 signal stage_fifo_xoff_sync : std_logic;
405 signal stage_fifo_busy_sync : std_logic;
406 signal xoff_condition : std_logic;
407 signal busy_condition : std_logic;
408 signal flx_backpressure_raw : std_logic;
409 signal flx_backpressure_rt : std_logic;
410 signal max_timeout_and_chan : std_logic_vector(31 downto 0);
412 signal current_chan : STD_LOGIC_VECTOR (7 downto 0);
413 signal chan_count : STD_LOGIC_VECTOR (4 downto 0);
417 fabric:
entity work.ipbus_fabric_sel
420 SEL_WIDTH => IPBUS_SEL_WIDTH
)
424 sel => ipbus_sel_L1CaloHubRodTobProc
(ipb_in.ipb_addr
),
425 ipb_to_slaves => ipbw,
426 ipb_from_slaves => ipbr
429 no_sim_regs: if SIM=0 generate
431 Event_fifo_control_reg:
entity work.ipbus_reg_v
435 ipbus_in => ipbw
(N_SLV_event_fifo_control
),
436 ipbus_out => ipbr
(N_SLV_event_fifo_control
),
437 q
(0) => event_fifo_control
440 Event_fifo_reset_reg:
entity work.ipbus_reg_v
443 reset => event_fifo_rst_rst,
444 ipbus_in => ipbw
(N_SLV_event_fifo_reset
),
445 ipbus_out => ipbr
(N_SLV_event_fifo_reset
),
446 stb
(0) => event_fifo_rst_stb,
447 q
(0) => event_fifo_reset
449 event_fifo_rst_rst <= event_fifo_rst_stb or ipb_rst;
452 event_fifo_fill_level_reg :
entity work.ipbus_syncreg_v
460 ipb_in => ipbw
(N_SLV_Event_fifo_fill_level
),
461 ipb_out => ipbr
(N_SLV_Event_fifo_fill_level
),
463 d
(0) => event_fifo_fill_level,
464 qmask =>
(others =>
(others => '1'
)),
469 event_fifo_fill_level(15 downto 0) <= event_fifo_level;
470 event_fifo_fill_level(31 downto 16) <= event_watermark;
473 event_fifo_watermark :
entity work.
watermark
475 watermark_width =>
16
479 level => event_fifo_level,
480 reset => event_watermark_reset,
481 watermark => event_watermark
484 event_watermark_reset <= (ipb_rst or event_fifo_reset(1));
488 debug_fifo_fill_level_reg :
entity work.ipbus_syncreg_v
496 ipb_in => ipbw
(N_SLV_Debug_fifo_fill_level
),
497 ipb_out => ipbr
(N_SLV_Debug_fifo_fill_level
),
499 d
(0) => debug_fifo_fill_level,
500 qmask =>
(others =>
(others => '1'
)),
505 debug_fifo_fill_level(15 downto 0) <= debug_fifo_level;
506 debug_fifo_fill_level(31 downto 16) <= debug_watermark;
509 debug_fifo_watermark :
entity work.
watermark
511 watermark_width =>
16
515 level => debug_fifo_level,
516 reset => debug_watermark_reset,
517 watermark => debug_watermark
520 debug_watermark_reset <= (ipb_rst or event_fifo_reset(5));
523 tob_proc_status :
entity work.ipbus_syncreg_v
531 ipb_in => ipbw
(N_SLV_Tob_Proc_Status
),
532 ipb_out => ipbr
(N_SLV_Tob_Proc_status
),
534 d
(0) => processor_status,
535 qmask =>
(others =>
(others => '1'
)),
540 processor_status(7 downto 0) <= current_chan;
541 processor_status(15 downto 8) <= current_state;
542 processor_status(16) <= header_mark;
543 processor_status(17) <= header_fifo_valid;
544 processor_status(18) <= hdr_crc_error;
545 processor_status(19) <= ttc_crc_error;
546 processor_status(31 downto 20) <= (others => '0');
549 Full_mode_control_reg:
entity work.ipbus_reg_v
553 ipbus_in => ipbw
(N_SLV_FULL_MODE_CONTROL
),
554 ipbus_out => ipbr
(N_SLV_FULL_MODE_CONTROL
),
555 q
(0) => full_mode_ctrl_i
557 full_mode_ctrl <= full_mode_ctrl_i;
559 full_mode_status_reg :
entity work.ipbus_syncreg_v
566 rst => full_mode_stat_reset,
567 ipb_in => ipbw
(N_SLV_FULL_MODE_STATUS
),
568 ipb_out => ipbr
(N_SLV_FULL_MODE_STATUS
),
570 d
(0) => full_mode_stat_i,
571 qmask =>
(others =>
(others => '1'
)),
577 full_mode_stat_i <= full_mode_stat(31 downto 24) & full_mode_stat(23 downto 16) & x"00" & full_mode_stat(7 downto 0);
579 full_mode_stat_reset <= ipb_rst or event_fifo_reset(9);
581 stage_fifo_fill_level_reg :
entity work.ipbus_syncreg_v
589 ipb_in => ipbw
(N_SLV_TOB_Staging_fifo_level
),
590 ipb_out => ipbr
(N_SLV_TOB_Staging_fifo_level
),
592 d
(0) => stage_fifo_fill_level,
593 qmask =>
(others =>
(others => '1'
)),
598 stage_fifo_fill_level(15 downto 0) <= stage_fifo_level;
599 stage_fifo_fill_level(31 downto 16) <= stage_watermark;
602 stage_fifo_watermark :
entity work.
watermark
604 watermark_width =>
16
608 level => stage_fifo_level,
609 reset => stage_watermark_reset,
610 watermark => stage_watermark
616 fullmode_fifo_fill_level_reg :
entity work.ipbus_syncreg_v
624 ipb_in => ipbw
(N_SLV_FULL_MODE_FIFO_LEVEL
),
625 ipb_out => ipbr
(N_SLV_FULL_MODE_FIFO_LEVEL
),
627 d
(0) => fm_fifo_fill_level,
628 qmask =>
(others =>
(others => '1'
)),
633 fm_fifo_fill_level(15 downto 0) <= fm_fifo_level(15 downto 0);
634 fm_fifo_fill_level(31 downto 16) <= fm_watermark;
637 fm_fifo_level(15 downto 0) <= x"00" & full_mode_stat(23 downto 16);
646 fm_fifo_watermark :
entity work.
watermark
648 watermark_width =>
16
652 level => fm_fifo_level,
653 reset => fm_watermark_reset,
654 watermark => fm_watermark
657 fm_watermark_reset <= (ipb_rst or event_fifo_reset(8));
668 fm_L1id_reg :
entity work.ipbus_syncreg_v
676 ipb_in => ipbw
(N_SLV_FULL_MODE_L1ID
),
677 ipb_out => ipbr
(N_SLV_FULL_MODE_L1ID
),
680 qmask =>
(others =>
(others => '1'
)),
686 fm_L1id_i <= FM_L1id_stat(31 downto 0);
690 tob_staging_thresholds_reg:
entity work.ipbus_reg_v
694 ipbus_in => ipbw
(N_SLV_Tob_staging_fifo_thresholds
),
695 ipbus_out => ipbr
(N_SLV_Tob_staging_fifo_thresholds
),
696 q
(0) => staging_threshold
699 tob_stage_busy_thresh <= staging_threshold(15 downto 0);
700 tob_stage_xoff_thresh <= staging_threshold(31 downto 16);
704 tob_staging_control_reg:
entity work.ipbus_reg_v
708 ipbus_in => ipbw
(N_SLV_Tob_staging_fifo_control
),
709 ipbus_out => ipbr
(N_SLV_Tob_staging_fifo_control
),
710 q
(0) => staging_control
712 busy_enable <= staging_control(0);
713 xoff_enable <= staging_control(1);
714 force_busy <= staging_control(4);
718 Tob_staging_fifo_resets_reg:
entity work.ipbus_reg_v
721 reset => stage_fifo_rst_rst,
722 ipbus_in => ipbw
(N_SLV_Tob_staging_fifo_resets
),
723 ipbus_out => ipbr
(N_SLV_Tob_staging_fifo_resets
),
724 stb
(0) => stage_fifo_rst_stb,
725 q
(0) => stage_fifo_reset_bits
727 stage_fifo_rst_rst <= stage_fifo_rst_stb or ipb_rst;
728 stage_fifo_reset <= stage_fifo_reset_bits(0);
729 stage_busy_thresh_reset <= stage_fifo_reset_bits(2);
730 stage_xoff_thresh_reset <= stage_fifo_reset_bits(3);
731 stage_watermark_reset <= stage_fifo_reset_bits(1);
732 flx_bp_count_reset <= stage_fifo_reset_bits(4);
737 Tob_stage_fifo_status_reg :
entity work.ipbus_syncreg_v
745 ipb_in => ipbw
(N_SLV_Tob_staging_fifo_status
),
746 ipb_out => ipbr
(N_SLV_Tob_staging_fifo_status
),
748 d
(0) => Stage_fifo_status,
749 qmask =>
(others =>
(others => '1'
)),
754 stage_fifo_status(0) <= stage_fifo_full;
755 stage_fifo_status(1) <= Stage_fifo_busy_i;
756 stage_fifo_status(2) <= Stage_fifo_xoff_i;
757 stage_fifo_status(31 downto 3) <= (others => '0');
761 Tob_stage_busy_Count_reg :
entity work.ipbus_syncreg_v
769 ipb_in => ipbw
(N_SLV_Tob_staging_fifo_busy_Count
),
770 ipb_out => ipbr
(N_SLV_Tob_staging_fifo_busy_Count
),
772 d
(0) => Stage_fifo_busy_count,
773 qmask =>
(others =>
(others => '1'
)),
780 Tob_stage_xoff_Count_reg :
entity work.ipbus_syncreg_v
788 ipb_in => ipbw
(N_SLV_Tob_staging_fifo_xoff_Count
),
789 ipb_out => ipbr
(N_SLV_Tob_staging_fifo_xoff_Count
),
791 d
(0) => Stage_fifo_xoff_count,
792 qmask =>
(others =>
(others => '1'
)),
800 Tob_timeout_reg :
entity work.ipbus_ctrlreg_v
808 ipbus_in => ipbw
(N_SLV_TOB_TIMEOUT_VALUES
),
809 ipbus_out => ipbr
(N_SLV_TOB_TIMEOUT_VALUES
),
811 ctrl_default
(0) => timeout_defaults,
812 d
(0) => timeout_defaults,
813 q
(0) => tob_timeouts,
819 load_defaults <= ipb_rst or reset;
820 timeout_1_val <= tob_timeouts(15 downto 0);
822 timeout_n_val <= tob_timeouts(31 downto 16);
824 timeout_defaults <= timeout_n_default & timeout_1_default;
849 error_count_register :
entity work.ipbus_syncreg_v
857 ipb_in => ipbw
(N_SLV_tob_error_count
),
858 ipb_out => ipbr
(N_SLV_Tob_error_count
),
860 d
(0) =>
(BCN_cnt & bad_l1id_cnt & crc20_cnt & crc9_cnt
),
861 qmask =>
(others =>
(others => '1'
)),
866 clr_crc9_cnt <= ipb_rst or reset or tob_proc_reg_reset(0);
867 clr_crc20_cnt <= ipb_rst or reset or tob_proc_reg_reset(1);
868 clr_l1id_cnt <= ipb_rst or reset or tob_proc_reg_reset(2);
869 clr_bcn_cnt <= ipb_rst or reset or tob_proc_reg_reset(3);
871 clr_timeout_err <= ipb_rst or reset or tob_proc_reg_reset(5);
872 clr_event_timer <= ipb_rst or reset or tob_proc_reg_reset(6);
874 clr_pkt_wait_timer <= ipb_rst or reset or tob_proc_reg_reset(8);
875 clr_max_timeout <= ipb_rst or reset or tob_proc_reg_reset(9);
877 tob_proc_reset_reg :
entity work.ipbus_reg_v
880 reset => tob_proc_rst_rst,
881 ipbus_in => ipbw
(N_SLV_tob_error_reset
),
882 ipbus_out => ipbr
(N_SLV_tob_error_reset
),
883 stb
(0) => tob_proc_rst_stb,
884 q
(0) => tob_proc_reg_reset
886 tob_proc_rst_rst <= tob_proc_rst_stb or ipb_rst;
896 ipb_in => ipbw
(N_SLV_PKT_CAPTURE_REGS
),
898 ipb_out => ipbr
(N_SLV_PKT_CAPTURE_REGS
),
899 pp_clock => pp_clock,
900 full_mode_stat => full_mode_stat,
902 m_tvalid => m_tvalid,
904 m_header_marker => m_header_marker
914 ipb_in => ipbw
(N_SLV_INPUT_CAPTURE_REGS
),
915 ipb_out => ipbr
(N_SLV_INPUT_CAPTURE_REGS
),
916 pp_clock => pp_clock,
917 current_chan => current_chan
(4 downto 0),
919 s_tvalid => s_tvalid,
921 s_header_mark => s_header_mark,
922 poll_chan => poll_chan,
923 timeout_err => timeout_err
936 watchdog_control_reg:
entity work.ipbus_reg_v
940 ipbus_in => ipbw
(N_SLV_watchdog_control
),
941 ipbus_out => ipbr
(N_SLV_watchdog_control
),
942 q
(0) => watchdog_control
945 wdog_disable <= watchdog_control(0);
946 wdog_fifo_reset_en <= watchdog_control(1);
947 l1id_resync_enable <= watchdog_control(4);
948 tob_timeout_1_disable <= watchdog_control(8);
949 tob_timeout_n_disable <= watchdog_control(9);
952 wdog_threshold_reg :
entity work.ipbus_ctrlreg_v
960 ipbus_in => ipbw
(N_SLV_WATCHDOG_THRESHOLD_VALUE
),
961 ipbus_out => ipbr
(N_SLV_WATCHDOG_THRESHOLD_VALUE
),
963 ctrl_default
(0) => watchdog_default,
964 d
(0) => watchdog_default,
965 q
(0) => wdog_threshold_i,
971 watchdog_default <= x"0000" & wdog_thresh_default;
972 wdog_threshold <= wdog_threshold_i(15 downto 0);
973 clr_wdog_cnt <= tob_proc_reg_reset(4);
975 watchdog_overflow_count_reg :
entity work.ipbus_syncreg_v
983 ipb_in => ipbw
(N_SLV_watchdog_overflow_count
),
984 ipb_out => ipbr
(N_SLV_watchdog_overflow_count
),
987 d
(0) => wdog_overflow_count,
988 qmask =>
(others =>
(others => '1'
)),
1006 counter_reset => clr_wdog_cnt,
1007 system_reset => ipb_rst,
1008 error => wdog_overflow,
1009 error_count => wdog_overflow_count
1012 wdog_fifo_reset <= wdog_overflow and wdog_fifo_reset_en and not wdog_disable;
1014 crc9_error_map_reg :
entity work.ipbus_syncreg_v
1022 ipb_in => ipbw
(N_SLV_crc9_error_map
),
1023 ipb_out => ipbr
(N_SLV_crc9_error_map
),
1024 slv_clk => pp_clock,
1025 d
(0) => x"00" & crc9_map ,
1026 qmask =>
(others =>
(others => '1'
)),
1031 crc20_error_map_reg :
entity work.ipbus_syncreg_v
1039 ipb_in => ipbw
(N_SLV_crc20_error_map
),
1040 ipb_out => ipbr
(N_SLV_crc20_error_map
),
1041 slv_clk => pp_clock,
1042 d
(0) => x"00" & crc20_map ,
1043 qmask =>
(others =>
(others => '1'
)),
1048 bcn_mismatch_map_reg :
entity work.ipbus_syncreg_v
1056 ipb_in => ipbw
(N_SLV_bcn_mismatch_map
),
1057 ipb_out => ipbr
(N_SLV_bcn_mismatch_map
),
1058 slv_clk => pp_clock,
1059 d
(0) => x"00" & bcn_map ,
1060 qmask =>
(others =>
(others => '1'
)),
1065 l1id_mismatch_map_reg :
entity work.ipbus_syncreg_v
1073 ipb_in => ipbw
(N_SLV_l1id_mismatch_map
),
1074 ipb_out => ipbr
(N_SLV_l1id_mismatch_map
),
1075 slv_clk => pp_clock,
1076 d
(0) => x"00" & l1id_map ,
1077 qmask =>
(others =>
(others => '1'
)),
1083 timeout_error_map_reg :
entity work.ipbus_syncreg_v
1091 ipb_in => ipbw
(N_SLV_timeout_error_map
),
1092 ipb_out => ipbr
(N_SLV_timeout_error_map
),
1093 slv_clk => pp_clock,
1094 d
(0) => x"00" & timeout_map ,
1095 qmask =>
(others =>
(others => '1'
)),
1103 process (ipb_clk)
begin
1104 if rising_edge (ipb_clk) then
1105 clr_crc9_cnt_s <= clr_crc9_cnt;
1106 clr_crc20_cnt_s <= clr_crc20_cnt;
1107 clr_BCN_cnt_s <= clr_BCN_cnt;
1108 clr_l1id_cnt_s <= clr_l1id_cnt;
1109 clr_timeout_s <= clr_timeout_err;
1116 reset_0 => clr_crc9_cnt_s,
1117 reset_1 => clr_crc20_cnt_s,
1118 reset_2 => clr_BCN_cnt_s,
1119 reset_3 => clr_l1id_cnt_s,
1120 reset_4 => clr_timeout_s,
1121 error_0 => crc9_err,
1122 error_1 => crc20_err,
1123 error_2 => BCID_mismatch,
1124 error_3 => L1ID_mismatch,
1125 error_4 => timeout_err,
1131 chan_in => current_chan
(4 downto 0),
1132 error_map_0 => crc9_map,
1133 error_map_1 => crc20_map,
1134 error_map_2 => bcn_map,
1135 error_map_3 => l1id_map,
1136 error_map_4 => timeout_map
1142 avg_event_time_reg :
entity work.ipbus_syncreg_v
1150 ipb_in => ipbw
(N_SLV_average_event_time
),
1151 ipb_out => ipbr
(N_SLV_average_event_time
),
1152 slv_clk => pp_clock,
1153 d
(0) => x"0000" & avg_event_time ,
1154 qmask =>
(others =>
(others => '1'
)),
1159 event_time_reg :
entity work.ipbus_syncreg_v
1167 ipb_in => ipbw
(N_SLV_event_time
),
1168 ipb_out => ipbr
(N_SLV_event_time
),
1169 slv_clk => pp_clock,
1171 d
(0) => max_event_time & event_time ,
1172 qmask =>
(others =>
(others => '1'
)),
1177 dbg_pkt_count_reg :
entity work.ipbus_syncreg_v
1185 ipb_in => ipbw
(N_SLV_debug_packet_count
),
1186 ipb_out => ipbr
(N_SLV_debug_packet_count
),
1187 slv_clk => pp_clock,
1188 d
(0) => dbg_pkt_count,
1189 qmask =>
(others =>
(others => '1'
)),
1194 dbg_pkt_count_reset <= tob_proc_reg_reset(7);
1196 flx_bp_time_reg :
entity work.ipbus_syncreg_v
1204 ipb_in => ipbw
(N_SLV_FELIX_BACKPRESSURE_TIME
),
1205 ipb_out => ipbr
(N_SLV_FELIX_BACKPRESSURE_TIME
),
1207 d
(0) => flx_bp_time,
1208 qmask =>
(others =>
(others => '1'
)),
1215 with full_mode_ctrl_i (11 downto 8) select
1216 flx_backpressure_raw <= flx_backpressure(0) when x"0",
1217 flx_backpressure(1) when x"1",
1218 flx_backpressure(2) when x"2",
1219 flx_backpressure(3) when x"3",
1220 flx_backpressure(4) when x"4",
1221 flx_backpressure(5) when x"5",
1222 flx_backpressure(6) when x"6",
1223 flx_backpressure(7) when x"7",
1224 flx_backpressure(8) when x"8",
1225 flx_backpressure(9) when x"9",
1226 flx_backpressure(10) when x"A",
1227 flx_backpressure(11) when x"B",
1230 flx_bp_enable <= full_mode_ctrl_i(4);
1235 if rising_edge (pp_clock) then
1236 flx_backpressure_bit <= flx_backpressure_raw;
1243 if rising_edge (rt_clk) then
1244 flx_backpressure_rt <= flx_backpressure_raw;
1248 process(rt_clk, ipb_rst, flx_bp_count_reset)
1250 if (ipb_rst or flx_bp_count_reset) = '1' then
1251 flx_bp_time <= (others => '0');
1252 elsif rising_edge(rt_clk) then
1253 if ((flx_bp_enable and flx_backpressure_rt) = '1') and (flx_bp_time < x"ffffffff") then
1254 flx_bp_time <= (flx_bp_time + 1);
1256 flx_bp_time <= flx_bp_time;
1261 pkt_wait_time_last_reg :
entity work.ipbus_syncreg_v
1269 ipb_in => ipbw
(N_SLV_PACKET_WAIT_TIME_LAST
),
1270 ipb_out => ipbr
(N_SLV_PACKET_WAIT_TIME_LAST
),
1271 slv_clk => pp_clock,
1272 d
(0) => l1id_measure_last,
1273 qmask =>
(others =>
(others => '1'
)),
1278 pkt_wait_time_max_reg :
entity work.ipbus_syncreg_v
1286 ipb_in => ipbw
(N_SLV_PACKET_WAIT_TIME_MAX
),
1287 ipb_out => ipbr
(N_SLV_PACKET_WAIT_TIME_MAX
),
1288 slv_clk => pp_clock,
1289 d
(0) => l1id_measure_max,
1290 qmask =>
(others =>
(others => '1'
)),
1295 pkt_max_wait_time_L1id_reg :
entity work.ipbus_syncreg_v
1303 ipb_in => ipbw
(N_SLV_PACKET_MAX_WAIT_TIME_L1ID
),
1304 ipb_out => ipbr
(N_SLV_PACKET_MAX_WAIT_TIME_L1ID
),
1305 slv_clk => pp_clock,
1306 d
(0) => l1id_max_l1id,
1307 qmask =>
(others =>
(others => '1'
)),
1313 max_timeout_reg :
entity work.ipbus_syncreg_v
1321 ipb_in => ipbw
(N_SLV_MAX_TIMEOUT
),
1322 ipb_out => ipbr
(N_SLV_MAX_TIMEOUT
),
1323 slv_clk => pp_clock,
1324 d
(0) => max_timeout_and_chan,
1325 qmask =>
(others =>
(others => '1'
)),
1330 max_timeout_and_chan(15 downto 0) <= timeout_counter_max;
1331 max_timeout_and_chan(23 downto 16) <= "000" & max_chan;
1332 max_timeout_and_chan(31 downto 24) <= x"00";
1336 start_state => x"12",
1342 reset => clr_event_timer,
1343 current_state => current_state,
1346 event_time => event_time,
1347 watermark => max_event_time,
1348 avg_time => avg_event_time
1351 trace_input(7 downto 0) <= current_chan;
1352 trace_input(8) <= wdog_overflow;
1353 trace_input(9) <= timeout_err;
1354 trace_input(10) <= l1id_mismatch;
1355 trace_input(11) <= s_tvalid;
1356 trace_input(12) <= header_fifo_valid;
1357 trace_input(13) <= header_mark;
1358 trace_input(14) <= hdr_crc_error;
1359 trace_input(15) <= ttc_crc_error;
1361 trace_module :
Processor_trace_module
1369 ipb_in => ipbw
(N_SLV_PROC_TRACE
),
1370 ipb_out => ipbr
(N_SLV_PROC_TRACE
),
1371 pp_clock => pp_clock,
1373 trace_input => trace_input,
1374 state => current_state,
1375 wd_event => wdog_overflow,
1376 timeout_error => timeout_err
1388 end generate no_sim_regs;
1397 ipb_in => ipbw
(N_SLV_L1ID_CAPTURE_REGS
),
1398 ipb_out => ipbr
(N_SLV_L1ID_CAPTURE_REGS
),
1399 pp_clock => pp_clock,
1401 s_tvalid => s_tvalid,
1403 idle_state => idle_status,
1404 l1id_ttc => L1ID_ttc_32_reg,
1405 l1id_pkt => s_tdata
(63 downto 32),
1406 current_chan => current_chan,
1407 first_chan => first_chan,
1408 poll_chan => poll_chan
1411 idle_status <= '1' when (current_state = 5x"00") else '0';
1419 process (pp_clock)
begin
1420 if rising_edge (pp_clock) then
1421 if clr_crc20_cnt = '1' then
1423 elsif (crc20_err = '1') and (crc20_cnt < x"FF") then
1424 crc20_cnt <= crc20_cnt + 1;
1426 crc20_cnt <= crc20_cnt;
1433 process (pp_clock)
begin
1434 if rising_edge (pp_clock) then
1435 if clr_crc9_cnt = '1' then
1437 elsif (crc9_err = '1') and (crc9_cnt < x"FF")then
1438 crc9_cnt <= crc9_cnt + 1;
1440 crc9_cnt <= crc9_cnt;
1448 process (pp_clock)
begin
1449 if rising_edge (pp_clock) then
1450 if clr_BCN_cnt = '1' then
1452 elsif (BCID_mismatch = '1') and (BCN_cnt < x"FF")then
1453 BCN_cnt <= BCN_cnt + 1;
1462 process (pp_clock)
begin
1463 if rising_edge (pp_clock) then
1464 if clr_l1id_cnt = '1' then
1465 bad_l1id_cnt <= x"00";
1466 elsif (L1ID_mismatch = '1') and (bad_l1id_cnt < x"FF")then
1467 bad_l1id_cnt <= bad_l1id_cnt + 1;
1469 bad_l1id_cnt <= bad_l1id_cnt;
1479 sim_only: if SIM=1 generate
1480 wdog_fifo_reset <= '0';
1481 end generate sim_only;
1486 reset => stage_busy_thresh_reset,
1487 threshold => tob_stage_busy_thresh,
1488 level => stage_fifo_level,
1489 above_count => stage_fifo_busy_count,
1496 reset => stage_busy_thresh_reset,
1497 threshold => tob_stage_busy_thresh,
1498 level => stage_fifo_level,
1499 above_count =>
open,
1500 busy => stage_fifo_busy_sync
1505 stage_fifo_busy_i <= (stage_fifo_busy_sync and busy_enable) or force_busy;
1506 stage_fifo_busy <= stage_fifo_busy_i;
1511 reset => stage_xoff_thresh_reset,
1512 threshold => tob_stage_xoff_thresh,
1513 level => stage_fifo_level,
1514 above_count => stage_fifo_xoff_count,
1521 reset => stage_xoff_thresh_reset,
1522 threshold => tob_stage_xoff_thresh,
1523 level => stage_fifo_level,
1524 above_count =>
open,
1525 busy => stage_fifo_xoff_sync
1530 stage_fifo_xoff_i <= stage_fifo_xoff_sync and xoff_enable;
1531 stage_fifo_xoff <= stage_fifo_xoff_i;
1534 xoff_condition <= '1' when ((stage_fifo_xoff_i = '1') and (tob_stage_xoff_thresh /= x"0000")) else '0';
1535 busy_condition <= '1' when ((stage_fifo_busy_i = '1') and (tob_stage_busy_thresh /= x"0000")) else '0';
1537 stop_proc <= xoff_condition or busy_condition;
1542 process (pp_clock)
begin
1543 if rising_edge (pp_clock) then
1544 if ((reset = '1') or (chan_pointer_reset = '1')) then
1545 chan_count <= first_chan;
1546 elsif (nxt_chan_0 = '1') then
1547 if (chan_count = last_chan) then
1548 chan_count <= first_chan;
1550 chan_count <= chan_count + '1';
1553 chan_count <= chan_count;
1558 current_chan(4 downto 0) <= chan_count;
1559 current_chan(7 downto 5) <= (others => '0');