Spurred on by talk of a GPSDO based on an ESP32 mode, last night I had a hack at creating 1MHz GPS referenced signal using an FPGA board. After a good bit of thinking It was surprisingly simple.
1. Have a 100MHz numerically controlled oscillator (NCO) generating the 1MHz signal.
2. Have a second accumulator, which sees how much error is present when the PPS signal is seen
3. Slowly slew the NCO's frequency, proportional to 1/8th of the error over the last second. So at the end of the second, it is 1/8th of the way closer to the magic 1MHz value - basically a slow feedback loop.
4. If the PPS signal goes away, then zero the current error (to stop the NCO's frequency slewing off to infinity).
So rather than the 8 ppm error I would get from the dev board's 100MHz XTAL divided by 100, I now get less than 1 ppm (admittedly with about 10ns of saw-tooth jitter).
There are quite a few enhancements I could play with, (if only I had the time). Examples are adding an DAC, removing lots of the sawtooth jitter, adding a frequency display...).
http://hamsterworks.co.nz/mediawiki/index.php/GPSDO