00001 // $Id: ovm__in__order__comparator_8svh-source.html,v 1.1 2008/10/07 21:54:09 alex.marin Exp $ 00002 //---------------------------------------------------------------------- 00003 // Copyright 2007-2008 Mentor Graphics Corporation 00004 // Copyright 2007-2008 Cadence Design Systems, Inc. 00005 // All Rights Reserved Worldwide 00006 // 00007 // Licensed under the Apache License, Version 2.0 (the 00008 // "License"); you may not use this file except in 00009 // compliance with the License. You may obtain a copy of 00010 // the License at 00011 // 00012 // http://www.apache.org/licenses/LICENSE-2.0 00013 // 00014 // Unless required by applicable law or agreed to in 00015 // writing, software distributed under the License is 00016 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 00017 // CONDITIONS OF ANY KIND, either express or implied. See 00018 // the License for the specific language governing 00019 // permissions and limitations under the License. 00020 //---------------------------------------------------------------------- 00021 00022 //---------------------------------------------------------------------- 00023 // CLASS in_order_comparator 00024 // 00025 // in_order_comparator : compares two streams of data 00026 // 00027 // makes no assumptions about the relative ordering of the two streams 00028 // 00029 // T is the type of the two streams of data. 00030 // 00031 // comp and convert are functors which describe how to do 00032 // comparison and printing for T. 00033 // 00034 // These parameters can be changed for different T's : 00035 // however, we expect that the two pairs of classes above 00036 // will be OK for most cases. Built in types ( such as ints, 00037 // bits, logic, and structs ) are dealt with by using the 00038 // default functors built_in_comp and built_in_converter, while 00039 // classes should be dealt with by class_comp and 00040 // class_converter, which in turn assume the existence of comp 00041 // and convert2string functions in the class itself. 00042 //---------------------------------------------------------------------- 00043 00044 class ovm_in_order_comparator 00045 #( type T = int , 00046 type comp_type = ovm_built_in_comp #( T ) , 00047 type convert = ovm_built_in_converter #( T ) , 00048 type pair_type = ovm_built_in_pair #( T ) ) 00049 extends ovm_component; 00050 00051 typedef ovm_in_order_comparator #(T,comp_type,convert,pair_type) this_type; 00052 00053 const static string type_name = 00054 "ovm_in_order_comparator #(T,comp_type,convert,pair_type)"; 00055 00056 // The two exports. Actually, there are no assumptions made about 00057 // ordering, so it doesn't matter which way around you make the 00058 // connections 00059 00060 ovm_analysis_export #( T ) before_export , after_export; 00061 ovm_analysis_port #( pair_type ) pair_ap; 00062 00063 local tlm_analysis_fifo #( T ) before_fifo , after_fifo; 00064 int m_matches , m_mismatches; 00065 00066 00067 function new( string name , 00068 ovm_component parent ) ; 00069 00070 super.new( name, parent ); 00071 00072 before_export = new("before_export" , this ); 00073 after_export = new("after_export" , this ); 00074 00075 pair_ap = new("pair_ap" , this ); 00076 00077 before_fifo = new("before" , this ); 00078 after_fifo = new("after" , this ); 00079 00080 m_matches = 0; 00081 m_mismatches = 0; 00082 endfunction 00083 00084 virtual function string get_type_name(); 00085 return type_name; 00086 endfunction 00087 00088 virtual function void connect(); 00089 before_export.connect( before_fifo.analysis_export ); 00090 after_export.connect( after_fifo.analysis_export ); 00091 endfunction 00092 00093 00094 // run is not a user visible task. It gets pairs of befores and 00095 // afters, and compares them. Status info is updated according to the 00096 // results of this comparison. 00097 00098 virtual task run(); 00099 00100 pair_type pair; 00101 T b; 00102 T a; 00103 00104 string s; 00105 00106 forever begin 00107 00108 before_fifo.get( b ); 00109 after_fifo.get( a ); 00110 00111 if( !comp_type::comp( b , a ) ) begin 00112 00113 $sformat( s , "%s differs from %s" , 00114 convert::convert2string( a ) , 00115 convert::convert2string( b ) ); 00116 00117 ovm_report_warning("Comparator Mismatch" , s ); 00118 m_mismatches++; 00119 end 00120 else begin 00121 s = convert::convert2string( b ); 00122 ovm_report_info("Comparator Match" , s ); 00123 m_matches++; 00124 end 00125 00126 // 00127 // we make the assumption here that a transaction "sent for 00128 // analysis" is safe from being edited by another process 00129 // 00130 // hence, it is safe not to clone a and b. 00131 00132 pair = new( a , b ); 00133 pair_ap.write( pair ); 00134 end 00135 00136 endtask 00137 00138 virtual function void flush(); 00139 m_matches = 0; 00140 m_mismatches = 0; 00141 endfunction 00142 00143 endclass : ovm_in_order_comparator 00144 00145 //---------------------------------------------------------------------- 00146 // CLASS in_order_built_in_comparator 00147 //---------------------------------------------------------------------- 00148 00149 // in_order_built_in_comparator uses the default ( ie, 00150 // built_in ) comparison and printing policy classes. 00151 00152 class ovm_in_order_built_in_comparator #( type T = int ) 00153 extends ovm_in_order_comparator #( T ); 00154 00155 const static string type_name = "ovm_in_order_built_in_comparator #(T)"; 00156 00157 function new( string name , ovm_component parent ); 00158 super.new( name, parent ); 00159 endfunction 00160 00161 virtual function string get_type_name (); 00162 return type_name; 00163 endfunction 00164 00165 endclass : ovm_in_order_built_in_comparator 00166 00167 //---------------------------------------------------------------------- 00168 // CLASS in_order_class_comparator 00169 //---------------------------------------------------------------------- 00170 00171 // in_order_class_comparator uses the class comparison and 00172 // printing policy classes. This ultimately relies on the 00173 // existence of comp and convert2string methods in the 00174 // transaction type T 00175 00176 class ovm_in_order_class_comparator #( type T = int ) 00177 extends ovm_in_order_comparator #( T , 00178 ovm_class_comp #( T ) , 00179 ovm_class_converter #( T ) , 00180 ovm_class_pair #( T, T ) ); 00181 00182 const static string type_name = "ovm_in_order_class_comparator #(T)"; 00183 00184 function new( string name , ovm_component parent); 00185 super.new( name, parent ); 00186 endfunction 00187 00188 virtual function string get_type_name (); 00189 return type_name; 00190 endfunction 00191 00192 endclass : ovm_in_order_class_comparator
![]() Intelligent Design Verification Project: OVM, Revision: 1.1.0 |
Copyright (c) 2008 Intelligent Design Verification. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included here: http://www.intelligentdv.com/licenses/fdl.txt |
![]() Doxygen Version: 1.4.6 Mon Sep 29 14:23:29 2008 |