How to load multiple test vector files, where the filename come fromgeneric parameters?

Discussion in 'VHDL' started by py, Dec 19, 2013.

  1. py

    py Guest


    For my test bench design, I coded an input procedure that loops continuously. In each iteration, it opens a vector file and load the content as test stimulus.

    What I'm trying to do is pipe in the filenames as generic parameters. At the moment, I can only do something ugly like this:

    for ii in 0 to G_NUM_TEST_CYCLE-1 loop
    if ii=0 then
    readline_nospace(f_data_ref, rline);
    elsif ii = 1 then
    readline_nospace(f_data_ref_1, rline);
    elsif ii = 2 then
    readline_nospace(f_data_ref_2, rline);

    Is there a way to create an array string (if so what's the syntax? I am using vhdl2008) to specify a set of index-able filenames?

    py, Dec 19, 2013
    1. Advertisements

  2. Le 19/12/2013 19:52, py a écrit :
    You can define an array of strings but they will have to have the same
    length (all elements of an array mut be of the exact same type)
    A more flexible way would be to read the file names from a single file:

    variable filename : line;
    file filenames_file, tb_file : text;

    while not endfile(filenames_file) loop
    readline(filenames_file, filename); -- Read the file name
    file_open(tb_file, filename.all, read_mode); -- Open the file
    while not endfile(tb_file) loop
    <read the file and do whatever needs to be done>
    end loop;
    end loop;

    Nicolas Matringe, Dec 19, 2013
    1. Advertisements

  3. py

    py Guest

    Thanks! I was stump earlier due to uneven filename length. This file of files approach sounds good.
    py, Dec 19, 2013
  4. Le 20/12/2013 00:59, py a écrit :
    It's ben a while since I've used this, my code may need some rework but
    the basic ideas is there.

    Nicolas Matringe, Dec 20, 2013
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.