- a single inverter
- a series of two inverters
So, regardless of input polarity, one chain output will be high and the other low.
I used a venerable CD4069 for a quick test, although any inverter (matched to the voltage of the signal) will do. The result of the polarity test is displayed with a pair of LEDs reversed in parallel.
As always, all notes, schematics and code are in the Little Arduino Projects repo on GitHub.