Forum Discussion
Altera_Forum
Honored Contributor
9 years agoLatches in frequecny divider using fsm implementation
I am new to verilog and HDL. I want to implement a N-frequency divider, which count clock ticks (pos and neg) and start the counting mechanism from the first rising edge of the input clk. In a...
Altera_Forum
Honored Contributor
9 years ago --- Quote Start --- OK, but as you said previously FPGAs doesn't support both falling and rising edges of signal. is that means every verilog module targeted for FPGA can't have sensitivity list without stating the edge of the signal? Thanks --- Quote End --- Your code is not clocked, it is level sensitive, hence the latches. If you wanted to be sentive to the edges, you would write:
always @(posedge clk or negedge clk)
begin
if (clk = '1') //rising edge action
else if (clk = '0') // falling edge action
end
This would create a double edge sensitive flop, which is not possible in FPGA. The following code is just level sensitive to the compiler, but not simulation as quartus will ignore the signals in the sensitivity list, and just use what is in the always block, so will not produce a flop:
always @(clk)
begin
if (clk = '1' ) // stuff to do while clock is '1'
else if (clk = '0') // stuff do while clock is '0'
end