Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

Shift register with asynchronous parallel load : Latch warning

Hello,

I am trying to instantiate a Shift Register with an asynchronous parallel Load.

My design works like a charm but there is a warning that makes me not comfortable with it.

Warning: Presettable and clearable registers converted to equivalent circuits with latches. Registers power-up to an undefined state, and DEVCLRn places the registers in an undefined state.
    Warning (13310): Register "tmp" is converted into an equivalent circuit using register "tmp~_emulated" and latch "tmp~latch"
   ...
    Warning (13310): Register "tmp" is converted into an equivalent circuit using register "tmp~_emulated" and latch "tmp~latch"

My code is the following :


library ieee;
use ieee.std_logic_1164.all;
entity shift_reg is  
port
(
    C, ALOAD : in std_logic :='0';     
    D            : in std_logic_vector(15 downto 0):= (others =>'0');       
    SO          : out std_logic:='0'
);
end shift_reg;
architecture archi of shift_reg is  
signal tmp     : std_logic_vector(16 downto 0) REGISTER := "00000000000000000";
signal adata : std_logic_vector(16 downto 0) REGISTER := (others=>'0');
signal count : integer :=0;
begin 
    
    process (C,ALOAD,adata) is
    begin
    if ALOAD='1' then
    tmp <=adata;
    elsif (C'event and C='1') then
        If Count<16 then
        tmp <= tmp(15 downto 0) & '0';
        end if;
    end if;
    end process;
     
    process(C, ALOAD)
    begin
    if (ALOAD = '1') then
    count <= 0;
    elsif (C'event and C='1') then
    count <= count + 1;
    end if;
    end process;
    
adata <= '0' & D;
SO     <= tmp(16);
end archi;

My question is what should i do to prevent those latches mentionned in the Warning lines?

Are those latches caused by the 'if' statement case, when 'ALOAD' and 'C' are both inactive?

Thanks in advance.

12 Replies