I have a requirement of forcing hierarachial nodes multiple times. I thought of writing a task and use force keyword for eg :
task check(input logic a,b,c);
force a = 0;
force b = 1;
force c = 0;
endtask
and i want it to go through a for loop :
for (i=0;i<=n;i++)
begin check(a[i],b[i],c[i]);
end
where a[i],b[i] and c[i] i have defined as an array of required nodes. but it seems this logic is not able to foce those nodes. Any suggestions to make it work?
ps: i tried the same thing with `define macro,but of no use.
Did you tried using ref as input argument of task.
task check(ref logic a,b,c);
force a = 0;
force b = 1;
force c = 0;
endtask
// calling task
for (i=0;i<=n;i++)
begin check(RTL_HIER.a[i],RTL_HIER.b[i],RTL_HIER.c[i]);
end
In reply to sohil08:
Did you tried using ref as input argument of task.
task check(ref logic a,b,c);
force a = 0;
force b = 1;
force c = 0;
endtask
// calling task
for (i=0;i<=n;i++)
begin check(RTL_HIER.a[i],RTL_HIER.b[i],RTL_HIER.c[i]);
end
It is giving below error :
Dynamic type in non-procedural context
“force a = 'b1;”
Argument: a
Automatic variable may not be used in non-procedural context.
You cannot force a signal via an indirect reference, and you cannot use a variable index on the LHS of a force statement. forces are very restrictive on the kinds of signals you can target, and hierarchical references are also restricted
It would help if you could show the declarations of the actual signals you want to force, and the relative scope you want to apply the force.
What you can do is force the array as a whole using an assignment patter, if that helps
force a = '{default:0}; // forces all elements to 0.