Add a check for packed memory MEMID uniqueness
authorMarcelina Kościelnicka <mwk@0x04.net>
Mon, 13 Jun 2022 14:53:29 +0000 (16:53 +0200)
committerMarcelina Kościelnicka <mwk@0x04.net>
Mon, 13 Jun 2022 17:23:55 +0000 (19:23 +0200)
kernel/rtlil.cc

index 8346b56e05a95e3a9820d6643c7d8f86de187631..dc4ea9a78ba786130042fd11db47b2daaff8eedb 100644 (file)
@@ -1842,6 +1842,8 @@ void RTLIL::Module::check()
                        log_assert(!it2.first.empty());
        }
 
+       pool<IdString> packed_memids;
+
        for (auto &it : cells_) {
                log_assert(this == it.second->module);
                log_assert(it.first == it.second->name);
@@ -1857,6 +1859,14 @@ void RTLIL::Module::check()
                        log_assert(!it2.first.empty());
                InternalCellChecker checker(this, it.second);
                checker.check();
+               if (it.second->has_memid()) {
+                       log_assert(memories.count(it.second->parameters.at(ID::MEMID).decode_string()));
+               } else if (it.second->is_mem_cell()) {
+                       IdString memid = it.second->parameters.at(ID::MEMID).decode_string();
+                       log_assert(!memories.count(memid));
+                       log_assert(!packed_memids.count(memid));
+                       packed_memids.insert(memid);
+               }
        }
 
        for (auto &it : processes) {