Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   VHDL (http://www.velocityreviews.com/forums/f18-vhdl.html)
-   -   converting floating point to fixed point (http://www.velocityreviews.com/forums/t56042-converting-floating-point-to-fixed-point.html)

 H aka N 02-28-2006 04:54 PM

converting floating point to fixed point

Hi,

I need to convert floating point inputs (32 bits) to fixed point (11
bits for integer and 10 bits for the fraction) representation in a
synthesizable way. I would be more than grateful if someone could show
me the way.

I need to do this without using any special tools or such. Just pure
VHDL.

Best

 jens 02-28-2006 08:14 PM

Re: converting floating point to fixed point

The first step is to define your requirements. Some questions you may
want to ask yourself (or whoever assigned this to you):

1. What is the format of the floating point number?
2. What should happen when the floating point number exceeds the bounds
of the fixed point number?
3. Since a lot of resolution is bound to be lost, what is gained by
doing this conversion?

 Mike Treseler 02-28-2006 09:09 PM

Re: converting floating point to fixed point

H aka N wrote:

> I need to convert floating point inputs (32 bits) to fixed point

-- Mike Treseler

 Isaac Bosompem 02-28-2006 10:51 PM

Re: converting floating point to fixed point

H aka N wrote:
> Hi,
>
> I need to convert floating point inputs (32 bits) to fixed point (11
> bits for integer and 10 bits for the fraction) representation in a
> synthesizable way. I would be more than grateful if someone could show
> me the way.
>
> I need to do this without using any special tools or such. Just pure
> VHDL.
>
> Best

I answered this question to someone a while ago in comp.lang.verilog.
Search in there.

 H aka N 03-01-2006 08:54 AM

Re: converting floating point to fixed point

Dear Isaac,

answer in comp.lang.verilog though I found some might be useful
answers. But even so I would be really grateful if you could dig out

Best

H aka N

Isaac Bosompem wrote:
> H aka N wrote:
> > Hi,
> >
> > I need to convert floating point inputs (32 bits) to fixed point (11
> > bits for integer and 10 bits for the fraction) representation in a
> > synthesizable way. I would be more than grateful if someone could show
> > me the way.
> >
> > I need to do this without using any special tools or such. Just pure
> > VHDL.
> >
> > Best

>
> I answered this question to someone a while ago in comp.lang.verilog.
> Search in there.

 H aka N 03-01-2006 08:58 AM

Re: converting floating point to fixed point

Dear Mike,

thanks a million for the link, but I cannot say that I found anything
useful here. I had done a similar search before.

I cannot use the vhdl-200x floating point and fixed point packages as I
am using XST and it (at least version 6.3) complains about negative
indexes, and there isn't much that can be done about it.

Best regards.

H aka N

 H aka N 03-01-2006 09:03 AM

Re: converting floating point to fixed point

Dear Jens,

thanks for your time and trouble taken for writing the message.

1. 11 bits for integer part and 10 bits for the fractional part.
2. It will be clipped.. (There is a step in the logic where the
exceeding floating numbers will be clipped to the bounds of the fixed
number, so nothing to be worried about here)
3. The resolution needed is well below the 10 bits reserved for the
fractional part. I just cannot help that my inputs need to be floating
point (32 bits)..

Best,

H aka N

 Mike Treseler 03-01-2006 02:53 PM

Re: converting floating point to fixed point

H aka N wrote:

> I cannot use the vhdl-200x floating point and fixed point packages as I
> am using XST and it (at least version 6.3) complains about negative
> indexes, and there isn't much that can be done about it.

All the source code is there.
It is probably easier to rewrite the function with
natural indexes than it is to start from scratch.

Or try Quartus. It sticks to the standards better than XST.

Or start a case with Xilinx. Are you using the latest XST version?

-- Mike Treseler

 Isaac Bosompem 03-01-2006 05:33 PM

Re: converting floating point to fixed point

H aka N wrote:
> Dear Isaac,
>
> many thanks for your reply, but unfortunately I couldn't find your
> answer in comp.lang.verilog though I found some might be useful
> answers. But even so I would be really grateful if you could dig out
>
> Best
>
> H aka N
>
> Isaac Bosompem wrote:
> > H aka N wrote:
> > > Hi,
> > >
> > > I need to convert floating point inputs (32 bits) to fixed point (11
> > > bits for integer and 10 bits for the fraction) representation in a
> > > synthesizable way. I would be more than grateful if someone could show
> > > me the way.
> > >
> > > I need to do this without using any special tools or such. Just pure
> > > VHDL.
> > >
> > > Best

> >
> > I answered this question to someone a while ago in comp.lang.verilog.
> > Search in there.

is here:

If you have any questions after reading it post them here.

 jens 03-01-2006 05:40 PM

Re: converting floating point to fixed point

If you're not concerned about range checking or resolution, it becomes
quite simple... just shift the floating point number's mantissa left or
right, based on the floating point number's exponent and where the
decimal point needs to end up.

You haven't mentioned the format of the floating point number, so the
sizes of the mantissa/exponent and whether it's signed or unsigned will
need to be taken into account.

Doing it yourself might be easier than trying to modify the IEEE
libraries to work with XST.

All times are GMT. The time now is 03:42 PM.