Skip to content

Commit 9432e97

Browse files
authored
Merge pull request #4626 from povik/select-t-at
select: Add new `t:@<name>` syntax
2 parents 11e94cc + f9f509b commit 9432e97

File tree

2 files changed

+69
-3
lines changed

2 files changed

+69
-3
lines changed

passes/cmds/select.cc

+17-3
Original file line numberDiff line numberDiff line change
@@ -876,9 +876,20 @@ static void select_stmt(RTLIL::Design *design, std::string arg, bool disable_emp
876876
sel.selected_members[mod->name].insert(cell->name);
877877
} else
878878
if (arg_memb.compare(0, 2, "t:") == 0) {
879-
for (auto cell : mod->cells())
880-
if (match_ids(cell->type, arg_memb.substr(2)))
881-
sel.selected_members[mod->name].insert(cell->name);
879+
if (arg_memb.compare(2, 1, "@") == 0) {
880+
std::string set_name = RTLIL::escape_id(arg_memb.substr(3));
881+
if (!design->selection_vars.count(set_name))
882+
log_cmd_error("Selection @%s is not defined!\n", RTLIL::unescape_id(set_name).c_str());
883+
884+
auto &muster = design->selection_vars[set_name];
885+
for (auto cell : mod->cells())
886+
if (muster.selected_modules.count(cell->type))
887+
sel.selected_members[mod->name].insert(cell->name);
888+
} else {
889+
for (auto cell : mod->cells())
890+
if (match_ids(cell->type, arg_memb.substr(2)))
891+
sel.selected_members[mod->name].insert(cell->name);
892+
}
882893
} else
883894
if (arg_memb.compare(0, 2, "p:") == 0) {
884895
for (auto &it : mod->processes)
@@ -1164,6 +1175,9 @@ struct SelectPass : public Pass {
11641175
log(" t:<pattern>\n");
11651176
log(" all cells with a type matching the given pattern\n");
11661177
log("\n");
1178+
log(" t:@<name>\n");
1179+
log(" all cells with a type matching a module in the saved selection <name>\n");
1180+
log("\n");
11671181
log(" p:<pattern>\n");
11681182
log(" all processes with a name matching the given pattern\n");
11691183
log("\n");

tests/select/mod-attribute.ys

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
read_rtlil <<EOT
2+
module \pdk_not
3+
4+
wire input 1 \A
5+
wire output 2 \Y
6+
7+
cell $_NOT_ \not
8+
connect \A \A
9+
connect \Y \Y
10+
end
11+
12+
end
13+
14+
module \pdk_buf
15+
16+
wire input 1 \A
17+
wire output 2 \Y
18+
19+
cell $_BUF_ \buf
20+
connect \A \A
21+
connect \Y \Y
22+
end
23+
24+
end
25+
26+
module \top
27+
wire input 1 \A
28+
wire output 2 \Y
29+
wire \w
30+
31+
cell \pdk_buf \buf
32+
connect \A \A
33+
connect \Y \w
34+
end
35+
36+
cell \pdk_not \not
37+
connect \A \w
38+
connect \Y \Y
39+
end
40+
41+
end
42+
EOT
43+
44+
cellmatch -lut_attrs *
45+
46+
select -set buffers a:lut=2'b10 %m
47+
select -set inverters a:lut=2'b01 %m
48+
49+
select -assert-count 1 t:@buffers t:pdk_buf %i
50+
select -assert-count 0 t:@buffers t:pdk_not %i
51+
select -assert-count 0 t:@inverters t:pdk_buf %i
52+
select -assert-count 1 t:@inverters t:pdk_not %i

0 commit comments

Comments
 (0)