Altera_Forum
Honored Contributor
15 years agoMeasuring Frequency help
I need to measuring a signal frequency
i have a reference frequency of 100 MHz i used the following code bu it didn't work properly it counter right at the first but after that it got wrong: process(n_reset,clk_ref100,clk) begin if n_reset='0' then s_clk_ref100_counter<=(others=>'0'); elsif rising_edge(clk_ref100) then if s_clk_ref100_counter>=10000 then s_freq<=s_sys_clk_counter; s_clk_ref100_counter<=(others=>'0'); else s_clk_ref100_counter<=s_clk_ref100_counter+1; end if; end if; if n_reset='0' then s_sys_clk_counter<= (others=>'0'); elsif rising_edge(clk) then if ((s_freq<=s_sys_clk_counter-5) and (s_sys_clk_counter/=x"000")) then s_sys_clk_counter<= (others=>'0'); else s_sys_clk_counter<=s_sys_clk_counter+1; end if; end if; end process; Please advice me.