Hi,
I defined an enumeration type ("reg") in a package header:
1 | LIBRARY ieee;
|
2 | USE ieee.std_logic_1164.all;
|
3 | USE ieee.std_logic_arith.all;
|
4 | ...
|
...
1 | type reg is (R0, R1, R2, R3);
|
...and a conversion function which converts type "std_logic_vector" to
my type "reg":
1 | function CONVTOREG (DATA :std_logic_vector) return reg;
|
In the body of the package I have the corresponding implementation of
this conversion function:
1 | function CONVTOREG (DATA :std_logic_vector) return reg IS
|
2 | variable result :integer;
|
3 | begin
|
4 | result := CONV_INTEGER(unsigned(DATA));
|
5 | return reg'VAL(result);
|
6 | end function;
|
This works fine. Now I need another conversion function which converts
the type "reg" back to std_logic_vector" which is declared like this:
1 | function CONV_REG_TO_STDLV (DATA :reg) return std_logic_vector;
|
But I don't know how to implement that since there is no type conversion
which accepts my enumeration type. Has anybody an idea how to do that?
Thanks a lot!
Best regards.
M.R.