Reputation: 21
//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
///////////////////////////////////////////////////////////////
`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
When I simulate this, Only in1[0] and in2[0] gets the value. Except for them, they got a blue line. Also, out got a red line. I really don't get what's wrong with this. Please help.
Upvotes: 1
Views: 989
Reputation: 1181
Although you define in1
, in2
, and out
as 32-bit ports in your module (as indicated by your comment), the connected signals in your testbench are only 1 bit wide. Therefore, only the first bit of your module's input signals (i.e., in1[0]
and in2[0]
) are driven.
Try to use the following testbench:
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
Upvotes: 1