Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

verilog task for detecting end of file

Status
Not open for further replies.

bh_letters

Junior Member level 3
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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top