35 for (
auto &it : module->
cells_)
36 for (
auto &port : it.second->connections_)
38 sigmap(port.second).replace(sig, dummy_wire, &port.second);
41 sigmap(conn.first).replace(sig, dummy_wire, &conn.first);
50 log(
" connect [-nomap] [-nounset] -set <lhs-expr> <rhs-expr>\n");
52 log(
"Create a connection. This is equivialent to adding the statement 'assign\n");
53 log(
"<lhs-expr> = <rhs-expr>;' to the verilog input. Per default, all existing\n");
54 log(
"drivers for <lhs-expr> are unconnected. This can be overwritten by using\n");
55 log(
"the -nounset option.\n");
58 log(
" connect [-nomap] -unset <expr>\n");
60 log(
"Unconnect all existing drivers for the specified expression.\n");
63 log(
" connect [-nomap] -port <cell> <port> <expr>\n");
65 log(
"Connect the specified cell port to the specified cell port.\n");
68 log(
"Per default signal alias names are resolved and all signal names are mapped\n");
69 log(
"the the signal name of the primary driver. Using the -nomap option deactivates\n");
70 log(
"this behavior.\n");
72 log(
"The connect command operates in one module only. Either only one module must\n");
73 log(
"be selected or an active module must be set using the 'cd' command.\n");
75 log(
"This command does not operate on module with processes.\n");
93 bool flag_nounset =
false, flag_nomap =
false;
94 std::string set_lhs, set_rhs, unset_expr;
95 std::string port_cell, port_port, port_expr;
98 for (argidx = 1; argidx < args.size(); argidx++)
100 std::string arg = args[argidx];
101 if (arg ==
"-nounset") {
105 if (arg ==
"-nomap") {
109 if (arg ==
"-set" && argidx+2 < args.size()) {
110 set_lhs = args[++argidx];
111 set_rhs = args[++argidx];
114 if (arg ==
"-unset" && argidx+1 < args.size()) {
115 unset_expr = args[++argidx];
118 if (arg ==
"-port" && argidx+3 < args.size()) {
119 port_cell = args[++argidx];
120 port_port = args[++argidx];
121 port_expr = args[++argidx];
130 std::vector<RTLIL::SigBit> lhs = it.first.to_sigbit_vector();
131 std::vector<RTLIL::SigBit> rhs = it.first.to_sigbit_vector();
132 for (
size_t i = 0; i < lhs.size(); i++)
133 if (rhs[i].wire !=
NULL)
134 sigmap.
add(lhs[i], rhs[i]);
137 if (!set_lhs.empty())
139 if (!unset_expr.empty() || !port_cell.empty())
140 log_cmd_error(
"Cant use -set together with -unset and/or -port.\n");
144 log_cmd_error(
"Failed to parse set lhs expression `%s'.\n", set_lhs.c_str());
146 log_cmd_error(
"Failed to parse set rhs expression `%s'.\n", set_rhs.c_str());
148 sigmap.
apply(sig_lhs);
149 sigmap.
apply(sig_rhs);
157 if (!unset_expr.empty())
159 if (!port_cell.empty() || flag_nounset)
160 log_cmd_error(
"Cant use -unset together with -port and/or -nounset.\n");
164 log_cmd_error(
"Failed to parse unset expression `%s'.\n", unset_expr.c_str());
170 if (!port_cell.empty())
180 log_cmd_error(
"Failed to parse port expression `%s'.\n", port_expr.c_str());
bool selected(T1 *module) const
static bool parse_sel(RTLIL::SigSpec &sig, RTLIL::Design *design, RTLIL::Module *module, std::string str)
const std::vector< RTLIL::SigSig > & connections() const
USING_YOSYS_NAMESPACE static PRIVATE_NAMESPACE_BEGIN void unset_drivers(RTLIL::Design *design, RTLIL::Module *module, SigMap &sigmap, RTLIL::SigSpec &sig)
virtual void execute(std::vector< std::string > args, RTLIL::Design *design)
std::vector< RTLIL::SigSig > connections_
void apply(RTLIL::SigBit &bit) const
static std::string escape_id(std::string str)
void connect(const RTLIL::SigSig &conn)
#define PRIVATE_NAMESPACE_BEGIN
bool cell_output(RTLIL::IdString type, RTLIL::IdString port)
RTLIL::Wire * addWire(RTLIL::IdString name, int width=1)
#define PRIVATE_NAMESPACE_END
static const char * id2cstr(const RTLIL::IdString &str)
void log_cmd_error(const char *format,...)
std::map< RTLIL::IdString, RTLIL::Process * > processes
#define USING_YOSYS_NAMESPACE
std::map< RTLIL::IdString, RTLIL::Module * > modules_
std::map< RTLIL::IdString, RTLIL::Cell * > cells_
void log(const char *format,...)
static bool parse_rhs(const RTLIL::SigSpec &lhs, RTLIL::SigSpec &sig, RTLIL::Module *module, std::string str)
void add(RTLIL::SigSpec from, RTLIL::SigSpec to)
std::pair< SigSpec, SigSpec > SigSig