Suppose we have a function call f(s). Here’s how we’d call that in the usual way, running it synchronously.
To invoke this function asynchronously, use the fork keyword. This new fork will execute concurrently with the calling one.
You can also start an anonymous function call asynchronously with fork.
Our two function calls are running asynchronously now. We use a small delay to wait for them to finish.
When we run this program, we see the output of the blocking call first, then the output of the other asynchronous calls. The asynchronous tasks’ output may be interleaved, because they are being run concurrently.
Next we’ll look at a complement to fork in concurrent Verilog programs: channels.