2013-09-26 2 views
0

오류 : 오류 : Xst : 787 - "E : /tumama/tytyty.vhd"줄 54 : 색인 값 < 4>가 범위 내에 있지 않습니다. 배열의.일반 바이너리 그레이 바이너리 변환기, 논리 오류

"임베디드 신호 A"는 5 비트의 n을 가지고 있습니다. 한 경우에만 4 비트로 변환하려고합니다. 그래서 의견이 동시 코드

위한 Y 4 개 비트를 가지고 있지만 난 루프 지수 i는 액세스하려는 다음 값 n-1에 도달하면 그것을 감사

library IEEE; 
    use IEEE.STD_LOGIC_1164.ALL; 



entity FirstTermExamen is 

    Generic (n: natural := 4); 

    Port (Num : in STD_LOGIC_VECTOR (n-1 downto 0); 
      Sel : in STD_LOGIC; 
      Y : out STD_LOGIC_VECTOR (n-1 downto 0) 
      ); 

end FirstTermExamen; 

architecture Behavioral of FirstTermExamen is 

    signal A: STD_LOGIC_VECTOR (n downto 0); 

begin 

-- --Secuencial Description 
-- Binary_Gray : process(A, Num, Sel) 
--  begin 
-- 
-- --Initial conditions 
-- A(0) <= Num(0); 
-- A(1) <= Num(0) xor Num(1); 
-- 
-- for i in 1 to n-1 loop 
--   if Sel = '1' then A(i+1) <= Num(i) xor Num(i+1); 
--   else    A(i+1) <= A(i) xor Num(i+1); 
--   
--   end if; 
--  
-- end loop; 
-- 
-- for j in 0 to n loop 
--   Y(j)<= A(j); 
--   
--  end loop; 
-- 
--end process Binary_Gray; 

    --Concurrent Description 
    A(0) <= Num(0); 
    A(1) <= Num(0) xor Num(1); 


    Binary_Gray: 
    for i in 1 to n-1 generate 
     begin 
      A(i+1) <= Num(i) xor Num(i+1) when Sel = '1' else 
        A(i) xor Num(i+1); 

     end generate; 

    output: 
     for j in 0 to n generate 
     begin 
      Y(j)<= A(j); 

     end generate; 

end Behavioral; 

답변

2

을 얻을 해달라고 Num(n). 그러나 은 (n-1 downto 0) 범위에 대해서만 정의됩니다. 당신은 3-1에서 i 값을 생성
하지만, 액세스 Num(i+1) 따라서 Num(4) : 기본 경우와 같이

숫자 예, N = 4 일 것이다. 그러나 위에서 설명한대로 Num3 downto 0 범위에서만 정의됩니다.