00001 class cl_syoscb_queue_std extends cl_syoscb_queue; 00002 // TBD: This is a hack to get things going!! 00003 int unsigned name_hack = 0; 00004 00005 // Poor mans queue implementation as a SV queue 00006 cl_syoscb_item items[$]; 00007 00008 `uvm_component_utils_begin(cl_syoscb_queue_std) 00009 `uvm_field_queue_object(items, UVM_DEFAULT) 00010 `uvm_component_utils_end 00011 00012 // Basic queue functions 00013 extern function new(string name, uvm_component parent); 00014 extern virtual function bit add_item(string producer, uvm_sequence_item item); 00015 extern virtual function bit delete_item(int unsigned idx); 00016 extern virtual function uvm_sequence_item get_item(int unsigned idx); 00017 extern virtual function int unsigned get_size(); 00018 extern virtual function bit insert_item(string producer, uvm_sequence_item item, int unsigned idx); 00019 00020 // Iterator support functions 00021 extern virtual function cl_syoscb_queue_iterator_base create_iterator(); 00022 extern virtual function bit delete_iterator(cl_syoscb_queue_iterator_base iterator); 00023 endclass: cl_syoscb_queue_std 00024 00025 function cl_syoscb_queue_std::new(string name, uvm_component parent); 00026 super.new(name, parent); 00027 endfunction : new 00028 00029 function bit cl_syoscb_queue_std::add_item(string producer, uvm_sequence_item item); 00030 // TBD consequences of not using create instead of new? 00031 cl_syoscb_item new_item = new(.name({producer,"-item-", $psprintf("%0d", this.name_hack++)})); 00032 new_item.set_producer(.producer(producer)); 00033 new_item.set_item(.item(item)); 00034 this.items.push_back(new_item); 00035 return 1; 00036 endfunction : add_item 00037 00038 function bit cl_syoscb_queue_std::delete_item(int unsigned idx); 00039 if(idx < this.items.size()) begin 00040 cl_syoscb_queue_iterator_base iter[$]; 00041 00042 while(!this.iter_sem.try_get()); 00043 items.delete(idx); 00044 00045 // Update iterators 00046 iter = this.iterators.find(x) with (x.get_idx() < idx); 00047 for(int i = 0; i < iter.size(); i++) begin 00048 void'(iter[i].previous()); 00049 end 00050 00051 this.iter_sem.put(); 00052 return 1; 00053 end else begin 00054 `uvm_info("OUT_OF_BOUNDS", $sformatf("Idx: %0d is not present in queue: %0s", idx, this.get_name()), UVM_DEBUG); 00055 return 0; 00056 end 00057 endfunction : delete_item 00058 00059 function uvm_sequence_item cl_syoscb_queue_std::get_item(int unsigned idx); 00060 if(idx < this.items.size()) begin 00061 return items[idx].get_item(); 00062 end else begin 00063 `uvm_info("OUT_OF_BOUNDS", $sformatf("Idx: %0d is not present in queue: %0s", idx, this.get_name()), UVM_DEBUG); 00064 return null; 00065 end 00066 endfunction : get_item 00067 00068 function int unsigned cl_syoscb_queue_std::get_size(); 00069 return this.items.size(); 00070 endfunction : get_size 00071 00072 function bit cl_syoscb_queue_std::insert_item(string producer, uvm_sequence_item item, int unsigned idx); 00073 cl_syoscb_item new_item = new(.name({producer,"-item-", $psprintf("%0d", this.name_hack++)})); 00074 new_item.set_producer(.producer(producer)); 00075 new_item.set_item(.item(item)); 00076 00077 if(idx < this.items.size()) begin 00078 cl_syoscb_queue_iterator_base iter[$]; 00079 00080 while(!this.iter_sem.try_get()); 00081 this.items.insert(idx, new_item); 00082 00083 // Update iterators 00084 iter = this.iterators.find(x) with (x.get_idx() >= idx); 00085 for(int i = 0; i < iter.size(); i++) begin 00086 // Call .next() blindly. This can never fail by design, since 00087 // if it was point at the last element then it points to the second last 00088 // element prior to the .next(). The .next() call will then just 00089 // set the iterator to the correct index again after the insertion 00090 void'(iter[i].next()); 00091 end 00092 00093 this.iter_sem.put(); 00094 return 1; 00095 end else if(idx == this.items.size()) begin 00096 this.items.push_back(new_item); 00097 return 1; 00098 end else begin 00099 `uvm_info("OUT_OF_BOUNDS", $sformatf("Idx: %0d too large for queue %0s", idx, this.get_name()), UVM_DEBUG); 00100 return 0; 00101 end 00102 endfunction : insert_item 00103 00104 function cl_syoscb_queue_iterator_base cl_syoscb_queue_std::create_iterator(); 00105 cl_syoscb_queue_iterator_std result; 00106 00107 // TBD: Hmmm, busywait due to function? 00108 while(this.iter_sem.try_get() == 0); 00109 00110 result = cl_syoscb_queue_iterator_std::type_id::create( 00111 $sformatf("%s_iter%0d", this.get_name(), this.iter_idx)); 00112 00113 // No need to check return value since set_queue will issue 00114 // and `uvm_error of something goes wrong 00115 void'(result.set_queue(this)); 00116 00117 this.iterators[result] = result; 00118 this.iter_idx++; 00119 this.iter_sem.put(); 00120 00121 return result; 00122 endfunction : create_iterator 00123 00124 function bit cl_syoscb_queue_std::delete_iterator(cl_syoscb_queue_iterator_base iterator); 00125 if(iterator == null) begin 00126 `uvm_info("NULL", $sformatf("Asked to delete null iterator from list of iterators in %s", 00127 this.get_name()), UVM_DEBUG); 00128 return 0; 00129 end else begin 00130 // TBD: Hmmm busy wait+function? 00131 while(!this.iter_sem.try_get()); 00132 00133 this.iterators.delete(iterator); 00134 this.iter_idx--; 00135 this.iter_sem.put(); 00136 return 1; 00137 end 00138 endfunction : delete_iterator
|
Project: SyoSil ApS UVM Scoreboard, Revision: 1.0.0.2 |
Copyright 2014 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 Wed Feb 25 04:01:40 2015 |