Verilog Modelsim 错误 2388。已在此范围内声明

Verliog Modelsim Error 2388. already declared in this scope

下面是我的 Verilog 代码。当我尝试编译它时,我在 Modelsim 中遇到了 2 个错误。

** 错误(可抑制):/home/ece4514/mul1.v(6): (vlog-2388) 'p' 已在此范围 (mul1) 中声明。 ** 错误(可抑制):/home/ece4514/mul1.v(8): (vlog-2388) 'c' 已在此范围内声明 (mul1).

module mul1(output [103:0] p, 
        output [51:0]  c, 
        input [51:0]   x,
        input [51:0]   y); 
reg [103:0]p;
reg [103:0]a;
reg c;
integer i; 

always @(x , y)
begin 
  a=x;
  p=0; // needs to zeroed
  for(i=0;i<104;i=i+1)
  begin
    if(y[i])
      p=p+a; // must be a blocking assignment
    a=a<<1;
  end

  for(i=103;i>=0;i=i-1)
  begin
    if (p[i])
        c=p[i:i-51];
        break;
    end

  end
endmodule

我需要做哪些改变?

您将 Verilog-1995 风格的端口声明与 Verilog-2001/SystemVerilog 风格混合在一起。使用较新的样式,有关端口的所有信息都在 header.

module mul1(output reg [103:0] p, 
        output reg [51:0]  c, 
        input [51:0]   x,
        input [51:0]   y); 

reg [103:0]a;
integer i; 

旧样式只有 header 中的标识符,您稍后声明了方向和类型。