Commit 07d08c43 authored by penacoba's avatar penacoba

Operational version with full timestamps and no timing errors


git-svn-id: http://svn.ohwr.org/fmc-tdc@56 85dfdc96-de2c-444c-878d-45b388be74a9
parent 9800f270
...@@ -208,6 +208,10 @@ begin ...@@ -208,6 +208,10 @@ begin
we <= we_i; we <= we_i;
-- outputs to other blocks -- outputs to other blocks
acam_ef1_o <= ef1;
acam_ef2_o <= ef2;
acam_lf1_o <= lf1;
acam_lf2_o <= lf2;
ack_o <= ack; ack_o <= ack;
dat_o <= ef1 & ef2 & lf1 & lf2 & data_bus_io; dat_o <= ef1 & ef2 & lf1 & lf2 & data_bus_io;
...@@ -231,10 +235,6 @@ begin ...@@ -231,10 +235,6 @@ begin
-- outputs to the ACAM -- outputs to the ACAM
address_o <= adr(3 downto 0); address_o <= adr(3 downto 0);
acam_ef1_o <= ef1;
acam_ef2_o <= ef2;
acam_lf1_o <= lf1;
acam_lf2_o <= lf2;
output_registers: process output_registers: process
begin begin
......
...@@ -86,6 +86,8 @@ architecture rtl of acam_timecontrol_interface is ...@@ -86,6 +86,8 @@ architecture rtl of acam_timecontrol_interface is
); );
end component; end component;
constant constant_delay : unsigned(g_width-1 downto 0):=x"00000004";
signal acam_refclk : std_logic; signal acam_refclk : std_logic;
signal clk : std_logic; signal clk : std_logic;
signal counter_reset : std_logic; signal counter_reset : std_logic;
...@@ -104,6 +106,7 @@ signal start_trig_edge : std_logic; ...@@ -104,6 +106,7 @@ signal start_trig_edge : std_logic;
signal start_trig_received : std_logic; signal start_trig_received : std_logic;
signal waitingfor_refclk : std_logic; signal waitingfor_refclk : std_logic;
signal window_active : std_logic; signal window_active : std_logic;
signal total_delay : std_logic_vector(g_width-1 downto 0);
signal window_delay : std_logic_vector(g_width-1 downto 0); signal window_delay : std_logic_vector(g_width-1 downto 0);
signal window_inverted : std_logic; signal window_inverted : std_logic;
signal window_prepulse : std_logic; signal window_prepulse : std_logic;
...@@ -155,7 +158,7 @@ begin ...@@ -155,7 +158,7 @@ begin
clk => clk, clk => clk,
reset => reset, reset => reset,
start => window_prepulse, start => window_prepulse,
start_value => window_delay, start_value => total_delay,
count_done => window_start, count_done => window_start,
current_value => open current_value => open
...@@ -256,6 +259,7 @@ begin ...@@ -256,6 +259,7 @@ begin
window_prepulse <= waitingfor_refclk and refclk_edge; window_prepulse <= waitingfor_refclk and refclk_edge;
counter_reset <= reset or window_start; counter_reset <= reset or window_start;
total_delay <= std_logic_vector(unsigned(window_delay)+constant_delay);
-- inputs -- inputs
clk <= clk_i; clk <= clk_i;
......
...@@ -275,7 +275,7 @@ begin ...@@ -275,7 +275,7 @@ begin
mem_data_rd <= dat_i; mem_data_rd <= dat_i;
-- outputs -- outputs
wr_pointer_o <= dacapo_flag & std_logic_vector(wr_pointer(g_width-4 downto 0)) & "00"; wr_pointer_o <= dacapo_flag & std_logic_vector(wr_pointer(g_width-6 downto 0)) & x"0";
adr_o <= mem_adr; adr_o <= mem_adr;
cyc_o <= mem_cyc; cyc_o <= mem_cyc;
......
...@@ -79,7 +79,7 @@ architecture rtl of one_hz_gen is ...@@ -79,7 +79,7 @@ architecture rtl of one_hz_gen is
); );
end component; end component;
constant constant_delay : unsigned(3 downto 0):=x"4"; constant constant_delay : unsigned(g_width-1 downto 0):=x"00000004";
signal clk : std_logic; signal clk : std_logic;
signal local_utc : unsigned(g_width-1 downto 0); signal local_utc : unsigned(g_width-1 downto 0);
......
...@@ -56,7 +56,7 @@ entity reg_ctrl is ...@@ -56,7 +56,7 @@ entity reg_ctrl is
read_start01_o : out std_logic; read_start01_o : out std_logic;
reset_acam_o : out std_logic; reset_acam_o : out std_logic;
load_utc_o : out std_logic; load_utc_o : out std_logic;
load_tdc_config_o : out std_logic; -- load_tdc_config_o : out std_logic;
clear_dacapo_flag_o : out std_logic; clear_dacapo_flag_o : out std_logic;
-- configuration registers from and for the ACAM and the modules of the TDC core -- configuration registers from and for the ACAM and the modules of the TDC core
...@@ -72,11 +72,11 @@ entity reg_ctrl is ...@@ -72,11 +72,11 @@ entity reg_ctrl is
acam_config_o : out config_vector; acam_config_o : out config_vector;
starting_utc_o : out std_logic_vector(g_width-1 downto 0); starting_utc_o : out std_logic_vector(g_width-1 downto 0);
clk_freq_o : out std_logic_vector(g_width-1 downto 0); -- clk_freq_o : out std_logic_vector(g_width-1 downto 0);
ref_clk_freq_o : out std_logic_vector(g_width-1 downto 0); -- ref_clk_freq_o : out std_logic_vector(g_width-1 downto 0);
start_phase_o : out std_logic_vector(g_width-1 downto 0); start_phase_o : out std_logic_vector(g_width-1 downto 0);
one_hz_phase_o : out std_logic_vector(g_width-1 downto 0); one_hz_phase_o : out std_logic_vector(g_width-1 downto 0)
retrig_freq_o : out std_logic_vector(g_width-1 downto 0) -- retrig_freq_o : out std_logic_vector(g_width-1 downto 0)
); );
end reg_ctrl; end reg_ctrl;
...@@ -126,11 +126,11 @@ signal wr_pointer : std_logic_vector(g_width-1 downto 0); ...@@ -126,11 +126,11 @@ signal wr_pointer : std_logic_vector(g_width-1 downto 0);
signal acam_config : config_vector; signal acam_config : config_vector;
signal starting_utc : std_logic_vector(g_width-1 downto 0); signal starting_utc : std_logic_vector(g_width-1 downto 0);
signal clk_freq : std_logic_vector(g_width-1 downto 0); --signal clk_freq : std_logic_vector(g_width-1 downto 0);
signal ref_clk_freq : std_logic_vector(g_width-1 downto 0); --signal ref_clk_freq : std_logic_vector(g_width-1 downto 0);
signal start_phase : std_logic_vector(g_width-1 downto 0); signal start_phase : std_logic_vector(g_width-1 downto 0);
signal one_hz_phase : std_logic_vector(g_width-1 downto 0); signal one_hz_phase : std_logic_vector(g_width-1 downto 0);
signal retrig_freq : std_logic_vector(g_width-1 downto 0); --signal retrig_freq : std_logic_vector(g_width-1 downto 0);
signal control_register : std_logic_vector(g_width-1 downto 0); signal control_register : std_logic_vector(g_width-1 downto 0);
signal clear_ctrl_reg : std_logic; signal clear_ctrl_reg : std_logic;
...@@ -220,11 +220,11 @@ begin ...@@ -220,11 +220,11 @@ begin
begin begin
if reg_reset ='1' then if reg_reset ='1' then
starting_utc <= (others =>'0'); starting_utc <= (others =>'0');
clk_freq <= (others =>'0'); -- clk_freq <= (others =>'0');
ref_clk_freq <= (others =>'0'); -- ref_clk_freq <= (others =>'0');
start_phase <= (others =>'0'); start_phase <= (others =>'0');
one_hz_phase <= (others =>'0'); one_hz_phase <= (others =>'0');
retrig_freq <= (others =>'0'); -- retrig_freq <= (others =>'0');
elsif reg_cyc ='1' and reg_stb ='1' and reg_we ='1' then elsif reg_cyc ='1' and reg_stb ='1' and reg_we ='1' then
if reg_adr = x"20" then -- corresponds to address 80080 of the gnum BAR 0 if reg_adr = x"20" then -- corresponds to address 80080 of the gnum BAR 0
...@@ -232,24 +232,24 @@ begin ...@@ -232,24 +232,24 @@ begin
end if; end if;
if reg_adr = x"21" then -- corresponds to address 80084 of the gnum BAR 0 if reg_adr = x"21" then -- corresponds to address 80084 of the gnum BAR 0
clk_freq <= reg_data_wr;
end if;
if reg_adr = x"22" then -- corresponds to address 80088 of the gnum BAR 0
ref_clk_freq <= reg_data_wr;
end if;
if reg_adr = x"23" then -- corresponds to address 8008C of the gnum BAR 0
start_phase <= reg_data_wr; start_phase <= reg_data_wr;
end if; end if;
if reg_adr = x"24" then -- corresponds to address 80090 of the gnum BAR 0 if reg_adr = x"22" then -- corresponds to address 80088 of the gnum BAR 0
one_hz_phase <= reg_data_wr; one_hz_phase <= reg_data_wr;
end if; end if;
if reg_adr = x"25" then -- corresponds to address 80094 of the gnum BAR 0 -- if reg_adr = x"23" then -- corresponds to address 8008C of the gnum BAR 0
retrig_freq <= reg_data_wr; -- start_phase <= reg_data_wr;
end if; -- end if;
--
-- if reg_adr = x"24" then -- corresponds to address 80090 of the gnum BAR 0
-- one_hz_phase <= reg_data_wr;
-- end if;
--
-- if reg_adr = x"25" then -- corresponds to address 80094 of the gnum BAR 0
-- retrig_freq <= reg_data_wr;
-- end if;
end if; end if;
wait until reg_clk ='1'; wait until reg_clk ='1';
end process; end process;
...@@ -305,15 +305,14 @@ begin ...@@ -305,15 +305,14 @@ begin
acam_config_rdbk(10) when x"1E", acam_config_rdbk(10) when x"1E",
starting_utc when x"20", starting_utc when x"20",
clk_freq when x"21", start_phase when x"21",
ref_clk_freq when x"22", one_hz_phase when x"22",
start_phase when x"23", -- when x"23",
one_hz_phase when x"24", irq_code when x"24",
retrig_freq when x"25", local_utc when x"25",
local_utc when x"26", -- when x"26",
irq_code when x"27", wr_pointer when x"27",
core_status when x"28", core_status when x"28",
wr_pointer when x"29",
x"FFFFFFFF" when others; x"FFFFFFFF" when others;
-- inputs from other blocks -- inputs from other blocks
...@@ -333,8 +332,9 @@ begin ...@@ -333,8 +332,9 @@ begin
acam_ififo2 <= acam_ififo2_i; acam_ififo2 <= acam_ififo2_i;
acam_start01 <= acam_start01_i; acam_start01 <= acam_start01_i;
irq_code <= irq_code_i; irq_code <= irq_code_i;
core_status <= core_status_i; local_utc <= local_utc_i;
wr_pointer <= wr_pointer_i; wr_pointer <= wr_pointer_i;
core_status <= core_status_i;
-- outputs to other blocks -- outputs to other blocks
reg_ack_o <= reg_ack; reg_ack_o <= reg_ack;
...@@ -351,15 +351,14 @@ begin ...@@ -351,15 +351,14 @@ begin
read_start01_o <= control_register(7); read_start01_o <= control_register(7);
reset_acam_o <= control_register(8); reset_acam_o <= control_register(8);
load_utc_o <= control_register(9); load_utc_o <= control_register(9);
load_tdc_config_o <= control_register(10); clear_dacapo_flag_o <= control_register(10);
clear_dacapo_flag_o <= control_register(11);
starting_utc_o <= starting_utc; starting_utc_o <= starting_utc;
clk_freq_o <= clk_freq; -- clk_freq_o <= clk_freq;
ref_clk_freq_o <= ref_clk_freq; -- ref_clk_freq_o <= ref_clk_freq;
start_phase_o <= start_phase; start_phase_o <= start_phase;
one_hz_phase_o <= one_hz_phase; one_hz_phase_o <= one_hz_phase;
retrig_freq_o <= retrig_freq; -- retrig_freq_o <= retrig_freq;
end rtl; end rtl;
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------
......
...@@ -373,7 +373,7 @@ architecture rtl of top_tdc is ...@@ -373,7 +373,7 @@ architecture rtl of top_tdc is
read_start01_o : out std_logic; read_start01_o : out std_logic;
reset_acam_o : out std_logic; reset_acam_o : out std_logic;
load_utc_o : out std_logic; load_utc_o : out std_logic;
load_tdc_config_o : out std_logic; -- load_tdc_config_o : out std_logic;
clear_dacapo_flag_o : out std_logic; clear_dacapo_flag_o : out std_logic;
-- configuration registers from and for the ACAM and the modules of the TDC core -- configuration registers from and for the ACAM and the modules of the TDC core
...@@ -389,11 +389,11 @@ architecture rtl of top_tdc is ...@@ -389,11 +389,11 @@ architecture rtl of top_tdc is
acam_config_o : out config_vector; acam_config_o : out config_vector;
starting_utc_o : out std_logic_vector(g_width-1 downto 0); starting_utc_o : out std_logic_vector(g_width-1 downto 0);
clk_freq_o : out std_logic_vector(g_width-1 downto 0); -- clk_freq_o : out std_logic_vector(g_width-1 downto 0);
ref_clk_freq_o : out std_logic_vector(g_width-1 downto 0); -- ref_clk_freq_o : out std_logic_vector(g_width-1 downto 0);
start_phase_o : out std_logic_vector(g_width-1 downto 0); start_phase_o : out std_logic_vector(g_width-1 downto 0);
one_hz_phase_o : out std_logic_vector(g_width-1 downto 0); one_hz_phase_o : out std_logic_vector(g_width-1 downto 0)
retrig_freq_o : out std_logic_vector(g_width-1 downto 0) -- retrig_freq_o : out std_logic_vector(g_width-1 downto 0)
); );
end component; end component;
...@@ -630,11 +630,11 @@ signal read_ififo1 : std_logic; ...@@ -630,11 +630,11 @@ signal read_ififo1 : std_logic;
signal read_ififo2 : std_logic; signal read_ififo2 : std_logic;
signal read_start01 : std_logic; signal read_start01 : std_logic;
signal starting_utc : std_logic_vector(g_width-1 downto 0); signal starting_utc : std_logic_vector(g_width-1 downto 0);
signal clk_freq : std_logic_vector(g_width-1 downto 0); --signal clk_freq : std_logic_vector(g_width-1 downto 0);
signal ref_clk_freq : std_logic_vector(g_width-1 downto 0); --signal ref_clk_freq : std_logic_vector(g_width-1 downto 0);
signal start_phase : std_logic_vector(g_width-1 downto 0); signal start_phase : std_logic_vector(g_width-1 downto 0);
signal one_hz_phase : std_logic_vector(g_width-1 downto 0); signal one_hz_phase : std_logic_vector(g_width-1 downto 0);
signal retrig_freq : std_logic_vector(g_width-1 downto 0); --signal retrig_freq : std_logic_vector(g_width-1 downto 0);
signal acam_config_rdbk : config_vector; signal acam_config_rdbk : config_vector;
signal acam_status : std_logic_vector(g_width-1 downto 0); signal acam_status : std_logic_vector(g_width-1 downto 0);
...@@ -891,7 +891,7 @@ begin ...@@ -891,7 +891,7 @@ begin
read_start01_o => read_start01, read_start01_o => read_start01,
reset_acam_o => reset_acam, reset_acam_o => reset_acam,
load_utc_o => load_utc, load_utc_o => load_utc,
load_tdc_config_o => load_tdc_config, -- load_tdc_config_o => load_tdc_config,
clear_dacapo_flag_o => clear_dacapo_flag, clear_dacapo_flag_o => clear_dacapo_flag,
-- configuration registers for the ACAM and the modules of the TDC core -- configuration registers for the ACAM and the modules of the TDC core
...@@ -907,11 +907,13 @@ begin ...@@ -907,11 +907,13 @@ begin
acam_config_o => acam_config, acam_config_o => acam_config,
starting_utc_o => starting_utc, starting_utc_o => starting_utc,
clk_freq_o => clk_freq, -- clk_freq_o => clk_freq,
ref_clk_freq_o => ref_clk_freq, -- ref_clk_freq_o => ref_clk_freq,
start_phase_o => start_phase, -- start_phase_o => start_phase,
one_hz_phase_o => one_hz_phase, -- one_hz_phase_o => one_hz_phase,
retrig_freq_o => retrig_freq start_phase_o => window_delay,
one_hz_phase_o => pulse_delay
-- retrig_freq_o => retrig_freq
); );
clks_rsts_mgment: clk_rst_managr clks_rsts_mgment: clk_rst_managr
...@@ -1029,6 +1031,31 @@ begin ...@@ -1029,6 +1031,31 @@ begin
current_value => open current_value => open
); );
-- (address decoding: memory used has 512 bytes depth)
-----------------------------------------------------
mem_pipe_cyc <= '1' when dma_cyc='1' and dma_adr(31 downto 9)=x"00000" & "000" else '0';
mem_pipe_adr <= dma_adr;
mem_pipe_stb <= dma_stb;
mem_pipe_we <= dma_we;
mem_pipe_data_wr <= dma_dat_w;
dma_ack <= mem_pipe_ack;
dma_dat_r <= mem_pipe_data_rd;
dma_stall <= mem_pipe_stall;
-- CSR master connected to register control slave
--------------------------------------------------
-- address decoding: first 512 kB for GNUM core, second 512 kB for TDC application (of which only 256 bytes are reserved)
reg_cyc <= '1' when csr_cyc(0)='1' and csr_adr(18 downto 8)="010" & x"00" else '0';
reg_adr(31 downto 19) <= (others=>'0');
reg_adr(18 downto 0) <= csr_adr;
reg_stb <= csr_stb;
reg_we <= csr_we;
reg_data_wr <= csr_dat_w;
csr_ack(0) <= reg_ack;
csr_dat_r <= reg_data_rd;
spec_led: process spec_led: process
begin begin
if gnum_reset ='1' then if gnum_reset ='1' then
...@@ -1065,56 +1092,6 @@ begin ...@@ -1065,56 +1092,6 @@ begin
-- internal signals -- internal signals
spec_led_green <= pll_ld_i; spec_led_green <= pll_ld_i;
-- CSR master connected directly to ACAM slave
-----------------------------------------------
-- acm_adr(19) <= '0';
-- acm_adr(18 downto 0) <= csr_adr;
-- acm_cyc <= csr_cyc(0);
-- acm_stb <= csr_stb;
-- acm_we <= csr_we;
-- acm_dat_w <= csr_dat_w;
-- csr_ack(0) <= acm_ack;
-- csr_dat_r <= acm_dat_r;
-- CSR master connected to circular buffer slave
-- DMA master connected to circular buffer pipelined slave
-----------------------------------------------------------
-- -- (address decoding)
-- mem_class_cyc <= '1' when csr_cyc(0)='1' and csr_adr(18 downto 7)=x"400" else '0';
-- mem_class_adr(31 downto 19) <= (others=>'0');
-- mem_class_adr(18 downto 0) <= csr_adr;
--
-- mem_class_stb <= csr_stb;
-- mem_class_we <= csr_we;
-- mem_class_data_wr(127 downto 32) <= (others=>'0');
-- mem_class_data_wr(31 downto 0) <= csr_dat_w;
-- csr_ack(0) <= mem_class_ack;
-- csr_dat_r <= mem_class_data_rd(31 downto 0);
-- (address decoding: memory used has 512 bytes depth)
mem_pipe_cyc <= '1' when dma_cyc='1' and dma_adr(31 downto 9)=x"00000" & "000" else '0';
mem_pipe_adr <= dma_adr;
mem_pipe_stb <= dma_stb;
mem_pipe_we <= dma_we;
mem_pipe_data_wr <= dma_dat_w;
dma_ack <= mem_pipe_ack;
dma_dat_r <= mem_pipe_data_rd;
dma_stall <= mem_pipe_stall;
-- CSR master connected to register memory slave
-----------------------------------------------------------
-- address decoding: first 512 kB for GNUM core, second 512 kB for TDC application (of which only 256 bytes are reserved)
reg_cyc <= '1' when csr_cyc(0)='1' and csr_adr(18 downto 8)="010" & x"00" else '0';
reg_adr(31 downto 19) <= (others=>'0');
reg_adr(18 downto 0) <= csr_adr;
reg_stb <= csr_stb;
reg_we <= csr_we;
reg_data_wr <= csr_dat_w;
csr_ack(0) <= reg_ack;
csr_dat_r <= reg_data_rd;
-- inputs -- inputs
-- gnum_reset <= not(rst_n_a_i) or not(spec_aux1_i); -- gnum_reset <= not(rst_n_a_i) or not(spec_aux1_i);
gnum_reset <= not(rst_n_a_i); gnum_reset <= not(rst_n_a_i);
...@@ -1131,10 +1108,11 @@ begin ...@@ -1131,10 +1108,11 @@ begin
tdc_led_trig4_o <= lf1_i; tdc_led_trig4_o <= lf1_i;
tdc_led_trig5_o <= tdc_led_trig5; tdc_led_trig5_o <= tdc_led_trig5;
-- these will evolve as we implement all the features -- all the section below may evolve as we implement all the features
--------------------------------------------------------------------
irq_p <= dma_irq(0) or dma_irq(1); irq_p <= dma_irq(0) or dma_irq(1);
pulse_delay <= x"00000001"; -- pulse_delay <= x"00000001";
window_delay <= x"00000002"; -- window_delay <= x"00000002";
mute_inputs_o <= '1'; mute_inputs_o <= '1';
term_en_1_o <= '1'; term_en_1_o <= '1';
term_en_2_o <= '1'; term_en_2_o <= '1';
...@@ -1165,7 +1143,8 @@ begin ...@@ -1165,7 +1143,8 @@ begin
wait until clk ='1'; wait until clk ='1';
end process; end process;
start_trig <= tdc_in_fpga_5_i; -- start_trig <= tdc_in_fpga_5_i;
start_trig <= activate_acq;
end rtl; end rtl;
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------
......
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