Modified the new search for files of $readmem[hb] to be backward compatible
authorRodrigo Alejandro Melo <rodrigomelo9@gmail.com>
Sat, 1 Feb 2020 01:10:51 +0000 (22:10 -0300)
committerRodrigo Alejandro Melo <rodrigomelo9@gmail.com>
Sat, 1 Feb 2020 01:10:51 +0000 (22:10 -0300)
Signed-off-by: Rodrigo Alejandro Melo <rodrigomelo9@gmail.com>
frontends/ast/simplify.cc

index f7364b9a800a78a376251d0937051ddde99af080..4f105eed6001bd54b96fb58da6e697b0cb3e8e2b 100644 (file)
@@ -2887,9 +2887,13 @@ AstNode *AstNode::readmem(bool is_readmemh, std::string mem_filename, AstNode *m
 
        std::ifstream f;
        std::string path = filename.substr(0, filename.find_last_of("\\/")+1);
-       f.open(path + mem_filename.c_str());
-       yosys_input_files.insert(mem_filename);
-
+       f.open(mem_filename.c_str());
+       if (f.fail()) {
+               f.open(path + mem_filename.c_str());
+               yosys_input_files.insert(path + mem_filename);
+       } else {
+               yosys_input_files.insert(mem_filename);
+       }
        if (f.fail())
                log_file_error(filename, linenum, "Can not open file `%s` for %s.\n", mem_filename.c_str(), str.c_str());