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

Reply

VHDL - How to find the ABS of std_logic_vector

 
Thread Tools Search this Thread
Old 11-21-2006, 11:48 AM   #1
Default How to find the ABS of std_logic_vector


hi
ABS function which is specified for integer type in VHDL
for slv data type
how to find the absolute value
reply back soon



priya
  Reply With Quote
Old 11-21-2006, 03:55 PM   #2
Ajeetha
 
Posts: n/a
Default Re: How to find the ABS of std_logic_vector

How about:

abs(to_integer(unsigned(my_slv)));


Use ieee.numeric_std package

Try it out and let me know if it works

Ajeetha, CVC
www.noveldv.com

priya wrote:
> hi
> ABS function which is specified for integer type in VHDL
> for slv data type
> how to find the absolute value
> reply back soon


  Reply With Quote
Old 11-21-2006, 04:25 PM   #3
Ralf Hildebrandt
 
Posts: n/a
Default Re: How to find the ABS of std_logic_vector

priya schrieb:

> ABS function which is specified for integer type in VHDL
> for slv data type
> how to find the absolute value



No one knows, if your std_(u)logic_vector is signed or not. Therefore
there is no such function.

my_abs<=abs( signed(my_stdlogicvector) ); -- using IEEE.numeric_std

Ralf
  Reply With Quote
Old 11-21-2006, 04:35 PM   #4
Andy
 
Posts: n/a
Default Re: How to find the ABS of std_logic_vector

I'm assuming the OP wants an SLV back, so:

my_abs <= std_logic_vector(abs(signed(my_slv)));

Or just use constrained integers or numeric-std.signed/unsigned instead
of slv for the data in the first place, and no conversions would be
necessary.

Andy


Ralf Hildebrandt wrote:
> priya schrieb:
>
> > ABS function which is specified for integer type in VHDL
> > for slv data type
> > how to find the absolute value

>
>
> No one knows, if your std_(u)logic_vector is signed or not. Therefore
> there is no such function.
>
> my_abs<=abs( signed(my_stdlogicvector) ); -- using IEEE.numeric_std
>
> Ralf


  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
Forum Jump