Digital Thermometer Code in Verilog VHDL Flash ADC Binary Encoder Verilog by VLSI Universe - May 26, 2021July 21, 20210 Thermometer code to Binary encoder or code converter. A digital thermometer code in VHDL and Verilog, Flash ADC-based Thermometer code with less BER. Table of Contents ToggleIntroductionA Digital ThermometerThermometer code (Thermometer to Binary conversion)Binary code to the thermometer readingConclusion Introduction A French word thermometer came out in La Recreation Mathematics by J. Leurechon in the year 1924. He comes up with a scale of 8 degrees thermometer. It is very important to have the thermometer digitized. Especially if we implement a thermometer code in Verilog HDL or VHDL, it will be a great job. In the current time, we are using automated logic synthesizers which help us to convert our VHDL or Verilog HDL to a digital circuit easily and faster way. If so, we can adapt different technologies by simply making small changes and by putting constrain on our code. We have very strong and powerful CAD tools which make the conversion more precise and effective. A Digital Thermometer A Digital Thermometer is a piece of bio-medical electronic equipment that can be used for knowing the body temperature of a human. This equipment typically measures the temperature or the temperature gradient of an individual. A typical digital thermometer mainly contains a temperature sensor and a converter. The temperature sensor will detect the temperature changes and the temperature converter will give us a digital number in the required unit. Hence the name digital temperature reader or thermometer. And it is more likely preferred by many because of its high precision and is easy to use. It beats the older traditional mercury thermostat which does the same job. Thermometer code (Thermometer to Binary conversion) A thermometer code is an output of a thermometer-to-binary encoder which is mainly making use of a component called flash ADC (Analog to digital converter). There are so many efficient have come up to make it in a more precise way. One of the main problems here was the BER i.e., Bubble error which mainly comes because of switching noise. The comparators of a Flash ADC will be the main cause for this switching noise spreading. The outcome is binary which becomes erroneous because of BER. If an encoder used the ROM approach or a combinational circuit which is defined using the Boolean expression, then we arrive at a good solution. Several good techniques are available in the design world to get the thermometer code from an analog value. Let’s assume here we have got the thermometer code which is binary by a very efficient Flash ADC or ROM approach. With some assumptions, we can write a Verilog code which helps to reduce the BER rate of the thermometer code. The assumptions are as below, 1. The bits which are set to 1 are assumed to be correct, 2. The bits which are set to 0 above the top 1 are assumed to be correct, 3. The bits which are set to 0 below the top 1 are assumed to be incorrect, This approach involves the divide and conquers approach to improve the performance of a design, either in both cases of software or hardware. The Verilog code for the thermometer to binary conversion is written as below, module thermometertobinary (thermometer, binary); input [62:0] thermometer; output [5:0] binary; reg [5:0] binary, binary1, binary2; integer k, m; always @ (thermometer) begin binary1 = 0; for(k = 1; k <= 32; k = k + 1) if(thermometer[k-1] == 1’b1) binary1 = k; end always @ (thermometer) begin binary2 = 0; for(m = 1; m <= 31; m = m + 1) if(thermometer[m+31] == 1’b1) binary2 = m; end always (binary1 or binary2) begin if(binary2 > 0) binary = binary2 + 32; else binary = binary1; end enmodule Binary code to the thermometer reading A typical thermometer code looks like a binary number P which has the lowermost P number of bits as logical 1 and other bits as logical 0. So, if we want to move from place P to P+1, the immediate next place we need to replace the rightmost 0 to 1. Let us understand the actual thermometer code, Any symbol of a thermometer code is nothing but a sequence of 0’s followed by a sequence of 1’s and a condition is that a binary code should not contain 0’s in between two adjacent 1’s. If a thermometer binary code is of N-bit, then it is made up of 2N-1 symbols. Example thermometer codes. A symbol 0010111 is invalid as it has 0’s in between 1’s A 4bit binary code will have 7 different symbols The above graphical chart shows 8-degree scale values from 0 to 7 of a thermometer binary code. Each scale value will correspond to individual temperature degree level in an 8 level scaled thermometer. The flash ADC plays an important role in bringing up these encoded binary values. A VHDL code is written below for conversion of thermometer binary code to thermometer readings. Here an input binary of 2bit is considered an output of 7 bit for the thermometer reading. library IEEE; use IEEE.STD_LOGIC_1164.ALL; use ieee.numeric_std.all; entity thermometercode6bit is port ( binary_in : in std_logic_vector (1 downto 0); thermometer_out : out std_logic_vector (6 downto 0) ); end thermometercode6bit; architecture Behavioral of bin2therm6bit is begin process (binary_in) begin LabelthermometerCode : case binary_in is when "000" => thermometer_out <= "0000000"; when "001" => thermometer_out <= "0000001"; when "010" => thermometer_out <= "0000011"; when "011" => thermometer_out <= "0000111"; when "100" => thermometer_out <= "0001111"; when "101" => thermometer_out <= "0011111"; when "110" => thermometer_out <= "0111111"; when "111" => thermometer_out <= "1111111"; when others => thermometer_out <= “xxxxxxx”; end case; end process; end behavioral; Conclusion The above example is considered only for illustration, whereas real-life data totally different. In real-life 8-degree scale value won’t give high accuracy. Practically there should be a minimum of 100-degree level to accurately measure human temperature. The biomedical equipment thermometer is dealing with real-life people. A flash ADC with a large number of comparators finds it difficult to get an optimal result. That is generating a thermometer code more precisely is very difficult and important to get maximum accuracy. The above-discussed example is for illustration only where on 8 different degree scales are considered. In real-life scenarios, a flash ADC will have a large number of comparators and produce a larger binary-valued thermometer code. Many binary bits in Verilog or VHDL have to be dealt and efficient hardware should come out. A synthesized digital circuit from a VHDL or Verilog code will further take to design an IC or VLSI chip. Which intern leads to an increased number of binary bits. A large number of binary bits would require more digital circuits. So implementing an efficient logic design is crucial. Hope you like it, please see other sections for important VLSI topics. If you are preparing for an interview please checkout the interview section where you will find various interview experiences and interview questions. Also, read popular articles from this blog, 1. Qualcomm Interview Experience 2. Maxlinear Interview Questions 3. MediaTek Interview Questions 4. Top 10 interview puzzles 5. Transistor Sizing W/L 6. FSM Solved Questions 7. Asynchronous FIFO Depth Calculation