纹波携带加法器测试台波形

时间:2018-04-24 13:30:17

标签: verilog

我的测试台如下所示,我需要以下波函数:waveform at 150ns

module rca_dataflow_tb;

reg [3:0] a;
reg [3:0] b;
reg cin;
wire [3:0] s;
wire cout;

rca_dataflow dut(.a(a),.b(b),.cin(cin),.s(s),.cout(cout));

initial
    begin

    #20
    a = 4'b0;
    b = 4'b0;
    cin = 1'b0;
    #20
    if ((s == 4'b0000) & (cout == 1'b0)) 
    $display("Test Passed");
    else 
    $display("Test Failed");

    // s to be 0000
    // cout should be 0

    #20
    a = 4'b0100;
    b = 4'b0000;
    cin = 1'b0;
    #20
    if ((s == 4'b0100) & (cout == 1'b0))
    $display("Test Passed");
    else 
    $display("Test Failed");

    // s to be 0100
    // cout should be 0

    #20    
    a = 4'b1001;
    b = 4'b0010;
    cin = 1'b0;
    #20
    if ((s == 4'b1011) & (cout == 1'b0))
    $display("Test Passed");
    else
    $display("Test Failed");

    // s to be 1011
    // cout should be 0

    #20
    a = 4'b1001;      
    b = 4'b1001;      
    cin = 1'b1;
    #20
    if ((s == 4'b0001) & (cout == 1'b1))
    $display("Test Passed");
    else
    $display("Test Failed");

    // s should be 0011 to pass test
    // cout should be 1

    end

endmodule

0 个答案:

没有答案