From: John Speth on 18 Nov 2009 12:20 Hi folks- I'm in the beginning stages of crafting a high-speed measurement device which needs to output a floating point value in ASCII string form that represents the measurement at a rate of 10 kHz. I'm using an Altera FPGA that runs Nios2. Convenient standard library functions like sprintf() or ftoa() running as code will be too time-consuming to meet my high throughput requirements. What I need is an ultrafast float to ASCII conversion function that can run in code *or* a strategy for implementing a conversion function in HDL. Altera has a nice tool called C to HDL compiler which I'm looking at now. It seems to me that a fast float to ASCII conversion function would be a common function of many embedded systems. Rather than me reinventing the wheel, can anyone point me to a resource (example on the web or a product for sale) that I can use to achieve my goal? Thanks, John Speth.
From: Andrew Jackson on 18 Nov 2009 12:43 > I'm in the beginning stages of crafting a high-speed measurement device > which needs to output a floating point value in ASCII string form that > represents the measurement at a rate of 10 kHz. I'm using an Altera FPGA > that runs Nios2. Convenient standard library functions like sprintf() or > ftoa() running as code will be too time-consuming to meet my high throughput > requirements. What I need is an ultrafast float to ASCII conversion > function that can run in code *or* a strategy for implementing a conversion > function in HDL. Altera has a nice tool called C to HDL compiler which I'm > looking at now. > > It seems to me that a fast float to ASCII conversion function would be a > common function of many embedded systems. Rather than me reinventing the > wheel, can anyone point me to a resource (example on the web or a product > for sale) that I can use to achieve my goal? I've always avoided trying to do any sort of conversion in an embedded system /because/ it tends to be slow. Also there are other difficulties with things like ftoa in that they (and other library routines) often use static buffers. Do you have to output the number as floating point? Could you consider outputting it as hexadecimal and conversion to floating point subsequently? Do you have to output at 10kHz? Could you consider outputting at a lower rate or is the output device actually storing it? (I personally can't read characters at 10kHz!) This begs the question where or to what is this output going? Andrew
From: D Yuniskis on 18 Nov 2009 14:05 John Speth wrote: > I'm in the beginning stages of crafting a high-speed measurement device > which needs to output a floating point value in ASCII string form that > represents the measurement at a rate of 10 kHz. I'm using an Altera FPGA > that runs Nios2. Convenient standard library functions like sprintf() or > ftoa() running as code will be too time-consuming to meet my high throughput > requirements. What I need is an ultrafast float to ASCII conversion > function that can run in code *or* a strategy for implementing a conversion > function in HDL. Altera has a nice tool called C to HDL compiler which I'm > looking at now. What is the source of your data? Surely (?) your "sensor" isn't generating floating point data?? I.e., can you deal with the data in some other form that is more readily converted to ASCII? (e.g., if you have to manipulate the data somehow before "output", use decimal math -- this is trivial to implement unless you start getting into the transcendental functions, etc.) > It seems to me that a fast float to ASCII conversion function would be a > common function of many embedded systems. Rather than me reinventing the > wheel, can anyone point me to a resource (example on the web or a product > for sale) that I can use to achieve my goal?
From: Jon Kirwan on 18 Nov 2009 14:20 On Wed, 18 Nov 2009 09:20:39 -0800, "John Speth" <johnspeth(a)yahoo.com> wrote: >I'm in the beginning stages of crafting a high-speed measurement device >which needs to output a floating point value in ASCII string form that >represents the measurement at a rate of 10 kHz. I'm using an Altera FPGA >that runs Nios2. Convenient standard library functions like sprintf() or >ftoa() running as code will be too time-consuming to meet my high throughput >requirements. What I need is an ultrafast float to ASCII conversion >function that can run in code *or* a strategy for implementing a conversion >function in HDL. Altera has a nice tool called C to HDL compiler which I'm >looking at now. > >It seems to me that a fast float to ASCII conversion function would be a >common function of many embedded systems. Rather than me reinventing the >wheel, can anyone point me to a resource (example on the web or a product >for sale) that I can use to achieve my goal? You are probably in far better position than most to know what features characterize your values. What is their dynamic range and magnitude, for example? How many ASCII characters will suffice? Is a radix point required? A sign? A highly generic library routine is not going to be as fast as one that takes into acount a priori information you know about your values. It's helpful to start by carefully delineating your boundary conditions. (Unless your values can truly span the entire dynamic range of the floating point representation itself. And if so, then I would wonder about just how serious you are there, such as denormals, NaNs, INFs, and so on.) Jon
From: Grant Edwards on 18 Nov 2009 15:04
On 2009-11-18, D Yuniskis <not.going.to.be(a)seen.com> wrote: > John Speth wrote: >> I'm in the beginning stages of crafting a high-speed measurement device >> which needs to output a floating point value in ASCII string form that >> represents the measurement at a rate of 10 kHz. I'm using an Altera FPGA >> that runs Nios2. Convenient standard library functions like sprintf() or >> ftoa() running as code will be too time-consuming to meet my high throughput >> requirements. What I need is an ultrafast float to ASCII conversion >> function that can run in code *or* a strategy for implementing a conversion >> function in HDL. Altera has a nice tool called C to HDL compiler which I'm >> looking at now. > > What is the source of your data? Surely (?) your "sensor" > isn't generating floating point data?? Even if it is generating floating point (we'll assume IEEE 754 format), just output the IEEE fp value in binary (or ASCII-hex) rather than attempting to convert it to base-10 floating point in ASCII. > I.e., can you deal with the data in some other form that is > more readily converted to ASCII? (e.g., if you have to > manipulate the data somehow before "output", use decimal math > -- this is trivial to implement unless you start getting into > the transcendental functions, etc.) > >> It seems to me that a fast float to ASCII conversion function >> would be a common function of many embedded systems. Nope. Reduce/process/buffer the data _then_ convert it to human-readible ASCII form. >> Rather than me reinventing the wheel, can anyone point me to a >> resource (example on the web or a product for sale) that I can >> use to achieve my goal? -- Grant Edwards grante Yow! Should I do my BOBBIE at VINTON medley? visi.com |