2012-12-05 2 views
1

내가 자일링스 14.3에서 VHDL 코딩 해요 그리고 Nexys이 보드를 목표로하고있다 *. * 내가 읽은 바로는내 VHDL 코드에 래치가있는 이유는 무엇입니까? 출력이 아닌 경우 문을/경우 또는 때

는 래치는 불완전 거기에서 오는 가능한 모든 경로에 설정하십시오.

나는 여러 번 코드를 살펴 봤지만 여전히 두 개의 래치를 얻고 있습니다. 이제

WARNING:Xst:737 - Found 8-bit latch for signal <DR>. Latches may be generated from incomplete case or if statements. We do not recommend the use of latches in FPGA/CPLD designs, as they may lead to timing problems. 
WARNING:Xst:737 - Found 8-bit latch for signal <P>. Latches may be generated from incomplete case or if statements. We do not recommend the use of latches in FPGA/CPLD designs, as they may lead to timing problems. 

, 등, 일부 신호가 사용되지 않고 큰 덩어리가 주석 때문에 나는 몇 가지 다른 오류를 얻고있다 ...하지만 난 내 코드 아직 아니에요 그것은 문제가되지 않습니다 지금.

그래서 모든 경로가 각 출력을 설정할 때 왜이 코드에서 래치가 계속 발생합니까? 그래서 그들은 변화하지 않거나 말해서 최근 값을 유지;

library IEEE; 
use IEEE.STD_LOGIC_1164.ALL; 
use IEEE.STD_LOGIC_ARITH.ALL; 
use IEEE.STD_LOGIC_UNSIGNED.ALL; 

-- Uncomment the following library declaration if using 
-- arithmetic functions with Signed or Unsigned values 
--use IEEE.NUMERIC_STD.ALL; 

-- Uncomment the following library declaration if instantiating 
-- any Xilinx primitives in this code. 
--library UNISIM; 
--use UNISIM.VComponents.all; 

entity project2vhd is 
    Port (CE_s : in STD_LOGIC; 
      A0 : in STD_LOGIC; 
      RD_s : in STD_LOGIC; 
      WR_s : in STD_LOGIC; 
      RESET : in STD_LOGIC; 
      ACK_s : inout STD_LOGIC; 
       Y1, Y2, Y3 : inout STD_LOGIC; 

--   Din : in STD_LOGIC_VECTOR (7 downto 0);  
--   Dout : out STD_LOGIC_VECTOR (7 downto 0); 
       D : inout STD_LOGIC_VECTOR (7 downto 0); 

       EN_s : out STD_LOGIC; 

      P : inout STD_LOGIC_VECTOR (7 downto 0)); 


end project2vhd; 

architecture Behavioral of project2vhd is 

signal CR : STD_LOGIC_VECTOR (1 downto 0); 
signal SR : STD_LOGIC_VECTOR (2 downto 0); 
signal DR : STD_LOGIC_VECTOR (7 downto 0); 

begin 

process (WR_s, ACK_s, RESET, A0, RD_s) 

begin 



if (RESET = '1') then --if reset is high 
    Y1 <= '0'; 
    Y2 <= '0'; 
    Y3 <= '0'; 
    D <= "ZZZZZZZZ"; 
    EN_s <= '0'; --check EN_s's value at reset 
    P <= P; 
    DR<= DR; 


else 
    D <= D; 
    DR <= DR; 
    P <= P; 

-- if (CR(0) = '1') then --Mode 1  
--  
--  Y1 <= ((Y1 and (not Y2) and Y3) or 
--    (WR_s and ACK_s and (not Y2) and Y3)); 
--  Y2 <= '0'; 
--  Y3 <= (((not Y1) and (not Y2) and Y3) or 
--    (WR_s and ACK_s and (not Y2) and Y3) or 
--    ((not Y1) and (not Y2) and (not WR_s) and ACK_s) or 
--    ((not WR_s) and (not Y2) and Y3)); 
--  SR(2) <=(((not ACK_s) and (not Y2) and (not Y3)) or --obf 
--    (WR_s and (not ACK_s) and (Y1) and (not Y2)) or 
--    (WR_s and (not ACK_s) and (not Y2) and Y3) or 
--    (WR_s and (not Y1) and (not Y2))); 
--  SR(0) <= (((not Y2) and (not Y3)) or --INTR_enable 
--     (WR_s and (not Y1) and (not Y2)) or 
--     ((not WR_s) and (not ACK_s) and (not Y1) and (not Y2) and Y3)); 
--       
--       
--  if (CE_s = '1') then 
--   D <= "ZZZZZZZZ"; 
--  
--  else 
--   if (WR_s = '0' and A0 = '0') then --Write Data (MODE 1) 
--    EN_s <= '0'; -- enable buffer 
--    
--    DR <= D; 
--    P <= D; 
--    
--   elsif (WR_s = '0' and A0 = '1') then --control Reg Mode (MODE 1 and 0) 
--    EN_s <= '0'; -- enable buffer 
--    
--    CR(0) <= D(0); 
--    CR(1) <= D(1); 
----    SR(0) 
----    SR(1) 
----    SR(2) 
--    
--    
--   elsif (RD_s = '0' and A0 = '1') then -- Read Status (MODE 1) 
--    EN_s <= '1'; -- disable buffer 
--    
--    D <= DR;  
----    D <= "10101010" 
-- 
--   else 
--    EN_s <= '0'; -- enable buffer 
--    D <= "ZZZZZZZZ"; 
-- 
--   end if; 
--  end if; 
-- else --Mode 0 

     SR <= "111"; 

     if (CE_s = '0' and WR_s = '0' and A0 = '1') then 
      EN_s <= '0'; -- enable buffer 
      DR <= D; 
      CR(1) <= D(1); 
      CR(0) <= D(0); 
      P <= P; 


     elsif (CE_s = '0' and WR_s = '0' and A0 = '0') then 
      EN_s <= '1'; -- disable buffer 
      P <= DR; 
      DR <= DR; 

     else 
      EN_s <= '0'; -- enable buffer 
      D <= "ZZZZZZZZ"; 
      DR <= DR; 
      P <= P; 


     end if; 
-- end if; 

end if; 

end process; 

end Behavioral; 

답변

2

때문에 다양한 조건 하에서 DR 및 P 신호 (DR < = DR 즉)은 자신에게 할당된다. 그것은 래치입니다.

+0

나는 래치를 고치기를 바라는 사람들을 실제로 추가했다. 다시 테스트하려면 자체를 할당 할 때마다 제거했지만 여전히 정확한 래치를 얻고 있습니다. 다른 수정 사항을 알고 있습니까? – twbbas

+0

만약 당신이 어떤 경우에 신호를 할당하지 않는다면, 그 신호를 그 자신에게 할당하는 것과 같은 의미를 갖거나 "마지막 값 기억"은 당신이 래치를 만들었다는 것을 의미합니다. 래치를 원하지 않으면 입력 문에 기반한 값을 조건문의 모든 코드 경로에서 각 출력에 명시 적으로 할당해야합니다. –

3

DR <= DR; 사본 두 개를 모두 제거 했습니까? 시작시 기본값과 "else"둘 다 제거하십시오.

"else"하나를 삭제하지 말고 DR <= (others => '0'); 또는 그 일부로 바꾸십시오. 래치가 사라져야합니다. 래치를 생성하는 방법에는 두 가지가 있습니다 : DR <= DR;과 DR을 할당하지 않은 채 프로세스를 통과하는 경로. 따라서 삭제 또는 주석 처리만으로는 작업을 수행 할 수 없습니다.

래치를 원하지 않지만 일부 상황에서 DR이 이전 값을 유지하도록하려면 클록 처리가 필요합니다.이 경우 DR에 레지스터를 넣을 수 있습니다.

그런 경우 일반적으로 민감도 목록에 시계와 리셋이 있고 읽기가 비동기로 유지되는 경우 읽기 액세스에 필요한 신호가 있습니다. 그러나 완벽하게 계시 된 디자인이 더 나은 실천입니다.