interconnect/stream: Add Gate.

This commit is contained in:
Florent Kermarrec 2021-06-08 18:58:08 +02:00
parent bd1463514b
commit 25ead1ad69
1 changed files with 19 additions and 0 deletions

View File

@ -293,6 +293,25 @@ class Demultiplexer(Module):
cases[i] = self.sink.connect(source)
self.comb += Case(self.sel, cases)
# Gate ---------------------------------------------------------------------------------------------
class Gate(Module):
def __init__(self, layout, sink_ready_when_disabled=False):
self.sink = Endpoint(layout)
self.source = Endpoint(layout)
self.enable = Signal()
# # #
self.comb += [
If(self.enable,
self.sink.connect(self.source)
).Else(
self.sink.ready.eq(int(sink_ready_when_disabled))
)
]
# Converter ----------------------------------------------------------------------------------------
class _UpConverter(Module):