00001 // $Id: ovm__report__server_8svh-source.html,v 1.1 2008/10/07 21:54:21 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 `ifndef OVM_REPORT_SERVER_SVH 00023 `define OVM_REPORT_SERVER_SVH 00024 00025 typedef class ovm_report_object; 00026 00027 //---------------------------------------------------------------------- 00028 // CLASS ovm_report_server 00029 //---------------------------------------------------------------------- 00030 class ovm_report_server; 00031 00032 local int max_quit_count; 00033 local int quit_count; 00034 local int severity_count[ovm_severity]; 00035 local int id_count[string]; 00036 00037 bit enable_report_id_count_summary=1; 00038 00039 function new(); 00040 set_max_quit_count(0); 00041 reset_quit_count(); 00042 reset_severity_counts(); 00043 endfunction 00044 00045 //-------------------------------------------------------------------- 00046 // accessors for setting, getting, and incrementing 00047 // the various counts 00048 //-------------------------------------------------------------------- 00049 function int get_max_quit_count(); 00050 return max_quit_count; 00051 endfunction 00052 00053 function void set_max_quit_count(int count); 00054 max_quit_count = count < 0 ? 0 : count; 00055 endfunction 00056 00057 function void reset_quit_count(); 00058 quit_count = 0; 00059 endfunction 00060 00061 function void incr_quit_count(); 00062 quit_count++; 00063 endfunction 00064 00065 function int get_quit_count(); 00066 return quit_count; 00067 endfunction 00068 00069 function void set_quit_count(int quit_count); 00070 quit_count = quit_count < 0 ? 0 : quit_count; 00071 endfunction 00072 00073 function bit is_quit_count_reached(); 00074 return (quit_count >= max_quit_count); 00075 endfunction 00076 00077 function void reset_severity_counts(); 00078 ovm_severity_type s; 00079 00080 s = s.first(); 00081 forever begin 00082 severity_count[s] = 0; 00083 if(s == s.last()) break; 00084 s = s.next(); 00085 end 00086 00087 endfunction 00088 00089 function void set_severity_count(ovm_severity severity, int count); 00090 severity_count[severity] = count < 0 ? 0 : count; 00091 endfunction 00092 00093 function int get_severity_count(ovm_severity severity); 00094 return severity_count[severity]; 00095 endfunction 00096 00097 function void incr_severity_count(ovm_severity severity); 00098 severity_count[severity]++; 00099 endfunction 00100 00101 function void copy_severity_counts(ovm_report_server dst); 00102 foreach(severity_count[s]) begin 00103 dst.set_severity_count(s,severity_count[s]); 00104 end 00105 endfunction 00106 00107 function void set_id_count(string id, int count); 00108 id_count[id] = count < 0 ? 0 : count; 00109 endfunction 00110 00111 function int get_id_count(string id); 00112 if(id_count.exists(id)) 00113 return id_count[id]; 00114 return 0; 00115 endfunction 00116 00117 function void incr_id_count(string id); 00118 if(id_count.exists(id)) 00119 id_count[id]++; 00120 else 00121 id_count[id] = 1; 00122 endfunction 00123 00124 function void copy_id_counts(ovm_report_server dst); 00125 foreach(id_count[s]) begin 00126 dst.set_id_count(s,id_count[s]); 00127 end 00128 endfunction 00129 00130 //-------------------------------------------------------------------- 00131 // f_display 00132 //-------------------------------------------------------------------- 00133 function void f_display(OVM_FILE file, string str); 00134 if (file == 0) 00135 $display(str); 00136 else 00137 $fdisplay(file, str); 00138 endfunction 00139 00140 //-------------------------------------------------------------------- 00141 // report 00142 //-------------------------------------------------------------------- 00143 extern virtual function void report( 00144 ovm_severity severity, 00145 string name, 00146 string id, 00147 string message, 00148 int verbosity_level, 00149 string filename, 00150 int line, 00151 ovm_report_object client 00152 ); 00153 //-------------------------------------------------------------------- 00154 // process_report 00155 //-------------------------------------------------------------------- 00156 extern virtual function void process_report( 00157 ovm_severity severity, 00158 string name, 00159 string id, 00160 string message, 00161 ovm_action action, 00162 OVM_FILE file, 00163 string filename, 00164 int line, 00165 string composed_message, 00166 int verbosity_level, 00167 ovm_report_object client 00168 ); 00169 //-------------------------------------------------------------------- 00170 // compose_message 00171 //-------------------------------------------------------------------- 00172 extern virtual function string compose_message( 00173 ovm_severity severity, 00174 string name, 00175 string id, 00176 string message, 00177 string filename, 00178 int line 00179 ); 00180 //-------------------------------------------------------------------- 00181 // summarize 00182 // 00183 // summarize prints out report statistics to the standard 00184 // output 00185 //-------------------------------------------------------------------- 00186 00187 function void summarize(OVM_FILE file=0); 00188 string id; 00189 string name; 00190 string output_str; 00191 00192 f_display(file, ""); 00193 f_display(file, "--- OVM Report Summary ---"); 00194 f_display(file, ""); 00195 00196 if(max_quit_count != 0) begin 00197 if ( quit_count >= max_quit_count ) f_display(file, "Quit count reached!"); 00198 $sformat(output_str, "Quit count : %d of %d", 00199 quit_count, max_quit_count); 00200 f_display(file, output_str); 00201 end 00202 00203 f_display(file, "** Report counts by severity"); 00204 for(ovm_severity_type s = s.first(); 1; s = s.next()) begin 00205 if(severity_count.exists(s)) begin 00206 int cnt; 00207 cnt = severity_count[s]; 00208 name = s.name(); 00209 $sformat(output_str, "%-8s :%5d", name, cnt); 00210 f_display(file, output_str); 00211 end 00212 if(s == s.last()) break; 00213 end 00214 00215 if (enable_report_id_count_summary) begin 00216 00217 f_display(file, "** Report counts by id"); 00218 for(int found = id_count.first(id); 00219 found; 00220 found = id_count.next(id)) begin 00221 int cnt; 00222 cnt = id_count[id]; 00223 $sformat(output_str, "[%-20s] %5d", id, cnt); 00224 f_display(file, output_str); 00225 end 00226 00227 end 00228 00229 endfunction 00230 00231 //-------------------------------------------------------------------- 00232 // dump_server_state 00233 //-------------------------------------------------------------------- 00234 function void dump_server_state(); 00235 00236 string s; 00237 ovm_severity_type sev; 00238 string id; 00239 00240 f_display(0, "report server state"); 00241 f_display(0, ""); 00242 f_display(0, "+-------------+"); 00243 f_display(0, "| counts |"); 00244 f_display(0, "+-------------+"); 00245 f_display(0, ""); 00246 00247 $sformat(s, "max quit count = %5d", max_quit_count); 00248 f_display(0, s); 00249 $sformat(s, "quit count = %5d", quit_count); 00250 f_display(0, s); 00251 00252 sev = sev.first(); 00253 forever begin 00254 int cnt; 00255 cnt = severity_count[sev]; 00256 s = sev.name(); 00257 $sformat(s, "%-8s :%5d", s, cnt); 00258 f_display(0, s); 00259 if(sev == sev.last()) 00260 break; 00261 sev = sev.next(); 00262 end 00263 00264 if(id_count.first(id)) 00265 do begin 00266 int cnt; 00267 cnt = id_count[id]; 00268 $sformat(s, "%-8s :%5d", id, cnt); 00269 f_display(0, s); 00270 end 00271 while (id_count.next(id)); 00272 00273 endfunction 00274 00275 endclass 00276 00277 `include "base/ovm_report_handler.svh" 00278 00279 //---------------------------------------------------------------------- 00280 // CLASS ovm_report_global_server 00281 // 00282 // Singleton object that maintains a single global report server 00283 //---------------------------------------------------------------------- 00284 class ovm_report_global_server; 00285 00286 static ovm_report_server global_report_server = null; 00287 00288 function new(); 00289 if (global_report_server == null) 00290 global_report_server = new; 00291 endfunction 00292 00293 function ovm_report_server get_server(); 00294 return global_report_server; 00295 endfunction 00296 00297 function void set_server(ovm_report_server server); 00298 server.set_max_quit_count(global_report_server.get_max_quit_count()); 00299 server.set_quit_count(global_report_server.get_quit_count()); 00300 global_report_server.copy_severity_counts(server); 00301 global_report_server.copy_id_counts(server); 00302 global_report_server = server; 00303 endfunction 00304 00305 endclass 00306 00307 `endif // OVM_REPORT_SERVER_SVH
![]() 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:30 2008 |