09-23-2020 02:13 AM
I have a refence clock of 100 MHZ. I would like to measure another clock which is varying in frequency.
I would like to know Is there any way to measure other clock with a reference clock(100 MHz in my case) inside RTL(system verilog) lets say by means of scanning the pulse and counter?
09-23-2020 02:29 AM
Can be done, but I think your clk to be measured will have a frequency restriction wrt the ref clk (100M).
Consider giving "Kudos" if you like my answer. Please mark my post "Accept as solution" if my answer has solved your problem
09-23-2020 03:00 AM
haven't tried my self but just a rough Idea:
Run two counters, one using A 100 Mhz and another B using the unknown freq.
Generate a Control circuitry such that it will be applied to both the counters and it will run A counter for only 1-2 or some finite number of counts.
Read the count values of both counters, you will get a relation like X cycles of A = Y cycles of B thus Y/X is the relation between unknown freq and known
This will only work when unknown freq > known freq.
Hope this helps
09-23-2020 03:18 AM
Surely if you run it for a known number of clocks in Domain A (the longer the better) then it doesnt matter if A is faster or slower than B, the ratio can be calculated. Obviously there may be a little jitter and synchronising the reset will be an issue, but the longer you run the sample the better.
09-23-2020 03:30 AM
yes, you are correct, I think my thought process ( while writing the reply ) did not consider the other possibility.
This will only work when unknown freq > known freq. As Richard said it will work, the tricky part is the reset ( control circuitry ) and in the other case ( unknown freq < known freq ) X/Y will be the relation.
09-23-2020 04:08 AM
Yes, it can be done. I've done it often. The trick is to use a counter to slow the variable clock down so that it's within the range of the 100MHz clock, and then to count the slower transitions on the 100MHz clock.
See here for a discussion and an example design that has done nicely for me. Resolution is 16Hz--far better than your hardware clocks will give you.