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

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

  // TRANSACTIONS
  `ifdef MODELSIM
    `define TR_CREATE(STREAM) $create_transaction_stream({"tb.transactions.", STREAM});
  `else
    `define TR_CREATE(STREAM) $sdi_create_fiber(STREAM, "TVM", "transactions");
  `endif

  // NCSIM (13.10) can't handle transactions with begin_time in always blocks -
  //  it will start them near time 0. Transactions in tasks work as expected.
  `ifdef MODELSIM
    `define TR_OPEN(TR,TEXT,BEGIN_TIME=$realtime) $begin_transaction(TR, TEXT, BEGIN_TIME);
  `else
    `define TR_OPEN(TR,TEXT,BEGIN_TIME=$realtime) $sdi_transaction("Begin, Link", TR, TEXT/*, TEXT, "", BEGIN_TIME*/);
  `endif

  `ifdef MODELSIM
    `define TR_ATTR(TRH,VAL,NAME) $add_attribute(TRH, VAL, NAME);
  `else
    `define TR_ATTR(TRH,VAL,NAME) \
    begin \
      bit [$high(VAL)-1 : 0] b_VAL; \
      $sdi_set_attribute(TRH, NAME, b_VAL); \
    end
  `endif

  `ifdef MODELSIM
    `define TR_END(TRH) \
      begin \
        $end_transaction(TRH); \
        $free_transaction(TRH); \
      end
  `else
    `define TR_END(TRH) \
      begin \
        $sdi_end_transaction(TRH); \
        $sdi_free_transaction_handle(TRH); \
      end
  `endif

  `ifdef MODELSIM
    `define TR_COLOR(TR,COLOR) $add_color(TR, COLOR);
  `else
    `define TR_COLOR(TR,COLOR) ;
  `endif

