Project

General

Profile

C++TESK Quick Reference » History » Version 2

Mikhail Chupilko, 09/20/2013 11:57 AM

1 1 Mikhail Chupilko
h1. C++TESK Quick Reference
2
3
h2. Introduction
4
5
This document is a quick reference of C++TESK Hardware Extension tool (С++TESK, hereafter) included into C++TESK Testing ToolKit and aimed to automated development of test systems for HDL-models (HDL (Hardware Description Language) — class of program languages used for description of hardware) of hardware. The tool architecture bases on general UniTESK (http://www.unitesk.ru) conventions.
6
7
_Test system_ is meant to be a special program which evaluates the functional correctness of _target system_, applying some input data (_stimuli_) and analyzing received results of their application (_reactions_). Typical test system consists of three common components: (1) _stimulus generator_ making sequences of stimuli (_test sequences_), (2) _test oracle_ checking correctness of reactions, and (3) _test completeness evaluator_.
8
9
The document describes facilities of C++TESK aimed to development of mentioned test system components, and consists of four common chapters.
10
* Development of reference model
11
* Development of reference model adapter
12
* Description of test coverage
13
* Development of test scenario
14
15
First two chapters touch upon development of test oracle basic parts: _reference model_ covering functionality of target system, and _reference model adapter_ binding reference model with target system. The third chapter is devoted to the test completeness estimation on the base of _test coverage_. The last chapter concerns development of test scenario which is the main part of stimulus generator.
16
17
More detailed toolkit review is given in _«C++TESK Testing ToolKit: User Guide»_.
18
19
Installation process of C++TESK is described in _«С++TESK Testing ToolKit: Installation Guide»_.
20
21
h2. Supporting obsolete constructions
22
23
Updates of C++TESK do not interfere in the compilation and running of test systems developed for older versions of C++TESK. When the toolkit has incompatible with older versions update, this update is marked by a build number in form of yymmdd, i.e. 110415 – the 15th of April, 2011. The update is available only if macro CPPTESKHW_VERSION (using gcc compiler it can be done by the option –Dmacro_name=value) is appropriately defined. E.g.,
24
-DCPPTESKHW_VERSION=110415 enables usage of incompatible updated having been made by the 15th of April, 2011 (including this date). Each build of the toolkit has the whole list of such changes.
25
26
Obsolete constructions of the toolkit are not described in this document. Possibilities of the toolkit, being incompatible with having become obsolete constructions, are presented with the build number, since which they have been available. E.g., the sentence “the means are supported from 110415 build” means that usage of these means requires two conditions: (1) using toolkit build has the number 110415 or greater, (2) the compilation option -DCPPTESKHW_VERSION=number, where number is not less than 110415, is used.
27
28
If some obsolete constructions are not used or prevent the toolkit from further development, they might become unsupported. In this case, during compilation of test system using these constructions, a message with advices about correction of test system will be shown.
29
30
During compilation of test systems, developed by means of C++TESK, usage of the compiler option -DCPPTESKHW_VERSION=number is highly recommended.
31
32
h2. Naming convention
33
34
The core of the toolkit is developed as a C++ library. Available means are grouped into the following namespaces.
35
36
* cpptesk::hw — means for development of reference models and their adapters;
37
* cpptesk::ts — basic means for test system development;
38
* cpptesk::ts::coverage — means for test coverage description;
39
* сpptesk::ts::engine  — library with test engines4;
40
* cpptesk::tracer — means for tracing;
41
* cpptesk::tracer::coverage — means for coverage tracing.
42
43
A lot of C++TESK means are implemented in form of macros. To avoid conflicts of names, names of all macros start with prefix CPPTESK_, e.g., CPPTESK_MODEL(name). Generally, each macro has two aliases: shortened name (without CPPTESK_ prefix) and short name, (after additional “compression” of shortened name). E.g., macro CPPTESK_ITERATION_BEGIN has two aliases: ITERATION_BEGIN and IBEGIN. To use shortened and short names, macros CPPTESK_SHORT_NAMES and CPPTESK_SHORT_SHORT_NAMES should be defined, respectively.
44
45
h2. Development of reference model
46
47
Reference model is a structured set of classes describing functionality of target system at some abstraction level5. Reference model consists of message classes describing format of input and output data (structures of stimuli and reactions), main class and set of auxiliary classes. Hereafter, a main class of reference model will be meant under term reference model.
48
49
h3. Class of message
50
51
Message classes are declared by macro @CPPTESK_MESSAGE(name)@. Row with macro @CPPTESK_SUPPORT_CLONE(name)@ defining the message clone method @name* clone()@ should be written inside of the each message class declaration.
52
53
Example:
54
<pre><code class="cpp">
55
#include <hw/message.hpp>
56
CPPTESK_MESSAGE(MyMessage) {
57
public:
58
    CPPTESK_SUPPORT_CLONE(MyMessage)
59
    ...
60
};
61
</code></pre>
62
*Notice*: Row @CPPTESK_SUPPORT_CLONE(name)@ is obligatory.
63
64 2 Mikhail Chupilko
h4. Input message randomizer
65 1 Mikhail Chupilko
66
Virtual method @randomize()@ (randomizer of the message) should be overloaded in each input message class. There are two macros @CPPTESK_{DECLARE|DEFINE}_RANDOMIZER@ for this purpose.
67
68
Example:
69
<pre><code class="cpp">
70
CPPTESK_MESSAGE(MyMessage) {
71
    ...
72
    CPPTESK_DECLARE_RANDOMIZER();
73
private:
74
    int data;
75
};
76
77
CPPTESK_DEFINE_RANDOMIZER(MyMessage) {
78
    data = CPPTESK_RANDOM(int);
79
}
80
</code></pre>
81
82
The following macros can be used for randomization of data fields.
83
* @CPPTESK_RANDOM(type)@ — generation of random integer value;
84
* @CPPTESK_RANDOM_WIDTH(type, length)@ — generation of random integer value of given number of bits;
85
* @CPPTESK_RANDOM_FIELD(type, min_bit, max_bit)@ — generation of random integer value with zero bits outside the given range;
86
* @CPPTESK_RANDOM_RANGE(type, min_value, max_value)@ — generation of random integer value from given integer range;
87
* @CPPTESK_RANDOM_CHOICE(type, value_1, ..., value_n)@ — random choice from given set of any type values.
88
89
*Notice*: randomizer may not be defined if all data fields are defined by special macros (see chapter _“Message data fields”_).
90
91 2 Mikhail Chupilko
h4. Comparator of output messages
92 1 Mikhail Chupilko
93
Virtual method @compare()@ (comparator of messages) should  be overloaded in each output message class. There are two macro @CPPTESK_{DECLARE|DEFINE}_COMPARATOR@ for this purpose (build is not less than 110428).
94
95
Example:
96
<pre><code class="cpp">
97
CPPTESK_MESSAGE(MyMessage) {
98
    ...
99
    CPPTESK_DECLARE_COMPARATOR();
100
private:
101
    int data;
102
};
103
104
CPPTESK_DEFINE_COMPARATOR(MyMessage) {
105
    const MyMessage &rhs = CPPTESK_CONST_CAST_MESSAGE(MyMessage);
106
    // in case of difference between messages return not empty string
107
    if(data != rhs.data)
108
        { return "incorrect data"; }
109
    // empty string is interpreted as absence of difference
110
    return COMPARE_OK;
111
}
112
</code></pre>
113
114
*Notice*: comparator may not be defined if all data fields are defined by special macros (see chapter “Message data fields”).
115
116 2 Mikhail Chupilko
h4. Message data fields
117 1 Mikhail Chupilko
118
The following macros are aimed to declaration of integer data fields.
119
* @CPPTESK_DECLARE_FIELD(name, length)@ declares integer field with given name and length.
120
* @CPPTESK_DECLARE_MASKED_FIELD(name, length, mask)@ declares integer field with given name, length, and mask.
121
* @CPPTESK_DECLARE_BIT(name)@ declares bit field with given name.
122
123
Example:
124
<pre><code class="cpp">
125
#include <hw/message.hpp>
126
CPPTESK_MESSAGE(MyMessage) {
127
public:
128
    CPPTESK_DECLARE_MASKED_FIELD(addr, 32, 0xffffFFF0);
129
    CPPTESK_DECLARE_FIELD(data, 32);
130
    CPPTESK_DECLARE_BIT(flag);
131
    ...
132
};
133
</code></pre>
134
135
*Notice*: length of the data fields should not exceed 64 bits.
136
137
All declared data fields should be registered in message class constructor by means of macro @CPPTESK_ADD_FIELD(full_name)@ or, when the data field should not be taken into account by comparator, by means of @CPPTESK_ADD_INCOMPARABLE_FIELD(full_name)@.
138
139
Example:
140
<pre><code class="cpp">
141
MyMessage::MyMessage() {
142
    CPPTESK_ADD_FIELD(MyMessage::addr);
143
    CPPTESK_ADD_FIELD(MyMessage::data);
144
    CPPTESK_ADD_INCOMPARABLE_FIELD(MyMessage::flag);
145
    ...
146
}
147
</code></pre>
148
149
*Notice*: full_name means usage both name of method and name of class.
150
151 2 Mikhail Chupilko
h4. Optional messages
152 1 Mikhail Chupilko
153
Output message can be declared to be optional (not obligatory for receiving) if the following method is used.
154
<pre><code class="cpp">void setOptional(optional_or_not_optional);</code></pre>
155
*Notice*: Default value of the parameter “optional_or_not_optional” is true, i.e. if there has not been correspondent implementation output message by a certain timeout, the message will be simply deleted without showing of an error. At the same time, the optional message is added to the interface arbiter and might affect to the matching of other output messages. If correspondent implementation reactions are received after the timeout and they are to be ignored, the flag of the message being optional should be set in message class constructor.
156
157
h2. Reference model
158
159 2 Mikhail Chupilko
Reference model (main class of the reference model) is declared by macro @CPPTESK_MODEL(name)@.
160
161 1 Mikhail Chupilko
Example:
162 2 Mikhail Chupilko
<pre><code class="cpp">
163 1 Mikhail Chupilko
#include <hw/model.hpp>
164
CPPTESK_MODEL(MyModel) {
165
    ...
166
};
167 2 Mikhail Chupilko
</code></pre>
168
169 1 Mikhail Chupilko
Reference model contains declaration of input and output interfaces, operations, auxiliary processes, and data necessary for operation description.
170 2 Mikhail Chupilko
171
h3. Interface
172
173
Input and output interfaces of the reference model are declared by means of two macros @CPPTESK_DECLARE_{INPUT|OUTPUT}(name)@, respectively.
174
175 1 Mikhail Chupilko
Example:
176 2 Mikhail Chupilko
<pre><code class="cpp">
177 1 Mikhail Chupilko
#include <hw/model.hpp>
178
CPPTESK_MODEL(MyModel) {
179
public:
180
    CPPTESK_DECLARE_INPUT(input_iface);
181
    CPPTESK_DECLARE_OUTPUT(output_iface);
182
    ...
183
};
184 2 Mikhail Chupilko
</code></pre>
185
186
All declared interfaces should be registered in reference model constructor by means of two macros @CPPTESK_ADD_{INPUT|OUTPUT}(name)@.
187
188 1 Mikhail Chupilko
Example:
189 2 Mikhail Chupilko
<pre><code>
190 1 Mikhail Chupilko
MyModel::MyModel() {
191
    CPPTESK_ADD_INPUT(input_iface);
192
    CPPTESK_ADD_OUTPUT(output_iface);
193
    ...
194
}
195 2 Mikhail Chupilko
</code></pre>
196
197
h3. Setting up ignoring of failures on output interface
198
199 1 Mikhail Chupilko
To disable showing errors of a certain type on a given interface is possible by means of the method:
200 2 Mikhail Chupilko
<pre><code class="cpp">
201 1 Mikhail Chupilko
void setFailureIgnoreTypes(disabling_error_types_mask);
202 2 Mikhail Chupilko
</code></pre>
203
204
Disabling error types include errors of implementation reaction absence (@MISSING_REACTION@) and specification reaction absence (@UNEXPECTED_REACTION@) on the given interface. Error types can be grouped by bit operation “or”.
205
206
h3. Process
207
208
Processes are the main means of functional specification of hardware. Processes are subdivided into operations (see chapter _“Operation”_) and internal processes. Operations describe processing of stimuli of a certain types by the target system. Internal processes are used for definition of the other, more complex processes, including operations.
209
210
Declaration and definition of reference model processes are made by means of macros @CPPTESK_{DECLARE|DEFINE}_PROCESS(name)@. Definition of the process should be started by calling macro @CPPTESK_START_PROCESS()@, and finished by calling macro @CPPTESK_STOP_PROCESS()@.
211
212 1 Mikhail Chupilko
Example:
213 2 Mikhail Chupilko
<pre><code class="cpp">
214 1 Mikhail Chupilko
#include <hw/model.hpp>
215
CPPTESK_MODEL(MyModel) {
216
public:
217
    ...
218
    CPPTESK_DECLARE_PROCESS(internal_process);
219
    ...
220
};
221
222
CPPTESK_DEFINE_PROCESS(MyModel::internal_process) {
223
    CPPTESK_START_PROCESS();
224
    ...
225
    CPPTESK_STOP_PROCESS();
226
}
227 2 Mikhail Chupilko
</code></pre>
228
229
*Notice*: macro @CPPTESK_START_PROCESS()@ may be used only once in definition of the process, and usually precedes the main process code. Semantics of @CPPTESK_STOP_PROCESS()@ is similar to the semantics of operator return — when the macro is called, the process finished.
230
231
*Notice*: keyword process is reserved and cannot be used for naming of processes.
232
233
h3. Process parameters
234
235 1 Mikhail Chupilko
Process should have three obligatory parameters: (1) process execution context, (2) associated with process interface, and (3) message. To access process parameters is possible by means of the following macros.
236 2 Mikhail Chupilko
* @CPPTESK_GET_PROCESS()@ — get process context;
237
* @CPPTESK_GET_IFACE()@ — get process interface;
238
* @CPPTESK_GET_MESSAGE()@ — get message.
239
240 1 Mikhail Chupilko
To cast message parameter to the necessary type is possible by means of the following macros.
241 2 Mikhail Chupilko
* @CPPTESK_CAST_MESSAGE(message_class)@;
242
* @CPPTESK_CONST_CAST_MESSAGE(message_class)@.
243
244 1 Mikhail Chupilko
Example:
245 2 Mikhail Chupilko
<pre><code class="cpp">
246 1 Mikhail Chupilko
#include <hw/model.hpp>
247
CPPTESK_DEFINE_PROCESS(MyModel::internal_process) {
248
    // copy message to the local variable
249
    MyMessage msg = CPPTESK_CAST_MESSAGE(MyMessage);
250
    // get reference to the message
251
    MyMessage &msg_ref = CPPTESK_CAST_MESSAGE(MyMessage);
252
    // get constant reference to the message
253
    const MyMessage &const_msg_ref = CPPTESK_CONST_CAST_MESSAGE(MyMessage);
254
    ...
255
}
256 2 Mikhail Chupilko
</code></pre>
257
258
h3. Process priority
259
260
During execution, each process is assigned with a priority, unsigned integer value from range @[1, 255]@ (0 is reserved). Priority affects the order of process execution inside of one cycle (processes with higher priority run first). Priorities may be used in matching of implementation and specification reactions (see chapter _“Reaction arbiter”_). When started, all processes are assigned with the same priority (@NORMAL_PRIORITY@). To change the priority is possible by means of the following macros.
261
* @CPPTESK_GET_PRIORITY()@ — get process priority.
262
* @CPPTESK_SET_PRIORITY(priority)@ — set process priority.
263
264
Some priority values are defined in the enumeration type @priority_t (cpptesk::hw namespace)@. The most general of them are the following ones.
265
* @NORMAL_PRIORITY@ — normal priority;
266
* @LOWEST_PRIORITY@ — the lowest priority;
267
* @HIGHEST_PRIORITY@ — the highest priority.
268
269 1 Mikhail Chupilko
Example:
270 2 Mikhail Chupilko
<pre><code class="cpp">
271 1 Mikhail Chupilko
#include <hw/model.hpp>
272
#include <iostream>
273
CPPTESK_DEFINE_PROCESS(MyModel::internal_process) {
274
    ...
275
    std::cout << "process priority is " << std::dec
276
              << CPPTESK_GET_PRIORITY() << std::end;
277
    ...
278
    CPPTESK_SET_PRIORITY(cpptesk::hw::HIGHEST_PRIORITY);
279
    ...
280
}
281 2 Mikhail Chupilko
</code></pre>
282
283
h3. Modeling of delays
284
285 1 Mikhail Chupilko
To model delays in processes is possible by means of the following macros.
286 2 Mikhail Chupilko
* @CPPTESK_CYCLE()@ - delay of one cycle.
287
* @CPPTESK_DELAY(number_of_cycles)@ - delay of several cycles.
288
* @CPPTESK_WAIT(condition)@ - delay till condition is satisfied.
289
* @CPPTESK_WAIT_TIMEOUT(condition, timeout)@ - limited in time delay till condition is satisfied.
290
291 1 Mikhail Chupilko
Example:
292 2 Mikhail Chupilko
<pre><code class="cpp">
293 1 Mikhail Chupilko
#include <hw/model.hpp>
294
#include <iostream>
295
CPPTESK_DEFINE_PROCESS(MyModel::internal_process) {
296
    ...
297
    std::cout << "cycle: " << std::dec << time() << std::end;
298
    // delay of one cycle
299
    CPPTESK_CYCLE();
300
    std::cout << "cycle: " << std::dec << time() << std::end;
301
    ...
302
    // wait till outputs.ready is true,
303
    // but not more than 100 cycles
304
    CPPTESK_WAIT_TIMEOUT(outputs.ready, 100);
305
    ...
306
}
307 2 Mikhail Chupilko
</code></pre>
308
309
h3. Process calling
310
311
Reference model process calling from another process is made by means of macro @CPPTESK_CALL_PROCESS(mode, process_name, interface, message)@, where mode might be either @PARALLEL@ or @SEQUENTIAL@. In the first case separated process is created, which is executed in parallel with the parent process. In the second case consequent execution is performed, where returning to the parent process execution is possible only after child process has been finished.
312
313 1 Mikhail Chupilko
Example:
314 2 Mikhail Chupilko
<pre><code class="cpp">
315 1 Mikhail Chupilko
#include <hw/model.hpp>
316
CPPTESK_DEFINE_PROCESS(MyModel::some_process) {
317
    ...
318
    // call separated process
319
    CPPTESK_CALL_PROCESS(PARALLEL, internal_process,
320
        CPPTESK_GET_IFACE(), CPPTESK_GET_MESSAGE());
321
    ...
322
    // call process and wait till it has been finished
323
    CPPTESK_CALL_PROCESS(SEQUENTIAL, internal_process,
324
        CPPTESK_GET_IFACE(), CPPTESK_GET_MESSAGE());
325
    ...
326
}
327 2 Mikhail Chupilko
</code></pre>
328
329
*Notice*: to call new processes is possible from any reference model methods, not only from methods describing processes. Macro @CPPTESK_CALL_PARALLEL(process_name, interface, message)@ should be used in this case. Calling process with mode @SEQUENTIAL@ from the method not being a process is prohibited.
330
331
h3. Stimulus receiving
332
333
Inside of the process, receiving of stimulus on one of the input interfaces can be modeled. It is possible by means of macro @CPPTESK_RECV_STIMULUS(mode, interface, message)@. Executing this macro, test system applies the stimulus to the target system via adapter of the correspondent input interface (see chapter _«Input interface adapter»_). Semantics of the mode parameter is described in the chapter _«Process calling»_.
334
335 1 Mikhail Chupilko
Example:
336 2 Mikhail Chupilko
<pre><code class="cpp">
337 1 Mikhail Chupilko
#include <hw/model.hpp>
338
CPPTESK_DEFINE_PROCESS(MyModel::some_process) {
339
    // modeling of stimulus receiving
340
    CPPTESK_RECV_STIMULUS(PARALLEL, input_iface, input_msg);
341
    ...
342
}
343 2 Mikhail Chupilko
</code></pre>
344
345
h3. Reaction sending
346
347
Modeling of reaction sending is done by the macro @CPPTESK_SEND_REACTION(mode, interface, message)@. Executing this macro, test system calls adapter of the correspondent output interface. The adapter starts waiting for the proper implementation reaction. When being received, the reaction is transformed into object of the correspondent message class (see chapter _“Adapter of the output interface”_). Then test system compares reference message with received message by means of comparator (see chapter _“Comparator of output messages”_). Semantics of the mode parameter is described in the chapter _“Process calling”_.
348
349 1 Mikhail Chupilko
Example:
350 2 Mikhail Chupilko
<pre><code class="cpp">
351 1 Mikhail Chupilko
#include <hw/model.hpp>
352
CPPTESK_DEFINE_PROCESS(MyModel::some_process) {
353
    // modeling of reaction sending
354
    CPPTESK_SEND_REACTION(SEQUENTIAL, output_iface, output_msg);
355
    ...
356
}
357 2 Mikhail Chupilko
</code></pre>
358
359
h3. Operation
360
361
Declaration and definition of interface operations of reference model is made by means of macros @CPPTESK_{DECLARE|DEFINE}_STIMULUS(name)@. The definition should start from macro @CPPTESK_START_STIMULUS(mode)@, and stop by macro @CPPTESK_STOP_STIMULUS()@.
362
363 1 Mikhail Chupilko
Example:
364 2 Mikhail Chupilko
<pre><code class="cpp">
365 1 Mikhail Chupilko
#include <hw/model.hpp>
366
CPPTESK_MODEL(MyModel) {
367
public:
368
    CPPTESK_DECLARE_STIMULUS(operation);
369
    ...
370
};
371
372
CPPTESK_DEFINE_STIMULUS(MyModel::operation) {
373
    CPPTESK_START_STIMULUS(PARALLEL);
374
    ...
375
    CPPTESK_STOP_STIMULUS();
376
}
377 2 Mikhail Chupilko
</code></pre>
378
379
*Notice*: operations are particular cases of processes, so that all the constructions from chapter _“Process”_ can be used in them.
380
381
*Notice*: calling macro @CPPTESK_START_STIMULUS(mode)@ is equivalent to the calling macro @CPPTESK_RECV_STIMULUS(mode, ...)@, where interface and message parameters are assigned with correspondent operation parameters.
382
383
h3. Callback function
384
385
In the main class of reference model, several callback functions are defined. The functions can be overloaded in the reference model. The main callback function is @onEveryCycle()@.
386
387
h4. Function onEveryCycle
388
389
Function @onEveryCycle()@ is called at the beginning of each reference model execution cycle.
390
391 1 Mikhail Chupilko
Example:
392 2 Mikhail Chupilko
<pre><code class="cpp">
393 1 Mikhail Chupilko
#include <hw/model.hpp>
394
CPPTESK_MODEL(MyModel) {
395
public:
396
    virtual void onEveryCycle();
397
    ...
398
};
399
400
void MyModel::onEveryCycle() {
401
    std::cout << "onEveryCycle: time=" << std::dec << time() << std::endl;
402
}
403 2 Mikhail Chupilko
</code></pre>
404
405
h2. Development of reference model adapter
406
407
_Reference model adapter_ (_mediator_) is a component of test system, binding reference model with target system. The adapter _serializes_ input message objects into sequences of input signal values, _deserializes_ sequences of output signal values into output message objects, and matches received from target system reactions with reference values.
408
409
h3. Reference model adapter
410
411
Reference model adapter is a subclass of reference model class. It is declared by means of the macro @CPPTESK_ADAPTER(adapter_name, model_name)@.
412
413 1 Mikhail Chupilko
Example:
414 2 Mikhail Chupilko
<pre><code class="cpp">
415 1 Mikhail Chupilko
#include <hw/media.hpp>
416
CPPTESK_ADAPTER(MyAdapter, MyModel) {
417
    ...
418
};
419 2 Mikhail Chupilko
</code></pre>
420
421
_Synchronization methods_, _input_ and _output interface adapters_, _output interface listeners_, and _reaction arbiters_ are declared in reference model adapter.
422
423
h4. Synchronizer
424
425 1 Mikhail Chupilko
Synchronizer is a low-level part of reference model adapter, responsible for synchronization of test system with being tested HDL-model. Synchronizer is implemented by overloading the following five methods of reference model adapter.
426 2 Mikhail Chupilko
* @void initialize()@ — test system initialization;
427
* @void finialize()@ — test system finalization;
428
* @void setInputs()@ — synchronization of inputs;
429
* @void getOutputs()@ — synchronization of outputs;
430
* @void simulate()@ — synchronization of time.
431
432
When hardware models written in Verilog being verified, these methods can be implemented by standard interface VPI (Verilog Procedural Interface). Also, tool VeriTool6 can be used for automation of synchronizer development. In this case, macro @CPPTESK_VERITOOL_ADAPTER(adapter_name, model_name)@ can be used for facilitating of the efforts.
433
434 1 Mikhail Chupilko
Example:
435 2 Mikhail Chupilko
<pre><code class="cpp">
436 1 Mikhail Chupilko
#include <hw/veritool/media.hpp>
437
// file generated by tool VeriTool
438
#include <interface.h>
439
CPPTESK_VERITOOL_ADAPTER(MyAdapter, MyModel) {
440
    ...
441
};
442 2 Mikhail Chupilko
</code></pre>
443
444 1 Mikhail Chupilko
Used for definition of synchronization methods functions and data structures (fields inputs and outputs) are generated automatically by tool VeriTool analyzing Verilog hardware model interface.
445
Notice: when macro CPPTESK_VERITOOL_ADAPTER being used, fields inputs и outputs should not be declared and methods and methods of synchronizer should not be overloaded.
446
Notice: tool VeriTool provides access to values of all HDL-model signals, including internal ones. To get access is possible by means of macros CPPTESK_GET_SIGNAL(signal_type, signal_name) for getting value of signal testbench.target.signal_name (signal_type is meant to be from the following list: int, uint64_t, etc.), and CPPTESK_SET_SIGNAL(signal_type, signal_name, new_value) for setting to a new value the signal testbench.target.signal_name (signal_type is meant to be the same as for getting value macro).
447
Input interface adapter
448
Input interface adapter is a process defined in reference model adapter and bound with one of the input interfaces. Input interface adapter is called by CPPTESK_START_STIMULUS(mode) macro (see chapter “Operation”) or by CPPTESK_RECV_STIMULUS(mode, interface, message) macro (see chapter “Stimulus receiving”). Declaration and definition of input interface adapters are done in typical for processes way.
449
It should be noticed, that just before the serialization, the input interface adapter should capture the interface. Capturing is made by macro CPPTESK_CAPTURE_IFACE(). Correspondently, after the serialization, the interface should be released by macro CPPTESK_RELEASE_IFACE().
450
Example:
451
#include <hw/media.hpp>
452
CPPTESK_ADAPTER(MyAdapter, MyModel) {
453
    CPPTESK_DECLARE_PROCESS(serialize_input);
454
    ...
455
};
456
457
CPPTESK_DEFINE_PROCESS(MyAdapter::serialize_input) {
458
    MyMessage msg = CPPTESK_CAST_MESSAGE(MyMessage);
459
    // start serialization process
460
    CPPTESK_START_PROCESS();
461
    // capture input interface
462
    CPPTESK_CAPTURE_IFACE();
463
    // set operation start strobe
464
    inputs.start = 1;
465
    // set information signals
466
    inputs.addr  = msg.get_addr();
467
    inputs.data  = msg.get_data();
468
    // one cycle delay
469
    CPPTESK_CYCLE();
470
    // reset of operation strobe
471
    inputs.start = 0;
472
    // release input interface
473
    CPPTESK_RELEASE_IFACE();
474
    // stop serialization process
475
    CPPTESK_STOP_PROCESS();
476
}
477
Binding of adapter and interface is made in reference model constructor by means of macro CPPTESK_SET_INPUT_ADAPTER(interface_name, adapter_full_name).
478
Example:
479
MyAdapter::MyAdapter{
480
    CPPTESK_SET_INPUT_ADAPTER(input_iface, MyAdater::serialize_input);
481
    ...
482
};
483
Notice: when input interface adapter being registered, its full name (including the name of reference model adapter class) should be used.
484
Output interface adapter
485
Output interface adapter is a process defined in reference model adapter and bound with one of the output interfaces, Output interface adapter is called by CPPTESK_SEND_REACTION(mode, interface, message) macro (see chapter “Reaction sending”). Declaration and definition of output interface adapters are done by means of the following macros.
486
CPPTESK_WAIT_REACTION(condition)
487
wait for reaction and allow reaction arbiter to access the reaction;
488
CPPTESK_NEXT_REACTION()
489
releasing of reaction arbiter (see chapter “Reaction arbiter”).
490
Example:
491
#include <hw/media.hpp>
492
CPPTESK_ADAPTER(MyAdapter, MyModel) {
493
    CPPTESK_DECLARE_PROCESS(deserialize_output);
494
    ...
495
};
496
497
CPPTESK_DEFINE_PROCESS(MyAdapter::deserialize_input) {
498
    // get reference to the message object
499
    MyMessage &msg = CPPTESK_CAST_MESSAGE(MyMessage);
500
    // start deserialization process
501
    CPPTESK_START_PROCESS();
502
    // wait for result strobe
503
    CPPTESK_WAIT_REACTION(outputs.result);
504
    // read data
505
    msg.set_data(outputs.data);
506
    // release reaction arbiter
507
    CPPTESK_NEXT_REACTION();
508
    // stop deserialization process
509
    CPPTESK_STOP_PROCESS();
510
}
511
The waiting for the implementation reaction time is restricted by a timeout. The timeout is set by macro CPPTESK_SET_REACTION_TIMEOUT(timeout), which as well as macro CPPTESK_SET_OUTPUT_ADAPTER(interface_name, adapter_full_name)is called in constructor of reference model adapter.
512
Example:
513
MyAdapter::MyAdapter{
514
    CPPTESK_SET_OUTPUT_ADAPTER(output_iface, MyAdater::deserialize_output);
515
    CPPTESK_SET_REACTION_TIMEOUT(100);
516
    ...
517
};
518
Notice: when output interface adapter being registered, its full name (including the name of reference model adapter class) should be used.
519
Output interface listener (deprecated feature)
520
Output interface listener is a special-purpose process, waiting for appearing of implementation reactions at the beginning of each cycle, and registering error in case of unexpected reactions. Definition of listeners is made by CPPTESK_DEFINE_BASIC_OUTPUT_LISTENER(name, interface_name, condition) macro.
521
Example:
522
#include <hw/media.hpp>
523
CPPTESK_ADAPTER(MyAdapter, MyModel) {
524
    CPPTESK_DEFINE_BASIC_OUTPUT_LISTENER(output_listener,
525
        output_iface, outputs.result);
526
    ...
527
};
528
Output interface listener is started in constructor of reference model adapter by macro CPPTESK_CALL_OUTPUT_LISTENER(listener_full_name, interface_name).
529
Example:
530
MyAdapter::MyAdapter{
531
    ...
532
    CPPTESK_CALL_OUTPUT_LISTENER(MyAdapter::output_listener, output_iface);
533
    ...
534
};
535
Reaction arbiter
536
Reaction arbiter (output interface arbiter) is aimed for matching implementation reactions (received from HDL-model) with specification reactions (calculated by reference model). Having been matched, the reaction pairs are sent to comparator, showing an error if there is difference in data between two reactions (see chapter “Comparator of output messages”).
537
The common types of arbiters are the following.
538
CPPTESK_FIFO_ARBITER — implementation reaction having been received, the arbiter prefers specification reaction which was created by the earliest among the other reactions call of macro CPPTESK_SEND_REACTION() (see chapter “Reaction sending”).
539
CPPTESK_PRIORITY_ARBITER — the arbiter prefers specification reaction which was created with the highest priority by macro CPPTESK_SEND_REACTION() (see chapter “Process priority”).
540
To declare reaction arbiter in reference model adapter class is possible by means of macro CPPTESK_DECLARE_ARBITER(type, name). To bind arbiter with output interface is possible by means of macro CPPTESK_SET_ARBITER(interface, arbiter), which should be called in constructor of reference model adapter.
541
Example:
542
#include <hw/media.hpp>
543
CPPTESK_ADAPTER(MyAdapter, MyModel) {
544
    CPPTESK_DECLARE_ARBITER(CPPTESK_FIFO_ARBITER, output_iface_arbiter);
545
    ...
546
};
547
548
MyAdapter::MyAdapter() {
549
    CPPTESK_SET_ARBITER(output_iface, output_iface_arbiter);
550
    ...
551
}
552
Test coverage description
553
Test coverage is aimed for evaluation of test completeness. As a rule, test coverage structure is described explicitly by enumerating of all possible in the test situations (test situations). To describe complex test situations, composition of simpler test coverage structures is used.
554
Test coverage can be described in the main class of reference model or moved to external class (test coverage class). In the second case, the class with test coverage description should have a reference to the reference model (see chapter “Test coverage class”).
555
Class of test coverage
556
Class of test coverage is a class containing definition of test coverage structure and functions calculating test situations. As test coverage is defined in terms of reference model, test coverage class should have a reference to the main class of reference model. To trace test situations, test coverage class has test situation tracer — an object of CoverageTracker class (namespace cpptesk::tracer::coverage) and function tracing test situations.
557
Example:
558
#include <ts/coverage.hpp>
559
#include <tracer/tracer.hpp>
560
class MyModel;
561
562
// Declaration of test coverage class
563
class MyCoverage {
564
public:
565
    MyCoverage(MyModel &model): model(model) {}
566
567
    // Test situation tracer
568
    CoverageTracker tracker;
569
570
    // Description of test coverage structure
571
    CPPTESK_DEFINE_ENUMERATED_COVERAGE(MY_COVERAGE, "My coverage", (
572
         (SITUATION_1, "Situation 1"),
573
         ...
574
         (SITUATION_N, "Situation N")
575
    ));
576
577
    // Function calculating test situation: signature of the function
578
    // contains all necessary for it parameters
579
    MY_COVERAGE cov_MY_COVERAGE(...) const;
580
581
    // Function tracing test situations: signature of the function
582
    // is the same as signature of the previous function
583
    void trace_MY_COVERAGE(...);
584
    ...
585
private:
586
    // Reference to the reference model
587
    MyModel &model;
588
};
589
Test coverage structure
590
Test coverage structure is described by means of enumerated coverage, coverage compositions, excluded coverage composition, and test coverage aliases.
591
Enumerated coverage
592
Enumerated coverage, as it goes from the coverage name, is defined by explicit enumeration of all possible test situations by macro CPPTESK_DEFINE_ENUMERATED_COVERAGE(coverage, description, situations), where coverage is an identifier of the coverage type, description is a string, and situations is the list of situations like ((id, description), ...).
593
Example:
594
#include <ts/coverage.hpp>
595
CPPTESK_DEFINE_ENUMERATED_COVERAGE(FIFO_FULLNESS, "FIFO fullness", (
596
    (FIFO_EMPTY, "Empty"),
597
     ...
598
    (FIFO_FULL, "Full")
599
));
600
Coverage composition
601
Coverage composition allows creation of test situation structure basing on two test coverage structures, containing Cartesian product of situations from both initial structures. Coverage composition is made by means of macro CPPTESK_DEFINE_COMPOSED_COVERAGE(type, description, coverage_1, coverage_2). Description of new test situations is made according to the pattern "%s,%s".
602
Example:
603
#include <ts/coverage.hpp>
604
CPPTESK_DEFINE_ENUMERATED_COVERAGE(COVERAGE_A, "Coverage A", (
605
    (A1, "A one"),
606
    (A2, "A two")
607
));
608
609
CPPTESK_DEFINE_ENUMERATED_COVERAGE(COVERAGE_B, "Coverage B", (
610
    (B1, "B one"),
611
    (B2, "B two")
612
));
613
614
// Product of structures A and B makes the following situations:
615
// (COVERAGE_AxB::Id(A1, B1), "A one, B one")
616
// (COVERAGE_AxB::Id(A1, B2), "A one, B two")
617
// (COVERAGE_AxB::Id(A2, B1), "A two, B one")
618
// (COVERAGE_AxB::Id(A2, B2), "A two, B two")
619
CPPTESK_DEFINE_COMPOSED_COVERAGE(COVERAGE_AxB, "Coverage AxB",
620
    COVERAGE_A, COVERAGE_B);
621
Excluded coverage composition
622
To make product of test coverage structures and exclude unreachable test situations is possible by macro CPPTESK_DEFINE_COMPOSED_COVERAGE_EXCLUDING(type, description, coverage_1, coverage_2, excluded), where excluded is the list like ({coverage_1::id, coverage_2::id}, ... ). Instead of test situation identifier, macro ANY() can be used. To product coverage structures being products themselves, correspondent tuples should be used instead of pairs.
623
Example:
624
#include <ts/coverage.hpp>
625
CPPTESK_DEFINE_ENUMERATED_COVERAGE(COVERAGE_A, "Coverage A", (
626
    (A1, "A one"),
627
    (A2, "A two")
628
));
629
630
CPPTESK_DEFINE_ENUMERATED_COVERAGE(COVERAGE_B, "Coverage B", (
631
    (B1, "B one"),
632
    (B2, "B two")
633
));
634
635
// The following composition makes the following test situations:
636
// (COVERAGE_AxB::Id(A1, B2), "A one, B two")
637
// (COVERAGE_AxB::Id(A2, B1), "A two, B one")
638
// (COVERAGE_AxB::Id(A2, B2), "A two, B two")
639
CPPTESK_DEFINE_COMPOSED_COVERAGE_EXCLUDING(COVERAGE_AxB, "Coverage AxB",
640
    COVERAGE_A, COVERAGE_B, ({COVERAGE_A::A1, COVERAGE_B::B1}));
641
Test coverage alias
642
To make a test coverage alias (test coverage with different name, but with the same test situations), macro CPPTESK_DEFINE_ALIAS_COVERAGE(alias, description, coverage) should be used.
643
Example:
644
#include <ts/coverage.hpp>
645
CPPTESK_DEFINE_ENUMERATED_COVERAGE(COVERAGE_A, "Coverage A", (
646
    (A1, "A one"),
647
    (A2, "A two")
648
));
649
650
// COVERAGE_B – alias of COVERAGE_A
651
CPPTESK_DEFINE_ALIAS_COVERAGE(COVERAGE_B, "Coverage B", COVERAGE_A);
652
Calculating current test situation function
653
Calculating current test situation function is a function, which returns identifier of the current test situation (see chapter “Structure of the test coverage”), having analyzed the reference model state and (possibly) input parameters of the operation. Identifier of test situation for enumerated coverage looks like coverage::identifier and class::coverage::identifier when used outside of test coverage class. Calculating current test situation function for production of coverage structures can be obtained by calling functions for particular coverage structures and “production” of their results (operator * should be appropriately overloaded).
654
Example:
655
#include <ts/coverage.hpp>
656
class MyCoverage {
657
    // definition of the enumerated coverage structure COVERAGE_A
658
    CPPTESK_DEFINE_ENUMERATED_COVERAGE(COVERAGE_A, "Coverage A", (
659
        (A1, "A one"),
660
        (A2, "A two")
661
    ));
662
    // test situation calculating function for coverage COVERAGE_A
663
    COVERAGE_A cov_COVERAGE_A(int a) const {
664
        switch(a) {
665
        case 1: return COVERAGE_A::A1;
666
        case 2: return COVERAGE_A::A2;
667
        }
668
        assert(false);
669
    }
670
    
671
    // definition of COVERAGE_B – alias of COVERAGE_A
672
    CPPTESK_DEFINE_ALIAS_COVERAGE(COVERAGE_B, "Coverage B", COVERAGE_A);
673
    // test situation calculating function for coverage COVERAGE_B
674
    COVERAGE_B cov_COVERAGE_B(int b) const {
675
        return cov_COVERAGE_A(b);
676
    }
677
678
    // definition of COVERAGE_AxB – production of COVERAGE_A and COVERAGE_B
679
    CPPTESK_DEFINE_COMPOSED_COVERAGE(COVERAGE_AxB, "Coverage AxB",
680
        COVERAGE_A, COVERAGE_B);s
681
    // test situation calculating function of coverage COVERAGE_AxB
682
    COVERAGE_AxB cov_COVERAGE_AxB(int a, int b) const {
683
        return cov_COVERAGE_A(a) * cov_COVERAGE_B(b);
684
    }
685
    ...
686
};
687
Tracing test situation function
688
Tracing test situation function is defined for each upper-level test coverage structure. As tracing function calls test situation calculating function, their parameters usually coincide. Implementation of this function is based on test situation tracer, being an object of class CoverageTracker (namespace cpptesk::tracer::coverage).
689
Example:
690
#include <ts/coverage.hpp>
691
#include <tracer/tracer.hpp>
692
CoverageTracker tracer;
693
void trace_COVERAGE_A(int a) {
694
    tracer << cov_COVERAGE_A(a);
695
}
696
Development of test scenario
697
Test scenario is a high-level specification of test, which being interpreted by test engine (see chapter “Test scenario running”) is used by test system for test sequence generation. Test scenario is developed as a special class named scenario class.
698
Class of scenario
699
Scenario class is declared by macro CPPTESK_SCENARIO(name).
700
Example:
701
#include <ts/scenario.hpp>
702
CPPTESK_SCENARIO(MyScenario) {
703
    ...
704
private:
705
    // testing is done via reference model adapter
706
    MyAdapter dut;
707
};
708
Test scenario initialization and finalization methods, scenario methods, and current state function are declared in scenario class.
709
Test scenario initialization method
710
Test scenario initialization method includes actions which should have been made right before test start. It is defined by overloading of base class virtual method bool init(int argc, char **argv). It returns true in case of successful initialization and false in case of some problem.
711
Exmple:
712
#include <ts/scenario.hpp>
713
CPPTESK_SCENARIO(MyScenario) {
714
public:
715
    virtual bool init(int argc, char **argv) {
716
        dut.initialize();
717
        std::cout << "Test has started..." << std::endl;
718
    }
719
    ...
720
};
721
Test scenario finalizing method
722
Test scenario finalizing method contains actions which should be done right after test finish. It is defined by overloading of base class virtual method void finish().
723
Example:
724
#include <ts/scenario.hpp>
725
CPPTESK_SCENARIO(MyScenario) {
726
public:
727
    virtual void finish() {
728
        dut.finalize();	
729
        std::cout << "Test has finished..." << std::endl;
730
    }
731
    ...
732
};
733
Scenario method
734
Scenario methods iterate parameters of input messages and run operations by means of reference model adapter. One scenario class may contain several scenario method declarations. Scenario method returns value of bool type, which is interpreted as a flag of some problem. The only parameter of scenario method is an iteration context, which is an object containing variables to be iterated by scenario method (iteration variables). Definition of scenario method starts from calling  macro CPPTESK_ITERATION_BEGIN, and finishes with CPPTESK_ITERATION_END.
735
Example:
736
#include <ts/scenario.hpp>
737
CPPTESK_SCENARIO(MyScenario) {
738
public:
739
    bool scenario(cpptesk::ts::IntCtx &ctx);
740
    ...
741
};
742
743
bool MyScenario::scenario(cpptesk::ts::IntCtx &ctx) {
744
    CPPTESK_ITERATION_BEGIN
745
    ...
746
    CPPTESK_ITERATION_END
747
}
748
Scenario methods are registered by macro CPPTESK_ADD_SCENARIO_METHOD(full_name) in scenario class constructor.
749
Example:
750
MyScenario::MyScenario() {
751
    CPPTESK_ADD_SCENARIO_METHOD(MyScenario::scenario);
752
    ...
753
}
754
Access to iteration variables
755
Iteration variables are fields of iteration context, which is a parameter of scenario method. To access iteration variables is possible by macro CPPTESK_ITERATION_VARIABLE(name), where name is a name of one of the iteration context fields.
756
Example:
757
#include <ts/scenario.hpp>
758
bool MyScenario::scenario(cpptesk::ts::IntCtx &ctx) {
759
    // get reference to iteration variable
760
    int &i = CPPTESK_ITERATION_VARIABLE(i);
761
    CPPTESK_ITERATION_BEGIN
762
    for(i = 0; i < 10; i++) {
763
        ...
764
    }
765
    CPPTESK_ITERATION_END
766
}
767
Test action block
768
Test action (preparation of input message and start of operation) is made in a code block CPPTESK_ITERATION_ACTION{ ... } located in scenario method.
769
Example:
770
#include <ts/scenario.hpp>
771
...
772
CPPTESK_ITERATION_BEGIN
773
for(i = 0; i < 10; i++) {
774
     ...
775
     // test action block
776
     CPPTESK_ITERATION_ACTION {
777
         // input message randomization
778
         CPPTESK_RANDOMIZE_MESSAGE(input_msg);
779
         input_msg.set_addr(i);
780
         // start operation
781
         CPPTESK_CALL_STIMULUS_OF(dut, MyModel::operation,
782
             dut.input_iface, input_msg);
783
         ...
784
     }
785
}
786
CPPTESK_ITERATION_END
787
Scenario action finishing
788
Each iteration of scenario method is finished by CPPTESK_ITERATION_YIELD(verdict) macro, quitting from scenario method. When being called next time, scenario method will continue its execution from next iteration.
789
Example:
790
#include <ts/scenario.hpp>
791
...
792
CPPTESK_ITERATION_BEGIN
793
for(i = 0; i < 10; i++) {
794
     ...
795
     // test action block
796
     CPPTESK_ITERATION_ACTION {
797
         ...
798
         // quit from scenario method and return verdict
799
         CPPTESK_ITERATION_YIELD(dut.verdict());
800
     }
801
}
802
CPPTESK_ITERATION_END
803
Delays
804
Making delays (sending of stimuli at different time of HDL-model simulation) in tests requires development of at least one method with calling reference model method cycle(). In case of possibility of parallel stimulus running, the most convenient way of usage method cycle() is to call this method from purposely created scenario method nop()7. Notice that in this case method cycle() should not be called from any other method.
805
Пример:	
806
#include <ts/scenario.hpp>
807
bool MyScenario::nop(cpptesk::ts::IntCtx& ctx) {
808
    CPPTESK_ITERATION_BEGIN
809
    CPPTESK_ITERATION_ACTION {
810
        dut.cycle();
811
        CPPTESK_ITERATION_YIELD(dut.verdict());
812
    }
813
    CPPTESK_ITERATION_END
814
}
815
Notice: scenario method nop() should be registered before any other scenario methods.
816
Calculating current state function
817
Calculating current state function is needed for test engines, using exploration of target system state graph for creation of test sequences. Returning by function value is interpreted as system state. Type of the returning value and function name are unrestricted. Method does not allow parameters.
818
Example:
819
#include <ts/scenario.hpp>
820
CPPTESK_SCENARIO(MyScenario) {
821
public:
822
    ...
823
    int get_model_state() {
824
        return dut.buffer.size();
825
    }
826
};
827
Setting up of calculating current state function is made by method void setup(...). in test scenario constructor.
828
Example:
829
#include <ts/scenario.hpp>
830
MyScenario::MyScenario() {
831
    setup("My scenario",
832
    UseVirtual::init,
833
    UseVirtual::finish,
834
    &MyScenario::get_model_state);
835
    ...
836
}
837
Test scenario running
838
Test scenario running at local computer is made by calling function localmain(engine, scenario.getTestScenario(), argc, argv) (namespace cpptesk::ts).
839
Available test engines are the following (namespace cpptesk::ts::engine).
840
fsm — generator of test sequence based on state graph exploration;
841
rnd — generator of randomized test sequence.
842
Example:
843
#include <netfsm/engines.hpp>
844
using namespace cpptesk::ts;
845
using namespace cpptesk::ts::engine;
846
...
847
MyScenario scenario;
848
localmain(fsm, scenario.getTestScenario(), argc, argv);
849
Auxiliary possibilities
850
C++TESK toolkit includes the following auxiliary possibilities: assertions and debug print. These possibilities can be used in reference models and in all test system components (adapters, test scenarios, etc). Their main aim is to facilitate debug of test system.
851
Assertions
852
Assertions are predicates (logic constructions) used for description of program properties and, as a rule, checked during runtime. If assertion is violated (predicate shows false), error is fixed and program is stopped. To make assertions is possible by CPPTESK_ASSERTION(predicate, description) macro, where predicate is a checking property, and description is a string describing error bound with violation of this property.
853
Example:
854
#include <hw/assertion.hpp>
855
...
856
CPPTESK_ASSERTION(pointer, "pointer is null");
857
Debug print
858
Debug print is devoted to debug of test system. In contrast to typical printing by means of, e.g., STL streams, adjustment of debug print is easier (turning on/off, changing of printing color, etc).
859
Debug print macros
860
Debug print is commonly made by macro CPPTESK_DEBUG_PRINT(level, message), where level is a level of debug print (see chapter “Debug print levels”) and message is a printing debug message, and macro CPPTESK_DEBUG_PRINTF(level, formal, parameters), where (format, parameters) is a formatted string and values of used in the string parameters in the same format as they are used by C library function printf().
861
Example:
862
#include <hw/debug.hpp>
863
using namespace cpptesk::hw;
864
...
865
CPPTESK_DEBUG_PRINT(DEBUG_USER, "The input message is "
866
    << CPPTESK_GET_MESSAGE());
867
...
868
CPPTESK_DEBUG_PRINTF(DEBUG_USER, "counter=%d", counter);
869
Notice: as a debug message in macro CPPTESK_DEBUG_PRINT() any “stream expression” (allowed for usage in standard C++ STL output streams expressions) can be used.
870
To add location information of debug macro to debug message (file name and string number) is possible by means of macros CPPTESK_DEBUG_PRINT_FILE_LINE() and CPPTESK_DEBUG_PRINTF_FILE_LINE(). Their parameters are the same as of macros mentioned above.
871
Process call stack printing
872
To print process call stack of reference model is possible by macro CPPTESK_CALL_STACK(), which can be used inside and instead of debug message of macro CPPTESK_DEBUG_PRINT().
873
Example:
874
#include <hw/model.hpp>
875
CPPTESK_DEFINE_PROCESS(MyModel::some_process) {
876
    CPPTESK_START_PROCESS();
877
878
    CPPTESK_DEBUG_PRINT(DEBUG_USER, "Call stack is "
879
        << CPPTESK_CALL_STACK());
880
    ...
881
    CPPTESK_STOP_PROCESS();
882
}
883
Notice: macro CPPTESK_CALL_STACK() can be used only inside on reference model.
884
Colored debug print
885
To facilitate manual search of debug messages of a certain type among all debug print is possible by means of colored debug print macros CPPTESK_COLORED_DEBUG_PRINT(level, color, background_color, message), CPPTESK_COLORED_DEBUG_PRINTF(level, color, background_color, format, parameters), and also macros  CPPTESK_COLORED_DEBUG_PRINT_FILE_LINE() and CPPTESK_COLORED_DEBUG_PRINTF_FILE_LINE().
886
The following color constants are defined (namespace cpptesk::hw):
887
BLACK — black;
888
RED — red;
889
GREEN — green;
890
YELLOW — yellow;
891
BLUE — blue;
892
MAGENTA — purple;
893
CYAN — cyan;
894
WHITE — white.
895
Example:
896
#include <hw/debug.hpp>
897
using namespace cpptesk::hw;
898
...
899
CPPTESK_COLORED_DEBUG_PRINT_FILE_LINE(DEBUG_USER, RED, BLACK,
900
    "The input message is " << CPPTESK_GET_MESSAGE());
901
...
902
CPPTESK_COLORED_DEBUG_PRINTF(DEBUG_USER, WHITE, BLACK,
903
    "counter=%d", counter);
904
Controlling indents in debug print
905
To control indents in debug print is possible by CPPTESK_SET_DEBUG_INDENT(indent), CPPTESK_BEGIN_DEBUG_INDENT, and CPPTESK_END_DEBUG_INDENT macros. Macro CPPTESK_SET_DEBUG_INDENT sets indent value (not negative integer) returning its old value. Macros CPPTESK_BEGIN_DEBUG_INDENT and CPPTESK_END_DEBUG_INDENT are used in complementary way: the first one increases indent, the second one decreases indent by one point.
906
Example:
907
#include <hw/debug.hpp>
908
using namespace cpptesk::hw;
909
...
910
unsigned old_indent = CPPTESK_SET_DEBUG_INDENT(2);
911
...
912
CPPTESK_BEGIN_DEBUG_INDENT
913
{
914
    CPPTESK_DEBUG_PRINT(DEBUG_USER, "Some message");
915
    ...
916
}
917
CPPTESK_END_DEBUG_INDENT
918
Debug print levels
919
There is a level of debug message parameter among other debug print parameters. Level characterizes importance of the message. Usually, debug messages of different levels are colored differently. The following debug levels are defined (namespace cpptesk::hw):
920
DEBUG_MORE — detailed debug messages produced by toolkit itself;
921
DEBUG_INFO — basic debug messages produced by toolkit itself;
922
DEBUG_USER — user’s debug messages;
923
DEBUG_WARN — warnings (typically, produced by toolkit itself);
924
DEBUG_FAIL — messages about failures (typically, produced by toolkit itself).
925
The most “important” level is DEBUG_FAIL, then DEBUG_WARN, etc. DEBUG_USER is the only one level for user’s messages.
926
Debug print setting up
927
To set up the volume of debug print messages is possible by selection of debug print level, and only those messages will be printed, which has debug level being not less than selected one. It is done by macro CPPTESK_SET_DEBUG_LEVEL(debug_level, colored). This macro has an additional Boolean parameter colored, turning on/off coloring. Debug level DEBUG_INFO is set by default. Special level DEBUG_NONE can be used to switch off debug print totally.
928
Each debug print level can be assigned with colors for messages of this level. It is done by macro CPPTESK_SET_DEBUG_STYLE(level, tag_color, tag_background_color, color, background_color).
929
Example:
930
#include <hw/model.hpp>
931
using namespace cpptesk::hw;
932
...
933
// reference model constructor
934
MyModel::MyModel() {
935
    // print messages with failures only,
936
    // switch on message coloring
937
    CPPTESK_SET_DEBUG_LEVEL(DEBUG_FAIL, true);
938
    // [FAIL] Error message style.
939
    CPPTESK_SET_DEBUG_STYLE(DEBUG_FAIL, BLACK, RED, RED, BLACK);
940
}