Access to the number of error messages shown

96 views
Skip to first unread message

Watt, James

unread,
Nov 28, 2008, 12:58:38 PM11/28/08
to avm-...@googlegroups.com
I've been searching through various resources looking for a way to get access to the number of error messages printed.  I'd like to access the number from the report (overloaded) function within my testcase so I can use it to determine a pass/fail.  In this case errors cause the testcase to fail.  The messages would be warnings or messages otherwise.
 
Tracking the information via my own global variable is possible, but redundant.  Does anyone have any suggestions for making this work, or a better way to do this?
 
Thanks in advance.
James.
 



joshr...@gmail.com

unread,
Nov 29, 2008, 9:49:43 PM11/29/08
to Advanced Verification Methodology User Group
Hi James,
It sounds like you are looking for an error count variable from the
avm_report_XX functions.
From the AVM manual - here are the variables that hold the ERROR/FATAL
counts:

final begin
// Test Pass Fail Block
int fatals = 0;
int errors = 0;
avm_report_formatter my_avm_reporter;
my_avm_reporter = get_report_formatter();
if ( my_avm_reporter.severity_count.exists(FATAL) )
fatals = my_avm_reporter.severity_count[FATAL];

if ( my_avm_reporter.severity_count.exists(ERROR) )
errors += my_avm_reporter.severity_count[ERROR];

if (errors > 0 ) begin
... report test failed
end
else
// test passed
end

Also you may want a variable that is incremented at various stages of
the simulation
to ensure you did not get a vacous pass (i.e. the test ran thru all of
the normal sequence and
did not terminate early.

Cheers,
Josh Robinson

Glasser, Mark

unread,
Nov 30, 2008, 1:20:32 PM11/30/08
to avm-...@googlegroups.com
Hi James,
 
You can access the message counts in the report server through the report handler.  Each component is derived from avm_report_client which contains a reference to the report server, m_srvr.  The report server has a function called get_serverity_count which takes a severity as an argument and returns the current count of messages that have been issued with that severity. For example, to get the number of errors use the following call:
 
  int errors;
 
  ...
 
  errors = m_srvr.get_severity_count(ERROR);
 
Another thing you can do is to use the quit_count feature.  When you set quit count to a value greater than zero and you set the action for any severity to include COUNT, then when the count for the particular severity reaches the threshold the testbench will terminate.  For example, to make the testbench stop when after five errors do the following (in an avm_named_component):
 
 
  set_report_max_quit_count(5);
  set_report_severity_action(ERROR, DISPLAY | COUNT);
 
Then when five errors are reached the testbench will terminate.  By the way, (DISPLAY | COUNT) is the default action for ERROR, so you don't need to set is explicitly.  I just show for illustration purposes.
 
A variation of this is to also use the CALL_HOOK action.  This will cause a user function to be called.  You could use this function to indicate pass/fail.  E.g.
 
  set_report_max_quit_count(5);
  set_report_serverity_action(ERROR, DISPLAY | COUNT | CALL_HOOK);
 
  In the same component define the function report_error_hook:
 
   function bit report_error_hook( string id, string message, int verbosity,
                                             string filename, int line);
     if(!m_srvr.is_quit_count_reached())
       return;
     // do whatever processing is necessary when a failure occurs
     $display("TEST FAILED");
   endfunction
 
Note: each component has its own report hooks, so the hook will only be called in the component where the message was issued.
 
Finally, one last way to terminate the testbench is to call avm_report_fatal when you encounter an error condition.  That will shut it down immediately.
 
I hope this helps you.
 
-- Mark
 


From: avm-...@googlegroups.com [mailto:avm-...@googlegroups.com] On Behalf Of Watt, James
Sent: Friday, November 28, 2008 9:59 AM
To: avm-...@googlegroups.com
Subject: Access to the number of error messages shown

Watt, James

unread,
Dec 1, 2008, 11:25:29 AM12/1/08
to avm-...@googlegroups.com
It helps a lot, yes.  Thanks very much.  I'll start with option 1 and work my way through.
 
James.




From: avm-...@googlegroups.com [mailto:avm-...@googlegroups.com] On Behalf Of Glasser, Mark
Sent: Sunday, November 30, 2008 1:21 PM
To: avm-...@googlegroups.com
Subject: RE: Access to the number of error messages shown

Watt, James

unread,
Dec 1, 2008, 11:28:34 AM12/1/08
to avm-...@googlegroups.com
Thanks for the help. It's a good point about the vacuous pass and one
we'll heed. It's an excellent suggestion to increment a count along the
way - I'm thinking we'll be using that.

And thanks for the code snippit. That's going to be useful.

James.



-----Original Message-----
From: avm-...@googlegroups.com [mailto:avm-...@googlegroups.com] On
Reply all
Reply to author
Forward
0 new messages