VICON: Sistema de Visión configurable V1.0
Trabajo Fin de Master Carlos Manuel Gomez Jimenez
Loading...
Searching...
No Matches
sim_utils_pkg Package Body Reference
Package Body >> sim_utils_pkg

Functions

string   vec_to_str ( vec: in std_logic_vector )
string   int_to_hex_str ( val: in integer , width: in integer 2 )

Procedures

  log_to_file(
constant file_name: in string
constant message: in string
constant is_error: in boolean false
)
  check_value(
constant actual: in std_logic_vector
constant expected: in std_logic_vector
constant msg_tag: in string
variable error_cnt: inout integer
constant file_name: in string " reporte_final_1.txt "
)

Detailed Description

Definition at line 33 of file sim_utils_pkg.vhd.

Member Function/Procedure/Process Documentation

◆ check_value()

check_value ( constant actual in std_logic_vector ,
constant expected in std_logic_vector ,
constant msg_tag in string ,
variable error_cnt inout integer ,
constant file_name in string "reporte_final_1.txt"  )

Definition at line 78 of file sim_utils_pkg.vhd.

78"reporte_final_1.txt" procedure check_value(
79 constant actual : in std_logic_vector;
80 constant expected : in std_logic_vector;
81 constant msg_tag : in string;
82 variable error_cnt : inout integer;
83 constant file_name : in string :=
84 ) is
85 begin
86 if (actual = expected) then
87 log_to_file(file_name, msg_tag & " OK | Val: " & vec_to_str(actual), false);
88 report "[SIM] " & msg_tag & " OK";
89 else
90 error_cnt := error_cnt + 1;
91 log_to_file(file_name, msg_tag & " FALLO | Exp: " & vec_to_str(expected) & " Act: " & vec_to_str(actual), true);
92 report "[SIM] " & msg_tag & " FAIL" severity error;
93 end if;
94 end procedure;
check_valueactual,expected,msg_tag,error_cnt,file_name,

◆ int_to_hex_str()

string int_to_hex_str ( val in integer ,
width in integer 2  )

Definition at line 47 of file sim_utils_pkg.vhd.

47 function int_to_hex_str(val : integer; width : integer := 2) return string is
48 variable temp : std_logic_vector((width * 4) - 1 downto 0);
49 constant hex_chars : string(1 to 16) := "0123456789ABCDEF";
50 variable res : string(1 to width);
51 variable nibble : integer;
52 begin
53 temp := std_logic_vector(to_unsigned(val, width * 4));
54 for i in 0 to width-1 loop
55 nibble := to_integer(unsigned(temp((i+1)*4-1 downto i*4)));
56 res(width-i) := hex_chars(nibble + 1);
57 end loop;
58 return res;
59 end function;
string int_to_hex_strval,width,

◆ log_to_file()

log_to_file ( constant file_name in string ,
constant message in string ,
constant is_error in boolean false  )

Definition at line 61 of file sim_utils_pkg.vhd.

61 procedure log_to_file(
62 constant file_name : in string;
63 constant message : in string;
64 constant is_error : in boolean := false
65 ) is
66 file f : text;
67 variable l : line;
68 variable prefix : string(1 to 7);
69 begin
70 if is_error then prefix := "ERROR :"; else prefix := "INFO :"; end if;
71
72 file_open(f, file_name, append_mode);
73 write(l, "[" & time'image(now) & "] - " & prefix & " " & message);
74 writeline(f, l);
75 file_close(f);
76 end procedure;
log_to_filefile_name,message,is_error,

◆ vec_to_str()

string vec_to_str ( vec in std_logic_vector  )

Definition at line 35 of file sim_utils_pkg.vhd.

35 function vec_to_str(vec : std_logic_vector) return string is
36 variable res : string(1 to vec'length);
37 begin
38 for i in 0 to vec'length-1 loop
39 if vec(vec'high-i) = '1' then res(i+1) := '1';
40 elsif vec(vec'high-i) = '0' then res(i+1) := '0';
41 else res(i+1) := 'X';
42 end if;
43 end loop;
44 return res;
45 end function;
string vec_to_strvec,

The documentation for this design unit was generated from the following file: