23 use IEEE.STD_LOGIC_1164.
ALL;
24 use IEEE.STD_LOGIC_unsigned.
ALL;
25 use IEEE.NUMERIC_STD.
ALL;
28 use work.ipbus_decode_L1CaloHubRodL1idCaptureRegisters.
all;
43 ipb_clk : in std_logic;
44 ipb_rst : in std_logic;
46 ipb_out : out ipb_rbus;
47 pp_clock : in STD_LOGIC;
49 s_tvalid : in STD_LOGIC;
50 s_tlast : in STD_LOGIC;
51 idle_state : in STD_LOGIC;
52 l1id_ttc : in STD_LOGIC_VECTOR(31 downto 0);
53 l1id_pkt : in STD_LOGIC_VECTOR(31 downto 0);
54 current_chan : in STD_LOGIC_VECTOR(7 downto 0);
55 first_chan : in STD_LOGIC_VECTOR(4 downto 0);
56 poll_chan : in STD_LOGIC
62 signal ipbw: ipb_wbus_array(N_SLAVES - 1 downto 0);
63 signal ipbr: ipb_rbus_array(N_SLAVES - 1 downto 0);
64 signal l1id_ttc_prior_0 : STD_LOGIC_VECTOR(31 downto 0);
65 signal l1id_ttc_prior_1 : STD_LOGIC_VECTOR(31 downto 0);
66 signal l1id_ttc_prior_2 : STD_LOGIC_VECTOR(31 downto 0);
67 signal l1id_ttc_prior_n : STD_LOGIC_VECTOR(31 downto 0);
68 signal l1id_ttc_prior_m : STD_LOGIC_VECTOR(31 downto 0);
69 signal l1id_ttc_after_0 : STD_LOGIC_VECTOR(31 downto 0);
70 signal l1id_ttc_after_1 : STD_LOGIC_VECTOR(31 downto 0);
71 signal l1id_ttc_after_2 : STD_LOGIC_VECTOR(31 downto 0);
72 signal l1id_ttc_mismatch : STD_LOGIC_VECTOR(31 downto 0);
74 signal l1id_pkt_prior_0 : STD_LOGIC_VECTOR(31 downto 0);
75 signal l1id_pkt_prior_1 : STD_LOGIC_VECTOR(31 downto 0);
76 signal l1id_pkt_prior_2 : STD_LOGIC_VECTOR(31 downto 0);
77 signal l1id_pkt_after_0 : STD_LOGIC_VECTOR(31 downto 0);
78 signal l1id_pkt_after_1 : STD_LOGIC_VECTOR(31 downto 0);
79 signal l1id_pkt_after_2 : STD_LOGIC_VECTOR(31 downto 0);
80 signal l1id_pkt_mismatch : STD_LOGIC_VECTOR(31 downto 0);
81 signal channel : STD_LOGIC_VECTOR(7 downto 0);
82 signal post_capture : STD_LOGIC;
83 signal postcapture_count : STD_LOGIC_VECTOR(1 downto 0);
85 signal clear : std_logic;
86 signal clear_s : std_logic;
87 signal clear_s_del : std_logic;
88 signal armed : std_logic;
89 signal armed_s : std_logic;
90 signal armed_s_del : std_logic;
91 signal armed_pulse : std_logic;
92 signal armed_stat : std_logic;
93 signal l_header_marker : std_logic;
94 signal l1id_capture_control : std_logic_vector(31 downto 0);
95 signal tvalid_prev : std_logic;
96 signal sample : std_logic;
97 signal l1id_capture_status : std_logic_vector(31 downto 0);
98 signal l1id_capture_control_reg_stb : std_logic;
99 signal l1id_capture_control_reg_rst : std_logic;
100 signal l1id_eq : std_logic;
101 signal triggered : std_logic;
118 no_sim_regs: if SIM=0 generate
119 fabric:
entity work.ipbus_fabric_sel
122 SEL_WIDTH => IPBUS_SEL_WIDTH
)
127 sel => ipbus_sel_L1CaloHubRodL1IDCaptureRegisters
(ipb_in.ipb_addr
),
128 ipb_to_slaves => ipbw,
129 ipb_from_slaves => ipbr
135 L1ID_Capture_Control_reg:
entity work.ipbus_reg_v
138 reset => l1id_capture_control_reg_rst,
139 ipbus_in => ipbw
(N_SLV_L1ID_CAPTURE_CONTROL
),
140 ipbus_out => ipbr
(N_SLV_L1ID_CAPTURE_CONTROL
),
141 stb
(0) => l1id_capture_control_reg_stb,
142 q
(0) => l1id_capture_control
144 l1id_capture_control_reg_rst <= l1id_capture_control_reg_stb or ipb_rst;
146 L1ID_Capture_status_reg:
entity work.ipbus_syncreg_v
154 ipb_in => ipbw
(N_SLV_L1ID_CAPTURE_STATUS
),
155 ipb_out => ipbr
(N_SLV_L1ID_CAPTURE_STATUS
),
157 d
(0) => l1id_capture_status,
158 qmask =>
(others =>
(others => '1'
)),
164 pkt_miss_reg:
entity work.ipbus_syncreg_v
172 ipb_in => ipbw
(N_SLV_PKT_MISS
),
173 ipb_out => ipbr
(N_SLV_PKT_MISS
),
175 d
(0) => l1id_pkt_mismatch,
176 qmask =>
(others =>
(others => '1'
)),
181 ttc_miss_reg:
entity work.ipbus_syncreg_v
189 ipb_in => ipbw
(N_SLV_TTC_MISS
),
190 ipb_out => ipbr
(N_SLV_TTC_MISS
),
192 d
(0) => l1id_ttc_mismatch,
193 qmask =>
(others =>
(others => '1'
)),
199 ttc_last_reg:
entity work.ipbus_syncreg_v
207 ipb_in => ipbw
(N_SLV_TTC_LAST
),
208 ipb_out => ipbr
(N_SLV_TTC_LAST
),
210 d
(0) => l1id_ttc_prior_n,
211 qmask =>
(others =>
(others => '1'
)),
216 ttc_penultimate_reg:
entity work.ipbus_syncreg_v
224 ipb_in => ipbw
(N_SLV_TTC_PENULTIMATE
),
225 ipb_out => ipbr
(N_SLV_TTC_PENULTIMATE
),
227 d
(0) => l1id_ttc_prior_m,
228 qmask =>
(others =>
(others => '1'
)),
234 end generate no_sim_regs;
238 l1id_eq <= '1' when l1ID_ttc = l1ID_pkt else '0';
240 l1id_capture_status <= x"00000" & channel & "00" & triggered & armed_stat;
254 process(pp_clock)
begin
255 if rising_edge (pp_clock) then
256 clear_s <= l1id_capture_control(1);
257 clear_s_del <= clear_s;
261 clear <= clear_s_del and not clear_s;
263 process(pp_clock)
begin
264 if rising_edge (pp_clock) then
265 armed_s <= l1id_capture_control(0);
266 armed_s_del <= armed_s;
270 armed_pulse <= armed_s_del and not armed_s;
272 process(pp_clock)
begin
273 if rising_edge (pp_clock) then
274 if (armed_pulse = '1') then
276 elsif (ipb_rst = '1') or (triggered = '1') or (clear = '1') or (reset = '1') then
279 armed_stat <= armed_stat;
304 process (pp_clock)
begin
305 if rising_edge (pp_clock) then
306 if (ipb_rst = '1') or (clear = '1') or (reset = '1') or (armed_pulse = '1') then
308 l1id_pkt_mismatch <= (others=> '0');
309 l1id_ttc_mismatch <= (others=> '0');
310 channel <= (others=> '0');
311 elsif (sample = '1') and (l1id_eq = '0') and (armed_stat = '1') then
312 channel <= current_chan;
314 l1id_pkt_mismatch <= l1id_pkt;
315 l1id_ttc_mismatch <= l1id_ttc;
316 l1id_ttc_prior_n <= l1id_ttc_prior_0;
317 l1id_ttc_prior_m <= l1id_ttc_prior_1;
321 triggered <= triggered;
322 l1id_pkt_mismatch <= l1id_pkt_mismatch;
323 l1id_ttc_mismatch <= l1id_ttc_mismatch;
328 process (pp_clock)
begin
329 if rising_edge (pp_clock) then
330 if (ipb_rst = '1') or (clear = '1') or (reset = '1') then
331 l1id_ttc_prior_0 <= (others=> '0');
332 l1id_ttc_prior_1 <= (others=> '0');
335 elsif (sample = '1') and (current_chan = first_chan) then
336 l1id_ttc_prior_0 <= l1id_ttc;
337 l1id_ttc_prior_1 <= l1id_ttc_prior_0;
339 l1id_ttc_prior_0 <= l1id_ttc_prior_0;
340 l1id_ttc_prior_1 <= l1id_ttc_prior_1;