nickg / nvc

VHDL compiler and simulator
https://www.nickg.me.uk/nvc/
GNU General Public License v3.0
589 stars 75 forks source link

FILE_OPEN Not Supplying Correct Status #864

Closed bpadalino closed 3 months ago

bpadalino commented 3 months ago
entity test is
end entity ;

architecture arch of test is

    impure function from_file(fname : in string) return real is
        use std.textio.all ;
        file f     : text ;
        variable s : file_open_status ;
        variable l : line ;
        variable r : real ;
    begin
        file_open(s, f, fname, READ_MODE) ;
        if s /= OPEN_OK then
            report "Could not open: " & fname severity failure ;
        end if ;
        readline(f, l) ;
        read(l, r) ;
        return r ;
    end function ;

    constant r : real := from_file("./nonexistent.txt") ;

begin

    tb : process
    begin
        std.env.stop ;
    end process ;

end architecture ;

Riviera fails with the following:

# EXECUTION:: FAILURE: Could not open: ./nonexistant.txt

nvc fails with the following:

** Fatal: ENDFILE called on closed file
   Procedure READLINE [TEXT, LINE] at ../lib/std/textio-body.vhd:632
   Function FROM_FILE [STRING return REAL] at nonexistent_file.vhdl:17
   Process (init) at nonexistent_file.vhdl:22

Riviera supplies the status as NAME_ERROR whereas nvc incorrectly states OPEN_OK.

nickg commented 3 months ago

It's a regression caused by c404bb04f.