15 use ieee.std_logic_1164.
all;
16 use ieee.numeric_std.
all;
18 LIBRARY infrastructure_lib;
24 DEBUG_FORMAT_VERSION : std_logic_vector (2 DOWNTO 0) := "001"
28 rst_clk : in std_logic;
30 ttc_info : IN std_logic_vector(49 DOWNTO 0);
31 ttc_valid : IN std_logic;
33 input_fifo_empty : IN std_logic;
34 input_tob_data : IN std_logic_vector(63 downto 0);
35 input_tob_valid : IN std_logic;
36 input_tob_last : IN std_logic;
37 input_tob_ready : OUT std_logic;
39 output_fifo_data : OUT packet_data_array(1 downto 0);
40 output_fifo_valid : OUT std_logic_vector(1 downto 0);
41 output_fifo_last : OUT std_logic_vector(1 downto 0);
42 output_fifo_ready : IN std_logic_vector(1 downto 0);
44 TOB_packet_ready : OUT std_logic;
45 TOB_packet_to_merge : OUT std_logic;
46 TOB_packet_missing : OUT std_logic;
47 debug_packet_created : OUT std_logic
55 generic(NSRC:
positive :=
4);
58 rst_clk :
in std_logic;
59 packet_merger_start :
in std_logic := '
0';
60 packet_merger_enabled :
IN std_logic_vector(NSRC
-1 downto 0);
61 packet_merger_source :
OUT std_logic_vector(
2 downto 0);
64 packet_merger_valid :
IN std_logic_vector(NSRC
-1 downto 0);
65 packet_merger_last :
IN std_logic_vector(NSRC
-1 downto 0);
66 packet_merger_ready :
OUT std_logic_vector(NSRC
-1 downto 0);
69 packet_valid :
OUT std_logic;
70 packet_last :
OUT std_logic;
71 packet_sub_last :
OUT std_logic;
72 packet_ready :
IN std_logic
78 INIT :
std_logic_vector(
31 downto 0) := (
Others => '
0')
84 A :
in std_logic_vector(
4 downto 0);
88 end COMPONENT SRLC32E;
105 signal header_sig: std_logic_vector(63 downto 0);
106 signal start_debug_merger_sig, header_valid_sig, header_ready_sig, debug_ready_sig, l1id_correct_sig, event_missing_sig, fifo_delay_start, fifo_delay_end: std_logic;
107 signal state_sig: STATE_TYPE;
112 output_fifo_data(0) <= input_tob_data;
113 output_fifo_valid(0) <= input_tob_valid when (state_sig = send_payload) else '0';
114 output_fifo_last(0) <= input_tob_last;
116 ready_mux: with state_sig select
117 input_tob_ready <= debug_ready_sig when send_debug,
118 '1' when skip_payload_header,
119 output_fifo_ready(0) when send_payload,
130 packet_merger_start => start_debug_merger_sig,
131 packet_merger_enabled => "
11",
132 packet_merger_source =>
OPEN,
133 packet_merger_data
(0) => header_sig,
134 packet_merger_data
(1) => input_tob_data,
135 packet_merger_valid
(0) => header_valid_sig,
136 packet_merger_valid
(1) => input_tob_valid,
137 packet_merger_last
(0) => header_valid_sig,
138 packet_merger_last
(1) => input_tob_last,
139 packet_merger_ready
(0) => header_ready_sig,
140 packet_merger_ready
(1) => debug_ready_sig,
142 packet_valid => output_fifo_valid
(1),
143 packet_last => output_fifo_last
(1),
144 packet_sub_last =>
OPEN,
145 packet_ready => output_fifo_ready
(1)
148 send_debug_block:
process(clk)
149 variable header_valid: std_logic;
151 if rising_edge(clk) then
152 if (state_sig = send_debug_header) then
157 header_valid_sig <= header_valid
163 end process send_debug_block;
165 header_block:
process(clk)
166 variable header: std_logic_vector(63 downto 0) := (Others => '1');
168 if rising_edge(clk) then
169 if (state_sig = idle) then
170 if (ttc_valid = '1') then
171 header := ttc_info(43 downto 12) & DEBUG_FORMAT_VERSION & "0" & x"00" & ttc_info(11 downto 0) & x"C0";
173 header := (Others => '1');
182 end process header_block;
184 l1id_correct_block:
process(clk)
185 variable bcn_match, l1id_match, ecrid_match, l1id_correct: std_logic;
187 if rising_edge(clk) then
192 if (input_tob_valid = '1') then
193 if (header_sig(19 downto 8) = input_tob_data(19 downto 8)) then
198 if (header_sig(55 downto 32) = input_tob_data(55 downto 32)) then
203 if (header_sig(63 downto 56) = input_tob_data(63 downto 56)) then
214 if (bcn_match = '1') and (l1id_match = '1') and (ecrid_match = '1') then
221 l1id_correct_sig <= l1id_correct
227 end process l1id_correct_block;
229 event_missing_block:
process(clk)
230 variable l1id_future, ecrid_future, ecrid_wraparound, event_missing: std_logic;
231 variable first_strike: std_logic := '1';
232 variable processed_packet: std_logic := '0';
234 if rising_edge(clk) then
235 if rst_clk = '1' then
236 event_missing := '0';
237 processed_packet := '0';
242 event_missing := '0';
244 if (input_tob_valid = '1') then
245 if (unsigned(header_sig(55 downto 32)) < unsigned(input_tob_data(55 downto 32))) then
250 if (unsigned(header_sig(63 downto 56)) < unsigned(input_tob_data(63 downto 56))) then
255 if (header_sig(63 downto 60) = "1111") and (input_tob_data(63 downto 60) = "0000") then
256 ecrid_wraparound := '1';
258 ecrid_wraparound := '0';
263 ecrid_wraparound := '1';
265 processed_packet := '1';
268 if ((l1id_future = '1') or (ecrid_future = '1') or (ecrid_wraparound = '1')) and (first_strike = '1') then
269 event_missing := '1';
271 event_missing := '0';
273 when start_debug_merger | skip_payload_header =>
275 processed_packet := '1';
277 if (processed_packet = '1') then
282 processed_packet := '0';
286 event_missing_sig <= event_missing
292 end process event_missing_block;
294 merger_start_block:
process(clk)
296 if rising_edge(clk) then
297 if (state_sig = start_debug_merger) then
298 start_debug_merger_sig <= '1'
304 start_debug_merger_sig <= '0'
311 end process merger_start_block;
313 report_status_block:
process(clk)
315 if rising_edge(clk) then
316 if (state_sig = send_status) then
317 TOB_packet_ready <= '1'
322 TOB_packet_to_merge <= l1id_correct_sig
327 TOB_packet_missing <= event_missing_sig
333 TOB_packet_ready <= '0'
338 TOB_packet_to_merge <= '0'
343 TOB_packet_missing <= '0'
349 if (state_sig = start_debug_merger) then
350 debug_packet_created <= '1'
356 debug_packet_created <= '0'
363 end process report_status_block;
365 SRLC32E_fifo_delay : SRLC32E
366 generic map (INIT => X"00000000"
)
369 Q31 => fifo_delay_end,
370 A =>
(Others => '1'
),
373 D => fifo_delay_start
376 state_machine:
process(clk)
377 variable next_state: STATE_TYPE := idle;
378 variable fifo_start: std_logic;
380 if rising_edge(clk) then
382 if rst_clk = '1' then
387 next_state := parse_l1id;
389 next_state := check_l1id;
391 if (l1id_correct_sig = '1') or (event_missing_sig = '1') then
392 next_state := send_status;
394 next_state := start_debug_merger;
396 when start_debug_merger =>
397 next_state := send_debug_header;
398 when send_debug_header =>
399 if (header_ready_sig = '1') then
400 next_state := send_debug;
402 next_state := send_debug_header;
405 if (input_tob_last = '1') and (input_tob_valid = '1') and (debug_ready_sig = '1') then
406 next_state := wait_fifo;
409 next_state := send_debug;
412 if (input_fifo_empty = '1') and (fifo_delay_end = '1') then
413 next_state := send_status;
414 elsif (input_tob_valid = '1') then
415 next_state := prepare_l1id;
417 next_state := wait_fifo;
420 if (l1id_correct_sig = '1') then
421 next_state := skip_payload_header;
423 next_state := end_event;
425 when skip_payload_header =>
426 next_state := send_payload;
428 if (input_tob_last = '1') and (input_tob_valid = '1') and (output_fifo_ready(0) = '1') then
429 next_state := end_event;
431 next_state := send_payload;
436 if (ttc_valid = '1') then
437 next_state := prepare_l1id;
443 state_sig <= next_state
448 fifo_delay_start <= fifo_start
454 end process state_machine;
456 END Architecture rtl;
MUX to concatenate AXI-stream fragments into single packet...
in packet_merger_data packet_data_array( NSRC- 1 downto 0)
Input signals.
out packet_data std_logic_vector( 63 DOWNTO 0)
FIFO signals.
efex_packet_merger
Input signals.