24 use IEEE.STD_LOGIC_1164.
ALL;
25 use ieee.std_logic_unsigned.
all;
26 use IEEE.NUMERIC_STD.
ALL;
39 packet_version : std_logic_vector(2 downto 0) := "001";
40 addr_width : integer := 4;
45 pp_clock : in std_logic;
46 ipb_rst : in std_logic;
47 input_capture_control : in std_logic_vector(31 downto 0);
48 s_tvalid : in std_logic;
49 s_tlast : in std_logic;
50 s_tdata : in std_logic_vector(63 downto 0);
51 poll_chan : in std_logic;
53 current_chan : in std_logic_vector(4 downto 0);
54 selected_chan : in std_logic_vector(4 downto 0);
56 timeout_err : in std_logic;
58 pkt_count : out std_logic_vector(31 downto 0);
60 input_header : out std_logic_vector(63 downto 0);
61 input_trailer : out std_logic_vector(63 downto 0);
62 capture_status : out std_logic_vector(31 downto 0);
63 header_crc9_error : out std_logic;
64 payload_crc20_error : out std_logic;
65 length_error : out std_logic;
67 spy_we : out std_logic;
68 spy_addr : out std_logic_vector(addr_width-1 downto 0)
78 fex_check :
integer :=
0;
79 crc20_G_Poly :
std_logic_vector(
19 downto 0) := x"
8349f"
84 s_tvalid :
in std_logic;
85 s_tlast :
in std_logic;
86 s_tdata :
in std_logic_vector(
63 downto 0);
87 header_error :
out std_logic;
88 payload_error :
out std_logic;
89 length_error :
out std_logic
95 signal clear : std_logic;
96 signal clear_s : std_logic;
97 signal clear_s_del : std_logic;
98 signal armed : std_logic;
99 signal armed_s : std_logic;
100 signal armed_s_del : std_logic;
101 signal armed_pulse : std_logic;
102 signal armed_stat : std_logic;
103 signal triggered : std_logic;
104 signal capture : std_logic;
105 signal tvalid_prev : std_logic;
106 signal l_header_marker : std_logic;
108 signal arm_for_timeout : std_logic;
109 signal armed_timeout_stat : std_logic;
110 signal armed_for_timeout_del : std_logic;
111 signal armed_for_timeout_pulse : std_logic;
114 signal m_header_marker_2 : std_logic;
115 signal header_0 : std_logic_vector(63 downto 0);
116 signal header_0_i : std_logic_vector(31 downto 0);
117 signal header_2 : std_logic_vector(31 downto 0);
118 signal trailer : std_logic_vector(63 downto 0);
120 signal incomp_pkt : std_logic;
123 signal pkt_count_i : std_logic_vector(31 downto 0);
125 signal tvalid_dup : std_logic;
126 signal poll_chan_del : std_logic;
127 signal poll_chan_del2 : std_logic;
128 signal crc_reset : std_logic;
130 signal header_crc9_error_i : std_logic;
131 signal payload_crc20_error_i : std_logic;
132 signal length_error_i : std_logic;
134 signal spy_addr_i : std_logic_vector(addr_width-1 downto 0);
135 signal spy_addr_max : std_logic_vector(addr_width-1 downto 0);
138 spy_addr_max <= (others => '1');
171 process(pp_clock)
begin
172 if rising_edge (pp_clock) then
173 clear_s <= input_capture_control(1);
174 clear_s_del <= clear_s;
178 clear <= clear_s_del and not clear_s;
181 process(pp_clock)
begin
182 if rising_edge (pp_clock) then
183 armed_s <= input_capture_control(0);
184 armed_s_del <= armed_s;
188 armed_pulse <= armed_s_del and not armed_s;
190 process(pp_clock)
begin
191 if rising_edge (pp_clock) then
192 if (ipb_rst = '1') or (capture = '1') or (clear = '1') then
194 elsif (armed_pulse = '1') then
197 armed_stat <= armed_stat;
204 process(pp_clock)
begin
205 if rising_edge (pp_clock) then
206 if (ipb_rst = '1') or (capture = '1') or (clear = '1') then
207 arm_for_timeout <= '0';
208 elsif (input_capture_control(2) = '1') then
209 arm_for_timeout <= '1';
211 arm_for_timeout <= arm_for_timeout;
216 process(pp_clock)
begin
217 if rising_edge (pp_clock) then
218 armed_for_timeout_del <= arm_for_timeout;
230 armed_for_timeout_pulse <= arm_for_timeout and not armed_for_timeout_del;
232 process(pp_clock)
begin
233 if rising_edge (pp_clock) then
234 if (ipb_rst = '1') or (capture = '1') or (clear = '1') then
235 armed_timeout_stat <= '0';
236 elsif (arm_for_timeout = '1') and ((timeout_err = '1') and (current_chan = selected_chan)) then
237 armed_timeout_stat <= '1';
239 armed_timeout_stat <= armed_timeout_stat;
247 process (pp_clock)
begin
248 if rising_edge (pp_clock) then
249 if (ipb_rst = '1') or (clear = '1') then
252 tvalid_prev <= (not s_tvalid) or (s_tlast and s_tvalid);
257 l_header_marker <= s_tvalid and tvalid_prev;
263 process(pp_clock)
begin
264 if rising_edge (pp_clock) then
265 if (ipb_rst = '1') or (clear = '1') then
268 elsif ((armed_stat = '1') or (armed_timeout_stat = '1')) and (l_header_marker = '1') and (s_tvalid = '1') and (current_chan = selected_chan) then
270 elsif (capture = '1') and (s_tlast = '1') then
279 process(pp_clock)
begin
280 if rising_edge (pp_clock) then
281 if (ipb_rst = '1') or (clear = '1') then
283 elsif (capture = '1') then
285 elsif (armed_pulse = '1') or (armed_for_timeout_pulse = '1') then
288 triggered <= triggered;
294 process(pp_clock)
begin
295 if rising_edge (pp_clock) then
296 if (clear = '1') then
297 header_0 <= (others => '0');
299 elsif ((armed_stat = '1' ) or (armed_timeout_stat = '1')) and (l_header_marker = '1') and (s_tvalid = '1') and (current_chan = selected_chan) then
302 header_0 <= header_0;
310 process(pp_clock)
begin
311 if rising_edge (pp_clock) then
312 if (clear = '1') then
313 trailer <= (others => '0');
314 elsif (capture = '1' ) and (s_tlast = '1') then
324 incomp_pkt <= capture;
329 capture_status(0) <= armed_stat;
330 capture_status(1) <= triggered;
331 capture_status(2) <= incomp_pkt;
332 capture_status(3) <= arm_for_timeout;
333 capture_status(4) <= header_crc9_error_i;
334 capture_status(5) <= payload_crc20_error_i;
335 capture_status(6) <= length_error_i;
336 capture_status(27 downto 7) <= (others => '0');
337 capture_status(30 downto 28) <= packet_version;
338 capture_status(31) <= '0';
342 process(pp_clock)
begin
343 if rising_edge (pp_clock) then
344 if (ipb_rst = '1') or (clear = '1') then
345 pkt_count_i <= (others => '0');
346 elsif (s_tlast = '1') and (s_tvalid = '1') and (current_chan = selected_chan) then
347 pkt_count_i <= (pkt_count_i + 1);
349 pkt_count_i <= pkt_count_i;
354 pkt_count <= pkt_count_i;
355 input_header <= header_0;
356 input_trailer <= trailer;
361 crc20_G_Poly => x"8359f"
366 s_tvalid => tvalid_dup,
369 header_error => header_crc9_error_i,
370 payload_error => payload_crc20_error_i,
371 length_error => length_error_i
374 crc_reset <= clear or armed_pulse;
377 header_crc9_error <= header_crc9_error_i;
378 payload_crc20_error <= payload_crc20_error_i;
379 length_error <= length_error_i;
387 process (pp_clock)
begin
388 if rising_edge (pp_clock) then
389 poll_chan_del <= poll_chan;
390 poll_chan_del2 <= poll_chan_del;
396 process (pp_clock)
begin
397 if rising_edge (pp_clock) then
398 if (ipb_rst = '1') or (clear = '1') or (s_tlast = '1') then
400 elsif (poll_chan_del = '1') and (s_tvalid = '1') and (current_chan = selected_chan) and (capture = '1') then
402 elsif s_tlast = '1' then
405 tvalid_dup <= tvalid_dup;
413 spy_we <= tvalid_dup;
415 process (pp_clock)
begin
416 if rising_edge (pp_clock) then
417 if (ipb_rst = '1') or (clear = '1') or (s_tlast = '1') then
418 spy_addr_i <= (others => '0');
419 elsif (tvalid_dup = '1') and (spy_addr_i < spy_addr_max) then
420 spy_addr_i <= spy_addr_i + 1;
422 spy_addr_i <= spy_addr_i;
427 spy_addr <= spy_addr_i;