signal hitbus_i : std_logic_vector(1 downto 0);
+ signal hitbus_buffer : std_logic;
--ToT Histogram
type hithisto_fsm_type is (idle, hitbus_high);
DataValid => open,
BinHeight => latency_BinValue);
-
+ -- purpose: hitbus synchronize and edge detect
+ hitbus_edge_proc: process (clk) is
+ begin -- process hitbus_edge_proc
+ if rising_edge(clk) then
+ hitbus_buffer <= hitbus;
+ hitbus_i <= hitbus_i(0) & hitbus_buffer;
+ end if;
+ end process hitbus_edge_proc;
+
-----------------------------------------------------------------------------
--Time over Threshold histogram
-----------------------------------------------------------------------------
-
HitBusHisto : process(clk)
begin -- process HitBusHisto
if rising_edge(clk) then
- hitbus_i <= hitbus_i(0) & hitbus;
case hithisto_fsm is
when idle =>
--hitbus_counter <= (others => '0');
memwren <= '0';
ro_busy_int <= '0';
endofevent <= '0';
+ delcounter <= (others => '0');
hitcounter <= (others => '0');
eventcounter <= eventcounter;
if(reseteventcount = '1') then
signal hitbuscounter : unsigned(15 downto 0) := (others => '0');
signal hitbus_edge : std_logic_vector(1 downto 0) := (others => '0');
signal szintillator_trigger_edge : std_logic_vector(1 downto 0) := (others => '0');
+ signal hitbusBuffer : std_logic := '0';
+ signal szintilatorTriggerBuffer : std_logic := '0';
type TimeWalk_fsm_type is (idle, waitforhitbus, measurehitbus, measurement_done);
signal timewalk_fsm : TimeWalk_fsm_type := idle;
begin -- architecture TimeWalk_Arch
+ -- purpose: synchronize signals and edge detection
+ signal_synchro: process (clk) is
+ begin -- process clk
+ if rising_edge(clk) then
+ hitbusBuffer <= hitbus;
+ szintilatorTriggerBuffer <= szintillator_trigger;
+ hitbus_edge <= hitbus_edge(0) & hitbusBuffer;
+ szintillator_trigger_edge <= szintillator_trigger_edge(0) & szintilatorTriggerBuffer;
+ end if;
+ end process signal_synchro;
+
TimeWalk_Measurement : process (clk, reset) is
begin -- process TimeWalk_Measurement
if rising_edge(clk) then
- hitbus_edge <= hitbus_edge(0) & hitbus;
- szintillator_trigger_edge <= szintillator_trigger_edge(0) & szintillator_trigger;
measurementFinished <= '0';
measurementData <= (others => '0');
case timewalk_fsm is
signal szintilatorEdgeCounter : unsigned(31 downto 0) := (others => '0');
signal hitbusRisingEdge : std_logic_vector(1 downto 0) := (others => '0');
signal szintilatorRisingEdge : std_logic_vector(1 downto 0) := (others => '0');
+ signal hitbus_buffer : std_logic := '0';
+ signal szintilator_trigger_buffer : std_logic := '0';
signal FiFo_Wren : std_logic := '0';
signal FiFo_Rden : std_logic := '0';
edge_counter: process (trb_slv_clock) is
begin -- process edge_counter
if rising_edge(trb_slv_clock) then
- hitbusRisingEdge <= hitbusRisingEdge(0) & hitbus;
- szintilatorRisingEdge <= szintilatorRisingEdge(0) & szintillator_trigger;
+ hitbus_buffer <= hitbus;
+ szintilator_trigger_buffer <= szintillator_trigger;
+ hitbusRisingEdge <= hitbusRisingEdge(0) & hitbus_buffer;
+ szintilatorRisingEdge <= szintilatorRisingEdge(0) & szintilator_trigger_buffer;
if szintilatorRisingEdge = "01" then
szintilatorEdgeCounter <= szintilatorEdgeCounter + 1;
end if;
process(clk, reset)
begin
- if(reset = '1') then
- counter_reg <= (others => '0');
- counter_reg(0) <= '1';
- no_ones_below(0) <= '1';
- elsif (clk'event and clk = '1') then
+ --if(reset = '1') then
+ -- counter_reg <= (others => '0');
+ -- counter_reg(0) <= '1';
+ -- no_ones_below(0) <= '1';
+ if (clk'event and clk = '1') then
if (sync_reset = '1') then
no_ones_below(0) <= '1';
counter_reg <= (others => '0');