Conversion for different packages

Status
Not open for further replies.

Binome

Full Member level 3
Joined
Nov 16, 2009
Messages
152
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Location
Lyon, France
Activity points
2,405
Hi,
I'm using : R<= unsigned(ext(A, N)) + unsigned(ext(B,N));
with ieee.std_logic_arith library.A, B, and R are std_logic_vector.
Now I know it's not a recommended library I want to use numeric_std. ext() is not known so I have to use another function. I'm trying to use to_unsigned like that:
R<= std_logic_vector(to_unsigned(unsigned(A), N) + to_unsigned(unsigned(B),N));
But Modelsim can't compile, the error is "No feasible entries for subprogram "TO_UNSIGNED"."
Can someone tell me why?
 

I assume you have declared to use the library numeric_std?

use ieee.numeric_std.all;
 

converting A and B to unsigned is fine, but there is no to_unsigned function for an unsigned type, thats only for integers. You're after the resize function:

R < std_logic_vector(resize(unsigned(A), N) + resize(unsigned(B), N));
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…