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 103

Go to most recent revision | 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
---- 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 35 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 101 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
    variable comparison_str     : string(1 to 32) := (others => ' ');
260
    variable comparison_str_len : integer := 1;
261
    variable actual_str         : string(1 to 32) := (others => ' ');
262
    variable actual_str_len     : integer := 1;
263
    variable expected_str       : string(1 to 32) := (others => ' ');
264
    variable expected_str_len   : integer := 1;
265
    variable mask_str           : string(1 to 32) := (others => ' ');
266
    variable mask_str_len       : integer := 1;
267
  begin
268
    if not expr then -- Output message only if the check fails
269
      if err_cnt_in_test <= 1 then -- TeamCity allows max one error message per test
270
        if actual /= "" then
271
          actual_str_len := 10 + actual'length;
272
          actual_str(1 to actual_str_len) := " actual='" & tcfilter(actual) & "'";
273
        end if;
274
        if expected /= "" then
275
          comparison_str_len := 26;
276
          comparison_str(1 to comparison_str_len) := " type='comparisonFailure' ";
277
          expected_str_len := 12 + expected'length;
278
          expected_str(1 to expected_str_len) := " expected='" & tcfilter(expected) & "'";
279
        end if;
280
        if mask /= "" then
281
          mask_str_len := 17 + mask'length;
282
          mask_str(1 to mask_str_len) := " details='mask=" & tcfilter(mask) & "' ";
283
        end if;
284
        print("##teamcity[testFailed" &
285
              comparison_str(1 to comparison_str_len) &
286
              "name='" & tcfilter(test_name) & "' " &
287
              "message='" & tcfilter(rpt) & "' " &
288
              expected_str(1 to expected_str_len) &
289
              actual_str(1 to actual_str_len) &
290
              mask_str(1 to mask_str_len) &
291
              "]");
292
      else
293
        print("(TeamCity error message filtered out, because max one message is allowed for each test)");
294
      end if;
295
    end if;
296
  end procedure custom_check_msg;
297
 
298
  procedure custom_error_msg(
299
    constant rpt                : in string;
300
    constant timestamp          : in time;
301
    constant test_num           : in integer;
302
    constant test_name          : in string;
303
    constant err_cnt_in_test    : in integer
304
  ) is
305
  begin
306
    if err_cnt_in_test <= 1 then -- TeamCity allows max one error message per test
307
      print("##teamcity[testFailed" &
308
            "name='" & tcfilter(test_name) & "' " &
309
            "message='" & tcfilter(rpt) & "']");
310
    else
311
      print("(TeamCity error message filtered out, because max one message is allowed for each test)");
312
    end if;
313
  end procedure custom_error_msg;
314
 
315
  --- User's function and procedure definitions ---
316
  -- Example for use with TeamCity. Remove, modify or replace
317
  -- to suit other other continous integration tools or scripts, if you need to.
318
 
319
  -- TeamCity string filter. Filters out characters which are not allowed in TeamCity messages.
320
  -- Search for "escaped values" in 
321
  --   http://confluence.jetbrains.com/display/TCD8/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-ReportingTests
322
  -- The TeamCity escape character is not used, because that changes the length of the string.
323
  -- The VHDL code can be simplified if it doesn't have to deal with changes of string
324
  -- lengths. 
325
  function tcfilter(
326
    constant s : string
327
  ) return string is
328
    variable r : string(s'range) := (others => (' '));
329
  begin
330
    for i in s'range loop
331
      if s(i) = ''' then
332
        r(i) := '`';
333
      elsif s(i) = lf or s(i) = cr then
334
        r(i) := ' ';
335
      elsif s(i) = '|' then
336
        r(i) := '/';
337
      elsif s(i) = '[' then
338
        r(i) := '{';
339
      elsif s(i) = ']' then
340
        r(i) := '}';
341
      else
342
        r(i) := s(i);
343
      end if;
344
    end loop;
345
    return r;
346
  end function tcfilter;
347
 
348
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.