Added support for %m selection op
authorClifford Wolf <clifford@clifford.at>
Thu, 6 Feb 2014 18:30:08 +0000 (19:30 +0100)
committerClifford Wolf <clifford@clifford.at>
Thu, 6 Feb 2014 18:30:08 +0000 (19:30 +0100)
passes/cmds/select.cc

index f1c251ebc515321354b72d4ef1acee22469fe412..99f9d31e1406f7bf672850a674bd7ccef7d661f2 100644 (file)
@@ -187,6 +187,14 @@ static void select_op_submod(RTLIL::Design *design, RTLIL::Selection &lhs)
        }
 }
 
+static void select_op_fullmod(RTLIL::Design *design, RTLIL::Selection &lhs)
+{
+       lhs.optimize(design);
+       for (auto &it : lhs.selected_members)
+               lhs.selected_modules.insert(it.first);
+       lhs.selected_members.clear();
+}
+
 static void select_op_union(RTLIL::Design*, RTLIL::Selection &lhs, const RTLIL::Selection &rhs)
 {
        if (rhs.full_selection) {
@@ -568,6 +576,11 @@ static void select_stmt(RTLIL::Design *design, std::string arg)
                                log_cmd_error("Must have at least one element on the stack for operator %%s.\n");
                        select_op_submod(design, work_stack[work_stack.size()-1]);
                } else
+               if (arg == "%m") {
+                       if (work_stack.size() < 1)
+                               log_cmd_error("Must have at least one element on the stack for operator %%s.\n");
+                       select_op_fullmod(design, work_stack[work_stack.size()-1]);
+               } else
                if (arg == "%x" || (arg.size() > 2 && arg.substr(0, 2) == "%x" && (arg[2] == ':' || arg[2] == '*' || arg[2] == '.' || ('0' <= arg[2] && arg[2] <= '9')))) {
                        if (work_stack.size() < 1)
                                log_cmd_error("Must have at least one element on the stack for operator %%x.\n");
@@ -893,6 +906,9 @@ struct SelectPass : public Pass {
                log("        expand top set by adding all modules of instantiated cells in selected\n");
                log("        modules\n");
                log("\n");
+               log("    %%m\n");
+               log("        expand top set by selecting all modules that contain selected objects\n");
+               log("\n");
                log("Example: the following command selects all wires that are connected to a\n");
                log("'GATE' input of a 'SWITCH' cell:\n");
                log("\n");