Skip to content

Commit

Permalink
Merge pull request #1736 from rowanG077/buf-endpoint-cfg
Browse files Browse the repository at this point in the history
soc/interconnect/stream: BufferizeEndpoints params
  • Loading branch information
enjoy-digital authored Aug 28, 2023
2 parents f7b35f0 + 91e1e53 commit 8efcc4f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions litex/soc/interconnect/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -985,21 +985,28 @@ def do_finalize(self):

# Add buffers on Endpoints (can be used to improve timings)
class BufferizeEndpoints(ModuleTransformer):
def __init__(self, endpoint_dict):
def __init__(self, endpoint_dict, pipe_valid=True, pipe_ready=False):
self.endpoint_dict = endpoint_dict

def transform_instance(self, submodule):
for name, direction in self.endpoint_dict.items():
endpoint = getattr(submodule, name)
# add buffer on sinks
if direction == DIR_SINK:
buf = Buffer(endpoint.description)
buf = Buffer(
endpoint.description,
pipe_valid=pipe_valid,
pipe_ready=pipe_ready
)
submodule.submodules += buf
setattr(submodule, name, buf.sink)
submodule.comb += buf.source.connect(endpoint)
# add buffer on sources
elif direction == DIR_SOURCE:
buf = Buffer(endpoint.description)
buf = Buffer(endpoint.description,
pipe_valid=pipe_valid,
pipe_ready=pipe_ready
)
submodule.submodules += buf
submodule.comb += endpoint.connect(buf.sink)
setattr(submodule, name, buf.source)
Expand Down

0 comments on commit 8efcc4f

Please sign in to comment.