2use IEEE.STD_LOGIC_1164.
ALL;
3use IEEE.NUMERIC_STD.
ALL;
12 function vec_to_str(vec :
std_logic_vector)
return string;
17 constant file_name :
in string;
18 constant message :
in string;
19 constant is_error :
in boolean := false
24 constant actual :
in std_logic_vector;
25 constant expected :
in std_logic_vector;
26 constant msg_tag :
in string;
27 variable error_cnt :
inout integer;
28 constant file_name :
in string :=
35 function vec_to_str(vec :
std_logic_vector)
return string is
36 variable res :
string(1 to vec'
length);
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';
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;
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);
62 constant file_name :
in string;
63 constant message :
in string;
64 constant is_error :
in boolean := false
68 variable prefix :
string(1 to 7);
70 if is_error
then prefix :=
"ERROR :";
else prefix :=
"INFO :";
end if;
72 file_open
(f, file_name, append_mode
);
73 write
(l,
"[" &
time'
image(now
) &
"] - " & prefix &
" " & message
);
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 :=
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";
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;
log_to_filefile_name,message,is_error,
string int_to_hex_strval,width,
check_valueactual,expected,msg_tag,error_cnt,file_name,