View Full Version : $error usage
Guys,
I'm want to use something like $error in my data checker task to print an error (something like dut_error() in specman).
If I use $error in task it shows compilation error saying $error cannot be used out of action block.
Is there any susbstitute for $error that can be used in a task?
Oh BTW I'm using modelsim 6.3c.
Regards,
Aji
dlong
01-23-2008, 01:51 AM
Hi Aji,
The $error system task is only used as part of the action block of an assert statement - that is why you are getting an error message.
To print an error message, I would suggest using one of the OVM reporting functions, e.g.
class data_checker extends ovm_threaded_component;
task run();
...
if (error_condition) ovm_report_error("DATA_ERR","error condition occurred");
...
endtask
...
endclass
By default, this will write the error message to the command line (and a log file if specified). If you want to stop the simulation when there is an error, you could you ovm_report_fatal instead.
Regards,
Dave
=============
David Long
Doulos
http://www.doulos.com
hansv
01-23-2008, 09:11 AM
And you can/should even use the OVM reporting methods with assert statements, immediate or concurrent assertions:
assert(...<CONDITION>) else ovm_report_error(...);
assert property(...
) else ovm_report_error(...);
dave_59
01-23-2008, 09:24 AM
The $error system task is only used as part of the action block of an assert statement - that is why you are getting an error message.
That restriction is going away in 1800-2008, but I still recommend David's solution regardless of whether you are in an action block or not. Having a standard reporting mechanism is a good practice in any software environment so that you can easily filter or elevate all of your messages.
And 1800-2008 will also allow you to do
if (error_condition)
ovm_report_error("DATA_ERR","error condition occurred",
`__FILE__,`__LINE__); which gives you back the missing file and line number information that $error provides.
Dave
Powered by vBulletin™ Version 4.0.3 Copyright © 2010 vBulletin Solutions, Inc. All rights reserved.