testbench.v 946 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
module middle_tb
(
	input x,
	input y,
	output o
);

parameter Y = 1'b1;

urtl_tb u_urtl (.x(x),.o(o),.y(Y));
endmodule

module urtl_tb
(
	input x,
	input y,
	output o
);

assign o = x + y;
endmodule

module testbench;
    reg [0:2] in;

	reg patt_A = 1'bX;
	wire patt_cout;
	wire cout,o;
    wire A;

    initial begin
        // $dumpfile("testbench.vcd");
        // $dumpvars(0, testbench);

        #5 in = 0;
        repeat (10000) begin
            #5 in = in + 1;
        end

        $display("OKAY");
    end

    top uut (
	.x(in[0]),
	.y(in[1]),
	.cin(in[2]),
	.A(A),
	.cout(cout)
	);

	always @(posedge in[2])
	patt_A <= o;

assign pattcout =  in[2]? in[1] : in[0];

middle_tb #(1'b0) u_mid1 (.x(in[0]),.o(o),.y(1'b0));
middle_tb #(1'b0) u_mid2 (.x(in[0]),.o(o),.y(1'b1));
middle_tb #(1'b0) u_mid3 (.x(in[0]),.o(o),.y(1'bX));
middle_tb #(1'b0) u_mid4 (.x(in[0]),.o(o),.y(1'bX));

	assert_comb out_test(.A(patt_A), .B(A));

endmodule