Is there some way to start the simulation which then asks which file
I'd like to use to initialise the memory before the sim progresses?
TIA, Niv.
Most simulators have a command-line option to set generics
(or Verilog parameters) at elaboration time. For example, in
Mentor Modelsim/Questa, if your top-level has a string generic
called FILENAME:
vsim -gFILENAME=somefile.txt my_top_level_entity
See also the -G option which does similar things. Beware of
spaces and backslashes in filenames :-(
However, perhaps you want to read in the filename dynamically?
You can read from the INPUT file (keyboard) procedurally:
use std.textio.all; -- as usual
file mem_file: text;
set_up_the_file: process
variable L: line;
variable status: file_open_status;
begin
loop -- keep going until user gives me a valid file
write(L, string'("Please type in the filename:"));
writeline(OUTPUT, L); -- send prompt to console
readline(INPUT, L); -- get user response
-- assume it's just a filename, nothing else
file_open(status, mem_file, L.all, READ_MODE);
exit when status=open_ok; -- we're done if the file was valid
write(L, string'("Bad filename "
& L.all
& " please try again!"));
writeline(OUTPUT, L);
end loop;
-- Here when we opened the file successfully. Our work is done.
wait;
end process;
Usually, though, it's far better to sort out the filename using
a Tcl script (which can search directories, check file permissions,
invent interesting filenames and suchlike) and then use the same
script to launch the sim with an appropriate file-name generic.
HTH
--
Jonathan Bromley, Consultant
DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services
Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
jonathan...@MYCOMPANY.com
http://www.MYCOMPANY.com
The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.
So something similar to this should work (can' test my self right now)
file_open(status, "$$MY_PATH/my_file.ext", L.all, READ_MODE);
HTH -- Pontus
Andy
Charles Bailey