Cope with inout ports
authorEddie Hung <eddie@fpgeh.com>
Wed, 17 Apr 2019 21:43:45 +0000 (14:43 -0700)
committerEddie Hung <eddie@fpgeh.com>
Wed, 17 Apr 2019 21:43:45 +0000 (14:43 -0700)
backends/aiger/xaiger.cc

index 070d6d4035747cb8154a206dceb6065f9df7936f..14fa4fb7fe7c2e59e452ac47da85051614516937 100644 (file)
@@ -197,9 +197,12 @@ struct XAigerWriter
                                                continue;
                                }
 
-                               if (cell->input(conn.first))
+                               if (cell->input(conn.first)) {
+                                       // Ignore inout for the sake of topographical ordering
+                                       if (cell->output(conn.first)) continue;
                                        for (auto bit : sigmap(conn.second))
                                                bit_users[bit].insert(cell->name);
+                               }
 
                                if (cell->output(conn.first))
                                        for (auto bit : sigmap(conn.second))
@@ -287,7 +290,18 @@ struct XAigerWriter
                                        for (auto user_cell : it.second)
                                                toposort.edge(driver_cell, user_cell);
 
+#ifndef NDEBUG
+                       toposort.analyze_loops = true;
+#endif
                        toposort.sort();
+#ifndef NDEBUG
+                       for (auto &it : toposort.loops) {
+                               log("  loop");
+                               for (auto cell : it)
+                                       log(" %s", log_id(cell));
+                               log("\n");
+                       }
+#endif
                        log_assert(!toposort.found_loops);
 
                        for (auto cell_name : toposort.sorted) {