Altera_Forum
Honored Contributor
14 years agoinferred latches in state machine \ general VHDL
hi all
the state machine below is part of a windowing function. It all builds OK, but I get a lot of.. Warning (10631): VHDL Process Statement warning at window.vhd(103): inferring latch(es) for signal or variable "PacketIndex", which holds its previous value in one or more paths through the process .. is it just a matter of having an assignment in every state? even when there's nothing to do? like PacketIndex<=PacketIndex ? would things like that get optimised out by the synthesiser? main : process (StateMachine,StartWindow,TheInput,HannTable,PacketIndex,result,resultlv) begin case StateMachine is when newpacket => PacketIndex <= 0; NextState <= idle; when idle => if (StartWindow = '1') then NextState <= load; else NextState <= idle; end if; when load => --another surplus state NextState <= math1; when math1 => result <= TheInput*HannTable(PacketIndex); NextState <= math2; when math2 => resultlv <= std_logic_vector(to_signed(result,22)); NextState <= math3; when math3 => realout <= resultlv(21 downto 6); NextState <= math3; PacketIndex <= PacketIndex+1; when strobehigh => realoutstrobe <= '1'; NextState <= wait1; when wait1 => NextState <= wait2; when wait2 => NextState <= strobelow; when strobelow=> NextState <= waitend; realoutstrobe <= '0'; when waitend => if (PacketIndex = 64) then PacketIndex <= 0; NextState <= idle; elsif (StartWindow = '0') then NextState <= idle; PacketIndex <= PacketIndex; else NextState <= waitend; PacketIndex <= PacketIndex; end if; when others => NextState <= idle; PacketIndex <= 0; end case; end process;