What I have
I'm trying to make a Test Bench where a file of one single line, where posible characters are "1" and "0". I've to read them all, and use one by one as input in my DUT.
So, in my TB, I've defined a process like the following, in order to read the file an pass it values to my DUT.
stim_proc: process
file input_file: TEXT is in "DatosEntrada.dat";
variable rdline : LINE;
variable line_content : string ( 1 to 4);
variable readed_char : character;
variable j : integer := 0;
begin
while not endfile(input_file) loop
readline(input_file, rdline);
--read(rdline, line_content);
for j in 1 to rdline'length-1 loop
readed_char := line_content(j);
if (readed_char = '1') then
input <= '1';
else
input <= '0';
end if;
wait for clk_period;
end loop;
end loop;
end process;
What I think it's happening
I'm reading the first (and only) line of my file with the first readline
execution. After this, this loop shouldn't execute again.
Then, data from file should be inside rdline
. So I've to process it. In order to do it, I've tried to loop over rdline
length, but this loop doesn't execute.
for j in 1 to rdline'length-1 loop
So I thought I need to read this line in order to loop over it, and tried to move its data to a string
var. The problem is that vector var like string need to have a defined size, and I don't know the file line size.
What have I tried
I've tried different ways to accomplish it, like reading each time 4 chars from rdline
into a string, process it, then repeat. However, I couldn't make it work.
I've found quite lot examples on Google about reading files with VHDL, but they're all pretty the same, and all have defined line formats, like columns or expected integers, where I just have an unknown text of one line.
I guess it could be achieved by reading from rdline
var in some way, but I can't achieve it. Could you help me to code it?
Thank you in advance
Aucun commentaire:
Enregistrer un commentaire