signal RDO_write : std_logic := '0';
signal RDO_data : std_logic_vector(31 downto 0) := (others => '0');
- --type epoch_counter_t is array(CHANNELS - 1 downto 0) of unsigned(23 downto 0);
- --signal epoch_counter, epoch_counter_save : epoch_counter_t;
- --signal epoch_counter_sys, epoch_counter_adc : epoch_counter_t;
+ type epoch_counter_t is array(CHANNELS - 1 downto 0) of unsigned(EPOCH_COUNTER_SIZE-1 downto 0);
+ signal epoch_counter : epoch_counter_t;
begin
CONF_adc <= CONF_sys when rising_edge(CLK_ADC);
busy_in_adc <= busy_in_sys when rising_edge(CLK_ADC);
busy_out_sys <= busy_out_adc when rising_edge(CLK_SYS);
+ epoch_counter <= (others => EPOCH_COUNTER_IN) when rising_edge(CLK_ADC);
gen_cfd : for i in 0 to CHANNELS - 1 generate
trigger_gen(i) <= debug_sys(i).Trigger;
RAM_BSY_IN => busy_in_adc,
RAM_BSY_OUT => busy_out_adc(i),
DEBUG => debug_adc(i),
- EPOCH_COUNTER_IN => EPOCH_COUNTER_IN
+ EPOCH_COUNTER_IN => epoch_counter(i)
);
ram_addr_sys(i) <= std_logic_vector(resize(ram_counter(i),ram_addr_sys(i)'length));
signal integral_sum : signed(RESOLUTION_CFD - 1 downto 0) := (others => '0');
- signal epoch_counter_save : unsigned(EPOCH_COUNTER_SIZE-1 downto 0) := (others => '0');
+ signal epoch_counter, epoch_counter_save : unsigned(EPOCH_COUNTER_SIZE-1 downto 0) := (others => '0');
type state_t is (IDLE, INTEGRATE, WRITE1, WRITE2, WRITE3, FINISH, LOCKED, DEBUG_DUMP);
signal state : state_t := IDLE;
begin
wait until rising_edge(CLK);
+ epoch_counter <= EPOCH_COUNTER_IN;
+
cfd_prev <= cfd.value;
if cfd_prev < 0 and cfd.value >= 0 and cfd.thresh = '1' then
zeroX := '1';
integral_sum <= resize(delay_integral_out, RESOLUTION_CFD);
cfd_prev_save <= cfd_prev;
cfd_save <= cfd.value;
- epoch_counter_save <= EPOCH_COUNTER_IN;
+ epoch_counter_save <= epoch_counter;
elsif CONF.DebugMode = 0 and RAM_BSY_IN = '1' then
state <= LOCKED;
elsif CONF.DebugMode /= 0 and RAM_BSY_IN = '1' then