00001 /// Class which base concet of a queue. All queues must extend this class 00002 /// and implement the queue API. 00003 class cl_syoscb_queue extends uvm_component; 00004 //------------------------------------- 00005 // Non randomizable variables 00006 //------------------------------------- 00007 /// Handle to the configuration 00008 protected cl_syoscb_cfg cfg; 00009 00010 /// List of iterators registered with queue 00011 protected cl_syoscb_queue_iterator_base iterators[cl_syoscb_queue_iterator_base]; 00012 00013 /// Current number of iterators 00014 protected int unsigned iter_idx; 00015 00016 /// Semaphore guarding exclusive access to the queue when 00017 /// multiple iterators are in play 00018 protected semaphore iter_sem; 00019 00020 // Counter for counting the number of inserts 00021 protected int unsigned cnt_add_item = 0; 00022 00023 //------------------------------------- 00024 // UVM Macros 00025 //------------------------------------- 00026 `uvm_component_utils_begin(cl_syoscb_queue) 00027 `uvm_field_object(cfg, UVM_DEFAULT) 00028 // TBD::JSA: Lacks a user defined implementation of field macro 00029 // for completeness since: `uvm_field_aa_object-object does not exist 00030 `uvm_field_int(iter_idx, UVM_DEFAULT) 00031 `uvm_field_int(cnt_add_item, UVM_DEFAULT) 00032 `uvm_component_utils_end 00033 00034 //------------------------------------- 00035 // Constructor 00036 //------------------------------------- 00037 extern function new(string name, uvm_component parent); 00038 00039 //------------------------------------- 00040 // UVM Phase methods 00041 //------------------------------------- 00042 extern function void build_phase(uvm_phase phase); 00043 extern function void check_phase(uvm_phase phase); 00044 extern function void report_phase(uvm_phase phase); 00045 00046 //------------------------------------- 00047 // Queue API 00048 //------------------------------------- 00049 // Basic queue functions 00050 extern virtual function bit add_item(string producer, uvm_sequence_item item); 00051 extern virtual function bit delete_item(int unsigned idx); 00052 extern virtual function cl_syoscb_item get_item(int unsigned idx); 00053 extern virtual function int unsigned get_size(); 00054 extern virtual function bit empty(); 00055 extern virtual function bit insert_item(string producer, uvm_sequence_item item, int unsigned idx); 00056 00057 // Iterator support functions 00058 extern virtual function cl_syoscb_queue_iterator_base create_iterator(); 00059 extern virtual function bit delete_iterator(cl_syoscb_queue_iterator_base iterator); 00060 00061 // Locator support functions 00062 // TBD::JSA: Locator not implemented yet 00063 00064 // Misc support functions 00065 extern function cl_syoscb_cfg get_cfg(); 00066 endclass: cl_syoscb_queue 00067 00068 function cl_syoscb_queue::new(string name, uvm_component parent); 00069 super.new(name, parent); 00070 00071 this.iter_sem = new(1); 00072 this.iter_idx = 0; 00073 endfunction: new 00074 00075 /// Gets the global scoreboard configuration 00076 function void cl_syoscb_queue::build_phase(uvm_phase phase); 00077 if (!uvm_config_db #(cl_syoscb_cfg)::get(this, "", "cfg", this.cfg)) begin 00078 `uvm_fatal("CFG_ERROR", $sformatf("[%s]: Configuration object not passed.", this.cfg.get_scb_name())) 00079 end 00080 endfunction 00081 00082 /// Checks if the queue is empty. If not then a UVM error is issued. 00083 function void cl_syoscb_queue::check_phase(uvm_phase phase); 00084 // Check that this queue is empty. If not then issue an error 00085 if(!this.empty()) begin 00086 // *NOTE*: Using this.get_name() is sufficient since the component 00087 // instance name is the queue name by definition 00088 `uvm_error("QUEUE_ERROR", $sformatf("[%s]: Queue %s not empty, entries: %0d", this.cfg.get_scb_name(), this.get_name(), this.get_size())); 00089 end 00090 endfunction 00091 00092 /// Prints queue stats 00093 function void cl_syoscb_queue::report_phase(uvm_phase phase); 00094 string stats; 00095 00096 stats = $sformatf("Inserts: %0d, Macthed: %0d, Orphans: %0d", this.cnt_add_item, this.cnt_add_item-this.get_size(), this.get_size()); 00097 00098 // *NOTE*: Using this.get_name() is sufficient since the component 00099 // instance name is the queue name by definition 00100 `uvm_info("QUEUE", $sformatf("[%s]: Statistics for queue: %s:\n%s", this.cfg.get_scb_name(), this.get_name(), stats), UVM_NONE) 00101 endfunction 00102 00103 /// <b>Queue API:</b> Adds an uvm_sequence_item. The implementation must wrap this in a 00104 /// cl_syoscb_item object before the item is inserted 00105 function bit cl_syoscb_queue::add_item(string producer, uvm_sequence_item item); 00106 `uvm_fatal("IMPL_ERROR", $sformatf("[%s]: cl_syoscb_queue::add_item() *MUST* be overwritten", this.cfg.get_scb_name())); 00107 return(1'b0); 00108 endfunction 00109 00110 /// <b>Queue API:</b> Deletes the item at index idx from the queue 00111 function bit cl_syoscb_queue::delete_item(int unsigned idx); 00112 `uvm_fatal("IMPL_ERROR", $sformatf("[%s]: cl_syoscb_queue::delete_item() *MUST* be overwritten", this.cfg.get_scb_name())); 00113 return(1'b0); 00114 endfunction 00115 00116 /// <b>Queue API:</b> Gets the item at index idx from the queue 00117 function cl_syoscb_item cl_syoscb_queue::get_item(int unsigned idx); 00118 `uvm_fatal("IMPL_ERROR", $sformatf("[%s]: cl_syoscb_queue::get_item() *MUST* be overwritten", this.cfg.get_scb_name())); 00119 return(null); 00120 endfunction 00121 00122 /// <b>Queue API:</b> Returns the current size of the queue 00123 function int unsigned cl_syoscb_queue::get_size(); 00124 `uvm_fatal("IMPL_ERROR", $sformatf("[%s]: cl_syoscb_queue::get_size() *MUST* be overwritten", this.cfg.get_scb_name())); 00125 return(0); 00126 endfunction 00127 00128 /// <b>Queue API:</b> Returns whether or not the queue is empty. 1'b0 means thet te queue 00129 /// is not empty. 1'b1 means that the queue is empty 00130 function bit cl_syoscb_queue::empty(); 00131 `uvm_fatal("IMPL_ERROR", $sformatf("[%s]: cl_syoscb_queue::empty() *MUST* be overwritten", this.cfg.get_scb_name())); 00132 return(0); 00133 endfunction 00134 00135 /// <b>Queue API:</b> Inserts a uvm_sequence_item at index idx. The implementation must wrap 00136 /// the uvm_sequence_item in a cl_syoscb_item before it is inserted. 00137 function bit cl_syoscb_queue::insert_item(string producer, uvm_sequence_item item, int unsigned idx); 00138 `uvm_fatal("IMPL_ERROR", $sformatf("[%s]: cl_syoscb_queue::insert_item() *MUST* be overwritten", this.cfg.get_scb_name())); 00139 return(1'b0); 00140 endfunction 00141 00142 /// <b>Queue API:</b> Creates an iterator for this queue. 00143 function cl_syoscb_queue_iterator_base cl_syoscb_queue::create_iterator(); 00144 `uvm_fatal("IMPL_ERROR", $sformatf("[%s]: cl_syoscb_queue::create_iterator() *MUST* be overwritten", this.cfg.get_scb_name())); 00145 return(null); 00146 endfunction 00147 00148 /// <b>Queue API:</b> Deletes a given iterator for this queue. 00149 function bit cl_syoscb_queue::delete_iterator(cl_syoscb_queue_iterator_base iterator); 00150 `uvm_fatal("IMPL_ERROR", $sformatf("[%s]: cl_syoscb_queue::delete_item() *MUST* be overwritten", this.cfg.get_scb_name())); 00151 return(1'b0); 00152 endfunction 00153 00154 function cl_syoscb_cfg cl_syoscb_queue::get_cfg(); 00155 return(this.cfg); 00156 endfunction
|
Project: SyoSil ApS UVM Scoreboard, Revision: 1.0.2.5 Copyright 2014-2015 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 Version: 1.6.1 IDV SV Filter Version: 2.6.2 Sat Nov 28 05:41:54 2015 |