Jump to content

How to call uvm_error from a static method?

Recommended Posts

What is the recommended way to call UVM report functions and macros from a static method in a uvm_component?


Having the following code:

  static function static_check();
    `uvm_error("ID", "Something failed");

causes a compile error:

** Error: testbench.sv(15): (vlog-2888) Illegal to access non-static method 'uvm_report_enabled' from a static method.

Full example can be edited and run here: http://www.edaplayground.com/s/4/762


Link to comment
Share on other sites



in static contexts you have to use the macro set with the postfix "_context". while the normal macros will invoke <this>.uvm_report_xyz() and therefore require a non static context the _context macros will invoke <context>.uvm_report_xyz(). messages emitted with the _context version can be used in static contexts and provide the same functionality as-if the non-context version would have been invoked in context.


(an alternate use model for the _context macro version is to emit a message from a different place than what appears as the messages context. eg. you can print from within the driver BUT the context is showing as if the message was emitted by the agent)



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...