Line 15... |
Line 15... |
---- ----
|
---- ----
|
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
---- SVN information
|
---- SVN information
|
----
|
----
|
---- $URL: file:///svn/vhdl_wb_tb/vhdl_wb_tb/trunk/rtl/vhdl/packages/convert_pkg.vhd $
|
---- $URL: file:///svn/vhdl_wb_tb/vhdl_wb_tb/trunk/rtl/vhdl/packages/convert_pkg.vhd $
|
---- $Revision: 14 $
|
---- $Revision: 17 $
|
---- $Date: 2018-07-22 16:27:41 +0200 (Sun, 22 Jul 2018) $
|
---- $Date: 2018-07-22 23:07:08 +0200 (Sun, 22 Jul 2018) $
|
---- $Author: sinx $
|
---- $Author: sinx $
|
---- $Id: convert_pkg.vhd 14 2018-07-22 14:27:41Z sinx $
|
---- $Id: convert_pkg.vhd 17 2018-07-22 21:07:08Z sinx $
|
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
---- ----
|
---- ----
|
---- Copyright (C) 2018 Authors and OPENCORES.ORG ----
|
---- Copyright (C) 2018 Authors and OPENCORES.ORG ----
|
---- ----
|
---- ----
|
---- This source file may be used and distributed without ----
|
---- This source file may be used and distributed without ----
|
Line 56... |
Line 56... |
PACKAGE convert_pkg IS
|
PACKAGE convert_pkg IS
|
|
|
FUNCTION to_std_logic_vector(input : integer; length : integer) RETURN std_logic_vector;
|
FUNCTION to_std_logic_vector(input : integer; length : integer) RETURN std_logic_vector;
|
|
|
FUNCTION to_integer(input : std_logic_vector) RETURN integer;
|
FUNCTION to_integer(input : std_logic_vector) RETURN integer;
|
FUNCTION to_string(int : integer; base : integer := 10; length : integer := 0) RETURN string;
|
FUNCTION to_string(int : integer; base : integer range 1 to 16 := 16; length : integer range 1 to 8:= 8) RETURN string;
|
FUNCTION to_string(slv : std_logic_vector; base : integer; length : integer) RETURN string;
|
FUNCTION to_string(slv : std_logic_vector; base : integer range 1 to 16 := 16; length : integer range 1 to 8 := 8) RETURN string;
|
|
|
END convert_pkg;
|
END convert_pkg;
|
|
|
-- package body ------------------------------------------------------
|
-- package body ------------------------------------------------------
|
PACKAGE BODY convert_pkg IS
|
PACKAGE BODY convert_pkg IS
|
Line 119... |
Line 119... |
WHEN OTHERS => c := '?';
|
WHEN OTHERS => c := '?';
|
END CASE;
|
END CASE;
|
RETURN c;
|
RETURN c;
|
END to_char;
|
END to_char;
|
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
FUNCTION to_string(int : integer; base : integer := 10; length : integer := 0) RETURN string IS
|
FUNCTION to_string(int : integer;
|
|
base : integer range 1 to 16 := 16;
|
|
length : integer range 1 to 8 := 8
|
|
) RETURN string IS
|
|
|
VARIABLE temp : string(1 TO 1000);
|
VARIABLE temp : string(1 TO 1000);
|
VARIABLE num : integer;
|
VARIABLE num : integer;
|
VARIABLE abs_int : integer;
|
VARIABLE abs_int : integer;
|
VARIABLE len : integer := 1;
|
VARIABLE len : integer := 1;
|
Line 250... |
Line 253... |
END CASE;
|
END CASE;
|
END LOOP;
|
END LOOP;
|
RETURN hex(1 TO hexlen);
|
RETURN hex(1 TO hexlen);
|
END to_string;
|
END to_string;
|
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
FUNCTION to_string(slv : std_logic_vector; base : integer; length : integer) RETURN string IS
|
FUNCTION to_string( slv : std_logic_vector;
|
|
base : integer range 1 to 16 := 16;
|
|
length : integer range 1 to 8 := 8
|
|
) RETURN string IS
|
|
|
BEGIN
|
BEGIN
|
RETURN to_string(to_integer(slv), base, length);
|
RETURN to_string(to_integer(slv), base, length);
|
END to_string;
|
END to_string;
|
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|