well, I have this code, that is working perfectly:
module syncRX(clk, signal, detect);
input clk, signal;
output reg [7:0] detect = 0;
reg [7:0] delay = 0;
//wire clk_1khz;
freq_div div(.clk(clk), .clk_1khz(clk_1khz));
always @(posedge signal)
begin
detect <= detect + 1;
delay <= 0;
end
always @(posedge clk_1khz)
begin
delay <= delay + 1;
end
endmodule // top
module freq_div(input clk, output reg clk_1khz);
reg [12:0] count = 0;
always @(posedge clk)
begin
if(count == 6000)
begin
clk_1khz <= ~clk_1khz;
count <= 0;
end
else
count <= count + 1;
end
endmodule
The problem appears when I change the line "detect <= detect + 1;" to "detect <= delay;". The intention is calculate the period of the signal, but I get this warning message of Icestorm: Warning: No clocks found in design
And the FPGA stop working… Please, anyone have an idea what is going bad? Thanks to all!
Best Answer
I think your real problem is that you are trying to load the
delay
flip-flops on two different edges,signal
andclk_1khz
. Such a flip-flop is (generally) not synthesizable, so the tools will throw an error if you try to do it. You will need to figure out a way to accomplish your goal without assigning to the same reg in two differentalways
blocks.