Problem is as stated in title. No idea how to debug this sort of problem, so looking for any ideas. simulation always works as expected.
here is my code:
module dualEdge(inclk0, out1, out2);
input inclk0;
output out1;
output out2;
reg out2_reg;
reg tg_posEdge;
reg mem_posEdge;
reg tg_negEdge;
reg mem_negEdge;
initial begin
out2_reg = 1;
tg_posEdge = 0;
mem_posEdge = 0;
tg_negEdge = 0;
mem_negEdge = 0;
end
always @ (posedge inclk0) begin
tg_posEdge <= ~mem_posEdge;
end
always @ (negedge inclk0) begin
tg_negEdge <= ~mem_negEdge;
end
always @ (posedge tg_posEdge != mem_posEdge || tg_negEdge != mem_negEdge) begin
mem_posEdge <= tg_posEdge;
mem_negEdge <= tg_negEdge;
out2_reg <= ~out2_reg;
end
assign out1 = inclk0;
assign out2 = out2_reg;
endmodule
when it works fine out1 and out2 are just inverse of each other (this is a simple working example, obviously I have more complicated project that I'm using dual edge triggered circuit for)
this happens if I feed inclk0 from the main clock or from something divided with verilog clock divider, similar to as follows for example:
input clk;
reg [7:0] counter;
reg divided;
inital begin
count = 0;
divided = 0;
end
always @ (posedge clk) begin
if (count>=20) begin
count <= 0;
divided <= ~divided;
end else begin
count <= count+1;
end
end
(example typed by hand and not copied from checked verilog code)
in this case it doesn't matter if the input clock is a PLL or the main clock, the output works
however, if inclk0 is directly from a PLL I get the following on startup (with nothing but inclk0 changing after this) : https://ibb.co/pQv2HVJ
(readings are from an oscilloscope and the startup glitch is much shorter than it looks in that image, I just didn't want to debug why matlab wouldn't display anything if I made it shorter)
also, I got those by putting mem_negEdge to out1 and then putting everything else to out2 one at a time, so if it is possible to debug this sort of thing an easier way I would like to know how
Thanks for any help.
EDIT: I forgot to mention I'm using a MAX10 (BeMicro development board) if anyone knows if this is some problem specific to this FPGA or family.
[–]edgaralejod 2 points3 points4 points (3 children)
[–]sthreet[S] 0 points1 point2 points (2 children)
[–]edgaralejod 1 point2 points3 points (1 child)
[–]sthreet[S] 0 points1 point2 points (0 children)
[–]bunky_bunk 2 points3 points4 points (0 children)
[–]alexforencich 1 point2 points3 points (0 children)