Pre-inversion

parent bc11ddc1
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
-- --
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- last changes: -- last changes:
-- 2011-11-07 SB Pre-inversion
-- 2011-10-25 SB Disable ring oscillator on reset -- 2011-10-25 SB Disable ring oscillator on reset
-- 2011-08-03 SB Created file -- 2011-08-03 SB Created file
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
...@@ -90,7 +91,9 @@ end entity; ...@@ -90,7 +91,9 @@ end entity;
architecture rtl of tdc_channel is architecture rtl of tdc_channel is
signal calib_sel_d : std_logic; signal calib_sel_d : std_logic;
signal muxed_signal : std_logic; signal muxed_signal : std_logic;
signal inv_signal : std_logic;
signal taps : std_logic_vector(4*g_CARRY4_COUNT-1 downto 0); signal taps : std_logic_vector(4*g_CARRY4_COUNT-1 downto 0);
signal ipolarity : std_logic;
signal polarity : std_logic; signal polarity : std_logic;
signal polarity_d1 : std_logic; signal polarity_d1 : std_logic;
signal polarity_d2 : std_logic; signal polarity_d2 : std_logic;
...@@ -110,6 +113,7 @@ begin ...@@ -110,6 +113,7 @@ begin
end process; end process;
with calib_sel_d select with calib_sel_d select
muxed_signal <= calib_i when '1', signal_i when others; muxed_signal <= calib_i when '1', signal_i when others;
inv_signal <= muxed_signal xor not ipolarity;
cmp_delayline: tdc_delayline cmp_delayline: tdc_delayline
generic map( generic map(
...@@ -118,19 +122,21 @@ begin ...@@ -118,19 +122,21 @@ begin
port map( port map(
clk_i => clk_i, clk_i => clk_i,
reset_i => reset_i, reset_i => reset_i,
signal_i => muxed_signal, signal_i => inv_signal,
taps_o => taps taps_o => taps
); );
cmp_lbc: tdc_lbc cmp_lbc: tdc_lbc
generic map( generic map(
g_N => g_RAW_COUNT, g_N => g_RAW_COUNT,
g_NIN => g_CARRY4_COUNT*4 g_NIN => g_CARRY4_COUNT*4,
g_IGNORE => 2
) )
port map( port map(
clk_i => clk_i, clk_i => clk_i,
reset_i => reset_i, reset_i => reset_i,
d_i => taps, d_i => taps,
ipolarity_o => ipolarity,
polarity_o => polarity, polarity_o => polarity,
count_o => raw count_o => raw
); );
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
-- --
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- last changes: -- last changes:
-- 2011-11-07 SB Pre-inversion
-- 2011-10-27 SB Fix pipeline balance -- 2011-10-27 SB Fix pipeline balance
-- 2011-08-01 SB Created file -- 2011-08-01 SB Created file
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
...@@ -41,14 +42,17 @@ use work.tdc_package.all; ...@@ -41,14 +42,17 @@ use work.tdc_package.all;
entity tdc_lbc is entity tdc_lbc is
generic( generic(
-- Number of output bits. -- Number of output bits.
g_N : positive; g_N : positive;
-- Number of input bits. Maximum is 2^g_N-1. -- Number of input bits. Maximum is 2^g_N-1.
g_NIN: positive g_NIN : positive;
-- Number of cycles to ignore input after a transition.
g_IGNORE : natural
); );
port( port(
clk_i : in std_logic; clk_i : in std_logic;
reset_i : in std_logic; reset_i : in std_logic;
d_i : in std_logic_vector(g_NIN-1 downto 0); d_i : in std_logic_vector(g_NIN-1 downto 0);
ipolarity_o : out std_logic;
polarity_o : out std_logic; polarity_o : out std_logic;
count_o : out std_logic_vector(g_N-1 downto 0) count_o : out std_logic_vector(g_N-1 downto 0)
); );
...@@ -97,6 +101,7 @@ signal polarity_d1 : std_logic; ...@@ -97,6 +101,7 @@ signal polarity_d1 : std_logic;
signal count : std_logic_vector(g_N-1 downto 0); signal count : std_logic_vector(g_N-1 downto 0);
signal count_d1 : std_logic_vector(g_N-1 downto 0); signal count_d1 : std_logic_vector(g_N-1 downto 0);
signal d_completed : std_logic_vector(2**g_N-2 downto 0); signal d_completed : std_logic_vector(2**g_N-2 downto 0);
signal ignore : std_logic;
-- enable retiming -- enable retiming
attribute register_balancing: string; attribute register_balancing: string;
...@@ -105,7 +110,7 @@ attribute register_balancing of count_d1: signal is "backward"; ...@@ -105,7 +110,7 @@ attribute register_balancing of count_d1: signal is "backward";
begin begin
g_expand: if g_NIN < 2**g_N-1 generate g_expand: if g_NIN < 2**g_N-1 generate
d_completed <= d_i & (2**g_N-1-g_NIN-1 downto 0 => not polarity); d_completed <= d_i & (2**g_N-1-g_NIN-1 downto 0 => '0');
end generate; end generate;
g_dontexpand: if g_NIN = 2**g_N-1 generate g_dontexpand: if g_NIN = 2**g_N-1 generate
d_completed <= d_i; d_completed <= d_i;
...@@ -120,13 +125,43 @@ begin ...@@ -120,13 +125,43 @@ begin
count <= (others => '0'); count <= (others => '0');
count_d1 <= (others => '0'); count_d1 <= (others => '0');
else else
polarity <= not d_completed(2**g_N-2); if (d_completed(2**g_N-2) = '1') and (ignore = '0') then
polarity <= not polarity;
end if;
polarity_d1 <= not polarity; polarity_d1 <= not polarity;
count <= f_cls(d_completed, polarity); count <= f_cls(d_completed, '1');
count_d1 <= count; count_d1 <= count;
end if; end if;
end if; end if;
end process; end process;
g_ignoresr: if g_IGNORE > 0 generate
signal ignore_sr: std_logic_vector(g_IGNORE-1 downto 0);
begin
process(clk_i)
begin
if rising_edge(clk_i) then
if reset_i = '1' then
ignore_sr <= (others => '0');
else
if (d_completed(2**g_N-2) = '1') and (ignore = '0') then
ignore_sr <= (others => '0');
ignore_sr(g_IGNORE-1) <= '1';
else
ignore_sr <= "0" & ignore_sr(g_IGNORE-1 downto 1);
end if;
end if;
end if;
end process;
ignore <= '0' when (ignore_sr = (ignore_sr'range => '0')) else '1';
end generate;
g_noignore: if g_IGNORE = 0 generate
begin
ignore <= '0';
end generate;
ipolarity_o <= polarity;
polarity_o <= polarity_d1; polarity_o <= polarity_d1;
count_o <= count_d1; count_o <= count_d1;
end architecture; end architecture;
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
-- --
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- last changes: -- last changes:
-- 2011-11-07 SB Pre-inversion
-- 2011-11-05 SB Added extra histogram bits support -- 2011-11-05 SB Added extra histogram bits support
-- 2011-10-25 SB Added single/multi channel bank components -- 2011-10-25 SB Added single/multi channel bank components
-- 2011-08-03 SB Created file -- 2011-08-03 SB Created file
...@@ -339,13 +340,15 @@ end component; ...@@ -339,13 +340,15 @@ end component;
component tdc_lbc is component tdc_lbc is
generic( generic(
g_N : positive; g_N : positive;
g_NIN : positive g_NIN : positive;
g_IGNORE : natural
); );
port( port(
clk_i : in std_logic; clk_i : in std_logic;
reset_i : in std_logic; reset_i : in std_logic;
d_i : in std_logic_vector(g_NIN-1 downto 0); d_i : in std_logic_vector(g_NIN-1 downto 0);
ipolarity_o : out std_logic;
polarity_o : out std_logic; polarity_o : out std_logic;
count_o : out std_logic_vector(g_N-1 downto 0) count_o : out std_logic_vector(g_N-1 downto 0)
); );
......
...@@ -41,11 +41,11 @@ NET "tdc_signal_p[1]" LOC = W12 | IOSTANDARD = "LVDS_25"; ...@@ -41,11 +41,11 @@ NET "tdc_signal_p[1]" LOC = W12 | IOSTANDARD = "LVDS_25";
NET "tdc_signal_n[1]" LOC = Y12 | IOSTANDARD = "LVDS_25"; NET "tdc_signal_n[1]" LOC = Y12 | IOSTANDARD = "LVDS_25";
# ==== TDC core ==== # ==== TDC core ====
NET "tdc/cmp_tdc/cmp_channelbank/g_multi.cmp_channelbank/g_channels[0].cmp_channel/muxed_signal" TIG; NET "tdc/cmp_tdc/cmp_channelbank/g_multi.cmp_channelbank/g_channels[0].cmp_channel/inv_signal" TIG;
NET "tdc/cmp_tdc/cmp_channelbank/g_multi.cmp_channelbank/g_channels[1].cmp_channel/muxed_signal" TIG; NET "tdc/cmp_tdc/cmp_channelbank/g_multi.cmp_channelbank/g_channels[1].cmp_channel/inv_signal" TIG;
INST "tdc/cmp_tdc/cmp_channelbank/g_multi.cmp_channelbank/g_channels[0].cmp_channel/Mmux_muxed_signal11" LOC = SLICE_X35Y0; INST "tdc/cmp_tdc/cmp_channelbank/g_multi.cmp_channelbank/g_channels[0].cmp_channel/Mxor_inv_signal_xo<0>1" LOC = SLICE_X35Y0;
INST "tdc/cmp_tdc/cmp_channelbank/g_multi.cmp_channelbank/g_channels[1].cmp_channel/Mmux_muxed_signal11" LOC = SLICE_X35Y0; INST "tdc/cmp_tdc/cmp_channelbank/g_multi.cmp_channelbank/g_channels[1].cmp_channel/Mxor_inv_signal_xo<0>1" LOC = SLICE_X35Y0;
INST "tdc/cmp_tdc/cmp_channelbank/g_multi.cmp_channelbank/g_channels[0].cmp_channel/cmp_delayline/g_carry4[0].g_firstcarry4.cmp_CARRY4" LOC = SLICE_X30Y2; INST "tdc/cmp_tdc/cmp_channelbank/g_multi.cmp_channelbank/g_channels[0].cmp_channel/cmp_delayline/g_carry4[0].g_firstcarry4.cmp_CARRY4" LOC = SLICE_X30Y2;
INST "tdc/cmp_tdc/cmp_channelbank/g_multi.cmp_channelbank/g_channels[1].cmp_channel/cmp_delayline/g_carry4[0].g_firstcarry4.cmp_CARRY4" LOC = SLICE_X32Y2; INST "tdc/cmp_tdc/cmp_channelbank/g_multi.cmp_channelbank/g_channels[1].cmp_channel/cmp_delayline/g_carry4[0].g_firstcarry4.cmp_CARRY4" LOC = SLICE_X32Y2;
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
-- --
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- last changes: -- last changes:
-- 2011-11-07 SB Pre-inversion
-- 2011-08-12 SB Test pipelining and polarity inversion -- 2011-08-12 SB Test pipelining and polarity inversion
-- 2011-08-03 SB Created file -- 2011-08-03 SB Created file
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
...@@ -93,24 +94,27 @@ begin ...@@ -93,24 +94,27 @@ begin
return result; return result;
end function; end function;
signal clk : std_logic; signal clk : std_logic;
signal reset : std_logic; signal reset : std_logic;
signal d : std_logic_vector(2**g_N-2 downto 0); signal d : std_logic_vector(2**g_N-2 downto 0);
signal count : std_logic_vector(g_N-1 downto 0); signal count : std_logic_vector(g_N-1 downto 0);
signal polarity : std_logic; signal ipolarity : std_logic;
signal polarity : std_logic;
begin begin
cmp_dut: tdc_lbc cmp_dut: tdc_lbc
generic map( generic map(
g_N => g_N, g_N => g_N,
g_NIN => 2**g_N-1 g_NIN => 2**g_N-1,
g_IGNORE => 0
) )
port map( port map(
clk_i => clk, clk_i => clk,
reset_i => reset, reset_i => reset,
d_i => d, d_i => d,
count_o => count, ipolarity_o => ipolarity,
polarity_o => polarity polarity_o => polarity,
count_o => count
); );
process process
variable v_polarity : std_logic; variable v_polarity : std_logic;
...@@ -122,6 +126,7 @@ begin ...@@ -122,6 +126,7 @@ begin
variable v_stim : std_logic_vector(0 downto 0); variable v_stim : std_logic_vector(0 downto 0);
begin begin
-- reset -- reset
d <= (others => '0');
reset <= '1'; reset <= '1';
clk <= '0'; clk <= '0';
wait for 5 ns; wait for 5 ns;
...@@ -150,7 +155,9 @@ begin ...@@ -150,7 +155,9 @@ begin
end if; end if;
end loop; end loop;
report "Vector out: " & str(v_d) & " (polarity: " & chr(v_polarity) & ")"; report "Vector out: " & str(v_d) & " (polarity: " & chr(v_polarity) & ")";
d <= v_d; for j in 0 to 2**g_N-2 loop
d(j) <= v_d(j) xor not ipolarity;
end loop;
end if; end if;
-- verify output -- verify output
if i > 2 then if i > 2 then
......
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