Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 3 commits
  • 2 files changed
  • 0 commit comments
  • 2 contributors
Showing with 40 additions and 4 deletions.
  1. +4 −4 migen/flow/actor.py
  2. +36 −0 migen/flow/plumbing.py
View
8 migen/flow/actor.py
@@ -22,12 +22,12 @@ def __init__(self, layout):
Record.__init__(self, full_layout)
class Source(_Endpoint):
- def connect(self, sink, **kwargs):
- return Record.connect(self, sink, **kwargs)
+ def connect(self, sink):
+ return Record.connect(self, sink)
class Sink(_Endpoint):
- def connect(self, source, **kwargs):
- return source.connect(self, **kwargs)
+ def connect(self, source):
+ return source.connect(self)
def get_endpoints(obj, filt=_Endpoint):
if hasattr(obj, "get_endpoints") and callable(obj.get_endpoints):
View
36 migen/flow/plumbing.py
@@ -52,6 +52,42 @@ def __init__(self, layout, subrecords):
for n, s in enumerate(sources):
self.comb += s.stb.eq(self.sink.stb & ~already_acked[n])
+class Multiplexer(Module):
+ def __init__(self, n, layout):
+ self.source = Source(layout)
+ sinks = []
+ for i in range(n):
+ sink = Sink(layout)
+ setattr(self, "sink"+str(i), sink)
+ sinks.append(sink)
+ self.busy = Signal()
+ self.sel = Signal(max=n)
+
+ ###
+
+ case = {}
+ for i, sink in enumerate(sinks):
+ cases[i] = self.source.connect(sink)
+ self.comb += Case(self.sel, cases)
+
+class Demultiplexer(Module):
+ def __init__(self, layout, n):
+ self.sink = Sink(layout)
+ sources = []
+ for i in range(n):
+ source = Source(layout)
+ setattr(self, "source"+str(i), source)
+ sources.append(source)
+ self.busy = Signal()
+ self.sel = Signal(max=n)
+
+ ###
+
+ cases = {}
+ for i, source in enumerate(sources):
+ cases[i] = source.connect(self.sink)
+ self.comb += Case(self.sel, cases)
+
# Actors whose layout should be inferred from what their single sink is connected to.
layout_sink = {Buffer, Splitter}
# Actors whose layout should be inferred from what their single source is connected to.

No commit comments for this range

Something went wrong with that request. Please try again.