Fixed finish_addr handling in $readmemh/$readmemb
authorClifford Wolf <clifford@clifford.at>
Sat, 20 Aug 2016 11:47:46 +0000 (13:47 +0200)
committerClifford Wolf <clifford@clifford.at>
Sat, 20 Aug 2016 11:47:46 +0000 (13:47 +0200)
frontends/ast/simplify.cc

index 6ff117a4450e670989d9af17dfe9370ce5b854d8..d071a54fa09ce16bf5d61817e4224b06eb3be0e4 100644 (file)
@@ -2468,12 +2468,12 @@ AstNode *AstNode::readmem(bool is_readmemh, std::string mem_filename, AstNode *m
                                block->children.back()->children[0]->id2ast = memory;
                        }
 
-                       if ((cursor == finish_addr) || (increment > 0 && cursor > range_max) || (increment < 0 && cursor < range_min))
-                               break;
                        cursor += increment;
+                       if ((cursor == finish_addr+increment) || (increment > 0 && cursor > range_max) || (increment < 0 && cursor < range_min))
+                               break;
                }
 
-               if ((cursor == finish_addr) || (increment > 0 && cursor > range_max) || (increment < 0 && cursor < range_min))
+               if ((cursor == finish_addr+increment) || (increment > 0 && cursor > range_max) || (increment < 0 && cursor < range_min))
                        break;
        }