Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > How to find the ABS of std_logic_vector

Reply
Thread Tools

How to find the ABS of std_logic_vector

 
 
priya
Guest
Posts: n/a
 
      11-21-2006
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
 
 
 
 
Ajeetha
Guest
Posts: n/a
 
      11-21-2006
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
 
 
 
 
Ralf Hildebrandt
Guest
Posts: n/a
 
      11-21-2006
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
 
Andy
Guest
Posts: n/a
 
      11-21-2006
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

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
inout std_logic_vector to array of std_logic_vector of generic length conversion... Thomas Rouam VHDL 6 11-09-2007 11:49 AM
f2c's abs conflicts with <complex> abs Klaas Vantournhout C++ 3 10-31-2006 10:07 PM
ABS Stealth Computer Case @ A True Review Silverstrand Front Page News 0 12-01-2005 01:23 AM
Math.abs markelmel@yahoo.com Java 37 11-14-2005 03:45 PM



Advertisments