K
Kenneth Brun Nielsen
Guest
Can I do both an assignment and a logical check in once?
E.g. I want to do something similar to:
r = $fgets(textline,fd);
if ((checkNum = $sscanf(textline," %1b %1b\n",inputBit1,inputBit2)) >
0)
$display("Input stimuli read (%d)",checkNum);
else if((checkNum = $sscanf(textline,"* %s \n",comment)) > 0)
$display("Comment read: %s",comment);
else
$display("Input line format not recognized: %s", comment);
The "if" line is the problem. Something similar to the above would be
simpler than (particularly for many else-if cases):
checkNum =$sscanf(textline," %1b %1b\n",inputBit1,inputBit2);
if (checkNum > 0)
$display("Input stimuli read (%d)",checkNum);
else
begin
checkNum = $sscanf(textline,"* %s \n",comment);
if (checkNum > 0)
$display("Comment read: %s",comment);
else
begin
...
end
end
Best regards,
Kenneth
E.g. I want to do something similar to:
r = $fgets(textline,fd);
if ((checkNum = $sscanf(textline," %1b %1b\n",inputBit1,inputBit2)) >
0)
$display("Input stimuli read (%d)",checkNum);
else if((checkNum = $sscanf(textline,"* %s \n",comment)) > 0)
$display("Comment read: %s",comment);
else
$display("Input line format not recognized: %s", comment);
The "if" line is the problem. Something similar to the above would be
simpler than (particularly for many else-if cases):
checkNum =$sscanf(textline," %1b %1b\n",inputBit1,inputBit2);
if (checkNum > 0)
$display("Input stimuli read (%d)",checkNum);
else
begin
checkNum = $sscanf(textline,"* %s \n",comment);
if (checkNum > 0)
$display("Comment read: %s",comment);
else
begin
...
end
end
Best regards,
Kenneth