Verilog加法器测试台

Verilog加法器测试台,verilog,Verilog,/////////////////////////////////////////////////////////////// //In here, `WORD_LEN is 32. `include "Defines.v" module Adder (in1, in2, out); input [`WORD_LEN-1:0] in1, in2; output [`WORD_LEN-1:0] out; assign out = in1 + in2; endmodule 当我模

///////////////////////////////////////////////////////////////

//In here, `WORD_LEN is 32.

`include "Defines.v"

module Adder (in1, in2, out);
  input [`WORD_LEN-1:0] in1, in2;
  output [`WORD_LEN-1:0] out;

  assign out = in1 + in2;
endmodule
当我模拟这个时,只有in1[0]和in2[0]得到这个值。除了他们,他们还有一条蓝线。
此外,我们还有一条红线。我真的不明白这是怎么回事。请提供帮助。

尽管您将模块中的
in1
in2
out
定义为32位端口(如您的注释所示),但测试台中连接的信号仅为1位宽。因此,只驱动模块输入信号的第一位(即1[0]中的
和2[0]
中的

尝试使用以下测试台:

`timescale 1ns/1ns

module AdderTest;
  reg in1, in2;
  wire out;
  Adder TestAdder(.in1(in1), .in2(in2), .out(out));

  initial begin
  in1 = 4'b0000; in2 = 4'b0000; #100;
  in1 = 4'b0011; in2 = 4'b1111; #100;
  in1 = 4'b1000; in2 = 4'b1100; #100;
  $stop;
  end


endmodule

另外,请查看编译器/模拟器生成的日志文件。如果端口大小和连接的信号不匹配,许多编译器会发出警告。
module AdderTest;
  reg  [31:0] in1, in2; // CHANGE
  wire [31:0] out;      // CHANGE
  Adder TestAdder(.in1(in1), .in2(in2), .out(out));

  initial begin
    in1 = 4'b0000; in2 = 4'b0000; #100;
    in1 = 4'b0011; in2 = 4'b1111; #100;
    in1 = 4'b1000; in2 = 4'b1100; #100;
    $stop;
  end
endmodule