- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey guys,
I posted something earlier here about NLMS on an FPGA. So far, I have the LMS working, but I need to perform a fixed point division to perform normalization. My question is how to use the LPM_DIVIDE megafunction to do this? Let's say you have two fixed point binary numbers with 4 bit precision, like 1110.0010. If you use the megafunction, you will get a quotient and remainder. The problem is how do you convert these two outputs back into a decimal number in binary? One idea I had was to use the floating point megafunction, and then convert between fixed and floating point through the conversion function. But, it uses a min of 6 clock cycles. I'm ddoing acoustic echo cancellation, so this really is undesirable. I already have some extraneous clock cycles to accomodate buffer latency. I really don't want to add any more. If I use the LPM_Divide function, I won't introduce any latency at all. This is a senior project, so I am kind of learning this stuff on the fly for the first time. Any help would be greatly appreciated.Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As usual with fixed point, LPM_DIV doesn't know about it and treats everything as integers.
If both your numerator and denominator are in q4 form (4 fractional bits), then your quotient will be in q0 form (no fractional bits) and your remainder will be in q4 form (4 fractional bits). More in general, if your numerator is in qX form and your denominator is in qY form, then - The remainder will be in qX form - The quotient will be in q(X-Y) form. Sometimes you can replace division with a multiplication by the inverse, where the inverse is obtained through a look up table.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the reply rbugalho.
I understand the format of the quotient and remainder, but you really did confirm and clear up my understanding. The problem I'm having is how to conver the remainder and quotient back into Q4 form. For example, let's say you are dividing 5 by 2. You should get 2 for a quotient and 1 for the remainder. As a decimal this would be 2.5, or 0010.1000. The quotient would be 0101 and the remainder would be 0001.0000. The grade school way of doing the conversion would be to add 1/2 to the quotient to yield 0010.1000, or 2.5. But, again it introduces another divsion with the same problem.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You need to promote the numerator to Q8, while leaving the denominator in Q4.
Then you'll get a quotient in Q4 and remainder in Q8. You can then convert the remainder to Q4 by rounding off the 4 LSBs.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5/2=2.5
101.00000000/010.0000=010.1000=2.5 Your solution works! Thank you. Added to your reputation...
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