包体中实体附近的语法错误
Syntax error near Entity in a Package body
我正在尝试为 VHDL 项目创建一个包含门和其他组件的小包。我已经创建了我的包,并在我的测试平台中从中实例化了一个组件,但是我收到了这个编译器错误:
ERROR: [VRFC 10-1412] syntax error near entity [/home/< redacted name >/Documents/school/ECE581/projects/project1/project_1/project_1.srcs/sources_1/new/components.vhdl:23]
问题
我的语法错误的原因是什么,我该如何解决?
包裹代码
package p1_components is
component cNAND
port ( inA, inB : in bit;
output : out bit);
end component;
end p1_components;
package body p1_components is
--------------------------------------------------------------------------
-- NAND implementation
--------------------------------------------------------------------------
entity cNAND is -- *** line 23 - error is reported here ***
port ( inA, inB : in bit;
output : out bit);
end cNAND;
architecture def of cNAND is
begin
def_proc : process(inA, inB)
begin
if (inA and inB) then
output <= transport '0' after 5 ns;
else
output <= transport '1' after 5 ns;
end if;
end def_proc;
end def;
end p1_components;
调试工作
我一直在参考一些标准库代码 here and here 以确保我的声明和语法正确,据我所知,它们是正确的。我还参考了一些其他在线资源,但我没有发现我的包、组件和实体声明有任何问题。
其他注意事项
- 我正在使用 Linux 版本的 Xilinx Vivado v2014.4(64 位)进行编译。
- 我知道像
NAND
这样的 VHDL 关键字,在实际设计中这会使我的实现变得多余。但是我正在做的项目是针对学校的,并且要求我们为项目的这一部分推出我们自己的 NAND 实现。
通常我不会将实体放在包内,而是放在包外。试试这个:
package p1_components is
component cNAND
port ( inA, inB : in bit;
output : out bit);
end component;
end p1_components;
package body p1_components is
end p1_components;
--------------------------------------------------------------------------
-- NAND implementation
--------------------------------------------------------------------------
entity cNAND is
port ( inA, inB : in bit;
output : out bit);
end cNAND;
architecture def of cNAND is
begin
def_proc : process(inA, inB)
begin
if (inA = '1' and inB = '1') then
output <= transport '0' after 5 ns;
else
output <= transport '1' after 5 ns;
end if;
end process def_proc;
end def;
我正在尝试为 VHDL 项目创建一个包含门和其他组件的小包。我已经创建了我的包,并在我的测试平台中从中实例化了一个组件,但是我收到了这个编译器错误:
ERROR: [VRFC 10-1412] syntax error near entity [/home/< redacted name >/Documents/school/ECE581/projects/project1/project_1/project_1.srcs/sources_1/new/components.vhdl:23]
问题
我的语法错误的原因是什么,我该如何解决?
包裹代码
package p1_components is
component cNAND
port ( inA, inB : in bit;
output : out bit);
end component;
end p1_components;
package body p1_components is
--------------------------------------------------------------------------
-- NAND implementation
--------------------------------------------------------------------------
entity cNAND is -- *** line 23 - error is reported here ***
port ( inA, inB : in bit;
output : out bit);
end cNAND;
architecture def of cNAND is
begin
def_proc : process(inA, inB)
begin
if (inA and inB) then
output <= transport '0' after 5 ns;
else
output <= transport '1' after 5 ns;
end if;
end def_proc;
end def;
end p1_components;
调试工作
我一直在参考一些标准库代码 here and here 以确保我的声明和语法正确,据我所知,它们是正确的。我还参考了一些其他在线资源,但我没有发现我的包、组件和实体声明有任何问题。
其他注意事项
- 我正在使用 Linux 版本的 Xilinx Vivado v2014.4(64 位)进行编译。
- 我知道像
NAND
这样的 VHDL 关键字,在实际设计中这会使我的实现变得多余。但是我正在做的项目是针对学校的,并且要求我们为项目的这一部分推出我们自己的 NAND 实现。
通常我不会将实体放在包内,而是放在包外。试试这个:
package p1_components is
component cNAND
port ( inA, inB : in bit;
output : out bit);
end component;
end p1_components;
package body p1_components is
end p1_components;
--------------------------------------------------------------------------
-- NAND implementation
--------------------------------------------------------------------------
entity cNAND is
port ( inA, inB : in bit;
output : out bit);
end cNAND;
architecture def of cNAND is
begin
def_proc : process(inA, inB)
begin
if (inA = '1' and inB = '1') then
output <= transport '0' after 5 ns;
else
output <= transport '1' after 5 ns;
end if;
end process def_proc;
end def;