- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
how fast is clk? the fact you are samplining a 100MHz counter in another clock domain and vice versa is probably your problem. You will need to transfer the counters across the clock domains safely, either with a double register or a dual clock fifo.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tiried with triple register and it worked
thanks
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page