I’ve used versions of this table function from the ngspice manual to make an ideal comparator. I recall being able to simply include some variation of this this as a netlist symbol in the comparator schematic, but you might have to iterate to get the full syntax correct:
ECMP 11 0 TABLE {V(10,9)} = (-5mV, 0V) (5mV, 5V)