2018-06-07 00:20:24 +08:00
|
|
|
#include <assert.h>
|
2018-06-08 03:38:24 +08:00
|
|
|
#include <string>
|
2018-06-07 00:20:24 +08:00
|
|
|
#include "log.h"
|
2018-06-12 02:12:57 +08:00
|
|
|
#include "nextpnr.h"
|
2018-06-07 00:20:24 +08:00
|
|
|
|
2018-06-12 20:24:59 +08:00
|
|
|
NEXTPNR_NAMESPACE_BEGIN
|
|
|
|
|
2018-06-18 20:06:37 +08:00
|
|
|
bool check_all_nets_driven(Context *ctx)
|
2018-06-08 03:38:24 +08:00
|
|
|
{
|
|
|
|
const bool debug = false;
|
2018-06-08 00:04:01 +08:00
|
|
|
|
2018-11-30 03:28:15 +08:00
|
|
|
log_info("Rule checker, verifying imported design\n");
|
2018-06-07 00:20:24 +08:00
|
|
|
|
2018-06-26 20:13:52 +08:00
|
|
|
for (auto &cell_entry : ctx->cells) {
|
2018-06-26 03:33:48 +08:00
|
|
|
CellInfo *cell = cell_entry.second.get();
|
2018-06-07 00:20:24 +08:00
|
|
|
|
2018-06-08 03:38:24 +08:00
|
|
|
if (debug)
|
2018-06-25 17:43:59 +08:00
|
|
|
log_info(" Examining cell \'%s\', of type \'%s\'\n", cell->name.c_str(ctx), cell->type.c_str(ctx));
|
2018-06-08 03:38:24 +08:00
|
|
|
for (auto port_entry : cell->ports) {
|
|
|
|
PortInfo &port = port_entry.second;
|
2018-06-07 00:20:24 +08:00
|
|
|
|
2018-06-08 03:38:24 +08:00
|
|
|
if (debug)
|
|
|
|
log_info(" Checking name of port \'%s\' "
|
|
|
|
"against \'%s\'\n",
|
2018-06-18 23:08:35 +08:00
|
|
|
port_entry.first.c_str(ctx), port.name.c_str(ctx));
|
2018-07-04 18:15:23 +08:00
|
|
|
NPNR_ASSERT(port.name == port_entry.first);
|
|
|
|
NPNR_ASSERT(!port.name.empty());
|
2018-06-07 21:38:14 +08:00
|
|
|
|
2018-06-08 03:38:24 +08:00
|
|
|
if (port.net == NULL) {
|
|
|
|
if (debug)
|
2018-06-25 17:43:59 +08:00
|
|
|
log_warning(" Port \'%s\' in cell \'%s\' is unconnected\n", port.name.c_str(ctx),
|
|
|
|
cell->name.c_str(ctx));
|
2018-06-08 03:38:24 +08:00
|
|
|
} else {
|
2018-07-04 18:15:23 +08:00
|
|
|
NPNR_ASSERT(port.net);
|
2018-06-08 03:38:24 +08:00
|
|
|
if (debug)
|
2018-06-25 17:43:59 +08:00
|
|
|
log_info(" Checking for a net named \'%s\'\n", port.net->name.c_str(ctx));
|
2018-07-04 18:15:23 +08:00
|
|
|
NPNR_ASSERT(ctx->nets.count(port.net->name) > 0);
|
2018-06-08 03:38:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-06-07 00:20:24 +08:00
|
|
|
|
2018-06-26 20:13:52 +08:00
|
|
|
for (auto &net_entry : ctx->nets) {
|
2018-06-26 03:33:48 +08:00
|
|
|
NetInfo *net = net_entry.second.get();
|
2018-06-07 00:20:24 +08:00
|
|
|
|
2018-07-04 18:15:23 +08:00
|
|
|
NPNR_ASSERT(net->name == net_entry.first);
|
2018-06-25 17:43:59 +08:00
|
|
|
if ((net->driver.cell != NULL) && (net->driver.cell->type != ctx->id("GND")) &&
|
2018-06-18 23:08:35 +08:00
|
|
|
(net->driver.cell->type != ctx->id("VCC"))) {
|
2018-06-07 00:20:24 +08:00
|
|
|
|
2018-06-08 03:38:24 +08:00
|
|
|
if (debug)
|
2018-06-25 17:43:59 +08:00
|
|
|
log_info(" Checking for a driver cell named \'%s\'\n", net->driver.cell->name.c_str(ctx));
|
2018-07-04 18:15:23 +08:00
|
|
|
NPNR_ASSERT(ctx->cells.count(net->driver.cell->name) > 0);
|
2018-06-08 03:38:24 +08:00
|
|
|
}
|
2018-06-07 00:20:24 +08:00
|
|
|
|
2018-06-08 03:38:24 +08:00
|
|
|
for (auto user : net->users) {
|
2018-06-25 17:43:59 +08:00
|
|
|
if ((user.cell != NULL) && (user.cell->type != ctx->id("GND")) && (user.cell->type != ctx->id("VCC"))) {
|
2018-06-07 00:20:24 +08:00
|
|
|
|
2018-06-08 03:38:24 +08:00
|
|
|
if (debug)
|
2018-06-25 17:43:59 +08:00
|
|
|
log_info(" Checking for a user cell named \'%s\'\n", user.cell->name.c_str(ctx));
|
2018-07-04 18:15:23 +08:00
|
|
|
NPNR_ASSERT(ctx->cells.count(user.cell->name) > 0);
|
2018-06-08 03:38:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-06-07 00:20:24 +08:00
|
|
|
|
2018-06-08 03:38:24 +08:00
|
|
|
if (debug)
|
|
|
|
log_info(" Verified!\n");
|
|
|
|
return true;
|
2018-06-07 00:20:24 +08:00
|
|
|
}
|
2018-06-12 20:24:59 +08:00
|
|
|
|
|
|
|
NEXTPNR_NAMESPACE_END
|