FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > FPGA

FPGA comp.arch.fpga newsgroup (usenet)

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-18-2009, 06:19 PM
John Speth
Guest
 
Posts: n/a
Default NIOS and ftoa()

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.


Reply With Quote
  #2 (permalink)  
Old 11-18-2009, 06:41 PM
glen herrmannsfeldt
Guest
 
Posts: n/a
Default Re: NIOS and ftoa()

John Speth <[email protected]> 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 would seem easier to write the internal form of the floating
point value and convert it outside.

> 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?


Most embedded work is done in fixed point. One of the slowest parts
of the library for most HLLs is the conversion between floating point
and ASCII representation. It also tends to be big, especially
if it tries to be fast.

As you don't say what your underlying problem is, it is hard to
say much more. It might be that using decimal floating point,
which is much easier to convert, would help.

-- glen
Reply With Quote
  #3 (permalink)  
Old 11-19-2009, 01:00 PM
Adam Górski
Guest
 
Posts: n/a
Default Re: NIOS and ftoa()

John Speth pisze:
> 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.
>
>


Hi John,

Which NIOS version are you using ?
How fast it should be ?
CPU freq ?

Adam
Reply With Quote
  #4 (permalink)  
Old 11-19-2009, 06:00 PM
John Speth
Guest
 
Posts: n/a
Default Re: NIOS and ftoa()

>> 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?


> Which NIOS version are you using ?
> How fast it should be ?
> CPU freq ?


It's Nios2. We selected the standard core but can pick the fast core if
necessary. The core will be clocked at 80 MHz. I need to be able to
convert from float to string in about 25% of the time to process a single
measurement at 10 KHz. That is, 100 usec times 25% or 25 usec.

JJS


Reply With Quote
  #5 (permalink)  
Old 11-19-2009, 06:10 PM
glen herrmannsfeldt
Guest
 
Posts: n/a
Default Re: NIOS and ftoa()

John Speth <[email protected]> wrote:

> It's Nios2. We selected the standard core but can pick the fast core if
> necessary. The core will be clocked at 80 MHz. I need to be able to
> convert from float to string in about 25% of the time to process a single
> measurement at 10 KHz. That is, 100 usec times 25% or 25 usec.


Are all allowable floating point values possible in your case,
or a reduced set? If the set is reduced, it might be that a simple
routine will get out the needed value.

-- glen
Reply With Quote
  #6 (permalink)  
Old 11-20-2009, 03:06 PM
Adam Górski
Guest
 
Posts: n/a
Default Re: NIOS and ftoa()

John Speth pisze:
>>> 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?

>
>> Which NIOS version are you using ?
>> How fast it should be ?
>> CPU freq ?

>
> It's Nios2. We selected the standard core but can pick the fast core if
> necessary. The core will be clocked at 80 MHz. I need to be able to
> convert from float to string in about 25% of the time to process a single
> measurement at 10 KHz. That is, 100 usec times 25% or 25 usec.
>
> JJS
>
>

What kind of output you are using ?
What you are using to measure coputation time ?
Could you put testing code here ?

I can verify your project if you want.

Adam
Reply With Quote
  #7 (permalink)  
Old 11-23-2009, 01:44 AM
Mark McDougall
Guest
 
Posts: n/a
Default Re: NIOS and ftoa()

John Speth wrote:

> Altera has a nice tool called C to HDL compiler which I'm
> looking at now.


Have you considered the custom instruction feature of the NIOS?

Regards,

--
Mark McDougall, Engineer
Virtual Logic Pty Ltd, <http://www.vl.com.au>
21-25 King St, Rockdale, 2216
Ph: +612-9599-3255 Fax: +612-9599-3266
Reply With Quote
  #8 (permalink)  
Old 11-24-2009, 12:16 PM
Michael S
Guest
 
Posts: n/a
Default Re: NIOS and ftoa()

On Nov 18, 7:19 pm, "John Speth" <[email protected]> wrote:
> 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.


It seems your task not just doesn't require floating-point to ASCII
conversion, it needs no floating point at all. I'd go as far as to say
that even if there was fast floating point hardware I'd still prefer
to not use it for that type of task.
Use fix point!
Suppose, you have 14-bit ADC with 3V unipolar scale and you want to
present the result in mV with three digits after decimal point. All
you need to do is something like:

const int ADC_CODE_TO_uV_NUM = int(3E6);
const int ADC_CODE_TO_uV_DEN = 1<<14;
unsigned result_uV = (unsigned)(((long long)result_code *
ADC_CODE_TO_uV_NUM*2 + ADC_CODE_TO_uV_DEN)/(ADC_CODE_TO_uV_DEN*2));
char result_uV_str[32];
int len1 = siprintf(result_uV_str, "%04u", result_uV);
char result_mV_str[32];
memcpy(result_mV_str, result_uV_str, len1 - 3);
result_mV_str[len1 - 3] = '.';
memcpy(&result_mV_str[len1 - 3 + 1], &result_uV_str[len1 - 3], 3);
result_mV_str[len1 + 1] = 0;
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Nios II] How fast the cpu in Nios II can reach in the Cycone ? lexluthor FPGA 3 09-13-2007 03:00 AM
WTB NIOS-II kit Neo FPGA 7 04-03-2005 06:40 AM
Using C++ on NIOS Nigel FPGA 1 09-23-2004 01:51 AM
What does nios-run do? cruzin FPGA 5 01-19-2004 12:23 AM
NIOS and OCI Jerry FPGA 5 09-30-2003 03:54 AM


All times are GMT +1. The time now is 01:02 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved