0
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
use ieee.std_logic_unsigned.all;
USE ieee.numeric_std.ALL;

USE IEEE.STD_LOGIC_TEXTIO.ALL;
USE STD.TEXTIO.ALL;

entity theswings is

end theswings;

architecture Behavioral of theswings is
    signal a_signal_p: std_logic_vector(3 downto 0) := "0000";
    signal the_other: std_logic_vector(3 downto 0) := "0000";
    file da_goods: TEXT open read_mode is "C:\Users\~~~~\playground\goods";
    procedure read_slv(file F: text; value: inout std_logic_vector) is
                 -- no error checking of any sort is performed by this function
                 -- it assumes the file is a newline-separated list of strings
                 -- describing one std_logic_vector each
                 -- if EOF, then return "XXXXXXXX"
        variable tmp: line;
        variable tmpr: std_logic_vector(3 downto 0) := "1010";
    begin
        if endfile(F) then
                for i in tmpr'range loop
                    tmpr(i) := 'X';
                end loop;
        else
                readline(F, tmp);
                read(tmp, tmpr);
        end if;
    end read_slv;

begin
    process
        --variable invar, outvar: std_logic_vector(3 downto 0);
        --variable tmp: line;
        variable tmpr: std_logic_vector(3 downto 0);
        --variable str: string;
    begin
        wait for 50 ns;
--      while not endfile(da_goods) loop
--          readline(da_goods, tmp);
--          read(tmp, tmpr);
--          a_signal_p <= tmpr;
--          --a_signal_p <= invar;
--          the_other <= not tmpr;
--          --outvar := the_other;
--          --write(da_bads, the_other);
--          wait for 10 ns;
--      end loop;
        for i in 0 to 8 loop
            read_slv(da_goods, tmpr);
            a_signal_p <= tmpr;
            the_other <= not tmpr;
            wait for 10 ns;
        end loop;
        wait;
    end process;
END;

正如您可能猜到的那样,注释掉的主循环工作正常,而使用该过程的 for 循环不起作用。(具体来说,在 50 ns 的零之后,所有信号都转到“UUUU”,而不是程序主体可能期望的“1010”。

有人认出我犯的错误吗?我 98% 确定这是一个非常愚蠢的问题,像我这样的菜鸟还无法理解。

4

1 回答 1

1

在您的过程声明中,您提到了变量“值”

procedure read_slv(file F: text; value: inout std_logic_vector) is

你必须在你的程序中用“tmpr”分配“价值”!

      ...
     if endfile(F) then
            for i in tmpr'range loop
                tmpr(i) := 'X';
            end loop;
    else
            readline(F, tmp);
            read(tmp, tmpr);
    end if;
    value:=tmpr; -- assign result!
 end read_slv;

正如您在问题中已经提到的......一个非常愚蠢的错误;-)

于 2013-06-20T05:46:41.627 回答