2015-01-20 7 views
0

이 내가 내가이 오류, C에서 ForLoop 루프 (# 치명적인 오류가 ModelSim을 그것을 시뮬레이션 오류 봉오리가없는치명적인 오류가

컴파일에서
library IEEE; 
use IEEE.STD_LOGIC_1164.ALL; 
use IEEE.STD_LOGIC_UNSIGNED.ALL; 
use ieee.std_logic_arith.all; 
use ieee.numeric_std.all; 
USE IEEE.STD_LOGIC_TEXTIO.ALL; 
USE STD.TEXTIO.ALL; 

entity inst_mem is 
    port(
     load: in std_logic; 
     address: in std_logic_vector (5 downto 0); 

     dataout: out std_logic_vector (10 downto 0) 
     ); 
end entity; 

architecture arch_inst_mem of inst_mem is 
    TYPE inst_mem is array (0 to 32) of std_logic_vector(10 downto 0); 

    procedure init_mem(variable memory : out inst_mem; 
            constant datafile : string) is 
     file stddata: text; 
     variable l: line; 
     variable data: std_logic_vector (10 downto 0); 
    begin 
     file_open (stddata, datafile, READ_MODE); 
     for i in memory'range(1) loop 
      readline (stddata, l); 
      read (l, data); 
      memory(i):= data; 
     end LOOP; 
    end procedure; 


begin 
    process (load , address) 
    variable memory: inst_mem; 
    begin 
    if (load = '1') then 
     init_mem (memory, "inst_mem.txt"); 
     dataout <= memory (conv_integer(address)); 
    end if; 
    end process; 
end arch_inst_mem; 

VHDL에 내 코드입니다 :/사용자 /Bana/Desktop/Q1/inst_mem.vhd 줄 29) 왜? 고마워, 바나.

+1

이 적어도, init_memory' 절차'의 끝에서'file_close' 호출을 추가'file_open'에 맞게. 'inst_mem.txt'파일에 올바른 항목 수가 있는지 확인하십시오. 주소 포트가 6 비트이므로 홀수가 64 개 (2 ** 6)이고 33 개 항목 (0 ~ 32)이 읽히는 경우가 있으므로 홀수입니다. 또한'IEEE.STD_LOGIC_UNSIGNED'와'ieee.std_logic_arith'는 비표준이고'ieee.numeric_std'로 대체 될 수 있기 때문에'ieee.numeric_std' 패키지 만 사용하는 것을 고려하십시오. –

+0

29 번줄은 어디에 있습니까? – Paebbels

+1

Morten이 제안한대로 하나의 산술 라이브러리 만 사용하십시오. 왜 당신의 RAM 33 항목이 있습니까? 오류를 방지하기 위해 for 루프에 EOF 테스트를 추가해야합니다. – Paebbels

답변

4

브라이언의 의견을 뒷받침하기 위해 for 루프에 3 개의 문만 있습니다. stddata 파일에 문제가있는 것 같습니다. 패트릭 레만 (Patrick Lehmann)은 EOF (ENDFILE) 테스트를 통해 파일이 부족한 지 확인할 수 있다고 말합니다. inst_mem은 배열 (0에서 32)이고 Morten Zilmer 노트는 33 개입니다.

나는 (당신이 아키텍처 선언적 지역에서 여분의 물건을 무시할 수있는 -1993 준수 VHDL 도구를 지원하기 위해 변경 및 패키지 numeric_std에 to_integer하는 conv_integer에서 전환) 모델을 인스턴스화 :

library IEEE; 
use IEEE.STD_LOGIC_1164.ALL; 
-- use IEEE.STD_LOGIC_UNSIGNED.ALL; 
-- use ieee.std_logic_arith.all; 
use ieee.numeric_std.all; 
-- USE IEEE.STD_LOGIC_TEXTIO.ALL; 
USE STD.TEXTIO.ALL; 

entity inst_mem is 
    port(
     load: in std_logic; 
     address: in std_logic_vector (5 downto 0); 

     dataout: out std_logic_vector (10 downto 0) 
     ); 
end entity; 

architecture arch_inst_mem of inst_mem is 
    TYPE inst_mem is array (0 to 32) of std_logic_vector(10 downto 0); 

    type MVL9plus is ('U', 'X', '0', '1', 'Z', 'W', 'L', 'H', '-', ERROR); 
    type MVL9_indexed_by_char is array (character) of STD_ULOGIC; 
    type MVL9plus_indexed_by_char is array (character) of MVL9plus; 

    constant char_to_MVL9: MVL9_indexed_by_char := 
     ('U' => 'U', 'X' => 'X', '0' => '0', '1' => '1', 'Z' => 'Z', 
     'W' => 'W', 'L' => 'L', 'H' => 'H', '-' => '-', others => 'U'); 

    constant char_to_MVL9plus: MVL9plus_indexed_by_char := 
     ('U' => 'U', 'X' => 'X', '0' => '0', '1' => '1', 'Z' => 'Z', 
     'W' => 'W', 'L' => 'L', 'H' => 'H', '-' => '-', others => ERROR); 

    procedure READ(L:inout LINE; VALUE:out STD_LOGIC_VECTOR) is 
     variable m: STD_ULOGIC; 
     variable c: character; 
     variable s: string(1 to value'length-1); 
     variable mv: STD_LOGIC_VECTOR(0 to value'length-1); 
     constant allU: STD_LOGIC_VECTOR(0 to value'length-1) 
         := (others => 'U'); 
     variable GOOD: boolean; 
    begin 
     loop     -- skip white space 
      read(l,c); 
      exit when ((c /= ' ') and (c /= CR) and (c /= HT)); 
     end loop; 

     if (char_to_MVL9plus(c) = ERROR) then 
      value := allU; 
      good := FALSE; 
      return; 
     end if; 

     read(l, s); 
      for i in integer range 1 to value'length-1 loop 
      if (char_to_MVL9plus(s(i)) = ERROR) then 
       value := allU; 
       good := FALSE; 
        return; 
      end if; 
     end loop; 

     mv(0) := char_to_MVL9(c); 
      for i in integer range 1 to value'length-1 loop 
      mv(i) := char_to_MVL9(s(i)); 
      end loop; 
     value := mv; 
     good := TRUE; 
    end READ; 


    procedure init_mem(variable memory : out inst_mem; 
            constant datafile : string) is 
     file stddata: text; 
     variable l: line; 
     variable data: std_logic_vector (10 downto 0); 
    begin 
     file_open (stddata, datafile, READ_MODE); 
     for i in memory'range(1) loop 
      readline (stddata, l); 
      read (l, data); 
      memory(i):= data; 
     end LOOP; 
    end procedure; 


begin 
    process (load , address) 
    variable memory: inst_mem; 
    begin 
    if (load = '1') then 
     init_mem (memory, "inst_mem.txt"); 
     dataout <= memory (to_integer(unsigned(address))); -- (conv_integer(address)); 
    end if; 
    end process; 
end arch_inst_mem; 

그리고 33 개 항목으로 inst_mem.txt 파일에 생성 :

00000000000 
00000000001 
00000000010 
00000000011 
00000000100 
00000000101 
00000000110 
00000000111 
00000001000 
00000001001 
00000001010 
00000001011 
00000001100 
00000001101 
00000001110 
00000001111 
00000010000 
00000010001 
00000010010 
00000010011 
00000010100 
00000010101 
00000010110 
00000010111 
00000011000 
00000011001 
00000011010 
00000011011 
00000011100 
00000011101 
00000011110 
00000011111 
00000100000 

그리고 모델은 성공적 (0.31 -1993 준수를) GHDL에서 실행. inst_mem.png (클릭)

: (파형 변수 표시를 지원하지 않습니다) 나는 그 inst_mem 메모리가 init_mem 연속 프로 시저 호출에 의해 초기화됩니다 입증 할 수 GHDL에서 매우 추악한 물건을함으로써

32 항목의 경우

ghdl -r inst_mem --wave=inst_mem.ghw
../../../src/std/textio_body.v93:558:5:@1ns:(assertion failure): character read failure
./inst_mem:error: assertion failed
./inst_mem:error: simulation failed
ghdl: compilation error

: 더 많은 것보다는 아마 말한다 어느, 잘못된 ENDFILE가 EOF를 감지하는 데 사용되지 않기 때문에 실패를 제공 inst_mem.txt의 항목 수를 보유하고 있습니다.

은 (그리고 당신은 GHDL 다시 설계 사양으로 추적하지 않습니다 확인할 수 있습니다.)

특정 메모리 위치에 않은 정의의 무리를 얻었을 것입니다 불법 항목이 있다면.

TYPE inst_mem is array (0 to 31) of std_logic_vector(10 downto 0); 

형 inst_mem 32 항목 배열로서, 또는 inst_mem.txt 파일 항목의 적절한 수 있었다 보험, 또는 ENDFILE 테스트를 사용하고 단순히 :

그래서 당신이 중 하나를 정의해야처럼 보인다 나머지 배열 요소를 초기화하지 않았습니다.

과 ENDFILE 테스트를 addding :

procedure init_mem(signal memory : out inst_mem; 
           constant datafile : string) is 
    file stddata: text; 
    variable l: line; 
    variable data: std_logic_vector (10 downto 0); 
begin 
    file_open (stddata, datafile, READ_MODE); 
    for i in memory'range(1) loop 
     if not ENDFILE(stddata) then 
      readline (stddata, l); 
      read (l, data); 
      memory(i) <= data; 
     end if; 
    end LOOP; 
    FILE_CLOSE(stddata); 
end procedure; 

위의 오류를 제거합니다. 또한 나머지 배열 요소를 초기화되지 않은 상태로 남겨 두는 부작용이 있습니다.

로드 또는 주소 및로드 = '1'에 이벤트가있을 때마다 메모리 배열을 다시 초기화 할 수 있다는 이론하에 Morten은 권장하는 FILE_CLOSE 프로 시저를 추가했음을 알 수 있습니다.이 합성 대상 테스트 벤치 또는없는 가정

process (load , address) 
    variable memory: inst_mem; 
    begin 
    if load'event and load = '1' then 
     init_mem (memory, "inst_mem.txt"); 
     dataout <= memory (conv_integer(address)); 
    end if; 
    end process; 

:

는 그리고 그것은 또한 당신이 수준을 부하가 높은 것 감지하지 않아야 있음을 알려줍니다.

FPGA 비트 스트림에 임베드 할 초기화 파일을 제공하려는 경우 벤더 프로세스를 준수해야합니다.

메모리를 변수로 선언 했으므로 동일한 프로세스를 사용하려고합니다. 공유 변수가 될 수 있습니다. 그리고 초기화 할 두 개의 분리 된 프로세스 하나를 읽을 수 있습니다.

메모리로 신호를 구현하는 것이 약간 쉬우 며이 경우 성능 저하가 발생하지 않습니다.

은 (내가 textio 문제에 관심을 가지고있다.)

+1

이제 의무 호출 외의 답변입니다! –