From 4f38b0ef6e891f62270fe5306719c95041ce2ad0 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Thu, 8 Jan 2015 22:59:31 +0100 Subject: [PATCH] improve timings with BufferizeEndpoints --- lib/sata/common.py | 34 ++++++++++++++++++++++++++++++++++ lib/sata/link/__init__.py | 4 ++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/lib/sata/common.py b/lib/sata/common.py index 7e33626a..ecb6723a 100644 --- a/lib/sata/common.py +++ b/lib/sata/common.py @@ -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) diff --git a/lib/sata/link/__init__.py b/lib/sata/link/__init__.py index e55c2ab2..381bba88 100644 --- a/lib/sata/link/__init__.py +++ b/lib/sata/link/__init__.py @@ -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 -- 2.30.2