do config start addresses
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 3 Aug 2018 09:18:39 +0000 (10:18 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 3 Aug 2018 09:18:39 +0000 (10:18 +0100)
src/bsv/peripheral_gen/base.py
src/spec/i_class.py

index 609e821f381be2df32daf952dbe05725e448b719..e6f9a53f84219c9a8513f59dabdea874aa2ce87d 100644 (file)
@@ -20,9 +20,56 @@ def li(txt, indent):
     return res
 
 
-class PBase(object):
+class MMapConfig(object):
+
+    def get_mmap_configs(self):
+        res = []
+        for cfg in self.peripheral.configs:
+            res.append(cfg.get('mmap', None))
+        # XXX HACK!  assume all configs same for each peripheral!
+        return res[0]
+
+    def map_to_idx(self, cfg, idx):
+        if isinstance(idx, int):
+            return idx
+        for (i, c) in enumerate(cfg):
+            if c[0] == idx:
+                return i
+        assert "config name %s not found" % s
+
+    def get_mmap_cfg_start(self, idx):
+        cfg = self.get_mmap_configs()
+        if cfg is None:
+            nregs = self.num_axi_regs32()
+            if isinstance(nregs, int) or len(nregs) == 1:
+                return 0
+            return "_%d_" % idx
+        idx = self.map_to_idx(cfg, idx)
+        return cfg[idx][1]
+
+    def get_mmap_cfg_name(self, idx):
+        cfg = self.get_mmap_configs()
+        if cfg is None:
+            nregs = self.num_axi_regs32()
+            if isinstance(nregs, int) or len(nregs) == 1:
+                return ""
+            return "_%d_" % idx
+        return cfg[idx][0]
+
+    def num_axi_regs32cfg(self):
+        cfg = self.get_mmap_configs()
+        if cfg is None:
+            return self.num_axi_regs32()
+        regs = []
+        for c in cfg:
+            regs.append(c[2])
+        return regs
+
+
+class PBase(MMapConfig):
     def __init__(self, name):
         self.name = name
+        MMapConfig.__init__(self)
 
     def extifdecl(self, name, count):
         sname = self.get_iname(count)
@@ -76,31 +123,6 @@ class PBase(object):
     def slowimport(self):
         return ''
 
-    def get_mmap_configs(self):
-        res = []
-        for cfg in self.peripheral.configs:
-            res.append(cfg.get('mmap', None))
-        # XXX HACK!  assume all configs same for each peripheral!
-        return res[0]
-
-    def get_mmap_cfg_name(self, idx):
-        cfg = self.get_mmap_configs()
-        if cfg is None:
-            nregs = self.num_axi_regs32()
-            if isinstance(nregs, int) or len(nregs) == 1:
-                return ""
-            return "_%d_" % idx
-        return cfg[idx][0]
-
-    def num_axi_regs32cfg(self):
-        cfg = self.get_mmap_configs()
-        if cfg is None:
-            return self.num_axi_regs32()
-        regs = []
-        for c in cfg:
-            regs.append(c[2])
-        return regs
-
     def num_axi_regs32(self):
         return 0
 
@@ -123,7 +145,13 @@ class PBase(object):
         offs = numregs * 4 * 16
         if offs == 0:
             return ('', 0)
-        end = start + offs - 1
+        cfgstart = self.get_mmap_cfg_start(idx)
+        if cfgstart:
+            start = cfgstart
+            end = start + offs - 1
+            offs = 0 # don't do contiguous addressing
+        else:
+            end = start + offs - 1
         bname = self.axibase(name, ifacenum, idx)
         bend = self.axiend(name, ifacenum, idx)
         comment = "%d 32-bit regs" % numregs
index 9f890f3f07a64dec23479992ed9786f84228131a..117d7974b731db85e661601cdd95ced752eaa0c9 100644 (file)
@@ -67,8 +67,8 @@ def pinspec():
                   'jtag': {'bus': 'fastbus'},
                   'fb': {'bus': 'fastbus'},
                   'sdr': {'bus': 'fastbus',
-                          'mmap': [['Mem', 0x50000000, 0x400000],
-                                   ['Cfg', 0x21000, 12]
+                          'mmap': [['Mem', 0x70000000, 0x400000],
+                                   ['Cfg', 0x17000, 12]
                                    ]},
                   })