signed/unsigned v.s. integer 
Author Message
 signed/unsigned v.s. integer

Hi everyone,

I am pretty new to vhdl and trying to guess the differences between
signed/unsigned and integer types.

I have discarded std_logic_signed/std_logic_unsigned and
std_logic_arith as they are not standard. Now, talking about
numeric_std types, what is the difference?. Both support logical and
math operators. So, in the common situation of math-operating two
std_logic_vector, is it really necessary to convert to integer?. For
example, in the most simple case, both

library ieee;
use ieee.numeric_std.all;
....
result<=std_logic_vector(to_unsigned(to_integer(unsigned(data_vector1))
+ to_integer(unsigned(data_vector2)),8));

and

result<=std_logic_vector((unsigned(data_vector1) + unsigned
(data_vector2));

works properly. So, witch is the most correct/efficient approach?

Thanks in advance for your comments.

Javier

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Mon, 28 Apr 2003 03:00:00 GMT  
 signed/unsigned v.s. integer

Quote:

> I have discarded std_logic_signed/std_logic_unsigned and
> std_logic_arith as they are not standard. Now, talking about
> numeric_std types, what is the difference?. Both support logical and
> math operators. So, in the common situation of math-operating two
> std_logic_vector, is it really necessary to convert to integer?. For
> example, in the most simple case, both

> library ieee;
> use ieee.numeric_std.all;
> ....

-------------

--don't forget:
use ieee.std_logic_1164.all;

-------------

Quote:
> result<=std_logic_vector(to_unsigned(to_integer(unsigned(data_vector1))
> + to_integer(unsigned(data_vector2)),8));
> and
> result<=std_logic_vector((unsigned(data_vector1) + unsigned
> (data_vector2));

> work properly.

----pretty cool, isn't it?

Quote:
> So, which is the most correct/efficient approach?

-- I like to declare all logic vectors as unsigned.
-- This would give you:

result <= data_vector1 + data_vector2;

-- you can even do:

result <= data_vector1 + 42;

--    mike.treseler at flukenetworks dot com



Mon, 28 Apr 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. 32-bit signed, unsigned and integers and overflows

2. Signed and Unsigned integers

3. Q: Signed / unsigned integer comparisons

4. unsigned word to signed word in RB

5. Signed/Unsigned Documentation CW2.002

6. signed,unsigned in verilog?!

7. Signed/Unsigned Operations for OVI 2.0

8. Signed and unsigned

9. Signed / Unsigned question.

10. Signed and Unsigned numbers?

11. unsigned ,signed how does it works

12. More signed/unsigned arithmetic craziness

 

 
Powered by phpBB® Forum Software