7 cl_tb_rnd_test_items rnd_items[];
13 `uvm_component_utils_begin(cl_scb_test_rnd)
14 `uvm_field_array_object(rnd_items, UVM_DEFAULT)
15 `uvm_component_utils_end
20 extern function new(string name = "cl_scb_test_rnd", uvm_component parent = null);
21 extern
virtual function void pre_build();
22 extern function void split_loops( input string names[],
23 output string primary[],
24 output string secondary[]);
29 extern
virtual function void build_phase(uvm_phase phase);
30 extern task run_phase(uvm_phase phase);
34 function cl_scb_test_rnd::new(string name = "cl_scb_test_rnd",
35 uvm_component parent = null);
36 super.new(name, parent);
40 function void cl_scb_test_rnd::pre_build();
41 string l_queues_name[];
43 this.syoscb_cfgs = cl_syoscb_cfgs::type_id::create("syoscb_cfgs");
44 this.syoscb_cfgs.init(pk_tb::NO_OF_SCB);
46 this.rnd_items = new[pk_tb::NO_OF_SCB];
48 foreach(this.syoscb_cfgs.syoscb_cfg[i]) begin
49 this.rnd_items[i] = cl_tb_rnd_test_items::type_id::create($sformatf("rnd_items%0d", i));
52 this.rnd_items[i].cfg_rnd = this.config_create_and_randomize();
54 if(!this.rnd_items[i].randomize()) begin
55 `uvm_fatal("TEST_RND", "Randomization of rnd_items failed!")
58 `uvm_info("TEST_RND", $sformatf("\n rnd_item %0d: \n %s", i,
59 this.rnd_items[i].sprint()), UVM_NONE)
61 this.syoscb_cfgs.syoscb_cfg[i] = cl_syoscb_cfg::type_id::create($sformatf("syoscb_cfg%0d", i));
64 l_queues_name = new[this.rnd_items[i].queues_no];
66 foreach(l_queues_name[i]) begin
68 l_queues_name[i] = $sformatf("Q%0d", i+1);
72 this.syoscb_cfgs.syoscb_cfg[i].set_queues(l_queues_name);
75 if (this.rnd_items[i].cfg_rnd.dynamic_primary_queue == 1'b0) begin
76 if(!this.syoscb_cfgs.syoscb_cfg[i].set_primary_queue("Q1")) begin
77 `uvm_fatal("CFG_ERROR", "syoscb_cfg.set_primary_queue call failed!")
82 if(!this.syoscb_cfgs.syoscb_cfg[i].set_producer("P1", l_queues_name)) begin
83 `uvm_fatal("CFG_ERROR", "syoscb_cfg.set_producer call failed!")
86 this.rnd_items[i].cfg_rnd.set_rnd_fields(this.syoscb_cfgs.syoscb_cfg[i]);
88 endfunction : pre_build
91 function void cl_scb_test_rnd::build_phase(uvm_phase phase);
94 super.build_phase(phase);
96 uvm_config_db #(cl_syoscb_cfgs)::set(this, "scb_env",
97 "cfg", this.syoscb_cfgs);
99 this.scb_env = cl_tb_env_scb::type_id::create("scb_env", this);
100 endfunction: build_phase
103 task cl_scb_test_rnd::run_phase(uvm_phase phase);
104 string l_queues_name [];
105 string primary_loop_names [];
106 string secondary_loop_names [];
108 phase.raise_objection(this);
110 super.run_phase(phase);
112 foreach (this.scb_env.syoscb[w]) begin
113 this.syoscb_cfgs.syoscb_cfg[w].get_queues(l_queues_name);
115 l_queues_name.shuffle();
117 this.split_loops(l_queues_name, primary_loop_names, secondary_loop_names);
120 begin : primary_iteration
121 `uvm_info("RND_TEST",
122 $sformatf("%0s: Primary iteration: adding item on primary group of queues: ",
123 this.scb_env.syoscb[w].get_name()), UVM_LOW)
126 for(int unsigned k=0; k < this.rnd_items[w].max_generated_item; k++) begin
127 cl_tb_seq_item item1;
128 item1 = cl_tb_seq_item::type_id::create("item1");
129 if(this.rnd_items[w].enable_duplets && this.rnd_items[w].duplet_insertion_idx == k) begin
130 `uvm_info("RND_TEST", $sformatf("Inserted duplet at position: %d. Duplet value: %d",
138 foreach(primary_loop_names[j]) begin
139 scb_env.syoscb[w].add_item(primary_loop_names[j], "P1", item1);
142 `uvm_info("RND_TEST",
143 $sformatf("%0s: Primary iteration done",
144 this.scb_env.syoscb[w].get_name()), UVM_LOW)
145 end : primary_iteration
147 begin : secondary_iteration
148 `uvm_info("RND_TEST",
149 $sformatf("%0s: Secondary iteration: adding item on secondary group of queues: ",
150 this.scb_env.syoscb[w].get_name()), UVM_LOW)
153 for(int unsigned k=0; k < this.rnd_items[w].max_generated_item; k++) begin
154 cl_tb_seq_item item1;
155 item1 = cl_tb_seq_item::type_id::create("item1");
156 if(this.rnd_items[w].enable_duplets && this.rnd_items[w].duplet_insertion_idx == k) begin
157 `uvm_info("RND_TEST", $sformatf("inserted duplet at position: %d. Duplet value: %d",
165 foreach(secondary_loop_names[j]) begin
166 scb_env.syoscb[w].add_item(secondary_loop_names[j], "P1", item1);
169 `uvm_info("RND_TEST",
170 $sformatf("%0s: Secondary iteration done",
171 this.scb_env.syoscb[w].get_name()), UVM_LOW)
172 end : secondary_iteration
176 phase.drop_objection(this);
181 function void cl_scb_test_rnd::split_loops( input string names[],
182 output string primary[],
183 output string secondary[]);
184 int unsigned primary_size;
185 int unsigned secondary_size;
188 primary_size = (($urandom) % (names.size()-1)) +1;
191 secondary_size = (names.size()) - primary_size;
193 primary = new[primary_size];
194 secondary = new[secondary_size];
196 foreach(primary[i]) begin
197 primary[i] = names[i];
198 `uvm_info("TEST_RND",$sformatf("Primary #%0d: %0s", i, primary[i]), UVM_DEBUG);
201 foreach(secondary[i]) begin
202 secondary[i] = names[primary_size+i];
203 `uvm_info("TEST_RND",$sformatf("Secondary #%0d: %0s", i, secondary[i]), UVM_DEBUG);
205 endfunction: split_loops
Random test to hit all the coverage holes which are not covered by tests derived from cl_scb_test_dou...
Base class for all SCB tests.