Fix verific_parameters construction, use attribute to mark top netlists
authorEddie Hung <eddie@fpgeh.com>
Wed, 13 Mar 2019 22:05:55 +0000 (22:05 +0000)
committerClifford Wolf <clifford@clifford.at>
Fri, 3 May 2019 18:53:25 +0000 (20:53 +0200)
frontends/verific/verific.cc
frontends/verific/verific.h

index 58a29ada4339d8806d42a991903772946125d3f6..a05fd29b5e4bb32b4d19aa4331fbf112f7fcc6d0 100644 (file)
@@ -775,9 +775,9 @@ void VerificImporter::merge_past_ffs(pool<RTLIL::Cell*> &candidates)
                merge_past_ffs_clock(it.second, it.first.first, it.first.second);
 }
 
-void VerificImporter::import_netlist(RTLIL::Design *design, Netlist *nl, std::set<Netlist*> &nl_todo, bool top)
+void VerificImporter::import_netlist(RTLIL::Design *design, Netlist *nl, std::set<Netlist*> &nl_todo)
 {
-       std::string netlist_name = top ? nl->CellBaseName() : nl->Owner()->Name();
+       std::string netlist_name = nl->GetAtt(" \\top") ? nl->CellBaseName() : nl->Owner()->Name();
        std::string module_name = nl->IsOperator() ? "$verific$" + netlist_name : RTLIL::escape_id(netlist_name);
 
        netlist = nl;
@@ -1768,7 +1768,7 @@ void verific_import(Design *design, const std::map<std::string,std::string> &par
        if (veri_lib) veri_libs.InsertLast(veri_lib);
 
        Map verific_params(STRING_HASH);
-       for (auto i : parameters)
+       for (const auto &i : parameters)
                verific_params.Insert(i.first.c_str(), i.second.c_str());
 
        if (top.empty()) {
@@ -1800,8 +1800,10 @@ void verific_import(Design *design, const std::map<std::string,std::string> &par
        int i;
 
        FOREACH_ARRAY_ITEM(netlists, i, nl) {
-               if (top.empty() || nl->CellBaseName() == top)
-                       nl_todo.insert(nl);
+               if (top.empty() && nl->CellBaseName() != top)
+                       continue;
+               nl->AddAtt(new Att(" \\top", NULL));
+               nl_todo.insert(nl);
        }
 
        delete netlists;
@@ -1817,7 +1819,7 @@ void verific_import(Design *design, const std::map<std::string,std::string> &par
                Netlist *nl = *nl_todo.begin();
                if (nl_done.count(nl) == 0) {
                        VerificImporter importer(false, false, false, false, false, false);
-                       importer.import_netlist(design, nl, nl_todo, nl->CellBaseName() == top);
+                       importer.import_netlist(design, nl, nl_todo);
                }
                nl_todo.erase(nl);
                nl_done.insert(nl);
@@ -2322,8 +2324,10 @@ struct VerificPass : public Pass {
                                Netlist *nl;
                                int i;
 
-                               FOREACH_ARRAY_ITEM(netlists, i, nl)
+                               FOREACH_ARRAY_ITEM(netlists, i, nl) {
+                                       nl->AddAtt(new Att(" \\top", NULL));
                                        nl_todo.insert(nl);
+                               }
                                delete netlists;
                        }
 
index fb44b17367f697a3765d30dd141f8fcca6dbc352..88a6cc0ba1752fd1fa661fc18eccd2298c9766f2 100644 (file)
@@ -93,7 +93,7 @@ struct VerificImporter
        void merge_past_ffs_clock(pool<RTLIL::Cell*> &candidates, SigBit clock, bool clock_pol);
        void merge_past_ffs(pool<RTLIL::Cell*> &candidates);
 
-       void import_netlist(RTLIL::Design *design, Verific::Netlist *nl, std::set<Verific::Netlist*> &nl_todo, bool top=false);
+       void import_netlist(RTLIL::Design *design, Verific::Netlist *nl, std::set<Verific::Netlist*> &nl_todo);
 };
 
 void verific_import_sva_assert(VerificImporter *importer, Verific::Instance *inst);