// ========== Copyright Header Begin ========================================== // // OpenSPARC T2 Processor File: std_display_class.vr // Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved // 4150 Network Circle, Santa Clara, California 95054, U.S.A. // // * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; version 2 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // For the avoidance of doubt, and except that if any non-GPL license // choice is available it will apply instead, Sun elects to use only // the General Public License version 2 (GPLv2) at this time for any // software where a choice of GPL license versions is made // available with the language indicating that GPLv2 or any later version // may be used, or where a choice of which version of the GPL is applied is // otherwise unspecified. // // Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, // CA 95054 USA or visit www.sun.com if you need additional information or // have any questions. // // ========== Copyright Header End ============================================ #include #include "std_display_defines.vri" #include "plusArgMacros.vri" #ifdef DISPLAY_CYCLES #define STD_GET_TIME sprintf (tmp_str,"%9d: ",get_cycle()) #else #define STD_GET_TIME sprintf (tmp_str,"%9d: ",{get_time(HI),get_time(LO)}) #endif #ifdef NTB // NTB does not suport get_time(HI), sighhh // get_time(LO) returns nothing, double sighhh #define STD_GET_TIME sprintf (tmp_str,"%8d__: ",get_cycle()) #endif class StandardDisplay { local reg[MAX_VERBOSITY-1:0] verbosity[]; local reg[MAX_VERBOSITY-1:0] default_verbosity = NORMAL_VERBOSITY; local string context_name[]; local string vlabel[MAX_VERBOSITY]; local reg [63:0] tmpTime; // these are not local so they can be accessed directly. integer errors = 0; integer warnings = 0; integer info_all = 0; // The following plus args are "standard": integer maxerror = 1; integer maxwarning = 5; integer wait_cycle_to_kill = 5; integer debug = 0; integer debug_all = 0; integer info = 0; integer start_debug = 0; integer quiet = 0; static reg [1:0] instanceCount; //------------------------------------------------------------------------------ // task new. paramater passing not required... //------------------------------------------------------------------------------ task new (integer maxErrors = 1, integer errorCnt = 0, integer maxWarnings = 5, integer wait_cycle_to_kill = 5, integer start_debug = 0) { reg[2048:0] arg_bit_str = 0; string src_str; if (instanceCount !== 2'bxx) instanceCount++; else instanceCount = 1; // sanity check if (instanceCount > 1) { printf("More than one instance of std_display_class.vr/StandardDisplay detected!\n"); printf("Since this class keeps error counts, we only want one. You can have as\n"); printf("many pointers as you want to the single instance though. (A=new();B=A;C=A;)\n"); error("Need to FAIL, sorry!\n"); } maxerror = maxErrors; errors = errorCnt; maxwarning = maxWarnings; wait_cycle_to_kill = wait_cycle_to_kill; start_debug = start_debug; init_vlabels(); if (mChkPlusarg(quiet) && !mChkPlusarg(noquiet)) { default_verbosity = QUIET_VERBOSITY; quiet = 1; info_all = 0; info = 0; debug_all = 0; debug = 0; } if (mChkPlusarg(info_all)) { default_verbosity = INFO_VERBOSITY; quiet = 0; info_all = 1; info = 1; debug_all = 0; debug = 0; } if (mChkPlusarg(debug_all)) { default_verbosity = DEBUG_VERBOSITY; quiet = 0; info_all = 1; info = 1; debug_all = 1; debug = 1; } if (mChkPlusarg(info)) { quiet = 0; info = 1; debug = 0; } if (mChkPlusarg(debug)) { quiet = 0; info = 1; debug = 1; } if (mChkPlusarg(mon+)) { mGetPlusargStr(mon+,arg_bit_str); src_str.bittostr (arg_bit_str); parse_mon_arg_str (src_str); } if (mChkPlusarg(maxerror=)) { mGetPlusargDec(maxerror=,maxerror); } if (mChkPlusarg(maxwarning=)) { mGetPlusargDec(maxwarning=,maxwarning); } if (mChkPlusarg(wait_cycle_to_kill=)) { mGetPlusargDec(wait_cycle_to_kill=,wait_cycle_to_kill); } if (mChkPlusarg(start_debug=)) { mGetPlusargDec(start_debug=,start_debug); } } // end task new //------------------------------------------------------------------------------ // task dispmon //------------------------------------------------------------------------------ task dispmon (string context_str, integer level, string message, string file = null, integer lineNum = 0 ) { reg[MAX_VERBOSITY-1:0] verbosity_enabled; string tmp_str; if (level == MON_DEBUG) if (start_debug && get_cycle() < start_debug) return; // !context_exists(context_str) if (! assoc_index(CHECK,verbosity,context_ndx(context_str))) { create_context (context_str); } verbosity_enabled = verbosity[context_ndx(context_str)]; if (verbosity_enabled[level]) { STD_GET_TIME; if (file == null) { printf("%s%s%s[]: %s\n", tmp_str, vlabel[level], context_str, message); } else { printf("%s%s%s[%s:%0d]: %s\n", tmp_str, vlabel[level], context_str, file, lineNum, message); } if (level == MON_ERR) errors++; else if (level == MON_WARN) warnings++; } } // end task dispmon task writemon (string context_str, integer level, string message, string file = null, integer lineNum = 0 ) { reg[MAX_VERBOSITY-1:0] verbosity_enabled; string tmp_str; if (level == MON_DEBUG) if (start_debug && get_cycle() < start_debug) return; // !context_exists(context_str) if (! assoc_index(CHECK,verbosity,context_ndx(context_str))) { create_context (context_str); } verbosity_enabled = verbosity[context_ndx(context_str)]; if (verbosity_enabled[level]) { STD_GET_TIME; if (file == null) { printf("%s%s%s[]: %s", tmp_str, vlabel[level], context_str, message); } else { printf("%s%s%s[%s:%0d]: %s", tmp_str, vlabel[level], context_str, file, lineNum, message); } if (level == MON_ERR) errors++; if (level == MON_WARN) warnings++; } } // end task writemon task appendmon (string context_str, integer level, string message) { reg[MAX_VERBOSITY-1:0] verbosity_enabled; string tmp_str; if (!context_exists(context_str)) { create_context (context_str); } verbosity_enabled = verbosity[context_ndx(context_str)]; if (verbosity_enabled[level]) { printf("%s",message); } } // end task appendmon //------------------------------------------------------------------------------ // function integer get_errors() //------------------------------------------------------------------------------ function integer get_errors() { get_errors = errors; } task getCounts(var integer err, var integer warn) { err = errors; warn = warnings; } //------------------------------------------------------------------------------ // task init_vlabels //------------------------------------------------------------------------------ protected task init_vlabels() { integer ii; vlabel[MON_ALWAYS] = ""; vlabel[MON_WARN] = "WARNING: "; vlabel[MON_ERR] = "ERROR: "; for (ii=1;ii