Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
21582 Discussions

the Quotient is floating point in vhdl

Altera_Forum
Honored Contributor II
1,772 Views

hi all  

 

if i want to divide two numbers and i know the result would be float . 

 

what can i do it and how to specify the output from division 

 

thanks a lot.
0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
1,085 Views

what are the two operands? diving two integers gives you an integer and remainder result (if you use the IP core). If you use correct scaling, you can get a fixed point output. You only get a floating point result if both inputs were floating also.

0 Kudos
Altera_Forum
Honored Contributor II
1,085 Views

hi tricky 

when i try to divide two integer as 8/12 =0.66666 it gave a float point the two operands type are std_logic_vector( 7 downto 0) .should i define the output from result in float
0 Kudos
Altera_Forum
Honored Contributor II
1,085 Views

8/12 = 1 and remainder 4. Not 0.666666. If you use different scaling you can get more accurate results. It will not be floating point unless you convert both 8 and 12 to floating point (32 bit usallly). 

 

Why not post the code.
0 Kudos
Altera_Forum
Honored Contributor II
1,085 Views

thanks tricky a lot for helping my design is used to measure the distance between two input data in the following code i used the accum to sum the distances measurements and the counter to count the numbers of data measured and i want to divide the accumulator result on the counter result .if you understand me well , is this possible or i should use the trigger signal to sense the last sample input . if that i said is wrong ,so i will divide accumulator on the counter result. sorry for ad English and i hope you help me thank a lot. i attache the code and the simulation picture . i want to thank kaz for helping me before to make this code thanks kaz very much

0 Kudos
Altera_Forum
Honored Contributor II
1,085 Views

Floating point is most likely not the best solution for your problem, a 8.8 fixed point number sounds like a better idea. You easily get it by multiplying the dividend with 256 before the division. 

 

8 fractional bitsis just a first guess, you have to find out the required accuracy for your problem. I notice that your ideal result is already several percent off by truncating the divisor of 12.5 to 12. Of course, this point could be corrected in a fixed point algorithm, too.
0 Kudos
Reply