Prepare for situation when port of the signal cannot be found
authorBogdan Vukobratovic <bogdan.vukobratovic@gmail.com>
Fri, 14 Jun 2019 09:39:24 +0000 (11:39 +0200)
committerBogdan Vukobratovic <bogdan.vukobratovic@gmail.com>
Fri, 14 Jun 2019 09:39:24 +0000 (11:39 +0200)
kernel/algo.h
passes/opt/opt_rmdff.cc

index 9626c780e58f1170dfa0438ce98e797faae76f99..f029ad6abfaf65a389ff347b75042d2a9ac6e47e 100644 (file)
@@ -58,10 +58,14 @@ struct Netlist {
                return sigbit_driver_map.at(sig);
        }
 
-       RTLIL::SigBit& driver_port(RTLIL::SigBit sig)
+       RTLIL::SigSpec driver_port(RTLIL::SigBit sig)
        {
                RTLIL::Cell *cell = driver_cell(sig);
 
+               if (!cell) {
+                       return RTLIL::SigSpec();
+               }
+
                for (auto &port : cell->connections_) {
                        if (ct.cell_output(cell->type, port.first)) {
                                RTLIL::SigSpec port_sig = sigmap(port.second);
@@ -72,6 +76,8 @@ struct Netlist {
                                }
                        }
                }
+
+               return RTLIL::SigSpec();
        }
 
        void setup_netlist(RTLIL::Module *module, const CellTypes &ct)
index 41bbdcd5735b689fa0c891e09ee6a17020a24bbd..cf89ac096c897522246878a3b75bc7fcac590a2b 100644 (file)
@@ -503,7 +503,7 @@ bool handle_dff(RTLIL::Module *mod, RTLIL::Cell *dff)
                        // If the register bit cannot change, we can replace it with a constant
                        if (!counter_example_found) {
 
-                               RTLIL::SigBit &driver_port = net.driver_port(q_sigbit);
+                               RTLIL::SigSpec driver_port = net.driver_port(q_sigbit);
                                RTLIL::Wire *dummy_wire = mod->addWire(NEW_ID, 1);
 
                                for (auto &conn : mod->connections_)