improve timings with BufferizeEndpoints
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Thu, 8 Jan 2015 21:59:31 +0000 (22:59 +0100)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Thu, 8 Jan 2015 21:59:31 +0000 (22:59 +0100)
lib/sata/common.py
lib/sata/link/__init__.py

index 7e33626a11185fc8025f9ae3bda5b8c8cf3d776d..ecb6723a352d7318e9e5e0001714f7da667a610a 100644 (file)
@@ -209,3 +209,37 @@ class Counter(Module):
                        self.value = signal
                self.width = flen(self.value)
                self.sync += self.value.eq(self.value+1)
+
+class BufferizeEndpoints(Module):
+       def __init__(self, decorated, *args):
+               self.decorated = decorated
+
+               endpoints = get_endpoints(decorated)
+               sinks = {}
+               sources = {}
+               for name, endpoint in endpoints.items():
+                       if name in args or len(args) == 0:
+                               if isinstance(endpoint, Sink):
+                                       sinks.update({name : endpoint})
+                               elif isinstance(endpoint, Source):
+                                       sources.update({name : endpoint})
+
+               # add buffer on sinks
+               for name, sink in sinks.items():
+                       buf = Buffer(sink.description)
+                       self.submodules += buf
+                       setattr(self, name, buf.d)
+                       self.comb += Record.connect(buf.q, sink)
+
+               # add buffer on sources
+               for name, source in sources.items():
+                       buf = Buffer(source.description)
+                       self.submodules += buf
+                       self.comb += Record.connect(source, buf.d)
+                       setattr(self, name, buf.q)
+
+       def __getattr__(self, name):
+               return getattr(self.decorated, name)
+
+       def __dir__(self):
+               return dir(self.decorated)
index e55c2ab22ddb477f2a2b2f9c13d7ba8cd2449e1d..381bba88b43b53f3e65bb4e6f38ece9c46874bb1 100644 (file)
@@ -34,7 +34,7 @@ class SATALinkTX(Module):
 
                # inserter CONT and scrambled data between
                # CONT and next primitive
-               self.cont  = cont = SATACONTInserter(phy_description(32))
+               self.cont  = cont = BufferizeEndpoints(SATACONTInserter(phy_description(32)), "source")
 
                # datas / primitives mux
                insert = Signal(32)
@@ -117,7 +117,7 @@ class SATALinkRX(Module):
                self.fsm = fsm = FSM(reset_state="IDLE")
 
                # CONT remover
-               self.cont = cont = SATACONTRemover(phy_description(32))
+               self.cont = cont = BufferizeEndpoints(SATACONTRemover(phy_description(32)), "source")
                self.comb += Record.connect(phy.source, cont.sink)
 
                # datas / primitives detection