aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorZipCPU <dgisselq@ieee.org>2018-06-06 12:20:24 -0400
committerZipCPU <dgisselq@ieee.org>2018-06-06 12:20:24 -0400
commit468ed85280f5a518c4a7b9c9770d2aa0764b3972 (patch)
tree58ae1aa9a6b0af029be08b6f5419ca8b026d9ee3 /common
parentd0ee08aeb12a8fb7237b31083666d9b165f13f69 (diff)
downloadnextpnr-468ed85280f5a518c4a7b9c9770d2aa0764b3972.tar.gz
nextpnr-468ed85280f5a518c4a7b9c9770d2aa0764b3972.tar.bz2
nextpnr-468ed85280f5a518c4a7b9c9770d2aa0764b3972.zip
Applied Rule Check to parser results, refactored JSON parser
Diffstat (limited to 'common')
-rw-r--r--common/rulecheck.cc61
1 files changed, 61 insertions, 0 deletions
diff --git a/common/rulecheck.cc b/common/rulecheck.cc
new file mode 100644
index 00000000..4b355368
--- /dev/null
+++ b/common/rulecheck.cc
@@ -0,0 +1,61 @@
+#include <string>
+#include <assert.h>
+#include "common/design.h"
+#include "log.h"
+
+bool check_all_nets_driven(Design *design) {
+ const bool debug = false;
+ log_info("Verifying all cells\n");
+
+ for(auto cell_entry : design->cells) {
+ CellInfo *cell = cell_entry.second;
+
+ if (debug) log_info(" Examining cell \'%s\', of type \'%s\'\n",
+ cell->name.c_str(),
+ cell->type.c_str());
+ for(auto port_entry : cell->ports) {
+ PortInfo &port = port_entry.second;
+
+ if (debug) log_info(" Checking name of port \'%s\' "
+ "against \'%s\'\n",
+ port_entry.first.c_str(),
+ port.name.c_str());
+ assert(port.name.compare(port_entry.first)==0);
+ assert(port.net);
+ assert(port.name.size() > 0);
+ if (debug) log_info(" Checking for a net named \'%s\'\n",
+ port.net->name.c_str());
+ assert(design->nets.count(port.net->name)>0);
+ // assert(design->nets[port.net->name]->driver.cell);
+ }
+ }
+
+ for(auto net_entry : design->nets) {
+ NetInfo *net = net_entry.second;
+
+ assert(net->name.compare(net_entry.first) == 0);
+ if ((net->driver.cell != NULL)
+ &&(net->driver.cell->type.compare("GND") != 0)
+ &&(net->driver.cell->type.compare("VCC") != 0)) {
+
+ if (debug) log_info(" Checking for a driver cell named \'%s\'\n",
+ net->driver.cell->name.c_str());
+ assert(design->cells.count(net->driver.cell->name) >0);
+ }
+
+ for(auto user : net->users) {
+ if ((user.cell != NULL)
+ &&(user.cell->type.compare("GND") != 0)
+ &&(user.cell->type.compare("VCC") != 0)) {
+
+ if (debug) log_info(" Checking for a user cell named \'%s\'\n",
+ user.cell->name.c_str());
+ assert(design->cells.count(user.cell->name) >0);
+ }
+
+ }
+ }
+
+ if (debug) log_info(" Verified!\n");
+}
+