He creado el siguiente módulo VHDL, que se utiliza como un contador arriba / abajo.
entity counter is
Port(clk : in STD_LOGIC;
count_clk : in STD_LOGIC;
reset : in STD_LOGIC;
count_up : in STD_LOGIC;
count_down : in STD_LOGIC;
counting : out STD_LOGIC;
value : out signed(19 downto 0));
end counter;
architecture Behavioral of counter is
signal temp_value : signed(19 downto 0) := (others => '0');
signal last_clk_val : STD_LOGIC := '0';
begin
process(clk, reset)
begin
if (reset = '1') then
temp_value <= (others => '0');
elsif (rising_edge(clk)) then
if (last_clk_val = '0' and count_clk = '1') then
if (count_up = '1') then
temp_value <= temp_value + 1;
elsif (count_down = '1') then
temp_value <= temp_value - 1;
end if;
end if;
end if;
end process;
last_clk_val <= count_clk;
counting <= count_up or count_down;
value <= temp_value;
end Behavioral;
ISE me presenta la siguiente advertencia (para cada bit de temp_value):
WARNING:Xst:1896 - Due to other FF/Latch trimming, FF/Latch <ttl_top_inst/COUNTER_COMPONENT/temp_value_0> has a constant value of 0 in block <ttl_oneshot_inputs_top>. This FF/Latch will be trimmed during the optimization process.
Al agregar las siguientes líneas al código marcado con - LAS LÍNEAS AÑADIDAS elimina la advertencia, pero el valor de temperatura no debe modificarse en ese punto del código.
entity counter is
Port(clk : in STD_LOGIC;
count_clk : in STD_LOGIC;
reset : in STD_LOGIC;
count_up : in STD_LOGIC;
count_down : in STD_LOGIC;
counting : out STD_LOGIC;
value : out signed(19 downto 0));
end counter;
architecture Behavioral of counter is
signal temp_value : signed(19 downto 0) := (others => '0');
signal last_clk_val : STD_LOGIC := '0';
begin
process(clk, reset)
begin
if (reset = '1') then
temp_value <= (others => '0');
elsif (rising_edge(clk)) then
if (last_clk_val = '0' and count_clk = '1') then
if (count_up = '1') then
temp_value <= temp_value + 1;
elsif (count_down = '1') then
temp_value <= temp_value - 1;
end if;
else --ADDED LINES
temp_value <= temp_value - 1; --ADDED LINES
end if;
end if;
end process;
last_clk_val <= count_clk;
counting <= count_up or count_down;
value <= temp_value;
end Behavioral;
El código funciona sin problemas en la simulación, pero sé que la simulación no es igual a la implementación real.
¿Podría alguien darme instrucciones sobre cómo solucionar este problema?
Gracias de antemano!