A binary-to-thermometer decoder digital block is created in Cadence. The VHDL code example transforms an 8-bit vector into 256 thermometer signals.
[Cuadro texto=’The thermometer code converts an N-bit number into a series of ones followed by zeroes of size 2^n’]
The thermometer code, also referred to unary code, is useful to transform the input vector and use it to drive several switches, as I show in this example of a digitally controlled current source. Also, it is used to perform smoother transition during the most significant bit changes, instead of the binary-code.
In this example, an 8-bit vector is going to be transformed into a 256 output vector (thermometer-encoded).
The thermometer coder block is written in VHDL, but it could be extrapolated to Verilog:
entity thermometer is
vector_in : in std_logic_vector(7 downto 0);
vector_out : out std_logic_vector(255 downto 0)
architecture vhdlams of thermometer is
signal salida : std_logic_vector(255 downto 0) := (others => '0');
variable intermediate: integer range 0 to 255;
intermediate := CONV_INTEGER((vector_in));
salida <= (others => '0');
for i in 0 to intermediate loop
salida(i) <= '1';
vector_out <= salida;
The Verilog block was simulated in Cadence. For the test bench, an 8-bit counter signal is given as an input vector to the block under test.
The output waveform: