【问题标题】:VHDL package and std_logic_vectorVHDL 包和 std_logic_vector
【发布时间】:2017-09-28 18:22:03
【问题描述】:

我正在尝试声明要在端口中使用的类型,但我遇到了问题 如果我执行以下操作,则会收到未声明 STD_LOGIC_VECTOR 的错误

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.numeric_std.all;
-- Custom types --
package Common  is
    type Mem_in is array (2**6 to 0) of STD_LOGIC_VECTOR (11 downto 0); 
    type DinDout is range 11 downto 0;
end package Common ;
-- Use Custom Type
use work.Common.all;

entity MUX is

    Port (
        D       :   in Mem_in;
        Q       :   out DinDout;
        SEL     :   in  STD_LOGIC_VECTOR (11 downto 0)
        );
end MUX;

为什么我不能使用 STD_LOGIC_VECTOR?如果我将其更改为 DinDout,我会在架构中遇到另一个问题: to_integer 未声明;索引名称不是 dindout。

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.numeric_std.all;
-- Custom types --
package Common  is
    type Mem_in is array (2**6 to 0) of STD_LOGIC_VECTOR (11 downto 0); 
    type DinDout is range 11 downto 0;
end package Common ;

以及实体使用包Common:

-- Use Custom Type
use work.Common.all;

entity MUX is

    Port (
        D       :   in Mem_in;
        Q       :   out DinDout;
        SEL     :   in  DinDout
        );
end MUX;

architecture Arc of MUX is
begin
    Q <= D(to_integer(unsigned(SEL)));
end Arc; 

如何将 STD_logic_vector 添加到我的包或解决这两个错误: to_integer 未声明;索引名称不是 dindout?

谢谢

【问题讨论】:

  • 除了前面上下文子句中缺少 MUX 实体声明的上下文项之外,您的 Mem_in 数组类型还有 2**6 + 1 (2**6 downto 0 ) 具有相同数量的不同索引而不是 2**DinDout'length 的元素会导致 SEL 的某些值违反约束。您的内存大小应该是与 SEL 长度匹配的 2 的幂。为端口提供这么多“位”(2**6+1 * 12 - 内存元素的长度或 780)似乎是不寻常的。该内存读取的 MUX 可能应该与 D 的实际位置一起定位,特别是对于块内存.
  • Type DinDout 是一个抽象数值类型,取值范围从 11 到 0,而 D(to_integer(unsigned(SEL))) 是 D 的一个索引元素,它是一个带有索引的 std_logic_vectors 数组范围从 11 到 0。它们是不同的类型。请注意,您接受的答案没有解决 ...或解决这两个错误:...索引名称不是 dindout? 您有多个错误。

标签: vhdl


【解决方案1】:

您在一个文件中有两个库单元(如果它是您引用的单个文件)。虽然我不确定会发生什么,但我猜它会重新启动每个单元的上下文。

这意味着你必须重复 library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.numeric_std.all; use work.Common.all;之前。

另外2**6 to 0 是一个空范围,应该是0 to 2**62**6 downto 0

【讨论】:

  • 谢谢它的工作,但现在我有一个问题:D(to_integer(unsigned(SEL)));它说“索引名称不是一个dindout”。如何索引以获取例如 Mem_in( int( X ) ) x 为 2**6 到 0?
猜你喜欢
  • 2015-09-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-15
  • 1970-01-01
相关资源
最近更新 更多