# HDL coded digital to bcd (binary-coded-decimal) conversion

1. ## HDL coded digital to bcd (binary-coded-decimal) conversion

Hi all,

In the process of digital to analog conversion, the thermometer code output, corresponding to the digital value of the input signal, activates the unit value of the analog entities (which may be current or voltage sources). The analog output is the summation of all those activated analog entities.

Please can any one help me or give me examples how can i describe this process unsig VHDL or HDL code?

thanks a lot!

•

2. ## Re: HDL coded digital to bcd (binary-coded-decimal) conversion

Say you are using 8 bits. Then a value can occupy a range from zero to 255.

Say zero represents 0V, and 255 represents 5V. Then you can use a simple proportion to translate any value to a voltage.

To model this in electrical terms, each analog voltage is derived by sending 5 volts through resistors of different values.

Similarly each bit is weighted. You multiply it by a power of 2.

So if you have 8 bits...

The most significant bit is multiplied by 64 (2^7). The least significant bit is multiplied by 1 (2^0).

Sum all eight values. The total is scaled to whatever is the maximum voltage you would get if the value were all 1's.

•

3. ## Re: HDL coded digital to bcd (binary-coded-decimal) conversion

can you please give me an example how can i write it with vhdl or verilog code?

•

4. ## Re: HDL coded digital to bcd (binary-coded-decimal) conversion

Originally Posted by noura7
can you please give me an example how can i write it with vhdl or verilog code?
Sorry, I'm not familiar with those languages.

If your question is about how to turn on a wire representing each bit, then:

Look at the least significant bit (2^0) of the number.

If it is 1, then turn on the corresponding wire. If it is 0 then turn it off.

Go on to the next bit. Etc.

The wires go to weighted resistors. Here is a schematic showing one type of network:

--[[ ]]--