2 use ieee.std_logic_1164.
all;
3 use ieee.numeric_std.
all;
4 use ieee.std_logic_unsigned.
all;
5 use ieee.std_logic_misc.
all;
7 use unisim.vcomponents.
all;
33 T_DELAY_SELF_TRIG : := 4;
34 FORCE_TRIG_BUF_DEPTH_g : := 5;
35 FORCE_TRIG_WIDTH_g: := 8;
36 POST_MUX_TRIG_BIT_BUFF_DEPTH_g : := 3 44 trgtag : in (31 downto 0) := (others=>'0');
45 ctime : in (26 downto 0) := (others=>'0');
49 vectrgbits : in tb_vec_type := (others => (others => '0'));
-- array of trigger bits from TargetX 53 qt_fifo_dout : out (17 downto 0) := (others=>'0');
54 qt_fifo_empty : out := '1';
55 qt_fifo_evt_rdy : out := '0';
57 ScrodConfig : in KlmScrodConfigType := KlmScrodConfigZero;
66 scalers_ch_arr : out slv32(9 downto 0) := (others => (others => '0'));
-- one scaler per ASIC for given channel number 69 tbfifo_err_cnt : out slv16(9 downto 0);
-- counter for trigger bits fifo overflows 70 trg_cnt : out (15 downto 0) := (others => '0');
-- number of triggers received 71 full_proc_cnt : out (15 downto 0) := (others => '0');
-- number of triggers processed 72 simp_proc_cnt : out (15 downto 0) := (others => '0');
-- number of triggers processed 73 null_proc_cnt : out (15 downto 0) := (others => '0');
-- number of triggers processed 74 -- occ_err_cnt : out std_logic_vector(15 downto 0) := (others => '0'); -- number of hits overflow counter 76 wave_stat : out waveform_stat_t;
77 debug_wave_we : out (1 downto 0) := (others => '0');
78 debug_wave_din : out slv12(1 downto 0) := (others => (others => '0'));
79 SPS_hist_rd_data : out slv16(1 downto 0) := (others => (others => '0'));
82 -- ctime_max : out std_logic_vector(26 downto 0) := (others => '1'); -- where ctime acually wraps around 85 RAM_IO : inout (7 downto 0) := (others => '0');
88 RAM_ADDR : out (21 downto 0) := (others => '1');
92 BUSA_DO : in (14 downto 0) := (others => '0');
93 BUSA_RAMP : out := '0';
94 BUSA_CLR : out := '0';
95 BUSA_RD_COLSEL : out (5 downto 0) := (others => '0');
96 BUSA_RD_ENA : out := '0';
97 BUSA_RD_ROWSEL : out (2 downto 0) := (others => '0');
98 BUSA_SAMPLESEL : out (4 downto 0) := (others => '0');
99 BUSA_SR_CLEAR : out := '0';
100 BUSA_SR_SEL : out := '0';
105 BUSB_DO : in (14 downto 0) := (others => '0');
106 BUSB_RAMP : out := '0';
107 BUSB_CLR : out := '0';
108 BUSB_RD_COLSEL : out (5 downto 0) := (others => '0');
109 BUSB_RD_ENA : out := '0';
110 BUSB_RD_ROWSEL : out (2 downto 0) := (others => '0');
111 BUSB_SAMPLESEL : out (4 downto 0) := (others => '0');
112 BUSB_SR_CLEAR : out := '0';
113 BUSB_SR_SEL : out := '0';
118 WR2_ENA : out (9 downto 0);
119 SSTIN_N : out (9 downto 0);
120 SSTIN_P : out (9 downto 0);
121 -- TDC_DONE : in std_logic_vector(9 downto 0) := (others => '0'); 122 SAMPLESEL_ANY : out (9 downto 0) := (others => '0');
123 SR_CLOCK : out (9 downto 0) := (others => '0');
134 -- SYNCHRONOUS SIGNALS BY PROCESS WHICH DRIVES THEM 137 signal i_trgtag : (4 downto 0) := (others => '0');
138 signal i_ctime : (26 downto 0) := (others => '0');
139 signal i_ScrodConfig : KlmScrodConfigType := KlmScrodConfigZero;
140 signal i_scalers_reset : := '0';
144 constant ctime_zero : (26 downto 0) := (others => '0');
148 signal sampling_lgc_rst : := '0';
149 signal tb_proc_rst : := '0';
150 signal ro_trg_rst : := '0';
154 signal i_vectrgbits : arr_tb_vec_type(POST_MUX_TRIG_BIT_BUFF_DEPTH_g - 1 downto 0) := (others=>(others => (others => '0')));
155 signal force_trig_sr : (FORCE_TRIG_BUF_DEPTH_g + FORCE_TRIG_WIDTH_g - 1 downto 0) := (others=>'0');
156 signal use_force_trig_sr : (FORCE_TRIG_BUF_DEPTH_g - 1 downto 0) := (others=>'0');
161 signal self_trig : := '0';
165 signal ii_trgtag : (4 downto 0) := (others => '0');
166 signal ii_ctime : (26 downto 0) := (others => '0');
170 -- SIGNALS DRIVEN BY INSTANTIATED ENTITIES 171 -- TrigBitsProc_10x_i : 172 signal trig : trig_info_type_0 := null_trig_info_t0;
173 signal self_trig_asic : (9 downto 0) := (others => '0');
174 signal i_sca_busy : (9 downto 0) := (others => '0');
177 -- WaveformReadout_i : 178 signal ro_busy_full : := '0';
179 signal i_trg_proc_full_cnt : (15 downto 0) := (others => '0');
180 signal i_evt_rdy_full : := '0';
181 signal ana_wr_ena_mask : TARGETX_analong_wr_ena_mask_t := null_TX_ana_wr_ena_mask;
185 signal localtrg : := '0';
186 signal ctime_trg : (26 downto 0) := (others => '0');
188 -- TargetX_SamplingLgc_i : 189 signal cur_win : (8 downto 0) := (others => '0');
192 -- ASYNCHRONOUSLY DRIVEN SIGNALS 200 --------------------- ASYNCHRONOUS LOGIC --------------------------------------------- 202 busy <= ro_busy_full;
203 trig.ctime <= ctime_trg(15 downto 0);
208 --------------------- SYNCHRONOUS LOGIC --------------------------------------------- 209 latch_input_data:
process(clk,
trg, trgtag, ctime, ScrodConfig,
scalers_reset)
211 if rising_edge(clk) then 213 i_trgtag <= trgtag(4 downto 0);
215 i_ScrodConfig <= ScrodConfig;
222 determine_where_ctime_wraps_around:
process(clk, rst, ctime, i_ctime,
i_ctime_max)
224 if rising_edge(clk) then 228 if ctime = ctime_zero and i_ctime > ctime_zero then 231 -- ctime_max <= i_ctime_max; 238 buffer_the_reset_signal:
process(clk, rst)
240 if rising_edge(clk) then 242 sampling_lgc_rst <= rst;
249 TB_mode_mux:
process(clk,
vectrgbits, force_trig,
250 i_ScrodConfig.wave_config.use_force_trig,
251 i_ScrodConfig.wave_config.force_trig_bits,
252 i_ScrodConfig.wave_config.force_trig_asic,
253 force_trig_sr, use_force_trig_sr)
255 if rising_edge(clk) then 256 if force_trig = '1' then 257 force_trig_sr(force_trig_sr'left downto FORCE_TRIG_WIDTH_g) <= (others=>'0');
258 force_trig_sr(FORCE_TRIG_WIDTH_g - 1 downto 0) <= (others=>'1');
260 force_trig_sr <= force_trig_sr(force_trig_sr'left - 1 downto 0) & '0';
262 use_force_trig_sr <= use_force_trig_sr(use_force_trig_sr'left - 1 downto 0) & i_ScrodConfig.wave_config.use_force_trig;
263 i_vectrgbits(i_vectrgbits'left downto 1) <= i_vectrgbits(i_vectrgbits'left - 1 downto 0);
264 if use_force_trig_sr(use_force_trig_sr'left) = '1' then 265 if force_trig_sr(force_trig_sr'left) = '1' then 266 i_vectrgbits(0)(i_ScrodConfig.wave_config.force_trig_asic(0) + 1) <= i_ScrodConfig.wave_config.force_trig_bits;
267 i_vectrgbits(0)(i_ScrodConfig.wave_config.force_trig_asic(1) + 6) <= i_ScrodConfig.wave_config.force_trig_bits;
269 i_vectrgbits(0) <= (others=>(others=>'0'));
279 self_trig_fsm:
process(clk, self_trig_asic)
280 variable count : range 0 to T_DELAY_SELF_TRIG := 0;
282 if rising_edge(clk) then 283 case self_trig_state is 287 if or_reduce(self_trig_asic) = '1' then 288 self_trig_state <= TRIGGERING;
292 if count = T_DELAY_SELF_TRIG then 293 self_trig <= not i_ScrodConfig.wave_config.use_ftsw_trig;
294 self_trig_state <= IDLE;
297 self_trig_state <= TRIGGERING;
306 KLMReadoutTrg_trig_mode_multiplexer:
process(clk, i_ScrodConfig.wave_config.use_ftsw_trig,
307 i_trg, i_ctime, i_trgtag, self_trig)
309 if rising_edge(clk) then 312 ii_trgtag <= i_trgtag;
313 if i_ScrodConfig.wave_config.use_ftsw_trig = '1' then 324 --------------------- MODULE INSTANTIATIONS --------------------------------------------- 326 TrigBitsProc_10x_i: for iAsic in 1 to 10 generate 333 tb => i_vectrgbits
(i_vectrgbits'left
)(iAsic
),
337 -- ro_busy => ro_busy_full, 339 localtrg => localtrg,
340 ctime_trg => ctime_trg,
342 -- hit_ren => i_hit_ren(iAsic-1), -- hit read enable 343 sca_rst => i_scalers_reset,
344 sca_cnt_max => i_ScrodConfig.TBScalersPeriod,
347 asic_on => i_ScrodConfig.TxProcMask
(iAsic-
1),
348 lookback => i_ScrodConfig.TBLookBack,
349 lookback_width => i_ScrodConfig.TBLookBackWidth,
353 hit_bits => trig.bits
(iAsic-
1),
354 hit_win => trig.wr_time
(iAsic-
1),
355 is_hit => trig.mask
(iAsic-
1),
356 -- tbfifo_drdy => tbfifo_drdy(iAsic-1), 357 self_trig => self_trig_asic
(iAsic-
1),
360 sca_busy => i_sca_busy
(iAsic-
1),
361 -- fifo_cnt => i_tbfifo_cnt(iAsic-1), 362 scalers_cnt => scalers_ch_arr
(iAsic-
1),
363 fifo_full_cnt => tbfifo_err_cnt
(iAsic-
1) 371 busy => ro_busy_full,
374 ana_wr_ena_mask => ana_wr_ena_mask,
375 localtrg => localtrg,
376 force_trig => force_trig,
377 sps_reset => sps_reset,
380 qt_fifo_dout => qt_fifo_dout,
381 qt_fifo_empty => qt_fifo_empty,
383 qt_fifo_evt_rdy => qt_fifo_evt_rdy,
384 full_proc_cnt => full_proc_cnt,
385 simp_proc_cnt => simp_proc_cnt,
386 null_proc_cnt => null_proc_cnt,
390 RAM_ADDR => RAM_ADDR,
392 BUSA_RAMP => BUSA_RAMP,
393 BUSA_CLR => BUSA_CLR,
394 BUSA_RD_COLSEL => BUSA_RD_COLSEL,
395 BUSA_RD_ENA => BUSA_RD_ENA,
396 BUSA_RD_ROWSEL => BUSA_RD_ROWSEL,
397 BUSA_SAMPLESEL => BUSA_SAMPLESEL,
398 BUSA_SR_CLEAR => BUSA_SR_CLEAR,
399 BUSA_SR_SEL => BUSA_SR_SEL,
401 BUSB_RAMP => BUSB_RAMP,
402 BUSB_CLR => BUSB_CLR,
403 BUSB_RD_COLSEL => BUSB_RD_COLSEL,
404 BUSB_RD_ENA => BUSB_RD_ENA,
405 BUSB_RD_ROWSEL => BUSB_RD_ROWSEL,
406 BUSB_SAMPLESEL => BUSB_SAMPLESEL,
407 BUSB_SR_CLEAR => BUSB_SR_CLEAR,
408 BUSB_SR_SEL => BUSB_SR_SEL,
409 SAMPLESEL_ANY => SAMPLESEL_ANY,
410 SR_CLOCK => SR_CLOCK,
411 wave_config => i_ScrodConfig.wave_config,
412 wave_stat => wave_stat,
413 debug_wave_we => debug_wave_we,
414 debug_wave_din => debug_wave_din,
415 SPS_hist_rd_data => SPS_hist_rd_data
427 readout_busy => ro_busy_full,
429 localtrg => localtrg,
430 ctime_trg => ctime_trg,
431 -- trgtag_trg => trgtag_trg, 441 reset => sampling_lgc_rst,
442 ana_wr_ena_mask => ana_wr_ena_mask,
out BUSB_WR_ADDRCLRstd_logic
BusB signals.
std_logic := '0' ii_trg
KLMReadoutTrg_trig_mode_multiplexer:
out qt_fifo_err_cntstd_logic_vector( 15 downto 0)
tbfifo_cnt : out slv16(9 downto 0) := (others => (others => '0')); – debug
in qt_fifo_rd_enstd_logic := '0'
daq data ports
array(natural range <> ) of tb_vec_type arr_tb_vec_type
TB_mode_mux:
out BUSA_WR_ADDRCLRstd_logic
BusA signals.
in trgstd_logic := '0'
b2tt signals
in vectrgbitstb_vec_type :=( others =>( others => '0'))
trigger bits from all asics
out scalers_busystd_logic
status ports TODO : pack it into a record e.g. ReadoutStatus
(IDLE,TRIGGERING) SELF_TRIG_STATE_t
self_trig_fsm:
std_logic_vector( 26 downto 0) :=( others => '1') i_ctime_max
determine_where_ctime_wraps_around:
in scalers_resetstd_logic := '0'
reset scalers for trigger bits
std_logic := '0' i_trg
latch_input_data:
std_logic := '0' wave_proc_rst
buffer_the_reset_signal:
inout RAM_IOstd_logic_vector( 7 downto 0) :=( others => '0')
debug FIXME : remove pedestal RAM access
out WR1_ENAstd_logic_vector( 9 downto 0)
TargetX DC signals.