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 |
|
|
/// Configuration class for the SyoSil UVM scoreboard
|
20 |
|
|
class cl_syoscb_cfg extends uvm_object;
|
21 |
|
|
//---------------------------------
|
22 |
|
|
// Non randomizable member variables
|
23 |
|
|
//---------------------------------
|
24 |
|
|
/// Associative array holding handles to each queue. Indexed by queue name
|
25 |
|
|
local cl_syoscb_queue queues[string];
|
26 |
|
|
|
27 |
|
|
/// Associative array indexed by producer name. Returns the list of queues which
|
28 |
|
|
/// this producer is related to.
|
29 |
|
|
local cl_syoscb_cfg_pl producers[string];
|
30 |
|
|
local string primary_queue;
|
31 |
|
|
|
32 |
|
|
/// 1'b0 => Calls to cl_syoscb::add_item will clone the uvm_sequence_item
|
33 |
|
|
/// 1'b1 => Calls to cl_syoscb::add_item will not clone the uvm_sequence_item
|
34 |
|
|
local bit disable_clone = 1'b0;
|
35 |
|
|
|
36 |
|
|
/// Maximum number of elements in each queue before an error is signalled. 0 means no limit (default)
|
37 |
|
|
local int unsigned max_queue_size[string];
|
38 |
|
|
|
39 |
|
|
// TBD::JSA local bit full_scb_dump;
|
40 |
|
|
// TBD::JSA local int unsigned full_max_queue_size[string];
|
41 |
|
|
// TBD::JSA local string full_scb_type[];
|
42 |
|
|
// TBD::JSA local int unsigned item_time_out_queue[string];
|
43 |
|
|
// TBD::JSA local int unsigned item_time_out_producer[string];
|
44 |
|
|
|
45 |
|
|
// The name of the SCB. Default will be the instance name of
|
46 |
|
|
// the SCB component if the name is not set explicitly
|
47 |
|
|
local string scb_name;
|
48 |
|
|
|
49 |
|
|
//-------------------------------------
|
50 |
|
|
// UVM Macros
|
51 |
|
|
//-------------------------------------
|
52 |
|
|
`uvm_object_utils_begin(cl_syoscb_cfg)
|
53 |
|
|
`uvm_field_aa_object_string(queues, UVM_DEFAULT)
|
54 |
|
|
`uvm_field_aa_object_string(producers, UVM_DEFAULT)
|
55 |
|
|
`uvm_field_string(primary_queue, UVM_DEFAULT)
|
56 |
|
|
`uvm_field_int(disable_clone, UVM_DEFAULT)
|
57 |
|
|
`uvm_field_aa_int_string(max_queue_size, UVM_DEFAULT)
|
58 |
|
|
`uvm_field_string(scb_name, UVM_DEFAULT)
|
59 |
|
|
`uvm_object_utils_end
|
60 |
|
|
|
61 |
|
|
//-------------------------------------
|
62 |
|
|
// Constructor
|
63 |
|
|
//-------------------------------------
|
64 |
|
|
extern function new(string name = "cl_syoscb_cfg");
|
65 |
|
|
|
66 |
|
|
//-------------------------------------
|
67 |
|
|
// Configuration API
|
68 |
|
|
//-------------------------------------
|
69 |
|
|
extern function cl_syoscb_queue get_queue(string queue_name);
|
70 |
|
|
extern function void set_queue(string queue_name, cl_syoscb_queue queue);
|
71 |
|
|
extern function void get_queues(output string queue_names[]);
|
72 |
|
|
extern function void set_queues(string queue_names[]);
|
73 |
|
|
extern function bit exist_queue(string queue_name);
|
74 |
|
|
extern function int unsigned size_queues();
|
75 |
|
|
extern function cl_syoscb_cfg_pl get_producer(string producer);
|
76 |
|
|
extern function bit set_producer(string producer, queue_names[]);
|
77 |
|
|
extern function bit exist_producer(string producer);
|
78 |
|
|
extern function void get_producers(output string producers[]);
|
79 |
|
|
extern function string get_primary_queue();
|
80 |
|
|
extern function bit set_primary_queue(string primary_queue_name);
|
81 |
|
|
extern function void set_disable_clone(bit dc);
|
82 |
|
|
extern function bit get_disable_clone();
|
83 |
|
|
extern function void set_max_queue_size(string queue_name, int unsigned mqs);
|
84 |
|
|
extern function int unsigned get_max_queue_size(string queue_name);
|
85 |
|
|
extern function string get_scb_name();
|
86 |
|
|
extern function void set_scb_name(string scb_name);
|
87 |
|
|
endclass : cl_syoscb_cfg
|
88 |
|
|
|
89 |
|
|
function cl_syoscb_cfg::new(string name = "cl_syoscb_cfg");
|
90 |
|
|
super.new(name);
|
91 |
|
|
endfunction: new
|
92 |
|
|
|
93 |
|
|
/// Configuration API: Returns a queue handle for the specificed queue
|
94 |
|
|
function cl_syoscb_queue cl_syoscb_cfg::get_queue(string queue_name);
|
95 |
|
|
// If queue does not exist then return NULL
|
96 |
|
|
if(!this.exist_queue(queue_name)) begin
|
97 |
|
|
`uvm_info("CFG_ERROR", $sformatf("[%s]: Queue: %0s is not found", this.scb_name, queue_name), UVM_DEBUG);
|
98 |
|
|
return(null);
|
99 |
|
|
end
|
100 |
|
|
|
101 |
|
|
return(this.queues[queue_name]);
|
102 |
|
|
endfunction: get_queue
|
103 |
|
|
|
104 |
|
|
/// Configuration API: Sets the queue object for a given queue
|
105 |
|
|
function void cl_syoscb_cfg::set_queue(string queue_name, cl_syoscb_queue queue);
|
106 |
|
|
this.queues[queue_name] = queue;
|
107 |
|
|
endfunction: set_queue
|
108 |
|
|
|
109 |
|
|
/// Configuration API: Returns all queue names a string list
|
110 |
|
|
function void cl_syoscb_cfg::get_queues(output string queue_names[]);
|
111 |
|
|
string queue_name;
|
112 |
|
|
int unsigned idx = 0;
|
113 |
|
|
|
114 |
|
|
queue_names = new[this.queues.size()];
|
115 |
|
|
|
116 |
|
|
while(this.queues.next(queue_name)) begin
|
117 |
|
|
queue_names[idx++] = queue_name;
|
118 |
|
|
end
|
119 |
|
|
endfunction: get_queues
|
120 |
|
|
|
121 |
|
|
/// Configuration API: Will set the legal queues when provides with a list of queue names.
|
122 |
|
|
/// An example could be: set_queues({"Q1", "Q2"})
|
123 |
|
|
/// Will set the max_queue_size for each queue to 0 (no limit) as default
|
124 |
|
|
function void cl_syoscb_cfg::set_queues(string queue_names[]);
|
125 |
|
|
foreach(queue_names[i]) begin
|
126 |
|
|
this.queues[queue_names[i]] = null;
|
127 |
|
|
|
128 |
|
|
// Set default max queue size to no limit
|
129 |
|
|
this.max_queue_size[queue_names[i]] = 0;
|
130 |
|
|
end
|
131 |
|
|
endfunction: set_queues
|
132 |
|
|
|
133 |
|
|
/// Configuration API: Returns 1'b0 if the queue does not exist and 1'b1 if it exists
|
134 |
|
|
function bit cl_syoscb_cfg::exist_queue(string queue_name);
|
135 |
|
|
return(this.queues.exists(queue_name)==0 ? 1'b0 : 1'b1);
|
136 |
|
|
endfunction
|
137 |
|
|
|
138 |
|
|
/// Configuration API: Returns the number of queues
|
139 |
|
|
function int unsigned cl_syoscb_cfg::size_queues();
|
140 |
|
|
return(this.queues.size());
|
141 |
|
|
endfunction
|
142 |
|
|
|
143 |
|
|
/// Configuration API: Gets the given producer object for a specified producer
|
144 |
|
|
function cl_syoscb_cfg_pl cl_syoscb_cfg::get_producer(string producer);
|
145 |
|
|
if(this.exist_producer(producer)) begin
|
146 |
|
|
return(this.producers[producer]);
|
147 |
|
|
end else begin
|
148 |
|
|
`uvm_info("CFG_ERROR", $sformatf("[%s]: Unable to get producer: %s", this.scb_name, producer), UVM_DEBUG);
|
149 |
|
|
return(null);
|
150 |
|
|
end
|
151 |
|
|
endfunction: get_producer
|
152 |
|
|
|
153 |
|
|
/// Configuration API: Sets the given producer for the listed queues
|
154 |
|
|
function bit cl_syoscb_cfg::set_producer(string producer, queue_names[]);
|
155 |
|
|
cl_syoscb_cfg_pl prod_list;
|
156 |
|
|
|
157 |
|
|
// Check that all queues exists
|
158 |
|
|
begin
|
159 |
|
|
bit unique_queue_name[string];
|
160 |
|
|
|
161 |
|
|
foreach (queue_names[i]) begin
|
162 |
|
|
if(!unique_queue_name.exists(queue_names[i])) begin
|
163 |
|
|
unique_queue_name[queue_names[i]] = 1'b1;
|
164 |
|
|
end else begin
|
165 |
|
|
`uvm_info("CFG_ERROR", $sformatf("[%s]: Unable to set producer: %s. List of queue names contains dublicates", this.scb_name, producer), UVM_DEBUG);
|
166 |
|
|
return(1'b0);
|
167 |
|
|
end
|
168 |
|
|
|
169 |
|
|
// If queue does not exist then return 1'b0
|
170 |
|
|
if(!this.exist_queue(queue_names[i])) begin
|
171 |
|
|
`uvm_info("CFG_ERROR", $sformatf("[%s]: Queue: %0s is not found", this.scb_name, queue_names[i]), UVM_DEBUG);
|
172 |
|
|
return(1'b0);
|
173 |
|
|
end
|
174 |
|
|
end
|
175 |
|
|
end
|
176 |
|
|
|
177 |
|
|
// All queues exist -> set the producer
|
178 |
|
|
prod_list = new(); // Create producer list
|
179 |
|
|
prod_list.set_list(queue_names); // Set queue names in producer list
|
180 |
|
|
this.producers[producer] = prod_list; // Set producer list for producer
|
181 |
|
|
|
182 |
|
|
// Return 1'b1 since all is good
|
183 |
|
|
return(1'b1);
|
184 |
|
|
endfunction: set_producer
|
185 |
|
|
|
186 |
|
|
/// Configuration API: Checks if a given producer exists
|
187 |
|
|
function bit cl_syoscb_cfg::exist_producer(string producer);
|
188 |
|
|
return(this.producers.exists(producer)==0 ? 1'b0 : 1'b1);
|
189 |
|
|
endfunction
|
190 |
|
|
|
191 |
|
|
/// Configuration API: Returns all producers as string list
|
192 |
|
|
function void cl_syoscb_cfg::get_producers(output string producers[]);
|
193 |
|
|
string producer;
|
194 |
|
|
int unsigned idx = 0;
|
195 |
|
|
|
196 |
|
|
producers = new[this.producers.size()];
|
197 |
|
|
|
198 |
|
|
while(this.producers.next(producer)) begin
|
199 |
|
|
producers[idx++] = producer;
|
200 |
|
|
end
|
201 |
|
|
endfunction: get_producers
|
202 |
|
|
|
203 |
|
|
/// Configuration API: Gets the primary queue.
|
204 |
|
|
/// The primary queue is used by the compare algorithms to select which queue to use as the primary one.
|
205 |
|
|
function string cl_syoscb_cfg::get_primary_queue();
|
206 |
|
|
return(this.primary_queue);
|
207 |
|
|
endfunction: get_primary_queue
|
208 |
|
|
|
209 |
|
|
/// Configuration API: Sets the primary queue.
|
210 |
|
|
/// The primary queue is used by the compare algorithms to select which queue to use as the primary one.
|
211 |
|
|
function bit cl_syoscb_cfg::set_primary_queue(string primary_queue_name);
|
212 |
|
|
// If queue does not exist then return 1'b0
|
213 |
|
|
if(!this.exist_queue(primary_queue_name)) begin
|
214 |
|
|
`uvm_info("CFG_ERROR", $sformatf("[%s]: Queue: %0s is not found", this.scb_name, primary_queue_name), UVM_DEBUG);
|
215 |
|
|
return(1'b0);
|
216 |
|
|
end
|
217 |
|
|
|
218 |
|
|
// Set the primary queue
|
219 |
|
|
this.primary_queue = primary_queue_name;
|
220 |
|
|
|
221 |
|
|
// Return 1'b1 since all is good
|
222 |
|
|
return(1'b1);
|
223 |
|
|
endfunction: set_primary_queue
|
224 |
|
|
|
225 |
|
|
/// Configuration API: Set the value of the disable_clone member variable
|
226 |
|
|
function void cl_syoscb_cfg::set_disable_clone(bit dc);
|
227 |
|
|
this.disable_clone = dc;
|
228 |
|
|
endfunction
|
229 |
|
|
|
230 |
|
|
/// Configuration API: Get the value of the disable_clone member variable
|
231 |
|
|
function bit cl_syoscb_cfg::get_disable_clone();
|
232 |
|
|
return(this.disable_clone);
|
233 |
|
|
endfunction
|
234 |
|
|
|
235 |
|
|
/// Configuration API: Set the maximum number of items allowed for a given queue.
|
236 |
|
|
/// 0 (no limit) is default
|
237 |
|
|
function void cl_syoscb_cfg::set_max_queue_size(string queue_name, int unsigned mqs);
|
238 |
|
|
if(this.exist_queue(queue_name)) begin
|
239 |
|
|
this.max_queue_size[queue_name] = mqs;
|
240 |
|
|
end else begin
|
241 |
|
|
`uvm_fatal("CFG_ERROR", $sformatf("[%s]: Queue: %s not found when trying to set max_queue_size", this.scb_name, queue_name))
|
242 |
|
|
end
|
243 |
|
|
endfunction
|
244 |
|
|
|
245 |
|
|
/// Configuration API: Returns the maximum number of allowed items for a given queue.
|
246 |
|
|
/// 0 (no limit) is default
|
247 |
|
|
function int unsigned cl_syoscb_cfg::get_max_queue_size(string queue_name);
|
248 |
|
|
if(this.exist_queue(queue_name)) begin
|
249 |
|
|
return(this.max_queue_size[queue_name]);
|
250 |
|
|
end else begin
|
251 |
|
|
`uvm_fatal("CFG_ERROR", $sformatf("[%s]: Queue: %s not found when trying to get max_queue_size", this.scb_name, queue_name))
|
252 |
|
|
return(0);
|
253 |
|
|
end
|
254 |
|
|
endfunction
|
255 |
|
|
|
256 |
|
|
function string cl_syoscb_cfg::get_scb_name();
|
257 |
|
|
return(this.scb_name);
|
258 |
|
|
endfunction: get_scb_name
|
259 |
|
|
|
260 |
|
|
function void cl_syoscb_cfg::set_scb_name(string scb_name);
|
261 |
|
|
this.scb_name = scb_name;
|
262 |
|
|
endfunction: set_scb_name
|