verilog task for detecting end of file

Status
Not open for further replies.

bh_letters

Junior Member level 3
Joined
Feb 14, 2005
Messages
25
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,464
Hi,

Are there any verilog system tasks available for detecting EOF. If ther aren't any, how can I detect EOF using available system tasks.

Thanks
 

Below is a code fragment. Basically, $fread returns a value that you can test for errors. If the return_value is not 1 then you have gone past the end of the file, ie an EOF error.

---- Steve


///////////////////////////////////////////////////////////////////////////////////////////
integer return_value, file ;
reg [7:0] mem, tmp_byte, tmp_nibble;
reg error;



file = $fopen("code.vec", "r");
$ferror(file, error);
if (error != 0)
$display("\nFile Open Failed with Error Code = %x", error);

return_value = $fread( mem, file);
if (return_value !=1)
error = 1;
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…