Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
13 years ago

error when reading datas from a file

Hi everybody,

I'm actually trying to make a pixel generator from a text file and i have an error in modelsim : (vsim-3543) TEXTIO procedure READ(INTEGER) : Parameter L designates an empty string.

my file seems like that :

3 1024 760

41 107 214 235 44 169 3 33 187 239

58 61 57 42 142 77 89 114 221 104

41 107 214 235 44 169 3 33 187 239

58 61 57 42 142 77 89 114 221 104

and my code is here:

FILE myfile : TEXT OPEN READ_MODE IS "fluxvid.txt";

BEGIN

PROCESS

VARIABLE fNumber : INTEGER range 1 to 3;

VARIABLE pnumber : INTEGER range 0 to 1024;

VARIABLE lnumber : INTEGER range 0 to 768;

variable buf : integer range 0 to 255;

variable buf_temp : unsigned(11 downto 0);

VARIABLE l: LINE;

BEGIN

READLINE(myfile,l); -- ... read a line ...

READ(l, fNumber); -- ... read the 1st element ...

READ(l, ipxl); -- ... and then the 2nd element

READ(l, jpxl); -- ... and then the 3nd element

IF (start_gen = '1') THEN

-- frame loop

FOR k IN 1 TO fNumber LOOP

fVal <= '1';

data_com <= (others => '0');

WAIT FOR 100 ns;

-- line loop

FOR i IN 1 TO lnumber LOOP

lVal <= '1';

-- pixel loop

FOR j IN 1 TO pnumber LOOP

READ(l, buf);

buf_temp := TO_UNSIGNED(buf, 12);

data_com <= STD_LOGIC_VECTOR(buf_temp);

WAIT FOR 10 ns;

END LOOP;

lVal <= '0';

END LOOP;

fVal <= '0';

WAIT FOR 100 ns;

END LOOP;

END IF;

END PROCESS;

Moreover, the data in the variable fNumber 41 instead of 3. I don't know where is my fault, i search on the web and didn't find the mistake.

Thx you for your answers !

5 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Cant really see the issue, clearly its reading in the 2nd line. Are you sure the file is correct? I also notice there's no wait at the end of the process, this means the process will start again when it gets to the end.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    NO Tricky, Martou78 is only reading the very first line, I can only find one single READLINE statement.

    So the READ in the pixel loop will fail. I'm almost sure that vsim will have pointed to that line ...
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    No it will read all the lines, as the process isn't permanently stopped with a single "wait;" statement.

    There are two problems I see in that code:[list][*]if start_gen isn't initialized at '1' (and by default it will be 'U') then the process will just read all the lines from the file and do nothing with them before going even one ps into the simulation[*]you never assign any value to lnumber and pnumber. By default they will be 0 so you never read the pixel values[/list]
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Correct, I overlooked that missing wait statement. I fixated on the missing ReadLine in the pixel loop. But as I said, ModelSim will (mostly) give a clue on the line with the offending statement, which would have been the first Read() after the ReadLine().