| 1 |
21 |
pela |
----------------------------------------------------------------------
|
| 2 |
|
|
---- ----
|
| 3 |
|
|
---- PlTbUtils User Configuration Package ----
|
| 4 |
|
|
---- ----
|
| 5 |
|
|
---- This file is part of the PlTbUtils project ----
|
| 6 |
|
|
---- http://opencores.org/project,pltbutils ----
|
| 7 |
|
|
---- ----
|
| 8 |
|
|
---- Description: ----
|
| 9 |
|
|
---- PlTbUtils is a collection of functions, procedures and ----
|
| 10 |
|
|
---- components for easily creating stimuli and checking response ----
|
| 11 |
|
|
---- in automatic self-checking testbenches. ----
|
| 12 |
|
|
---- ----
|
| 13 |
|
|
---- This file defines the user's customizations. ----
|
| 14 |
|
|
---- ----
|
| 15 |
|
|
---- If the user wishes to modify anything in this file, it is ----
|
| 16 |
|
|
---- recommended that he/she first copies it to another directory ----
|
| 17 |
|
|
---- and modifies the copy. Also make sure that the simulator ----
|
| 18 |
|
|
---- read the modified file instead of the original. ----
|
| 19 |
|
|
---- This makes it easier to update pltbutils to new versions ----
|
| 20 |
|
|
---- without destroying the customizations. ----
|
| 21 |
|
|
---- ----
|
| 22 |
|
|
---- To Do: ----
|
| 23 |
|
|
---- - ----
|
| 24 |
|
|
---- ----
|
| 25 |
|
|
---- Author(s): ----
|
| 26 |
|
|
---- - Per Larsson, pela@opencores.org ----
|
| 27 |
|
|
---- ----
|
| 28 |
|
|
----------------------------------------------------------------------
|
| 29 |
|
|
---- ----
|
| 30 |
|
|
---- Copyright (C) 2014 Authors and OPENCORES.ORG ----
|
| 31 |
|
|
---- ----
|
| 32 |
|
|
---- This source file may be used and distributed without ----
|
| 33 |
|
|
---- restriction provided that this copyright statement is not ----
|
| 34 |
|
|
---- removed from the file and that any derivative work contains ----
|
| 35 |
|
|
---- the original copyright notice and the associated disclaimer. ----
|
| 36 |
|
|
---- ----
|
| 37 |
|
|
---- This source file is free software; you can redistribute it ----
|
| 38 |
|
|
---- and/or modify it under the terms of the GNU Lesser General ----
|
| 39 |
|
|
---- Public License as published by the Free Software Foundation; ----
|
| 40 |
|
|
---- either version 2.1 of the License, or (at your option) any ----
|
| 41 |
|
|
---- later version. ----
|
| 42 |
|
|
---- ----
|
| 43 |
|
|
---- This source is distributed in the hope that it will be ----
|
| 44 |
|
|
---- useful, but WITHOUT ANY WARRANTY; without even the implied ----
|
| 45 |
|
|
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ----
|
| 46 |
|
|
---- PURPOSE. See the GNU Lesser General Public License for more ----
|
| 47 |
|
|
---- details. ----
|
| 48 |
|
|
---- ----
|
| 49 |
|
|
---- You should have received a copy of the GNU Lesser General ----
|
| 50 |
|
|
---- Public License along with this source; if not, download it ----
|
| 51 |
|
|
---- from http://www.opencores.org/lgpl.shtml ----
|
| 52 |
|
|
---- ----
|
| 53 |
|
|
----------------------------------------------------------------------
|
| 54 |
|
|
library ieee;
|
| 55 |
|
|
use ieee.std_logic_1164.all;
|
| 56 |
|
|
use ieee.numeric_std.all;
|
| 57 |
|
|
use std.textio.all;
|
| 58 |
|
|
--use std.env.all; -- Uncomment if using stop or finish in custom_stopsim() below.
|
| 59 |
|
|
use work.txt_util.all;
|
| 60 |
|
|
use work.pltbutils_type_pkg.all; -- Use for VHDL-2002 protected types, comment out for VHDL-93
|
| 61 |
|
|
|
| 62 |
|
|
package pltbutils_user_cfg_pkg is
|
| 63 |
|
|
|
| 64 |
|
|
--- Constants ---
|
| 65 |
|
|
-- The user is free to modify the values to fit his/her requirements.
|
| 66 |
|
|
constant C_PLTBUTILS_USE_STD_STARTSIM_MSG : boolean := true;
|
| 67 |
|
|
constant C_PLTBUTILS_USE_STD_ENDSIM_MSG : boolean := true;
|
| 68 |
|
|
constant C_PLTBUTILS_USE_STD_STARTTEST_MSG : boolean := true;
|
| 69 |
|
|
constant C_PLTBUTILS_USE_STD_ENDTEST_MSG : boolean := true;
|
| 70 |
|
|
constant C_PLTBUTILS_USE_STD_CHECK_MSG : boolean := true;
|
| 71 |
|
|
constant C_PLTBUTILS_USE_STD_ERROR_MSG : boolean := true;
|
| 72 |
|
|
constant C_PLTBUTILS_USE_STD_STOPSIM : boolean := true;
|
| 73 |
|
|
constant C_PLTBUTILS_USE_CUSTOM_STARTSIM_MSG : boolean := false;
|
| 74 |
|
|
constant C_PLTBUTILS_USE_CUSTOM_ENDSIM_MSG : boolean := false;
|
| 75 |
|
|
constant C_PLTBUTILS_USE_CUSTOM_STARTTEST_MSG : boolean := false;
|
| 76 |
|
|
constant C_PLTBUTILS_USE_CUSTOM_ENDTEST_MSG : boolean := false;
|
| 77 |
|
|
constant C_PLTBUTILS_USE_CUSTOM_CHECK_MSG : boolean := false;
|
| 78 |
|
|
constant C_PLTBUTILS_USE_CUSTOM_ERROR_MSG : boolean := false;
|
| 79 |
|
|
constant C_PLTBUTILS_USE_CUSTOM_STOPSIM : boolean := false;
|
| 80 |
|
|
|
| 81 |
|
|
--- Procedure declarations ---
|
| 82 |
|
|
-- The user should NOT modify these.
|
| 83 |
|
|
|
| 84 |
|
|
procedure custom_startsim_msg(
|
| 85 |
|
|
constant testcase_name : in string;
|
| 86 |
|
|
constant timestamp : in time
|
| 87 |
|
|
);
|
| 88 |
|
|
|
| 89 |
|
|
procedure custom_endsim_msg(
|
| 90 |
|
|
constant testcase_name : in string;
|
| 91 |
|
|
constant timestamp : in time;
|
| 92 |
|
|
constant num_tests : in integer;
|
| 93 |
|
|
constant num_checks : in integer;
|
| 94 |
|
|
constant num_errors : in integer;
|
| 95 |
|
|
constant show_success_fail : in boolean
|
| 96 |
|
|
);
|
| 97 |
|
|
|
| 98 |
|
|
procedure custom_starttest_msg(
|
| 99 |
|
|
constant test_num : in integer;
|
| 100 |
|
|
constant test_name : in string;
|
| 101 |
|
|
constant timestamp : in time
|
| 102 |
|
|
);
|
| 103 |
|
|
|
| 104 |
|
|
procedure custom_endtest_msg(
|
| 105 |
|
|
constant test_num : in integer;
|
| 106 |
|
|
constant test_name : in string;
|
| 107 |
|
|
constant timestamp : in time;
|
| 108 |
|
|
constant num_checks_in_test : in integer;
|
| 109 |
|
|
constant num_errors_in_test : in integer
|
| 110 |
|
|
);
|
| 111 |
|
|
|
| 112 |
|
|
procedure custom_check_msg(
|
| 113 |
|
|
constant rpt : in string;
|
| 114 |
|
|
constant expr : in boolean;
|
| 115 |
|
|
constant actual : in string;
|
| 116 |
|
|
constant expected : in string;
|
| 117 |
|
|
constant mask : in string;
|
| 118 |
|
|
constant test_num : in integer;
|
| 119 |
|
|
constant test_name : in string;
|
| 120 |
|
|
constant check_num : in integer;
|
| 121 |
|
|
constant err_cnt_in_test : in integer
|
| 122 |
|
|
);
|
| 123 |
|
|
|
| 124 |
|
|
procedure custom_error_msg(
|
| 125 |
|
|
constant rpt : in string;
|
| 126 |
|
|
constant timestamp : in time;
|
| 127 |
|
|
constant test_num : in integer;
|
| 128 |
|
|
constant test_name : in string;
|
| 129 |
|
|
constant err_cnt_in_test : in integer
|
| 130 |
|
|
);
|
| 131 |
|
|
|
| 132 |
|
|
procedure custom_stopsim(
|
| 133 |
|
|
constant timestamp : in time
|
| 134 |
|
|
);
|
| 135 |
|
|
|
| 136 |
|
|
--- User's function and procedure declarations ---
|
| 137 |
|
|
-- Example for use with TeamCity. Remove, modify or replace
|
| 138 |
|
|
-- to suit other other continous integration tools or scripts, if you need to.
|
| 139 |
|
|
function tcfilter(
|
| 140 |
|
|
constant s : string
|
| 141 |
|
|
) return string;
|
| 142 |
|
|
|
| 143 |
|
|
end package pltbutils_user_cfg_pkg;
|
| 144 |
|
|
|
| 145 |
|
|
package body pltbutils_user_cfg_pkg is
|
| 146 |
|
|
|
| 147 |
|
|
--- Procedure definitions ---
|
| 148 |
|
|
-- The user should NOT modify the arguments,
|
| 149 |
|
|
-- but the behaviour is free to modify to fit the user's requirements.
|
| 150 |
|
|
|
| 151 |
|
|
-- Example custom messages for TeamCity.
|
| 152 |
|
|
-- Edit to suit other continous integration tools or scripts, if you need to.
|
| 153 |
|
|
-- General TeamCity information: http://www.jetbrains.com/teamcity/
|
| 154 |
|
|
-- http://en.wikipedia.org/wiki/Teamcity
|
| 155 |
|
|
-- TeamCity test reporting: http://confluence.jetbrains.com/display/TCD8/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-ReportingTests
|
| 156 |
|
|
|
| 157 |
|
|
procedure custom_startsim_msg(
|
| 158 |
|
|
constant testcase_name : in string;
|
| 159 |
|
|
constant timestamp : in time
|
| 160 |
|
|
) is
|
| 161 |
|
|
begin
|
| 162 |
|
|
print("##teamcity[testSuiteStarted name='" & tcfilter(testcase_name) & "']");
|
| 163 |
|
|
end procedure custom_startsim_msg;
|
| 164 |
|
|
|
| 165 |
|
|
procedure custom_endsim_msg(
|
| 166 |
|
|
constant testcase_name : in string;
|
| 167 |
|
|
constant timestamp : in time;
|
| 168 |
|
|
constant num_tests : in integer;
|
| 169 |
|
|
constant num_checks : in integer;
|
| 170 |
|
|
constant num_errors : in integer;
|
| 171 |
|
|
constant show_success_fail : in boolean
|
| 172 |
|
|
) is
|
| 173 |
|
|
begin
|
| 174 |
|
|
-- TeamCity ignores all arguments except testcase_name
|
| 175 |
|
|
print("##teamcity[testSuiteFinished name='" & tcfilter(testcase_name) & "']");
|
| 176 |
|
|
end procedure custom_endsim_msg;
|
| 177 |
|
|
|
| 178 |
|
|
procedure custom_starttest_msg(
|
| 179 |
|
|
constant test_num : in integer;
|
| 180 |
|
|
constant test_name : in string;
|
| 181 |
|
|
constant timestamp : in time
|
| 182 |
|
|
) is
|
| 183 |
|
|
begin
|
| 184 |
|
|
-- TeamCity ignores test_num and timestamp
|
| 185 |
|
|
print("##teamcity[testStarted name='" & tcfilter(test_name) & "']");
|
| 186 |
|
|
end procedure custom_starttest_msg;
|
| 187 |
|
|
|
| 188 |
|
|
procedure custom_endtest_msg(
|
| 189 |
|
|
constant test_num : in integer;
|
| 190 |
|
|
constant test_name : in string;
|
| 191 |
|
|
constant timestamp : in time;
|
| 192 |
|
|
constant num_checks_in_test : in integer;
|
| 193 |
|
|
constant num_errors_in_test : in integer
|
| 194 |
|
|
) is
|
| 195 |
|
|
begin
|
| 196 |
|
|
-- TeamCity ignores all arguments except test_name
|
| 197 |
|
|
print("##teamcity[testFinished name='" & tcfilter(test_name) & "']");
|
| 198 |
|
|
end procedure custom_endtest_msg;
|
| 199 |
|
|
|
| 200 |
|
|
procedure custom_check_msg(
|
| 201 |
|
|
constant rpt : in string;
|
| 202 |
|
|
constant expr : in boolean;
|
| 203 |
|
|
constant actual : in string;
|
| 204 |
|
|
constant expected : in string;
|
| 205 |
|
|
constant mask : in string;
|
| 206 |
|
|
constant test_num : in integer;
|
| 207 |
|
|
constant test_name : in string;
|
| 208 |
|
|
constant check_num : in integer;
|
| 209 |
|
|
constant err_cnt_in_test : in integer
|
| 210 |
|
|
) is
|
| 211 |
|
|
variable comparison_str : string(1 to 32) := (others => ' ');
|
| 212 |
|
|
variable comparison_str_len : integer := 1;
|
| 213 |
|
|
variable actual_str : string(1 to 32) := (others => ' ');
|
| 214 |
|
|
variable actual_str_len : integer := 1;
|
| 215 |
|
|
variable expected_str : string(1 to 32) := (others => ' ');
|
| 216 |
|
|
variable expected_str_len : integer := 1;
|
| 217 |
|
|
variable mask_str : string(1 to 32) := (others => ' ');
|
| 218 |
|
|
variable mask_str_len : integer := 1;
|
| 219 |
|
|
begin
|
| 220 |
|
|
if not expr then -- Output message only if the check fails
|
| 221 |
|
|
if err_cnt_in_test <= 1 then -- TeamCity allows max one error message per test
|
| 222 |
|
|
if actual /= "" then
|
| 223 |
|
|
actual_str_len := 10 + actual'length;
|
| 224 |
|
|
actual_str(1 to actual_str_len) := " actual='" & tcfilter(actual) & "'";
|
| 225 |
|
|
end if;
|
| 226 |
|
|
if expected /= "" then
|
| 227 |
|
|
comparison_str_len := 26;
|
| 228 |
|
|
comparison_str(1 to comparison_str_len) := " type='comparisonFailure' ";
|
| 229 |
|
|
expected_str_len := 12 + expected'length;
|
| 230 |
|
|
expected_str(1 to expected_str_len) := " expected='" & tcfilter(expected) & "'";
|
| 231 |
|
|
end if;
|
| 232 |
|
|
if mask /= "" then
|
| 233 |
|
|
mask_str_len := 17 + mask'length;
|
| 234 |
|
|
mask_str(1 to mask_str_len) := " details='mask=" & tcfilter(mask) & "' ";
|
| 235 |
|
|
end if;
|
| 236 |
|
|
print("##teamcity[testFailed" &
|
| 237 |
|
|
comparison_str(1 to comparison_str_len) &
|
| 238 |
|
|
"name='" & tcfilter(test_name) & "' " &
|
| 239 |
|
|
"message='" & tcfilter(rpt) & "' " &
|
| 240 |
|
|
expected_str(1 to expected_str_len) &
|
| 241 |
|
|
actual_str(1 to actual_str_len) &
|
| 242 |
|
|
mask_str(1 to mask_str_len) &
|
| 243 |
|
|
"]");
|
| 244 |
|
|
else
|
| 245 |
|
|
print("(TeamCity error message filtered out, because max one message is allowed for each test)");
|
| 246 |
|
|
end if;
|
| 247 |
|
|
end if;
|
| 248 |
|
|
end procedure custom_check_msg;
|
| 249 |
|
|
|
| 250 |
|
|
procedure custom_error_msg(
|
| 251 |
|
|
constant rpt : in string;
|
| 252 |
|
|
constant timestamp : in time;
|
| 253 |
|
|
constant test_num : in integer;
|
| 254 |
|
|
constant test_name : in string;
|
| 255 |
|
|
constant err_cnt_in_test : in integer
|
| 256 |
|
|
) is
|
| 257 |
|
|
begin
|
| 258 |
|
|
if err_cnt_in_test <= 1 then -- TeamCity allows max one error message per test
|
| 259 |
|
|
print("##teamcity[testFailed" &
|
| 260 |
|
|
"name='" & tcfilter(test_name) & "' " &
|
| 261 |
|
|
"message='" & tcfilter(rpt) & "']");
|
| 262 |
|
|
else
|
| 263 |
|
|
print("(TeamCity error message filtered out, because max one message is allowed for each test)");
|
| 264 |
|
|
end if;
|
| 265 |
|
|
end procedure custom_error_msg;
|
| 266 |
|
|
|
| 267 |
|
|
procedure custom_stopsim(
|
| 268 |
|
|
constant timestamp : in time
|
| 269 |
|
|
) is
|
| 270 |
|
|
begin
|
| 271 |
|
|
-- The best way to stop a simulation differs between different simulators.
|
| 272 |
|
|
-- Below are some examples. Modify to suit your simulator.
|
| 273 |
|
|
|
| 274 |
|
|
-- Works with some simulators.
|
| 275 |
|
|
-- Requires that 'use std.env.all' at the top of the file is uncommented.
|
| 276 |
|
|
--stop; -- VHDL-2008
|
| 277 |
|
|
|
| 278 |
|
|
-- Works with some simulators.
|
| 279 |
|
|
-- Requires that 'use std.env.all' at the top of the file is uncommented.
|
| 280 |
|
|
--finish; -- VHDL-2008
|
| 281 |
|
|
|
| 282 |
|
|
-- Works in all simulators known by the author, but ugly.
|
| 283 |
|
|
assert false
|
| 284 |
|
|
report "--- FORCE END OF SIMULATION ---" &
|
| 285 |
|
|
" (ignore this false failure message, it's not a real failure)"
|
| 286 |
|
|
severity failure;
|
| 287 |
|
|
|
| 288 |
|
|
end procedure custom_stopsim;
|
| 289 |
|
|
|
| 290 |
|
|
--- User's function and procedure definitions ---
|
| 291 |
|
|
-- Example for use with TeamCity. Remove, modify or replace
|
| 292 |
|
|
-- to suit other other continous integration tools or scripts, if you need to.
|
| 293 |
|
|
|
| 294 |
|
|
-- TeamCity string filter. Filters out characters which are not allowed in TeamCity messages.
|
| 295 |
|
|
-- Search for "escaped values" in
|
| 296 |
|
|
-- http://confluence.jetbrains.com/display/TCD8/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-ReportingTests
|
| 297 |
|
|
-- The TeamCity escape character is not used, because that changes the length of the string.
|
| 298 |
|
|
-- The VHDL code can be simplified if it doesn't have to deal with changes of string
|
| 299 |
|
|
-- lengths.
|
| 300 |
|
|
function tcfilter(
|
| 301 |
|
|
constant s : string
|
| 302 |
|
|
) return string is
|
| 303 |
|
|
variable r : string(s'range) := (others => (' '));
|
| 304 |
|
|
begin
|
| 305 |
|
|
for i in s'range loop
|
| 306 |
|
|
if s(i) = ''' then
|
| 307 |
|
|
r(i) := '`';
|
| 308 |
|
|
elsif s(i) = lf or s(i) = cr then
|
| 309 |
|
|
r(i) := ' ';
|
| 310 |
|
|
elsif s(i) = '|' then
|
| 311 |
|
|
r(i) := '/';
|
| 312 |
|
|
elsif s(i) = '[' then
|
| 313 |
|
|
r(i) := '{';
|
| 314 |
|
|
elsif s(i) = ']' then
|
| 315 |
|
|
r(i) := '}';
|
| 316 |
|
|
else
|
| 317 |
|
|
r(i) := s(i);
|
| 318 |
|
|
end if;
|
| 319 |
|
|
end loop;
|
| 320 |
|
|
return r;
|
| 321 |
|
|
end function tcfilter;
|
| 322 |
|
|
|
| 323 |
|
|
end package body pltbutils_user_cfg_pkg;
|