← All problems

Binary to Thermometer

Easy · Combinational · SystemVerilog · VHDL

Design a binary-to-thermometer decoder.

A thermometer (unary) code writes a number m as a word whose lowest m bits are 1 and the rest 0, like mercury rising in a thermometer.

dout is the thermometer code of din: its lowest din bits are 1 and all higher bits are 0. So din = 0 gives all 0s, and the largest din leaves only the top bit of dout at 0.

The module is combinational.

Open this challenge in the editor →