![]() |
|
|
|||||||
![]() |
VHDL - Converting logic_vector -> natural |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
Hi
I want to convert vect(3 downto 0) into natural digit is there any standard conversion procedure/function in vhdl for that?? Paul magik |
|
|
|
|
#2 |
|
Posts: n/a
|
magik wrote:
> Hi > > I want to convert vect(3 downto 0) into natural digit > > is there any standard conversion procedure/function in vhdl for that?? use ieee.numeric_std.all; ..... variable natvar : natural; variable vect : std_logic_vector (3 downto 0); ...... natvar := to_integer(unsigned(vect)); David Bishop |
|
|
|
#3 |
|
Posts: n/a
|
thanx!!
I used conv_integer from std_logic_unsigned and the result is the same Uzytkownik "David Bishop" <> napisal w wiadomosci news:HJxve.54606$... > magik wrote: > >> Hi >> >> I want to convert vect(3 downto 0) into natural digit >> >> is there any standard conversion procedure/function in vhdl for that?? > > use ieee.numeric_std.all; > > .... > variable natvar : natural; > variable vect : std_logic_vector (3 downto 0); > ..... > > natvar := to_integer(unsigned(vect)); > magik |
|
|
|
#4 |
|
Posts: n/a
|
magik wrote:
> I used conv_integer from std_logic_unsigned and the result is the same Don't do it. First this library is /not/ a standard library. Your code is not protable. Second you always assume /unsigned/ numbers in the vector. It is much better to treat std_(u)logic_vectors neighter as signed nor as unsigned number in general and to choose it using the conversion unsigned() or signed() dependend on the context. O.k. - for your conversion to natural, which cover non-negative integers there is no problem, but a conversion to integer would never lead to negative numbers. Ralf Ralf Hildebrandt |
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help - Method for converting float to double | mcvishnuprasad | The Lounge | 2 | 07-24-2008 02:00 PM |
| Problems converting avi to DVD using WinAVI Help!! | KIMOSABE | DVD Video | 4 | 01-04-2007 08:58 PM |
| DVD Verdict reviews: NATURAL CITY, UNO BIANCA, GODZILLA: MONSTER EDITION, and more! | DVD Verdict | DVD Video | 0 | 04-27-2006 09:21 AM |
| Converting HD to Divx or Wmv HD how ??? | No One Realy | DVD Video | 0 | 09-13-2005 06:22 PM |
| HD-DVD and DVD's future | Phil Riker | DVD Video | 68 | 09-28-2003 09:32 PM |