Forum Discussion
Altera_Forum
Honored Contributor
15 years agolong long division does not make use of the HW divider
My NIOSII has configured hw divider. When I look into the OBJDUMP of divide operation of 2 integers (32 bits), I see that the operation is proprly done by a single "div" instruction. However -...
Altera_Forum
Honored Contributor
15 years agoThe hardware divide only does 32x32 divide.
So you need something else to perform the 64 bit divide. If you really do need the division operation then there is little choice. However if you are only dividing by constants, you can arrange to use a 'multiply by reciprocal' sequence instead. If the divisor is relatively small (say less than 16 bits) the you might be able to do a series of divisions (like doing long division by hand) where each is less that 32 bits. Alternatively, if the performance isn't an issue, do a 64 bit binary long division yourself. Provided __divdid3() is compiled with -O3 it may actually be reasonly fast - I haven't looked at the one that Altera provide, but the code might be generating several bits per iteration.