dpaul
Advanced Member level 5
I have a test-bench module which is instantiated multiple times. In there is a file write operation. My requirement is to have an unique file created for each instantiated module.
How can I do that?
--------------------------------------------------------------------
This is what I have done...
The uniqueness of the file name is to be derived from two generics, SLOT_NUM and PORT_NUM.
e.g. - file__SLOT_NUM__PORT_NUM
Now I have like - file_open(outfile, string'(complete_file_path), write_mode); which does not work.
The goal is to create and write to files such as
C:\Work\elog\fpga_a7\sources\sim\frm_rx\file__0__0.txt
C:\Work\elog\fpga_a7\sources\sim\frm_rx\file__0__1.txt
C:\Work\elog\fpga_a7\sources\sim\frm_rx\file__1__0.txt, and so on.
I am doing those string'() explicit string casting to be on the safe side but they don't help.
Vivado2019.2 complains this line: writeline(outfile, outline); -- Begin file write after 1 line space
I suspect it has something to do with the file_open() procedure, because if I replace the complete_file_path by an explicit string like "....." at least the file is created.
So what is the workaround?
How can I do that?
--------------------------------------------------------------------
This is what I have done...
The uniqueness of the file name is to be derived from two generics, SLOT_NUM and PORT_NUM.
e.g. - file__SLOT_NUM__PORT_NUM
Code:
SLOT_NUM : integer := 0;
PORT_NUM : std_logic_vector(1 downto 0) := "00" ;
Inside the module I have the declaration,
constant file_path : string(1 to 40) := "C:\Work\elog\fpga_a7\sources\sim\frm_rx\";
signal file_name : string(1 to 13) ;
signal complete_file_path : string(1 to 53) ;
file outfile : text ; -- Declare write file variable, file pointer
shared variable outline : line ; -- line number declaration
.
.
file_name <= "frm_rx_" & integer'image(SLOT_NUM) & integer'image(to_integer(unsigned(PORT_NUM))) & ".txt";
complete_file_path <= string'(file_path) & string'(file_name);
Now I have like - file_open(outfile, string'(complete_file_path), write_mode); which does not work.
The goal is to create and write to files such as
C:\Work\elog\fpga_a7\sources\sim\frm_rx\file__0__0.txt
C:\Work\elog\fpga_a7\sources\sim\frm_rx\file__0__1.txt
C:\Work\elog\fpga_a7\sources\sim\frm_rx\file__1__0.txt, and so on.
I am doing those string'() explicit string casting to be on the safe side but they don't help.
Vivado2019.2 complains this line: writeline(outfile, outline); -- Begin file write after 1 line space
I suspect it has something to do with the file_open() procedure, because if I replace the complete_file_path by an explicit string like "....." at least the file is created.
So what is the workaround?