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