Maintenance scheduled 24th July -- expect downtime along that day

Commit 8d74d3fa authored by penacoba's avatar penacoba

Top reorganized, and outputs for the Acam properly registered.


git-svn-id: http://svn.ohwr.org/fmc-tdc@40 85dfdc96-de2c-444c-878d-45b388be74a9
parent 552710a7
......@@ -13,7 +13,7 @@
-- modified by :
--
----------------------------------------------------------------------------------------------------
-- last changes:
-- last changes: Added registers for the outputs.
----------------------------------------------------------------------------------------------------
-- to do:
----------------------------------------------------------------------------------------------------
......@@ -134,8 +134,8 @@ begin
when rd_ack =>
ack <= '1';
cs <= '1';
rd <= '1';
cs <= '0';
rd <= '0';
wr <= '0';
nxt_acam_data_st <= idle;
......@@ -150,9 +150,9 @@ begin
when write =>
ack <= '0';
cs <= '1';
cs <= '0';
rd <= '0';
wr <= '1';
wr <= '0';
nxt_acam_data_st <= wr_ack;
......@@ -196,10 +196,22 @@ begin
-- outputs to the ACAM
address_o <= adr(3 downto 0);
cs_n_o <= not(cs);
output_registers: process
begin
if reset ='1' then
cs_n_o <= '1';
rd_n_o <= '1';
wr_n_o <= '1';
else
cs_n_o <= not(cs);
rd_n_o <= not(rd);
wr_n_o <= not(wr);
end if;
wait until clk ='1';
end process;
oe_n_o <= '1';
rd_n_o <= not(rd);
wr_n_o <= not(wr);
end rtl;
----------------------------------------------------------------------------------------------------
......
......@@ -26,24 +26,26 @@ use IEEE.numeric_std.all;
----------------------------------------------------------------------------------------------------
entity acam_timecontrol_interface is
generic(
g_width : integer :=32
g_width : integer :=32
);
port(
-- signals external to the chip: interface with acam
err_flag_i : in std_logic;
int_flag_i : in std_logic;
err_flag_i : in std_logic;
int_flag_i : in std_logic;
start_dis_o : out std_logic;
start_from_fpga_o : out std_logic;
stop_dis_o : out std_logic;
start_dis_o : out std_logic;
start_from_fpga_o : out std_logic;
stop_dis_o : out std_logic;
-- signals internal to the chip: interface with other modules
clk_i : in std_logic;
start_trig_i : in std_logic;
reset_i : in std_logic;
clk_i : in std_logic;
start_trig_i : in std_logic;
reset_i : in std_logic;
acam_errflag_p_o : out std_logic;
acam_intflag_p_o : out std_logic
acam_rise_errflag_p_o : out std_logic;
acam_fall_errflag_p_o : out std_logic;
acam_rise_intflag_p_o : out std_logic;
acam_fall_intflag_p_o : out std_logic
);
end acam_timecontrol_interface;
......@@ -67,17 +69,19 @@ architecture rtl of acam_timecontrol_interface is
);
end component;
signal clk : std_logic;
signal counter_reset : std_logic;
signal start_trig : std_logic;
signal reset : std_logic;
signal s_int_flag : unsigned(2 downto 0);
signal s_err_flag : unsigned(2 downto 0);
signal clk : std_logic;
signal counter_reset : std_logic;
signal start_trig : std_logic;
signal reset : std_logic;
signal s_int_flag : unsigned(2 downto 0);
signal s_err_flag : unsigned(2 downto 0);
signal start_dis : std_logic;
signal start_from_fpga : std_logic;
signal start_window : std_logic;
signal window_inverted : std_logic;
signal start_dis : std_logic;
signal start_from_fpga : std_logic;
signal start_window : std_logic;
signal start_window_reg : unsigned(2 downto 0);
signal start_window_edge : std_logic;
signal window_inverted : std_logic;
----------------------------------------------------------------------------------------------------
-- architecture begins
......@@ -106,24 +110,17 @@ begin
wait until clk ='1';
end process;
acam_errflag_p_o <= not(s_err_flag(1)) and s_err_flag(0);
acam_intflag_p_o <= not(s_int_flag(1)) and s_int_flag(0);
acam_fall_errflag_p_o <= not(s_err_flag(1)) and s_err_flag(0);
acam_rise_errflag_p_o <= s_err_flag(1) and not(s_err_flag(0));
acam_fall_intflag_p_o <= not(s_int_flag(1)) and s_int_flag(0);
acam_rise_intflag_p_o <= s_int_flag(1) and not(s_int_flag(0));
-- generation of the window allowing the start:
-- every second an external start retrigger is generated by the
-- rising edge of the ref_clk
start_disable_control: process
begin
if reset ='1' then
start_dis <='1';
else
start_dis <= not(start_window);
end if;
wait until clk ='1';
end process;
window_counter: incr_counter
generic map(
width => g_width
......@@ -139,18 +136,52 @@ begin
);
start_window <= not(window_inverted);
start_disable_control: process
begin
if reset ='1' then
start_dis <='1';
else
start_dis <= not(start_window);
end if;
wait until clk ='1';
end process;
start_pulse_fitter: process
begin
if reset ='1' then
start_window_reg <= (others=>'0');
else
start_window_reg <= shift_right(start_window_reg,1);
start_window_reg(2) <= start_window;
end if;
wait until clk ='1';
end process;
start_pulse: process
begin
if reset ='1' then
start_from_fpga <= '0';
elsif start_window_edge ='1' then
start_from_fpga <= '1';
else
start_from_fpga <= '0';
end if;
wait until clk ='1';
end process;
counter_reset <= reset or start_trig;
start_from_fpga <= start_trig;
start_window_edge <= start_window_reg(2) and not(start_window_reg(1)) and not(start_window_reg(0));
-- inputs
clk <= clk_i;
start_trig <= start_trig_i;
reset <= reset_i;
start_trig <= start_trig_i;
-- outputs
start_dis_o <= start_dis;
stop_dis_o <= '0';
start_from_fpga_o <= start_from_fpga;
stop_dis_o <= '0';
end rtl;
----------------------------------------------------------------------------------------------------
......
......@@ -34,10 +34,11 @@ entity data_engine is
port(
-- wishbone master signals internal to the chip: interface with other modules
ack_i : in std_logic;
dat_i : in std_logic_vector(31 downto 0);
dat_i : in std_logic_vector(g_width-1 downto 0);
adr_o : out std_logic_vector(19 downto 0);
cyc_o : out std_logic;
dat_o : out std_logic_vector(31 downto 0);
dat_o : out std_logic_vector(g_width-1 downto 0);
stb_o : out std_logic;
we_o : out std_logic;
......@@ -59,17 +60,39 @@ end data_engine;
----------------------------------------------------------------------------------------------------
architecture rtl of data_engine is
type engine_state_ty is (wr_config, rest_wr, rd_timestamp, rest_rd);
type engine_state_ty is (idle, wr_config, rest_wr, rd_timestamp, rest_rd);
signal engine_st, nxt_engine_st : engine_state_ty;
signal ef1 : std_logic;
signal ef2 : std_logic;
signal clk : std_logic;
signal reset : std_logic;
----------------------------------------------------------------------------------------------------
-- architecture begins
----------------------------------------------------------------------------------------------------
begin
data_engine_seq_fsm: process
begin
if reset ='1' then
engine_st <= idle;
else
engine_st <= nxt_engine_st;
end if;
wait until clk ='1';
end process;
-- data_engine_comb_fsm: process
-- begin
-- case engine_st is
-- when waiting =>
--
-- inputs
clk <= clk_i;
reset <= reset_i;
end rtl;
----------------------------------------------------------------------------------------------------
......
......@@ -30,16 +30,17 @@ use IEEE.numeric_std.all;
----------------------------------------------------------------------------------------------------
entity start_retrigger_control is
generic(
g_width : integer :=32
g_width : integer :=32
);
port(
acam_intflag_p_i : in std_logic;
clk_i : in std_logic;
one_hz_p_i : in std_logic;
reset_i : in std_logic;
acam_rise_intflag_p_i : in std_logic;
acam_fall_intflag_p_i : in std_logic;
clk_i : in std_logic;
one_hz_p_i : in std_logic;
reset_i : in std_logic;
start_nb_offset_o : out std_logic_vector(g_width-1 downto 0);
start_trig_o : out std_logic
start_nb_offset_o : out std_logic_vector(g_width-1 downto 0);
start_trig_o : out std_logic
);
end start_retrigger_control;
......@@ -63,15 +64,18 @@ architecture rtl of start_retrigger_control is
);
end component;
signal acam_intflag_p : std_logic;
signal clk : std_logic;
signal counter_reset : std_logic;
signal offset_value : std_logic_vector(g_width-1 downto 0);
signal offset_to_shift : unsigned(g_width-1 downto 0);
signal one_hz_p : std_logic;
signal reset : std_logic;
signal start_nb_offset : std_logic_vector(g_width-1 downto 0);
signal start_trig : std_logic;
signal acam_fall_intflag_p : std_logic;
signal acam_rise_intflag_p : std_logic;
signal acam_halfcounter_gone : std_logic;
signal add_offset : std_logic;
signal clk : std_logic;
signal counter_reset : std_logic;
signal offset_value : std_logic_vector(g_width-1 downto 0);
signal offset_to_shift : unsigned(g_width-1 downto 0);
signal one_hz_p : std_logic;
signal reset : std_logic;
signal start_nb_offset : std_logic_vector(g_width-1 downto 0);
signal start_trig : std_logic;
----------------------------------------------------------------------------------------------------
-- architecture begins
......@@ -85,20 +89,34 @@ begin
port map(
clk => clk,
end_value => x"FFFFFFFF",
incr => acam_intflag_p,
incr => add_offset,
reset => counter_reset,
count_done => open,
current_value => offset_value
);
halfcounter_monitor: process -- The halfcounter monitor is needed to make
begin -- sure that the falling edge pulse received
if reset ='1' or one_hz_p ='1' then -- corresponds to a real overflow of the ACAM
acam_halfcounter_gone <= '0'; -- counter and not to a different reason,
elsif acam_rise_intflag_p ='1' then -- for example a reset.
acam_halfcounter_gone <= '1'; -- This way the start_nb_offset will really
elsif acam_fall_intflag_p ='1' then -- track the number of internal start retriggers
acam_halfcounter_gone <= '0'; -- inside the ACAM.
end if;
wait until clk ='1';
end process;
add_offset <= acam_fall_intflag_p and acam_halfcounter_gone;
counter_reset <= reset or one_hz_p;
offset_to_shift <= unsigned(offset_value);
start_nb_offset <= std_logic_vector(shift_left(offset_to_shift,8));
start_trig <= one_hz_p;
-- inputs
acam_intflag_p <= acam_intflag_p_i;
acam_fall_intflag_p <= acam_fall_intflag_p_i;
acam_rise_intflag_p <= acam_rise_intflag_p_i;
clk <= clk_i;
one_hz_p <= one_hz_p_i;
reset <= reset_i;
......
......@@ -143,16 +143,17 @@ architecture rtl of top_tdc is
component start_retrigger_control is
generic(
g_width : integer :=32
g_width : integer :=32
);
port(
acam_intflag_p_i : in std_logic;
clk_i : in std_logic;
one_hz_p_i : in std_logic;
reset_i : in std_logic;
acam_rise_intflag_p_i : in std_logic;
acam_fall_intflag_p_i : in std_logic;
clk_i : in std_logic;
one_hz_p_i : in std_logic;
reset_i : in std_logic;
start_nb_offset_o : out std_logic_vector(g_width-1 downto 0);
start_trig_o : out std_logic
start_nb_offset_o : out std_logic_vector(g_width-1 downto 0);
start_trig_o : out std_logic
);
end component;
......@@ -176,24 +177,26 @@ architecture rtl of top_tdc is
component acam_timecontrol_interface
generic(
g_width : integer :=32
g_width : integer :=32
);
port(
-- signals external to the chip: interface with acam
err_flag_i : in std_logic;
int_flag_i : in std_logic;
err_flag_i : in std_logic;
int_flag_i : in std_logic;
start_dis_o : out std_logic;
start_from_fpga_o : out std_logic;
stop_dis_o : out std_logic;
start_dis_o : out std_logic;
start_from_fpga_o : out std_logic;
stop_dis_o : out std_logic;
-- signals internal to the chip: interface with other modules
clk_i : in std_logic;
start_trig_i : in std_logic;
reset_i : in std_logic;
clk_i : in std_logic;
start_trig_i : in std_logic;
reset_i : in std_logic;
acam_errflag_p_o : out std_logic;
acam_intflag_p_o : out std_logic
acam_rise_errflag_p_o : out std_logic;
acam_fall_errflag_p_o : out std_logic;
acam_rise_intflag_p_o : out std_logic;
acam_fall_intflag_p_o : out std_logic
);
end component;
......@@ -366,8 +369,10 @@ signal tdc_led_trig3 : std_logic:='0';
signal tdc_led_trig4 : std_logic:='0';
signal tdc_led_trig5 : std_logic:='0';
signal acam_errflag_p : std_logic;
signal acam_intflag_p : std_logic;
signal acam_fall_errflag_p : std_logic;
signal acam_rise_errflag_p : std_logic;
signal acam_fall_intflag_p : std_logic;
signal acam_rise_intflag_p : std_logic;
signal acam_start01 : std_logic_vector(16 downto 0);
signal acam_timestamp : std_logic_vector(28 downto 0);
signal acam_timestamp_valid : std_logic;
......@@ -435,16 +440,17 @@ begin
start_retrigger_block: start_retrigger_control
generic map(
g_width => g_width
g_width => g_width
)
port map(
acam_intflag_p_i => acam_intflag_p,
clk_i => clk,
one_hz_p_i => one_hz_p,
reset_i => general_reset,
acam_fall_intflag_p_i => acam_fall_intflag_p,
acam_rise_intflag_p_i => acam_rise_intflag_p,
clk_i => clk,
one_hz_p_i => one_hz_p,
reset_i => general_reset,
start_nb_offset_o => start_nb_offset,
start_trig_o => start_trig
start_nb_offset_o => start_nb_offset,
start_trig_o => start_trig
);
data_formatting_block: data_formatting
......@@ -483,8 +489,10 @@ begin
start_trig_i => start_trig,
reset_i => general_reset,
acam_errflag_p_o => acam_errflag_p,
acam_intflag_p_o => acam_intflag_p
acam_fall_errflag_p_o => acam_fall_errflag_p,
acam_rise_errflag_p_o => acam_rise_errflag_p,
acam_fall_intflag_p_o => acam_fall_intflag_p,
acam_rise_intflag_p_o => acam_rise_intflag_p
);
acam_data_block: acam_databus_interface
......@@ -686,13 +694,14 @@ begin
spec_led_red_o <= spec_led_red;
tdc_led_status_o <= tdc_led_status;
tdc_led_trig1_o <= tdc_led_trig1;
tdc_led_trig2_o <= tdc_led_trig2;
tdc_led_trig3_o <= tdc_led_trig3;
tdc_led_trig4_o <= tdc_led_trig4;
tdc_led_trig1_o <= ef2_i;
tdc_led_trig2_o <= ef1_i;
tdc_led_trig3_o <= lf2_i;
tdc_led_trig4_o <= lf1_i;
tdc_led_trig5_o <= tdc_led_trig5;
-- these will evolve as we implement all the features
pulse_delay <= x"00000001";
mute_inputs_o <= '1';
term_en_1_o <= '1';
term_en_2_o <= '1';
......
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