00001 class cl_syoscb_compare_ooo extends cl_syoscb_compare_base; 00002 `uvm_object_utils(cl_syoscb_compare_ooo) 00003 00004 // TBD: max_search_window for OOO compare? 00005 00006 extern function new(string name = "cl_syoscb_compare_ooo"); 00007 extern virtual function bit compare(); 00008 extern function bit compare_do(); 00009 00010 endclass: cl_syoscb_compare_ooo 00011 00012 function cl_syoscb_compare_ooo::new(string name = "cl_syoscb_compare_ooo"); 00013 super.new(name); 00014 endfunction: new 00015 00016 function bit cl_syoscb_compare_ooo::compare(); 00017 // Here any state variables should be queried 00018 // to compute if the compare should be done or not 00019 return(this.compare_do()); 00020 endfunction: compare 00021 00022 function bit cl_syoscb_compare_ooo::compare_do(); 00023 string primary_queue_name; 00024 cl_syoscb_queue primary_queue; 00025 cl_syoscb_queue_iterator_base primary_queue_iter; 00026 string queue_names[]; 00027 int unsigned secondary_item_found[string]; 00028 bit compare_continue = 1'b1; 00029 bit compare_result = 1'b0; 00030 uvm_sequence_item primary_item; 00031 00032 primary_queue_name = this.get_primary_queue_name(); 00033 this.get_cfg.get_queues(queue_names); 00034 00035 `uvm_info("DEBUG", $sformatf("cmp-ooo: primary queue: %s", primary_queue_name), UVM_FULL); 00036 `uvm_info("DEBUG", $sformatf("cmp-ooo: number of queues: %0d", queue_names.size()), UVM_FULL); 00037 00038 if(!$cast(primary_queue, this.get_cfg().queues[primary_queue_name])) begin 00039 `uvm_fatal("TYPE_ERROR", $sformatf("Unable to cast type %0s to type %0s", 00040 this.get_cfg().queues[primary_queue_name].get_type_name(), 00041 primary_queue.get_type_name())); 00042 end 00043 00044 primary_queue_iter = primary_queue.create_iterator(); 00045 00046 // Outer loop loops through all 00047 while (!primary_queue_iter.is_done()) begin 00048 primary_item = primary_queue_iter.get_item(); 00049 00050 // Inner loop through all queues 00051 foreach(queue_names[i]) begin 00052 `uvm_info("DEBUG", $sformatf("Looking at queue: %s", queue_names[i]), UVM_FULL); 00053 00054 if(queue_names[i] != primary_queue_name) begin 00055 cl_syoscb_queue secondary_queue; 00056 cl_syoscb_queue_iterator_base secondary_queue_iter; 00057 00058 `uvm_info("DEBUG", $sformatf("%s is a secondary queue - now comparing", queue_names[i]), UVM_FULL); 00059 00060 if(!$cast(secondary_queue, this.get_cfg().queues[queue_names[i]])) begin 00061 `uvm_fatal("TYPE_ERROR", $sformatf("Unable to cast type %0s to type %0s", 00062 this.get_cfg().queues[primary_queue_name].get_type_name(), 00063 primary_queue.get_type_name())); 00064 end 00065 secondary_queue_iter = secondary_queue.create_iterator(); 00066 00067 // Only the first match is removed 00068 while(!secondary_queue_iter.is_done()) begin 00069 if(secondary_queue_iter.get_item().compare(primary_item) == 1'b1) begin 00070 secondary_item_found[queue_names[i]] = secondary_queue_iter.get_idx(); 00071 `uvm_info("DEBUG", $sformatf("Secondary item found at index: %0d", secondary_queue_iter.get_idx()), 00072 UVM_FULL); 00073 break; 00074 end 00075 if(!secondary_queue_iter.next()) begin 00076 `uvm_fatal("QUEUE_ERROR", $sformatf("Unable to get next element from iterator on secondary queue: %s", queue_names[i])); 00077 end 00078 end 00079 if(!secondary_queue.delete_iterator(secondary_queue_iter)) begin 00080 `uvm_fatal("QUEUE_ERROR", $sformatf("Unable to delete iterator from secondaery queue: %s", queue_names[i])); 00081 end 00082 end else begin 00083 `uvm_info("DEBUG", $sformatf("%s is the primary queue - skipping", queue_names[i]), UVM_FULL); 00084 end 00085 end 00086 00087 // Only start to remove items if all slave items are found (One from each slave queue) 00088 if(secondary_item_found.size() == queue_names.size()-1) begin 00089 string queue_name; 00090 `uvm_info("DEBUG", $sformatf("Found match for primary queue item : %s", 00091 primary_queue_iter.get_item().sprint()), UVM_FULL); 00092 00093 // Remove from primary 00094 if(!primary_queue.delete_item(primary_queue_iter.get_idx())) begin 00095 `uvm_error("QUEUE_ERROR", $sformatf("Unable to delete item idx %0d from queue %s", 00096 primary_queue_iter.get_idx(), primary_queue.get_name())); 00097 end 00098 00099 // Remove from all secondaries 00100 while(secondary_item_found.next(queue_name)) begin 00101 cl_syoscb_queue secondary_queue; 00102 00103 if(!$cast(secondary_queue, this.get_cfg().queues[queue_name])) begin 00104 `uvm_fatal("TYPE_ERROR", $sformatf("Unable to cast type %0s to type %0s", 00105 this.get_cfg().queues[primary_queue_name].get_type_name(), 00106 primary_queue.get_type_name())); 00107 end 00108 if(!secondary_queue.delete_item(secondary_item_found[queue_name])) begin 00109 `uvm_error("QUEUE_ERROR", $sformatf("Unable to delete item idx %0d from queue %s", 00110 secondary_item_found[queue_name], secondary_queue.get_name())); 00111 end 00112 end 00113 end 00114 00115 // TBD: Call .next() blindly since we do ot care about the 00116 // return value, since we might be at the end of the queue. 00117 // Thus, .next() will fail 00118 void'(primary_queue_iter.next()); 00119 end 00120 00121 if(!primary_queue.delete_iterator(primary_queue_iter)) begin 00122 `uvm_fatal("QUEUE_ERROR", $sformatf("Unable to delete iterator from primary queue: %s", primary_queue_name)); 00123 end 00124 00125 // TBD: See note in cl_scbsyo_compare_base.svh 00126 return(1'b1); 00127 endfunction : compare_do
|
Project: SyoSil ApS UVM Scoreboard, Revision: 1.0.0.1 |
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 Mon Nov 24 09:24:22 2014 |