OpenCores
URL https://opencores.org/ocsvn/pltbutils/pltbutils/trunk

Subversion Repositories pltbutils

[/] [pltbutils/] [trunk/] [src/] [vhdl/] [pltbutils_user_cfg_pkg.vhd] - Blame information for rev 107

Details | Compare with Previous | View Log

Line No. Rev Author Line
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 97 pela
---- - Per Larsson, pela.opencores@gmail.com                      ----
27 21 pela
----                                                              ----
28
----------------------------------------------------------------------
29
----                                                              ----
30 107 pela
---- Copyright (C) 2014-2020 Authors and OPENCORES.ORG            ----
31 21 pela
----                                                              ----
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 107 pela
use std.textio.all;
58 21 pela
--use std.env.all; -- Uncomment if using stop or finish in custom_stopsim() below.
59
use work.txt_util.all;
60
 
61
package pltbutils_user_cfg_pkg is
62
 
63
  --- Constants ---
64
  -- The user is free to modify the values to fit his/her requirements.
65
  constant C_PLTBUTILS_USE_STD_STARTSIM_MSG     : boolean := true;
66
  constant C_PLTBUTILS_USE_STD_ENDSIM_MSG       : boolean := true;
67
  constant C_PLTBUTILS_USE_STD_STARTTEST_MSG    : boolean := true;
68 107 pela
  constant C_PLTBUTILS_USE_STD_SKIPTEST_MSG     : boolean := true;
69 21 pela
  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 101 pela
  constant C_PLTBUTILS_USE_CUSTOM_SKIPTEST_MSG  : boolean := false;
77 21 pela
  constant C_PLTBUTILS_USE_CUSTOM_ENDTEST_MSG   : boolean := false;
78
  constant C_PLTBUTILS_USE_CUSTOM_CHECK_MSG     : boolean := false;
79
  constant C_PLTBUTILS_USE_CUSTOM_ERROR_MSG     : boolean := false;
80
  constant C_PLTBUTILS_USE_CUSTOM_STOPSIM       : boolean := false;
81
 
82
  --- Procedure declarations ---
83
  -- The user should NOT modify these.
84
 
85 35 pela
  procedure custom_stopsim(
86
    constant timestamp          : in time
87
  );
88
 
89 21 pela
  procedure custom_startsim_msg(
90
    constant testcase_name      : in string;
91
    constant timestamp          : in time
92
  );
93
 
94
  procedure custom_endsim_msg(
95
    constant testcase_name      : in string;
96
    constant timestamp          : in time;
97
    constant num_tests          : in integer;
98 101 pela
    constant num_skip_tests     : in integer;
99 21 pela
    constant num_checks         : in integer;
100
    constant num_errors         : in integer;
101
    constant show_success_fail  : in boolean
102
  );
103
 
104
  procedure custom_starttest_msg(
105
    constant test_num           : in integer;
106
    constant test_name          : in string;
107
    constant timestamp          : in time
108
  );
109
 
110 101 pela
  procedure custom_skiptest_msg(
111
    constant test_num           : in integer;
112
    constant test_name          : in string;
113
    constant timestamp          : in time
114
  );
115
 
116 21 pela
  procedure custom_endtest_msg(
117
    constant test_num           : in integer;
118
    constant test_name          : in string;
119
    constant timestamp          : in time;
120 101 pela
    constant test_active        : in boolean;
121 21 pela
    constant num_checks_in_test : in integer;
122
    constant num_errors_in_test : in integer
123
  );
124
 
125
  procedure custom_check_msg(
126
    constant rpt                : in string;
127 35 pela
    constant timestamp          : in time;
128 21 pela
    constant expr               : in boolean;
129
    constant actual             : in string;
130
    constant expected           : in string;
131
    constant mask               : in string;
132
    constant test_num           : in integer;
133
    constant test_name          : in string;
134
    constant check_num          : in integer;
135
    constant err_cnt_in_test    : in integer
136
  );
137
 
138
  procedure custom_error_msg(
139
    constant rpt                : in string;
140
    constant timestamp          : in time;
141
    constant test_num           : in integer;
142
    constant test_name          : in string;
143
    constant err_cnt_in_test    : in integer
144
  );
145 35 pela
 
146 21 pela
  --- User's function and procedure declarations ---
147
  -- Example for use with TeamCity. Remove, modify or replace
148
  -- to suit other other continous integration tools or scripts, if you need to.
149
  function tcfilter(
150
    constant s : string
151
  ) return string;
152
 
153
end package pltbutils_user_cfg_pkg;
154
 
155
package body pltbutils_user_cfg_pkg is
156
 
157
  --- Procedure definitions ---
158
  -- The user should NOT modify the arguments,
159
  -- but the behaviour is free to modify to fit the user's requirements.
160 35 pela
 
161
  procedure custom_stopsim(
162
    constant timestamp          : in time
163
  ) is
164
  begin
165
    -- The best way to stop a simulation differs between different simulators.
166
    -- Below are some examples. Modify to suit your simulator.
167
 
168
    -- Works with some simulators that supports VHDL-2008. 
169
    -- Requires that 'use std.env.all' at the top of the file is uncommented.
170
    --stop;
171
 
172
    -- Works with some simulators that support VHDL-2008. 
173
    -- Requires that 'use std.env.all' at the top of the file is uncommented.
174
    --finish;
175
 
176
    -- Works in all simulators known by the author, but ugly.
177
    assert false
178
    report "--- FORCE END OF SIMULATION ---" &
179
           " (ignore this false failure message, it's not a real failure)"
180
    severity failure;
181
 
182
  end procedure custom_stopsim;
183 21 pela
 
184
  -- Example custom messages for TeamCity.
185
  -- Edit to suit other continous integration tools or scripts, if you need to.
186
  -- General TeamCity information: http://www.jetbrains.com/teamcity/
187
  --                               http://en.wikipedia.org/wiki/Teamcity
188
  -- TeamCity test reporting:      http://confluence.jetbrains.com/display/TCD8/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-ReportingTests
189
 
190
  procedure custom_startsim_msg(
191
    constant testcase_name      : in string;
192
    constant timestamp          : in time
193
  ) is
194
  begin
195
    print("##teamcity[testSuiteStarted name='" & tcfilter(testcase_name) & "']");
196
  end procedure custom_startsim_msg;
197
 
198
  procedure custom_endsim_msg(
199
    constant testcase_name      : in string;
200
    constant timestamp          : in time;
201
    constant num_tests          : in integer;
202 101 pela
    constant num_skip_tests     : in integer;
203 21 pela
    constant num_checks         : in integer;
204
    constant num_errors         : in integer;
205
    constant show_success_fail  : in boolean
206
  ) is
207
  begin
208
    -- TeamCity ignores all arguments except testcase_name
209
    print("##teamcity[testSuiteFinished name='" & tcfilter(testcase_name) & "']");
210
  end procedure custom_endsim_msg;
211
 
212
  procedure custom_starttest_msg(
213
    constant test_num           : in integer;
214
    constant test_name          : in string;
215
    constant timestamp          : in time
216
  ) is
217
  begin
218
    -- TeamCity ignores test_num and timestamp
219
    print("##teamcity[testStarted name='" & tcfilter(test_name) & "']");
220
  end procedure custom_starttest_msg;
221
 
222 101 pela
  procedure custom_skiptest_msg(
223
    constant test_num           : in integer;
224
    constant test_name          : in string;
225
    constant timestamp          : in time
226
  ) is
227
  begin
228
    -- TeamCity ignores test_num and timestamp
229
    print("##teamcity[testIgnored name='" & tcfilter(test_name) & "']");
230
  end procedure custom_skiptest_msg;
231
 
232 21 pela
  procedure custom_endtest_msg(
233
    constant test_num           : in integer;
234
    constant test_name          : in string;
235
    constant timestamp          : in time;
236 101 pela
    constant test_active        : in boolean;
237 21 pela
    constant num_checks_in_test : in integer;
238
    constant num_errors_in_test : in integer
239
  ) is
240
  begin
241 101 pela
    if test_active then
242
      -- TeamCity ignores all arguments except test_name
243
     print("##teamcity[testFinished name='" & tcfilter(test_name) & "']");
244
    end if;
245 21 pela
  end procedure custom_endtest_msg;
246
 
247
  procedure custom_check_msg(
248
    constant rpt                : in string;
249 35 pela
    constant timestamp          : in time;
250 21 pela
    constant expr               : in boolean;
251
    constant actual             : in string;
252
    constant expected           : in string;
253
    constant mask               : in string;
254
    constant test_num           : in integer;
255
    constant test_name          : in string;
256
    constant check_num          : in integer;
257
    constant err_cnt_in_test    : in integer
258
  ) is
259 107 pela
    variable l                  : line;
260
    constant C_NO_TAGS_STR      : string := "!NO_TAGS!";
261
    variable no_tags            : boolean := false;
262 21 pela
  begin
263
    if not expr then -- Output message only if the check fails
264
      if err_cnt_in_test <= 1 then -- TeamCity allows max one error message per test
265 107 pela
        if mask'length = C_NO_TAGS_STR'length then
266
          if mask = C_NO_TAGS_STR then
267
            no_tags := true;
268
          end if;
269
        end if;
270
        if no_tags then
271
          write(l, "##teamcity[testFailed name='" & tcfilter(test_name) & "'");
272
          write(l, "  message='" & tcfilter(rpt) & "'");
273
          if actual /= "" or expected /= "" then
274
            write(l, " details='" & tcfilter(actual));
275
            if actual /= "" and expected /= "" then
276
              write(l, string'(" "));
277
            end if;
278
            write(l, tcfilter(expected) & "'");
279
          end if;
280
          write(l, string'("]"));
281
        else
282
          write(l, "##teamcity[testFailed type='comparisonFailure' name='" & tcfilter(test_name) & "'");
283
          if expected /= "" then
284
            write(l, " expected='" & tcfilter(expected) & "'");
285
          end if;
286
          if actual /= "" then
287
            write(l, " actual='" & tcfilter(actual) & "'");
288
          end if;
289
          if mask /= "" then
290
            write(l, " details='mask=" & tcfilter(mask) & "'");
291
          end if;
292
          write(l, string'("]"));
293
        end if;
294
        print(l.all);
295 21 pela
      else
296
        print("(TeamCity error message filtered out, because max one message is allowed for each test)");
297
      end if;
298
    end if;
299
  end procedure custom_check_msg;
300
 
301
  procedure custom_error_msg(
302
    constant rpt                : in string;
303
    constant timestamp          : in time;
304
    constant test_num           : in integer;
305
    constant test_name          : in string;
306
    constant err_cnt_in_test    : in integer
307
  ) is
308
  begin
309
    if err_cnt_in_test <= 1 then -- TeamCity allows max one error message per test
310
      print("##teamcity[testFailed" &
311
            "name='" & tcfilter(test_name) & "' " &
312
            "message='" & tcfilter(rpt) & "']");
313
    else
314
      print("(TeamCity error message filtered out, because max one message is allowed for each test)");
315
    end if;
316
  end procedure custom_error_msg;
317
 
318
  --- User's function and procedure definitions ---
319
  -- Example for use with TeamCity. Remove, modify or replace
320
  -- to suit other other continous integration tools or scripts, if you need to.
321
 
322
  -- TeamCity string filter. Filters out characters which are not allowed in TeamCity messages.
323
  -- Search for "escaped values" in 
324
  --   http://confluence.jetbrains.com/display/TCD8/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-ReportingTests
325
  -- The TeamCity escape character is not used, because that changes the length of the string.
326
  -- The VHDL code can be simplified if it doesn't have to deal with changes of string
327
  -- lengths. 
328
  function tcfilter(
329
    constant s : string
330
  ) return string is
331
    variable r : string(s'range) := (others => (' '));
332
  begin
333
    for i in s'range loop
334
      if s(i) = ''' then
335
        r(i) := '`';
336
      elsif s(i) = lf or s(i) = cr then
337
        r(i) := ' ';
338
      elsif s(i) = '|' then
339
        r(i) := '/';
340
      elsif s(i) = '[' then
341
        r(i) := '{';
342
      elsif s(i) = ']' then
343
        r(i) := '}';
344
      else
345
        r(i) := s(i);
346
      end if;
347
    end loop;
348
    return r;
349
  end function tcfilter;
350
 
351 107 pela
end package body pltbutils_user_cfg_pkg;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.