2 use IEEE.STD_LOGIC_1164.
ALL;
3 use IEEE.NUMERIC_STD.
ALL;
4 use IEEE.STD_LOGIC_MISC.
ALL;
5 use IEEE.STD_LOGIC_UNSIGNED.
ALL;
7 use unisim.vcomponents.
all;
9 use unimacro.vcomponents.
all;
12 -- use work.conc_intfc_pkg.all; 13 -- use work.klm_scrod_pkg.all; 14 -- use work.tdc_pkg.all; 67 --1. For now, we shift out whole windows only, if we calculate a finer ROI, 68 --then we can perhaps shift out fewer samples to save time. 73 FORCE_TRIG_BUF_DEPTH_g : := 6;
74 TRG_BUFF_DEPTH_g : := 4;
75 TRIG_QUEUE_DEPTH_g : := 5;
76 TQ_PROG_FULL_THRESH_g : := 3;
77 CALC_ROI_LAG_g : := 2;
78 T_WAIT_2C_IF_QUEUE_FULL_g : := 31;
79 reset_buff_depth_g : := 10;
80 SLC_STAT_BUFF_DEPTH_g : := 4;
81 packet_type_g : (7 downto 0):= X"80";
-- marks scintillators hits for DataConcentrator 82 N_readout_samples_g : (7 downto 0) := "10000000";
-- 128 83 LAST_WINDOW_ADDRESS : (8 downto 0) := "111111111";
85 T_wait_busy_to_come_up_g : := 31;
86 FineLookback_win_g : (8 downto 0) := "000000001";
87 max_proc_time_g : (15 downto 0) := "0011000110011100" -- 100us 93 b2tt_runreset : in := '0';
94 trig : in trig_info_type_0 := null_trig_info_t0;
96 -- signals with SamplingLgc 97 ana_wr_ena_mask : out TARGETX_analong_wr_ena_mask_t := null_TX_ana_wr_ena_mask;
99 -- signals with HitDataSerializer 100 localtrg :
in := '0';
101 force_trig : in := '0';
102 sps_reset : in := '0';
103 cur_win : in (8 downto 0);
105 -- nxt : in std_logic := '0'; 106 -- tbfifo_rden : out std_logic_vector(9 downto 0) := (others=>'0'); 109 qt_fifo_dout : out (17 downto 0) := (others=>'0');
110 qt_fifo_empty : out := '1';
111 qt_fifo_err_cnt : out (15 downto 0);
-- counter for daq data fifo overflows 112 qt_fifo_evt_rdy : out := '0';
113 full_proc_cnt : out (15 downto 0) := (others=>'0');
114 simp_proc_cnt : out (15 downto 0) := (others=>'0');
115 null_proc_cnt : out (15 downto 0) := (others=>'0');
117 -- pedestal RAM access 118 RAM_IO : inout (7 downto 0) := (others => '0');
119 RAM_WEb : out := '1';
120 RAM_OEb : out := '0';
121 RAM_ADDR : out (21 downto 0) := (others => '1');
124 BUSA_DO : in (14 downto 0) := (others => '0');
125 BUSA_RAMP : out := '0';
126 BUSA_CLR : out := '0';
127 BUSA_RD_COLSEL : out (5 downto 0) := (others => '0');
128 BUSA_RD_ENA : out := '0';
129 BUSA_RD_ROWSEL : out (2 downto 0) := (others => '0');
130 BUSA_SAMPLESEL : out (4 downto 0) := (others => '0');
131 BUSA_SR_CLEAR : out := '0';
132 BUSA_SR_SEL : out := '0';
135 BUSB_DO : in (14 downto 0) := (others => '0');
136 BUSB_RAMP : out := '0';
137 BUSB_CLR : out := '0';
138 BUSB_RD_COLSEL : out (5 downto 0) := (others => '0');
139 BUSB_RD_ENA : out := '0';
140 BUSB_RD_ROWSEL : out (2 downto 0) := (others => '0');
141 BUSB_SAMPLESEL : out (4 downto 0) := (others => '0');
142 BUSB_SR_CLEAR : out := '0';
143 BUSB_SR_SEL : out := '0';
145 -- TargetX DC signals 146 SAMPLESEL_ANY : out (9 downto 0) := (others => '0');
147 SR_CLOCK : out (9 downto 0) := (others => '0');
149 -- SCROD config registers 150 wave_config : in wave_config_t := default_wave_config;
153 wave_stat : out waveform_stat_t := wave_stat_0;
154 debug_wave_we : out (1 downto 0) := (others=>'0');
155 debug_wave_din : out slv12(1 downto 0) := (others=> (others=>'0'));
156 SPS_hist_rd_data : out slv16(1 downto 0) := (others=> (others=>'0')) 163 type trig_staging_FSM is (IDLE, WAIT_VALID, PROCESSING_REQ, WAIT_ACK);
164 type modify_sampling_mask_FSM is (IDLE, WAIT_DONE);
165 type ro_states is (IDLE, WAIT_RESET, CHECK_VALID, WAIT_WAVEFORM_READOUT, SEND_HITS, CHECK_DONE, STOP, SEND_SIMPLE);
168 --SYNCHRONOUS SIGNALS BY PROCESS WHICH DRIVES THEM 171 signal wave_stat_i : wave_stat_vec(SLC_STAT_BUFF_DEPTH_g - 1 downto 0) := (others => wave_stat_0);
175 signal wave_config_q2 : wave_config_t := default_wave_config;
176 signal wave_config_q3 : wave_config_t := default_wave_config;
177 signal wave_config_q4 : wave_config_t := default_wave_config;
178 signal wave_config_q5 : wave_config_t := default_wave_config;
179 signal wave_config_q6 : wave_config_t := default_wave_config;
183 signal busA_reset : := '0';
184 signal busB_reset : := '0';
188 signal either_bus_busy : := '0';
194 signal force_trig_sr : (FORCE_TRIG_BUF_DEPTH_g-1 downto 0) := (others => '0');
195 signal sps_reset_sr : (FORCE_TRIG_BUF_DEPTH_g-1 downto 0) := (others => '0');
199 signal i_N_readout_samples : (7 downto 0) := "00100000";
200 signal i_RAM_WEb : := '1';
201 signal i_RAM_din : (7 downto 0) := (others => '0');
202 signal RAM_din : (7 downto 0) := (others => '0');
203 signal RAM_rw : := '1';
207 signal SPS_measure_start : (1 downto 0) := "00";
211 signal starting_win_samp : slv14(9 downto 0) := (others => (others=>'0'));
212 signal first_dig_win : (8 downto 0) := (others=>'0');
213 signal last_dig_win : (8 downto 0) := (others=>'0');
214 signal asic_mask : (9 downto 0) := (others => '0');
219 signal calc_roi_ena : := '0';
220 signal trg_proc_busy : := '0';
221 signal mask_windows : := '0';
222 signal trig_queue_wr_ena : := '0';
225 signal wr_ptr : range 0 to TRIG_QUEUE_DEPTH_g - 1 := 0;
226 signal rd_ptr : range 0 to TRIG_QUEUE_DEPTH_g - 1 := 0;
227 signal wr_ptr_nxt : range 0 to TRIG_QUEUE_DEPTH_g - 1 := 0;
228 signal rd_ptr_nxt : range 0 to TRIG_QUEUE_DEPTH_g - 1 := 0;
229 signal queue_empty : := '1';
230 signal queue_above_thresh : := '0';
231 signal queue_full : := '0';
232 signal start_readout : := '0';
233 signal trig_queue : trig_queue_type(TRIG_QUEUE_DEPTH_g - 1 downto 0) := (others => null_trig_info_t1);
-- triggers on deck 234 signal trig_q0 : trig_info_type_1 := null_trig_info_t1;
238 signal mask_ack : := '0';
239 signal unmask_ack : := '0';
240 signal i_ana_wr_ena_mask : TARGETX_analong_wr_ena_mask_t := null_TX_ana_wr_ena_mask;
244 signal hit_bldr_fsm_busy : := '0';
245 signal ro_reset : := '0';
246 signal daq_axis_i : := '0';
247 signal daq_chan_i : (6 downto 0) := (others => '0');
248 signal daq_chan_base : (6 downto 0) := (others => '0');
250 signal simp : := '0';
251 signal le_time_i : (13 downto 0) := (others => '0');
252 signal peak_i : (11 downto 0) := (others => '0');
253 signal daq_start_ro : := '0';
254 signal i_full_proc_cnt : (15 downto 0) := (others => '0');
255 signal i_simp_proc_cnt : (15 downto 0) := (others => '0');
256 signal i_null_proc_cnt : (15 downto 0) := (others => '0');
257 signal daq_asic_mask : (9 downto 0) := (others => '0');
258 signal simp_asic_mask : (9 downto 0) := (others => '0');
259 signal unmask_windows : := '0';
260 signal rx_features_ack : (1 downto 0) := (others => '0');
261 signal ser_run_i : := '0';
262 signal HitData_i : KlmScrodHitDataType := KlmScrodHitDataNull;
266 signal HitData : KlmScrodHitDataType := KlmScrodHitDataNull;
272 signal single_bus_reset : := '0';
273 signal disambig_tb5 : := '1';
274 signal or_busy_status : := '0';
276 -- SIGNALS DRIVEN BY INSTANTIATED ENTITIES 279 signal trig_in_t1 : trig_info_type_1 := null_trig_info_t1;
-- copy of input trig with ROI added 283 signal ped_fetch_chan : slv4(1 downto 0) := (others => "0000");
284 signal ped_win_samp_start : slv14(1 downto 0) := (others=>(others=>'0'));
285 signal ped_fetch_ena : (1 downto 0) := (others => '0');
286 signal BUSA_WINSEL : (8 downto 0) := (others => '0');
287 signal BUSB_WINSEL : (8 downto 0) := (others => '0');
288 signal rx_features_ena : (1 downto 0) := (others => '0');
289 signal last_hit : (1 downto 0) := "00";
290 signal peak : slv12(1 downto 0) := (others => "000000000000");
291 signal le_time : slv14(1 downto 0) := (others => "00000000000000");
292 signal daq_chan : slv7(1 downto 0) := (others => "0000000");
293 signal DigStoreProcBusy : (1 downto 0) := "00";
294 signal DigNShiftBusy : (1 downto 0) := "00";
295 signal DigBusy : (1 downto 0) := "00";
296 signal ShiftOutWinBusy : (1 downto 0) := "00";
297 signal ShiftOutSampBusy : (1 downto 0) := "00";
298 signal FeatExtBusy : (1 downto 0) := "00";
299 signal PedFetchQueueBusy : (1 downto 0) := "00";
300 signal avg_peds_busy : (1 downto 0) := "00";
301 signal wr_peds2sram_ena : (1 downto 0) := (others=>'0');
302 signal even_sample : slv12(1 downto 0) := (others => (others=>'0'));
303 signal odd_sample : slv12(1 downto 0) := (others => (others=>'0'));
304 signal sram_asic_addr : slv3(1 downto 0) := (others=>(others=>'0'));
305 signal sram_chan_addr : slv4(1 downto 0) := (others=>(others=>'0'));
306 signal sram_samp_addr : slv4(1 downto 0) := (others=>(others=>'0'));
310 signal ped_fifo_asic_sel : (4 downto 0) := (others => '0');
311 signal ped_fifo_chan_sel : (3 downto 0) := (others => '0');
312 signal ped_fifo_wr_ena : (1 downto 0) := (others => '0');
313 signal ped_fifo_din : (11 downto 0) := (others => '0');
314 signal RAM_rd_addr : (21 downto 0) := (others => '0');
318 signal wr_peds2sram_ack : (1 downto 0) := (others=>'0');
322 signal ped_start_ro : := '0';
323 signal prime_fifos : := '0';
324 signal avg_peds_ena : := '0';
325 signal summing_ena : := '0';
327 -- HitData_Serializer_i : 328 signal ser_busy : := '0';
331 signal RAM_do : (7 downto 0) := (others => '0');
335 ------------------- ASYNCHRONOUS LOGIC --------------------------------------------- 337 single_bus_reset <= ro_reset;
-- or rst_from_sps_fsm; 338 BUSA_RD_ROWSEL <= BUSA_WINSEL(2 downto 0);
-- Kurtis says bit pattern is more complicated... 339 BUSB_RD_ROWSEL <= BUSB_WINSEL(2 downto 0);
-- ...may be shuffled in UCF or elsewhere in firmware 340 BUSA_RD_COLSEL <= BUSA_WINSEL(8 downto 3);
341 BUSB_RD_COLSEL <= BUSB_WINSEL(8 downto 3);
342 -- dbg_start_ro <= (force_trig_sr(force_trig_sr'left) and not (wave_config_q6.measure_peds or wave_config_q6.use_loop_trig)); 343 -- asic_chan_win_sel <= wave_config_q6.measure_peds & wave_config_q6.use_ftsw_trig; 344 -- bus_mask <= daq_bus_mask or ped_bus_mask; 345 ana_wr_ena_mask <= i_ana_wr_ena_mask;
351 or_busy_status <= or_reduce(DigStoreProcBusy) 352 or or_reduce(DigNShiftBusy) 353 or or_reduce(DigBusy) 354 or or_reduce(ShiftOutWinBusy) 355 or or_reduce(ShiftOutSampBusy) 356 or or_reduce(FeatExtBusy) 357 or or_reduce(PedFetchQueueBusy);
358 -- trg_proc_cnt <= i_trg_proc_cnt(31 downto 24) & i_trg_proc_cnt(7 downto 0); 359 full_proc_cnt <= i_full_proc_cnt;
360 simp_proc_cnt <= i_simp_proc_cnt;
361 null_proc_cnt <= i_null_proc_cnt;
362 -- or_calc_roi_busy <= or_reduce(calc_roi_busy); 363 disambig_tb5 <= wave_config_q6.use_ftsw_trig;
365 --------------------- SYNCHRONOUS LOGIC --------------------------------------------- 373 conf_dffs:
process(clk, wave_config,
wave_config_q1, wave_config_q2,
374 wave_config_q3, wave_config_q4, wave_config_q5)
376 if rising_edge(clk) then 379 wave_config_q3 <= wave_config_q2;
380 wave_config_q4 <= wave_config_q3;
381 wave_config_q5 <= wave_config_q4;
382 wave_config_q6 <= wave_config_q5;
384 end process conf_dffs;
388 if rising_edge(clk) then 391 busA_reset <= single_bus_reset;
392 busB_reset <= single_bus_reset;
394 end process rst_buff;
397 busy_lgc:
process(clk, or_busy_status, queue_full)
399 if rising_edge(clk) then 402 wave_stat_i(0).wave_proc_busy <= hit_bldr_fsm_busy;
403 -- busy <= localtrg or calc_roi_busy(0) or calc_roi_busy(1) or queue_full; 404 busy <= trg_proc_busy or queue_full;
406 end process busy_lgc;
409 trg_buff:
process(clk, localtrg)
411 if rising_edge(clk) then 417 force_trig_buffer:
process(clk, force_trig)
419 if rising_edge(clk) then 425 sps_reset_buffer:
process(clk, sps_reset)
427 if rising_edge(clk) then 428 sps_reset_sr <= sps_reset_sr(sps_reset_sr'left - 1 downto 0) & sps_reset;
433 ---------------------------------------------------------------------------- 434 -- ADDRESS MULTIPLEXER AND PIPELINE FOR SRAM CONTROL -- 435 ---------------------------------------------------------------------------- 436 SRAM_mux:
process (clk, wave_config_q6.measure_peds,
force_trig_sr, i_RAM_din,
439 if rising_edge(clk) then 440 RAM_din <= i_RAM_din;
-- DFF for matching phase with address 441 RAM_WEb <= i_RAM_WEb;
-- DFF for matching phase with address 442 if wave_config_q6.measure_peds = '1' then 447 i_N_readout_samples <= "00100000";
451 RAM_ADDR <= RAM_rd_addr;
453 i_N_readout_samples <= N_readout_samples_g;
456 end process SRAM_mux;
459 ena_logic:
process(clk, ped_start_ro, daq_start_ro)
461 if rising_edge(clk) then 464 end process ena_logic;
467 asic_chan_win_mux:
process(clk, wave_config_q6.measure_peds,
ped_meas_win, daq_asic_mask, trig_q0)
469 if rising_edge(clk) then 470 if wave_config_q6.measure_peds = '1' then 472 asic_mask <= (others=>'1');
477 first_dig_win <= trig_q0.first_dig_win - FineLookback_win_g;
478 last_dig_win <= trig_q0.last_dig_win - FineLookback_win_g + (N_readout_samples_g(7 downto 5) - "001");
479 asic_mask <= daq_asic_mask;
481 starting_win_samp(i) <= (trig_q0.wr_time(i) & "00000") - (FineLookback_win_g & "00000");
482 i_trig_bits(i) <= trig_q0.bits(i);
-- used by SingleBusProcessing to make a channel mask 486 end process asic_chan_win_mux;
487 ---------------------------------------------------------------------------- 491 ------------------------------------------------ 492 --- Process Triggers: Calc ROI, fill queue, mask windows -- initiated by in port 'localtrg' 493 ------------------------------------------------ 494 trg_proc:
process(clk,
i_localtrg(i_localtrg'left), queue_full, mask_ack, trig)
495 variable count : range 0 to (CALC_ROI_LAG_g + N_ASICS_g);
497 if rising_edge(clk) then 503 trg_proc_busy <= '1';
506 trg_proc_busy <= '0';
511 -- tbfifo_rden <= "0000000000"; 512 -- if trig.ready = "1111111111" then 513 trig_in_t0 <= trig;
-- tb_fifo is 1st-wd fall-through, so trig ready before tbfifo_rden 514 -- tbfifo_rden <= trig.mask; 515 -- tbfifo_rden <= "1111111111"; -- mask taken care of in KLMTrigBitsProc 519 -- trig_staging <= WAIT_VALID; 522 when PROCESSING_REQ => 523 -- tbfifo_rden <= "0000000000"; 525 if count < (CALC_ROI_LAG_g + N_ASICS_g) then 527 -- if calc_roi_ena = '1' or calc_roi_busy(1) = '1' or calc_roi_busy(0) = '1' then -- wait for calcROI 529 -- elsif or_calc_roi_busy = '1' then 530 -- trig_staging <= PROCESSING_REQ; 532 mask_windows <= '1';
-- stop TargetX sampling over ROI 533 trig_queue_wr_ena <= '1';
-- trig_in_t1 ready w/ROI info added. Add to queue. 538 trig_queue_wr_ena <= '0';
539 if mask_ack = '1' then -- wait for verification that masking was done 548 end process trg_proc;
551 ------------------------------------------------ 552 --- Queue triggers and initiate readout 553 ------------------------------------------------ 555 -- variable wr_ptr : integer range 0 to TRIG_QUEUE_DEPTH_g - 1 := 0; 556 -- variable rd_ptr : integer range 0 to TRIG_QUEUE_DEPTH_g - 1 := 0; 557 -- variable wr_ptr_nxt : integer range 0 to TRIG_QUEUE_DEPTH_g - 1 := 0; 558 variable above_thresh_but_not_full : := '0';
560 if rising_edge(clk) then 561 queue_above_thresh <= above_thresh_but_not_full or queue_full;
565 start_readout <= '0';
568 if wr_ptr = (TRIG_QUEUE_DEPTH_g - 1) then 574 if (wr_ptr - rd_ptr) >= TQ_PROG_FULL_THRESH_g then 575 above_thresh_but_not_full := '1';
577 above_thresh_but_not_full := '0';
580 if (TRIG_QUEUE_DEPTH_g - (rd_ptr - wr_ptr)) >= TQ_PROG_FULL_THRESH_g then 581 above_thresh_but_not_full := '1';
583 above_thresh_but_not_full := '0';
586 if rd_ptr = (TRIG_QUEUE_DEPTH_g - 1) then 589 rd_ptr_nxt <= rd_ptr + 1;
591 if trig_queue_wr_ena = '1' and queue_full = '0'then 593 if wr_ptr = (TRIG_QUEUE_DEPTH_g - 1) then -- increment write pointer 598 if wr_ptr_nxt = rd_ptr then 602 elsif queue_empty = '0' and hit_bldr_fsm_busy = '0' and start_readout = '0' then 603 start_readout <= '1';
-- initiate readout 604 trig_q0 <= trig_queue(rd_ptr);
-- trig_q0 is the one being processed 605 if rd_ptr = (TRIG_QUEUE_DEPTH_g - 1) then -- increment read pointer 608 rd_ptr <= rd_ptr + 1;
610 if rd_ptr_nxt = wr_ptr then 615 start_readout <= '0';
619 end process trg_queue;
622 ------------------------------------------------ 623 --- Mask / Unmask windows for waveform sampling 624 ------------------------------------------------ 625 mask_unmask_proc:
process(clk, mask_windows, unmask_windows,
626 trig_in_t1.first_dig_win, trig_q0.first_dig_win)
627 variable count : range 0 to 3;
629 if rising_edge(clk) then 634 i_ana_wr_ena_mask <= null_TX_ana_wr_ena_mask;
637 if mask_windows = '1' then -- mask off windows when trigger goes into queue 638 mask_ack <= '1';
-- acknowledge signal to arbitrate collisions 639 i_ana_wr_ena_mask.ena <= '1';
640 i_ana_wr_ena_mask.mask_bit <= '0';
641 i_ana_wr_ena_mask.win_start <= trig_in_t1.first_dig_win;
642 i_ana_wr_ena_mask.n_win <= "0010" + i_N_readout_samples(7 downto 5);
--FIXME: use last dig_win 644 elsif unmask_windows = '1' then -- unmask windows when current trigger is done processing 646 i_ana_wr_ena_mask.ena <= '1';
647 i_ana_wr_ena_mask.mask_bit <= '1';
648 i_ana_wr_ena_mask.win_start <= trig_q0.first_dig_win;
649 i_ana_wr_ena_mask.n_win <= "0010" + i_N_readout_samples(7 downto 5);
--FIXME: use last dig_win 658 -- if count = (N_readout_samples_g(7 downto 5) + "010") then 660 i_ana_wr_ena_mask <= null_TX_ana_wr_ena_mask;
671 ----------------------------------------------------------------------------- 672 --- KLM Hit Builder -- initiated when HitQueue not empty and this FSM not busy 673 ----------------------------------------------------------------------------- 675 rx_features_ena, peak, le_time, daq_chan, i_full_proc_cnt, i_simp_proc_cnt, i_null_proc_cnt,
676 last_hit, unmask_ack, wave_config_q6.use_ftsw_trig,
678 variable count : range 0 to T_WAIT_2C_IF_QUEUE_FULL_g := 0;
679 variable i_last_hit : (1 downto 0) := "00";
680 variable i_first_hit : := '1';
681 variable i_queue_getting_full : := '0';
683 if rising_edge(clk) then 687 qt_fifo_evt_rdy <= '0';
689 i_full_proc_cnt <= (others=>'0');
690 i_simp_proc_cnt <= (others=>'0');
691 i_null_proc_cnt <= (others=>'0');
700 qt_fifo_evt_rdy <= '0';
701 HitData_i.last_hit <= '0';
703 -- HitData_i.null_hit <= '1'; 704 daq_chan_base <= (others=>'0');
705 daq_chan_i <= (others=>'0');
706 le_time_i <= (others=>'0');
707 peak_i <= (others=>'0');
708 if start_readout = '1' then -- initiated by trig_queue whenever queue is nonempty and readout is not busy 712 hit_bldr_fsm_busy <= '1';
715 hit_bldr_fsm_busy <= '0';
719 -- FIXME: CHECK IF STATE CAN BE REMOVED 720 When WAIT_RESET => -- soft reset to make sure staging fifos are empty before processing new trigger 726 if count < T_WAIT_2C_IF_QUEUE_FULL_g then 735 -- wait until event data is valid 737 i_last_hit(0) := not or_reduce(trig_q0.mask(4 downto 0));
738 i_last_hit(1) := not or_reduce(trig_q0.mask(9 downto 5));
739 daq_asic_mask <= trig_q0.mask;
740 simp_asic_mask <= trig_q0.mask;
741 if or_reduce(trig_q0.mask) = '1' then 742 HitData_i.null_hit <= '0';
743 if queue_above_thresh = '0' then 744 i_queue_getting_full := '0';
747 i_full_proc_cnt <= i_full_proc_cnt + '1';
750 i_queue_getting_full := '1';
752 i_simp_proc_cnt <= i_simp_proc_cnt + '1';
756 HitData_i.null_hit <= '1';
757 i_null_proc_cnt <= i_null_proc_cnt + '1';
762 WHEN WAIT_WAVEFORM_READOUT => 764 if rx_features_ena(0) = '1' then 765 rx_features_ack <= "01";
767 -- HitData_i.null_hit <= null_hit(0); 769 le_time_i <= le_time(0);
770 daq_chan_i <= daq_chan(0);
771 i_last_hit(0) := last_hit(0);
-- BusA last hit 772 -- HitData_i.last_hit <= last_hit(0) and i_last_hit(1); 774 elsif rx_features_ena(1) = '1' then 775 rx_features_ack <= "10";
777 -- HitData_i.null_hit <= null_hit(1); 779 le_time_i <= le_time(1);
780 daq_chan_i <= daq_chan(1);
781 i_last_hit(1) := last_hit(1);
-- BusB last hit 782 -- HitData_i.last_hit <= last_hit(1) and i_last_hit(0); 790 if i_queue_getting_full = '1' then 791 i_last_hit(0) := not or_reduce(simp_asic_mask(4 downto 0));
792 i_last_hit(1) := not or_reduce(simp_asic_mask(9 downto 5));
794 rx_features_ack <= "00";
795 if ser_busy = '1' then 798 HitData_i.first_hit <= i_first_hit;
799 HitData_i.last_hit <= i_last_hit(1) and i_last_hit(0);
800 ser_run_i <= wave_config_q6.use_ftsw_trig;
-- initiate transaction 808 if i_last_hit(1) = '1' and i_last_hit(0) = '1' THEN 809 qt_fifo_evt_rdy <= wave_config_q6.use_ftsw_trig;
810 unmask_windows <= '1';
811 -- i_trg_proc_cnt <= i_trg_proc_cnt + '1'; 814 if i_queue_getting_full = '1' then 824 if unmask_ack = '1' then -- VERY IMPORTANT: stay here until sampling mask is removed. 825 unmask_windows <= '0';
832 TB5 <= trig_q0.bits(count)(4);
833 daq_chan_i <= daq_chan_base + ("000" & trig_q0.bits(count)(3 downto 0) - '1');
839 if simp_asic_mask(count) = '1' or count = 9 then 840 simp_asic_mask(count) <= '0';
846 daq_chan_base <= "0000000";
848 daq_chan_base <= daq_chan_base + "0001111";
856 end process hit_bldr;
859 ppln_hit_data:
process(clk, daq_axis_i, daq_chan_i, trig_q0.ctime, simp, TB5,
860 le_time_i, peak_i, HitData_i, ser_run_i)
862 if rising_edge(clk) then 863 HitData_i.word1 <= packet_type_g & daq_axis_i & daq_chan_i;
864 HitData_i.word2 <= trig_q0.ctime;
865 HitData_i.word3 <= simp & TB5 & le_time_i;
866 HitData_i.word4 <= "0000" & peak_i;
867 HitData <= HitData_i;
875 ---------------------BEGIN MODULES --------------------------------------------- 878 ARR_DEPTH_g => N_ASICS_g,
884 -- busy => calc_roi_busy(i), 885 vec_arr => trig_in_t0.wr_time,
886 arr_mask => trig_in_t0.mask,
887 first_vec => trig_in_t1.first_dig_win,
888 last_vec => trig_in_t1.last_dig_win
894 N_BITS_AVG_g => N_BITS_AVG_g
900 ped_sub_ena => wave_config_q6.ped_sub_ena,
901 disambig_tb5 => disambig_tb5,
902 measure_peds => wave_config_q6.measure_peds,
903 stream_peds => wave_config_q6.stream_peds,
905 win_samp_start => starting_win_samp
(4 downto 0),
907 asic_mask => asic_mask
(4 downto 0),
908 first_dig_win => first_dig_win,
909 last_dig_win => last_dig_win,
913 ped_fetch_chan => ped_fetch_chan
(0),
914 ped_win_samp_start => ped_win_samp_start
(0),
915 ped_fetch_ena => ped_fetch_ena
(0),
917 ped_fifo_wr_asic => ped_fifo_asic_sel,
918 ped_fifo_wr_chan => ped_fifo_chan_sel,
919 ped_fifo_wr_ena => ped_fifo_wr_ena
(0),
920 ped_fifo_din => ped_fifo_din,
922 -- wires to/from TargetX 923 BUS_RD_ENA => BUSA_RD_ENA,
924 BUS_RAMP => BUSA_RAMP,
927 SR_CLR => BUSA_SR_CLEAR,
928 SR_CLK => SR_CLOCK
(4 downto 0),
929 SR_SEL => BUSA_SR_SEL,
930 BUS_RD_WINSEL => BUSA_WINSEL,
931 SAMPLESEL => BUSA_SAMPLESEL,
932 SAMPLESEL_ANY => SAMPLESEL_ANY
(4 downto 0),
934 -- wires to HitDataSerializer 935 rx_features_ack => rx_features_ack
(0),
936 rx_features_ena => rx_features_ena
(0),
937 last_hit => last_hit
(0),
938 -- null_hit => null_hit(0), 940 le_time => le_time
(0),
941 daq_chan => daq_chan
(0),
943 -- SCROD config registers 944 ramp_length => wave_config_q6.ramp_length,
945 -- force_test_pattern => wave_config_q6.force_test_pattern, 946 t_samp_addr_settle => wave_config_q6.t_samp_addr_settle,
947 t_setup_ss_any => wave_config_q6.t_setup_ss_any,
948 t_strobe_settle => wave_config_q6.t_strobe_settle,
949 t_sr_clk_high => wave_config_q6.t_sr_clk_high,
950 t_sr_clk_low => wave_config_q6.t_sr_clk_low,
951 t_sr_clk_strobe => wave_config_q6.t_sr_clk_strobe,
952 N_readout_samples => i_N_readout_samples,
953 LE_time_thresh => wave_config_q6.LE_time_thresh,
956 debug_we => debug_wave_we
(0),
957 debug_wave => debug_wave_din
(0),
958 DigStoreProcBusy => DigStoreProcBusy
(0),
959 DigNShiftBusy => DigNShiftBusy
(0),
960 DigBusy => DigBusy
(0),
961 ShiftOutWinBusy => ShiftOutWinBusy
(0),
962 ShiftOutSampBusy => ShiftOutSampBusy
(0),
963 FeatExtBusy => FeatExtBusy
(0),
964 PedFetchQueueBusy => PedFetchQueueBusy
(0),
966 -- wires for ped calc 967 prime_fifos => prime_fifos,
968 summing_ena => summing_ena,
969 avg_peds_ena => avg_peds_ena,
970 avg_peds_busy => avg_peds_busy
(0),
971 wr_peds2sram_ena => wr_peds2sram_ena
(0),
972 wr_peds2sram_ack => wr_peds2sram_ack
(0),
973 even_ped => even_sample
(0),
974 odd_ped => odd_sample
(0),
975 sram_asic_addr => sram_asic_addr
(0),
976 sram_chan_addr => sram_chan_addr
(0),
977 sram_samp_addr => sram_samp_addr
(0),
979 sps_reset => sps_reset_sr
(sps_reset_sr'left
),
980 SPS_hist_rd_addr => wave_config_q6.SPS_hist_rd_addr
(0),
981 SPS_hist_rd_data => SPS_hist_rd_data
(0) 987 N_BITS_AVG_g => N_BITS_AVG_g
993 ped_sub_ena => wave_config_q6.ped_sub_ena,
994 disambig_tb5 => disambig_tb5,
995 measure_peds => wave_config_q6.measure_peds,
996 stream_peds => wave_config_q6.stream_peds,
998 win_samp_start => starting_win_samp
(9 downto 5),
1000 asic_mask => asic_mask
(9 downto 5),
1001 first_dig_win => first_dig_win,
1002 last_dig_win => last_dig_win,
1006 ped_fetch_chan => ped_fetch_chan
(1),
1007 ped_win_samp_start => ped_win_samp_start
(1),
1008 ped_fetch_ena => ped_fetch_ena
(1),
1010 ped_fifo_wr_asic => ped_fifo_asic_sel,
1011 ped_fifo_wr_chan => ped_fifo_chan_sel,
1012 ped_fifo_wr_ena => ped_fifo_wr_ena
(1),
1013 ped_fifo_din => ped_fifo_din,
1015 -- wires to/from TargetX 1016 BUS_RD_ENA => BUSB_RD_ENA,
1017 BUS_RAMP => BUSB_RAMP,
1018 BUS_CLR => BUSB_CLR,
1020 SR_CLR => BUSB_SR_CLEAR,
1021 SR_CLK => SR_CLOCK
(9 downto 5),
1022 SR_SEL => BUSB_SR_SEL,
1023 BUS_RD_WINSEL => BUSB_WINSEL,
1024 SAMPLESEL => BUSB_SAMPLESEL,
1025 SAMPLESEL_ANY => SAMPLESEL_ANY
(9 downto 5),
1027 -- wires to HitDataSerializer 1028 rx_features_ack => rx_features_ack
(1),
1029 rx_features_ena => rx_features_ena
(1),
1030 last_hit => last_hit
(1),
1031 -- null_hit => null_hit(1), 1033 le_time => le_time
(1),
1034 daq_chan => daq_chan
(1),
1036 -- SCROD config registers 1037 ramp_length => wave_config_q6.ramp_length,
1038 -- force_test_pattern => wave_config_q6.force_test_pattern, 1039 t_samp_addr_settle => wave_config_q6.t_samp_addr_settle,
1040 t_setup_ss_any => wave_config_q6.t_setup_ss_any,
1041 t_strobe_settle => wave_config_q6.t_strobe_settle,
1042 t_sr_clk_high => wave_config_q6.t_sr_clk_high,
1043 t_sr_clk_low => wave_config_q6.t_sr_clk_low,
1044 t_sr_clk_strobe => wave_config_q6.t_sr_clk_strobe,
1045 N_readout_samples => i_N_readout_samples,
1046 LE_time_thresh => wave_config_q6.LE_time_thresh,
1049 debug_we => debug_wave_we
(1),
1050 debug_wave => debug_wave_din
(1),
1051 DigStoreProcBusy => DigStoreProcBusy
(1),
1052 DigNShiftBusy => DigNShiftBusy
(1),
1053 DigBusy => DigBusy
(1),
1054 ShiftOutWinBusy => ShiftOutWinBusy
(1),
1055 ShiftOutSampBusy => ShiftOutSampBusy
(1),
1056 FeatExtBusy => FeatExtBusy
(1),
1057 PedFetchQueueBusy => PedFetchQueueBusy
(1),
1059 -- wires for ped calc 1060 prime_fifos => prime_fifos,
1061 summing_ena => summing_ena,
1062 avg_peds_ena => avg_peds_ena,
1063 avg_peds_busy => avg_peds_busy
(1),
1064 wr_peds2sram_ena => wr_peds2sram_ena
(1),
1065 wr_peds2sram_ack => wr_peds2sram_ack
(1),
1066 even_ped => even_sample
(1),
1067 odd_ped => odd_sample
(1),
1068 sram_asic_addr => sram_asic_addr
(1),
1069 sram_chan_addr => sram_chan_addr
(1),
1070 sram_samp_addr => sram_samp_addr
(1),
1072 sps_reset => sps_reset_sr
(sps_reset_sr'left
),
1073 SPS_hist_rd_addr => wave_config_q6.SPS_hist_rd_addr
(1),
1074 SPS_hist_rd_data => SPS_hist_rd_data
(1) 1082 ena => ped_fetch_ena,
1085 chan_addr => ped_fetch_chan,
1086 win_samp_start => ped_win_samp_start,
1087 fifo_asic_sel => ped_fifo_asic_sel,
-- fanned out to busA/B, wr_ena controlled 1088 fifo_chan_sel => ped_fifo_chan_sel,
-- fanned out to busA/B, wr_ena controlled 1089 ped_fifo_wr_ena => ped_fifo_wr_ena,
-- slv[1:0] 1090 ped_fifo_din => ped_fifo_din,
1091 N_readout_samples => i_N_readout_samples,
1093 RAM_ADDR => RAM_rd_addr
1100 ena => wr_peds2sram_ena,
1101 ack => wr_peds2sram_ack,
1102 chan_addr => sram_chan_addr,
1103 asic_addr => sram_asic_addr,
1104 samp_addr => sram_samp_addr,
1106 even_sample => even_sample,
1107 odd_sample => odd_sample,
1108 RAM_din => i_RAM_din,
1109 RAM_WEb => i_RAM_WEb,
1116 LAST_WINDOW_ADDRESS => LAST_WINDOW_ADDRESS,
1117 N_BITS_AVG_g => N_BITS_AVG_g
1123 force_trig => ped_start_ro,
1125 prime_fifos => prime_fifos,
1126 summing_ena => summing_ena,
1128 either_bus_busy => either_bus_busy,
1129 avg_peds_ena => avg_peds_ena,
1130 avg_peds_busy => avg_peds_busy,
1132 -- bus_mask => ped_bus_mask 1142 -- daq data to be serialized 1143 first_hit => HitData.first_hit,
-- hit is the first hit in the event 1144 last_hit => HitData.last_hit,
-- hit is the last hit in the event 1145 null_hit => HitData.null_hit,
-- hit is null 1146 word1 => HitData.word1,
-- in 1147 word2 => HitData.word2,
-- in 1148 word3 => HitData.word3,
-- in 1149 word4 => HitData.word4,
-- in 1152 fifo_empty => qt_fifo_empty,
1153 -- fifo_full => open, 1154 fifo_dout => qt_fifo_dout,
1156 fifo_err_cnt => qt_fifo_err_cnt,
1161 tristate : for i in 0 to 7 generate 1163 --
generic map(IFD_DELAY_VALUE => "
0", DRIVE =>
12, SLEW =>
"SLOW") <--
Default values, uncomment
and change
if needed
1164 port map(o =>
RAM_do(i
), io => RAM_IO
(i
), i => RAM_din
(i
), t => RAM_rw
);