【发布时间】:2014-11-12 10:55:56
【问题描述】:
我正在尝试分析以下应该与 VHDL-2008 兼容的文件。
entity closely_related is
end;
architecture example of closely_related is
type integer_vector is array (natural range <>) of integer;
type real_vector is array (natural range <>) of real;
begin
process
variable int_vect: integer_vector(1 to 3);
variable real_vect: real_vector(1 to 3);
begin
real_vect := ( 1.0, 2.0, 3.0 );
int_vect := integer_vector( real_vect );
wait;
end process;
end;
这应该是一个关于密切相关类型的实验。根据 LRM,有两种密切相关的类型:
——抽象数字类型——任何抽象数字类型都与任何其他抽象数字密切相关 类型。 — 数组类型——当且仅当类型相同时,两个数组类型密切相关 维度和元素类型密切相关
我了解实数和整数密切相关;它们之间的类型转换(又名类型转换)可以正常工作。那为什么对上面的数组类型不起作用呢?
GHDL 给出以下错误:
conversion not allowed between not closely related types
Modelsim Altera 10.1e(带 -2008 开关)也好不到哪里去:
Illegal type conversion from std.STANDARD.REAL_VECTOR to std.STANDARD.INTEGER_VECTOR
(array element type difference).
为了彻底,我尝试一次对一个元素执行相同的操作:
int_vect(1) := integer( real_vect(1) );
int_vect(2) := integer( real_vect(2) );
int_vect(3) := integer( real_vect(3) );
而且效果很好。有什么想法吗?
【问题讨论】:
-
VHDL-2008 将 integer_vector 和 real_vector 类型添加到包标准中。您是否在设计中重新定义了这些类型?您是否在打开 VHDL-2008 开关且未定义您自己的类型的情况下尝试过此操作?
-
@JimLewis 回想起来,也许我应该使用不同的名称......现在我已经做到了,并在 Modelsim 中测试了四种组合:带/不带 -2008,带/不带重载名称(即将类型重命名为 my_integer_vector 和 my_real_vector),以及使用 std.standard 中的类型的第五个替代方案(即注释掉类型声明)。在所有五种情况下,我都会遇到相同的错误。
-
听起来你发现了一个错误。你提交了吗?
-
@JimLewis 我已经在他们的公共论坛上发布了一份报告,因为我不是企业客户。那里的版主说他会把它传递出去。
标签: arrays casting type-conversion vhdl ghdl