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

标签 arrays vhdl record

我正在初始化一个记录数组,其中也包含一个字符串。我收到错误 HDLCompiler:806 Line 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。)

关于arrays - 如何在VHDL中初始化记录数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55607275/

相关文章:

c - 如何从C函数中返回字符数组

c++ - 数组和右值

compiler-errors - 错误(10818): Can't infer register for “E” at clk200Hz.vhd(29) because it does not hold its value outside the clock edge

postgresql - PL/pgSQL 中的 EXECUTE...INTO...USING 语句无法执行到记录中?

C++,为什么多维数组的一个元素的增加似乎在增加另一个?

javascript - Angular.js ng-repeat 数组显示为 json

vhdl - 如何在 VHDL 中进行字符串/模式检查?

vhdl - 如何从 Spartan 6 写入 Nexys 3 FPGA 板上的 Micron 外部蜂窝 RAM?

html - html5录制计算机声音

f# - 从记录中引用通用值