2014-01-21 4 views
2

누구든지이 코드를 왜 시뮬레이션 할 수 없는지 말할 수 있습니까? 동작 확인 구문이 올바른 것입니다. 나는 상수 인 정수의 2D 배열을 만들려고합니다.VHDL 2D 배열

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

--selection function 1 

entity S1 is 
    Port ( 
    i : in STD_LOGIC_VECTOR (5 downto 0); 
    o : out STD_LOGIC_VECTOR (3 downto 0)); 
end S1; 

architecture Behavioral of S1 is 

    type matrix is array(0 downto 3, 0 downto 15) of INTEGER range 0 to 15; 
    constant m : matrix := 
     ((14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7), 
     (0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8), 
     (4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0), 
     (15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13)); 

    signal row : STD_LOGIC_VECTOR(1 downto 0); 
    signal col : STD_LOGIC_VECTOR(3 downto 0); 

begin 

    row <= i(5) & i(0); 
    col <= i(4 downto 1); 
    o <= conv_std_logic_vector(m(conv_integer(row), conv_integer(col)), 4); 

end Behavioral; 

해결책 : 0 (N)이어야하며 (0 downto N)이 아니어야합니다. 오류 메시지가 분명하지 않습니다.

+0

시뮬레이션 할 수 없다고 할 때 무슨 뜻입니까? 실행되지 않습니까? 아니면 잘못된 결과가 나옵니까? 내가 보는 한 가지는 2D 벡터를 0 downto 3으로 정의했다는 것입니다. 이것은 3 downto 0이어야합니다. 당신이 그것을 뒤로 할 때 어떤 일이 발생하는지 잘 모르겠습니다. – Russell

답변

7

더 나은 구문 검사기가 필요합니다.

GHDL 보고서 :

ghdl -a --ieee=synopsys nullrange.vhd 
nullrange.vhd:18:7: too many elements associated 
nullrange.vhd:18:7: range length is beyond subtype length 
nullrange.vhd:18:7: too many elements associated 
nullrange.vhd:18:7: range length is beyond subtype length 
nullrange.vhd:19:6: too many elements associated 
nullrange.vhd:19:6: subaggregate length mismatch 
nullrange.vhd:20:6: too many elements associated 
nullrange.vhd:20:6: subaggregate length mismatch 
nullrange.vhd:21:6: too many elements associated 
nullrange.vhd:21:6: subaggregate length mismatch 
nullrange.vhd:17:10: default value length does not match object type length 
ghdl: compilation error 

(0 3 downto)는 법적으로 허용되지만 회원이없는 "널 범위"라고합니다. 따라서 초기화 집합에 너무 많은 요소가 있습니다 ...

+0

감사합니다. 나는 그 때의 성명서로 그것을 구현해야한다. – crow

+1

반드시 그렇지는 않습니다. '(3 downto 0)'또는 그 방향 (''0 ~ 3 ')을 뒤집는 것이 더 쉬울 수도 있습니다. –

+0

감사합니다. 문제가 무엇인지 이해했습니다. 오류 메시지는 매우 명확하지 않습니다. – crow