mirror of https://github.com/YosysHQ/yosys.git
Merge pull request #1755 from boqwxp/add_cmd_cleanup
Clean up `passes/cmds/add.cc` code style.
This commit is contained in:
commit
f91705cf8a
|
@ -24,24 +24,23 @@ PRIVATE_NAMESPACE_BEGIN
|
||||||
|
|
||||||
static void add_wire(RTLIL::Design *design, RTLIL::Module *module, std::string name, int width, bool flag_input, bool flag_output, bool flag_global)
|
static void add_wire(RTLIL::Design *design, RTLIL::Module *module, std::string name, int width, bool flag_input, bool flag_output, bool flag_global)
|
||||||
{
|
{
|
||||||
RTLIL::Wire *wire = NULL;
|
RTLIL::Wire *wire = nullptr;
|
||||||
name = RTLIL::escape_id(name);
|
name = RTLIL::escape_id(name);
|
||||||
|
|
||||||
if (module->count_id(name) != 0)
|
if (module->count_id(name) != 0)
|
||||||
{
|
{
|
||||||
if (module->wires_.count(name) > 0)
|
wire = module->wire(name);
|
||||||
wire = module->wires_.at(name);
|
|
||||||
|
|
||||||
if (wire != NULL && wire->width != width)
|
if (wire != nullptr && wire->width != width)
|
||||||
wire = NULL;
|
wire = nullptr;
|
||||||
|
|
||||||
if (wire != NULL && wire->port_input != flag_input)
|
if (wire != nullptr && wire->port_input != flag_input)
|
||||||
wire = NULL;
|
wire = nullptr;
|
||||||
|
|
||||||
if (wire != NULL && wire->port_output != flag_output)
|
if (wire != nullptr && wire->port_output != flag_output)
|
||||||
wire = NULL;
|
wire = nullptr;
|
||||||
|
|
||||||
if (wire == NULL)
|
if (wire == nullptr)
|
||||||
log_cmd_error("Found incompatible object with same name in module %s!\n", module->name.c_str());
|
log_cmd_error("Found incompatible object with same name in module %s!\n", module->name.c_str());
|
||||||
|
|
||||||
log("Module %s already has such an object.\n", module->name.c_str());
|
log("Module %s already has such an object.\n", module->name.c_str());
|
||||||
|
@ -53,7 +52,6 @@ static void add_wire(RTLIL::Design *design, RTLIL::Module *module, std::string n
|
||||||
wire->port_output = flag_output;
|
wire->port_output = flag_output;
|
||||||
|
|
||||||
if (flag_input || flag_output) {
|
if (flag_input || flag_output) {
|
||||||
wire->port_id = module->wires_.size();
|
|
||||||
module->fixup_ports();
|
module->fixup_ports();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,21 +61,20 @@ static void add_wire(RTLIL::Design *design, RTLIL::Module *module, std::string n
|
||||||
if (!flag_global)
|
if (!flag_global)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (auto &it : module->cells_)
|
for (auto cell : module->cells())
|
||||||
{
|
{
|
||||||
if (design->modules_.count(it.second->type) == 0)
|
RTLIL::Module *mod = design->module(cell->type);
|
||||||
|
if (mod == nullptr)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
RTLIL::Module *mod = design->modules_.at(it.second->type);
|
|
||||||
if (!design->selected_whole_module(mod->name))
|
if (!design->selected_whole_module(mod->name))
|
||||||
continue;
|
continue;
|
||||||
if (mod->get_blackbox_attribute())
|
if (mod->get_blackbox_attribute())
|
||||||
continue;
|
continue;
|
||||||
if (it.second->hasPort(name))
|
if (cell->hasPort(name))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
it.second->setPort(name, wire);
|
cell->setPort(name, wire);
|
||||||
log("Added connection %s to cell %s.%s (%s).\n", name.c_str(), module->name.c_str(), it.first.c_str(), it.second->type.c_str());
|
log("Added connection %s to cell %s.%s (%s).\n", name.c_str(), module->name.c_str(), cell->name.c_str(), cell->type.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,9 +152,9 @@ struct AddPass : public Pass {
|
||||||
|
|
||||||
extra_args(args, argidx, design);
|
extra_args(args, argidx, design);
|
||||||
|
|
||||||
for (auto &mod : design->modules_)
|
for (auto module : design->modules())
|
||||||
{
|
{
|
||||||
RTLIL::Module *module = mod.second;
|
log_assert(module != nullptr);
|
||||||
if (!design->selected_whole_module(module->name))
|
if (!design->selected_whole_module(module->name))
|
||||||
continue;
|
continue;
|
||||||
if (module->get_bool_attribute("\\blackbox"))
|
if (module->get_bool_attribute("\\blackbox"))
|
||||||
|
|
Loading…
Reference in New Issue