Modelsim Verilog VSIM-3365太多端口


    // 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

消息表示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位信号。

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

最新更新