setup_type("$memrd", {CLK, ADDR}, {DATA});
                setup_type("$memwr", {CLK, EN, ADDR, DATA}, pool<RTLIL::IdString>());
+               setup_type("$meminit", {ADDR, DATA}, pool<RTLIL::IdString>());
                setup_type("$mem", {RD_CLK, RD_ADDR, WR_CLK, WR_EN, WR_ADDR, WR_DATA}, {RD_DATA});
 
                setup_type("$fsm", {CLK, ARST, CTRL_IN}, {CTRL_OUT});
 
                                return;
                        }
 
+                       if (cell->type == "$meminit") {
+                               param("\\MEMID");
+                               param("\\PRIORITY");
+                               port("\\ADDR", param("\\ABITS"));
+                               port("\\DATA", param("\\WIDTH"));
+                               check_expected();
+                               return;
+                       }
+
                        if (cell->type == "$mem") {
                                param("\\MEMID");
                                param("\\SIZE");
 
                                        if (bit.wire != nullptr)
                                                wire2driver[bit].insert(cell);
                }
-               if (cell->type == "$memwr" || cell->type == "$assert" || cell->has_keep_attr())
+               if (cell->type.in("$memwr", "$meminit", "$assert") || cell->has_keep_attr())
                        queue.insert(cell);
                else
                        unused.insert(cell);
 
 
 // --------------------------------------------------------
 
+module \$meminit (ADDR, DATA);
+
+parameter MEMID = "";
+parameter ABITS = 8;
+parameter WIDTH = 8;
+
+parameter PRIORITY = 0;
+
+input [ABITS-1:0] ADDR;
+input [WIDTH-1:0] DATA;
+
+initial begin
+       if (MEMID != "") begin
+               $display("ERROR: Found non-simulatable instance of $meminit!");
+               $finish;
+       end
+end
+
+endmodule
+
+// --------------------------------------------------------
+
 module \$mem (RD_CLK, RD_ADDR, RD_DATA, WR_CLK, WR_EN, WR_ADDR, WR_DATA);
 
 parameter MEMID = "";