00001 // $Id: ovm__in__order__comparator_8svh-source.html,v 1.1 2008/10/07 21:54:42 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_threaded_component; 00050 00051 // The two exports. Actually, there are no assumptions made about 00052 // ordering, so it doesn't matter which way around you make the 00053 // connections 00054 00055 ovm_analysis_export #( T ) before_export , after_export; 00056 ovm_analysis_port #( pair_type ) pair_ap; 00057 00058 local tlm_analysis_fifo #( T ) before_fifo , after_fifo; 00059 int m_matches , m_mismatches; 00060 00061 00062 function new( string name , 00063 ovm_component parent ) ; 00064 00065 super.new( name, parent ); 00066 00067 before_export = new("before_export" , this ); 00068 after_export = new("after_export" , this ); 00069 00070 pair_ap = new("pair_ap" , this ); 00071 00072 before_fifo = new("before" , this ); 00073 after_fifo = new("after" , this ); 00074 00075 m_matches = 0; 00076 m_mismatches = 0; 00077 endfunction 00078 00079 function void export_connections; 00080 before_export.connect( before_fifo.analysis_export ); 00081 after_export.connect( after_fifo.analysis_export ); 00082 endfunction 00083 00084 00085 // run is not a user visible task. It gets pairs of befores and 00086 // afters, and compares them. Status info is updated according to the 00087 // results of this comparison. 00088 00089 task run(); 00090 00091 pair_type pair; 00092 T b; 00093 T a; 00094 00095 string s; 00096 00097 forever begin 00098 00099 before_fifo.get( b ); 00100 after_fifo.get( a ); 00101 00102 if( !comp_type::comp( b , a ) ) begin 00103 00104 $sformat( s , "%s differs from %s" , 00105 convert::convert2string( a ) , 00106 convert::convert2string( b ) ); 00107 00108 ovm_report_warning("Comparator Mismatch" , s ); 00109 m_mismatches++; 00110 end 00111 else begin 00112 s = convert::convert2string( b ); 00113 ovm_report_info("Comparator Match" , s ); 00114 m_matches++; 00115 end 00116 00117 // 00118 // we make the assumption here that a transaction "sent for 00119 // analysis" is safe from being edited by another process 00120 // 00121 // hence, it is safe not to clone a and b. 00122 00123 pair = new( a , b ); 00124 pair_ap.write( pair ); 00125 end 00126 00127 endtask 00128 00129 function void flush(); 00130 m_matches = 0; 00131 m_mismatches = 0; 00132 endfunction 00133 00134 endclass : ovm_in_order_comparator 00135 00136 //---------------------------------------------------------------------- 00137 // CLASS in_order_built_in_comparator 00138 //---------------------------------------------------------------------- 00139 00140 // in_order_built_in_comparator uses the default ( ie, 00141 // built_in ) comparison and printing policy classes. 00142 00143 class ovm_in_order_built_in_comparator #( type T = int ) 00144 extends ovm_in_order_comparator #( T ); 00145 00146 function new( string name , 00147 ovm_component parent ); 00148 super.new( name, parent ); 00149 endfunction 00150 00151 endclass : ovm_in_order_built_in_comparator 00152 00153 //---------------------------------------------------------------------- 00154 // CLASS in_order_class_comparator 00155 //---------------------------------------------------------------------- 00156 00157 // in_order_class_comparator uses the class comparison and 00158 // printing policy classes. This ultimately relies on the 00159 // existence of comp and convert2string methods in the 00160 // transaction type T 00161 00162 class ovm_in_order_class_comparator #( type T = int ) 00163 extends ovm_in_order_comparator #( T , 00164 ovm_class_comp #( T ) , 00165 ovm_class_converter #( T ) , 00166 ovm_class_pair #( T, T ) ); 00167 00168 function new( string name , 00169 ovm_component parent); 00170 super.new( name, parent ); 00171 endfunction 00172 00173 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:20:12 2008 |