File operations

Hi,

What is the syntax for $fread operation. I am trying to read a file using $fread system task but i am getting the error.

$fread(“INFO”, file_read, trans.data_read);

$fread : Argument 2 is not a valid file descriptor

In reply to shankar_logic:
No one is going to read the manual for you here. Please see section 21.3.4 Reading data from a file in the IEEE 1800-2012 LRM

I referred the article. But — $fread

$fread has two variants—a register variant and a set of three memory variants.
The register variant,
$fread(myreg, fd);

In the similar way, i gave
$fread(trans.data_read, file_read);

But i get the error
Error: (vsim-PLI-3068) rtl/sequence.sv(21): $fread : Invalid argument

In reply to shankar_logic:

How did you declare trans.data_read and file_read?

trans.data_read is declared as
bit [127:0] data_read in the seq_item file
and
file_read is a int variable for which is a file pointer.
int file_read;
file_read = $fopen(“data.txt”);