原程序: module adder4(cout,sum,bina,binb,cin);
input[3:0]bina,binb;
input cin;
output cout;
output [3:0]sum;
assign {cout,sum}=bina+binb+cin;
endmodule
testbench:
`timescale 1ns/1ns
`include"E:/ge/adder4.v"
module adder_tb;
reg [3:0] a,b;
reg cin;
wire cout;
wire [3:0] sum;
integer i,j;
adder4 adder(cout,sum,a,b,cin);
always #5 cin=~cin;
initial
begin
a=0;
b=0;
cin=0;
for(i=0;i<16;i=i+1)
#10 a=i;
end
initial
begin
for(j=0;j<16;j=j+1)
#10 b=j;
end
initial
begin
$monitor($time,,,"%d+%d+%b={%b,%d},a,b,cin,cout,sum);
#160 $finish;
end
endmodule
compile testbench时候就是有错...找不出来...各位帮忙看下不.. |