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

Subversion Repositories uart2bus_testbench

[/] [uart2bus_testbench/] [trunk/] [tb/] [uvm_src/] [macros/] [uvm_sequence_defines.svh] - Blame information for rev 16

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 16 HanySalah
//------------------------------------------------------------------------------
2
//   Copyright 2007-2011 Mentor Graphics Corporation
3
//   Copyright 2007-2010 Cadence Design Systems, Inc.
4
//   Copyright 2010 Synopsys, Inc.
5
//   All Rights Reserved Worldwide
6
//
7
//   Licensed under the Apache License, Version 2.0 (the
8
//   "License"); you may not use this file except in
9
//   compliance with the License.  You may obtain a copy of
10
//   the License at
11
//
12
//       http://www.apache.org/licenses/LICENSE-2.0
13
//
14
//   Unless required by applicable law or agreed to in
15
//   writing, software distributed under the License is
16
//   distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
17
//   CONDITIONS OF ANY KIND, either express or implied.  See
18
//   the License for the specific language governing
19
//   permissions and limitations under the License.
20
//------------------------------------------------------------------------------
21
 
22
// Title: Sequence-Related Macros
23
 
24
 
25
 
26
//-----------------------------------------------------------------------------
27
//
28
// Group: Sequence Action Macros
29
//
30
// These macros are used to start sequences and sequence items on the default
31
// sequencer, ~m_sequencer~. This is determined a number of ways.
32
// - the sequencer handle provided in the  method
33
// - the sequencer used by the parent sequence
34
// - the sequencer that was set using the  method
35
//-----------------------------------------------------------------------------
36
 
37
// MACRO: `uvm_create
38
//
39
//| `uvm_create(SEQ_OR_ITEM)
40
//
41
// This action creates the item or sequence using the factory.  It intentionally
42
// does zero processing.  After this action completes, the user can manually set
43
// values, manipulate rand_mode and constraint_mode, etc.
44
 
45
`define uvm_create(SEQ_OR_ITEM) \
46
  `uvm_create_on(SEQ_OR_ITEM, m_sequencer)
47
 
48
 
49
// MACRO: `uvm_do
50
//
51
//| `uvm_do(SEQ_OR_ITEM)
52
//
53
// This macro takes as an argument a uvm_sequence_item variable or object.
54
// The argument is created using <`uvm_create> if necessary,
55
// then randomized.
56
// In the case of an item, it is randomized after the call to
57
//  returns.
58
// This is called late-randomization.
59
// In the case of a sequence, the sub-sequence is started using
60
//  with ~call_pre_post~ set to 0.
61
// In the case of an item,
62
// the item is sent to the driver through the associated sequencer.
63
//
64
// For a sequence item, the following are called, in order
65
//
66
//|
67
//|   `uvm_create(item)
68
//|   sequencer.wait_for_grant(prior) (task)
69
//|   this.pre_do(1)                  (task)
70
//|   item.randomize()
71
//|   this.mid_do(item)               (func)
72
//|   sequencer.send_request(item)    (func)
73
//|   sequencer.wait_for_item_done()  (task)
74
//|   this.post_do(item)              (func)
75
//|
76
//
77
// For a sequence, the following are called, in order
78
//
79
//|
80
//|   `uvm_create(sub_seq)
81
//|   sub_seq.randomize()
82
//|   sub_seq.pre_start()         (task)
83
//|   this.pre_do(0)              (task)
84
//|   this.mid_do(sub_seq)        (func)
85
//|   sub_seq.body()              (task)
86
//|   this.post_do(sub_seq)       (func)
87
//|   sub_seq.post_start()        (task)
88
//|
89
 
90
`define uvm_do(SEQ_OR_ITEM) \
91
  `uvm_do_on_pri_with(SEQ_OR_ITEM, m_sequencer, -1, {})
92
 
93
 
94
// MACRO: `uvm_do_pri
95
//
96
//| `uvm_do_pri(SEQ_OR_ITEM, PRIORITY)
97
//
98
// This is the same as `uvm_do except that the sequence item or sequence is
99
// executed with the priority specified in the argument
100
 
101
`define uvm_do_pri(SEQ_OR_ITEM, PRIORITY) \
102
  `uvm_do_on_pri_with(SEQ_OR_ITEM, m_sequencer, PRIORITY, {})
103
 
104
 
105
// MACRO: `uvm_do_with
106
//
107
//| `uvm_do_with(SEQ_OR_ITEM, CONSTRAINTS)
108
//
109
// This is the same as `uvm_do except that the constraint block in the 2nd
110
// argument is applied to the item or sequence in a randomize with statement
111
// before execution.
112
 
113
`define uvm_do_with(SEQ_OR_ITEM, CONSTRAINTS) \
114
  `uvm_do_on_pri_with(SEQ_OR_ITEM, m_sequencer, -1, CONSTRAINTS)
115
 
116
 
117
// MACRO: `uvm_do_pri_with
118
//
119
//| `uvm_do_pri_with(SEQ_OR_ITEM, PRIORITY, CONSTRAINTS)
120
//
121
// This is the same as `uvm_do_pri except that the given constraint block is
122
// applied to the item or sequence in a randomize with statement before
123
// execution.
124
 
125
`define uvm_do_pri_with(SEQ_OR_ITEM, PRIORITY, CONSTRAINTS) \
126
  `uvm_do_on_pri_with(SEQ_OR_ITEM, m_sequencer, PRIORITY, CONSTRAINTS)
127
 
128
 
129
//-----------------------------------------------------------------------------
130
//
131
// Group: Sequence on Sequencer Action Macros
132
//
133
// These macros are used to start sequences and sequence items on a specific
134
// sequencer. The sequence or item is created and executed on the given
135
// sequencer.
136
//-----------------------------------------------------------------------------
137
 
138
// MACRO: `uvm_create_on
139
//
140
//| `uvm_create_on(SEQ_OR_ITEM, SEQR)
141
//
142
// This is the same as <`uvm_create> except that it also sets the parent sequence
143
// to the sequence in which the macro is invoked, and it sets the sequencer to
144
// the specified ~SEQR~ argument.
145
 
146
`define uvm_create_on(SEQ_OR_ITEM, SEQR) \
147
  begin \
148
  uvm_object_wrapper w_; \
149
  w_ = SEQ_OR_ITEM.get_type(); \
150
  $cast(SEQ_OR_ITEM , create_item(w_, SEQR, `"SEQ_OR_ITEM`"));\
151
  end
152
 
153
 
154
// MACRO: `uvm_do_on
155
//
156
//| `uvm_do_on(SEQ_OR_ITEM, SEQR)
157
//
158
// This is the same as <`uvm_do> except that it also sets the parent sequence to
159
// the sequence in which the macro is invoked, and it sets the sequencer to the
160
// specified ~SEQR~ argument.
161
 
162
`define uvm_do_on(SEQ_OR_ITEM, SEQR) \
163
  `uvm_do_on_pri_with(SEQ_OR_ITEM, SEQR, -1, {})
164
 
165
 
166
// MACRO: `uvm_do_on_pri
167
//
168
//| `uvm_do_on_pri(SEQ_OR_ITEM, SEQR, PRIORITY)
169
//
170
// This is the same as <`uvm_do_pri> except that it also sets the parent sequence
171
// to the sequence in which the macro is invoked, and it sets the sequencer to
172
// the specified ~SEQR~ argument.
173
 
174
`define uvm_do_on_pri(SEQ_OR_ITEM, SEQR, PRIORITY) \
175
  `uvm_do_on_pri_with(SEQ_OR_ITEM, SEQR, PRIORITY, {})
176
 
177
 
178
// MACRO: `uvm_do_on_with
179
//
180
//| `uvm_do_on_with(SEQ_OR_ITEM, SEQR, CONSTRAINTS)
181
//
182
// This is the same as <`uvm_do_with> except that it also sets the parent
183
// sequence to the sequence in which the macro is invoked, and it sets the
184
// sequencer to the specified ~SEQR~ argument.
185
// The user must supply brackets around the constraints.
186
 
187
`define uvm_do_on_with(SEQ_OR_ITEM, SEQR, CONSTRAINTS) \
188
  `uvm_do_on_pri_with(SEQ_OR_ITEM, SEQR, -1, CONSTRAINTS)
189
 
190
 
191
// MACRO: `uvm_do_on_pri_with
192
//
193
//| `uvm_do_on_pri_with(SEQ_OR_ITEM, SEQR, PRIORITY, CONSTRAINTS)
194
//
195
// This is the same as `uvm_do_pri_with except that it also sets the parent
196
// sequence to the sequence in which the macro is invoked, and it sets the
197
// sequencer to the specified ~SEQR~ argument.
198
 
199
`define uvm_do_on_pri_with(SEQ_OR_ITEM, SEQR, PRIORITY, CONSTRAINTS) \
200
  begin \
201
  uvm_sequence_base __seq; \
202
  `uvm_create_on(SEQ_OR_ITEM, SEQR) \
203
  if (!$cast(__seq,SEQ_OR_ITEM)) start_item(SEQ_OR_ITEM, PRIORITY);\
204
  if ((__seq == null || !__seq.do_not_randomize) && !SEQ_OR_ITEM.randomize() with CONSTRAINTS ) begin \
205
    `uvm_warning("RNDFLD", "Randomization failed in uvm_do_with action") \
206
  end\
207
  if (!$cast(__seq,SEQ_OR_ITEM)) finish_item(SEQ_OR_ITEM, PRIORITY); \
208
  else __seq.start(SEQR, this, PRIORITY, 0); \
209
  end
210
 
211
 
212
//-----------------------------------------------------------------------------
213
//
214
// Group: Sequence Action Macros for Pre-Existing Sequences
215
//
216
// These macros are used to start sequences and sequence items that do not
217
// need to be created.
218
//-----------------------------------------------------------------------------
219
 
220
 
221
// MACRO: `uvm_send
222
//
223
//| `uvm_send(SEQ_OR_ITEM)
224
//
225
// This macro processes the item or sequence that has been created using
226
// `uvm_create.  The processing is done without randomization.  Essentially, an
227
// `uvm_do without the create or randomization.
228
 
229
`define uvm_send(SEQ_OR_ITEM) \
230
  `uvm_send_pri(SEQ_OR_ITEM, -1)
231
 
232
 
233
// MACRO: `uvm_send_pri
234
//
235
//| `uvm_send_pri(SEQ_OR_ITEM, PRIORITY)
236
//
237
// This is the same as `uvm_send except that the sequence item or sequence is
238
// executed with the priority specified in the argument.
239
 
240
`define uvm_send_pri(SEQ_OR_ITEM, PRIORITY) \
241
  begin \
242
  uvm_sequence_base __seq; \
243
  if (!$cast(__seq,SEQ_OR_ITEM)) begin \
244
     start_item(SEQ_OR_ITEM, PRIORITY);\
245
     finish_item(SEQ_OR_ITEM, PRIORITY);\
246
  end \
247
  else __seq.start(__seq.get_sequencer(), this, PRIORITY, 0);\
248
  end
249
 
250
 
251
// MACRO: `uvm_rand_send
252
//
253
//| `uvm_rand_send(SEQ_OR_ITEM)
254
//
255
// This macro processes the item or sequence that has been already been
256
// allocated (possibly with `uvm_create). The processing is done with
257
// randomization.  Essentially, an `uvm_do without the create.
258
 
259
`define uvm_rand_send(SEQ_OR_ITEM) \
260
  `uvm_rand_send_pri_with(SEQ_OR_ITEM, -1, {})
261
 
262
 
263
// MACRO: `uvm_rand_send_pri
264
//
265
//| `uvm_rand_send_pri(SEQ_OR_ITEM, PRIORITY)
266
//
267
// This is the same as `uvm_rand_send except that the sequence item or sequence
268
// is executed with the priority specified in the argument.
269
 
270
`define uvm_rand_send_pri(SEQ_OR_ITEM, PRIORITY) \
271
  `uvm_rand_send_pri_with(SEQ_OR_ITEM, PRIORITY, {})
272
 
273
 
274
// MACRO: `uvm_rand_send_with
275
//
276
//| `uvm_rand_send_with(SEQ_OR_ITEM, CONSTRAINTS)
277
//
278
// This is the same as `uvm_rand_send except that the given constraint block is
279
// applied to the item or sequence in a randomize with statement before
280
// execution.
281
 
282
`define uvm_rand_send_with(SEQ_OR_ITEM, CONSTRAINTS) \
283
  `uvm_rand_send_pri_with(SEQ_OR_ITEM, -1, CONSTRAINTS)
284
 
285
 
286
// MACRO: `uvm_rand_send_pri_with
287
//
288
//| `uvm_rand_send_pri_with(SEQ_OR_ITEM, PRIORITY, CONSTRAINTS)
289
//
290
// This is the same as `uvm_rand_send_pri except that the given constraint block
291
// is applied to the item or sequence in a randomize with statement before
292
// execution.
293
 
294
`define uvm_rand_send_pri_with(SEQ_OR_ITEM, PRIORITY, CONSTRAINTS) \
295
  begin \
296
  uvm_sequence_base __seq; \
297
  if (!$cast(__seq,SEQ_OR_ITEM)) start_item(SEQ_OR_ITEM, PRIORITY);\
298
  else __seq.set_item_context(this,SEQ_OR_ITEM.get_sequencer()); \
299
  if ((__seq == null || !__seq.do_not_randomize) && !SEQ_OR_ITEM.randomize() with CONSTRAINTS ) begin \
300
    `uvm_warning("RNDFLD", "Randomization failed in uvm_rand_send_with action") \
301
  end\
302
  if (!$cast(__seq,SEQ_OR_ITEM)) finish_item(SEQ_OR_ITEM, PRIORITY);\
303
  else __seq.start(__seq.get_sequencer(), this, PRIORITY, 0);\
304
  end
305
 
306
 
307
`define uvm_create_seq(UVM_SEQ, SEQR_CONS_IF) \
308
  `uvm_create_on(UVM_SEQ, SEQR_CONS_IF.consumer_seqr) \
309
 
310
`define uvm_do_seq(UVM_SEQ, SEQR_CONS_IF) \
311
  `uvm_do_on(UVM_SEQ, SEQR_CONS_IF.consumer_seqr) \
312
 
313
`define uvm_do_seq_with(UVM_SEQ, SEQR_CONS_IF, CONSTRAINTS) \
314
  `uvm_do_on_with(UVM_SEQ, SEQR_CONS_IF.consumer_seqr, CONSTRAINTS) \
315
 
316
 
317
 
318
//-----------------------------------------------------------------------------
319
//
320
// Group- Sequence Library
321
//
322
//-----------------------------------------------------------------------------
323
 
324
 
325
// MACRO: `uvm_add_to_sequence_library
326
//
327
// Adds the given sequence ~TYPE~ to the given sequence library ~LIBTYPE~
328
//
329
//| `uvm_add_to_seq_lib(TYPE,LIBTYPE)
330
//
331
// Invoke any number of times within a sequence declaration to statically add
332
// that sequence to one or more sequence library types. The sequence will then
333
// be available for selection and execution in all instances of the given
334
// sequencer types.
335
//
336
//| class seqA extends uvm_sequence_base #(simple_item);
337
//|
338
//|    function new(string name=`"TYPE`");
339
//|      super.new(name);
340
//|    endfunction
341
//|
342
//|    `uvm_object_utils(seqA)
343
//|
344
//|    `uvm_add_to_seq_lib(seqA, simple_seq_lib_RST)
345
//|    `uvm_add_to_seq_lib(seqA, simple_seq_lib_CFG)
346
//|
347
//|    virtual task body(); \
348
//|      `uvm_info("SEQ_START", {"Executing sequence '", get_full_name(),
349
//|                             "' (",get_type_name(),")"},UVM_HIGH)
350
//|      #10;
351
//|    endtask
352
//|
353
//|  endclass
354
 
355
 
356
`define uvm_add_to_seq_lib(TYPE,LIBTYPE) \
357
   static bit add_``TYPE``_to_seq_lib_``LIBTYPE =\
358
      LIBTYPE::m_add_typewide_sequence(TYPE::get_type());
359
 
360
 
361
 
362
// MACRO: `uvm_sequence_library_utils
363
//
364
//| `uvm_sequence_library_utils(TYPE)
365
//
366
// Declares the infrastructure needed to define extensions to the
367
//  class. You define new sequence library subtypes
368
// to statically specify sequence membership from within sequence
369
// definitions. See also <`uvm_add_to_sequence_library> for more information.
370
//
371
//
372
//| typedef simple_seq_lib uvm_sequence_library #(simple_item);
373
//|
374
//| class simple_seq_lib_RST extends simple_seq_lib;
375
//|
376
//|   `uvm_object_utils(simple_seq_lib_RST)
377
//|
378
//|   `uvm_sequence_library_utils(simple_seq_lib_RST)
379
//|
380
//|   function new(string name="");
381
//|     super.new(name);
382
//|   endfunction
383
//|
384
//| endclass
385
//
386
// Each library, itself a sequence, can then be started independently
387
// on different sequencers or in different phases of the same sequencer.
388
// See  for information on
389
// starting default sequences.
390
 
391
`define uvm_sequence_library_utils(TYPE) \
392
\
393
   static protected uvm_object_wrapper m_typewide_sequences[$]; \
394
   \
395
   function void init_sequence_library(); \
396
     foreach (TYPE::m_typewide_sequences[i]) \
397
       sequences.push_back(TYPE::m_typewide_sequences[i]); \
398
   endfunction \
399
   \
400
   static function void add_typewide_sequence(uvm_object_wrapper seq_type); \
401
     if (m_static_check(seq_type)) \
402
       TYPE::m_typewide_sequences.push_back(seq_type); \
403
   endfunction \
404
   \
405
   static function void add_typewide_sequences(uvm_object_wrapper seq_types[$]); \
406
     foreach (seq_types[i]) \
407
       TYPE::add_typewide_sequence(seq_types[i]); \
408
   endfunction \
409
   \
410
   static function bit m_add_typewide_sequence(uvm_object_wrapper seq_type); \
411
     TYPE::add_typewide_sequence(seq_type); \
412
     return 1; \
413
   endfunction
414
 
415
 
416
 
417
//-----------------------------------------------------------------------------
418
//
419
// Group: Sequencer Subtypes
420
//
421
//-----------------------------------------------------------------------------
422
 
423
 
424
// MACRO: `uvm_declare_p_sequencer
425
//
426
// This macro is used to declare a variable ~p_sequencer~ whose type is
427
// specified by ~SEQUENCER~.
428
//
429
//| `uvm_declare_p_sequencer(SEQUENCER)
430
//
431
// The example below shows using the `uvm_declare_p_sequencer macro
432
// along with the uvm_object_utils macros to set up the sequence but
433
// not register the sequence in the sequencer's library.
434
//
435
//| class mysequence extends uvm_sequence#(mydata);
436
//|   `uvm_object_utils(mysequence)
437
//|   `uvm_declare_p_sequencer(some_seqr_type)
438
//|   task body;
439
//|     //Access some variable in the user's custom sequencer
440
//|     if(p_sequencer.some_variable) begin
441
//|       ...
442
//|     end
443
//|   endtask
444
//| endclass
445
//
446
 
447
`define uvm_declare_p_sequencer(SEQUENCER) \
448
  SEQUENCER p_sequencer;\
449
  virtual function void m_set_p_sequencer();\
450
    super.m_set_p_sequencer(); \
451
    if( !$cast(p_sequencer, m_sequencer)) \
452
        `uvm_fatal("DCLPSQ", \
453
        $sformatf("%m %s Error casting p_sequencer, please verify that this sequence/sequence item is intended to execute on this type of sequencer", get_full_name())) \
454
  endfunction
455
 

powered by: WebSVN 2.1.0

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