Suppose I have 3 separate square-wave digital 5V clocks, named A, B and C. All 3 clocks are running at the same frequency of 1 kHz, and at different phase offsets. Suppose the clock generators that are creating these clock signals can be disabled and restarted arbitrarily, but they cannot be "paused". For the purposes of this example, we can assume all the clock generators are ideal, and that no drifting is present.
Suppose I want to shift the phase offset of clock C by the phase difference between clocks A and B.
For example;
If clocks A, B and C have phase offsets of 0°, 20° and 50° respectively, I would seek to shift the phase of clock C by -20° (from 50° to 30°).
This task would be simple to accomplish if the clock generators in my case were some sort of analog circuits which use isolatable capacitors to perform the clock timing, such as a 555 timer. In that case the clocks could have their phase offsets effectively shifted by any arbitrary amount if we momentarily pause the charging & discharging cycles of the timing capacitors by isolating them.
However, in my specific example, the clock generators are digital circuits, and therefore this "pausing" concept is not possible. I was therefore curious whether it is possible to achieve this phase-shifting using only digital logic.
I'm assuming the first step towards achieving this would be to quantify the exact phase difference between clocks A and B. I'm assuming this would be done by using an XOR gate between clocks A and B, which would yield the phase difference between them. However, I'm unsure of how to proceed next.
Since all the clocks are running concurrently at different phase offsets, it proves challenging to achieve this. However, I was wondering whether it would be possible to do this if my clock generators can be disabled & restarted arbitrarily, and whether it would be possible to maybe output the shifted version of clock C as a new fourth clock signal from another clock generator after some digital processing.
In my specific case the clocks are being supplied from several microcontrollers, each running on their own respective clocks. While it may be possible to pause the firmware running on the MCUs in question in order to achieve the phase shifting of the clocks they're running, I'm worried that using the firmware on the digital MCUs to shift the phases of these clocks would introduce inherent errors into the system, since I'm seeking to shift the phases of these clocks by a continous, not a discrete amount.
However, I'm pretty sure this type of clock synchronization is a linear operation, and therefore this might be possible to achieve using only digital logic. As stated though, whatever logic is required to make this work, it would probably involve starting new clocks in the continous time space.
Is it possible to shift the phase offset of a digital clock by the exact phase difference two separate digital clocks using only digital logic? Are there existing digital circuits made for this purpose?
