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.

[SOLVED] task in blocking statements

Status
Not open for further replies.

rocking_vlsi

Member level 5
Member level 5
Joined
Jun 9, 2011
Messages
87
Helped
6
Reputation
12
Reaction score
6
Trophy points
1,288
Visit site
Activity points
1,833
Hi

Please read the code below and

//////////////////////////////////////////////////////////
reg gbl_reg ;
reg temp1;

task simple_task
input a;
begin
gbl_reg=a;
end
endtask


always@(*)
temp1=0;
simple_task(0);

case(fsm_state)
state1: begin
temp1=1;
simple_task(1);
end
state2: begin
temp1=0;
simple_task(0);
end
endcase

//////////////////////////////////////////////////////////

I am unable to understand which value will be assigned to temp1 and gbl_reg ?
Everytime the fsm_state changes, will temp1 and gbl_reg are assigned value 0. and depending on the fsm_state, temp1 and gbl_reg are assigned later.
 

You can make multiple assignments to the same variable in the same always process, and the last write 'wins'. People code this way when they have a lot of variables, and the case statement branches only have assignments to variables that are different from the default.
 
Thanks Dave. One of my other concern is task invocation. Does only one task get invoked based on the condition?

Because I am assigning a value to global register inside the task and if earlier task does not complete before the next task invocation then value may get over written. Please correct me if i am wrong?
 

It doesn't matter. In your case, that task has no blocking statements; it could have been written as a function. Even if it did have blocking statements, you could (and should) declare the task as automatic so that the value of a does not get overwritten by another concurrent task.

If you can use SystemVerilog, you should declare any task as a function that does not block as a function void. That is a guarantee that it will never block.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top