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

Subversion Repositories lpffir

[/] [lpffir/] [trunk/] [uvm/] [tools/] [uvm_syoscb/] [src/] [pk_syoscb.sv] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 vladimirar
//----------------------------------------------------------------------
2
//   Copyright 2014-2015 SyoSil ApS
3
//   All Rights Reserved Worldwide
4
//
5
//   Licensed under the Apache License, Version 2.0 (the
6
//   "License"); you may not use this file except in
7
//   compliance with the License.  You may obtain a copy of
8
//   the License at
9
//
10
//       http://www.apache.org/licenses/LICENSE-2.0
11
//
12
//   Unless required by applicable law or agreed to in
13
//   writing, software distributed under the License is
14
//   distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
15
//   CONDITIONS OF ANY KIND, either express or implied.  See
16
//   the License for the specific language governing
17
//   permissions and limitations under the License.
18
//----------------------------------------------------------------------
19
`ifndef __PK_SYOSCB_SV__
20
`define __PK_SYOSCB_SV__
21
 
22
/// @mainpage
23
/// User and implementation documentation for the UVM scoreboard
24
///
25
/// This documentation provides the following additional documentation, besides
26
/// the normal source code documentation:
27
///
28
///   -# Getting started: \ref pGettingStarted
29
///   -# How to integrate the UVM scoreboard: \ref pIntegration
30
///   -# Implementation notes: \ref pImplementationNotes
31
///
32
/// It is assumed that the reader is familiar with the UVM scoreboard architecture
33
/// described in the SyoSil paper on the subject: Versatile UVM Scoreboarding located in
34
/// in the docs directory.
35
///
36
/// @page pGettingStarted Getting started
37
/// This software package also provides some simple examples beside the source code for the UVM scoreboard. Before starting to integrate the UVM scoreboard into your own code then it might be beneficial to look at the provided examples. An example testbench is placed in the tb directory and the tests are in the tb/test directory.
38
///
39
/// To run the examples you need to select a Vendor since the examples can be run with all of the three major SystemVerilog simulator vendors: Mentor Graphics, Cadence and Synopsys. See README.txt for a description of how to select the vendor.
40
///
41
/// Once the vendor has been selected then the available Make targets for that vendor can be listed by typing: "make". Typically, you run the simulation with: make sim.
42
///
43
/// In general you can type: make help to get information about what Make options are available.
44
///
45
/// @page pIntegration How to integrate the UVM scoreboard
46
/// The UVM scoreboard is easily integrated into your existing testbench environment.
47
///
48
/// @section sCompile Compiling the UVM scoreboard
49
/// To get the UVM scoreboard compiled you need to add src/pk_syoscb.sv to your list of files that are complied when compiling your testbench. How this is done is highly dependent on the verification environment since some environments compile everything into different libraries and some do not etc.
50
///
51
/// @section sAcccess Accessing the UVM scoreboard from your own code
52
/// Once the UVM scoreboard is compiled with the verification environment then it is accessible either by explicit scoping:
53
///
54
/// @code
55
///   class myclass;
56
///     pk_syoscb::cl_syoscb my_new_scb;
57
///     ...
58
/// @endcode
59
///
60
/// or by importing the complete package into your scope:
61
///
62
/// @code
63
///   import pk_syoscb::*;
64
///
65
///   class myclass;
66
///     cl_syoscb my_new_scb;
67
///     ...
68
/// @endcode
69
///
70
/// @section sInstantiation Instantiating the UVM scoreboard
71
/// The UVM scoreboard itself needs to be instantiated along with the configuration object. The simplest way to to this is to add the UVM scoreboard and the configuration object to the UVM environment - note that the configuration object is passed to the scoreboard via the config_db:
72
///
73
/// @code
74
///   import pk_syoscb::*;
75
///
76
///   class cl_scbtest_env extends uvm_env;
77
///
78
///     cl_syoscb     syoscb;
79
///     cl_syoscb_cfg syoscb_cfg;
80
///
81
///     `uvm_component_utils_begin(cl_scbtest_env)
82
///       `uvm_field_object(syoscb,     UVM_ALL_ON)
83
///       `uvm_field_object(syoscb_cfg, UVM_ALL_ON)
84
///     `uvm_component_utils_end
85
///
86
///     ...
87
///
88
///   endclass: cl_scbtest_env
89
///
90
///   function void cl_scbtest_env::build_phase(uvm_phase phase);
91
///     super.build_phase(phase);
92
///
93
///     // Create the scoreboard configuration object
94
///     this.syoscb_cfg = cl_syoscb_cfg::type_id::create("syoscb_cfg");
95
///
96
///     // Pass the scoreboard configuration object to the config_db
97
///     uvm_config_db #(cl_syoscb_cfg)::set(this, "syoscb", "cfg", this.syoscb_cfg);
98
///
99
///     // Create the scoreboard
100
///     this.syoscb = cl_syoscb::type_id::create("syoscb", this);
101
///
102
///     ...
103
///
104
///   endfunction: build_phase
105
/// @endcode
106
///
107
/// @section sConfiguration Configuring the UVM scoreboard
108
/// The UVM scoreboard configuration object needs to be configured after it has been created. The following example shows how two queues Q1 and Q2 wit Q1 as the primary queue. Furthermore, one producer P1 is added to both queues:
109
///
110
/// @code
111
///   function void cl_scbtest_env::build_phase(uvm_phase phase);
112
///     super.build_phase(phase);
113
///
114
///     // Create the scoreboard configuration object
115
///     this.syoscb_cfg = cl_syoscb_cfg::type_id::create("syoscb_cfg");
116
///
117
///     // Configure the scoreboard
118
///     this.syoscb_cfg.set_queues({"Q1", "Q2"});
119
///     void'(this.syoscb_cfg.set_primary_queue("Q1"));
120
///     void'(this.syoscb_cfg.set_producer("P1", {"Q1", "Q2"}));
121
///
122
///     // Pass the scoreboard configuration object to the config_db
123
///     uvm_config_db #(cl_syoscb_cfg)::set(this, "syoscb", "cfg", this.syoscb_cfg);
124
///
125
///     // Create the scoreboard
126
///     this.syoscb = cl_syoscb::type_id::create("syoscb", this);
127
///
128
///     ...
129
///
130
///   endfunction: build_phase
131
/// @endcode
132
///
133
/// @section sFunctionAPIHookUp Function based API hook up
134
/// The function based API is very easy to use once you have done the configuration and instantiation
135
/// of the scoreboard as describe above.
136
///
137
/// Whenever you need to add an UVM sequence item to a queue produced by a specified producer then you simply
138
/// invoke the cl_syoscb::add_item() method:
139
///
140
/// @code
141
///   // *NOTE*: Assumes syoscb is handle to an instance of the scoreboard and
142
///   //         item1 is a handle to a UVM sequence item
143
///
144
///   ...
145
///
146
///   // Insert UVM sequence item for queue: Q1, for producer: P1
147
///   syoscb.add_item("Q1", "P1", item1);
148
/// @endcode
149
///
150
/// Invoking the cl_syoscb::add_item() method will simply wrap the UVM sequence item in a cl_syoscb_item object, add it the correct queue
151
/// and finally invoke the configured compare method.
152
///
153
/// The UVM environment will typically contain a handle to the scoreboard as described above. This can then be utilized if UVM sequences
154
/// needs to be added from a test case:
155
///
156
/// @code
157
///   class cl_scbtest_seq_item extends uvm_sequence_item;
158
///     //-------------------------------------
159
///     // Randomizable variables
160
///     //-------------------------------------
161
///     rand int unsigned int_a;
162
///
163
///     //-------------------------------------
164
///     // UVM Macros
165
///     //-------------------------------------
166
///     `uvm_object_utils_begin(cl_scbtest_seq_item)
167
///       `uvm_field_int(int_a, UVM_ALL_ON)
168
///     `uvm_object_utils_end
169
///
170
///     //-------------------------------------
171
///     // Constructor
172
///     //-------------------------------------
173
///     function cl_scbtest_seq_item::new (string name = "cl_scbtest_seq_item");
174
///        super.new(name);
175
///     endfunction
176
///   endclass: cl_scbtest_seq_item
177
///
178
///   class cl_scbtest_test extends uvm_test;
179
///     //-------------------------------------
180
///     // Non randomizable variables
181
///     //-------------------------------------
182
///     cl_scbtest_env scbtest_env;
183
///
184
///     //-------------------------------------
185
///     // UVM Macros
186
///     //-------------------------------------
187
///     `uvm_component_utils(cl_scbtest_test)
188
///
189
///     //-------------------------------------
190
///     // Constructor
191
///     //-------------------------------------
192
///     function new(string name = "cl_scbtest_test", uvm_component parent = null);
193
///       super.new(name, parent);
194
///     endfunction: new
195
///
196
///     //-------------------------------------
197
///     // UVM Phase methods
198
///     //-------------------------------------
199
///     function void build_phase(uvm_phase phase);
200
///       super.build_phase(phase);
201
///       scbtest_env = cl_scbtest_env::type_id::create("scbtest_env", this);
202
///     endfunction: build_phase
203
///
204
///     task run_phase(uvm_phase phase);
205
///       super.run_phase(phase);
206
///       begin
207
///         cl_scbtest_seq_item item1;
208
///         item1 = cl_scbtest_seq_item::type_id::create("item1");
209
///         item1.int_a = 'h3a;
210
///         scbtest_env.syoscb.add_item("Q1", "P1", item1);
211
///       end
212
///       begin
213
///         cl_scbtest_seq_item item1;
214
///         item1 = cl_scbtest_seq_item::type_id::create("item1");
215
///         item1.int_a = 'h3a;
216
///         scbtest_env.syoscb.add_item("Q2", "P1", item1);
217
///       end
218
///     endtask: run_phase
219
///   endclass: cl_scbtest_test
220
/// @endcode
221
///
222
/// @section sTLMAPIHookUp TLM based API hook up
223
/// The TLM API is even easier to use than the function based API. The scoreboard provides generic UVM subscribers which
224
/// can be connected to anything which has a UVM analysis port (e.g. a UVM monitor). Typically, the UVM agents inside the UVM environment
225
/// contain one or more monitors with UVM analysis ports which should be connected to the scoreboard. The following example has two agents which
226
/// each has a monitor. The monitors are connected to Q1 and Q2 in the scoreboard:
227
///
228
/// @code
229
///   import pk_syoscb::*;
230
///
231
///   class cl_scbtest_env extends uvm_env;
232
///
233
///     cl_syoscb     syoscb;
234
///     cl_syoscb_cfg syoscb_cfg;
235
///     myagent       agent1;
236
///     myagent       agent2;
237
///
238
///     ...
239
///
240
///     function void build_phase(uvm_phase phase);
241
///
242
///       ...
243
///
244
///       // Configure and create the scoreboard
245
///       // Create and configure the agents
246
///
247
///       ...
248
///
249
///     endfunction: build_phase
250
///
251
///     ...
252
///
253
///     function void connect_phase(uvm_phase phase);
254
///       super.connect_phase(phase);
255
///
256
///       begin
257
///         cl_syoscb_subscriber subscriber;
258
///
259
///         // Get the subscriber for Producer: P1 for queue: Q1 and connect it
260
///         // to the UVM monitor producing transactions for this queue
261
///         subscriber = this.syoscb.get_subscriber("Q1", "P1");
262
///         this.agent1.mon..connect(subscriber.analysis_export);
263
///
264
///         // Get the subscriber for Producer: P1 for queue: Q2 and connect it
265
///         // to the UVM monitor producing transactions for this queue
266
///         subscriber = this.syoscb.get_subscriber("Q2", "P1");
267
///         this.agent1.mon..connect(subscriber.analysis_export);
268
///       end
269
///     endfunction: connect_phase
270
///   @endcode
271
///
272
/// @section sFactory Factory overwrites
273
/// Finally, the wanted queue and compare algorithm implementation needs to be selected. This is done by factory overwrites since they can be changed test etc.
274
///
275
/// NOTE: This MUST be done before creating the scoreboard!
276
///
277
/// The following queue implementations are available:
278
///
279
///   -# Standard SV queue (cl_syoscb_queue_std)
280
///
281
/// and the following compare algorithms are available:
282
///
283
///   -# Out-of-Order (cl_syoscb_compare_ooo)
284
///   -# In-Order (cl_syoscb_compare_io)
285
///   -# In-Order by producer (cl_syoscb_compare_iop)
286
///
287
/// The following example shows how they are configured:
288
///
289
/// @code
290
///   cl_syoscb_queue::set_type_override_by_type(cl_syoscb_queue::get_type(),
291
///                                              cl_syoscb_queue_std::get_type(),
292
///                                              "*");
293
///
294
///   factory.set_type_override_by_type(cl_syoscb_compare_base::get_type(),
295
///                                     cl_syoscb_compare_ooo::get_type(),
296
///                                     "*");
297
/// @endcode
298
///
299
/// The full build phase, including the factory overwrites, of cl_scbtest_env is shown here for completeness:
300
///
301
/// @code
302
///   function void cl_scbtest_env::build_phase(uvm_phase phase);
303
///     super.build_phase(phase);
304
///
305
///     // Use the standard SV queue implementation as scoreboard queue
306
///     cl_syoscb_queue::set_type_override_by_type(cl_syoscb_queue::get_type(),
307
///                                                cl_syoscb_queue_std::get_type(),
308
///                                                "*");
309
///
310
///     // Set the compare strategy to be OOO
311
///     factory.set_type_override_by_type(cl_syoscb_compare_base::get_type(),
312
///                                       cl_syoscb_compare_ooo::get_type(),
313
///                                       "*");
314
///
315
///     // Create the scoreboard configuration object
316
///     this.syoscb_cfg = cl_syoscb_cfg::type_id::create("syoscb_cfg");
317
///
318
///     // Configure the scoreboard
319
///     this.syoscb_cfg.set_queues({"Q1", "Q2"});
320
///     void'(this.syoscb_cfg.set_primary_queue("Q1"));
321
///     void'(this.syoscb_cfg.set_producer("P1", {"Q1", "Q2"}));
322
///
323
///     // Pass the scoreboard configuration object to the config_db
324
///     uvm_config_db #(cl_syoscb_cfg)::set(this, "syoscb", "cfg", this.syoscb_cfg);
325
///
326
///     // Create the scoreboard
327
///     this.syoscb = cl_syoscb::type_id::create("syoscb", this);
328
///
329
///     ...
330
///
331
///   endfunction: build_phase
332
/// @endcode
333
///
334
/// @page pImplementationNotes Implementation notes
335
///
336
/// @section sAPIs Implementation APIs
337
///
338
/// The following APIs have been defined for easy extension fo the scoreboard classes:
339
///
340
///   -# Configuration API: cl_syoscb_cfg
341
///   -# Item API: cl_syoscb_item
342
///   -# Queue API: cl_syoscb_queue
343
///   -# Compare API: cl_syoscb_compare_base
344
///   -# Subscriber API: cl_syoscb_subscriber
345
///   -# Iterator API: cl_syoscb_queue_iterator_base
346
///
347
/// @section sGeneralErrorHandling General error handling
348
/// In general when a lower level method detects an error then two concepts are used. Primarily, the method will either issue a UVM info with some information about what went wrong or issue a UVM error/fatal immediately. The first one will then return 1'b0 to signal that something went wrong. Thus, it is up to the parent levels to catch the error and convert them into UVM errors/fatals etc. This method was chosen since the parent level typically provides more and better information when things go wrong.
349
/// @section sErrorCategories Error categories
350
/// There are several ERROR categories. The following table lists them with some explanation:
351
///
352
///  
353
///  
354
///    
Error Category
355
///    
Description
356
///  
357
///  
358
///    
IMPL_ERROR
359
///    
Implementation error. Something is really broken
360
///  
361
///  
362
///    
QUEUE_ERROR
363
///    
A queue related error, e.g. the queue could not be found
364
///  
365
///  
366
///    
CFG_ERROR
367
///    
Configuration error. Usually, because the configuration object is missing
368
///  
369
///  
370
///    
TYPE_ERROR
371
///    
Type error. Typically issued when $cast() fails
372
///  
373
///  
374
///    
COMPARE_ERROR
375
///    
Compare error. Issued, e.g. when the in order compare fails
376
///  
377
///  
378
///    
SUBSCRIBER_ERROR
379
///    
Subscriber error. Issued, e.g. when the call to cl_syoscb::get_subscriber() fails
380
///  
381
///  
382
///
383
/// @section sMultipleQueueRefs Multiple queue references
384
/// Both the top level class cl_syoscb and the configuration class cl_syoscb_cfg contains
385
/// handles to all queues. The former uses an ordinary array which provides a fast way of
386
/// looping over the queues and the latter an associative which makes it easy to find
387
/// a queue using only its name.
388
 
389
package pk_syoscb;
390
  ////////////////////////////////////////////////////////////////////////////
391
  // Imported packages
392
  ////////////////////////////////////////////////////////////////////////////
393
  import uvm_pkg::*;
394
  `include "uvm_macros.svh"
395
 
396
  ////////////////////////////////////////////////////////////////////////////
397
  // Type definitions
398
  ////////////////////////////////////////////////////////////////////////////
399
  typedef class cl_syoscb;
400
  typedef class cl_syoscb_cfg;
401
  typedef class cl_syoscb_queue;
402
 
403
  ////////////////////////////////////////////////////////////////////////////
404
  // Package source files
405
  ////////////////////////////////////////////////////////////////////////////
406
  `include "cl_syoscb_cfg_pl.svh"
407
  `include "cl_syoscb_cfg.svh"
408
  `include "cl_syoscb_item.svh"
409
  `include "cl_syoscb_queue_iterator_base.svh"
410
  `include "cl_syoscb_queue_iterator_std.svh"
411
  `include "cl_syoscb_queue.svh"
412
  `include "cl_syoscb_queue_std.svh"
413
  `include "cl_syoscb_compare_base.svh"
414
  `include "cl_syoscb_compare.svh"
415
  `include "cl_syoscb_compare_ooo.svh"
416
  `include "cl_syoscb_compare_io.svh"
417
  `include "cl_syoscb_compare_iop.svh"
418
  `include "cl_syoscb_report_catcher.svh"
419
  `include "cl_syoscb_subscriber.svh"
420
  `include "cl_syoscb.svh"
421
endpackage: pk_syoscb
422
 
423
`endif //  __PK_SYOSCB_SV__

powered by: WebSVN 2.1.0

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