Fixed handling of unconditional generate blocks
authorClifford Wolf <clifford@clifford.at>
Tue, 26 Mar 2013 08:44:54 +0000 (09:44 +0100)
committerClifford Wolf <clifford@clifford.at>
Tue, 26 Mar 2013 08:44:54 +0000 (09:44 +0100)
frontends/ast/genrtlil.cc
frontends/ast/simplify.cc

index 0654db2df59ba562aa3942c4087d3eacde35ddc2..47ca37bd0559977b7dcac32402c7ac4f2b742cd8 100644 (file)
@@ -528,6 +528,7 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint)
        case AST_LOCALPARAM:
        case AST_GENVAR:
        case AST_GENFOR:
+       case AST_GENBLOCK:
        case AST_GENIF:
                break;
 
index ef06c5b032a9c71d998b061662433dff48bc5328..981897db55d2cde95da6a6d142a98c4da6483372 100644 (file)
@@ -182,6 +182,8 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage)
                        break;
                if (type == AST_GENIF && i >= 1)
                        break;
+               if (type == AST_GENBLOCK)
+                       break;
                if (type == AST_PREFIX && i >= 1)
                        break;
                while (did_something_here && i < children.size()) {
@@ -409,6 +411,21 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage)
                did_something = true;
        }
 
+       // simplify unconditional generate block
+       if (type == AST_GENBLOCK && children.size() != 0)
+       {
+               if (!str.empty()) {
+                       std::map<std::string, std::string> name_map;
+                       expand_genblock(std::string(), str + ".", name_map);
+               }
+
+               for (size_t i = 0; i < children.size(); i++)
+                       current_ast_mod->children.push_back(children[i]);
+
+               children.clear();
+               did_something = true;
+       }
+
        // simplify generate-if blocks
        if (type == AST_GENIF && children.size() != 0)
        {
@@ -434,7 +451,7 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage)
 
                        if (!buf->str.empty()) {
                                std::map<std::string, std::string> name_map;
-                               buf->expand_genblock(std::string(), buf->str, name_map);
+                               buf->expand_genblock(std::string(), buf->str + ".", name_map);
                        }
 
                        for (size_t i = 0; i < buf->children.size(); i++)