User guide
2-33
Modeling Your Design
Avoiding Circular Dependency
The $random system function has an optional seed argument. You
can use this argument to make the return value of this system function
the assigned value in a continuous assignment, procedural
continuous assignment, or force statement. For example:
assign out = $random(in);
initial
begin
assign dr1 = $random(in);
force dr2 = $random(in);
When you do this, you might set up a circular dependency between
the seed value and the statement, resulting in an infinite loop and a
simulation failure.
This circular dependency doesn’t usually occur but it can occur, so
VCS displays a warning message when you use a seeded argument
with these kinds of statements. This message is as follows:
Warning-[RWSI] $random() with a ’seed’ input
$random in the following statement was called with a ’seed’ input
This may cause an infinite loop and an eventual crash at runtime.
"exp1.v", 24: assign dr1 = $random(in);
The warning message ends with the source file name and line number
of the statement, followed by the statement itself.
This possible circular dependency does not occur either when you
use a seed argument and the return value is the assigned value in a
procedural assignment statement, or when you do not use the seed
argument in a continuous, procedural continuous, or force
statement.