Improve "read_verilog -dump_vlog[12]" handling of upto ranges
authorClifford Wolf <clifford@clifford.at>
Thu, 21 Mar 2019 21:20:16 +0000 (22:20 +0100)
committerClifford Wolf <clifford@clifford.at>
Thu, 21 Mar 2019 21:20:16 +0000 (22:20 +0100)
Signed-off-by: Clifford Wolf <clifford@clifford.at>
frontends/ast/ast.cc

index 0442ea0dba097c43f410df5a3e021007fe6bbd6c..d489961677c2cfa12dc6df54142c0ab966717c87 100644 (file)
@@ -431,9 +431,12 @@ void AstNode::dumpVlog(FILE *f, std::string indent) const
                break;
 
        case AST_RANGE:
-               if (range_valid)
-                       fprintf(f, "[%d:%d]", range_left, range_right);
-               else {
+               if (range_valid) {
+                       if (range_swapped)
+                               fprintf(f, "[%d:%d]", range_right, range_left);
+                       else
+                               fprintf(f, "[%d:%d]", range_left, range_right);
+               } else {
                        for (auto child : children) {
                                fprintf(f, "%c", first ? '[' : ':');
                                child->dumpVlog(f, "");