View Full Version : fork-join construct is used in the function of member class in OVM
vikassinghal21
01-16-2008, 05:34 AM
Using fork-join (parallel blocks) construct in functions are not LRM compliant. Here, this construct is used in the member function of class ovm_component.
Code snippet from ovm_component.sv file:
function void ovm_component::do_exit_action(ovm_report_object object);
if ( ovm_top_levels.size() ) begin
ovm_component nc;
fork
global_stop_request();
join_none
if( $cast(nc, object) ) begin
if ( nc.m_env != null ) object.die();
end
end
else begin
object.die();
end
endfunction
ajeetha
01-16-2008, 07:00 AM
fork..join_none is harmless as it doesn't block. I vaguely remember this was discussed in SV-EC/BC commitee. VCS has been allowing this for years so it looks like all 3 tools allow this.
Ajeetha, CVC
www.noveldv.com
dave_59
01-16-2008, 09:18 AM
fork..join_none is harmless as it doesn't block. I vaguely remember this was discussed in SV-EC/BC commitee. VCS has been allowing this for years so it looks like all 3 tools allow this.
Ajeetha, CVC
www.noveldv.com (http://www.noveldv.com)
Sometimes a bug in a tool is exploited as a feature by a user. However if the feature is used in a slightly different context, interaction with the rest of the system is ill-defined.
The proposal to allow fork/join_none in a function (http://www.eda-stds.org/svdb/view.php?id=1336)(login guest/guest) was approved a year ago, then rejected, then approved, then rejected, then re-approved just a few days ago..
Once the door was opened up for fork/join_none, other restrictions in functions start to become meaningless, like clocking block drives, non-blocking assignments, event triggers. A restriction remains that you can't fork a process unless the parent process is a process created by an initial or always block. That means it illegal to have a static variable initialization function call fork/join_none.
Dave
vikassinghal21
01-16-2008, 10:37 PM
Once the door was opened up for fork/join_none, other restrictions in functions start to become meaningless, like clocking block drives, non-blocking assignments, event triggers. A restriction remains that you can't fork a process unless the parent process is a process created by an initial or always block. That means it illegal to have a static variable initialization function call fork/join_none.
Dave
Can I used the delays in the functions something like:
#20 clk1 = 1'b1;
or
@(posedge clk1);
What are the advantages of allowing these constructs in functions, instead of using the task for achieving this functionality?
dave_59
01-16-2008, 11:41 PM
Can I used the delays in the functions something like:
#20 clk1 = 1'b1;
or
@(posedge clk1);
What are the advantages of allowing these constructs in functions, instead of using the task for achieving this functionality?
You can never use a blocking statement in a function unless it is within a fork/join_none constructAND the other conditions have been met. (must be from a thread started by an initial or always construct).
There are a number of advantages by allowing non-blocking statements in a function:
The fact that a function is guaranteed not to block is a contract between the caller and the callee, just as the formal argument types are the contract as part of the interface between caller and callee.
The construction of a class may spawn a process. This can eliminate a lot of bookkeeping that would otherwise have to be done to keep track of all the constructed classes.
You can't nest task calls. Now, more tasks can be written as functions, and it easier to have a function return a value as part of an expression than to output through an argument.So this is mainly an small enhancement for the testbench, but with much larger impact to the people that have to implement it.
Dave
vikassinghal21
01-17-2008, 12:35 AM
Thanks a lot for your reply.
Powered by vBulletin™ Version 4.0.3 Copyright © 2010 vBulletin Solutions, Inc. All rights reserved.