type I phase detector - analog vs digital inputs
In binary math, multiplication is done by shift and add while while the XOR gate logic adds.  The output is the DC phase error and 2f pulse (difference phase/frequency, f and sum).

Learn with simulation here.

Think of the square wave clock as a multiplier +/-1 of the input signal. 1=Invert, 0 = Normal  then the output is the sum and difference frequencies. If both at same f then output Vdc= phase difference.