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