wishbone: optimise SRAM addr_width
authorHarry Ho <hh@m-labs.hk>
Wed, 8 Jan 2020 06:39:43 +0000 (14:39 +0800)
committerHarry Ho <hh@m-labs.hk>
Wed, 29 Jan 2020 07:13:18 +0000 (15:13 +0800)
nmigen_soc/wishbone/sram.py

index 3ee165ec4bad7a4603d48985773c8a7a6c5e2641..b72687dd544a80f7b4dcb5149ed930b5b000a7e4 100644 (file)
@@ -25,7 +25,7 @@ class SRAM(Elaboratable):
         if not read_only:
             self._memdepth += self.memory.depth
         if bus is None:
-            bus = Interface(addr_width=bits_for(self._memdepth),
+            bus = Interface(addr_width=max(0, log2_int(self._memdepth, need_pow2=False)),
                             data_width=self.memory.width,
                             granularity=granularity,
                             features=features,