Four phase detectors. Signal flow is from left to right. In the upper left is a Gilbert cell, which works well for sine waves and square waves, but less well for pulses. In the case of square waves, it acts as an XOR gate, which can also be made from NAND gates. On the middle left are two phase detectors: adding feedback and removing one NAND gate produces a time-frequency detector. The delay line avoids a dead band. On the right is a charge pump with a filter at its output.
A phase detector or phase comparator is a frequency mixer, analog multiplier or logic circuit that generates a signal which represents the difference in phase between two signal inputs.