Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
21615 Discussions

inferring latch error

Altera_Forum
Honored Contributor II
1,443 Views

Hi, I'm new to VHDL and I am trying to set up a program that will take a 14 bit encoder input and output it to a 12 bit synchro converter. But the code must also create a gear ratio for the synchro converter. For every full revolution of the encoder the synchro converter increments by 1. But I keep getting this error in my code: Warning (10631): VHDL Process Statement warning at bin_to_int.vhd(21): inferring latch(es) for signal or variable "output", which holds its previous value in one or more paths through the process. Then it tell me my output is permanently disabled. Can anyone help me with this? here is my code: 

 

library ieee; 

use ieee.std_logic_1164.ALL; 

use ieee.numeric_std.ALL; 

entity bin_to_int is 

port( 

signal input_vect :IN std_logic_vector(13 downto 0); 

signal synchro_1 :OUT integer range 0 to 4095 

);  

end entity bin_to_int; 

 

architecture behavioral of bin_to_int is  

 

---General Declarations--- 

signal input :integer range 0 to 16383; 

signal prev_input :integer range 0 to 16383; 

 

begin 

 

synchro_output :process (input_vect, input, prev_input) 

---Variable Declarations--- 

variable val :integer range 0 to 16383 := 0;  

variable output :integer range 0 to 4095 := 0; 

 

begin 

 

prev_input <= val; 

val := to_integer(unsigned(input_vect)); 

input <= val; 

 

if input = 16383 and prev_input = 0 then --Deceasing encoder value and decreasing synchro angle 

if output = 0 then -- If synchro angle is 0 degrees restart it to 360 degrees 

output := 4095;  

end if; 

output := output - 1; 

elsif input = 0 and prev_input = 16383 then --Increasing encoder value and increasing synchro angle 

if output = 4095 then -- If synchro angle is 360 degrees restart it to 0 degrees 

output := 0; 

end if; 

output := output + 1; 

end if; 

 

synchro_1 <= output; --Value of the 1:1 synchro signal 

 

end process synchro_output;  

end architecture behavioral;
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
710 Views

I don't see a chance that the code gives reliable results without a clock.

0 Kudos
Altera_Forum
Honored Contributor II
710 Views

add a clock, and it will all sort itself out.

0 Kudos
Altera_Forum
Honored Contributor II
710 Views

Add a clock and also it seems that your 'if' statements have ony one condition and no 'else' condition...this some time infer latches to your design...

0 Kudos
Altera_Forum
Honored Contributor II
710 Views

 

--- Quote Start ---  

Add a clock and also it seems that your 'if' statements have ony one condition and no 'else' condition...this some time infer latches to your design... 

--- Quote End ---  

 

 

This is only a problem when you dont have a clock.
0 Kudos
Reply