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

lpm_divide remainder result

Altera_Forum
Honored Contributor II
1,444 Views

My thread is mainly on the remainder output from the lpm_divide. 

 

I am using the lpm_divide megafunction for diving two 16 bit fixed point numbers and the denominator is always greater than or equal to the numerator. Meaning, the result of the division in my case would be less than 1 90% of the time. The quotient of the megafunction would give either a 0 or 1. But what about the remainder?  

 

For example, (0.25 / 0.50) * (2^15/2^15) = 8192/16384 using lpm_divide would give a quotient 0. But would the remainder be simply 8192? 

 

Thanks in advance for the help.
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
424 Views

That's correct you should get that value as the remainder. As a result I would prescale the numerator more than the denominator so that you get a quotient that is beyond 0 or 1 (otherwise you don't really need a divider to figure out the answer....)

0 Kudos
Reply