Commit 011fbe69 authored by Denia Bouhired-Ferrag's avatar Denia Bouhired-Ferrag

Major changes: conv_pulse_gen.vhd has been almost completely rewritten. Also top…

Major changes: conv_pulse_gen.vhd has been almost completely rewritten. Also top file now uses pulse periods instead of duty cycles, this is to be able to cope with none round duty cycles
parent 4b29f817
...@@ -193,9 +193,10 @@ entity conv_dyn_burst_ctrl is ...@@ -193,9 +193,10 @@ entity conv_dyn_burst_ctrl is
-- i.e. temp_rise >= g_max_temp. -- i.e. temp_rise >= g_max_temp.
------------------------------------------------------------------------ ------------------------------------------------------------------------
when PULSE_REJECT => when PULSE_REJECT =>
if (pulse_f_edge_p_i = '1' and temp_rise <= g_max_temp) OR if pulse_f_edge_p_i = '1' and temp_rise <= g_max_temp then
temp_rise = 0 then
nxt_state <= PULSE_REPEAT; nxt_state <= PULSE_REPEAT;
elsif temp_rise = 0 then
nxt_state <= IDLE;
else else
nxt_state <= PULSE_REJECT; nxt_state <= PULSE_REJECT;
end if; end if;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
-- Pulse generator with trigger -- Pulse generator with trigger
--============================================================================== --==============================================================================
-- --
-- author:
-- --
-- date of creation: 2013-03-01 -- date of creation: 2013-03-01
-- --
...@@ -11,8 +11,9 @@ ...@@ -11,8 +11,9 @@
-- --
-- description: -- description:
-- This module generates a constant-width pulse. The width is set using the -- This module generates a constant-width pulse. The width is set using the
-- g_pwidth generic, given in number of clk_i cycles. With a clk_i period of -- g_pwidth generic, given in number of clk_i cycles. The module in principle
-- 50 ns, the output pulse width is by default 50*24=1.2 us. -- should generate either 250ns pulses or 1.2us. With a clk_i period of
-- 50 ns, the output pulse width is by default 5 or 24clock cycles long respectively.
-- --
-- The module is designed to work with an external glitch filter. Enabling -- The module is designed to work with an external glitch filter. Enabling
-- this glitch filter will result in jitter on the leading edge of the -- this glitch filter will result in jitter on the leading edge of the
...@@ -24,7 +25,9 @@ ...@@ -24,7 +25,9 @@
-- g_pwidth. At the end of the pulse, a rejection phase is implemented in order -- g_pwidth. At the end of the pulse, a rejection phase is implemented in order
-- to avoid too many pulses arriving on the input. This is to safeguard the -- to avoid too many pulses arriving on the input. This is to safeguard the
-- blocking output stage of the CONV-TTL-BLO boards. The isolation phase limits -- blocking output stage of the CONV-TTL-BLO boards. The isolation phase limits
-- the input pulse to 1/500 duty cycle. -- the input pulse to 1/2 cycles for 250 ns pulses and 1/8 for 1.2 us pulses.
-- The burst cntrol module placed immediately after this module, will integrate
-- pulse repetition frequency over time according to a pre-defined "thermal" model.
-- --
-- dependencies: -- dependencies:
-- none -- none
...@@ -44,14 +47,7 @@ ...@@ -44,14 +47,7 @@
--============================================================================== --==============================================================================
-- last changes: -- last changes:
-- 01-03-2013 Theodor Stana File created. -- 01-03-2013 Theodor Stana File created.
-- 02-08-2013 Theodor Stana Implemented rejection phase. -- 02-03-2017 Denia Bouhired Almost total re-write of the code to make for a more general FSM
-- 17-02-2014 Theodor Stana Moved the glitch filter to outside the
-- module.
-- 04-03-2014 Theodor Stana Added first pulse inhibit on glitch-filtered
-- side.
-- 24-07-2014 Theodor Stana Added g_with_fixed_pwidth generic and
-- subsequent logic.
-- 19-12-2016 Denia Bouhired Small modification to FSM to allow for very short 250ns pulses.
--============================================================================== --==============================================================================
-- TODO: - -- TODO: -
...@@ -66,47 +62,51 @@ entity conv_pulse_gen is ...@@ -66,47 +62,51 @@ entity conv_pulse_gen is
generic generic
( (
-- This generic enables elaboration of the fixed pulse width logic -- This generic enables elaboration of the fixed pulse width logic
g_with_fixed_pwidth : boolean; g_with_fixed_pwidth : boolean;
-- Pulse width, in number of clk_i cycles -- Pulse width, in number of clk_i cycles
-- Default pulse width (20 MHz clock): 1.2 us -- Default pulse width (20 MHz clock): 1.2 us
-- Minimum allowable pulse width (20 MHz clock): 1 us -- Minimum allowable pulse width (20 MHz clock): 100 ns
-- Maximum allowable pulse width (20 MHz clock): 2 us -- Maximum allowable pulse width (20 MHz clock): 2 us
g_pwidth : natural range 2 to 40 := 24; g_pwidth : natural range 2 to 40 := 24;
-- Duty cycle divider: D = 1/g_duty_cycle_div -- Pulse period in unit of clock cycles
g_duty_cycle_div : natural := 5 g_pperiod : natural := 9
); );
port port
( (
-- Clock and active-low reset inputs -- Clock and active-low reset inputs
clk_i : in std_logic; clk_i : in std_logic;
rst_n_i : in std_logic; rst_n_i : in std_logic;
-- Glitch filter enable input -- Glitch filter enable input
-- '1' - Glitch filter disabled (glitch-sensitive, no output jitter) -- '1' - Glitch filter disabled (glitch-sensitive, no output jitter)
-- '0' - Glitch filter enabled (glitch-insensitive, with output jitter) -- '0' - Glitch filter enabled (glitch-insensitive, with output jitter)
gf_en_n_i : in std_logic; gf_en_n_i : in std_logic;
-- Enable input, pulse generation is enabled when '1' -- Enable input, pulse generation is enabled when '1'
en_i : in std_logic; en_i : in std_logic;
-- Trigger input, has to be '1' to assure pulse output with delay no greater -- Trigger input, has to be '1' to assure pulse output with delay no greater
-- than internal gate delays. -- than internal gate delays.
trig_a_i : in std_logic; trig_a_i : in std_logic;
-- Rising and falling edges of the input trigger. Externally synchronised to the clock
trig_r_edge_p_i : in std_logic; --synced 1 cycle-long r edge output
trig_f_edge_p_i : in std_logic; --synced 1 cycle-long f edge output
-- Pulse error output, pulses high for one clock cycle when a pulse arrives -- Pulse error output, pulses high for one clock cycle when a pulse arrives
-- within a pulse period -- within a pulse period
pulse_err_p_o : out std_logic; pulse_err_p_o : out std_logic;
-- Pulse output, active-high -- Pulse output, active-high
-- latency: -- latency:
-- glitch filter disabled: none -- glitch filter disabled: none
-- glitch filter enabled: glitch filter length + 5 clk_i cycles -- glitch filter enabled: glitch filter length + 5 clk_i cycles
pulse_o : out std_logic; pulse_o : out std_logic;
pulse_r_edge_p_o : out std_logic; --synced 1 cycle-long r edge output -- Rising and falling edges of the output pulse, synchronised to the clock
pulse_f_edge_p_o : out std_logic pulse_r_edge_p_o : out std_logic; --synced 1 cycle-long r edge output
pulse_f_edge_p_o : out std_logic
); );
end entity conv_pulse_gen; end entity conv_pulse_gen;
...@@ -115,39 +115,35 @@ architecture behav of conv_pulse_gen is ...@@ -115,39 +115,35 @@ architecture behav of conv_pulse_gen is
--============================================================================ --============================================================================
-- Type declarations -- Type declarations
--============================================================================ --============================================================================
type t_state is ( type t_state is (
IDLE, -- idle state, wait for pulse IDLE, -- idle state, wait for pulse
GEN_GF_OFF, -- pulse generation, glitch filter off PRE_IDLE, -- idle state, wait for pulse
REJ_GF_OFF, -- pulse rejection, glitch filter off GEN_PULSE_OUTPUT, -- pulse generation
GEN_GF_ON, -- pulse generation, glitch filter on REJ_PULSE_INPUT -- pulse rejection
REJ_GF_ON -- pulse rejection, glitch filter on
); );
--============================================================================ --============================================================================
-- Constant declarations -- Constant declarations
--============================================================================ --============================================================================
-- Max value of pulse counter for pulse width and pulse rejection width. -- Max value of pulse counter for pulse width and pulse rejection width.
-- glitch filter OFF: -- Generate time:
-- generate: -- * Maximum pulse width = g_pwidth
-- * g_pwidth-1: counter starts from 0 -- * Count starts from 0 c_max_gen = pwidth - 1
-- * g_pwidth-4: three-cycle delay through synchronizer -- * Allow three cycle for synchrnised rising edge pwidth-4
-- * g_pwidth-5: reset signal applied in REJ_GF_OFF state --
-- reject: constant c_max_gen : natural := g_pwidth-1;
-- * g_duty_cycle_div*g_pwidth: D duty cycle
-- * g_duty_cycle_div*g_pwidth-5: 5-cycle delay added from the generate phase
-- glitch filter ON: -- Rejection time:
-- generate: -- * Maximum pulse period = g_pperiod*g_pwidth
-- * g_pwidth-1: counter starts from 0 -- * Allow one cycle to change state from REJ_PULSE_INPUT to PRE_IDLE
-- reject: constant c_max_rej : natural := g_pperiod-1;
-- * g_duty_cycle_div*g_pwidth: D duty cycle
-- * g_duty_cycle_div*g_pwidth-2: need one cycle less to allow for true 1/D -- Rising edges result from leading edge of trigger going through a 3 stage synchrnoiser.
-- duty cycle, -- An extra 1 clock cycle delay is needed before state can be changed.
-- since the FSM needs to go through IDLE to accept a pulse constant c_r_edge_sync_delay : natural := 4;
constant c_max_gen_gf_off : natural := g_pwidth-5;
constant c_max_rej_gf_off : natural := g_duty_cycle_div*g_pwidth - 6;
constant c_max_gen_gf_on : natural := g_pwidth-1;
constant c_max_rej_gf_on : natural := g_duty_cycle_div*g_pwidth - 2;
--============================================================================ --============================================================================
-- Function and procedure declarations -- Function and procedure declarations
...@@ -165,29 +161,23 @@ architecture behav of conv_pulse_gen is ...@@ -165,29 +161,23 @@ architecture behav of conv_pulse_gen is
--============================================================================ --============================================================================
-- Signal declarations -- Signal declarations
--============================================================================ --============================================================================
-- Trigger signals -- Reset signal combining reset and en signals
signal pulse_gf_off_d0 : std_logic; signal gen_edge_n : std_logic;
signal pulse_gf_off_d1 : std_logic;
signal pulse_gf_off_d2 : std_logic;
signal gen_edge_gf_off_n : std_logic;
signal trig_gf_on : std_logic;
signal trig_gf_on_d0 : std_logic;
signal trig_gf_on_r_edge_p : std_logic;
signal trig_gf_on_f_edge_p : std_logic;
-- Pulse output signals -- Pulse output signals
signal pulse_gf_on : std_logic; signal pulse_out_rst_n : std_logic; -- From FSM
signal pulse_gf_off : std_logic; signal pulse_gf_on : std_logic; -- Generated from synchronous input
signal pulse_gf_off_rst : std_logic; signal pulse_gf_off : std_logic; -- Generated from asynchronous input
signal pulse_gf_off_r_edge_p : std_logic; signal pulse_out : std_logic; -- Selects between pulse_gf_on and pulse_gf_off
signal pulse_gf_off_f_edge_p : std_logic;
-- Pulse length counter -- Pulse length counter
signal pulse_cnt : unsigned(f_log2_size(g_duty_cycle_div*g_pwidth)-1 downto 0); signal pulse_cnt_reset : std_logic; -- From FSM
signal pulse_cnt_clr : std_logic; -- From FSM
signal pulse_cnt : unsigned(f_log2_size(g_pperiod)-1 downto 0);
-- FSM signal -- FSM states
signal state : t_state; signal state : t_state;
signal nxt_state : t_state;
--============================================================================== --==============================================================================
-- architecture begin -- architecture begin
...@@ -200,98 +190,90 @@ gen_without_fixed_pwidth : if (g_with_fixed_pwidth = false) generate ...@@ -200,98 +190,90 @@ gen_without_fixed_pwidth : if (g_with_fixed_pwidth = false) generate
end generate gen_without_fixed_pwidth; end generate gen_without_fixed_pwidth;
gen_with_fixed_pwidth : if (g_with_fixed_pwidth = true) generate gen_with_fixed_pwidth : if (g_with_fixed_pwidth = true) generate
--============================================================================ -- ============================================================================
-- Output logic -- Output logic
--============================================================================ -- ============================================================================
pulse_o <= pulse_gf_off when (gf_en_n_i = '1') else
pulse_gf_on; -- pulse_out <= pulse_gf_off when (gf_en_n_i = '1') else
-- pulse_gf_on;
pulse_o <= pulse_out;
-- Synchronise output to get correct rising edges and falling edges output pulses
gen_edge_n <= rst_n_i and en_i;
cmp_sync_ffs : gc_sync_ffs
port map
(
clk_i => clk_i,
rst_n_i => gen_edge_n,
data_i => pulse_out,
ppulse_o => pulse_r_edge_p_o,
npulse_o => pulse_f_edge_p_o
);
--============================================================================ --============================================================================
-- Pulse generation logic -- Pulse generation logic
--============================================================================ --============================================================================
-- Generate the pulse on rising edge of trig_a_i -- Generate the pulse on rising edge of trig_a_i
p_pulse_gf_off: process(pulse_gf_off_rst, trig_a_i)
p_pulse_gf_off : process(pulse_out_rst_n, trig_a_i, en_i, gf_en_n_i)
begin begin
if (pulse_gf_off_rst = '1') then if pulse_out_rst_n = '0' then
pulse_gf_off <= '0'; pulse_out <= '0';
elsif rising_edge(trig_a_i) then elsif rising_edge(trig_a_i) then
if (en_i = '1') and (gf_en_n_i = '1') then if (en_i = '1') then --and (gf_en_n_i = '1') then
pulse_gf_off <= '1'; pulse_out <= '1';
end if; end if;
end if; end if;
end process p_pulse_gf_off; end process p_pulse_gf_off;
--pulse_gf_on <= '0' when pulse_out_rst_n = '0' else trig_a_i and not gf_en_n_i;
-- and synchronize the trigger in clk_i domain
-- p_sync_pulse_gf_off: process (clk_i) is
-- begin --============================================================================
-- if rising_edge(clk_i) then -- Pulse width adjustment logic
-- if (rst_n_i = '0') then --============================================================================
-- pulse_gf_off_d0 <= '0'; p_count_cycles: process(clk_i)
-- pulse_gf_off_d1 <= '0';
-- pulse_gf_off_d2 <= '0';
-- pulse_gf_off_r_edge_p <= '0';
-- elsif (en_i = '1') and (gf_en_n_i = '1') then
-- pulse_gf_off_d0 <= pulse_gf_off;
-- pulse_gf_off_d1 <= pulse_gf_off_d0;
-- pulse_gf_off_d2 <= pulse_gf_off_d1;
-- pulse_gf_off_r_edge_p <= pulse_gf_off_d1 and (not pulse_gf_off_d2);
-- end if;
-- end if;
-- end process p_sync_pulse_gf_off;
gen_edge_gf_off_n <= rst_n_i or en_i or gf_en_n_i;
-- and synchronize the trigger in clk_i domain using sync_ffs general core
cmp_gc_sync_ffs : gc_sync_ffs
generic map
(
g_sync_edge => "positive"
)
port map(
clk_i => clk_i, -- clock from the destination clock domain
rst_n_i => gen_edge_gf_off_n, -- reset is acomibnation of rst_n_i,
-- en_i and gf_en_n_i
data_i => pulse_gf_off, -- async input
npulse_o => pulse_gf_off_f_edge_p,-- negative edge detect output
ppulse_o => pulse_gf_off_r_edge_p-- positive edge detect output
);
-- Trigger signal with glitch filter ON is input signal
trig_gf_on <= '0' when rst_n_i = '0' else trig_a_i ;
-- Rising edge detector for the trigger signal when glitch filter is ON
p_trig_gf_on : process (clk_i) is
begin begin
if rising_edge(clk_i) then if rising_edge(clk_i) then
if (rst_n_i = '0') then if rst_n_i = '0' or pulse_cnt_reset = '1' then
pulse_cnt <= to_unsigned(c_r_edge_sync_delay, f_log2_size(g_pperiod));
trig_gf_on_d0 <= '0'; elsif pulse_cnt_clr = '1' then
trig_gf_on_r_edge_p <= '0'; pulse_cnt <= (others => '0');
else else
trig_gf_on_d0 <= trig_gf_on; pulse_cnt <= pulse_cnt+1;
trig_gf_on_r_edge_p <= trig_gf_on and (not trig_gf_on_d0); end if;
trig_gf_on_f_edge_p <= (not trig_gf_on) and trig_gf_on_d0;
end if;
end if; end if;
end process p_trig_gf_on; end process p_count_cycles;
pulse_r_edge_p_o <= pulse_gf_off_r_edge_p when gf_en_n_i = '1' else trig_gf_on_r_edge_p; -----------------------------------------------------------------------------
pulse_f_edge_p_o <= pulse_gf_off_f_edge_p when gf_en_n_i = '1' else trig_gf_on_f_edge_p; -- Finite State Machine FSM
--============================================================================ -----------------------------------------------------------------------------
-- Pulse width adjustment logic
--============================================================================
-- Generate the FSM logic -- Process to trigger state transitions
p_pulse_width: process(clk_i) ----------------------------------------
p_fsm_transitions: process(clk_i)
begin begin
if rising_edge(clk_i) then if rising_edge(clk_i) then
if (rst_n_i = '0') then if rst_n_i = '0' then
state <= IDLE; state <= IDLE;
pulse_gf_off_rst <= '1';
pulse_gf_on <= '0';
pulse_cnt <= (others => '0');
pulse_err_p_o <= '0';
--first_p <= '1';
elsif (en_i = '1') then elsif (en_i = '1') then
-- State machine logic state <= nxt_state;
end if;
end if;
end process;
-- ======================================================================================
-- Generate the FSM logic
p_fsm_states : process(state, trig_r_edge_p_i, pulse_cnt)
begin
case state is case state is
--------------------------------------------------------------------- ---------------------------------------------------------------------
-- IDLE -- IDLE
...@@ -300,118 +282,123 @@ pulse_f_edge_p_o <= pulse_gf_off_f_edge_p when gf_en_n_i = '1' else trig_gf_on_f ...@@ -300,118 +282,123 @@ pulse_f_edge_p_o <= pulse_gf_off_f_edge_p when gf_en_n_i = '1' else trig_gf_on_f
-- appropriate input arrives -- appropriate input arrives
--------------------------------------------------------------------- ---------------------------------------------------------------------
when IDLE => when IDLE =>
pulse_cnt <= (others => '0');
pulse_gf_off_rst <= '0'; if trig_r_edge_p_i = '1' then
pulse_err_p_o <= '0'; nxt_state <= GEN_PULSE_OUTPUT;
if (gf_en_n_i = '1') then
if (pulse_gf_off_r_edge_p = '1') then
state <= GEN_GF_OFF;
end if;
else else
if (trig_gf_on_r_edge_p = '1') then nxt_state <= IDLE;
state <= GEN_GF_ON; end if;
end if;
end if; when PRE_IDLE =>
-- Pulse error assignment if pulse_cnt >= c_r_edge_sync_delay-1 then
-- This has been added for special cases whre rising edge occurs if trig_r_edge_p_i = '1' then
-- on state transition nxt_state <= GEN_PULSE_OUTPUT;
if (trig_gf_on_f_edge_p = '1' ) then else
pulse_err_p_o <= '1'; nxt_state <= IDLE;
end if;
else
nxt_state <= PRE_IDLE;
end if; end if;
--------------------------------------------------------------------- ---------------------------------------------------------------------
-- GEN_GF_OFF -- GEN_PULSE_OUTPUT
--------------------------c------------------------------------------- --------------------------c-------------------------------------------
-- Extend the generated pulse to the required pulse width. -- Extend the generated pulse to the required pulse width.
--------------------------------------------------------------------- ---------------------------------------------------------------------
when GEN_GF_OFF => when GEN_PULSE_OUTPUT =>
-- Pulse logic and state change if pulse_cnt = c_max_gen then
pulse_cnt <= pulse_cnt + 1; nxt_state <= REJ_PULSE_INPUT;
if pulse_cnt = c_max_gen_gf_off then else
state <= REJ_GF_OFF; nxt_state <= GEN_PULSE_OUTPUT;
end if;
if c_max_gen_gf_off = 0 then
state <= REJ_GF_OFF;
pulse_gf_off_rst <= '1';
end if;
-- Pulse error assignment
pulse_err_p_o <= '0';
if (trig_gf_on_r_edge_p = '1') then
pulse_err_p_o <= '1';
end if; end if;
--------------------------------------------------------------------- ---------------------------------------------------------------------
-- REJ_GF_OFF -- REJ_PULSE_INPUT
--------------------------------------------------------------------- ---------------------------------------------------------------------
-- Cut and reject input pulses, to safeguard the output transformers. -- Cut and reject input pulses, to safeguard the output transformers.
--------------------------------------------------------------------- ---------------------------------------------------------------------
when REJ_GF_OFF => when REJ_PULSE_INPUT =>
-- Pulse logic and state change if pulse_cnt = c_max_rej then
pulse_cnt <= pulse_cnt + 1; nxt_state <= PRE_IDLE;
if pulse_cnt = c_max_rej_gf_off then else
state <= IDLE; nxt_state <= REJ_PULSE_INPUT;
pulse_gf_off_rst <= '0';
else
pulse_gf_off_rst <= '1';
end if;
-- Pulse error assignment
pulse_err_p_o <= '0';
if (trig_gf_on_r_edge_p = '1') then
pulse_err_p_o <= '1';
end if;
---------------------------------------------------------------------
-- GEN_GF_ON
---------------------------------------------------------------------
-- Start generating the output pulse with the required width.
---------------------------------------------------------------------
when GEN_GF_ON =>
-- Pulse logic and state change
pulse_cnt <= pulse_cnt + 1;
pulse_gf_on <= '1';
if (pulse_cnt = c_max_gen_gf_on) then
state <= REJ_GF_ON;
end if; end if;
-- Pulse error assignment when others =>
pulse_err_p_o <= '0'; nxt_state <= IDLE;
if (trig_gf_on_r_edge_p = '1') then
pulse_err_p_o <= '1';
end if;
end case;
end process p_fsm_states;
-- Generate the FSM logic
p_fsm_outputs : process(state, trig_r_edge_p_i, pulse_cnt)
begin
case state is
--------------------------------------------------------------------- ---------------------------------------------------------------------
-- REJ_GF_ON -- IDLE
--------------------------------------------------------------------- ---------------------------------------------------------------------
-- Stop generating the output pulse and reject incoming pulses. -- Clear all values and go to pulse generation state when the
-- appropriate input arrives
--------------------------------------------------------------------- ---------------------------------------------------------------------
when REJ_GF_ON => when IDLE =>
-- Pulse logic and state change pulse_out_rst_n <= rst_n_i;
pulse_gf_on <= '0'; pulse_err_p_o <= '0';
pulse_cnt <= pulse_cnt + 1; pulse_cnt_reset <= '1';
if (pulse_cnt = c_max_rej_gf_on) then pulse_cnt_clr <= '0';
state <= IDLE;
when PRE_IDLE =>
pulse_out_rst_n <= rst_n_i;
if pulse_cnt < c_r_edge_sync_delay-1 then
pulse_err_p_o <= trig_r_edge_p_i;
else
pulse_err_p_o <= '0';
end if; end if;
pulse_cnt_reset <= '0';
pulse_cnt_clr <= '0';
---------------------------------------------------------------------
-- GEN_PULSE_OUTPUT
--------------------------c-------------------------------------------
-- Extend the generated pulse to the required pulse width.
---------------------------------------------------------------------
when GEN_PULSE_OUTPUT =>
pulse_out_rst_n <= rst_n_i;
pulse_err_p_o <= trig_r_edge_p_i;
pulse_cnt_reset <= '0';
pulse_cnt_clr <= '0';
-- Pulse error assignment ---------------------------------------------------------------------
pulse_err_p_o <= '0'; -- REJ_PULSE_INPUT
if (trig_gf_on_r_edge_p = '1') then ---------------------------------------------------------------------
pulse_err_p_o <= '1'; -- Cut and reject input pulses, to safeguard the output transformers.
---------------------------------------------------------------------
when REJ_PULSE_INPUT =>
pulse_err_p_o <= trig_r_edge_p_i;
pulse_out_rst_n <= '0';
pulse_cnt_reset <= '0';
if pulse_cnt = c_max_rej then
pulse_cnt_clr <= '1';
else
pulse_cnt_clr <= '0';
end if; end if;
when others => when others =>
state <= IDLE; pulse_out_rst_n <= '0';
pulse_err_p_o <= '0';
pulse_cnt_reset <= '1';
end case; end case;
end if;
end if;
end process p_pulse_width;
end process p_fsm_outputs;
end generate gen_with_fixed_pwidth; end generate gen_with_fixed_pwidth;
end architecture behav; end architecture behav;
......
...@@ -73,14 +73,14 @@ entity conv_common_gw is ...@@ -73,14 +73,14 @@ entity conv_common_gw is
-- Pulse width at pulse generator output (valid with fixed output pulse width) -- Pulse width at pulse generator output (valid with fixed output pulse width)
g_pgen_pwidth_lg : natural range 2 to 40 := 24; g_pgen_pwidth_lg : natural range 2 to 40 := 24;
g_pgen_pwidth_sh : natural range 2 to 40 := 5; g_pgen_pwidth_sh : natural range 2 to 40 := 5;
-- Duty cycle divider ratio for pulse generator
-- output pulse will be limited to 1/g_pgen_duty_cycle_div -- output pulse will be limited to period
--For continuous mode operation max freq 4.16kHz --For continuous mode operation max freq 4.16kHz
g_pgen_duty_cycle_div_cont : natural range 2 to 200 := 200; g_pgen_pperiod_cont : natural range 2 to 5000 := 4800;
--for LONG pulses changes maximum frequency to ~104kHz --for LONG pulses changes maximum frequency to ~104kHz
g_pgen_duty_cycle_div_lg : natural range 6 to 300 := 8; g_pgen_pperiod_lg : natural range 6 to 300 := 191;
--for SHORT pulses changes maximum frequency to ~2MHz --for SHORT pulses changes maximum frequency to ~2MHz
g_pgen_duty_cycle_div_sh : natural range 2 to 300 := 2; g_pgen_pperiod_sh : natural range 2 to 300 := 9;
-- Pulse generator glitch filter length in number of clk_20_i cycles -- Pulse generator glitch filter length in number of clk_20_i cycles
g_pgen_gf_len : integer := 4; g_pgen_gf_len : integer := 4;
...@@ -320,8 +320,7 @@ architecture arch of conv_common_gw is ...@@ -320,8 +320,7 @@ architecture arch of conv_common_gw is
signal trig_degl : std_logic_vector(g_nr_chans-1 downto 0); signal trig_degl : std_logic_vector(g_nr_chans-1 downto 0);
signal trig_chan : std_logic_vector(g_nr_chans-1 downto 0); signal trig_chan : std_logic_vector(g_nr_chans-1 downto 0);
signal trig_chan_redge_p : std_logic_vector(g_nr_chans-1 downto 0); signal trig_chan_redge_p : std_logic_vector(g_nr_chans-1 downto 0);
signal trig_chan_ttl_redge_p : std_logic_vector(g_nr_chans-1 downto 0); signal trig_chan_fedge_p : std_logic_vector(g_nr_chans-1 downto 0);
signal trig_chan_blo_redge_p : std_logic_vector(g_nr_chans-1 downto 0);
signal trig_man : std_logic_vector(g_nr_chans-1 downto 0); signal trig_man : std_logic_vector(g_nr_chans-1 downto 0);
signal trig_pgen : std_logic_vector(g_nr_chans-1 downto 0); signal trig_pgen : std_logic_vector(g_nr_chans-1 downto 0);
signal burst_en_n : std_logic; signal burst_en_n : std_logic;
...@@ -473,11 +472,11 @@ architecture arch of conv_common_gw is ...@@ -473,11 +472,11 @@ architecture arch of conv_common_gw is
signal CONTROL : std_logic_vector(35 downto 0); signal CONTROL : std_logic_vector(35 downto 0);
signal CLK : std_logic; signal CLK : std_logic;
signal TRIG0_in : std_logic_vector(7 downto 0); signal TRIG0_in : std_logic_vector(7 downto 0);
signal TRIG1_in : std_logic_vector(7 downto 0); -- signal TRIG1_in : std_logic_vector(7 downto 0);
signal TRIG2_in : std_logic_vector(7 downto 0); -- signal TRIG2_in : std_logic_vector(7 downto 0);
signal TRIG3_in : std_logic_vector(7 downto 0); -- signal TRIG3_in : std_logic_vector(7 downto 0);
signal TRIG4_in : std_logic_vector(7 downto 0); -- signal TRIG4_in : std_logic_vector(7 downto 0);
signal TRIG5_in : std_logic_vector(7 downto 0); -- signal TRIG5_in : std_logic_vector(7 downto 0);
-- signal TRIG6_in : std_logic_vector(7 downto 0); -- signal TRIG6_in : std_logic_vector(7 downto 0);
-- signal TRIG7_in : std_logic_vector(7 downto 0); -- signal TRIG7_in : std_logic_vector(7 downto 0);
-- signal TRIG8_in : std_logic_vector(7 downto 0); -- signal TRIG8_in : std_logic_vector(7 downto 0);
...@@ -497,22 +496,22 @@ begin ...@@ -497,22 +496,22 @@ begin
port map ( port map (
CONTROL => CONTROL, CONTROL => CONTROL,
CLK => clk_20_i, CLK => clk_20_i,
TRIG0 => TRIG0_in, TRIG0 => TRIG0_in);
TRIG1 => TRIG1_in,
TRIG2 => TRIG2_in,
TRIG3 => TRIG3_in,
TRIG4 => TRIG4_in,
TRIG5 => TRIG5_in);
chipscope_icon_1 : chipscope_icon chipscope_icon_1 : chipscope_icon
port map ( CONTROL0 => CONTROL); port map ( CONTROL0 => CONTROL);
TRIG0_in(7 downto 0) <= std_logic_vector(temp_rise_c_sh(3)(7 downto 0));
TRIG1_in(7 downto 0) <= std_logic_vector(temp_rise_c_sh(3)(15 downto 8)); TRIG0_in(0) <= pulse_outp_err_sh_p(5);
TRIG2_in(7 downto 0) <= std_logic_vector(temp_rise_c_sh(3)(23 downto 16)); TRIG0_in(1) <= burst_outp_err_sh_p(5);
TRIG3_in(7 downto 0) <= std_logic_vector(temp_rise_c_sh(3)(31 downto 24));
TRIG4_in(7 downto 0) <= std_logic_vector(temp_rise_c_sh(3)(39 downto 32)); TRIG0_in(2) <= trig_pgen(5);
TRIG5_in(5 downto 0) <= pulse_outp_err_lg_p; TRIG0_in(3) <= pulse_outp_sh(5);
TRIG0_in(4) <= pulse_outp_err_lg_p(5);
TRIG0_in(5) <= burst_outp_err_lg_p(5);
TRIG0_in(6) <= pulse_outp_lg(5);
TRIG0_in(7) <= ch_ttl_pcr_ld(5);
--============================================================================ --============================================================================
...@@ -669,6 +668,10 @@ gen_pulse_chan_logic : for i in 0 to g_nr_chans-1 generate ...@@ -669,6 +668,10 @@ gen_pulse_chan_logic : for i in 0 to g_nr_chans-1 generate
trig_chan(i) <= trig_a(i) when (gf_en_n_i = '1') else trig_chan(i) <= trig_a(i) when (gf_en_n_i = '1') else
trig_degl(i); trig_degl(i);
-- The trigger to the pulse generator is either manual OR from the channel input
trig_pgen(i) <= trig_chan(i) or trig_man(i);
-- Now, sync this channel trigger signal before passing it to the counters -- Now, sync this channel trigger signal before passing it to the counters
-- --
-- The pulse counter is triggered only by a pulse that actually makes it -- The pulse counter is triggered only by a pulse that actually makes it
...@@ -682,17 +685,11 @@ gen_pulse_chan_logic : for i in 0 to g_nr_chans-1 generate ...@@ -682,17 +685,11 @@ gen_pulse_chan_logic : for i in 0 to g_nr_chans-1 generate
( (
clk_i => clk_20_i, clk_i => clk_20_i,
rst_n_i => rst_20_n, rst_n_i => rst_20_n,
data_i => trig_chan(i), data_i => trig_pgen(i),
ppulse_o => trig_chan_redge_p(i) ppulse_o => trig_chan_redge_p(i),
npulse_o => trig_chan_fedge_p(i)
); );
-- AND the ttl line with the de-glitched pulse in order to determine
-- source of pulse. If ANDed signal is 1 then TTL source.
trig_chan_ttl_redge_p(i) <= trig_chan_redge_p(i) and line_front_i (i);
-- AND the blo line with the de-glitched pulse in order to determine
-- source of pulse. If ANDed signal is 1 then BLO source.
trig_chan_blo_redge_p(i) <= trig_chan_redge_p(i) and line_rear_i (i);
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
gen_pulse_cnt : if (g_with_pulse_cnt = true) generate gen_pulse_cnt : if (g_with_pulse_cnt = true) generate
...@@ -757,8 +754,6 @@ end generate gen_pulse_cnt_unused_chans; ...@@ -757,8 +754,6 @@ end generate gen_pulse_cnt_unused_chans;
end generate gen_pulse_cnt; end generate gen_pulse_cnt;
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- The trigger to the pulse generator is either manual OR from the channel input
trig_pgen(i) <= trig_chan(i) or trig_man(i);
------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------
-- Instantiate pulse generator + burst controller block for the channel for LONG pulse operation -- Instantiate pulse generator + burst controller block for the channel for LONG pulse operation
...@@ -772,7 +767,7 @@ end generate gen_pulse_cnt; ...@@ -772,7 +767,7 @@ end generate gen_pulse_cnt;
( (
g_with_fixed_pwidth => g_pgen_fixed_width, g_with_fixed_pwidth => g_pgen_fixed_width,
g_pwidth => g_pgen_pwidth_lg, g_pwidth => g_pgen_pwidth_lg,
g_duty_cycle_div => g_pgen_duty_cycle_div_cont g_pperiod => g_pgen_pperiod_cont
) )
port map port map
( (
...@@ -784,6 +779,8 @@ end generate gen_pulse_cnt; ...@@ -784,6 +779,8 @@ end generate gen_pulse_cnt;
en_i => '1', en_i => '1',
trig_a_i => trig_pgen(i), trig_a_i => trig_pgen(i),
trig_r_edge_p_i => trig_chan_redge_p(i),
trig_f_edge_p_i => trig_chan_fedge_p(i),
pulse_err_p_o => pulse_outp_err_cont (i), pulse_err_p_o => pulse_outp_err_cont (i),
...@@ -801,7 +798,7 @@ end generate gen_pulse_cnt; ...@@ -801,7 +798,7 @@ end generate gen_pulse_cnt;
( (
g_with_fixed_pwidth => g_pgen_fixed_width, g_with_fixed_pwidth => g_pgen_fixed_width,
g_pwidth => g_pgen_pwidth_lg, g_pwidth => g_pgen_pwidth_lg,
g_duty_cycle_div => g_pgen_duty_cycle_div_lg g_pperiod => g_pgen_pperiod_lg
) )
port map port map
( (
...@@ -813,6 +810,8 @@ end generate gen_pulse_cnt; ...@@ -813,6 +810,8 @@ end generate gen_pulse_cnt;
en_i => '1', en_i => '1',
trig_a_i => trig_pgen(i), trig_a_i => trig_pgen(i),
trig_r_edge_p_i => trig_chan_redge_p(i),
trig_f_edge_p_i => trig_chan_fedge_p(i),
pulse_err_p_o => pulse_outp_err_lg_p (i), pulse_err_p_o => pulse_outp_err_lg_p (i),
...@@ -855,7 +854,7 @@ end generate gen_pulse_cnt; ...@@ -855,7 +854,7 @@ end generate gen_pulse_cnt;
( (
g_with_fixed_pwidth => g_pgen_fixed_width, g_with_fixed_pwidth => g_pgen_fixed_width,
g_pwidth => g_pgen_pwidth_sh, g_pwidth => g_pgen_pwidth_sh,
g_duty_cycle_div => g_pgen_duty_cycle_div_sh g_pperiod => g_pgen_pperiod_sh
) )
port map port map
( (
...@@ -867,6 +866,8 @@ end generate gen_pulse_cnt; ...@@ -867,6 +866,8 @@ end generate gen_pulse_cnt;
en_i => '1', en_i => '1',
trig_a_i => trig_pgen(i), trig_a_i => trig_pgen(i),
trig_r_edge_p_i => trig_chan_redge_p(i),
trig_f_edge_p_i => trig_chan_fedge_p(i),
pulse_err_p_o => pulse_outp_err_sh_p (i), pulse_err_p_o => pulse_outp_err_sh_p (i),
......
...@@ -85,11 +85,11 @@ package conv_common_gw_pkg is ...@@ -85,11 +85,11 @@ package conv_common_gw_pkg is
-- Pulse width at pulse generator output (valid with fixed output pulse width) -- Pulse width at pulse generator output (valid with fixed output pulse width)
g_pgen_pwidth_lg : natural range 2 to 40 := 24; --**DB: was 20 to 40 g_pgen_pwidth_lg : natural range 2 to 40 := 24; --**DB: was 20 to 40
g_pgen_pwidth_sh : natural range 2 to 40 := 5; g_pgen_pwidth_sh : natural range 2 to 40 := 5;
-- Duty cycle divider ratio for pulse generator
-- output pulse will be limited to 1/g_pgen_duty_cycle_div -- output pulse will be limited to pulse period
g_pgen_duty_cycle_div_cont : natural range 2 to 200 := 200; --For continuous mode operation max freq 4.12kHz g_pgen_pperiod_cont : natural range 2 to 5000 := 4800; --For continuous mode operation max freq 4.12kHz
g_pgen_duty_cycle_div_lg : natural range 6 to 300 := 16; --for LONG pulses changes maximum g_pgen_pperiod_lg : natural range 6 to 300 := 191; --for LONG pulses changes maximum
g_pgen_duty_cycle_div_sh : natural range 2 to 300 := 2; --for SHORT pulses changes maximum g_pgen_pperiod_sh : natural range 2 to 300 := 9; --for SHORT pulses changes maximum
-- Pulse generator glitch filter length in number of clk_20_i cycles -- Pulse generator glitch filter length in number of clk_20_i cycles
g_pgen_gf_len : integer := 4; g_pgen_gf_len : integer := 4;
...@@ -282,8 +282,8 @@ package conv_common_gw_pkg is ...@@ -282,8 +282,8 @@ package conv_common_gw_pkg is
-- Maximum allowable pulse width (20 MHz clock): 2 us -- Maximum allowable pulse width (20 MHz clock): 2 us
g_pwidth : natural range 2 to 40 := 24; --DB was 20 to 40 g_pwidth : natural range 2 to 40 := 24; --DB was 20 to 40
-- Duty cycle divider: D = 1/g_duty_cycle_div -- Pulse period in unit of clock cycles
g_duty_cycle_div : natural := 5 g_pperiod : natural := 5
); );
port port
( (
...@@ -302,7 +302,10 @@ package conv_common_gw_pkg is ...@@ -302,7 +302,10 @@ package conv_common_gw_pkg is
-- Trigger input, has to be '1' to assure pulse output with delay no greater -- Trigger input, has to be '1' to assure pulse output with delay no greater
-- than internal gate delays. -- than internal gate delays.
trig_a_i : in std_logic; trig_a_i : in std_logic;
trig_r_edge_p_i : in std_logic; --synced 1 cycle-long r edge output
trig_f_edge_p_i : in std_logic; --synced 1 cycle-long f edge output
-- Pulse error output, pulses high for one clock cycle when a pulse arrives -- Pulse error output, pulses high for one clock cycle when a pulse arrives
-- within a pulse period -- within a pulse period
pulse_err_p_o : out std_logic; pulse_err_p_o : out std_logic;
...@@ -714,12 +717,7 @@ end component wf_decr_counter; ...@@ -714,12 +717,7 @@ end component wf_decr_counter;
port ( port (
CONTROL: inout std_logic_vector(35 downto 0); CONTROL: inout std_logic_vector(35 downto 0);
CLK: in std_logic; CLK: in std_logic;
TRIG0: in std_logic_vector(7 downto 0); TRIG0: in std_logic_vector(7 downto 0));
TRIG1: in std_logic_vector(7 downto 0);
TRIG2: in std_logic_vector(7 downto 0);
TRIG3: in std_logic_vector(7 downto 0);
TRIG4: in std_logic_vector(7 downto 0);
TRIG5: in std_logic_vector(7 downto 0));
END component chipscope_ila; END component chipscope_ila;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment