2 typedef enum { NEXT, PREV, FIRST, LAST, INSERT, DELETE } iterator_action_t;
6 class cl_scb_test_iterator_correctness_helper_object
extends uvm_object;
10 `uvm_object_utils_begin(cl_scb_test_iterator_correctness_helper_object)
11 `uvm_field_int(index, UVM_DEFAULT)
12 `uvm_field_enum(iterator_action_t, op, UVM_DEFAULT)
15 function new(string name = "cl_scb_test_iterato_deadlock_helper_object");
19 function string convert2string();
20 return {this.op.name(), $sformatf(
" %3d", this.index)};
21 endfunction: convert2string
34 cl_scb_test_iterator_correctness_helper_object operations[$];
43 `uvm_component_utils_begin(cl_scb_test_iterator_correctness)
45 `uvm_component_utils_end
50 function new(string name = "cl_scb_test_iterator_correctness", uvm_component parent = null);
51 super.new(name, parent);
57 extern task main_phase(uvm_phase phase);
58 extern task use_iterator(int id);
65 task cl_scb_test_iterator_correctness::use_iterator(int id);
66 iterator_action_t action;
70 #($urandom_range(100, 1)); //Wait for some random amount before creating the iterator 71 iter = q.create_iterator();
73 for(int i=0; i<this.NUM_ACTIONS; i++) begin
74 if(!std::randomize(action)) begin
75 `uvm_fatal("RAND", "Unable to randomize action to take")
79 NEXT: if(iter.has_next()) void'(iter.next());
80 PREV: if(iter.has_previous()) void'(iter.previous());
81 FIRST: void'(iter.first());
82 LAST: void'(iter.last());
85 cl_tb_seq_item ctsi = cl_tb_seq_item::type_id::create("ctsi");
86 cl_scb_test_iterator_correctness_helper_object help = new;
87 help.index = this.operations.size();
89 ctsi.int_a = this.operations.size();
91 this.operations.push_back(help);
92 this.scb_env.syoscb[0].add_item("Q1", "P1", ctsi);
95 cl_syoscb_proxy_item_base proxy;
96 cl_scb_test_iterator_correctness_helper_object help;
100 if(iter.has_next()) begin
103 void'(iter.previous());
109 help.index = iter.previous_index();
111 this.operations.push_back(help);
112 void'(q.delete_item(proxy));
118 #($urandom_range(10,1));
121 endtask: use_iterator
123 task cl_scb_test_iterator_correctness::main_phase(uvm_phase phase);
126 phase.raise_objection(this);
127 super.main_phase(phase);
135 for(int i=0; i<this.NUM_ITEMS; i++) begin
136 cl_tb_seq_item ctsi = cl_tb_seq_item::type_id::create("ctsi");
137 cl_scb_test_iterator_correctness_helper_object help = new;
141 this.operations.push_back(help);
144 this.scb_env.syoscb[0].add_item("Q1", "P1", ctsi);
148 for(int i=0; i<this.NUM_ITERS; i++) begin
152 this.use_iterator(k);
159 foreach(this.operations[i]) begin
160 if(this.operations[i].op == INSERT) begin
161 result.push_back(this.operations[i].index);
162 end else if(this.operations[i].op == DELETE) begin
163 result.delete(this.operations[i].index);
165 `uvm_error("TEST", $sformatf("Bad enum in helper object. str=%s, value=%0d", this.operations[i].op.name(), this.operations[i].op))
171 foreach(result[i]) begin
172 cl_tb_seq_item ctsi = cl_tb_seq_item::type_id::create("ctsi");
173 ctsi.int_a = result[i];
174 this.scb_env.syoscb[0].add_item("Q2", "P1", ctsi);
177 phase.drop_objection(this);
Test to ensure that multiple iterators on the same queue won't deadlock and are performing correctly...
Queue iterator base class defining the iterator API used for iterating over queues.
Class which represents the base concept of a queue.