I have created one logic to monitor whether a signal is 0/1.
task xyz();
if(abc == 1)
begin
task123;
end
else
begin
task234;
end
the value of abc variable is taken on next clock cycle, but for current clock cycle it is treated as ‘X’.
problem here in above task is that, initially the value of abc variable is neither 0 nor 1. hence it is ‘X’, so it is treated as ZERO, and he task234 is executed.
Moreover, i want my abc varaible value to be “logic 1” for first transaction and then randomizing it for the rest.
Still no where near enough code shown about where abc is declared and how its value is set to be able to understand your question. If you want to be 1, then either initialize it to 1 in its declaration, or set it to 1 when you want it to be.
class A;
rand logic abc = 1;
task runme;
$display(abc); // first reference to abc is displays 1
forever begin
randomize();
$display(abc); // rest of time, abc is randomized
end
endtask
I am sure this does not answer your question, but you have not given us any clue about what defines a “use” of abc.