From 6683c3a916257d629ba91cd0b2568d829edb5cc6 Mon Sep 17 00:00:00 2001 From: Catherine Date: Tue, 5 Sep 2023 06:39:17 +0000 Subject: [PATCH] hdl.mem: fix `INIT` parameter of emitted `$mem_v2` cell. Unspecified memory slots are initialized to zero, not uninitialized. --- amaranth/hdl/mem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amaranth/hdl/mem.py b/amaranth/hdl/mem.py index 3eada33..dd402ed 100644 --- a/amaranth/hdl/mem.py +++ b/amaranth/hdl/mem.py @@ -120,7 +120,7 @@ class Memory(Elaboratable): def elaborate(self, platform): init = "".join(format(Const(elem, unsigned(self.width)).value, f"0{self.width}b") for elem in reversed(self.init)) - init = Const(int(init or "0", 2), len(self.init) * self.width) + init = Const(int(init or "0", 2), self.depth * self.width) rd_clk = [] rd_clk_enable = 0 rd_transparency_mask = 0