I am new in this field. I have a problem with conversion of std logic input into real values. I have been using to_float
function but it always showed error. When I used package float_generic_pkg
, it showed error:
Cannot find in library .
I also tried creating new library ieee_proposed
but still it showed error.
I tried using IEEE.numeric_std.all
, too.
Again it gave error <to_real>
not declared.
Do I need to use some other library package?
I am using ISE Design Suite 14.7.
One thing more: its for synthsis too. Please help me.
Here is the code :
library ieee;
use ieee.std_logic_1164.all;
use ieee.float_pkg.all;
use ieee.float_generic_pkg.all;
entity dafsm is
port (x : in std_logic_vector (1 downto 0);
y : out std_logic_vector (1 downto 0));
end dafsm;
architecture fpga of dafsm is
signal r,s : real range 0.0 to 15.0;
begin
r <= to_float(x);
s <= r * 0.5;
y <= to_slv(s);
end fpga;
The error messages:
Line 4: Cannot find <float_pkg> in library <ieee>. Please ensure that the library was compiled, and that a library and a use clause are present in the VHDL file.
Line 5: Cannot find <float_generic_pkg> in library <ieee>. Please ensure that the library was compiled, and that a library and a use clause are present in the VHDL file.
Line 12: <real> is not declared.
Line 14: <r> is not declared.
Line 15: <s> is not declared.
Line 16: <y> is not declared.
Best Answer
I made some changes to your code. The changes will be explained below.
This analyzed, elaborated and simulated.
The changes:
You carefully scrubbed any vendor identifying information from your error messages and I don't have their implementations any way, I used ghdl.
I first compiled the sources in a directory named ieee_proposed to create a library ieee_proposed:
We don't need all these to demonstrate your code, but there your are.
Then analyzed, elaborated and simulated your code:
There are two outputs because there is an initialization event on
s
befores
is assignedr * 0.5
. Note I made the monitor process sensitive tos
because y is an output and can't appear in a process sensitivity list. I recreated the the valuey
will have assigned.The second is the result, 15 in hex is 21 decimal.
The -P./ieee_proposed tells ghdl to look in the current directory for a subdirectory library ieee_proposed (the name of the directory is the same as the library). I could have placed it in ghdl's library search path, it seemed unnecessary for this demonstration.
Other tools usage may vary.
David Bishop assures us this should be synthesis eligible. I haven't tried myself.
Please avail yourself of the documentation on the above web page.