Call a file and read data from it

Guest
Hey all,

I am trying to call a file "DataFile" and read some of the data from
it, Kind of like using the ifstream command in C.
ifstream File( DataFile );
I am not sure how to do it in verilog..!!
 
This is what I am trying to figure out how to do in Verilog:

ifstream File( DataFile );

for ( i=0; i<NumThresholds; i++ )
{
File >> Taps;
};

File.close();
 
Two of the simpler ways are :

1. You encoded in a memory file format, that can be read into a two
dimensional reg array, using $readmemh (or similar) system task .

2. You can write your own pli that reads the file and returns the data
through the Task/Function(tf_) pli calls.

-Art
 
can someone explain this with more detail :

1. You encoded in a memory file format, that can be read into a two
dimensional reg array, using $readmemh (or similar) system task .

Thank you ..
 
Or if your tools support Verilog-2001, you can use the built-in file
I/O functions that are similar to the C stdio library functions
($fopen, $fscanf, $fclose, etc).

BTW, the example given appears to be C++ rather than C. The
Verilog-2001 file I/O is based on the C library, not C++.
 

Welcome to EDABoard.com

Sponsor

Back
Top