Eric wrote:
> Hi,
>
> I would to setup a verification methodology in which a device read the
> stimuli from a file given a filename and in which the filename can be
> changed several time during the simulation (in order to execute several
> test scenario one after the other). I encounter some problems in
> passing the filename to the device because the VHDL compiler that I use
> (modelsim) only accept to pass a fixed length string to the device.
>
The way I do it is to declare a large enough string for any filename in
a package file:
subtype Filename_Str_Type is String(1 to 50);
I am reading a filename out of a plain text script file, so when I do
that, as I copy the filename into the string, I count the number of
characters copied:
-- Skip leading spaces/tabs, then copy characters into the
-- output string until the next space/tab.
procedure get_filename(L : inout line;
the_str : inout Filename_Str_Type;
name_len : inout integer) is
variable the_ch : character;
begin
j := 1;
read(L, the_ch, good);
-- skip leading spaces and tabs
while good = True and (the_ch = ' ' OR the_ch = ht) loop
read(L, the_ch, good);
end loop;
-- get the string
while good = True and j <= the_str'length loop
the_str(j) := the_ch;
j := j+1;
read(L, the_ch, good);
if the_ch = ' ' OR the_ch = ht then
exit;
end if;
end loop;
name_len := j;
end procedure get_filename;
Which is called like:
get_filename(L, file_str, name_len_v);
data_filename <= file_str;
NAME_LEN <= name_len_v;
I output the filename string and the number of characters in it:
entity bd_test is
port (
data_filename : out Filename_Str_Type;
NAME_LEN : out integer;
And then the file is opened in another place like this:
file_open(data_file, external_name => data_filename(1 to
NAME_LEN), open_kind => read_mode);
|