23 use IEEE.STD_LOGIC_1164.
ALL;
27 use IEEE.NUMERIC_STD.
ALL;
28 use IEEE.STD_LOGIC_UNSIGNED.
ALL;
37 channel_num : STD_LOGIC_VECTOR (11 downto 0) := "000000000000";
38 lmem : STD_LOGIC_VECTOR (3 downto 0) := "0000";
39 max_packet_length : STD_LOGIC_VECTOR (15 downto 0) := x"02A0"
42 Port ( pp_clock : in STD_LOGIC;
43 aurora_user_clk : in STD_LOGIC;
45 aurora_chan_stat : in STD_LOGIC_VECTOR (31 downto 0);
46 s_axis_tvalid : in STD_LOGIC;
47 s_axis_tlast : in STD_LOGIC;
48 s_axis_tdata : in STD_LOGIC_VECTOR (63 downto 0);
49 m_axis_tvalid : out STD_LOGIC;
50 m_axis_tlast : out STD_LOGIC;
51 m_axis_tdata : out STD_LOGIC_VECTOR (63 downto 0);
52 m_first_cyc : out STD_LOGIC;
53 crc_error : out STD_LOGIC;
54 m_tval_tob : out STD_LOGIC;
55 m_tval_calo : out STD_LOGIC;
56 pkt_len_violation : out STD_LOGIC;
58 comb_error : in STD_LOGIC;
59 m_comb_error : out std_logic
68 Nbits :
positive :=
64;
69 CRC_Width :
positive :=
9;
72 G_Poly:
Std_Logic_Vector := "
011111011";
73 G_InitVal:
std_logic_vector:= "
111111111"
76 CRC :
out std_logic_vector(CRC_Width
-1 downto 0);
79 DIn :
in std_logic_vector(Nbits
-1 downto 0);
80 Reset :
in std_logic);
86 COUNTER_WIDTH :
integer :=
7
91 pulse_in :
in STD_LOGIC;
92 pulse_out :
out STD_LOGIC
98 signal axis_tvalid_1 : STD_LOGIC := '0';
99 signal axis_tlast_1 : STD_LOGIC := '0';
100 signal axis_tdata_1 : STD_LOGIC_VECTOR (63 downto 0);
101 signal first_cyc_1 : STD_LOGIC := '0';
102 signal comb_error_1 : STD_LOGIC := '0';
104 signal axis_tvalid_2 : STD_LOGIC := '0';
105 signal axis_tlast_2 : STD_LOGIC := '0';
106 signal axis_tdata_2 : STD_LOGIC_VECTOR (63 downto 0);
107 signal first_cyc_2 : STD_LOGIC := '0';
108 signal comb_error_2 : STD_LOGIC := '0';
110 signal axis_tvalid_3 : STD_LOGIC := '0';
111 signal axis_tlast_3 : STD_LOGIC := '0';
112 signal axis_tdata_3 : STD_LOGIC_VECTOR (63 downto 0);
113 signal first_cyc_3 : STD_LOGIC := '0';
114 signal comb_error_3 : STD_LOGIC := '0';
115 signal tval_tob_3 : STD_LOGIC := '0';
116 signal tval_calo_3 : STD_LOGIC := '0';
118 signal axis_tvalid_4 : STD_LOGIC := '0';
119 signal axis_tlast_4 : STD_LOGIC := '0';
120 signal axis_tdata_4 : STD_LOGIC_VECTOR (63 downto 0);
121 signal first_cyc_4 : STD_LOGIC := '0';
122 signal comb_error_4 : STD_LOGIC := '0';
123 signal tval_tob_4 : STD_LOGIC := '0';
124 signal tval_calo_4 : STD_LOGIC := '0';
126 signal m_axis_tvalid_i : STD_LOGIC := '0';
127 signal m_axis_tlast_i : STD_LOGIC := '0';
128 signal m_axis_tdata_i : STD_LOGIC_VECTOR (63 downto 0);
129 signal m_first_cyc_i : STD_LOGIC := '0';
130 signal s_first_cyc : STD_LOGIC;
131 signal tvalid_prev : STD_LOGIC := '0';
132 signal generated_crc: STD_LOGIC_VECTOR (8 downto 0);
133 signal header_crc : STD_LOGIC_VECTOR (8 downto 0);
134 signal crc_error_i : STD_LOGIC;
135 signal crc_error_3 : STD_LOGIC := '0';
136 signal crc_error_4 : STD_LOGIC := '0';
137 signal crc_input_low : STD_LOGIC_VECTOR (31 downto 0);
138 signal crc_input_high : STD_LOGIC_VECTOR (31 downto 0);
139 signal crc_input_flip : STD_LOGIC_VECTOR (63 downto 0);
140 signal m_tval_tob_i : STD_LOGIC := '0';
141 signal tval_tob : STD_LOGIC := '0';
142 signal m_tval_calo_i : STD_LOGIC := '0';
143 signal tval_calo : STD_LOGIC := '0';
145 signal pkt_count : STD_LOGIC_VECTOR (15 downto 0) := x"0000";
146 signal trailer_value : STD_LOGIC_VECTOR (63 downto 0);
147 signal terminate_pkt : STD_LOGIC := '0';
148 signal terminate_pkt_1 : STD_LOGIC := '0';
149 signal terminate_pkt_2 : STD_LOGIC := '0';
150 signal terminate_pkt_flag : STD_LOGIC := '0';
151 signal pkt_len_violation_i : STD_LOGIC := '0';
152 signal in_progress : STD_LOGIC;
154 signal calc_crc20 : STD_LOGIC;
155 signal generated_crc20 : STD_LOGIC_vector(19 downto 0);
156 signal reg_crc20 : STD_LOGIC_vector(19 downto 0) := x"00000";
158 signal m_comb_error_i : std_logic;
159 signal pipe_lock : std_logic;
160 signal valid_low : std_logic;
161 signal valid_low_1 : std_logic;
162 signal valid_low_2 : std_logic;
163 signal valid_low_3 : std_logic;
171 process (aurora_user_clk, reset, pkt_len_violation_i, aurora_chan_stat(
0), pipe_lock)
begin
173 if (reset = '1') or (pkt_len_violation_i = '1') or (aurora_chan_stat(0) = '0') or (pipe_lock = '1') then
175 axis_tvalid_1 <= '0';
180 elsif rising_edge (aurora_user_clk) then
181 axis_tdata_1 <= s_axis_tdata;
182 comb_error_1 <= comb_error;
188 axis_tvalid_1 <= s_axis_tvalid;
189 axis_tlast_1 <= s_axis_tlast;
191 first_cyc_1 <= s_first_cyc;
200 process (aurora_user_clk, reset, pkt_len_violation_i, aurora_chan_stat(
0))
begin
202 if (reset = '1')or (pkt_len_violation_i = '1') or (aurora_chan_stat(0) = '0') then
204 axis_tvalid_2 <= '0';
208 elsif rising_edge (aurora_user_clk) then
209 axis_tdata_2 <= axis_tdata_1;
210 comb_error_2 <= comb_error_1;
216 axis_tvalid_2 <= axis_tvalid_1;
217 axis_tlast_2 <= axis_tlast_1;
219 first_cyc_2 <= first_cyc_1;
226 process (aurora_user_clk, reset, pkt_len_violation_i, aurora_chan_stat(
0))
begin
228 if (reset = '1') or (pkt_len_violation_i = '1') or (aurora_chan_stat(0) = '0') then
230 axis_tvalid_3 <= '0';
235 elsif rising_edge (aurora_user_clk) then
236 axis_tdata_3 <= axis_tdata_2;
237 comb_error_3 <= comb_error_2;
245 axis_tvalid_3 <= axis_tvalid_2;
246 axis_tlast_3 <= axis_tlast_2;
248 first_cyc_3 <= first_cyc_2;
250 tval_tob_3 <= tval_tob;
251 tval_calo_3 <= tval_calo;
288 process (aurora_user_clk)
begin
289 if rising_edge (aurora_user_clk) then
290 crc_error_4 <= crc_error_3 and first_cyc_3;
291 if (reset = '1') then
296 first_cyc_4 <= first_cyc_3;
297 tval_tob_4 <= tval_tob_3 or (crc_error_3 and first_cyc_3);
298 tval_calo_4 <= tval_calo_3 and not crc_error_3;
303 process (aurora_user_clk)
begin
304 if rising_edge (aurora_user_clk) then
305 if (reset = '1') then
306 axis_tvalid_4 <= '0';
308 axis_tdata_4 <= axis_tdata_3;
309 comb_error_4 <= comb_error_3;
310 elsif (terminate_pkt = '1') then
311 axis_tdata_4 <= trailer_value;
313 axis_tvalid_4 <= '1';
315 axis_tvalid_4 <= axis_tvalid_3;
316 axis_tlast_4 <= axis_tlast_3;
317 axis_tdata_4 <= axis_tdata_3;
318 comb_error_4 <= comb_error_3;
325 trailer_value <= channel_num & "0000" & max_packet_length & x"5a5a5" & x"A" & '0' & "0101100";
331 process (aurora_user_clk)
begin
332 if rising_edge (aurora_user_clk) then
333 m_axis_tdata_i <= axis_tdata_4;
334 m_comb_error_i <= comb_error_4;
335 if (reset = '1') then
336 m_axis_tvalid_i <= '0';
337 m_axis_tlast_i <= '0';
338 m_first_cyc_i <= '0';
340 m_tval_calo_i <= '0';
344 m_axis_tvalid_i <= axis_tvalid_4;
345 m_axis_tlast_i <= axis_tlast_4;
347 m_first_cyc_i <= first_cyc_4;
348 m_tval_tob_i <= tval_tob_4;
349 m_tval_calo_i <= tval_calo_4;
350 crc_error_i <= crc_error_4;
356 m_axis_tvalid <= m_axis_tvalid_i;
357 m_axis_tlast <= m_axis_tlast_i;
358 m_axis_tdata <= m_axis_tdata_i;
359 m_first_cyc <= m_first_cyc_i;
360 m_tval_tob <= m_tval_tob_i;
361 m_tval_calo <= m_tval_calo_i;
362 m_comb_error <= m_comb_error_i;
365 process (aurora_user_clk)
begin
366 if rising_edge (aurora_user_clk) then
367 if (reset = '1') then
370 tvalid_prev <= (not s_axis_tvalid) or (s_axis_tlast and s_axis_tvalid);
375 process(aurora_user_clk, terminate_pkt)
begin
376 if (terminate_pkt = '1') then
378 elsif rising_edge (aurora_user_clk) then
379 if (reset = '1') or (s_axis_tlast = '1') then
381 elsif (s_first_cyc = '1') and (s_axis_tlast = '0') then
384 in_progress <= in_progress;
390 s_first_cyc <= s_axis_tvalid and tvalid_prev and not s_axis_tlast and not in_progress;
392 process (aurora_user_clk)
begin
393 if rising_edge (aurora_user_clk) then
394 if (reset = '1') then
395 header_crc <= (others => '0');
397 header_crc <= axis_tdata_2(28 downto 20);
403 crc_input_low <= axis_tdata_1(63 downto 32);
404 crc_input_flip <= axis_tdata_1(31 downto 29) & "000000000" & axis_tdata_1(19 downto 0) & axis_tdata_1(63 downto 32);
412 G_Poly => "
011111011",
413 G_InitVal => "
111111111"
416 CRC => generated_CRC,
418 Clk => aurora_user_clk,
419 DIn => crc_input_flip,
423 crc_error_3 <= '1' when generated_CRC /= header_crc else '0';
425 crc_error <= crc_error_i;
467 tval_tob <= first_cyc_2 and not axis_tdata_2(7);
468 tval_calo <= first_cyc_2 and axis_tdata_2(7);
471 process (aurora_user_clk, pkt_len_violation_i)
begin
472 if pkt_len_violation_i = '1' then
473 pkt_count <= (others => '0');
474 elsif rising_edge (aurora_user_clk) then
475 if (reset = '1') or (s_axis_tlast = '1') or (pipe_lock = '1') then
476 pkt_count <= (others => '0');
477 elsif (s_axis_tvalid = '1') then
478 pkt_count <= (pkt_count + 1);
480 pkt_count <= pkt_count;
502 process (pp_clock)
begin
504 if rising_edge (pp_clock) then
505 if (reset = '1') or (terminate_pkt_1 = '1') then
506 terminate_pkt_1 <= '0';
507 elsif (pkt_count >= max_packet_length) and (pkt_len_violation_i = '0') then
508 terminate_pkt_1 <= '1';
513 process (pp_clock)
begin
515 if rising_edge (pp_clock) then
516 terminate_pkt_2 <= terminate_pkt_1;
520 terminate_pkt <= terminate_pkt_1 or terminate_pkt_2;
525 process (aurora_user_clk)
begin
526 if rising_edge (aurora_user_clk) then
527 if (reset = '1') or (terminate_pkt_flag = '1') then
528 terminate_pkt_flag <= '0';
529 elsif (pkt_count = max_packet_length) then
530 terminate_pkt_flag <= '1';
547 pulse_in => terminate_pkt,
549 pulse_out => pkt_len_violation_i
552 pkt_len_violation <= pkt_len_violation_i;
563 process (aurora_user_clk, pkt_len_violation_i)
begin
564 if pkt_len_violation_i = '1' then
568 elsif rising_edge (aurora_user_clk) then
569 valid_low_1 <= not s_axis_tvalid;
570 valid_low_2 <= valid_low_1;
571 valid_low_3 <= valid_low_2;
575 valid_low <= valid_low_1 and valid_low_2 and valid_low_3;
579 process (aurora_user_clk, pkt_len_violation_i)
begin
580 if pkt_len_violation_i = '1' then
582 elsif rising_edge (aurora_user_clk) then
583 if (valid_low = '1') then
586 pipe_lock <= pipe_lock;