如何在 VHDL 中初始化记录数组?

How to initialize an array of record in VHDL?

我正在初始化一个记录数组,其中也包含一个字符串。我收到错误 HDLCompiler:806 第 109 行:"text_passages" 附近的语法错误(下面代码的最后一行)。正确的初始化方式是什么?

type text_info is
    record
        text : string(1 to 15);
        x: integer;
        y: integer;
    end record;
constant init_text_info: text_info := (text => "               ", x => 0, y => 0);
type text_info_array is array(natural range <>) of text_info;

我的声明和初始化如下

signal text_passages : text_info_array(0 to 1) := (others => init_text_info);
text_passages(0) <= (text => "This is a Test.", x => 50, y => 50);

好吧,你在最后一行的末尾有一个额外的括号,但除此之外,没关系。 (我怀疑你报告的错误信息是由那个括号引起的。)最后一行应该是:

text_passages(0) <= (text => "This is a Test.", x => 50, y => 50);

一个[MCVE]:

entity E is
end entity ;

architecture A of E is

  type text_info is
    record
        text : string(1 to 15);
        x: integer;
        y: integer;
    end record;
  constant init_text_info: text_info := (text => "               ", x => 0, y => 0);
  type text_info_array is array(natural range <>) of text_info;
  signal text_passages : text_info_array(0 to 1) := (others => init_text_info);

begin

  text_passages(0) <= (text => "This is a Test.", x => 50, y => 50);

end architecture A;

https://www.edaplayground.com/x/4ARJ

(提交 MCVE 总是最好的。)