Thermometer Code Detector
Medium · Combinational · SystemVerilog
Implement a thermometer code detector: assert {isThermometer} when {codeIn} is a valid thermometer code in either orientation — a run of 1s growing from one end of the word with 0s filling the rest.
Equivalently, {codeIn} is a thermometer code exactly when scanning it bit-to-bit finds a single 0/1 transition. All-0s and all-1s words contain no transition and are not thermometer codes.