XOR GATE
Verilog
design
//in Structural model
module xor_gate (
input a,b,
output y);
   xor x1(y,a, b);
endmodule
TestBench
module tb_and_gate;
    reg A,B;
    wire Y;
   Â
    xor_gate a1 (.a(A)
,.b(B),.y(Y));Â Â Â Â Â Â Â Â Â
   Â
    initial
begin
   Â
        A =1'b0;
        B= 1'b0;
        #45 $finish;
   Â
    end    Â
   Â
    always #6 A =~A;
    always #3 B =~B;
   Â
    always @(Y)
    $display( \"time =%0t \tINPUT VALUES: \t
A=%b B =%b \t output value Y =%b\",$time,A,B,Y);
endmodule
output
time =0Â Â Â Â Â Â Â Â INPUT
VALUES:Â Â Â Â A=0 B
=0Â Â Â Â Â Â Â Â output value Y
=0
time =3Â Â Â Â Â Â Â Â INPUT
VALUES:Â Â Â Â A=0 B
=1Â Â Â Â Â Â Â Â output value Y
=1
time =6Â Â Â Â Â Â Â Â INPUT
VALUES:Â Â Â Â A=1 B
=0Â Â Â Â Â Â Â Â output value Y
=1
time =9Â Â Â Â Â Â Â Â INPUT
VALUES:Â Â Â Â A=1 B
=1Â Â Â Â Â Â Â Â output value Y
=0