Commit fe95a435 authored by Denia Bouhired-Ferrag's avatar Denia Bouhired-Ferrag

Small modifications to the burst control mode, mainly code improvement

parent fa08e685
......@@ -30,7 +30,7 @@
--==============================================================================
-- last changes:
-- 19-09-2016 Denia Bouhired File created.
--
-- 11-01-2017 Denia Bouhired File rewritten to use FSM
--==============================================================================
-- TODO: -
--==============================================================================
......@@ -48,21 +48,29 @@ use work.conv_common_gw_pkg.all;
entity conv_dyn_burst_ctrl is
generic
(
-- Fixed pulse width set to 5 clock cycles = 5* 50ns = 250 ns
g_pwidth : natural range 2 to 40 := 5;
-- Scaled temperature rise resulting from single pulse. This number can be defined empirically or derived from temperature measurements on the board.
g_1_pulse_temp_rise :in unsigned (15 downto 0) := x"A410";
g_max_temp :in unsigned (39 downto 0) := x"174876E800"
-- Scaled maximum temperature ceiling before pulse inhibition is necessary to lower temperature
--g_max_temp :in unsigned (39 downto 0) := x"174876E800"
g_max_temp :in unsigned (39 downto 0) := x"00000186A0"--100000
);
port
(
-- Clock and active-low reset inputs
clk_i : in std_logic;
rst_n_i : in std_logic;
-- Enable input, pulse generation is enabled when '1'
en_i : in std_logic;
pulse_burst_i : in std_logic;
--Input pulse burst or pulse train
pulse_burst_i : in std_logic;
--Dynamically controlled ouput pulse train.
pulse_burst_o : out std_logic;
-- output used for debugging. OUGHT TO BE DELETED
temp_rise_c : out unsigned (39 downto 0) ;
-- Burst error output, pulses high for one clock cycle when a pulse arrives
......@@ -79,11 +87,11 @@ entity conv_dyn_burst_ctrl is
-----signals declaration----------
signal temp_decre : t_temp_decre := (0, 769, 31, 104, 14, 82);
--signal temp_decre : t_temp_decre := (0, 76923, 3077, 10385, 1434, 8182);
signal burst_ctrl_rst : std_logic;
signal pulse_train_in : std_logic;
signal temp_rise : unsigned (39 downto 0) ;
--signal test : integer ;
signal test : integer ;
signal temp_fall : unsigned (39 downto 0) ;
signal single_cycle_cnt : integer;
signal five_cycle_cnt : integer;
......@@ -98,29 +106,27 @@ entity conv_dyn_burst_ctrl is
-- Generate the pulse on rising edge of pulse_burst_i
p_pulse_redge: process (burst_ctrl_rst, pulse_burst_i)
begin
--if rising_edge(clk_i) then
if rst_n_i = '0' then
-- burst_err_p_o <= '0';
elsif (en_i = '1') then
--if rising_edge(clk_i) then
--TO DOooo consider moving within else statement
if (burst_ctrl_rst = '1') then
if falling_edge(pulse_burst_i) then
if falling_edge(pulse_burst_i) then --pulse_burst_i) then -- wait for pulse to finish before cutoff
--TODO why not use falling edge 1-clk-cycle pulse
pulse_train_in <= '0';
end if;
-- burst_err_p_o <= '0';
-- if pulse_train_in_r_edge_p = '1' then
-- burst_err_p_o <= '1';
-- end if;
elsif (burst_ctrl_rst = '0') then
--if (pulse_burst_i = '0') then
pulse_train_in <= pulse_burst_i; --re-activate output only if input line is off
elsif (en_i = '1') then
pulse_train_in <= pulse_burst_i; --re-activate output only if input line is off
end if;
--end if;
end if;
end if;
--end if;
end process p_pulse_redge;
end process p_pulse_redge;
pulse_burst_o <= pulse_train_in; --copy controlled input burst to output
temp_rise_c <= temp_rise; --TODO to delete as output is not really necessary
p_pulse_redge_detect : process (clk_i) is
-- TODO is it necessary since pulse should already be synchronised to clock domain?/
p_pulse_redge_detect : process (clk_i) is
begin
if rising_edge(clk_i) then
if (rst_n_i = '0') then
......@@ -133,10 +139,7 @@ entity conv_dyn_burst_ctrl is
end if;
end if;
end process p_pulse_redge_detect;
pulse_burst_o <= pulse_train_in;
temp_rise_c <=temp_rise;
p_five_cycle_cnt : process(clk_i)
begin
......@@ -145,12 +148,11 @@ temp_rise_c <=temp_rise;
single_cycle_cnt <= 1;
five_cycle_cnt <= 1;
else
if pulse_train_in_r_edge_p = '1' and burst_ctrl_rst /= '1' then
single_cycle_cnt <= 1;
five_cycle_cnt <= 1;
elsif pulse_train_in = '0' then
if pulse_train_in_r_edge_p = '1' then --and burst_ctrl_rst = '0' then
--reset counters in the event of a new pulse
single_cycle_cnt <= 1;
five_cycle_cnt <= 1;
elsif pulse_train_in = '0' then --TODO change condition of if statement, try with falling edge
single_cycle_cnt <= single_cycle_cnt+1;
if single_cycle_cnt = 5 then
if five_cycle_cnt < 6 then
......@@ -169,9 +171,7 @@ temp_rise_c <=temp_rise;
p_thermal_sim : process (clk_i)
begin
if rising_edge(clk_i) then
if rst_n_i = '0' then
if rst_n_i = '0' then
temp_rise <= (others => '0');
burst_ctrl_rst <= '1';
burst_err_p_o <= '0';
......@@ -179,31 +179,37 @@ temp_rise_c <=temp_rise;
else
if signed(temp_rise) >= 0 and (signed(temp_rise) <= signed(g_max_temp)) then
if pulse_burst_i = '0' then
burst_ctrl_rst <= '0';
burst_err_p_o <= '0';
end if;
if pulse_train_in_r_edge_p = '1' then
if burst_ctrl_rst = '0' then -- temperature less than maximum
if pulse_train_in_f_edge_p = '1' then --wait until pulse finishes before repetition
burst_ctrl_rst <= '0';
elsif pulse_train_in_r_edge_p = '1' then --new pulse
if burst_ctrl_rst = '1' then
burst_err_p_o <= '1';
--end if;
--if burst_ctrl_rst = '0' then -- temperature less than maximum
else
temp_rise <= temp_rise + g_1_pulse_temp_rise;
else
burst_err_p_o <= '1';
--else ;
end if;
elsif signed(temp_rise) /= 0 and pulse_train_in = '0' then --temperature fall between pulses
--test <= temp_decre(five_cycle_cnt-1);
--burst_err_p_o <= '0';
--elsif signed(temp_rise) /= 0 and pulse_train_in = '0' then
elsif signed(temp_rise) /= 0 then --and pulse_burst_i = '0' then --temperature fall between pulses
test <= temp_decre(five_cycle_cnt-1);
if temp_rise > temp_decre(five_cycle_cnt-1) then
temp_rise <= temp_rise - to_unsigned(temp_decre(five_cycle_cnt-1), 40);
else
temp_rise <= (others => '0');
end if;
end if;
elsif (signed(temp_rise) > signed(g_max_temp)) and pulse_train_in = '0' then -- and (pulse_train_in_f_edge_p = '1') then
--elsif (signed(temp_rise) > signed(g_max_temp)) and pulse_train_in = '0' then -- and
elsif (signed(temp_rise) > signed(g_max_temp)) then -- and pulse_burst_i = '0' then -- and (pulse_train_in_f_edge_p = '1') then
burst_ctrl_rst <= '1';
burst_err_p_o <= '0';
if pulse_train_in_r_edge_p = '1' then
if pulse_train_in_r_edge_p = '1' then
burst_err_p_o <= '1';
end if;
end if;
burst_err_p_o <= '0';
temp_rise <= temp_rise - temp_decre(five_cycle_cnt-1);
end if;
......
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