// ------------------------------------------------------------------------
// ON Semiconductor Proprietary and Confidential Information.
// ------------------------------------------------------------------------

// ------------------------------------------------------------------------
// Company           : ON Semiconductor
// ------------------------------------------------------------------------
// File              : $RCSfile: messages.inc.sv,v $
// ------------------------------------------------------------------------
// Last Modified     : $Date: 2016/04/01 08:03:44 $
// Last Modified By  : $Author: fg7g4t $
// Revision          : $Revision: 1.1 $
// ------------------------------------------------------------------------
// Description       : Include file with messaging macros definition.
// ------------------------------------------------------------------------
// Revision history  :
//
//   $Log: messages.inc.sv,v $
//   Revision 1.1  2016/04/01 08:03:44  fg7g4t
//   Initial revision (directory structure & standard scripts revision 255).
//

`ifndef __MESSAGES__

  `define __MESSAGES__

  // GET_TIME - get actual time
  `define GET_TIME ($time > 1s) ? $time/1.0s : ($time > 1ms) ? $time/1.0ms : ($time > 1us) ? $time/1.0us : $time/1.0ns
  // GET_UNITS - get actual time units
  `define GET_UNITS ($time > 1s) ? "s" : ($time > 1ms) ? "ms" : ($time > 1us) ? "us" : "ns"

  // MSG - print out info message
  //
  // usage: `MSG(("msg text", msg text arguments))
  //
  `define MSG(TEXT, INDENT=0) begin \
    `ifdef MODELSIM \
      $write("%19.3f%2s %16s%s", `GET_TIME, `GET_UNITS, c_MODULE, {1+INDENT{" "}}); $messagelog($sformatf TEXT); \
    `else \
      $display("%21.3f%2s %16s%s", `GET_TIME, `GET_UNITS, c_MODULE, {1+INDENT{" "}}, $sformatf TEXT); \
    `endif \
    end

  // MSG_WRN - print out warning message
  //
  // usage: `MSG_WRN(("msg text", msg text arguments))
  //
  `ifdef MODELSIM
    `define MSG_WRN(TEXT) begin $write("** Warning: %7.3f%2s %16s ", `GET_TIME, `GET_UNITS, c_MODULE); $warning($sformatf TEXT); end
  `else
    `define MSG_WRN(TEXT) begin assert (0) else $warning(" *W, Warning: %7.3f%2s %16s ", `GET_TIME, `GET_UNITS, c_MODULE, $sformatf TEXT); end
  `endif

  // MSG_ERR - print out error message
  //
  // usage: `MSG_ERR(("msg text", msg text arguments))
  //
  `ifdef MODELSIM
    `define MSG_ERR(TEXT) begin $write("** Error: %9.3f%2s %16s ", `GET_TIME, `GET_UNITS, c_MODULE); $error($sformatf TEXT); -> tb.ev_error; end
  `else
    `define MSG_ERR(TEXT) begin assert (0) else $error(" *E, Error: %9.3f%2s %16s ", `GET_TIME, `GET_UNITS, c_MODULE, $sformatf TEXT); -> tb.ev_error; end
  `endif

  // MSG_PHASE - print out phase message
  //
  // usage: `MSG_PHASE(("phase text", phase text arguments))
  //
  `ifdef MODELSIM
    `define MSG_PHASE(TEXT) begin $write("%11s %7.3f%2s %16s ", "PHASE", `GET_TIME, `GET_UNITS, c_MODULE); $messagelog($sformatf TEXT); end
  `else
    `define MSG_PHASE(TEXT) begin $display("%13s %7.3f%2s %16s ", "PHASE", `GET_TIME, `GET_UNITS, c_MODULE, $sformatf TEXT); end
  `endif

  // MSG_SUBPHASE - print out sub-phase message
  //
  // usage: `MSG_SUBPHASE(("sub-phase text", sub-phase text arguments))
  //
  `ifdef MODELSIM
    `define MSG_SUBPHASE(TEXT) begin $write("%11s %7.3f%2s %16s ", "SUBPHASE", `GET_TIME, `GET_UNITS, c_MODULE); $messagelog($sformatf TEXT); end
  `else
    `define MSG_SUBPHASE(TEXT) begin $display("%13s %7.3f%2s %16s ", "SUBPHASE", `GET_TIME, `GET_UNITS, c_MODULE, $sformatf TEXT); end
  `endif

  `define MSG_INF(TEXT, INDENT=0) begin if (dbg_msg >= c_INFO) `MSG(TEXT, INDENT) end
  `define MSG_VERBOSE(TEXT, INDENT=0) begin if (dbg_msg >= c_VERBOSE) `MSG(TEXT, INDENT) end
  `define MSG_DBG(TEXT, INDENT=0) begin if (dbg_msg >= c_DEBUG) `MSG(TEXT, INDENT) end
`endif

