Forum Discussion
Altera_Forum
Honored Contributor
15 years ago --- Quote Start --- you can look at 'a' as an 8 bit integer, say 51 which is 00110011 say you wanted to divide by 3. we will actually multiply by 1/3 in 8 bits fractional, so 'b' is 0.010101 00110011 x 0.010101 = 000010001.0000100 51 * 0.328125 = 17.03125 the decimal point is an abstraction. anyhow, this may work for your application (maybe if 'b' only has a few possible values) and only uses a 9 bit signed multiplier. hopefully someone can double check my work, its been awhile... --- Quote End --- Expanding on this, you could could use a lookup table to return your 1/n values and feed the output into a multiplier. Use n as the look up address, and have the table pre-calculated. This can run very very fast and wont eat up resources like a divider. Of course, this is only viable if you have a small number of bits in the denominator. In an Arria2/stratix 4 you'll probably be fine with 16 bits or so, but memory will start to dissapear after 8 bits with smaller devices.