hari said:
hi
a) i want to convert a real number to 16 bit signed binary number.
the real number is 2E15-1.so how should i do it.do we have any
default packages for that.
Assuming you mean SIGNED from Numeric_std, you could use
library IEEE;
use IEEE.NUMERIC_STD.all;
....
signal S : SIGNED(15 downto 0)
signal V : STD_LOGIC_VECTOR(15 downto 0);
signal I : INTEGER range -2**15 to 2**15-1;
signal R : real;
....
S <= to_signed(INTEGER(R),16));
If you want to go to std_logic_vector, then
V <= STD_LOGIC_VECTOR(to_signed(INTEGER(R),16)));
If you meant just an integer, then they are closely related so you can
just
do
I <= INTEGER(R);
The conversion rounds.
regards
Alan
--
Alan Fitch
Consultant
DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * Perl * Tcl/Tk * Verification * Project
Services
Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, Hampshire, BH24
1AW, UK
Tel: +44 (0)1425 471223 mail:
(e-mail address removed)
Fax: +44 (0)1425 471573 Web:
http://www.doulos.com
The contents of this message may contain personal views which are not
the
views of Doulos Ltd., unless specifically stated.