hi guys,
im having some trouble with reading from a file, actually the thing is the opening part. the problem is that i "dont" know the name of the file to read before compiling, that is because i've a "configuration" file where i give commands, one of them being the name of the "input" file.
i know i could use a function, but that only works when i've a small amount of data to read, cause otherwise, storing a HUGE array slows down the simulation, without saying that modelsim tells me that i has not enough memory and will start paging to disk and after a while it says that i got completely out of memory.
Simulation works perfect if i read one line (of the input file) at the time, but that means that the filename has to be written on the code (at least that's how i've been doing, by using ' file fp : TEXT is in "input.dat"; ')
now i need to open an arbitrary file, so i tried "file_open(fp, filenameString, READ_MODE);" the problem is that somehow it doesnt work, as it seems that if i open the file in one process (i have to open the file just once and read it till the end of the file at every rising_edge(clk), so that's two processes). It doesnt work cause it seems that the file is "closed" outside the process it was opened (i think i even read about that issue).
Also i cant find "file_open" declaration.
i also tried with a process like this: (im at home now, so i dont have the real sources, but i cant sleep so im writing to ask for help :) please)
process begin
if (filenameString /= nothing) then file_open(fp, filenameString, READ_MODE);
while (not endfile(fp)) loop wait until rising_edge(clk); read(fp, data); etc, etc end loop; file_close(fp); end if; end process;
that didnt work either, im not sure if it was because of the file_open part (i also did a check on the opening, it was succesful) or because the process get in an infinite loop, modelsim just stop responding (i think that endfile might return false if the file is not open, giving rise to the infinite loop, but the loop would at least be "waiting" for "clk" and it would actually read the data, but that doesnt happen). The file might get closed once "out" the process (like when another process gets executed) or something, i have no clue...
do any of you knows or have faced already this kind of situation? namely, reading a file whose name's specified after compilation (by another file) line by line (that is, not using a function to read a whole chunk of data and storing it in an array)
any comments will be appreciated, thanks
Paris