00001 // $Id: a00258.html,v 1.1 2009/01/07 19:29:49 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 `include "base/ovm_printer.svh" 00023 `include "base/ovm_misc.svh" 00024 00025 function string ovm_printer_knobs::get_radix_str(ovm_radix_enum radix); 00026 if(show_radix == 0) return ""; 00027 if(radix == OVM_NORADIX) radix = default_radix; 00028 case(radix) 00029 OVM_BIN: return bin_radix; 00030 OVM_OCT: return oct_radix; 00031 OVM_UNSIGNED: return unsigned_radix; 00032 OVM_DEC: return dec_radix; 00033 OVM_HEX: return hex_radix; 00034 default: return ""; 00035 endcase 00036 endfunction 00037 00038 //------------------------------------------------------------------------------ 00039 // 00040 // Loose functions for utility: 00041 // int ovm_num_characters (ovm_radix_enum radix, ovm_bitstream_t value, int size) 00042 // string ovm_vector_to_string (ovm_bitstream_t value, int size, 00043 // ovm_radix_enum radix=OVM_NORADIX); 00044 // 00045 //------------------------------------------------------------------------------ 00046 00047 //------------------------------------------------------------------------------ 00048 // ovm_num_characters 00049 // -------------- 00050 // 00051 // int ovm_num_characters (ovm_radix_enum radix, ovm_bitstream_t value, int size) 00052 // Precondition: 00053 // radix: the radix to use to calculate the number of characters 00054 // value: integral value to test to find number of characters 00055 // size: number of bits in value 00056 // radix_str: the string that identifes the radix 00057 // Postcondition: 00058 // Returns the minimum number of ascii characters needed to represent 00059 // value in the desired base. 00060 //------------------------------------------------------------------------------ 00061 00062 function automatic int ovm_num_characters (ovm_radix_enum radix, ovm_bitstream_t value, 00063 int size, string radix_str=""); 00064 int chars; 00065 int r; 00066 ovm_bitstream_t mask; 00067 if(radix==OVM_NORADIX) 00068 radix = OVM_HEX; 00069 00070 mask = {OVM_STREAMBITS{1'b1}}; 00071 mask <<= size; 00072 mask = ~mask; 00073 value &= mask; 00074 00075 //fast way of finding number of characters is to use division, slow way 00076 //is to construct a string. But, if x's are in the value then the 00077 //string method is much easier. 00078 if((^value) !== 1'bx) begin 00079 case(radix) 00080 OVM_BIN: r = 2; 00081 OVM_OCT: r = 8; 00082 OVM_UNSIGNED: r = 10; 00083 OVM_DEC: r = 10; 00084 OVM_HEX: r = 16; 00085 OVM_TIME: r = 10; 00086 OVM_STRING: return size/8; 00087 default: r = 16; 00088 endcase 00089 chars = radix_str.len() + 1; 00090 if((radix == OVM_DEC) && (value[size-1] === 1)) begin 00091 //sign extend and get 2's complement of value 00092 mask = ~mask; 00093 value |= mask; 00094 value = ~value + 1; 00095 chars++; //for the negative 00096 end 00097 for(ovm_bitstream_t i=r; value/i != 0; i*=r) 00098 chars++; 00099 return chars; 00100 end 00101 else begin 00102 string s; 00103 s = ovm_vector_to_string(value, size, radix, radix_str); 00104 return s.len(); 00105 end 00106 endfunction 00107 00108 function string ovm_vector_to_string (ovm_bitstream_t value, int size, 00109 ovm_radix_enum radix=OVM_NORADIX, 00110 string radix_str=""); 00111 ovm_bitstream_t mask; 00112 string str; 00113 00114 mask = {OVM_STREAMBITS{1'b1}}; 00115 mask <<= size; 00116 mask = ~mask; 00117 00118 case(radix) 00119 OVM_BIN: begin 00120 $swrite(str, "%0s%0b", radix_str, value&mask); 00121 end 00122 OVM_OCT: begin 00123 $swrite(str, "%0s%0o", radix_str, value&mask); 00124 end 00125 OVM_UNSIGNED: begin 00126 $swrite(str, "%0s%0d", radix_str, (value&mask)); 00127 end 00128 OVM_DEC: begin 00129 if(value[size-1] === 1) begin 00130 //sign extend for negative value 00131 ovm_bitstream_t sval; mask = ~mask; 00132 sval = (value|mask); 00133 //don't show radix for negative 00134 $swrite(str, "%0d", sval); 00135 end 00136 else begin 00137 $swrite(str, "%0s%0d", radix_str, (value&mask)); 00138 end 00139 end 00140 OVM_STRING: begin 00141 $swrite(str, "%0s%0s", radix_str, value&mask); 00142 end 00143 OVM_TIME: begin 00144 $swrite(str, "%0s%0t", radix_str, value&mask); 00145 end 00146 default: begin 00147 $swrite(str, "%0s%0x", radix_str, value&mask); 00148 end 00149 endcase 00150 return str; 00151 endfunction 00152 00153 //------------------------------------------------------------------------------ 00154 // 00155 // Class: ovm_printer 00156 // 00157 //------------------------------------------------------------------------------ 00158 00159 // write_stream 00160 // ------------ 00161 00162 function void ovm_printer::write_stream(string str); 00163 string space; 00164 if(!knobs.max_width) return; 00165 if(str[str.len()-1] == " ") begin 00166 space = " "; 00167 str = str.substr(0,str.len()-2); 00168 end 00169 else space = ""; 00170 00171 if((knobs.max_width != -1) && (str.len() > knobs.max_width)) begin 00172 str = {str.substr(0, knobs.max_width-2), knobs.truncation}; 00173 end 00174 if(knobs.sprint) 00175 m_string = {m_string, str, space}; 00176 else 00177 $fwrite(knobs.mcd, "%s%s", str, space); 00178 knobs.column+=str.len()+space.len(); 00179 endfunction 00180 00181 00182 // print_header 00183 // ------------ 00184 00185 function void ovm_printer::print_header(); 00186 if(!m_scope.depth()) begin 00187 m_scope.set_arg(""); 00188 m_string = ""; 00189 write_stream(knobs.prefix); 00190 indent(knobs.global_indent, " "); 00191 end 00192 return; 00193 endfunction 00194 00195 00196 // print_footer 00197 // ------------ 00198 00199 function void ovm_printer::print_footer(); 00200 return; 00201 endfunction 00202 00203 00204 // print_id 00205 // -------- 00206 00207 function void ovm_printer::print_id(string id, byte scope_separator="."); 00208 string str, idstr; 00209 if(id == "") return; 00210 if(knobs.identifier) begin 00211 if(knobs.full_name || id == "...") begin 00212 str = { id, " " }; 00213 end 00214 else begin 00215 str = ovm_leaf_scope(id, scope_separator); 00216 end 00217 write_stream(str); 00218 end 00219 return; 00220 endfunction 00221 00222 00223 // print_type_name 00224 // --------------- 00225 00226 function void ovm_printer::print_type_name(string name, bit is_object=0); 00227 if(knobs.type_name && name.len() && name != "-") begin 00228 write_stream(" ("); 00229 write_stream(name); 00230 write_stream(")"); 00231 end 00232 return; 00233 endfunction 00234 00235 00236 // print_size 00237 // ---------- 00238 00239 function void ovm_printer::print_size(int size=-1); 00240 string str; 00241 if(!knobs.size) 00242 return; 00243 if(size == -1) 00244 return; 00245 else 00246 $swrite(str, "%0d", size); 00247 00248 if(knobs.sprint) 00249 m_string = {m_string, " (", str, ") "}; 00250 else 00251 $fwrite(knobs.mcd, " (%s) ", str); 00252 knobs.column+=str.len()+4; 00253 return; 00254 endfunction 00255 00256 00257 // print_value 00258 // ----------- 00259 00260 function void ovm_printer::print_value(ovm_bitstream_t value, int size, 00261 ovm_radix_enum radix=OVM_NORADIX); 00262 string str; 00263 00264 if(radix == OVM_NORADIX) 00265 radix = knobs.default_radix; 00266 str = ovm_vector_to_string (value, size, radix, knobs.get_radix_str(radix)); 00267 00268 // if(knobs.sprint) 00269 // m_string = {m_string, str}; 00270 // else 00271 // $fwrite(knobs.mcd, "%s", str); 00272 // knobs.column+=str.len(); 00273 write_stream(str); 00274 endfunction 00275 00276 00277 // print_value_object 00278 // ------------------ 00279 00280 function void ovm_printer::print_value_object (ovm_object value); 00281 string str; 00282 if(!knobs.reference) return; 00283 `ifdef INCA 00284 str = ovm_object_value_str(value); 00285 write_stream({"(", str, ")"}); 00286 `else 00287 `endif 00288 endfunction 00289 00290 00291 // print_value_string 00292 // ------------------ 00293 00294 function void ovm_printer::print_value_string (string value); 00295 if(value != "-") 00296 write_stream ( value ); 00297 endfunction 00298 00299 00300 // print_value_array 00301 // ----------------- 00302 00303 function void ovm_printer::print_value_array (string value="", int size=0); 00304 write_stream(value); 00305 endfunction 00306 00307 00308 // print_array_header 00309 // ------------------ 00310 00311 function void ovm_printer::print_array_header (string name, int size, 00312 string arraytype="array", byte scope_separator="."); 00313 00314 if(name != "") 00315 m_scope.set_arg(name); 00316 print_id (m_scope.get_arg(), scope_separator); 00317 print_type_name (arraytype); 00318 print_size (size); 00319 print_value_array("", size); 00320 print_newline(); 00321 m_scope.down(name, null); 00322 m_array_stack.push_back(1); 00323 endfunction 00324 00325 00326 // print_array_footer 00327 // ------------------ 00328 00329 function void ovm_printer::print_array_footer (int size=0); 00330 if(m_array_stack.size()) begin 00331 m_scope.up(null); 00332 void'(m_array_stack.pop_front()); 00333 end 00334 endfunction 00335 00336 00337 // print_array_range 00338 // ----------------- 00339 00340 function void ovm_printer::print_array_range(int min, int max); 00341 string tmpstr; 00342 if(min == -1 && max == -1) return; 00343 if(min == -1) min = max; 00344 if(max == -1) max = min; 00345 if(max < min) return; 00346 // $swrite(tmpstr, "[%0d:%0d]", min, max); 00347 tmpstr = "..."; 00348 print_generic(tmpstr, "...", -2, " ..."); 00349 endfunction 00350 00351 00352 // print_field 00353 // ----------- 00354 00355 function void ovm_printer::print_field (string name, 00356 ovm_bitstream_t value, 00357 int size, 00358 ovm_radix_enum radix=OVM_NORADIX, 00359 byte scope_separator=".", 00360 string type_name=""); 00361 print_header(); 00362 00363 if(name != "") 00364 m_scope.set_arg(name); 00365 00366 print_id (m_scope.get_arg(), scope_separator); 00367 if(type_name != "") begin 00368 print_type_name(type_name); 00369 end 00370 else begin 00371 if(radix == OVM_TIME) 00372 print_type_name ("time"); 00373 else if(radix == OVM_STRING) 00374 print_type_name ("string"); 00375 else 00376 print_type_name ("integral"); 00377 end 00378 print_size (size); 00379 print_value ( value, size, radix); 00380 print_newline(); 00381 00382 print_footer(); 00383 endfunction 00384 00385 00386 // print_time 00387 // ---------- 00388 00389 function void ovm_printer::print_time (string name, time value, 00390 byte scope_separator="."); 00391 print_field(name, value, 64, OVM_TIME, scope_separator); 00392 endfunction 00393 00394 00395 // print_object_header 00396 // ------------------- 00397 00398 function void ovm_printer::print_object_header ( string name, 00399 ovm_object value, 00400 byte scope_separator="."); 00401 print_header(); 00402 00403 if(name != "") 00404 m_scope.set_arg(name); 00405 print_id (m_scope.get_arg(), scope_separator); 00406 00407 if(value != null) 00408 print_type_name(value.get_type_name()); 00409 else 00410 print_type_name ("object"); 00411 print_size (-1); 00412 print_value_object ( value ); 00413 print_newline(); 00414 endfunction 00415 00416 00417 // print_object 00418 // ------------ 00419 00420 function void ovm_printer::print_object (string name, ovm_object value, 00421 byte scope_separator="."); 00422 ovm_component named, child; 00423 00424 if(name == "") begin 00425 if(value!=null) begin 00426 if((m_scope.depth()==0) && $cast(named, value)) begin 00427 name = named.get_full_name(); 00428 end 00429 else begin 00430 name=value.get_name(); 00431 end 00432 end 00433 end 00434 00435 if(name == "") 00436 name = "<unnamed>"; 00437 00438 print_object_header(name, value, scope_separator); 00439 00440 if(value != null) 00441 if((knobs.depth == -1 || (knobs.depth > m_scope.depth())) && 00442 !m_scope.in_hierarchy(value)) 00443 begin 00444 00445 m_scope.down(name, value); 00446 00447 //Handle children of the named_object 00448 if($cast(named, value)) begin 00449 string name; 00450 if (named.get_first_child(name)) 00451 do begin 00452 child = named.get_child(name); 00453 if(child.print_enabled) 00454 this.print_object("",child); 00455 end while (named.get_next_child(name)); 00456 end 00457 if(knobs.sprint) 00458 //ignore the return because the m_string will be appended 00459 void'(value.sprint(this)); 00460 else begin 00461 value.print(this); 00462 end 00463 00464 if(name[0] == "[") 00465 m_scope.up(value,"["); 00466 else 00467 m_scope.up(value,"."); 00468 end 00469 00470 print_footer(); 00471 endfunction 00472 00473 00474 // istop 00475 // ----- 00476 00477 function bit ovm_printer::istop (); 00478 return (m_scope.depth() == 0); 00479 endfunction 00480 00481 00482 // print_string 00483 // ------------ 00484 00485 function void ovm_printer::print_string (string name, string value, 00486 byte scope_separator="."); 00487 print_header(); 00488 00489 if(name != "") 00490 m_scope.set_arg(name); 00491 00492 print_id (m_scope.get_arg(), scope_separator); 00493 print_type_name ("string"); 00494 print_size (value.len()); 00495 //print_value_string ( {"\"", value, "\""} ); 00496 print_value_string ( value ); 00497 print_newline(); 00498 00499 print_footer(); 00500 endfunction 00501 00502 00503 // print_newline 00504 // ------------- 00505 00506 function void ovm_printer::print_newline(bit do_global_indent=1); 00507 write_stream("\n"); 00508 if(do_global_indent) begin 00509 write_stream(knobs.prefix); 00510 indent(knobs.global_indent, " "); 00511 end 00512 knobs.column=0; 00513 return; 00514 endfunction 00515 00516 00517 // print_generic 00518 // ------------- 00519 00520 function void ovm_printer::print_generic (string name, string type_name, 00521 int size, string value, byte scope_separator="."); 00522 print_header(); 00523 00524 if(name != "") 00525 m_scope.set_arg(name); 00526 00527 if(name == "...") 00528 print_id (name, scope_separator); 00529 else 00530 print_id (m_scope.get_arg(), scope_separator); 00531 print_type_name (type_name); 00532 print_size (size); 00533 print_value_string ( value ); 00534 print_newline(); 00535 00536 print_footer(); 00537 endfunction 00538 00539 00540 // index 00541 // ----- 00542 00543 function int ovm_printer::index(string name); 00544 string tmp; 00545 if(name == "" || name[name.len()-1] != "]") 00546 return -1; 00547 tmp=""; 00548 for(int c = name.len()-2; c>=0 && name[c] != "["; --c) begin 00549 tmp = {" ", tmp}; 00550 tmp[0] = name[c]; 00551 end 00552 if(!tmp.len()) 00553 return -1; 00554 return tmp.atoi(); 00555 endfunction 00556 00557 00558 // index_string 00559 // ------------ 00560 00561 function string ovm_printer::index_string(int index, string name=""); 00562 index_string.itoa(index); 00563 index_string = { name, "[", index_string, "]" }; 00564 endfunction 00565 00566 00567 // indent 00568 // ------ 00569 00570 function void ovm_printer::indent(int depth, string indent_str=" "); 00571 for(int i=0; i<depth; ++i) begin 00572 write_stream(indent_str); 00573 end 00574 endfunction 00575 00576 00577 //------------------------------------------------------------------------------ 00578 // 00579 // Class: ovm_table_printer 00580 // 00581 //------------------------------------------------------------------------------ 00582 00583 // new 00584 // --- 00585 00586 function ovm_table_printer::new(); 00587 super.new(); 00588 super.knobs = knobs; 00589 endfunction 00590 00591 00592 // print_header 00593 // ------------ 00594 00595 function void ovm_table_printer::print_header(); 00596 ovm_printer::print_header(); 00597 if(!knobs.header || m_scope.depth() != 0) return; 00598 00599 for(int i=0; 00600 i<(knobs.name_width+knobs.type_width+knobs.size_width+knobs.value_width); 00601 ++i) 00602 write_stream("-"); 00603 00604 print_newline(); 00605 if(knobs.name_width) begin 00606 if(knobs.max_width != -1) knobs.max_width = knobs.name_width; 00607 write_stream("Name "); 00608 indent(knobs.name_width-5, " "); 00609 end 00610 if(knobs.type_width) begin 00611 if(knobs.max_width != -1) knobs.max_width = knobs.type_width; 00612 write_stream("Type "); 00613 indent(knobs.type_width-5, " "); 00614 end 00615 if(knobs.size_width) begin 00616 if(knobs.max_width != -1) knobs.max_width = knobs.size_width-1; 00617 write_stream("Size "); 00618 indent(knobs.size_width-5, " "); 00619 end 00620 if(knobs.value_width) begin 00621 if(knobs.max_width != -1) knobs.max_width = knobs.value_width; 00622 indent(knobs.value_width-5, " "); 00623 write_stream("Value"); 00624 end 00625 00626 print_newline(); 00627 for(int i=0; 00628 i<(knobs.name_width+knobs.type_width+knobs.size_width+knobs.value_width); 00629 ++i) 00630 write_stream("-"); 00631 print_newline(); 00632 knobs.column=0; 00633 endfunction 00634 00635 00636 // print_footer 00637 // ------------ 00638 00639 function void ovm_table_printer::print_footer(); 00640 if(!knobs.footer || m_scope.depth() != 0) return; 00641 for(int i=0; 00642 i<(knobs.name_width+knobs.type_width+knobs.size_width+knobs.value_width); 00643 ++i) 00644 write_stream("-"); 00645 print_newline(0); 00646 knobs.column=0; 00647 endfunction 00648 00649 00650 // print_id 00651 // -------- 00652 00653 function void ovm_table_printer::print_id (string id, byte scope_separator="."); 00654 int fn; 00655 if(!knobs.name_width) return; 00656 if(knobs.max_width != -1) 00657 knobs.max_width=knobs.name_width- 00658 (m_scope.depth()*knobs.indent_str.len())-1; 00659 fn = knobs.full_name; 00660 if(knobs.show_root && m_scope.depth()==0) 00661 knobs.full_name = 1; 00662 00663 indent(m_scope.depth(), knobs.indent_str); 00664 super.print_id(id, scope_separator); 00665 indent(knobs.name_width-knobs.column, " "); 00666 00667 knobs.full_name = fn; 00668 endfunction 00669 00670 00671 // print_type_name 00672 // --------------- 00673 00674 function void ovm_table_printer::print_type_name (string name, bit is_object=0); 00675 if(!knobs.type_width) return; 00676 if(knobs.max_width != -1) knobs.max_width = knobs.type_width-1; 00677 00678 indent(knobs.name_width-knobs.column, " "); 00679 if(knobs.type_name) begin 00680 write_stream({name, " "}); 00681 end 00682 indent((knobs.name_width+knobs.type_width)-knobs.column, " "); 00683 endfunction 00684 00685 00686 // print_size 00687 // ---------- 00688 00689 function void ovm_table_printer::print_size (int size=-1); 00690 string str; 00691 int chars; 00692 00693 if(!knobs.size_width) return; 00694 if(knobs.max_width != -1) knobs.max_width = knobs.size_width-1; 00695 00696 if(!knobs.size) 00697 size = -1; 00698 00699 if(size == -1) chars = 1; 00700 else chars = ovm_num_characters (OVM_DEC, size, 32); 00701 indent(knobs.type_width-knobs.column-1, " "); 00702 indent(knobs.size_width-knobs.column-chars-1, " "); 00703 if(size == -1) 00704 str = "-"; 00705 else if(size == -2) 00706 str = "..."; 00707 else 00708 $swrite(str, "%0d", size); 00709 indent((knobs.name_width+knobs.type_width)-knobs.column, " "); 00710 write_stream(str); 00711 write_stream(" "); 00712 indent((knobs.name_width+knobs.type_width+knobs.size_width)-knobs.column, 00713 " "); 00714 return; 00715 endfunction 00716 00717 00718 // print_value 00719 // ----------- 00720 00721 function void ovm_table_printer::print_value (ovm_bitstream_t value, int size, 00722 ovm_radix_enum radix=OVM_NORADIX); 00723 int chars; 00724 string s; 00725 00726 if(!knobs.value_width) return; 00727 if(knobs.max_width != -1) knobs.max_width = knobs.value_width; 00728 00729 if(radix==OVM_NORADIX) radix = knobs.default_radix; 00730 if(radix != OVM_TIME) begin 00731 if(knobs.show_radix) begin 00732 if((radix != OVM_DEC) || (value[size-1] !== 1)) //for negative, don't print radix 00733 chars = ovm_num_characters(radix, value, size, knobs.get_radix_str(radix)); 00734 else 00735 chars = ovm_num_characters(radix, value, size); 00736 end 00737 else 00738 chars = ovm_num_characters(radix, value, size); 00739 end 00740 else begin 00741 $swrite(s, "%0t", value); 00742 chars = s.len(); 00743 end 00744 indent((knobs.name_width+knobs.type_width+knobs.size_width)-knobs.column, 00745 " "); 00746 indent(knobs.value_width-chars, " "); 00747 super.print_value(value, size, radix); 00748 endfunction 00749 00750 00751 // ovm_object_value_str 00752 // --------------------- 00753 00754 // This function is needed to work around a but in $swrite 00755 function string ovm_object_value_str(ovm_object v); 00756 if(v == null) return "<null>"; 00757 `ifdef INCA 00758 $swrite(ovm_object_value_str, "@%0d",v); 00759 `else 00760 ovm_object_value_str.itoa(v.get_inst_id()); 00761 ovm_object_value_str = {v.get_name(),"@",ovm_object_value_str}; 00762 `endif 00763 endfunction 00764 00765 // print_value_object 00766 // ------------------ 00767 function void ovm_table_printer::print_value_object (ovm_object value); 00768 string str; 00769 00770 if(!knobs.value_width) return; 00771 if(knobs.max_width != -1) knobs.max_width = knobs.value_width-1; 00772 if(!knobs.reference) begin 00773 indent((knobs.name_width+knobs.type_width+knobs.size_width)-knobs.column, 00774 " "); 00775 indent(knobs.value_width-1, " "); 00776 write_stream("-"); 00777 end 00778 else begin 00779 indent((knobs.name_width+knobs.type_width+knobs.size_width)-knobs.column, 00780 " "); 00781 str = ovm_object_value_str(value); 00782 indent(knobs.value_width-str.len(), " "); 00783 if(!knobs.sprint) begin 00784 write_stream(str); 00785 end 00786 else begin 00787 m_string = {m_string, str}; 00788 end 00789 end 00790 endfunction 00791 00792 00793 // print_value_string 00794 // ------------------ 00795 00796 function void ovm_table_printer::print_value_string (string value); 00797 if(!knobs.value_width) return; 00798 if(knobs.max_width != -1) knobs.max_width = knobs.value_width; 00799 00800 indent((knobs.name_width+knobs.type_width+knobs.size_width)-knobs.column, 00801 " "); 00802 indent(knobs.value_width-value.len(), " "); 00803 write_stream(value); 00804 endfunction 00805 00806 00807 // print_value_array 00808 // ----------------- 00809 00810 function void ovm_table_printer::print_value_array (string value="", 00811 int size=0); 00812 if(!value.len()) 00813 value = "-"; 00814 print_value_string(value); 00815 endfunction 00816 00817 //------------------------------------------------------------------------------ 00818 // 00819 // Class: ovm_tree_printer 00820 // 00821 //------------------------------------------------------------------------------ 00822 00823 00824 // print_value_object 00825 // ------------------ 00826 00827 function ovm_tree_printer::new(); 00828 super.new(); 00829 super.knobs = knobs; 00830 knobs.size = 0; 00831 endfunction 00832 00833 00834 // print_scope_close 00835 // ----------------- 00836 00837 function void ovm_tree_printer::print_scope_close(); 00838 if(((knobs.depth == -1) || (knobs.depth > m_scope.depth())) && 00839 (knobs.separator.len()==2)) 00840 begin 00841 indent(m_scope.depth(), knobs.indent_str); 00842 if(knobs.sprint) begin 00843 //Can't use swrite on a string index, so use this workaround 00844 //$swrite(m_string, "%c", knobs.separator[1]); 00845 m_string = {m_string, " "}; 00846 m_string[m_string.len()-1] = knobs.separator[1]; 00847 end 00848 else begin 00849 $fwrite(knobs.mcd, "%c", knobs.separator[1]); 00850 end 00851 if(m_scope.depth()) 00852 print_newline(); 00853 else 00854 print_newline(0); 00855 knobs.column=0; 00856 end 00857 return; 00858 endfunction 00859 00860 00861 // print_scope_open 00862 // ---------------- 00863 00864 function void ovm_tree_printer::print_scope_open(); 00865 if(((knobs.depth == -1) || (knobs.depth > m_scope.depth())) && 00866 knobs.separator.len()>0) 00867 begin 00868 if(knobs.sprint) begin 00869 //Can't use swrite on a string index, so use this workaround 00870 //$swrite(m_string, "%c", knobs.separator[0]); 00871 m_string = {m_string, " "}; 00872 m_string[m_string.len()-1] = knobs.separator[0]; 00873 end 00874 else 00875 $fwrite(knobs.mcd, " %c", knobs.separator[0]); 00876 knobs.column++; 00877 end 00878 return; 00879 endfunction 00880 00881 00882 // print_id 00883 // -------- 00884 00885 function void ovm_tree_printer::print_id (string id, byte scope_separator="."); 00886 int fn; 00887 fn = knobs.full_name; 00888 if(knobs.show_root && m_scope.depth()==0) 00889 knobs.full_name = 1; 00890 00891 indent(m_scope.depth(), knobs.indent_str); 00892 super.print_id(id, scope_separator); 00893 if(id == "" || id == "...") return; 00894 write_stream(": "); 00895 00896 knobs.full_name = fn; 00897 endfunction 00898 00899 00900 // print_type_name 00901 // --------------- 00902 00903 function void ovm_tree_printer::print_type_name (string name, bit is_object=0); 00904 if(knobs.type_name && name.len()>0) begin 00905 if(is_object) 00906 begin 00907 write_stream("("); 00908 write_stream(name); 00909 if(!knobs.reference) 00910 write_stream(")"); //end paren is printed by ::print_value_object 00911 end 00912 end 00913 endfunction 00914 00915 00916 // print_string 00917 // ------------ 00918 00919 function void ovm_tree_printer::print_string (string name, string value, 00920 byte scope_separator="."); 00921 print_header(); 00922 00923 if(name != "") 00924 m_scope.set_arg(name); 00925 00926 print_id (m_scope.get_arg(), scope_separator); 00927 print_type_name ("string"); 00928 //print_value_string ( {"\"", value, "\""} ); 00929 print_value_string ( value ); 00930 print_newline(); 00931 00932 print_footer(); 00933 endfunction 00934 00935 00936 // print_object_header 00937 // ------------------- 00938 00939 function void ovm_tree_printer::print_object_header ( string name, 00940 ovm_object value, 00941 byte scope_separator="."); 00942 ovm_component no; 00943 print_header(); 00944 00945 if(name != "" && name != "<unnamed>") 00946 m_scope.set_arg(name); 00947 print_id (m_scope.get_arg(), scope_separator); 00948 00949 if(value!=null) 00950 print_type_name(value.get_type_name(), 1); 00951 else 00952 print_type_name ("object", 1); 00953 print_size (-1); 00954 print_value_object ( value ); 00955 print_newline(); 00956 endfunction 00957 00958 00959 // print_object 00960 // ------------ 00961 00962 function void ovm_tree_printer::print_object (string name, ovm_object value, 00963 byte scope_separator="."); 00964 super.print_object(name, value, scope_separator); 00965 if(value!=null) 00966 print_scope_close(); 00967 endfunction 00968 00969 00970 // print_value_object 00971 // ------------------ 00972 00973 function void ovm_tree_printer::print_value_object (ovm_object value); 00974 string str; 00975 if(!knobs.reference) begin 00976 if(value!=null) 00977 print_scope_open(); 00978 return; 00979 end 00980 `ifdef INCA 00981 str = ovm_object_value_str(value); 00982 if(value == null) 00983 write_stream(" <null>) "); 00984 else 00985 write_stream({str, ") "}); 00986 `else 00987 write_stream(") "); 00988 `endif 00989 if(value!=null) 00990 print_scope_open(); 00991 endfunction 00992 00993 // print_value_array 00994 // ----------------- 00995 00996 function void ovm_tree_printer::print_value_array (string value= "", 00997 int size=0); 00998 if(size && ((knobs.depth == -1) || (knobs.depth > m_scope.depth()+1))) 00999 print_scope_open(); 01000 endfunction 01001 01002 01003 // print_array_footer 01004 // ------------------ 01005 01006 function void ovm_tree_printer::print_array_footer (int size=0); 01007 ovm_printer::print_array_footer(size); 01008 if(size) 01009 print_scope_close(); 01010 endfunction 01011 01012 01013 //------------------------------------------------------------------------------ 01014 // 01015 // Class: ovm_line_printer 01016 // 01017 //------------------------------------------------------------------------------ 01018 01019 // new 01020 // --- 01021 01022 function ovm_line_printer::new(); 01023 super.new(); 01024 knobs.indent_str = ""; 01025 endfunction 01026 01027 01028 // print_newline 01029 // ------------- 01030 01031 function void ovm_line_printer::print_newline (bit do_global_indent=1); 01032 write_stream(" "); 01033 endfunction 01034 01035 01036 //------------------------------------------------------------------------------ 01037 // 01038 // Class: ovm_hier_printer_knobs 01039 // 01040 //------------------------------------------------------------------------------ 01041 01042 01043 // new 01044 // --- 01045 01046 function ovm_hier_printer_knobs::new(); 01047 full_name = 0; 01048 endfunction 01049 01050
![]() Intelligent Design Verification Project: OVM, Revision: 2.0.1 |
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.5.5 Wed Jan 7 19:27:18 2009 |