11 use ieee.std_logic_1164.
all;
12 use ieee.numeric_std.
all;
14 library TOB_rdout_lib;
16 library infrastructure_lib;
21 ILA_ENABLED : std_logic := '0'
24 clk_40_i : in std_logic;
27 l1a_id_ext_i : in std_logic_vector(31 downto 0);
28 l1a_in_i : in std_logic;
29 ecr_in_i : in std_logic;
30 bcn_id_lcl_i : in std_logic_vector(11 downto 0);
31 ttc_parity_i : in std_logic;
33 err_history_o : out std_logic_vector(31 downto 0) := (others => '0');
34 l1a_id_good_o : out std_logic_vector(31 downto 0) := (others => '0');
35 l1a_id_err_o : out std_logic_vector(31 downto 0) := (others => '0');
36 l1a_id_expected_o : out std_logic_vector(31 downto 0) := (others => '0');
37 bcn_err_expected_o : out std_logic_vector(31 downto 0) := (others => '0');
38 l1id_parity_err_cntr_o : out std_logic_vector(31 downto 0) := (others => '0');
39 l1id_mismatch_cntr_o : out std_logic_vector(31 downto 0) := (others => '0');
40 bcn_parity_err_cntr_o : out std_logic_vector(31 downto 0) := (others => '0');
41 bcn_mismatch_cntr_o : out std_logic_vector(31 downto 0) := (others => '0')
47 signal probe_o : std_logic_vector(34 downto 0) := (others=>'0');
48 signal l1id_next: std_logic_vector(31 downto 0) := (others => '0');
49 signal bcn_err_trigger, bcn_mismatch_trigger, l1id_err_trigger, l1id_mismatch_trigger, parity12, parity32: std_logic;
54 probe0 :
IN STD_LOGIC_VECTOR(
34 DOWNTO 0)
59 ttc_parity_calc :
entity infrastructure_lib.
ttc_parity
61 ttc_data => l1a_id_ext_i,
67 l1id_next_block:
process(clk_40_i)
68 variable l1id_local : unsigned(23 downto 0);
69 variable ecrid_local : unsigned(7 downto 0);
71 if rising_edge(clk_40_i) then
73 ecrid_local := (Others => '0');
74 l1id_local := (Others => '0');
76 if (l1a_in_i = '1') then
77 if (ttc_parity_i = parity32) then
78 ecrid_local := unsigned(l1a_id_ext_i(31 downto 24));
79 l1id_local := unsigned(l1a_id_ext_i(23 downto 0));
81 l1id_local := l1id_local + 1;
82 elsif (ecr_in_i = '1') then
83 if (ecrid_local = x"FF") then
84 ecrid_local := (Others => '0');
86 ecrid_local := ecrid_local + 1;
88 l1id_local := (Others => '0');
91 l1id_next <= std_logic_vector(ecrid_local & l1id_local);
93 end process l1id_next_block;
96 debug_output :
process (clk_40_i)
97 variable parity_err_bcn, parity_err_l1id : std_logic := '0';
98 variable mismatch_bcn, mismatch_l1id : std_logic := '0';
99 variable err_history: std_logic_vector(31 downto 0) := (others => '0');
101 if rising_edge(clk_40_i) then
102 if (rst_i = '1') then
103 parity_err_bcn := '0';
104 parity_err_l1id := '0';
106 mismatch_l1id := '0';
107 err_history := (Others => '0');
109 probe_o <= (Others => '0');
110 l1a_id_good_o <= (Others => '0');
111 l1a_id_err_o <= (Others => '0');
112 l1a_id_expected_o <= (Others => '0');
113 bcn_err_expected_o <= (Others => '0');
116 parity_err_bcn := '0';
117 parity_err_l1id := '0';
119 mismatch_l1id := '0';
120 if (l1a_in_i = '0') then
121 if (ttc_parity_i /= parity12) then
122 parity_err_bcn := '1';
124 if (l1a_id_ext_i(11 downto 0) /= bcn_id_lcl_i) then
128 if (ttc_parity_i /= parity32) then
129 parity_err_l1id := '1';
131 if (l1a_id_ext_i /= l1id_next) then
132 mismatch_l1id := '1';
137 if (parity_err_bcn = '1') or (mismatch_bcn = '1') then
138 err_history := err_history(27 downto 0) & parity_err_bcn & mismatch_bcn & "00";
139 bcn_err_expected_o <= parity_err_bcn & mismatch_bcn & "00" & bcn_id_lcl_i & "0000" & l1a_id_ext_i(11 downto 0);
140 elsif (parity_err_l1id = '1') or (mismatch_l1id = '1') then
141 err_history := err_history(27 downto 0) & "00" & parity_err_l1id & mismatch_l1id;
142 l1a_id_err_o <= l1a_id_ext_i;
143 l1a_id_expected_o <= l1id_next;
144 elsif (l1a_in_i = '1') then
145 l1a_id_good_o <= l1a_id_ext_i;
149 if l1a_in_i = '1' then
151 probe_o <= parity_err_l1id & mismatch_l1id & l1a_in_i & l1a_id_ext_i;
154 probe_o <= parity_err_bcn & mismatch_bcn & l1a_in_i & "0000" & bcn_id_lcl_i & "0000" & l1a_id_ext_i(11 downto 0);
157 bcn_err_trigger <= parity_err_bcn;
158 bcn_mismatch_trigger <= mismatch_bcn;
159 l1id_err_trigger <= parity_err_l1id;
160 l1id_mismatch_trigger <= mismatch_l1id;
161 err_history_o <= err_history;
163 end process debug_output;
165 l1id_parity_err_cntr_block :
entity TOB_rdout_lib.
cntr_generic
166 generic map (width =>
32, WRAPAROUND => False
)
168 CE => l1id_err_trigger,
171 Q => l1id_parity_err_cntr_o
);
173 l1id_mismatch_cntr_block :
entity TOB_rdout_lib.
cntr_generic
174 generic map (width =>
32, WRAPAROUND => False
)
176 CE => l1id_mismatch_trigger,
179 Q => l1id_mismatch_cntr_o
);
181 bcn_parity_err_cntr_block :
entity TOB_rdout_lib.
cntr_generic
182 generic map (width =>
32, WRAPAROUND => False
)
184 CE => bcn_err_trigger,
187 Q => bcn_parity_err_cntr_o
);
189 bcn_mismatch_cntr_block :
entity TOB_rdout_lib.
cntr_generic
190 generic map (width =>
32, WRAPAROUND => False
)
192 CE => bcn_mismatch_trigger,
195 Q => bcn_mismatch_cntr_o
);
197 ila_block : if (ILA_ENABLED = '1') generate
198 debug_bcn_l1a_parity : ila_1
Observes BCN ID, L1A ID, and parity bits.
Observes BCN ID, L1A ID, and parity bits.
Generic Counter for process FPGA.
in CLK STD_LOGIC
Clock signal input.
in CE STD_LOGIC
Enable signal input.
out Q STD_LOGIC_VECTOR( width- 1 downto 0)
Counter Output signal.
in RST STD_LOGIC
Reset signal input.
generate parity for data going from Control FPGA to Processors