eFEX firmware  1.7.3
ATLAS l1-calo - electron and tau feature extraction firmware for eFEX boards

Back to eFEX documentation
bcn_l1a_valid_checker.vhd
Go to the documentation of this file.
1 
9 
10 library ieee;
11 use ieee.std_logic_1164.all;
12 use ieee.numeric_std.all;
13 
14 library TOB_rdout_lib;
15 
16 library infrastructure_lib;
17 
20 GENERIC(
21  ILA_ENABLED : std_logic := '0'
22 );
23 port(
24  clk_40_i : in std_logic;
25  rst_i : in std_logic; -- resets the counters
26 
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;
32 
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')
42  );
44 
46 architecture rtl of bcn_l1a_valid_checker is
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;
50 
51  COMPONENT ila_1
52  PORT (
53  clk : IN STD_LOGIC;
54  probe0 : IN STD_LOGIC_VECTOR(34 DOWNTO 0)
55  );
56  END COMPONENT;
57 begin
58 
59  ttc_parity_calc : entity infrastructure_lib.ttc_parity
60  port map (
61  ttc_data => l1a_id_ext_i,
62  parity12 => parity12,
63  parity32 => parity32
64  );
65 
66 -- next L1ID block: take incoming l1a_id_ext_i if parity OK, otherwise update local cache
67  l1id_next_block: process(clk_40_i)
68  variable l1id_local : unsigned(23 downto 0);
69  variable ecrid_local : unsigned(7 downto 0);
70  begin
71  if rising_edge(clk_40_i) then
72  if (rst_i = '1') then
73  ecrid_local := (Others => '0');
74  l1id_local := (Others => '0');
75  else
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));
80  end if;
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');
85  else
86  ecrid_local := ecrid_local + 1;
87  end if;
88  l1id_local := (Others => '0');
89  end if;
90  end if;
91  l1id_next <= std_logic_vector(ecrid_local & l1id_local);
92  end if;
93  end process l1id_next_block;
94 
95  -- makes sure relevant outputs are going to the ila
96  debug_output : process (clk_40_i)
97  variable parity_err_bcn, parity_err_l1id : std_logic := '0'; -- Will go high if it spots an error
98  variable mismatch_bcn, mismatch_l1id : std_logic := '0'; -- Will go high if it spots an error
99  variable err_history: std_logic_vector(31 downto 0) := (others => '0');
100  begin
101  if rising_edge(clk_40_i) then
102  if (rst_i = '1') then
103  parity_err_bcn := '0';
104  parity_err_l1id := '0';
105  mismatch_bcn := '0';
106  mismatch_l1id := '0';
107  err_history := (Others => '0');
108 
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');
114  else
115  -- check incoming signal against expectations
116  parity_err_bcn := '0';
117  parity_err_l1id := '0';
118  mismatch_bcn := '0';
119  mismatch_l1id := '0';
120  if (l1a_in_i = '0') then
121  if (ttc_parity_i /= parity12) then
122  parity_err_bcn := '1';
123  end if;
124  if (l1a_id_ext_i(11 downto 0) /= bcn_id_lcl_i) then
125  mismatch_bcn := '1';
126  end if;
127  else
128  if (ttc_parity_i /= parity32) then
129  parity_err_l1id := '1';
130  end if;
131  if (l1a_id_ext_i /= l1id_next) then
132  mismatch_l1id := '1';
133  end if;
134  end if;
135 
136  -- manages the rest of the output signals --
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;
146  end if;
147 
148  -- manages what output is going to the ila probe0 --
149  if l1a_in_i = '1' then -- if l1a_in_i is active, l1a_id_ext_i is transmitting L1A ID, so examine that
150  -- sets probe output to look at L1A ID, as it is transmitted whilst l1a_in_i = '1'
151  probe_o <= parity_err_l1id & mismatch_l1id & l1a_in_i & l1a_id_ext_i;
152  else -- when l1a_in is not active, l1a_id_ext_i is transmitting BCN ID, so examine that
153  -- sets probe output to look at BCN ID, as it is transmitted whilst l1a_in_i = '0'
154  probe_o <= parity_err_bcn & mismatch_bcn & l1a_in_i & "0000" & bcn_id_lcl_i & "0000" & l1a_id_ext_i(11 downto 0);
155  end if;
156  end if;
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;
162  end if;
163  end process debug_output;
164 
165  l1id_parity_err_cntr_block : entity TOB_rdout_lib.cntr_generic
166  generic map (width => 32, WRAPAROUND => False)
167  port map (
168  CE => l1id_err_trigger,
169  CLK => clk_40_i,
170  RST => rst_i,
171  Q => l1id_parity_err_cntr_o);
172 
173  l1id_mismatch_cntr_block : entity TOB_rdout_lib.cntr_generic
174  generic map (width => 32, WRAPAROUND => False)
175  port map (
176  CE => l1id_mismatch_trigger,
177  CLK => clk_40_i,
178  RST => rst_i,
179  Q => l1id_mismatch_cntr_o);
180 
181  bcn_parity_err_cntr_block : entity TOB_rdout_lib.cntr_generic
182  generic map (width => 32, WRAPAROUND => False)
183  port map (
184  CE => bcn_err_trigger,
185  CLK => clk_40_i,
186  RST => rst_i,
187  Q => bcn_parity_err_cntr_o);
188 
189  bcn_mismatch_cntr_block : entity TOB_rdout_lib.cntr_generic
190  generic map (width => 32, WRAPAROUND => False)
191  port map (
192  CE => bcn_mismatch_trigger,
193  CLK => clk_40_i,
194  RST => rst_i,
195  Q => bcn_mismatch_cntr_o);
196 
197 ila_block : if (ILA_ENABLED = '1') generate
198  debug_bcn_l1a_parity : ila_1
199  PORT MAP (
200  clk => clk_40_i,
201  probe0 => probe_o
202  );
203 end generate;
204 
205 end rtl;
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
Definition: ttc_parity.vhd:13