Continue to Site

# How to solve this frequency comparator task?

Status
Not open for further replies.

#### ashish.master2

##### Newbie level 5
problem statement is in the image attached

Re: frequency comparator

a naive approach would be to do make two counters for two clocks and let them count in each clock frequency. Run the counter for a fixed number of cycles of system clock. See if the the two counts are equal or unequal.

I hope it helps. Seniors like FvM and others can correct me.

Kind Regards,

Re: frequency comparator

This is likely the function of one of the phase detectors used in the Phase-Locked Loop (PLL), perhaps you can find it by yourself.

Operating the counters in different clock domains, although basically possible, creates serious data consistency problems when comparing the values. The fast system clock point suggests to run the logic exclusively in the system clock domain. You have to synchronize both asynchronous clocks to the system clock domain and then detect their edges and count them.

A PFD (phase frequency detector) state machine hasn't the primary purpose to detect frequency differences, because the PLL is mainly controlled by phass difference. The frequency detector is needed to achieve locking with large frequency deviations. But it doesn't directly detect smaller frequency differences.

You are right FvM. When I have closely analyzed various edge detectors, I found out that none can solve this problem.
To pass my time, I am trying to build one in my own way. The challenge is to get the exact output in the shortest time. When two frequencies are very close, their phase difference looks as being constant for too many periods.
In general, an optimum solution for a block couldn't be found if its application (its end purpose) is not well defined.

FvM

### FvM

Points: 2
The challenge is to get the exact output in the shortest time. When two frequencies are very close, their phase difference looks as being constant for too many periods.
In general, an optimum solution for a block couldn't be found if its application (its end purpose) is not well defined.
I agree with the latter. In fact, it doesn't make much sense to discuss the point more detailed without an exact specification. The exercise text doesn't give it.

Perhaps it's useful to refer to general frequency measurement. You get the fastest result by measuring the duration of a single period, the resolution is however limited by the timebase to input clock ratio. To increase it, you have to go for a multi period measurement.

KerimF

Points: 2