Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.arch.embedded > #30270
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Newsgroups | comp.arch.embedded |
| Subject | Re: Fixed Point Calculations |
| Date | 2021-01-18 08:53 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <ru3epe$fmq$1@dont-email.me> (permalink) |
| References | (2 earlier) <8441a69e-f16d-4ff7-8e62-12c75a253f69n@googlegroups.com> <rsskse$423$1@dont-email.me> <c10b9d38-2052-416d-b0c9-0dfe90dc680en@googlegroups.com> <rsujet$kv4$1@dont-email.me> <c992ae8e-f603-47ef-9534-1092c2b72327n@googlegroups.com> |
On 18/01/2021 07:11, Rick C wrote: > I solved the problem of fixed point math being a PITA by changing to > floating point which is easier in some ways even if a bit of a bother > in others. Floating point makes multiplies and divides easier (ignoring NaNs and other complications), but addition and subtraction harder. I still can't help feeling you are over-complicating things by your approach, and that this should all be doable by a few lines of code (whether in an HDL or in a software HLL), or by ready-made components. You are not the first person to do a division in an FPGA. But I get the impression that you are restrained by certain requirements, and whether or not they are logical (I've seen projects that ban "software" for "reliability reasons" but are quite happy with FPGA code). Anyway, it's nice to hear you've got it under control. > Multiplies and divides only need to be handled between > numbers in the range of 1.0 to 1.999... Turns out the divide ends > up being very easy. A table lookup gets around 10 bits of accuracy > and one iteration of the Newton-Raphson algorithm gives the full 18 > bits the basic hardware is capable of and more than is needed for the > calculations. Adds/subtractions are a bit more work requiring > denormalization before the sum and renormalization after. In order > to prevent having to deal with negative numbers the two addends are > ordered so a subtraction does not result in a negative mantissa. > > Once the details are worked out floating point is not hard at all and > lends itself to an easy solution to the divide problem as well as the > tracking of scale factor in fixed point math. Someone had suggested > that a 32.32 format fixed point would do the job without floating > point, but it would require a lot more hardware resources and still > not work for every calculation that might be required. One of the > calcs involved squaring a value then applying a coefficient with a > 10^-6 range. I suppose that could be done by taking the square root > of the coefficient, but it's just easier to not have to worry with > how many significant bits are left at the end. With floating point > the main worry is the small result from subtracting large numbers and > I will be able to identify those ahead of time. >
Back to comp.arch.embedded | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Fixed Point Calculations Rick C <gnuarm.deletethisbit@gmail.com> - 2021-01-01 02:18 -0800
Re: Fixed Point Calculations upsidedown@downunder.com - 2021-01-01 13:33 +0200
Re: Fixed Point Calculations Rick C <gnuarm.deletethisbit@gmail.com> - 2021-01-03 01:45 -0800
Re: Fixed Point Calculations Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2021-01-03 12:18 +0200
Re: Fixed Point Calculations Rick C <gnuarm.deletethisbit@gmail.com> - 2021-01-03 05:33 -0800
Re: Fixed Point Calculations upsidedown@downunder.com - 2021-01-03 14:48 +0200
Re: Fixed Point Calculations David Brown <david.brown@hesbynett.no> - 2021-01-03 15:38 +0100
Re: Fixed Point Calculations Rick C <gnuarm.deletethisbit@gmail.com> - 2021-01-03 18:55 -0800
Re: Fixed Point Calculations David Brown <david.brown@hesbynett.no> - 2021-01-04 09:26 +0100
Re: Fixed Point Calculations Rick C <gnuarm.deletethisbit@gmail.com> - 2021-01-17 22:11 -0800
Re: Fixed Point Calculations David Brown <david.brown@hesbynett.no> - 2021-01-18 08:53 +0100
Re: Fixed Point Calculations Rick C <gnuarm.deletethisbit@gmail.com> - 2021-01-18 00:42 -0800
Re: Fixed Point Calculations Anssi Saari <as@sci.fi> - 2021-01-18 22:00 +0200
Re: Fixed Point Calculations Rick C <gnuarm.deletethisbit@gmail.com> - 2021-01-18 13:46 -0800
Re: Fixed Point Calculations upsidedown@downunder.com - 2021-01-19 10:44 +0200
Re: Fixed Point Calculations Rick C <gnuarm.deletethisbit@gmail.com> - 2021-01-19 01:14 -0800
Re: Fixed Point Calculations Anssi Saari <as@sci.fi> - 2021-01-20 09:50 +0200
csiph-web