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

Add parameter to not filter out blackboxes in selected_modules and selected_whole_modules #4565

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
8 changes: 4 additions & 4 deletions kernel/rtlil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -884,22 +884,22 @@ bool RTLIL::Design::selected_whole_module(RTLIL::Module *mod) const
return selected_whole_module(mod->name);
}

std::vector<RTLIL::Module*> RTLIL::Design::selected_modules() const
std::vector<RTLIL::Module*> RTLIL::Design::selected_modules(bool include_bw_box) const
{
std::vector<RTLIL::Module*> result;
result.reserve(modules_.size());
for (auto &it : modules_)
if (selected_module(it.first) && !it.second->get_blackbox_attribute())
if (selected_module(it.first) && (include_bw_box ? true : !it.second->get_blackbox_attribute()))
result.push_back(it.second);
return result;
}

std::vector<RTLIL::Module*> RTLIL::Design::selected_whole_modules() const
std::vector<RTLIL::Module*> RTLIL::Design::selected_whole_modules(bool include_bw_box) const
{
std::vector<RTLIL::Module*> result;
result.reserve(modules_.size());
for (auto &it : modules_)
if (selected_whole_module(it.first) && !it.second->get_blackbox_attribute())
if (selected_whole_module(it.first) && (include_bw_box ? true : !it.second->get_blackbox_attribute()))
result.push_back(it.second);
return result;
}
Expand Down
4 changes: 2 additions & 2 deletions kernel/rtlil.h
Original file line number Diff line number Diff line change
Expand Up @@ -1150,8 +1150,8 @@ struct RTLIL::Design
}


std::vector<RTLIL::Module*> selected_modules() const;
std::vector<RTLIL::Module*> selected_whole_modules() const;
std::vector<RTLIL::Module*> selected_modules(bool include_bw_box = false) const;
std::vector<RTLIL::Module*> selected_whole_modules(bool include_bw_box = false) const;
std::vector<RTLIL::Module*> selected_whole_modules_warn(bool include_wb = false) const;
#ifdef WITH_PYTHON
static std::map<unsigned int, RTLIL::Design*> *get_all_designs(void);
Expand Down
2 changes: 1 addition & 1 deletion passes/sat/cutpoint.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct CutpointPass : public Pass {
}
extra_args(args, argidx, design);

for (auto module : design->selected_modules())
for (auto module : design->selected_modules(true))
{
if (design->selected_whole_module(module->name)) {
log("Making all outputs of module %s cut points, removing module contents.\n", log_id(module));
Expand Down
4 changes: 2 additions & 2 deletions passes/techmap/attrmap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,12 @@ struct AttrmapPass : public Pass {

if (modattr_mode)
{
for (auto module : design->selected_whole_modules())
for (auto module : design->selected_whole_modules(true))
attrmap_apply(stringf("%s", log_id(module)), actions, module->attributes);
}
else
{
for (auto module : design->selected_modules())
for (auto module : design->selected_modules(true))
{
for (auto wire : module->selected_wires())
attrmap_apply(stringf("%s.%s", log_id(module), log_id(wire)), actions, wire->attributes);
Expand Down
7 changes: 7 additions & 0 deletions tests/select/cutpoint_blackbox.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(* blackbox *)
module add #(parameter N=3) (input [N-1:0] a, b, output [N-1:0] q);
endmodule

module top(input [7:0] a, b, output [7:0] q);
add #(.N(8)) add_i(.a(a), .b(b), .q(q));
endmodule
9 changes: 9 additions & 0 deletions tests/select/cutpoint_blackbox.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
read_verilog cutpoint_blackbox.v
check
select -assert-mod-count 1 =A:blackbox
select -assert-count 0 =t:$anyseq
cutpoint =A:blackbox
attrmap -modattr -remove blackbox
check
select -assert-mod-count 0 =A:blackbox
select -assert-count 1 =t:$anyseq
Loading