我正在用Active-hdl编写4位全加器,我认为我的代码和测试平台是正确的,但是和cout的值在波形中总是z,谁能帮我解决is.this我的代码和测试bech的问题吗?
module fullAdder(A, B, cin, sum, cout);
input A,B,cin;
output sum,cout;
assign {cout , sum} = A + B + cin;
endmodule
module fullAdder4bits(A, B, cin, sum, cout);
input [3:0] A,B;
input cin;
output [3:0] sum;
output cout;
wire w1,w2,w3;
fullAdder I0(A[0],B[0],cin,sum[0],w1);
fullAdder I1(A[1],B[1],w1,sum[1],w2);
fullAdder I2(A[2],B[2],w2,sum[2],w3);
fullAdder I3(A[3],B[3],w3,sum[3],cout);
endmodule
`timescale 1 ns/1 ps
module testbench;
reg tcin;
reg [3:0] tA,tB;
wire [3:0] tsum;
wire tcout;
fullAdder4bits dut(tA, tB, tcin, tsum, tcout);
initial
begin
tA = 0;
tB = 0;
tcin = 0;
#10 tA = 5;
#10 tB = 8;
#10 tA = 7;
#10 tcin = 1;
end
initial $monitor("A = %d , B = %d , cin = %b , sum = %d , cout = %b",tA,tB,tcin,tsum,tcout);
initial #60 $finish;
endmodule

发布于 2019-01-03 14:06:00
我找不到任何错误,所以我决定把你的设计扔到Vivado。
它帮助您提供完整的代码,包括测试平台!
您的代码似乎很好,在Vivado中,我没有看到“z”状态:

https://stackoverflow.com/questions/54023582
复制相似问题