1

Weird error when running the test bench, I have never seen this before. I am attempting to simulate an 8-bit calculator with 4 registers. The calculator has 8 bit instructions for add,subtract, branches on equal, load immediate, and print to the monitor. I've checked to make sure I am not in any infinite loops. I've researched online, and there does not seem to be any specific reasons why I may have this error.

I've triple checked for loops, memory leaks, and also tried increasing the stack frame. None have worked out so far. Using commands ghdl -a, -e, and -r to analyze, compile, and run.

'''

architecture structural of calculator_tb is
component calculator is
  port(
    I : in std_logic_vector(7 downto 0); --instruction input
    clk : in std_logic
  );
end component calculator;


signal I : std_logic_vector(7 downto 0);
signal clk : std_logic;


begin
  calculator_0 : calculator port map(I, clk);
    process
      file instruction_file : text is in "instructions.txt"; --Instructions in text(ASCII) file.
      variable instruction_line : line;
      variable intruction_vector : bit_vector(7 downto 0);
    begin
      while (not(endfile(instruction_file))) loop --Loop to the end of the text file.
        wait for 1 ns;
        clk <= '0';
        readline(instruction_file, instruction_line); --Read in instruction line
        read(instruction_line, intruction_vector); --merge instruction to bit vector
        I <= to_stdlogicvector(intruction_vector); --Convert bit vector to std_logic_vector and pass instruction to the calculator input.

        --Create a rising edge for the clock.
        wait for 1 ns;
        clk <= '1';
      end loop;
      assert false report "end of test" severity note;
    end process;
end architecture structural;
''''
The runtime error I receive is:

invalid memory access (dangling accesses or stack too small)

Loocid
  • 6,112
  • 1
  • 24
  • 42
Mike Rawding
  • 121
  • 4
  • Adding the missing context clause and entity declaration and your design analyzes and elaborates (with calculator unbound). Creating an instructions.txt file with a small number of 8 bit binary values one per line and your design simulates reaching end of test. You code example doesn't reproduce your issue as is with a a final `wait'` before the `end process;` The wait prevents you from repeating the 'test' over and over again. What version of ghdl? What platform? –  May 03 '19 at 00:59
  • 1
    Version 0.29.1 running on windows command prompt, and yes I meant to include the wait', but regardless I am receiving the same run time error. Might you be able to go into more detail with the unbound entity declaration. – Mike Rawding May 03 '19 at 01:10
  • 1
    Upgrade to a new revision, there's a [ghdl-0.36](https://github.com/ghdl/ghdl/releases/tag/v0.36) binary release [ghdl-0.36-mingw32-mcode.zip](https://github.com/ghdl/ghdl/releases/download/v0.36/ghdl-0.36-mingw32-mcode.zip). The only place I could find your symptom was using 0.29. –  May 03 '19 at 01:17
  • There is no calculator provided in your question. Just the testbench. The component instance calculator_0 is unbound. That's legal but will generate a warning in a newer ghdl. –  May 03 '19 at 01:53

0 Answers0