//AND gate using Structural modeling
module and_gate_s(a,b,y);
input a,b;
output y;
and(y,a,b);
endmodule
//AND gate using data flow modeling
module and_gate_d(a,b,y);
input a,b;
output y;
assign y = a & b;
endmodule
//AND gate using behavioural modeling
module AND_gate_b(a,b,y);
input a,b;
output y;
always @ (a,b)
y = a & b;
endmodule
//OR gate using data flow modeling
module or_gate_d(a,b,y);
input a,b;
output y;
assign y = a | b;
endmodule
//NAND gate using data flow modeling
module nand_gate_d(a,b,y);
input a,b;
output y;
assign y = ~(a & b);
endmodule
//NOR gate using data flow modeling
module nor_gate_d(a,b,y);
input a,b;
output y;
assign y = ~(a | b);
endmodule
//EX-OR gate using data flow modeling
module xor_gate_d(a,b,y);
input a,b;
output y;
assign y = a ^ b;
endmodule
module not_gate_s(a,y);
input a;
output y;
not(y,a);
endmodule
module not_gate_d(a,y);
input a;
output y;
assign y = ~a;
endmodule
module not_gate_b(a,y);
input a;
output reg y;
always @ (a)
y = ~a;
endmodule