System Task $fgets

K

kumar

Guest
Hi all,

I am having a query regarding $fgets(line, fd);
I have read the file completely and once the file is completely read,
I am getting an error message "$fgets : Argument 2 is an unknown file
descriptor."

How can i avoid this error message?

Since i am using Verilog-95 constructs, hence the system task $ferror
cannot be used, and $feof is also not possible as i am using Modelsim.
Is there any method by which i can block this error Message from the
code.

Regards
Kumar
 
kummikd@yahoo.com (kumar) wrote in message news:<35043f4b.0307072125.7e2ea689@posting.google.com>...
Since i am using Verilog-95 constructs, hence the system task $ferror
cannot be used, and $feof is also not possible as i am using Modelsim.
I just thought I would point out that $fgets is not a Verilog-1995
construct. It was added to Verilog-2001 along with $ferror. I don't
know why a $feof was not added at the same time. I have already
proposed this to the IEEE as a possible enhancement.

$fgets will return 0 if it fails to read anything, due to an error
or presumably end of file. This would be the most obvious way of
detecting that you have reached end of file. However, Modelsim might
produce the error message at that time, so this might not allow you
to avoid it. There are also some things you could do with $ftell and
$fseek, but that would be clumsy.
 
kummikd@yahoo.com (kumar) wrote in message news:<35043f4b.0307072125.7e2ea689@posting.google.com>...
How can i avoid this error message?
You could also test for end of file before reading in another
way: use $fgetc to read a character and test the return value
for EOF (-1). If it is not EOF, put it back with $ungetc and
proceed with your read.
 

Welcome to EDABoard.com

Sponsor

Back
Top