【问题标题】:(VHDL) I'm Receiving an Error When Trying to Output from an Array(VHDL) 尝试从数组输出时收到错误消息
【发布时间】:2018-12-05 20:28:21
【问题描述】:

我正在尝试将数组中的数据输出到我的 DE1-SoC 板上的 7 段显示器。

这是我的变量:

display : out std_logic_vector (6 downto 0);

type bigDisplay is array (0 to 4, 0 to 6) of bit;

signal displayArray : bigDisplay;

代码如下:

display <= displayArray (0, 6-0);

这是我收到的错误:

Error (10381): VHDL Type Mismatch error at Final_Project.vhd(326): indexed name returns a value whose type does not match "std_logic_vector", the type of the target expression

所以,我猜我需要将我的位数组转换为输出到 std_logic_vector?我该怎么做?

【问题讨论】:

    标签: arrays output vhdl seven-segment-display


    【解决方案1】:

    使用bit 有什么特别的原因吗?您可以轻松地创建std_logic_vector 的数组:

    type bigDisplay is array(0 to 4) of std_logic_vector(6 downto 0);
    signal displayArray : bigDisplay;
    

    然后简单地(当然,在使用值初始化 displayArray 之后):

    display <= displayArray(0);
    

    等,或任何您想要的索引,以便将数组中的值分配给显示。

    【讨论】:

    • 嗯,好吧。我使用这种类型的数组来保存 5 组不同的 7 位值以发送到我的显示器。 (所以我可以像这样引用它:displayArray (0, 6-0), displayArray (1, 6-0), displayArray (2, 6-0) 等)我可以用同样的方式对待 std_logic_vectors 吗?
    • 当我这样尝试时:type bigDisplay is array (0 to 4) of std_logic_vector (6 downto 0); display &lt;= displayArray (0, 6-0); 我得到了错误:index of object of array type bigDisplay must have 1 dimensions
    • 您需要删除, 6-0 部分,因为现在您的数组是std_logic_vector,而不是bit 的二维数组。
    • 好的。我想解决方案是创建 5 个不同的逻辑向量,每个向量包含 7 个值。谢谢。 :)
    • 一旦你有了arraystd_logic_vector,你可以像displayArray &lt;= ("0000101","0000000","0011001","1111111","1010101"); 这样初始化它们,像displayArray(0) &lt;= ... displayArray(1) &lt;= ... 这样索引它们,而不是创建5个单独的逻辑向量。
    猜你喜欢
    • 2021-06-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-08
    • 2020-03-07
    • 1970-01-01
    • 2022-10-04
    相关资源
    最近更新 更多