- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi All,
I am using MAX10 FPGA and need to calculate percentage. My data is 12 bit long. So I take the data, divide it by 100 by using the LPM_DIVIDE IP. I take the Quotient and multiply it to the desired percentage factor through LPM_MULTIPLIER. But LPM_DIVIDE IP produces Quotient and remainder. I am taking Quotient only that's why I am unable to get accurate results. So my question is that how should I use remainder to produce more accurate results. Thanks Regards USMANLink Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your 12bit data ranges from 0 to 4095, then if you divide it by 100 you simply lose the last two digits, namely 6-7 less significant bits of original data.
A better solution would be starting with the multiplication into a 18bit register and THEN dividing by 100.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ouh...
first you do multiplication and store intermediate result with more than required bits , then you do division. <- this works well. i don't know the number range you deal with. ( but if it doesn't break your accuracy you can replace division by 100 = 2^2 * 25 with division by 96 = 2^5 * 3 it means that at least 5 bits of operand looses)- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you guys... thank you very much. it is working now

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page