使用可能范围(0 到 0)的数组类型的数组时有什么问题?
我真的不明白出了什么问题:
我有一个不受约束的类型
type int_matrix_type is array (natural range <>, natural range <>) of integer;
,用于创建不同大小的矩阵,即使我想要一个范围为 (0 到 1, 0 to 0)
我认为这会给出一个 2 行 1 列的矩阵(对吗?),就像这个例子中的 signal example2_matrix
:
library ieee;
use ieee.std_logic_1164.all;
entity toto is
port (
clk : in std_logic
);
end entity;
architecture test of toto is
-- type declaration
type int_matrix_type is array (natural range <> ,natural range <>) of integer;
-- examples of matrix signals
signal example1_matrix : int_matrix_type (0 to 1, 0 to 1)
:= ((0, 1),
(2, 3)
);
signal example2_matrix : int_matrix_type (0 to 1, 0 to 0)
:= ((0), -- here line 20
(2) -- line 21
);
begin
end test;
但是当我编译时,Quartus 返回错误
那么出了什么问题呢?
提前致谢 !
I don't really understand what is wrong :
I have an unconstrained type
type int_matrix_type is array (natural range <>, natural range <>) of integer;
that I'm using to create different sizes of matrices, even I want a matrix with the range (0 to 1, 0 to 0)
which I consider will give a matrix of 2 lines and 1 column (right?), like in this example signal example2_matrix
:
library ieee;
use ieee.std_logic_1164.all;
entity toto is
port (
clk : in std_logic
);
end entity;
architecture test of toto is
-- type declaration
type int_matrix_type is array (natural range <> ,natural range <>) of integer;
-- examples of matrix signals
signal example1_matrix : int_matrix_type (0 to 1, 0 to 1)
:= ((0, 1),
(2, 3)
);
signal example2_matrix : int_matrix_type (0 to 1, 0 to 0)
:= ((0), -- here line 20
(2) -- line 21
);
begin
end test;
But when I compile, Quartus returns errors
So what is wrong ?
Thanks in advance !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方案已在主帖下的评论中给出。所以我只是在这里为其他人重写一个明确的解决方案。我引用:
@user16145658
这意味着我的代码应该看起来更像:
希望它能帮助其他人!
Solutions were given in the comments under the main post. So I'm just rewritting here a clear solution for others. I quote :
@user16145658
which means that my code should look more like :
Hope it will help others !