From 7aa3fdab806c7df29345da5f0f2319edca35ca28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Wed, 16 Oct 2024 11:43:26 +0200 Subject: [PATCH] select: Add `-list-mod` option --- passes/cmds/select.cc | 12 +++++++++--- tests/select/list_mod.ys | 13 +++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 tests/select/list_mod.ys diff --git a/passes/cmds/select.cc b/passes/cmds/select.cc index ff72724ae..aec4c964b 100644 --- a/passes/cmds/select.cc +++ b/passes/cmds/select.cc @@ -1041,7 +1041,7 @@ struct SelectPass : public Pass { log(" select [ -add | -del | -set ] {-read | }\n"); log(" select [ -unset ]\n"); log(" select [ ] {-read | }\n"); - log(" select [ -list | -write | -count | -clear ]\n"); + log(" select [ -list | -list-mod | -write | -count | -clear ]\n"); log(" select -module \n"); log("\n"); log("Most commands use the list of currently selected objects to determine which part\n"); @@ -1277,6 +1277,7 @@ struct SelectPass : public Pass { bool clear_mode = false; bool none_mode = false; bool list_mode = false; + bool list_mod_mode = false; bool count_mode = false; bool got_module = false; bool assert_none = false; @@ -1338,6 +1339,11 @@ struct SelectPass : public Pass { list_mode = true; continue; } + if (arg == "-list-mod") { + list_mode = true; + list_mod_mode = true; + continue; + } if (arg == "-write" && argidx+1 < args.size()) { write_file = args[++argidx]; continue; @@ -1416,7 +1422,7 @@ struct SelectPass : public Pass { log_cmd_error("Options %s can not be combined.\n", common_flagset); if ((list_mode || !write_file.empty() || count_mode) && common_flagset_tally) - log_cmd_error("Options -list, -write and -count can not be combined with %s.\n", common_flagset); + log_cmd_error("Options -list, -list-mod, -write and -count can not be combined with %s.\n", common_flagset); if (!set_name.empty() && (list_mode || !write_file.empty() || count_mode || !unset_name.empty() || common_flagset_tally)) log_cmd_error("Option -set can not be combined with -list, -write, -count, -unset, %s.\n", common_flagset); @@ -1467,7 +1473,7 @@ struct SelectPass : public Pass { { if (sel->selected_whole_module(mod->name) && list_mode) log("%s\n", id2cstr(mod->name)); - if (sel->selected_module(mod->name)) { + if (sel->selected_module(mod->name) && !list_mod_mode) { for (auto wire : mod->wires()) if (sel->selected_member(mod->name, wire->name)) LOG_OBJECT("%s/%s\n", id2cstr(mod->name), id2cstr(wire->name)) diff --git a/tests/select/list_mod.ys b/tests/select/list_mod.ys new file mode 100644 index 000000000..c8a3ac8b5 --- /dev/null +++ b/tests/select/list_mod.ys @@ -0,0 +1,13 @@ +read_verilog <