Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Verilog - Multiple Calls to Task

Status
Not open for further replies.

forkconfig

Member level 1
Joined
Jan 28, 2013
Messages
32
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,655
Let's say there is a task called myTask() that looks something like this:

task myTask;
input a;
input b;

begin
/* STUFF */
end
endtask

Let's say in my module I have two sections of code calling this task

module (
varQ
varW
varE
varR
);

// call this section of code Alpha
always @(...) begin
myTask(varQ, varW);
...
end

// call this section of code Beta
always @(...) begin
myTask(varE, varR);
...
end

Okay now here is my question...
If Alpha calls myTask first, then while it is still running Beta calls myTask, it is my understanding that the variables will be overwritten. Therefore, whatever Alpha calculates will be based off the overwritten values of Beta. How can I avoid this conflict?

Thanks
 

all the vars in your code are individual so there is no conflict. the two calls are completly independent.
 

If myTask does not any consume time, there is not much of a problem because one call will finish before the next call starts. ( and you should be using functions, not tasks if they are not supposed to consume time). But technically threads are allowed to interleave, sou you can declare your task/function as automatic. Then each call gets its own set of variables.
 

You probably want to use.

task automatic myTask;

Using the automatic keyword makes the task re-entrant. Which is what you might want if your task can be called in two sections of code simultaneously. This is something introduced in Verilog 2001.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top