I am beginner in Verilog. So I am confused in coding in Verilog. Can I use one module in another module?
module pn(
input p,
input n,
input clk,
output reg q
);
initial begin
q = 0;
end
always @(posedge clk) q=(q&n)|((~q)&p);
endmodule
I want to use it in following module
module ic2323(
input p0,
input n0,
input p1,
input n1,
input clk,
output q0,
output q1,
output x
);
endmodule
Is it possible?
EDIT:
x=q0~^q1;
this code gives error
Reference to scalar wire 'x' is not a legal reg or variable lvalue
Illegal left hand side of blocking assignment
x=q0~^q1;
inside an always block, or in anassign
statement? If it's in an always block, you need to declarereg x
first. – The Photon Apr 7 at 14:58