我不太了解verilog,所以这可能是我设置事物方式的一些简单问题,但我似乎无法确定为什么我的模拟波形会为我的测试台输出产生x或z。这是我正在模拟的模块:
module addsub_4bit (Sum, Ovflw, A, B, sub);
input [3:0] A, B;
input sub;
output [3:0] Sum;
output Ovflw;
wire cin, c0, c1, c2, c3;
assign B[3:0] = (sub) ? (~B + 1) : B;
assign cin = 0;
assign Ovflw = (c3 ^ c2);
full_adder_1bit fa0 (.sum(Sum[0]), .cout(c0), .a(A[0]), .b(B[0]), .cin(cin));
full_adder_1bit fa1 (.sum(Sum[1]), .cout(c1), .a(A[1]), .b(B[1]), .cin(c0));
full_adder_1bit fa2 (.sum(Sum[2]), .cout(c2), .a(A[2]), .b(B[2]), .cin(c1));
full_adder_1bit fa3 (.sum(Sum[3]), .cout(c3), .a(A[3]), .b(B[3]), .cin(c2));
endmodule
和我的测试台:
module addsub_4bit_tb();
reg [7:0] stim;
reg sub;
wire [3:0] Sum;
wire Ovflw;
integer i;
addsub_4bit DUT(.Sum(Sum), .A(stim[3:0]), .B(stim[7:4]), .Ovflw(Ovfw),
.sub(sub));
initial begin
stim = 0;
sub = 0;
#100;
for(i=0; i<16; i=i+1) begin
stim = stim + 1;
#100;
end
stim = 0;
sub = 1;
#100;
for(i=0; i<16; i=i+1) begin
stim = stim + 1;
#100;
end
end
initial $monitor("A= %d\tB= %d\nAdd/Sub= %b\nSum= %d\tOvflw=
%b",stim[3:0],stim[7:4],sub,Sum,Ovflw);
endmodule
我的输出给出了 Sum = x 和 Ovflw = z。我用来组成我的 4 位加法器的单位全加器模块工作正常并经过测试。我很感激任何反馈。