首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么在verilog中会出现以下重声明错误?

为什么在verilog中会出现以下重声明错误?
EN

Stack Overflow用户
提问于 2016-05-13 10:19:49
回答 2查看 1.7K关注 0票数 1

我正在尝试实现一个简单的verilog代码,如下所示:

代码语言:javascript
复制
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中合成它时,我得到了以下错误消息:

代码语言:javascript
复制
=========================================================================
*                          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`

我无法解决此错误。任何帮助都将不胜感激。

EN

回答 2

Stack Overflow用户

发布于 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样式标题:

代码语言:javascript
复制
module test1(
  input ACLK,
  input RST,
  output test_output1,
  output reg test_output2 );

非ANSI样式标题:

代码语言:javascript
复制
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)。

票数 3
EN

Stack Overflow用户

发布于 2016-05-13 11:58:12

增加如下修改:

  1. 你在assign语句中使用了test_output1,所以它应该是wire类型。

模块test1(输入wire ACLK,输入wire RST,输出wire test_output1,输出reg test_output2 );

  • 您已经声明了test_output1test_outpu2为output,默认类型为wire,只需根据用法隐式指定wire或reg即可。

// reg test_output2;;// reg test_output1

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37200244

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档