File VHDL如何将文件中的输出指定为包中的常量?

File VHDL如何将文件中的输出指定为包中的常量?,file,package,constants,vhdl,readline,File,Package,Constants,Vhdl,Readline,我想从文本文件中读取大整数数组,并将这些数组作为常量分配到包中。我该怎么做?我制作了一个从文件读取的进程,输出的是我想要的数组: P1: process file vec_file: text open read_mode is "mytext"; variable iline: line; variable data_read: integer; variable x: integer := 0; begin

我想从文本文件中读取大整数数组,并将这些数组作为常量分配到包中。我该怎么做?我制作了一个从文件读取的进程,输出的是我想要的数组:

       P1: process
       file vec_file: text open read_mode is "mytext";
       variable iline: line;
       variable data_read: integer;
       variable x: integer := 0;
       begin

          while not endfile (vec_file) loop
            readline (vec_file, iline);
            read(iline,data_read);
            wait until rising_edge(clk); 
            output(x) <= data_read;
            x := x + 1;

          end loop;
          wait until rising_edge(clk); 
          wait;
      END process P1;
P1:进程
文件矢量文件:文本打开读取模式为“mytext”;
可变直线:直线;
变量数据读取:整数;
变量x:整数:=0;
开始
而不是endfile(vec_文件)循环
readline(vec_文件,iline);
读取(iline,数据读取);
等待上升沿(clk);

输出(x)通过读取文件的函数初始化包中的常量数组,如下所示:

package pkg is
  type output_t is array(0 to 9) of integer;  -- Just change size
  constant output : output_t;  -- Value assign is deferred
end package;

library std;
use std.textio.all;
package body pkg is

  -- Entries in output without value in file are assigned to 0
  impure function output_init return output_t is
    file vec_file: text open read_mode is "mytext";
    variable iline: line;
    variable data_read: integer;
    variable x: integer := 0;
    variable res_t : output_t := (others => 0);
  begin
    while not endfile (vec_file) loop
      readline (vec_file, iline);
      read(iline,data_read);
      res_t(x) := data_read;
      x := x + 1;
    end loop;
    return res_t;
  end function;

  constant output : output_t := output_init;

end package body;

这是模拟还是合成代码?两者都是可能的,但合成代码有一些特殊性。我不会使用进程,而是声明一个(不纯)函数,该函数读取文件并返回常量的值。看看我们使用这种技术的片上RAM实现。此函数在体系结构中本地声明,但也可以移动到包中。请改为编写函数。让它读取文件内容并将其返回值赋给常数。谢谢您的回答!成功了!但是现在我必须分配依赖于这个数组的其他常量。我将在包体中的输出赋值下分配它们。但是使用这个包的组件不能识别这个常量。我应该在哪里分配它们?然后在
输出
的分配之后(下)分配,但也要记住在包中声明它们,但使用延迟分配,就像
输出
被声明但直到包体才分配一样。