AN2108 explains multiple implementations of a hysteresis comparator using PSoC® 1. Hysteresis is necessary to produce a glitch-free comparator output when there is noise in the input signals.
The comparator is the most fundamental building block of a mixed-signal design. It is essentially a differential amplifier with an extremely high open loop gain.