cl_syoscb_queue_std.svh

Go to the documentation of this file.
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_MEDIUM);
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_MEDIUM);
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       void'(iter[i].next());
00087     end
00088 
00089     this.iter_sem.put();
00090     return 1;
00091   end else if(idx == this.items.size()) begin
00092     this.items.push_back(new_item);
00093     return 1;
00094   end else begin
00095     `uvm_info("OUT_OF_BOUNDS", $sformatf("Idx: %0d too large for queue %0s", idx, this.get_name()), UVM_MEDIUM);
00096     return 0;
00097   end
00098 endfunction : insert_item
00099 
00100 function cl_syoscb_queue_iterator_base cl_syoscb_queue_std::create_iterator();
00101   cl_syoscb_queue_iterator_std result;
00102 
00103   // TBD: Hmmm, busywait due to function?
00104   while(this.iter_sem.try_get() == 0);
00105 
00106   result = cl_syoscb_queue_iterator_std::type_id::create(
00107       $sformatf("%s_iter%0d", this.get_name(), this.iter_idx));
00108 
00109   // No need to check return value since set_queue will issue
00110   // and `uvm_error of something goes wrong
00111   void'(result.set_queue(this));
00112 
00113   this.iterators[result] = result;
00114   this.iter_idx++;
00115   this.iter_sem.put();
00116 
00117   return result;
00118 endfunction : create_iterator
00119 
00120 function bit cl_syoscb_queue_std::delete_iterator(cl_syoscb_queue_iterator_base iterator);
00121   if(iterator == null) begin
00122     `uvm_info("NULL", $sformatf("Asked to delete null iterator from list of iterators in %s",
00123                                 this.get_name()), UVM_MEDIUM);
00124     return 0;
00125   end else begin  
00126     // TBD: Hmmm busy wait+function?
00127     while(!this.iter_sem.try_get());
00128 
00129     this.iterators.delete(iterator);
00130     this.iter_idx--;
00131     this.iter_sem.put();
00132     return 1;
00133   end
00134 endfunction : delete_iterator
 All Classes Namespaces Files Functions Variables

Project: SyoSil ApS UVM Scoreboard, Revision: 1.0.0.0
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
Doxygen Version: 1.6.1
IDV SV Filter Version: 2.6.2
Thu Oct 30 05:34:49 2014
Find a documentation bug? Report bugs to: bugs.intelligentdv.com Project: DoxygenFilterSV