Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
17247 Discussions

continue process after end of file

Altera_Forum
Honored Contributor II
1,437 Views

goodmorning, 

I have created a testbench importing data from a .bin file. 

These data are loaded in a RAM, and then analyzed by a second process. The time for analyzing all data is more than the time to upload them in the RAM. 

I have written the process to extract data from file in this way: 

 

begin 

if not endfile(input) then 

wait for clockRAM*4; 

for i in 0 to 7 loop 

read(datafile, indata); 

inputvariable<=CONV_STD_LOGIC_VECTOR(character'pos(indata),8); --I extract 8 byte at a time. 

end loop; 

else 

file_close(datafile); 

wait; 

end if; 

end process; 

 

I would that the simulation doesn't stop when the datafile is ended, but I would wait the end of the data analysis, which is in another process; But when datafile is ended I receive a message of fatal error.  

How can I do? 

 

Thanks 

 

Dario
0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
669 Views

PS. I'm using Modelsim simulator v.10.1

0 Kudos
Altera_Forum
Honored Contributor II
669 Views

you didnt say what thye error is? 

 

I do notice though that in your code you have no waits between read values. Signals are only updated when a process suspends, so your current code read 8 values from a file but will only put the 8th value onto inputvariable (this is a silly name for a signal, as it is not a variable).
0 Kudos
Altera_Forum
Honored Contributor II
669 Views

you are right. The error is: "Attempt to read past the end of file." In my code the inputvariable is called Macoutput, because the MAC inteface extract 8 bit for clock cycle. Every 96 ns I begin to extract the first 8 bits of a Payload which is - in my case - 64 bit long. Then they are saved in eight registers and finally a fifo is filled. But these are details. The important thing is that the simulation should go on when the read file is at the eof.

0 Kudos
Altera_Forum
Honored Contributor II
669 Views

You havent posted the whole code, so I can only go off what you have posted: 

- You check for end of file from a file called "input" but you read from a file called "datafile". 

 

- Are there enough values in the file? You only check for end of file every 8 values - so is the total length of the file divisible by 8? 

 

- Your code will not do what you're talking about. Because signals are only assigned when a process suspends, according to your code "inputvariable" is only assigned the 8th value, the first 7 are discarded. and you're talking about reading bits - do you mean reading bytes? 

 

- You also wait for a specified period of time. Does this sync up with the clock properly? why dont you wait for a rising/falling edge of a clock?
0 Kudos
Altera_Forum
Honored Contributor II
669 Views

Fantastic!! You are right again... I'm a stupid man! I've write the wrong name of the file.... I'm really sorry :'(  

Thanks a lot, and sorry again for my poor figure!
0 Kudos
Reply