diff --git a/libraries/base/common/tb/vhdl/tb_common_pkg.vhd b/libraries/base/common/tb/vhdl/tb_common_pkg.vhd index dfd1e86eb0cd4e0b5011f99bcc3199ed5a4dbc78..4167e7db4476139884117d5606d5bea9b65caa1b 100644 --- a/libraries/base/common/tb/vhdl/tb_common_pkg.vhd +++ b/libraries/base/common/tb/vhdl/tb_common_pkg.vhd @@ -990,23 +990,30 @@ PACKAGE BODY tb_common_pkg IS VARIABLE v_string : STRING(1 TO 80); VARIABLE v_row_arr : t_integer_arr(0 TO nof_col-1); BEGIN - -- Open the file for reading - proc_common_open_file(v_file_status, v_in_file, file_name, READ_MODE); - -- Read and skip the header - FOR J IN 0 TO nof_header_lines-1 LOOP - proc_common_readline_file(v_file_status, v_in_file, v_string); - END LOOP; - FOR J IN 0 TO nof_row-1 LOOP - proc_common_readline_file(v_file_status, v_in_file, v_row_arr, nof_col); - FOR I IN 0 TO nof_col-1 LOOP - return_array(J*nof_col + I) <= v_row_arr(I); -- use loop to be independent of t_integer_arr downto or to range + IF file_name/="UNUSED" AND file_name/="unused" THEN + -- Open the file for reading + proc_common_open_file(v_file_status, v_in_file, file_name, READ_MODE); + -- Read and skip the header + FOR J IN 0 TO nof_header_lines-1 LOOP + proc_common_readline_file(v_file_status, v_in_file, v_string); END LOOP; - IF ENDFILE(v_in_file) THEN - EXIT; - END IF; - END LOOP; - -- Close the file - proc_common_close_file(v_file_status, v_in_file); + FOR J IN 0 TO nof_row-1 LOOP + proc_common_readline_file(v_file_status, v_in_file, v_row_arr, nof_col); + FOR I IN 0 TO nof_col-1 LOOP + return_array(J*nof_col + I) <= v_row_arr(I); -- use loop to be independent of t_integer_arr downto or to range + END LOOP; + IF ENDFILE(v_in_file) THEN + IF J/=nof_row-1 THEN + REPORT "COMMON : Unexpected end of file" SEVERITY FAILURE; + END IF; + EXIT; + END IF; + END LOOP; + -- Close the file + proc_common_close_file(v_file_status, v_in_file); + ELSE + return_array <= (return_array'RANGE=>0); + END IF; END proc_common_read_integer_file; ------------------------------------------------------------------------------