elaborate function for DataMerger
authorTobias Platen <tplaten@posteo.de>
Wed, 27 May 2020 09:27:06 +0000 (11:27 +0200)
committerTobias Platen <tplaten@posteo.de>
Wed, 27 May 2020 09:27:06 +0000 (11:27 +0200)
src/soc/experiment/l0_cache.py

index de6b4ca3df0b02e16a1fd9f6d90065aa8562b141..e9fdfcd80a32abf72de8e48399f82765ede953ad 100644 (file)
@@ -190,6 +190,23 @@ class DataMerger(Elaboratable):
         self.data_i = Array(ul)
         self.data_o = DataMergerRecord()
 
+        def elaborate(self, platform):
+            m = Module()
+            comb, sync = m.d.comb, m.d.sync
+            #(1) pick a row
+            m.submodules.pick = pick = PriorityEncoder(self.array_size)
+            pick.i.eq(0)
+            for j in range(self.addr):
+                with m.If(self.addr_match_i[j]>0):
+                    pick.i.eq(pick.i||(1<<j))
+            valid = ~pick.n
+            idx = pick.o
+            #(2) merge
+            self.data_o.eq(0)
+            for j in range(self.array_size):
+                with m.If(self.addr_match_i[idx][j] && valid):
+                    self.data_o.eq(self.data_i[j]|self.data_o)
+
 
 class LDSTPort(Elaboratable):
     def __init__(self, idx, regwid=64, addrwid=48):