首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我在4位fullAdder中的输出总是z,不改变

我在4位fullAdder中的输出总是z,不改变
EN

Stack Overflow用户
提问于 2019-01-03 13:48:42
回答 1查看 441关注 0票数 0

我正在用Active-hdl编写4位全加器,我认为我的代码和测试平台是正确的,但是和cout的值在波形中总是z,谁能帮我解决is.this我的代码和测试bech的问题吗?

代码语言:javascript
复制
    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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-01-03 14:06:00

我找不到任何错误,所以我决定把你的设计扔到Vivado。

它帮助您提供完整的代码,包括测试平台!

您的代码似乎很好,在Vivado中,我没有看到“z”状态:

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54023582

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档