写出两位全加器的testbench代码
时间: 2023-09-22 12:14:50 浏览: 122
adder_tp.zip_四位全加器
很高兴为您解答问题。以下是两位全加器的testbench代码:
`module full_adder_tb;
reg [1:0] a, b, cin;
wire [1:0] sum;
wire cout;
full_adder fa(
.a(a),
.b(b),
.cin(cin),
.sum(sum),
.cout(cout)
);
initial
begin
a = 0; b = 0; cin = 0;
#10 a = 0; b = 1; cin = 0;
#10 a = 1; b = 0; cin = 0;
#10 a = 1; b = 1; cin = 0;
#10 a = 0; b = 0; cin = 1;
#10 a = 0; b = 1; cin = 1;
#10 a = 1; b = 0; cin = 1;
#10 a = 1; b = 1; cin = 1;
end
endmodule`
希望能为您提供帮助!
阅读全文