【问题标题】:How to use "std_logic" after package/package body declaration?如何在包/包体声明后使用“std_logic”?
【发布时间】:2019-07-25 12:41:42
【问题描述】:

我正在尝试使用 VHDL 变得更好,因此我想尝试实现“包 ... is”和“包体 ... is”功能。 当我这样做时,似乎“std_logic”在 GHDL 分析步骤中看不到 IEEEE 库的内容。

到目前为止,我尝试了带有和不带有代码的命令 -> 结果相同。 没有“包”行,它就像一个魅力......但我将无法按计划扩展它。

library IEEE;
use IEEE.std_logic_1164.all;

package run is
    -- some package definitions
end run;

package body run is
    -- the body
end run;

entity andfunc is
    Port( A : in std_logic;
        B : in std_logic;
        C : out std_logic
);
end andfunc;

architecture Behavioral of andfunc is
begin
    C <= A and B ;
end Behavioral;

具体的错误信息是: “[...] 错误:没有声明“std_logic”

期待您的回答。

【问题讨论】:

    标签: package vhdl ieee ghdl


    【解决方案1】:

    libraryuse 的范围(可见性)不是整个文件。在package 之后,如果您仍然需要它们,您必须召回它们。为了工作,您的代码应该是:

    library IEEE;
    use IEEE.std_logic_1164.all;
    
    package run is
        -- some package definitions
    end run;
    
    package body run is
        -- the body
    end run;
    
    
    library IEEE;
    use IEEE.std_logic_1164.all;
    
    entity andfunc is
        Port( A : in std_logic;
            B : in std_logic;
            C : out std_logic
    );
    end andfunc;
    
    architecture Behavioral of andfunc is
    begin
        C <= A and B ;
    end Behavioral;
    

    【讨论】:

      【解决方案2】:

      您的 std_logic_1164 导入属于该包,并且在其主体中也是可见的。它在整个文件中不可见。在实体之前重复这些行,它将对实体及其架构可见。

      【讨论】:

      • 非常感谢。 面对面。现在可以使用 +1
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-01-28
      • 1970-01-01
      • 2012-12-04
      • 2020-06-16
      • 2023-04-02
      • 2020-05-23
      • 1970-01-01
      相关资源
      最近更新 更多