log("Unconnect all existing drivers for the specified expression.\n");
log("\n");
log("\n");
- log(" connect [-nomap] -port <cell> <port> <expr>\n");
+ log(" connect [-nomap] [-assert] -port <cell> <port> <expr>\n");
log("\n");
log("Connect the specified cell port to the specified cell port.\n");
log("\n");
log("The connect command operates in one module only. Either only one module must\n");
log("be selected or an active module must be set using the 'cd' command.\n");
log("\n");
+ log("The -assert option verifies that the connection already exists, instead of\n");
+ log("making it.\n");
+ log("\n");
log("This command does not operate on module with processes.\n");
log("\n");
}
if (!module->processes.empty())
log_cmd_error("Found processes in selected module.\n");
- bool flag_nounset = false, flag_nomap = false;
+ bool flag_nounset = false, flag_nomap = false, flag_assert = false;
std::string set_lhs, set_rhs, unset_expr;
std::string port_cell, port_port, port_expr;
flag_nomap = true;
continue;
}
+ if (arg == "-assert") {
+ flag_assert = true;
+ continue;
+ }
if (arg == "-set" && argidx+2 < args.size()) {
set_lhs = args[++argidx];
set_rhs = args[++argidx];
if (!flag_nomap)
for (auto &it : module->connections()) {
std::vector<RTLIL::SigBit> lhs = it.first.to_sigbit_vector();
- std::vector<RTLIL::SigBit> rhs = it.first.to_sigbit_vector();
+ std::vector<RTLIL::SigBit> rhs = it.second.to_sigbit_vector();
for (size_t i = 0; i < lhs.size(); i++)
if (rhs[i].wire != nullptr)
sigmap.add(lhs[i], rhs[i]);
if (!unset_expr.empty() || !port_cell.empty())
log_cmd_error("Can't use -set together with -unset and/or -port.\n");
+ if (flag_assert)
+ log_cmd_error("The -assert option is only supported with -port.\n");
+
RTLIL::SigSpec sig_lhs, sig_rhs;
if (!RTLIL::SigSpec::parse_sel(sig_lhs, design, module, set_lhs))
log_cmd_error("Failed to parse set lhs expression `%s'.\n", set_lhs.c_str());
if (!port_cell.empty() || flag_nounset)
log_cmd_error("Can't use -unset together with -port and/or -nounset.\n");
+ if (flag_assert)
+ log_cmd_error("The -assert option is only supported with -port.\n");
+
RTLIL::SigSpec sig;
if (!RTLIL::SigSpec::parse_sel(sig, design, module, unset_expr))
log_cmd_error("Failed to parse unset expression `%s'.\n", unset_expr.c_str());
if (!RTLIL::SigSpec::parse_sel(sig, design, module, port_expr))
log_cmd_error("Failed to parse port expression `%s'.\n", port_expr.c_str());
- module->cell(RTLIL::escape_id(port_cell))->setPort(RTLIL::escape_id(port_port), sigmap(sig));
+ if (!flag_assert) {
+ module->cell(RTLIL::escape_id(port_cell))->setPort(RTLIL::escape_id(port_port), sigmap(sig));
+ } else {
+ SigSpec cur = module->cell(RTLIL::escape_id(port_cell))->getPort(RTLIL::escape_id(port_port));
+ if (sigmap(sig) != sigmap(cur)) {
+ log_cmd_error("Expected connection not present: expected %s, found %s.\n", log_signal(sig), log_signal(cur));
+ }
+ }
}
else
log_cmd_error("Expected -set, -unset, or -port.\n");