Skip to content
Snippets Groups Projects
Commit 35be740e authored by Eric Kooistra's avatar Eric Kooistra
Browse files

Added real_to_str().

parent 023789e8
No related branches found
No related tags found
No related merge requests found
...@@ -43,6 +43,7 @@ PACKAGE common_str_pkg IS ...@@ -43,6 +43,7 @@ PACKAGE common_str_pkg IS
Function hex_nibble_to_slv(c: character) return std_logic_vector; Function hex_nibble_to_slv(c: character) return std_logic_vector;
FUNCTION int_to_str(int: INTEGER) RETURN STRING; FUNCTION int_to_str(int: INTEGER) RETURN STRING;
FUNCTION real_to_str(re: REAL; width : INTEGER; digits : INTEGER) RETURN STRING;
PROCEDURE print_str(str : STRING); PROCEDURE print_str(str : STRING);
...@@ -212,6 +213,16 @@ PACKAGE BODY common_str_pkg IS ...@@ -212,6 +213,16 @@ PACKAGE BODY common_str_pkg IS
RETURN v_str; RETURN v_str;
END; END;
FUNCTION real_to_str(re: REAL; width : INTEGER; digits : INTEGER) RETURN STRING IS
VARIABLE v_line: LINE;
VARIABLE v_str: STRING(1 TO width):= (OTHERS => ' ');
BEGIN
STD.TEXTIO.WRITE(v_line, re, right, width, digits);
v_str(v_line.ALL'RANGE) := v_line.ALL;
deallocate(v_line);
RETURN v_str;
END;
PROCEDURE print_str(str: STRING) IS PROCEDURE print_str(str: STRING) IS
VARIABLE v_line: LINE; VARIABLE v_line: LINE;
BEGIN BEGIN
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment