Skip to content

Commit

Permalink
Merge pull request #4700 from povik/select-list-mod
Browse files Browse the repository at this point in the history
Add `select -list-mod`
  • Loading branch information
Ravenslofty authored Nov 4, 2024
2 parents 2610ccb + 35a20da commit 3250f2b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
3 changes: 2 additions & 1 deletion passes/cmds/logger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ struct LoggerPass : public Pass {
log_cmd_error("Number of expected messages must be higher then 0 !\n");
if (type=="error" && count!=1)
log_cmd_error("Expected error message occurrences must be 1 !\n");
log("Added regex '%s' for warnings to expected %s list.\n", pattern.c_str(), type.c_str());
log("Added regex '%s' to expected %s messages list.\n",
pattern.c_str(), type.c_str());
try {
if (type == "error")
log_expect_error[pattern] = LogExpectedItem(YS_REGEX_COMPILE(pattern), count);
Expand Down
12 changes: 9 additions & 3 deletions passes/cmds/select.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ struct SelectPass : public Pass {
log(" select [ -add | -del | -set <name> ] {-read <filename> | <selection>}\n");
log(" select [ -unset <name> ]\n");
log(" select [ <assert_option> ] {-read <filename> | <selection>}\n");
log(" select [ -list | -write <filename> | -count | -clear ]\n");
log(" select [ -list | -list-mod | -write <filename> | -count | -clear ]\n");
log(" select -module <modname>\n");
log("\n");
log("Most commands use the list of currently selected objects to determine which part\n");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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))
Expand Down
13 changes: 13 additions & 0 deletions tests/select/list_mod.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
read_verilog <<EOF
module top1;
(* foo *)
wire w;
endmodule

module top2;
(* bar *)
wire w;
endmodule
EOF
logger -expect log top1 1
select -list-mod a:foo %m

0 comments on commit 3250f2b

Please sign in to comment.