I found the method for c language.But I do not know how to perform this in VHDL.
Let a fixed point number (12 downto -19) like 3456.478396 I need break this number entirely into separate numbers 3456.478396 –> 3, 4, 5, 6, (dot) , 4, 7, 8, 3, 9, 6… into 11 integer type variables.
How to perform this in VHDL?
signal example : sfixed(4 downto -4);
--'example' contains 9.75 then it is storage as "01001.1100".
--simply example ="10011100".
--10011100 --> integer 156
How to get back original 9.75 number from 156 to separate into single digits?
I USED,
library ieee;
library ieee_proposed;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee_proposed.float_pkg.ALL;
use ieee_proposed.fixed_pkg.ALL;
use ieee_proposed.fixed_float_types.ALL;
Best Answer
Here's some pseudocode.
Let's take the ones left of the decimal first, max number is \$15_{10}\$ => 2 decimal digits.
Example:
ex=\$12_{10}\$=\$1100_{2}\$
And then the ones to the right, smallest number => 0.0625 => 4 decimal digits. Same method as before, just multiply by \$625_{10}\$ before you start. Because \$0001_{2}\$ in binary translates to \$.0625_{10}\$ in decimal. So the bit width of temp should be \$ceil(log_2(625×15))=\$ 14 bits because \$15_{10}\$ is \$1111_{2}\$ which is your highest value.
Example:
ex=\$0.1875_{10}\$=\$0011_{2}\$
And it should be displayed like this:
\$L_1 L_0 . R_0 R_1 R_2 R_3\$
All the constant division by 10 can be replaced by a multiplication with \$\frac{1}{10}\$. So it's not too inefficient to implement. I'm fairly certain that the modulus operator comes with the standard library.
If you use 6 bits for the right hand side of the decimal point. Then the bit width for temp should be \$ceil(log2(63×15625))\$ = 20 bits. This is probably not the most efficient way, it's a way I came up with just now on my own. It should work without any major problems.
Since this is being done on an FPGA you can parallelize the multiplication, for R3,R2,R1 and R0, multiply their temp with 1, \$\frac{1}{10}\$, \$\frac{1}{100}\$ and \$\frac{1}{1000}\$ so you get the values straight away, instead of serially. And then use the mod 10 on them.
EDIT
Mishyoshi gave me an idea for how this could be solved in another way. \$L_0\$ and \$L_1\$ are solved like before, but the \$R_{0..3}\$ can be done in another more efficient way.
Example:
ex=\$0.1875_{10}\$=\$0011_{2}\$
As you can see it's all about getting the bits to the "ones" place, the 4 bits to the left of the decimal point.
That's way fewer bits needed for this. In this other solution you can, like Mishyoshi said, put them in a pipeline.