0
\$\begingroup\$

I am building a simple debouncer with decrementing counter. The syntitizer is yelling that there are latches. I don't need latches. I just need flipflops. WHich part in the following code is creating latches?

Design: The block receives a value and if the value is different from the stored one, it starts to count down. As soon as the counter reaches 0, the block outputs the new value.

library IEEE;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_unsigned.all;
USE ieee.numeric_std.ALL;

entity Debouncer is
    Generic (
          DB_DATA_WIDTH             :   integer range 1 to 8   := 8;
          DB_CLOCKS                 :   integer range 0 to 1023   := 3
    );
    Port(
        clk : in STD_LOGIC; --clock
        Sig : in STD_LOGIC_VECTOR (DB_DATA_WIDTH-1 downto 0);   --raw input signal
        Deb_Sig : out STD_LOGIC_VECTOR (DB_DATA_WIDTH-1 downto 0);
        Deb_Rdy : out STD_LOGIC;
        rst : in STD_LOGIC
    );--debounced output signal
end Debouncer;

architecture Behavioral of Debouncer is

    signal value_reg :STD_LOGIC_VECTOR (DB_DATA_WIDTH-1 downto 0);
    signal tick_counter : unsigned (9 downto 0);



begin

    process (clk, rst) is
    begin

        if (rst = '1') then

            --TO_UNSIGNED(DB_CLOCKS, tick_counter'length)
            tick_counter <= TO_UNSIGNED(DB_CLOCKS, tick_counter'length);
            value_reg <= (others=>'0');

        elsif (clk'event and clk= '1') then

            if (value_reg = Sig) then

                if (tick_counter /= 0) then
                    tick_counter <= tick_counter -1;
                end if;

            else

                value_reg <= Sig;
                tick_counter <= TO_UNSIGNED(DB_CLOCKS, tick_counter'length);

            end if;
        end if;

    end process;

    Deb_Rdy <= '1' when ( tick_counter = 0 ) else '0';--debouncing logic is assigned to the output Deb_sig
    Deb_Sig <= value_reg;

end Behavioral;

Log:

WARNING:Xst:1710 - FF/Latch <Inst_Debouncer/tick_counter_9> (without init value) has a constant value of 0 in block <led_switches>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <Inst_Debouncer/tick_counter_8> (without init value) has a constant value of 0 in block <led_switches>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <Inst_Debouncer/tick_counter_6> (without init value) has a constant value of 0 in block <led_switches>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <Inst_Debouncer/tick_counter_5> (without init value) has a constant value of 0 in block <led_switches>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <Inst_Debouncer/tick_counter_7> (without init value) has a constant value of 0 in block <led_switches>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <Inst_Debouncer/tick_counter_3> (without init value) has a constant value of 0 in block <led_switches>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <Inst_Debouncer/tick_counter_2> (without init value) has a constant value of 0 in block <led_switches>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <Inst_Debouncer/tick_counter_4> (without init value) has a constant value of 0 in block <led_switches>. This FF/Latch will be trimmed during the optimization process.
\$\endgroup\$
1
  • \$\begingroup\$ There are no latches; that's not what the error messages are telling you. \$\endgroup\$
    – user16324
    Mar 27, 2014 at 11:57

1 Answer 1

2
\$\begingroup\$

I believe your synthesizer is telling you that you only need a 2 bit tick_counter since you made DB_CLOCKS 3 in this case. It isn't creating latches, it is trimming FF/Latches (in this case FF).

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.