On Jun 3, 5:44*am, laserbeak43 <laserbea...@gmail.com> wrote:
> subtype digit is integer range 0 to 9;
> Is it possible to convert
> this type to unsigned? when i do it, i get errors.
>
> signal h1 * * * : digit;
> signal hv1 * * *: unsigned(3 downto 0);
> hv1 <= unsigned(h1); *--Error
You're just using the name of the new type (unsigned)
as if it were a function. That's not really a function;
it's a "type conversion", which works only between
closely related types. For example:
- REAL and any INTEGER subtype are closely related,
because they are simple numeric types
- STD_LOGIC_VECTOR and UNSIGNED are closely related,
because they are both arrays of STD_LOGIC indexed
by INTEGER
But INTEGER and UNSIGNED are not closely related, so
you need a conversion function:
hvl = to_unsigned(hl, hvl'length);
If you get an error for this line, it's because you
are a Very Bad Person and are using std_logic_arith.
Switch to numeric_std before we get angry with you

--
Jonathan Bromley