【问题标题】:VHDL StructuralVHDL 结构
【发布时间】:2015-10-29 05:29:30
【问题描述】:

您好,任何人都可以帮助我解决 VHDL 问题。我正在尝试一些实用的结构编程,并想从一个简单的半加器开始。这是我的代码

LIBRARY IEEE;
USE IEEE.std_logic_1164.all;

--异或描述

entity xor_2 is
    port (a, b : in std_logic;
        f : out std_logic );
end xor_2;

Architecture func of xor_2 is
begin
    f <= a xor b;
end func;

--和描述

entity and_2 is
    port (a, b : in std_logic;
            f : out std_logic);
end and_2;

architecture func of and_2 is
begin
    f1 <= a and b;
end func;

--半加器描述

entity struct_1 is
    port ( a, b : in std_logic;
            s, c : out std_logic);
end struct_1;

architecture struct_1 of struct_1 is

component xor_2 is
    port( a, b : in std_logic;
            f : out std_logic);
end component;

component and_2 is
    port( a, b : in std_logic;
            f : out std_logic);
end component;

begin
    g1 : xor_2 port map (a, b, s);
    g2 : and_2 port map (a, b, c);

end struct_1;

我正在使用 Quartus II 设计软件,并且在运行测试时不断收到以下警告:

Error (10482): VHDL error at Struct_1.vhd(15): object "std_logic" is used but
not declared

我查看了各种网站和论文以了解我在做什么,但我访问过的每个地方给出的细节都略有不同,我还没有找到一个真正适用于比较的地方。我可以让它与数据流方法一起工作,但不是结构性的。 请小伙子和女士们在这里帮助一个男人

【问题讨论】:

    标签: vhdl hdl


    【解决方案1】:

    问题是std_logic 类型不可见。它需要通过 library/use 子句使其可见:

    library ieee;
    use ieee.std_logic_1164.all;
    

    当然,我看到你已经有了这样的条款。它的范围并没有你想象的那么大。在 VHDL 中,库/使用子句仅适用于以下实体、体系结构、包或包体。架构会自动从其实体继承 library/use 子句,而不是相反。包体会自动从其包中继承 library/use 子句,但反之则不然。

    我猜你已经把所有东西都放在同一个文件 Struct_1.vhd 中了?在这种情况下,只有 xor_2 实体/架构可以看到 ieee.std_logic_1164 的库/使用子句。您需要将它添加到每个实体之上。另外一个好的编码习惯是每个文件只有一个实体/架构对。

    【讨论】:

    • 您好 Kraigher,感谢您对 excellet 的回复。是的,你是对的,我假设声明 IEEE 库就像声明 C 头文件一样。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-23
    • 2018-08-18
    • 1970-01-01
    相关资源
    最近更新 更多