add assertion checking bus write against memory write port granularity
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 20 Jun 2020 12:25:57 +0000 (13:25 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 20 Jun 2020 12:25:57 +0000 (13:25 +0100)
nmigen_soc/wishbone/sram.py

index 630b53c..c518ff9 100644 (file)
@@ -86,7 +86,11 @@ class SRAM(Elaboratable):
                 wrport.addr.eq(self.bus.adr[:len(rdport.addr)]),
                 wrport.data.eq(self.bus.dat_w)
             ]
-            for i in range(4):
+            n_wrport = wrport.en.shape()[0]
+            n_bussel = self.bus.sel.shape()[0]
+            assert n_wrport == n_bussel, "bus enable count %d " \
+                    "must match memory wen count %d" % (n_wrport, n_bussel)
+            for i in range(n_wrport):
                 m.d.comb += wrport.en[i].eq(self.bus.cyc & self.bus.stb &
                                             self.bus.we & self.bus.sel[i])