modelsim verilog vsim-3365太多端口

时间:2017-05-01 16:59:30

标签: verilog modelsim digital

由于我是Verilog的新手,我不知道这意味着什么。我想我犯了一个简单的错误,但我似乎无法解决它,也没有通过谷歌找到解决方案。有人知道我能做什么,以便我的项目有效吗?

    // Dataflow description of a 4-bit comparator  
    module FourBcompare ( 
      output        A_lt_B, A_eq_B, A_gt_B, 
      input [3: 0]  A, B
    );
      assign A_lt_B = (A < B);
      assign A_gt_B = (A > B);
      assign A_eq_B = (A == B);
    endmodule

//'timescale 1 ps / 1 ps
module t_fourBcompare;

  reg   [7: 0]AB;
  wire  t_A_lt_B;
  wire  t_A_eq_B;
  wire  t_A_gt_B;
  parameter stop_time = 100;

  FourBcompare M1 (   t_A_lt_B, t_A_eq_B, t_A_gt_B ,
              AB[7],AB[6],AB[5],AB[4],
              AB[3],AB[2],AB[1],AB[0]
           );

  initial # stop_time $finish;
  initial begin                 // Stimulus generator
        AB = 8'b00000000;
    repeat (256)
   #10 AB = AB +1'b1;
  end

可以编译但不能在modelsim上进行模拟。

以下是错误消息:

# Compile of FourBcompare.v was successful.
# Compile of t_fourBcompare.v was successful.
# 2 compiles, 0 failed with no errors.
vsim work.t_fourBcompare
# vsim work.t_fourBcompare 
# Start time: 01:43:58 on May 02,2017
# Loading work.t_fourBcompare
# Loading work.FourBcompare
# ** Fatal: (vsim-3365) D:/util/t_fourBcompare.v(10): Too many port connections. Expected 5, found 11.
#    Time: 0 ps  Iteration: 0  Instance: /t_fourBcompare/M1 File: D:/util/FourBcompare.v
# FATAL ERROR while loading design
# Error loading design
# End time: 01:43:58 on May 02,2017, Elapsed time: 0:00:00
# Errors: 1, Warnings: 0

1 个答案:

答案 0 :(得分:1)

该消息表示FourBcompare模块有5个信号(2个输入+ 3个输出),但您正在尝试将11个信号连接到它。端口input [3:0] A计为一个信号,而不是4。

这是摆脱错误的一种方法,但您必须确定它是否适合您的案例:

  FourBcompare M1 (   t_A_lt_B, t_A_eq_B, t_A_gt_B ,
              {AB[7],AB[6],AB[5],AB[4]},
              {AB[3],AB[2],AB[1],AB[0]}
           );

我使用连接运算符{}将各个位分组到总线中。请参阅免费的IEEE Std 1800-2012, 11.4.12连接运算符部分。现在,4位值{AB[7],AB[6],AB[5],AB[4]}连接到4位A信号。

注意:{AB[7],AB[6],AB[5],AB[4]}可简化为AB[7:4]