Fork-join clarification

This is a discussion on Fork-join clarification within the verilog forums in Programming Languages category; I'm using fork-joins in my testbench and I just want to be sure that the more succinct version is functionally identical to the long version (shown below). // Succinct fork run_test(instance_1); run_test(instance_2); join // Long fork begin run_test(instance_1); end begin run_test(instance_2); end join I'm using SystemVerilog but I don't think this would be different in Verilog. Thanks, - Mark...

Go Back   Application Development Forum > Programming Languages > verilog

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 09-03-2008, 10:17 AM
mrfirmware
Guest
 
Default Fork-join clarification

I'm using fork-joins in my testbench and I just want to be sure that
the more succinct version is functionally identical to the long
version (shown below).

// Succinct
fork
run_test(instance_1);
run_test(instance_2);
join

// Long
fork
begin
run_test(instance_1);
end

begin
run_test(instance_2);
end
join

I'm using SystemVerilog but I don't think this would be different in
Verilog.

Thanks,

- Mark
Reply With Quote
  #2  
Old 09-03-2008, 10:49 AM
Jonathan Bromley
Guest
 
Default Re: Fork-join clarification

On Wed, 3 Sep 2008 07:17:41 -0700 (PDT), mrfirmware
<mrfirmware@gmail.com> wrote:

>I'm using fork-joins in my testbench and I just want to be sure that
>the more succinct version is functionally identical to the long
>version (shown below).
>
>// Succinct
>fork
> run_test(instance_1);
> run_test(instance_2);
>join
>
>// Long
>fork
> begin
> run_test(instance_1);
> end
>
> begin
> run_test(instance_2);
> end
>join
>
>I'm using SystemVerilog but I don't think this would be different in
>Verilog.


You're fine. It's the same. A fork...join block wraps a bunch of
procedural statements (such as your run_test() calls) which are
executed in parallel; a begin...end wraps a bunch of procedural
statements which are then executed sequentially. A complete
fork...join, or a complete begin...end, has precisely the same
(syntactic) status as a single procedural statement and can be
used as one of the statements in another fork...join or
begin...end.

SystemVerilog changes the rules in two ways,
neither of which affects your issue:

1) Subprogram bodies:
In standard Verilog the body of a task or function
must be a single procedural statement. Of course,
almost any practical task or function needs multiple
statements, and therefore needs a begin...end to
enclose them. You could instead have a fork...join
as the body of your subprogram, but that's unusual.
In SystemVerilog, the usual begin...end is optional
so that you can now have multiple sequential statements
as the body of your subprogram.

2) Dynamic processes:
fork...join_none and fork...join_any. These have the
same "bracketing" effect as fork...join, but launch
their sub-threads in a rather different way.
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
jonathan.bromley@MYCOMPANY.com
http://www.MYCOMPANY.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.
Reply With Quote
  #3  
Old 09-03-2008, 01:25 PM
mrfirmware
Guest
 
Default Re: Fork-join clarification

On Sep 3, 10:49*am, Jonathan Bromley <jonathan.brom...@MYCOMPANY.com>
wrote:
> On Wed, 3 Sep 2008 07:17:41 -0700 (PDT), mrfirmware
>
>
>
> <mrfirmw...@gmail.com> wrote:
> >I'm using fork-joins in my testbench and I just want to be sure that
> >the more succinct version is functionally identical to the long
> >version (shown below).

>
> >// Succinct
> >fork
> > * *run_test(instance_1);
> > * *run_test(instance_2);
> >join

>
> >// Long
> >fork
> > * *begin
> > * * * *run_test(instance_1);
> > * *end

>
> > * *begin
> > * * * *run_test(instance_2);
> > * *end
> >join

>
> >I'm using SystemVerilog but I don't think this would be different in
> >Verilog.

>
> You're fine. *It's the same. *A fork...join block wraps a bunch of
> procedural statements (such as your run_test() calls) which are
> executed in parallel; a begin...end wraps a bunch of procedural
> statements which are then executed sequentially. *A complete
> fork...join, or a complete begin...end, has precisely the same
> (syntactic) status as a single procedural statement and can be
> used as one of the statements in another fork...join or
> begin...end.


Thanks. That's the confirmation I was hoping for.

Regards,

- Mark
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 04:34 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.