Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

select: Add new t:@<name> syntax #4626

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions passes/cmds/select.cc
Original file line number Diff line number Diff line change
Expand Up @@ -876,9 +876,20 @@ static void select_stmt(RTLIL::Design *design, std::string arg, bool disable_emp
sel.selected_members[mod->name].insert(cell->name);
} else
if (arg_memb.compare(0, 2, "t:") == 0) {
for (auto cell : mod->cells())
if (match_ids(cell->type, arg_memb.substr(2)))
sel.selected_members[mod->name].insert(cell->name);
if (arg_memb.compare(2, 1, "@") == 0) {
std::string set_name = RTLIL::escape_id(arg_memb.substr(3));
if (!design->selection_vars.count(set_name))
log_cmd_error("Selection @%s is not defined!\n", RTLIL::unescape_id(set_name).c_str());

auto &muster = design->selection_vars[set_name];
for (auto cell : mod->cells())
if (muster.selected_modules.count(cell->type))
sel.selected_members[mod->name].insert(cell->name);
} else {
for (auto cell : mod->cells())
if (match_ids(cell->type, arg_memb.substr(2)))
sel.selected_members[mod->name].insert(cell->name);
}
} else
if (arg_memb.compare(0, 2, "p:") == 0) {
for (auto &it : mod->processes)
Expand Down Expand Up @@ -1164,6 +1175,9 @@ struct SelectPass : public Pass {
log(" t:<pattern>\n");
log(" all cells with a type matching the given pattern\n");
log("\n");
log(" t:@<name>\n");
log(" all cells with a type matching a module in the saved selection <name>\n");
log("\n");
log(" p:<pattern>\n");
log(" all processes with a name matching the given pattern\n");
log("\n");
Expand Down
52 changes: 52 additions & 0 deletions tests/select/mod-attribute.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
read_rtlil <<EOT
module \pdk_not

wire input 1 \A
wire output 2 \Y

cell $_NOT_ \not
connect \A \A
connect \Y \Y
end

end

module \pdk_buf

wire input 1 \A
wire output 2 \Y

cell $_BUF_ \buf
connect \A \A
connect \Y \Y
end

end

module \top
wire input 1 \A
wire output 2 \Y
wire \w

cell \pdk_buf \buf
connect \A \A
connect \Y \w
end

cell \pdk_not \not
connect \A \w
connect \Y \Y
end

end
EOT

cellmatch -lut_attrs *

select -set buffers a:lut=2'b10 %m
select -set inverters a:lut=2'b01 %m

select -assert-count 1 t:@buffers t:pdk_buf %i
select -assert-count 0 t:@buffers t:pdk_not %i
select -assert-count 0 t:@inverters t:pdk_buf %i
select -assert-count 1 t:@inverters t:pdk_not %i
Loading