有人能帮我提个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我看过不同的网站和论文来了解我在做什么,但是我去过的每一个地方都给出了稍微不同的细节,而且我还没有找到一个真正有效的比较方法。我不介意让它使用数据流方法,但不需要结构化的。请小伙子们和女士们在这里帮助一个男人
发布于 2015-10-29 05:44:09
问题是std_logic类型不可见。需要通过库/use子句使其可见:
library ieee;
use ieee.std_logic_1164.all;我当然知道你已经有这样的条款了。它的范围并不像你想象的那么大。在VHDL中,库/use子句仅适用于以下实体、体系结构、包或包主体。架构会自动从其实体继承库/使用子句,而不是相反。包主体自动从其包继承库/使用子句,而不是相反。
我想你把所有东西都放在同一个文件Struct_1.vhd里了吧?在这种情况下,只有xor_2实体/体系结构才能看到ieee.std_logic_1164的库/use子句。你需要把它加到每一个实体上面。另外,一个好的编码实践是每个文件只有一个实体/架构对。
https://stackoverflow.com/questions/33406568
复制相似问题