我正在尝试实现一个简单的verilog代码,如下所示:
module test1(
input ACLK,
input RST,
output test_output1,
output test_output2
);
//wire ACLK;
//wire RST;
reg test_output1;
reg test_output2;
assign test_output1 = ACLK;
always @(posedge ACLK or negedge RST)
begin
if(!RST)
begin
//test_output1 <=0;
test_output2 <=0;
end
else
begin
//test_output1 <=0;
test_output2 <=1;
end
end
endmodule当我尝试在Xilinx ISE中合成它时,我得到了以下错误消息:
=========================================================================
* HDL Compilation *
=========================================================================
Compiling verilog file "test1.v" in library work
ERROR:HDLCompilers:27 - "test1.v" line 30 Illegal redeclaration of 'test_output1'
ERROR:HDLCompilers:27 - "test1.v" line 31 Illegal redeclaration of 'test_output2`我无法解决此错误。任何帮助都将不胜感激。
发布于 2016-05-13 12:12:03
如果在portlist中声明端口的方向,还必须声明类型。这称为ANSI样式标头。
还有一个非ANSI样式标头,用于分隔端口列表、方向和类型。如果你允许IEEE1364-1995约定,那么你必须使用非ANSI风格,并且你不能声明类型(例如,output reg test_output2;是非法的,而output test_output2; reg test_output2;是合法的)。因为IEEE1364-2001支持ANSI和非ANSI样式(并且非ANSI允许output reg test_output2;)。所有的现代Verilog模拟器都是SystemVerilog (IEEE1800)模拟器,因此它是设计者的选择。(ANSI样式更受欢迎,因为它的打字量更少)。
ANSI样式标题:
module test1(
input ACLK,
input RST,
output test_output1,
output reg test_output2 );非ANSI样式标题:
module test1( ACLK, RST, test_output1, test_output2 );
input ACLK;
input RST;
output test_output1;
output test_output2;
reg test_output2;注意:在IEEE1364中,您不能使用assign语句驱动reg,它必须是网络类型。IEEE1800已经软化了logic代替reg的规则,但通常如果你要使用assign,那么你应该分配一个网络(例如wire)。
发布于 2016-05-13 11:58:12
增加如下修改:
test_output1,所以它应该是wire类型。模块test1(输入wire ACLK,输入wire RST,输出wire test_output1,输出reg test_output2 );
test_output1和test_outpu2为output,默认类型为wire,只需根据用法隐式指定wire或reg即可。// reg test_output2;;// reg test_output1
https://stackoverflow.com/questions/37200244
复制相似问题