SyoSil ApS UVM Scoreboard  1.0.3.0
cl_scbs_test_base.svh
1 /// Base class for all SCBs tests
2 //FIN: The type of sequence items generated, which are then transformed to uvm_sequence_item in the filter transfrom
3 //MON: The type of monitors to be used. Must be parameterized to accept items of type FIN
4 //FT: The type of filter transform to be used. Must be parameterized w.r.t the type of FIN
5 class cl_scbs_test_base#(type FIN = cl_tb_seq_item,
6  type MON = cl_tb_tlm_monitor#(cl_tb_seq_item),
7  type FT = pk_utils_uvm::filter_trfm#(FIN, uvm_sequence_item)) extends uvm_test;
8  //-------------------------------------
9  // Non randomizable variables
10  //-------------------------------------
11  cl_tb_env_scbs#(FIN, MON, FT) scbs_env;
12 
13  cl_syoscbs_cfg scbs_cfg;
14 
15  //-------------------------------------
16  // UVM Macros
17  //-------------------------------------
18  `uvm_component_param_utils(cl_scbs_test_base#(FIN, MON, FT))
19 
20  //-------------------------------------
21  // Constructor
22  //-------------------------------------
23  extern function new(string name = "cl_scbs_test_base", uvm_component parent = null);
24  extern virtual function void pre_build();
25  extern virtual task rnd_scb_insert();
26 
27  //-------------------------------------
28  // UVM Phase methods
29  //-------------------------------------
30  extern virtual function void build_phase(uvm_phase phase);
31 
32 endclass : cl_scbs_test_base
33 
34 function cl_scbs_test_base::new(string name = "cl_scbs_test_base", uvm_component parent = null);
35  super.new(name, parent);
36 endfunction : new
37 
38 function void cl_scbs_test_base::build_phase(uvm_phase phase);
39  this.pre_build();
40 
41  super.build_phase(phase);
42 
43  this.scbs_env = cl_tb_env_scbs#(FIN, MON, FT)::type_id::create("scbs_env", this);
44 endfunction: build_phase
45 
46 function void cl_scbs_test_base::pre_build();
47  this.scbs_cfg = cl_syoscbs_cfg::type_id::create("scbs_cfg");
48 
49  // Create NO_OF_SCBS cfg objects inside scbs_cfg.cfgs dyn array.
50  // Other arguments are kept empty: Here we are interested to create cfgs only, and
51  // the complete init will be called inside scbs_env with the fields defined in it.
52  //
53  // -scbs_name : The specific name of the scbs wrapper.
54  // If not provided, the wrapper will have the name given while calling the create method.
55  // -no_scbs : The number of cfg objects contained inside the wrapper.
56  // In this case the number is set with NO_OF_SCBS to be equal 10.
57  // -scb_names[]: Provide a different name for each scb. If no arguments are passed,
58  // each scb inside the wrapper will be assigned a default name.
59  // -queues[] : Sets the queues contained in the passed argument, and sets it for each
60  // cfg contained in the wrapper. Now we are passing an empty argument since the
61  // queue name list will be defined inside the env.
62  // -producers[]: specifies the group of producers for the wrapper. Here we are giving an empty
63  // argument because we will define the list of producers inside the env.
64  this.scbs_cfg.init("myscbs", NO_OF_SCBS, {}, {}, {});
65  for(int i=0; i<NO_OF_SCBS; i++) begin
66  cl_syoscb_cfg cfg = this.scbs_cfg.get_cfg(i);
67  cfg.set_compare_type(pk_syoscb::SYOSCB_COMPARE_IO);
68  cfg.set_queue_type(pk_syoscb::SYOSCB_QUEUE_STD);
69  this.scbs_cfg.set_cfg(cfg, i);
70  end
71 
72  // Forward created cfg to scbs_env
73  uvm_config_db #(cl_syoscbs_cfg)::set(this , "scbs_env",
74  "cfg", this.scbs_cfg);
75 
76 
77  //We factory override from cl_syoscbs_base to cl_syoscbs#(FIN) in most cases
78  cl_syoscbs_base::type_id::set_type_override(cl_syoscbs#(FIN)::get_type());
79 endfunction: pre_build
80 
81 task cl_scbs_test_base::rnd_scb_insert();
82  int unsigned item_cnt;
83 
84  // Inject random errors
85  repeat ($urandom_range(100, 1)) begin
86  int unsigned ws;
87  int unsigned scb_idx;
88  cl_syoscb scb;
89  cl_tb_seq_item item;
90 
91  // Generate random wait
92  ws = $urandom_range(100, 10);
93 
94  `uvm_info("TEST", $sformatf("[%0d]: Waiting %0d time units",
95  item_cnt, ws), UVM_NONE);
96 
97  // Do the wait
98  #(ws);
99 
100  `uvm_info("TEST", $sformatf("[%0d]: Wait done", item_cnt), UVM_NONE);
101 
102  // Pick random scb
103  scb_idx = $urandom_range(this.scbs_env.syoscbs_cfg.get_no_scbs()-1, 0);
104 
105  // Get scb
106  scb = this.scbs_env.syoscbs.get_scb(scb_idx);
107 
108  item = cl_tb_seq_item::type_id::create($sformatf("scb[%0d]-item[%0d]", scb_idx, item_cnt));
109 
110  if(!item.randomize()) begin
111  `uvm_fatal("TEST_ERROR", "Unable to randomize")
112  end
113 
114  scb.add_item(((item_cnt % 2) == 0) ? "Q1" : "Q2", "P1", item);
115  end
116 endtask: rnd_scb_insert
Base class for all SCBs tests.
Top level class implementing the root of the SyoSil UVM scoreboard.
Definition: cl_syoscb.svh:2
Configuration object for the cl_syoscbs_base scoreboard wrapper.
Default implementation of a scoreboard wrapper.
Definition: cl_syoscbs.svh:3
Configuration class for the SyoSil UVM scoreboard.
Base class for a filter transformation.
Definition: pk_utils_uvm.sv:18

Project: SyoSil ApS UVM Scoreboard, Revision: 1.0.3.0

Copyright 2014-2022 SyoSil ApS
All Rights Reserved Worldwide

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
doxygen
Doxygen Version: 1.8.14
Generated with IDV SV Filter Version: 2.6.3
Fri Sep 2 2022 14:38:34
Find a documentation bug? Report bugs to: scoreboard@syosil.com