I'm currently trying to code a positive edge detector that changes its output every time a positive edge is detected. I succeeded in building one with gate-level modelling, but now I need to build it using behavioral modelling. I tried building it using this foundation:
module pos_edge_det ( input sig,
input clk,
output pe);
reg sig_dly;
always @ (posedge clk) begin
sig_dly <= sig;
end
assign pe = sig & ~sig_dly;
endmodule
I tried making code where in every positive edge it detects on the input, the output will always invert:
module posedgedet(in, out, clk, res);
input wire in,clk,res;
output wire out;
always @ (posedge in, posedge clk)
begin
out <= ~out;
end
endmodule
When compiling, it returned this following error
Error: C:/Modeltech_pe_edu_10.4a/examples/pos edge detect.v(8): (vlog-2110) Illegal reference to net "out".
What does this error mean, and how do you properly use the always code to detect a positive edge on both input and clock pulse?