25 std::map<RTLIL::SigBit, int> bit_usage_count;
33 for (
auto &cell_iter : module->
cells_)
34 for (
auto &conn : cell_iter.second->connections())
43 bit_usage_count[bit]++;
47 for (
auto &wire_iter : module->
wires_)
56 int usage_offset = wire->
port_id > 0 ? 1 : 0;
59 std::set<int> stub_bits;
66 for (
int i = 0; i <
GetSize(sig); i++)
67 if (sig[i].wire !=
NULL && (bit_usage_count[sig[i]] + usage_offset) < 2)
71 if (stub_bits.size() == 0)
82 for (
int bit : stub_bits)
83 log(
"%s%d", bit == *stub_bits.begin() ?
"" :
", ", bit);
93 log(
" found %d stub wires or wires with stub bits.\n", line_count);
95 log(
" found %d stub wires.\n", line_count);
104 bool report_bits = 0;
106 log_header(
"Executing STUBNETS pass (find stub nets).\n");
110 for (argidx = 1; argidx < args.size(); argidx++) {
111 std::string arg = args[argidx];
112 if (arg ==
"-report_bits") {
bool selected(T1 *module) const
bool selected_module(RTLIL::IdString mod_name) const
virtual void execute(std::vector< std::string > args, RTLIL::Design *design)
void log_header(const char *format,...)
std::map< RTLIL::IdString, RTLIL::Wire * > wires_
StubnetsPass StubnetsPass
#define PRIVATE_NAMESPACE_BEGIN
int GetSize(RTLIL::Wire *wire)
#define PRIVATE_NAMESPACE_END
static const char * id2cstr(const RTLIL::IdString &str)
#define USING_YOSYS_NAMESPACE
std::map< RTLIL::IdString, RTLIL::Module * > modules_
USING_YOSYS_NAMESPACE static PRIVATE_NAMESPACE_BEGIN void find_stub_nets(RTLIL::Design *design, RTLIL::Module *module, bool report_bits)
std::map< RTLIL::IdString, RTLIL::Cell * > cells_
void log(const char *format,...)
void extra_args(std::vector< std::string > args, size_t argidx, RTLIL::Design *design, bool select=true)