UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

AR# 33732

ISE Simulator (ISim) - $fscanf does not return "-1" upon EOF (end of file)

Description

I am expecting ISim to return "-1" when $fscanf reaches EOF of the text file I am attempting to read in. However, ISim continues to read the last line.

How can I properly identify EOF using the $fscanf function?

Solution

This is a known issue in all updates of ISE Simulator 11. This issue is currently under investigation to better address this condition in a future release of the ISE Simulator.

To work around this issue, use the $feof Verilog function to catch EOF. For example:

initial while(!$feof(input_file)) begin

#10;

read_ok = $fscanf(input_file,"%h\n",data);

$display("%g: Read $%h from input file. read_ok = %d",$time,data,read_ok);

end

Linked Answer Records

Associated Answer Records

Answer Number Answer Title Version Found Version Resolved
33381 ISE Design Suite 11 - ISE Simulator (ISim) Known Issues N/A N/A
AR# 33732
Date Created 10/30/2009
Last Updated 12/15/2012
Status Active
Type General Article