4 comments

  1. As I understand it, it works because it’s all enclosed in a bigger loop:


    allpixels : loop
    readline(pgmfile, l);

    exit when l = null;
    exit when l'length = 0;

    loop in question-->
    loop
    read(l, int, good);
    exit when not good;
    ret(x, y) := int;
    exit allpixels when x = width-1 and y = height-1;
    x := x + 1;
    if x >= width then
    x := 0;
    y := y + 1;
    end if;
    end loop;
    end loop allpixels;

    Now that I think of it, this confusion may be due to the format of my pgm files. Every pixel value is on a new line, as exported by Gimp. Example:

    P2
    # CREATOR: GIMP PNM Filter Version 1.1
    450 375
    255
    119
    120
    ...

    That’s why the read() in question reads 1 character per line and then throws the error. I have run your testbench with the changes and it works the same. I’m using the Isim that comes with ISE 12.1 (M.53d)

  2. I’m not sure that’s a valid fix in general (removing the loop and the exit) – it works fine for one number per line, but shouldn’t work when there’s more than one number per line. That may be a failing of my testcases!

    I think the root-cause of the problem is really just that Isim is whinging a lot. I’ll see if I can replicate it here and come up with a better fix.

Leave a comment

Your email address will not be published. Required fields are marked *