Fixed handling of parameters with reversed range
authorClifford Wolf <clifford@clifford.at>
Mon, 8 Jun 2015 12:03:06 +0000 (14:03 +0200)
committerClifford Wolf <clifford@clifford.at>
Mon, 8 Jun 2015 12:03:06 +0000 (14:03 +0200)
frontends/ast/simplify.cc

index 30b4f51391969adaeecd02a7201921302e3e806a..88df28f8bbf50b40cee954c90f9227dc4bc33691 100644 (file)
@@ -678,7 +678,7 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
                if (children.size() > 1 && children[1]->type == AST_RANGE) {
                        if (!children[1]->range_valid)
                                log_error("Non-constant width range on parameter decl at %s:%d.\n", filename.c_str(), linenum);
-                       int width = children[1]->range_left - children[1]->range_right + 1;
+                       int width = std::abs(children[1]->range_left - children[1]->range_right) + 1;
                        if (children[0]->type == AST_REALVALUE) {
                                RTLIL::Const constvalue = children[0]->realAsConst(width);
                                log_warning("converting real value %e to binary %s at %s:%d.\n",