[SOLVED] Unable to read data from text file showing EOF reached in veriloga spectre

Status
Not open for further replies.

amiramu10

Newbie level 4
Joined
Oct 21, 2015
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,423
Hi,
I am using the code (more o less) available on the post https://www.edaboard.com/threads/reading-a-file-in-veriloga.382674/. But for me, it is showing that the end of file (EOF) reached as shown in attached screenshot.
I am reading data from a file which contains the pixel values of column of image. I am performing the transient analysis using spectre to get the output (out here) at each time event. I have tried, just to check, different length of simulations but the response is same as shown in the attached figure. Also, simulation does not stop and continue. Please help.

C-like:
// VerilogA for Verilog_A, data_readout, veriloga



`include "constants.vams"
`include "disciplines.vams"

module module_filereader (out);

output out;
electrical out;

parameter real period = 1/10k;
parameter integer maxcount = 480;

integer dataread, cnt;
real mydata1, mydata2;
real datacol [maxcount-1:0];

analog begin

@(initial_step("tran")) begin
cnt = 0;
dataread = $fopen("/mnt/cnm/khan/Amir_IC/Building_block/One_column_image1.csv","r"); //opening file readable access
end

@(timer(0, period )) begin
cnt = cnt+1;
end

while( cnt < maxcount ) begin
mydata1 = $fscanf(dataread,"%f", datacol[cnt]);
// mydata1 = $fscanf(dataread,"%f",cnt);

end
$debug("\nThe value of variable mydata1 is %f",mydata1);


@(final_step) $fclose(dataread);

V(out) <+ transition(mydata1, 1n, 1n, 1n);

end

endmodule




 
Last edited by a moderator:

you are reading more data than what is inside the file, apparently.

just add an if condition to check for EOF/null and you will be fine.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…