I need to write code with simple logical gates. How to assign one output to be next gate input?
Here is what I have tried:
module logical_gates(a,b,c,d,e,f,x,x1,x2,x3,x4);
input a,b,c,d,e,f;
output x,x1,x2,x3;
wire a,b,c,d,e,f;
wire x1,x2,x3,x4,x;
assign x1=a&b;
assign x2=e|f;
assign x3=x1~|c;
assign x4=x2~&d;
assign x=x3^x4;
endmodule
Here is what i need to convert into code.
Is there something wrong with your code? It seems to be fine (despite the fact that x4
should also be defined as output
). You can always describe your desired logic that way:
assign out = ~(~((a & b) | c) ^ ~(d & (e | f)));