Create my own macros

down vote
favorite
I want to use the following macro in uvm project

//---------------------------------------------------------
//   General macros which contain sequence repeate
//   in many places.
//---------------------------------------------------------

`ifndef MY_MACROS_SV
`define MY_MACROS_SV
// MACRO: 'my_fatal_err
//
// calls uvm_fatal in case the assertion is not correct

`define my_fatal(id, msg )
      assert (file_p != 0) else
    `uvm_fatal("FATAL ERROR", "FILE OPENED FAILED")


`endif  //MY_MACROS_SV

I to call this macro from different classes (sequenece, driver, etc…) by:

`my_fatal("FATAL ERROR", "FILE OPENED FAILED")

When I try to compile this I got the following error:

** Error: (vlog-13069) ** while parsing file included at ./sv/girobo2_pkg.sv(4

)

** at .\sv\my_macros.sv(13): near “assert”: syntax error, unexpected assert ,

expecting class.

In reply to saritr:

I believe this paper (starting on page 14) has good information regarding using macros and assertions in general.
http://www.sunburst-design.com/papers/CummingsSNUG2009SJ_SVA_Bind.pdf

In reply to saritr:

If you desire to make a `define extend beyond one line, you need to use the '' character at the end of each line. Refer to the existing UVM macros for examples.

Also, you shouldn’t be using assert() statements in general as there is the potential for them to be inadvertently disabled resulting in errors.

Also, you shouldn’t be referring to variables out of the blue (file_p) because if it doesn’t exist where the macro is utilized, there will be an error which is very difficult to debug.