首页 文章

VHDL结构

提问于
浏览
1

大家好,任何人都可以帮我解决VHDL问题 . 我正在尝试一些实用的结构编程,并希望从一个简单的半加法器开始 . 继承我的代码

LIBRARY IEEE;
USE IEEE.std_logic_1164.all;

--XOR DESCRITION

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;

--HALF ADDER DESCRIPTION

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

我查看了各种网站和论文,了解我正在做什么,但我访问的每个地方都提供了略有不同的细节,我还没有找到一个实际用于比较的地方 . 我可以使用数据流方法,但没有结构 . 请小伙子和女士帮助一个男人在这里

1 回答

  • 5

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

    library ieee;
    use ieee.std_logic_1164.all;
    

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

    我猜你已把所有东西放在同一个文件Struct_1.vhd中?在这种情况下,只有xor_2实体/体系结构才能看到ieee.std_logic_1164的library / use子句 . 您需要将其添加到每个实体上方 . 另外一个好的编码实践是每个文件只有一个实体/体系结构对 .

相关问题