32 if (module->
wires_.count(name) > 0)
33 wire = module->
wires_.at(name);
47 log(
"Module %s already has such an object.\n", module->
name.
c_str());
51 wire = module->
addWire(name, width);
55 if (flag_input || flag_output) {
60 log(
"Added wire %s to module %s.\n", name.c_str(), module->
name.
c_str());
66 for (
auto &it : module->
cells_)
68 if (design->
modules_.count(it.second->type) == 0)
74 if (mod->get_bool_attribute(
"\\blackbox"))
76 if (it.second->hasPort(name))
79 it.second->setPort(name, wire);
80 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());
90 log(
" add <command> [selection]\n");
92 log(
"This command adds objects to the design. It operates on all fully selected\n");
93 log(
"modules. So e.g. 'add -wire foo' will add a wire foo to all selected modules.\n");
96 log(
" add {-wire|-input|-inout|-output} <name> <width> [selection]\n");
98 log(
"Add a wire (input, inout, output port) with the given name and width. The\n");
99 log(
"command will fail if the object exists already and has different properties\n");
100 log(
"than the object to be created.\n");
103 log(
" add -global_input <name> <width> [selection]\n");
105 log(
"Like 'add -input', but also connect the signal between instances of the\n");
106 log(
"selected modules.\n");
112 std::string arg_name;
113 bool arg_flag_input =
false;
114 bool arg_flag_output =
false;
115 bool arg_flag_global =
false;
119 for (argidx = 1; argidx < args.size(); argidx++)
121 std::string arg = args[argidx];
122 if (arg ==
"-wire" || arg ==
"-input" || arg ==
"-inout" || arg ==
"-output" || arg ==
"-global_input") {
123 if (argidx+2 >= args.size())
126 if (arg ==
"-input" || arg ==
"-inout" || arg ==
"-global_input")
127 arg_flag_input =
true;
128 if (arg ==
"-output" || arg ==
"-inout")
129 arg_flag_output =
true;
130 if (arg ==
"-global_input")
131 arg_flag_global =
true;
132 arg_name = args[++argidx];
133 arg_width = atoi(args[++argidx].c_str());
145 if (module->get_bool_attribute(
"\\blackbox"))
148 if (command ==
"wire")
149 add_wire(design, module, arg_name, arg_width, arg_flag_input, arg_flag_output, arg_flag_global);
const char * c_str() const
std::map< RTLIL::IdString, RTLIL::Wire * > wires_
USING_YOSYS_NAMESPACE static PRIVATE_NAMESPACE_BEGIN void add_wire(RTLIL::Design *design, RTLIL::Module *module, std::string name, int width, bool flag_input, bool flag_output, bool flag_global)
static std::string escape_id(std::string str)
virtual void execute(std::vector< std::string > args, RTLIL::Design *design)
#define PRIVATE_NAMESPACE_BEGIN
RTLIL::Wire * addWire(RTLIL::IdString name, int width=1)
bool selected_whole_module(RTLIL::IdString mod_name) const
#define PRIVATE_NAMESPACE_END
void log_cmd_error(const char *format,...)
#define USING_YOSYS_NAMESPACE
virtual size_t count_id(RTLIL::IdString id)
std::map< RTLIL::IdString, RTLIL::Module * > modules_
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)