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

Subversion Repositories uart2bus_testbench

[/] [uart2bus_testbench/] [trunk/] [tb/] [uvm_src/] [base/] [uvm_cmdline_processor.svh] - Blame information for rev 16

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 16 HanySalah
//
2
//------------------------------------------------------------------------------
3
//   Copyright 2011 Mentor Graphics Corporation
4
//   Copyright 2011 Cadence Design Systems, Inc.
5
//   Copyright 2011 Synopsys, Inc.
6
//   Copyright 2013 NVIDIA Corporation
7
//   All Rights Reserved Worldwide
8
//
9
//   Licensed under the Apache License, Version 2.0 (the
10
//   "License"); you may not use this file except in
11
//   compliance with the License.  You may obtain a copy of
12
//   the License at
13
//
14
//       http://www.apache.org/licenses/LICENSE-2.0
15
//
16
//   Unless required by applicable law or agreed to in
17
//   writing, software distributed under the License is
18
//   distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
19
//   CONDITIONS OF ANY KIND, either express or implied.  See
20
//   the License for the specific language governing
21
//   permissions and limitations under the License.
22
//------------------------------------------------------------------------------
23
 
24
`ifndef UVM_CMDLINE_PROCESSOR_SV
25
`define UVM_CMDLINE_PROCESSOR_SV
26
 
27
class uvm_cmd_line_verb;
28
  string comp_path;
29
  string id;
30
  uvm_verbosity verb;
31
  int exec_time;
32
endclass
33
 
34
// Class: uvm_cmdline_processor
35
//
36
// This class provides an interface to the command line arguments that
37
// were provided for the given simulation.  The class is intended to be
38
// used as a singleton, but that isn't required.  The generation of the
39
// data structures which hold the command line argument information
40
// happens during construction of the class object.  A global variable
41
// called ~uvm_cmdline_proc~ is created at initialization time and may
42
// be used to access command line information.
43
//
44
// The uvm_cmdline_processor class also provides support for setting various UVM
45
// variables from the command line such as components' verbosities and configuration
46
// settings for integral types and strings.  Each of these capabilities is described
47
// in the Built-in UVM Aware Command Line Arguments section.
48
//
49
 
50
class uvm_cmdline_processor extends uvm_report_object;
51
 
52
  static local uvm_cmdline_processor m_inst;
53
 
54
  // Group: Singleton
55
 
56
  // Function: get_inst
57
  //
58
  // Returns the singleton instance of the UVM command line processor.
59
 
60
  static function uvm_cmdline_processor get_inst();
61
    if(m_inst == null)
62
      m_inst = new("uvm_cmdline_proc");
63
    return m_inst;
64
  endfunction
65
 
66
  protected string m_argv[$];
67
  protected string m_plus_argv[$];
68
  protected string m_uvm_argv[$];
69
 
70
  // Group: Basic Arguments
71
 
72
  // Function: get_args
73
  //
74
  // This function returns a queue with all of the command line
75
  // arguments that were used to start the simulation. Note that
76
  // element 0 of the array will always be the name of the
77
  // executable which started the simulation.
78
 
79
  function void get_args (output string args[$]);
80
    args = m_argv;
81
  endfunction
82
 
83
  // Function: get_plusargs
84
  //
85
  // This function returns a queue with all of the plus arguments
86
  // that were used to start the simulation. Plusarguments may be
87
  // used by the simulator vendor, or may be specific to a company
88
  // or individual user. Plusargs never have extra arguments
89
  // (i.e. if there is a plusarg as the second argument on the
90
  // command line, the third argument is unrelated); this is not
91
  // necessarily the case with vendor specific dash arguments.
92
 
93
  function void get_plusargs (output string args[$]);
94
    args = m_plus_argv;
95
  endfunction
96
 
97
  // Function: get_uvmargs
98
  //
99
  // This function returns a queue with all of the uvm arguments
100
  // that were used to start the simulation. A UVM argument is
101
  // taken to be any argument that starts with a - or + and uses
102
  // the keyword UVM (case insensitive) as the first three
103
  // letters of the argument.
104
 
105
  function void get_uvm_args (output string args[$]);
106
    args = m_uvm_argv;
107
  endfunction
108
 
109
  // Function: get_arg_matches
110
  //
111
  // This function loads a queue with all of the arguments that
112
  // match the input expression and returns the number of items
113
  // that matched. If the input expression is bracketed
114
  // with //, then it is taken as an extended regular expression
115
  // otherwise, it is taken as the beginning of an argument to match.
116
  // For example:
117
  //
118
  //| string myargs[$]
119
  //| initial begin
120
  //|    void'(uvm_cmdline_proc.get_arg_matches("+foo",myargs)); //matches +foo, +foobar
121
  //|                                                            //doesn't match +barfoo
122
  //|    void'(uvm_cmdline_proc.get_arg_matches("/foo/",myargs)); //matches +foo, +foobar,
123
  //|                                                             //foo.sv, barfoo, etc.
124
  //|    void'(uvm_cmdline_proc.get_arg_matches("/^foo.*\.sv",myargs)); //matches foo.sv
125
  //|                                                                   //and foo123.sv,
126
  //|                                                                   //not barfoo.sv.
127
 
128
  function int get_arg_matches (string match, ref string args[$]);
129
 
130
   `ifndef UVM_CMDLINE_NO_DPI
131
    chandle exp_h = null;
132
    int len = match.len();
133
    args.delete();
134
    if((match.len() > 2) && (match[0] == "/") && (match[match.len()-1] == "/")) begin
135
       match = match.substr(1,match.len()-2);
136
       exp_h = uvm_dpi_regcomp(match);
137
       if(exp_h == null) begin
138
         uvm_report_error("UVM_CMDLINE_PROC", {"Unable to compile the regular expression: ", match}, UVM_NONE);
139
         return 0;
140
       end
141
    end
142
    foreach (m_argv[i]) begin
143
      if(exp_h != null) begin
144
        if(!uvm_dpi_regexec(exp_h, m_argv[i]))
145
           args.push_back(m_argv[i]);
146
      end
147
      else if((m_argv[i].len() >= len) && (m_argv[i].substr(0,len - 1) == match))
148
        args.push_back(m_argv[i]);
149
    end
150
 
151
    if(exp_h != null)
152
      uvm_dpi_regfree(exp_h);
153
    `endif
154
 
155
    return args.size();
156
  endfunction
157
 
158
 
159
  // Group: Argument Values
160
 
161
  // Function: get_arg_value
162
  //
163
  // This function finds the first argument which matches the ~match~ arg and
164
  // returns the suffix of the argument. This is similar to the $value$plusargs
165
  // system task, but does not take a formatting string. The return value is
166
  // the number of command line arguments that match the ~match~ string, and
167
  // ~value~ is the value of the first match.
168
 
169
  function int get_arg_value (string match, ref string value);
170
    int chars = match.len();
171
    get_arg_value = 0;
172
    foreach (m_argv[i]) begin
173
      if(m_argv[i].len() >= chars) begin
174
        if(m_argv[i].substr(0,chars-1) == match) begin
175
          get_arg_value++;
176
          if(get_arg_value == 1)
177
            value = m_argv[i].substr(chars,m_argv[i].len()-1);
178
        end
179
      end
180
    end
181
  endfunction
182
 
183
  // Function: get_arg_values
184
  //
185
  // This function finds all the arguments which matches the ~match~ arg and
186
  // returns the suffix of the arguments in a list of values. The return
187
  // value is the number of matches that were found (it is the same as
188
  // values.size() ).
189
  // For example if '+foo=1,yes,on +foo=5,no,off' was provided on the command
190
  // line and the following code was executed:
191
  //
192
  //| string foo_values[$]
193
  //| initial begin
194
  //|    void'(uvm_cmdline_proc.get_arg_values("+foo=",foo_values));
195
  //|
196
  //
197
  // The foo_values queue would contain two entries.  These entries are shown
198
  // here:
199
  //
200
  //   0 - "1,yes,on"
201
  //   1 - "5,no,off"
202
  //
203
  // Splitting the resultant string is left to user but using the
204
  // uvm_split_string() function is recommended.
205
 
206
  function int get_arg_values (string match, ref string values[$]);
207
    int chars = match.len();
208
 
209
    values.delete();
210
    foreach (m_argv[i]) begin
211
      if(m_argv[i].len() >= chars) begin
212
        if(m_argv[i].substr(0,chars-1) == match)
213
          values.push_back(m_argv[i].substr(chars,m_argv[i].len()-1));
214
      end
215
    end
216
    return values.size();
217
  endfunction
218
 
219
  // Group: Tool information
220
 
221
  // Function: get_tool_name
222
  //
223
  // Returns the simulation tool that is executing the simulation.
224
  // This is a vendor specific string.
225
 
226
  function string get_tool_name ();
227
    return uvm_dpi_get_tool_name();
228
  endfunction
229
 
230
  // Function: get_tool_version
231
  //
232
  // Returns the version of the simulation tool that is executing the simulation.
233
  // This is a vendor specific string.
234
 
235
  function string  get_tool_version ();
236
    return uvm_dpi_get_tool_version();
237
  endfunction
238
 
239
  // constructor
240
 
241
  function new(string name = "");
242
    string s;
243
    string sub;
244
    int doInit=1;
245
    super.new(name);
246
    do begin
247
      s = uvm_dpi_get_next_arg(doInit);
248
      doInit=0;
249
      if(s!="") begin
250
        m_argv.push_back(s);
251
        if(s[0] == "+") begin
252
          m_plus_argv.push_back(s);
253
        end
254
        if(s.len() >= 4 && (s[0]=="-" || s[0]=="+")) begin
255
          sub = s.substr(1,3);
256
          sub = sub.toupper();
257
          if(sub == "UVM")
258
            m_uvm_argv.push_back(s);
259
        end
260
      end
261
    end while(s!="");
262
 
263
    // Group: Command Line Debug
264
 
265
    // Variable: +UVM_DUMP_CMDLINE_ARGS
266
    //
267
    // ~+UVM_DUMP_CMDLINE_ARGS~ allows the user to dump all command line arguments to the
268
    // reporting mechanism.  The output in is tree format.
269
 
270
    // The implementation of this is in uvm_root.
271
 
272
    // Group: Built-in UVM Aware Command Line Arguments
273
 
274
    // Variable: +UVM_TESTNAME
275
    //
276
    // ~+UVM_TESTNAME=~ allows the user to specify which uvm_test (or
277
    // uvm_component) should be created via the factory and cycled through the UVM phases.
278
    // If multiple of these settings are provided, the first occurrence is used and a warning
279
    // is issued for subsequent settings.  For example:
280
    //
281
    //|  +UVM_TESTNAME=read_modify_write_test
282
    //
283
 
284
    // The implementation of this is in uvm_root since this is procedurally invoked via
285
    // ovm_root::run_test().
286
 
287
    // Variable: +UVM_VERBOSITY
288
    //
289
    // ~+UVM_VERBOSITY=~ allows the user to specify the initial verbosity
290
    // for all components.  If multiple of these settings are provided, the first occurrence
291
    // is used and a warning is issued for subsequent settings.  For example:
292
    //
293
    //|  +UVM_VERBOSITY=UVM_HIGH
294
    //
295
 
296
    // The implementation of this is in uvm_root since this is procedurally invoked via
297
    // ovm_root::new().
298
 
299
    // Variable: +uvm_set_verbosity
300
    //
301
    // ~+uvm_set_verbosity=,,,~ and
302
    // ~+uvm_set_verbosity=,,,time,
303
    // verbosity of specific components at specific phases (and times during the "run" phases)
304
    // of the simulation.  The ~id~ argument can be either ~_ALL_~ for all IDs or a
305
    // specific message id.  Wildcarding is not supported for ~id~ due to performance concerns.
306
    // Settings for non-"run" phases are executed in order of occurrence on the command line.
307
    // Settings for "run" phases (times) are sorted by time and then executed in order of
308
    // occurrence for settings of the same time.  For example:
309
    //
310
    //|  +uvm_set_verbosity=uvm_test_top.env0.agent1.*,_ALL_,UVM_FULL,time,800
311
    //
312
 
313
    // Variable: +uvm_set_action
314
    //
315
    // ~+uvm_set_action=,,,~ provides the equivalent of
316
    // various uvm_report_object's set_report_*_action APIs.  The special keyword,
317
    // ~_ALL_~, can be provided for both/either the ~id~ and/or ~severity~ arguments.  The
318
    // action can be UVM_NO_ACTION or a | separated list of the other UVM message
319
    // actions.  For example:
320
    //
321
    //|  +uvm_set_action=uvm_test_top.env0.*,_ALL_,UVM_ERROR,UVM_NO_ACTION
322
    //
323
 
324
    // Variable: +uvm_set_severity
325
    //
326
    // ~+uvm_set_severity=,,,~ provides the
327
    // equivalent of the various uvm_report_object's set_report_*_severity_override APIs. The
328
    // special keyword, ~_ALL_~, can be provided for both/either the ~id~ and/or
329
    // ~current severity~ arguments.  For example:
330
    //
331
    //|  +uvm_set_severity=uvm_test_top.env0.*,BAD_CRC,UVM_ERROR,UVM_WARNING
332
    //
333
 
334
    // Variable: +UVM_TIMEOUT
335
    //
336
    // ~+UVM_TIMEOUT=,~ allows users to change the global timeout of the UVM
337
    // framework.  The  argument ('YES' or 'NO') specifies whether user code can subsequently
338
    // change this value.  If set to 'NO' and the user code tries to change the global timeout value, an
339
    // warning message will be generated.
340
    //
341
    //|  +UVM_TIMEOUT=200000,NO
342
    //
343
 
344
    // The implementation of this is in uvm_root.
345
 
346
    // Variable: +UVM_MAX_QUIT_COUNT
347
    //
348
    // ~+UVM_MAX_QUIT_COUNT=,~ allows users to change max quit count for the report
349
    // server.  The  argument ('YES' or 'NO') specifies whether user code can subsequently
350
    // change this value.  If set to 'NO' and the user code tries to change the max quit count value, an
351
    // warning message will be generated.
352
    //
353
    //|  +UVM_MAX_QUIT_COUNT=5,NO
354
    //
355
 
356
 
357
    // Variable: +UVM_PHASE_TRACE
358
    //
359
    // ~+UVM_PHASE_TRACE~ turns on tracing of phase executions.  Users simply need to put the
360
    // argument on the command line.
361
 
362
    // Variable: +UVM_OBJECTION_TRACE
363
    //
364
    // ~+UVM_OBJECTION_TRACE~ turns on tracing of objection activity.  Users simply need to put the
365
    // argument on the command line.
366
 
367
    // Variable: +UVM_RESOURCE_DB_TRACE
368
    //
369
    // ~+UVM_RESOURCE_DB_TRACE~ turns on tracing of resource DB access.
370
    // Users simply need to put the argument on the command line.
371
 
372
    // Variable: +UVM_CONFIG_DB_TRACE
373
    //
374
    // ~+UVM_CONFIG_DB_TRACE~ turns on tracing of configuration DB access.
375
    // Users simply need to put the argument on the command line.
376
 
377
    // Variable: +uvm_set_inst_override
378
 
379
    // Variable: +uvm_set_type_override
380
    //
381
    // ~+uvm_set_inst_override=,,~ and
382
    // ~+uvm_set_type_override=,[,]~ work
383
    // like the name based overrides in the factory--factory.set_inst_override_by_name()
384
    //  and factory.set_type_override_by_name().
385
    // For uvm_set_type_override, the third argument is 0 or 1 (the default is
386
    // 1 if this argument is left off); this argument specifies whether previous
387
    // type overrides for the type should be replaced.  For example:
388
    //
389
    //|  +uvm_set_type_override=eth_packet,short_eth_packet
390
    //
391
 
392
    // The implementation of this is in uvm_root.
393
 
394
    // Variable: +uvm_set_config_int
395
 
396
    // Variable: +uvm_set_config_string
397
    //
398
    // ~+uvm_set_config_int=,,~ and
399
    // ~+uvm_set_config_string=,,~ work like their
400
    // procedural counterparts: set_config_int() and set_config_string(). For
401
    // the value of int config settings, 'b (0b), 'o, 'd, 'h ('x or 0x)
402
    // as the first two characters of the value are treated as base specifiers
403
    // for interpreting the base of the number. Size specifiers are not used
404
    // since SystemVerilog does not allow size specifiers in string to
405
    // value conversions.  For example:
406
    //
407
    //|  +uvm_set_config_int=uvm_test_top.soc_env,mode,5
408
    //
409
    // No equivalent of set_config_object() exists since no way exists to pass a
410
    // uvm_object into the simulation via the command line.
411
    //
412
 
413
    // The implementation of this is in uvm_root.
414
 
415
    // Variable: +uvm_set_default_sequence
416
    //
417
    // The ~+uvm_set_default_sequence=,,~ plusarg allows
418
    // the user to define a default sequence from the command line, using the
419
    // ~typename~ of that sequence.  For example:
420
    //
421
    //|  +uvm_set_default_sequence=path.to.sequencer,main_phase,seq_type
422
    //
423
    // This is functionally equivalent to calling the following in your
424
    // test:
425
    //
426
    //| uvm_coreservice_t cs = uvm_coreservice_t::get();
427
    //| uvm_factory f = cs.get_factory();
428
    //| uvm_config_db#(uvm_object_wrapper)::set(this,
429
    //|                                         "path.to.sequencer.main_phase",
430
    //|                                         "default_sequence",
431
    //|                                         f.find_wrapper_by_name("seq_type"));
432
    //
433
 
434
 
435
    // The implementation of this is in uvm_root.
436
  endfunction
437
 
438
  function bit m_convert_verb(string verb_str, output uvm_verbosity verb_enum);
439
    case (verb_str)
440
      "NONE"       : begin verb_enum = UVM_NONE;   return 1; end
441
      "UVM_NONE"   : begin verb_enum = UVM_NONE;   return 1; end
442
      "LOW"        : begin verb_enum = UVM_LOW;    return 1; end
443
      "UVM_LOW"    : begin verb_enum = UVM_LOW;    return 1; end
444
      "MEDIUM"     : begin verb_enum = UVM_MEDIUM; return 1; end
445
      "UVM_MEDIUM" : begin verb_enum = UVM_MEDIUM; return 1; end
446
      "HIGH"       : begin verb_enum = UVM_HIGH;   return 1; end
447
      "UVM_HIGH"   : begin verb_enum = UVM_HIGH;   return 1; end
448
      "FULL"       : begin verb_enum = UVM_FULL;   return 1; end
449
      "UVM_FULL"   : begin verb_enum = UVM_FULL;   return 1; end
450
      "DEBUG"      : begin verb_enum = UVM_DEBUG;  return 1; end
451
      "UVM_DEBUG"  : begin verb_enum = UVM_DEBUG;  return 1; end
452
      default      : begin                         return 0; end
453
    endcase
454
  endfunction
455
 
456
endclass
457
 
458
const uvm_cmdline_processor uvm_cmdline_proc = uvm_cmdline_processor::get_inst();
459
 
460
`endif //UVM_CMDLINE_PROC_PKG_SV
461
 

powered by: WebSVN 2.1.0

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