Thanks syedshan...can you explain me with some example?
i tried this program and it is showing wrong results...
module arithmetic(A,B,S,out);
input A,B;
input [1:0] S;
output out;
wire en1,en2,en3,en4;
assign en1=(~S[0])&(~S[1]);
assign en2=(S[0])&(~S[1]);
assign en3=(~S[0])&(S[1]);
assign en4=S[1]&S[0];
and1 a1(A,B,en1,out);
or1 o1(A,B,en2,out);
xor1 x1(A,B,en3,out);
nor1 n1(A,B,en4,out);
endmodule
module and1(A,B,en1,out);
input A,B,en1;
output out;
wire out;
assign out=A&B&en1;
endmodule
module or1(A,B,en2,out);
input A,B,en2;
output out;
wire out;
assign out=(A|B)&en2;
//always@(A or B or en2)
// begin
// if(en2)
// out=A|B;
// end
endmodule
module xor1(A,B,en3,out);
input A,B,en3;
output out;
wire out;
assign out=(A^B)&en3;
endmodule
module nor1(A,B,en4,out);
input A,B,en4;
output out;
wire out;
assign out=(~(A|B))&en4;
endmodule