OpenCores
no use no use 1/1 no use no use
SV and UVM Questions
by rakeshsachdev2003 on Mar 16, 2018
rakeshsachdev2003
Posts: 3
Joined: Mar 16, 2018
Last seen: Mar 17, 2018
Hi All,

If anyone has the SV/UVM questions then do post here in forum. I will answer those.

Regards,
Rakesh Sachdev
RE: SV and UVM Questions
by sindhujo on Mar 16, 2018
sindhujo
Posts: 1
Joined: Jan 14, 2012
Last seen: Dec 4, 2020
Hi Sir,

Can you explain the behavior of this code.
module test();

task add(int a, int b);
#2;
$display("the sum is %0d", a+b);
endtask

initial
fork
begin
add(2,3);
end
begin
#1;
add(3,4);
end
join
endmodule

I'm expecting 5 & 7 as output but it is 7 every time. If i remove delays, then the output is fluctuating. not same everytime.
Please explain.
RE: SV and UVM Questions
by shaurya29 on Mar 17, 2018
shaurya29
Posts: 1
Joined: Dec 8, 2017
Last seen: Mar 19, 2018
I want to learn UVM can you recommend a course or book , videos etc.
RE: SV and UVM Questions
by santhg on Mar 17, 2018
santhg
Posts: 1
Joined: Aug 27, 2013
Last seen: Nov 18, 2018
Default Lifetime of variable/ methods(task or function) :

1. Class variable : Automatic
2. Method variable : Automatic
3. Local variable of loop : Automatic
4. Module or Program block variable : Static
5. Variable declared in initial of always block : Static

As you've a task inside a module, it goes as static, which means the different calls will share the memory. Whereas in automatic task, each call gets memory dynamically allocated.

Try to run your task like this:


module test();
task automatic add2(int a,b);
#2;
$display("%0t: auto : sum is %0d", $time a+b);
endtask

task add(int a, int b);
#2;
$display("%0t: satic: sum is %0d", $time a+b);
endtask

initial
fork
begin
add(2,3);
end
begin
#1;
add(3,4);
end
begin
add2(2,3);
end
begin
#1;
add2(3,4);
end
join
endmodule

Output:

2: satic: sum is 7
2: auto : sum is 5
3: satic: sum is 7
3: auto : sum is 7
no use no use 1/1 no use no use
© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.