RegisterLogin  
Update Profile
   
You are here: Forum  
Minimize 
SVUG Community Forum
Subject: $fread question
Prev Next
You are not authorized to post a reply.

Author Messages
GregUser is Offline

Posts:11

05/13/2008 6:49 PM  
hi found this example on web.
i get an error when using it. - $fread: Argument 2 is not  avalid file descriptor
any ideas why it's failing?

thx

integer file, i;
reg Ε:0] memΎ:4095]
    file_name = "data.bin";
    file = $fopenr(file_name);
    i = $fread(file, memΎ]);

ShalomUser is Offline

Posts:15

05/14/2008 7:15 AM  
The order of the arguments to $fread shohld be reversed.

Shalom.Bresticker@intel.com
GregUser is Offline

Posts:11

05/14/2008 8:37 AM  
I also saw a warning that Questasim didn't know what $fopenr was so I switched to $fopen("path","r") as shown in LRM.

I switched the inputs and get the same error, now on elaboration stage vs a runtime error.

file = $fopen(file_name,"r");
i = $fread(memΎ], file);
GregUser is Offline

Posts:11

05/14/2008 9:45 AM  
I finally got this to work:
$readmemb("path", mem);

That read in the contents of the file and loaded, line by line, into the array I defined.

thx
You are not authorized to post a reply.



ActiveForums 3.7
  

 Copyright 2008 by SystemVerilog User Group Contact Us    Privacy Statement