Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - Convert Real number to Std_logic_vector

 
Thread Tools Search this Thread
Old 02-03-2007, 10:19 AM   #1
Default Convert Real number to Std_logic_vector


Hi

I Have 2 constant values nu= 3.131764231e-3
and v = 0.993736471

Later on in my VHDL code I have to multiply these with two values
which are std_logic_vectors of 20bits. So I would like to convert
these constants to vectors of 20 bits without losing precision.How
could I do so in VHDL

tried to do conv_std_logic_vector(nu,20); unfortunately it didnt work!

Please if anyone could help me I would be grateful

Thanks

Sudsy



Sudhir
  Reply With Quote
Old 02-03-2007, 05:36 PM   #2
KJ
 
Posts: n/a
Default Re: Convert Real number to Std_logic_vector

"Sudhir" <> wrote in message
news: oups.com...
> Hi
>
> I Have 2 constant values nu= 3.131764231e-3
> and v = 0.993736471
>
> Later on in my VHDL code I have to multiply these with two values
> which are std_logic_vectors of 20bits. So I would like to convert
> these constants to vectors of 20 bits without losing precision.How
> could I do so in VHDL

You can't. The real numbers are represented with more than 20 bits of
precision so converting them to 20 std_logic_vectors will result in lost
precision.

>
> tried to do conv_std_logic_vector(nu,20); unfortunately it didnt work!

Because you can't convert a real to a std_logic_vector using this function.

>
> Please if anyone could help me I would be grateful
>

Convert the std_logic_vectors into real numbers and keep the full precision
of your calculation.

Also since your attempt used the 'conv_std_logic_vector' this implies that
you're using the 'ieee.std_logic_arith' package. This package is not a
standard and really should not be used. Use the ieee.numeric_std package
instead and you'll save yourself some headaches down the road.

Kevin Jennings




KJ
  Reply With Quote
Old 03-10-2007, 05:18 PM   #3
David Bishop
 
Posts: n/a
Default Re: Convert Real number to Std_logic_vector
Sudhir wrote:
> Hi
>
> I Have 2 constant values nu= 3.131764231e-3
> and v = 0.993736471
>
> Later on in my VHDL code I have to multiply these with two values
> which are std_logic_vectors of 20bits. So I would like to convert
> these constants to vectors of 20 bits without losing precision.How
> could I do so in VHDL
>
> tried to do conv_std_logic_vector(nu,20); unfortunately it didnt work!
>
> Please if anyone could help me I would be grateful


First off, these are real numbers. Real numbers don't synthesize.
Internally they are represented as 64 bit floating point numbers.

I would recommend using fixed point. Then you can convert the numbers
into something synthesizable.

http://www.vhdl.org/vhdl-200x/vhdl-2...ges/files.html
For the documentation.

For code to synthesize, look at:
http://www.vhdl.org/fphdl/vhdl.html


David Bishop
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Rip DVD and Convert Video on Mac OS dave345 Media 12 07-07-2008 09:32 AM
How to easily convert real video to wmv files? Norm DVD Video 2 05-22-2007 10:03 AM
How to convert Real Audio *.rm files to mp3 for free? kopn@hotbox.ru DVD Video 12 07-13-2006 06:44 AM
New Releases: Troy, Ultimate Matrix & status changes: Updated complete downloadable R1 DVD DB & info lists Doug MacLean DVD Video 1 08-31-2004 01:02 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46