flow/actor: add single_sink/single_source retrieval methods
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Sat, 16 Jun 2012 20:38:16 +0000 (22:38 +0200)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Sat, 16 Jun 2012 20:38:16 +0000 (22:38 +0200)
migen/flow/actor.py

index 71dc1dffd1eae912e3e7cccc2cfecf1efa65889a..90049701dd3f33af7a49d5cce444e56db32c1be5 100644 (file)
@@ -60,6 +60,16 @@ class Actor:
 
        def sources(self):
                return self.filter_endpoints(Source)
+               
+       def single_sink(self):
+               eps = self.sinks()
+               assert(len(eps) == 1)
+               return eps[0]
+       
+       def single_source(self):
+               eps = self.sources()
+               assert(len(eps) == 1)
+               return eps[0]
 
        def get_control_fragment(self):
                raise NotImplementedError("Actor classes must overload get_control_fragment or get_fragment")