arrays - 如何在 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。)
推荐阅读
- c# - 当我在 C# 中使用 inkcanvas1.Strokes.Erase 语句时,WPF-InkCanvas StrokeErased 事件未触发
- python - 遍历数据帧,编写字典并将浮点值附加到键
- javascript - React 中的动态 GraphQL 突变与模板文字
- javascript - 如何使用 Javascript 访问严格/显式 href 值?
- chart.js - 如何在 x 轴上显示半小时刻度
- wkhtmltopdf - 文本在表中重叠
- datomic - 排除某些 id 的查询
- kotlin - 模拟每个 {}.throws() 异常失败测试
- asp.net-core - Blazor - 使用移动设备访问已发布网站时出错
- google-analytics - 主机名流量和 ISP 域访问有什么区别?