- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page