How to find the ABS of std_logic_vector

P

priya

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

Ralf Hildebrandt

priya said:
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
 
A

Andy

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top