Fixed-point math support in gcc

Go To Last Post
14 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've gladly found that avr-gcc from Atmel provided toolchain is compiled with fixed point arithmetic, so I can use different _Fract and _Accum types. I've checked some basic math and it works ok. But I can't find strtoXX and xxtostr functions, k and r in printf are not supported either (xx is appropriate fixed-point type). Do you know any Atmel note describing their fixed-point implementation? And where I can find the toolchain sources?
Another thing is fixed-point support in gcc 4.5.x. I was unable to compile gcc 4.5.1 with fixed point support enabled for AVR platform, so Atmel must use some specific patches, that's why I'm looking for their sources "“ I want to try patch gcc 4.5.1 to see if it will compile with "“-enable-fixed-point.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The fixed point implementation is most likely the one done by AVRfreaks member 'geckosenator'. It was discussed here a year or two ago, and IIRC it was not complete, and it seems that it made it into AVR Toolchain in that state. geckosenator is not very active here so you should be able to find the threads reasonably easy.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, I’ve found the original topic, and I think Atmel uses his implementation. But with possible improvements. Do you know where I can find sources of Atmel toolchain? I can’t find a reference on their webpage.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are you using WinAVR or "AVR Toolchain"? Right now, they are distinctly different and AVR Toolchain is reported as "not ready for prime time".

Technically, "Atmel" does not use the implementation. AVR-gcc uses the implementation (created by volunteers generally not Atmel employees) and Atmel uses AVR-gcc.

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

He said

Quote:

Atmel provided toolchain

Also, WinAVR20100110 (latest) does not have the fixed point stuff.

But yes, your point holds, Jim. There has been flaws reported for some quite basic stuff like the timed delay functions (_delay_ms() and/or _delay_us()).

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The problem with delay functions is connected with AVR-libc (see the bugreports), not the Atmel's compiler itself.
But do you know where I can find sources of Atmel's toolchain? I think that they should provide the sources as gcc is under GPL license.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I expect they will when it is released.

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ka7ehk wrote:
I expect they will when it is released.
The toolchain is released (what the GPL considers distribution, propagation, or conveyance)

http://distribute.atmel.no/tools...

Atmel would have to provide the source code now. I won't be surprised if they, like so many companies, think they don't have to care and can do things on their own terms.

Stealing Proteus doesn't make you an engineer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

--enable-fixed-point won't suffice. corresponding machine modes must be supported, at least their mov insns.

Just as with floats in dp-bit.c/fp-bit.c, fixed support comes with a support library, fixed-bit.c or something like that. Look in directory gcc/config where dp-bit.c is located.

I cannot say anything about atmel stuff. in general, patches applied against the compiler are shipped in ./source/avr/gcc.

Is there an ABI or EABI specification that clarifies how IEC/DTR18037 shall be implemented for avr?

avrfreaks does not support Opera. Profile inactive.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ironically I stumbled across this thread when trying to find more information about the fixed point patch at http://distribute.atmel.no/tools... . Fixed point support added in 30-gcc-4.4.3-fixedpoint-3-4-2010.patch - I haven't compared this to geckosenator's patches contributed in another thread. From the release notes of toolchain 3.1.0 on betaware: "Fixed Point Math Support
Release 3.0.0 adds preliminary support for fixed point arithmetic. This is not supported for all the devices and not
all the gcc fixed point constructs are supported fully yet.
"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is fixed point used in other apps. besides DSP ?

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

indianajones11 wrote:
Is fixed point used in other apps. besides DSP ?
Guidance/Navigation/Control - one application I worked on though did use floating point for one computation (not in an inner loop; due to easy-to-implement need for more than 32-bits of precision).

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Is fixed point used in other apps. besides DSP ?

Oh, you kids. It was often used in financial work and similar. (Still is?) COBOL forever. Remember that the Burroughs Medium-Systems class mainframes >>were<< "fixed point" processors.
http://en.wikipedia.org/wiki/Bur...

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Any app you like. When there is need, I do it all the time in regular C code without any mythical fixed point libraries.

All fixed point means is that for instance in integers value 1 means 1, and in float 1.000 still means 1. In fixed point, you can just scale numbers and for example make integer value of 1000 to mean 1.000 if you scale with 10-base decimals or 1024 to mean 1.000 if you scale with 2-base binary numbers.

Scaling with binary numbers means easier scaling as you can just shift bits instead of division/multiply.