ioo: move to genlib
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Wed, 10 Apr 2013 20:28:53 +0000 (22:28 +0200)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Wed, 10 Apr 2013 20:28:53 +0000 (22:28 +0200)
examples/pytholite/uio.py
migen/genlib/ioo.py [new file with mode: 0644]
migen/pytholite/io.py
migen/uio/__init__.py [deleted file]
migen/uio/ioo.py [deleted file]

index 3718acc2a6a0ab2f2c34f1a9cd4d0a7febd67b24..8519f7a0abce34057b017e47aed025cee62a74a5 100644 (file)
@@ -3,7 +3,7 @@ from migen.flow.transactions import *
 from migen.actorlib.sim import Dumper
 from migen.bus import wishbone
 from migen.bus.transactions import *
-from migen.uio.ioo import UnifiedIOSimulation
+from migen.genlib.ioo import UnifiedIOSimulation
 from migen.pytholite.transel import Register
 from migen.pytholite.compiler import make_pytholite
 from migen.sim.generic import Simulator
diff --git a/migen/genlib/ioo.py b/migen/genlib/ioo.py
new file mode 100644 (file)
index 0000000..9257ad0
--- /dev/null
@@ -0,0 +1,76 @@
+from migen.fhdl.structure import *
+from migen.fhdl.specials import Memory
+from migen.flow.actor import *
+from migen.flow.transactions import *
+from migen.actorlib.sim import TokenExchanger
+from migen.bus import wishbone, memory
+from migen.bus.transactions import *
+
+class UnifiedIOObject(Module):
+       def __init__(self, dataflow=None, buses={}):
+               if dataflow is not None:
+                       self.busy = Signal()
+                       for name, cl, layout in dataflow:
+                               setattr(self, name, cl(layout))
+               self.buses = buses
+               self.specials += set(v for v in self.buses.values() if isinstance(v, Memory))
+
+(_WAIT_COMPLETE, _WAIT_POLL) = range(2)
+
+class UnifiedIOSimulation(UnifiedIOObject):
+       def __init__(self, generator, dataflow=None, buses={}):
+               self.generator = generator
+               UnifiedIOObject.__init__(self, dataflow, buses)
+               
+               callers = []
+               self.busname_to_caller_id = {}
+               if dataflow is not None:
+                       callers.append(TokenExchanger(self.dispatch_g(0), self))
+               for k, v in self.buses.items():
+                       caller_id = len(callers)
+                       self.busname_to_caller_id[k] = caller_id
+                       g = self.dispatch_g(caller_id)
+                       if isinstance(v, wishbone.Interface):
+                               caller = wishbone.Initiator(g, v)
+                       elif isinstance(v, Memory):
+                               caller = memory.Initiator(g, v)
+                       else:
+                               raise NotImplementedError
+                       callers.append(caller)
+               self.submodules += callers
+               
+               self.dispatch_state = _WAIT_COMPLETE
+               self.dispatch_caller = 0
+               self.pending_transaction = None
+       
+       def identify_transaction(self, t):
+               if isinstance(t, Token):
+                       return 0
+               elif isinstance(t, TRead) or isinstance(t, TWrite):
+                       if t.busname is None:
+                               if len(self.busname_to_caller_id) != 1:
+                                       raise TypeError
+                               else:
+                                       return list(self.busname_to_caller_id.values())[0]
+                       else:
+                               return self.busname_to_caller_id[t.busname]
+               else:
+                       raise TypeError
+       
+       def dispatch_g(self, caller_id):
+               while True:
+                       if self.dispatch_state == _WAIT_COMPLETE and self.dispatch_caller == caller_id:
+                               transaction = next(self.generator)
+                               tr_cid = self.identify_transaction(transaction)
+                               self.dispatch_caller = tr_cid
+                               if tr_cid == caller_id:
+                                       yield transaction
+                               else:
+                                       self.pending_transaction = transaction
+                                       self.dispatch_state = _WAIT_POLL
+                                       yield None
+                       elif self.dispatch_state == _WAIT_POLL and self.dispatch_caller == caller_id:
+                               self.dispatch_state = _WAIT_COMPLETE
+                               yield self.pending_transaction
+                       else:
+                               yield None
index c20cc467a3692cbc32a554ab0e60f98b5c72231f..c89cf791819e3e81ae13bc8b573050cf211807cc 100644 (file)
@@ -3,7 +3,7 @@ from itertools import zip_longest
 
 from migen.fhdl.structure import *
 from migen.fhdl.specials import Memory
-from migen.uio.ioo import UnifiedIOObject
+from migen.genlib.ioo import UnifiedIOObject
 from migen.flow.actor import Source, Sink
 from migen.flow.transactions import *
 from migen.bus import wishbone
diff --git a/migen/uio/__init__.py b/migen/uio/__init__.py
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/migen/uio/ioo.py b/migen/uio/ioo.py
deleted file mode 100644 (file)
index 9257ad0..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-from migen.fhdl.structure import *
-from migen.fhdl.specials import Memory
-from migen.flow.actor import *
-from migen.flow.transactions import *
-from migen.actorlib.sim import TokenExchanger
-from migen.bus import wishbone, memory
-from migen.bus.transactions import *
-
-class UnifiedIOObject(Module):
-       def __init__(self, dataflow=None, buses={}):
-               if dataflow is not None:
-                       self.busy = Signal()
-                       for name, cl, layout in dataflow:
-                               setattr(self, name, cl(layout))
-               self.buses = buses
-               self.specials += set(v for v in self.buses.values() if isinstance(v, Memory))
-
-(_WAIT_COMPLETE, _WAIT_POLL) = range(2)
-
-class UnifiedIOSimulation(UnifiedIOObject):
-       def __init__(self, generator, dataflow=None, buses={}):
-               self.generator = generator
-               UnifiedIOObject.__init__(self, dataflow, buses)
-               
-               callers = []
-               self.busname_to_caller_id = {}
-               if dataflow is not None:
-                       callers.append(TokenExchanger(self.dispatch_g(0), self))
-               for k, v in self.buses.items():
-                       caller_id = len(callers)
-                       self.busname_to_caller_id[k] = caller_id
-                       g = self.dispatch_g(caller_id)
-                       if isinstance(v, wishbone.Interface):
-                               caller = wishbone.Initiator(g, v)
-                       elif isinstance(v, Memory):
-                               caller = memory.Initiator(g, v)
-                       else:
-                               raise NotImplementedError
-                       callers.append(caller)
-               self.submodules += callers
-               
-               self.dispatch_state = _WAIT_COMPLETE
-               self.dispatch_caller = 0
-               self.pending_transaction = None
-       
-       def identify_transaction(self, t):
-               if isinstance(t, Token):
-                       return 0
-               elif isinstance(t, TRead) or isinstance(t, TWrite):
-                       if t.busname is None:
-                               if len(self.busname_to_caller_id) != 1:
-                                       raise TypeError
-                               else:
-                                       return list(self.busname_to_caller_id.values())[0]
-                       else:
-                               return self.busname_to_caller_id[t.busname]
-               else:
-                       raise TypeError
-       
-       def dispatch_g(self, caller_id):
-               while True:
-                       if self.dispatch_state == _WAIT_COMPLETE and self.dispatch_caller == caller_id:
-                               transaction = next(self.generator)
-                               tr_cid = self.identify_transaction(transaction)
-                               self.dispatch_caller = tr_cid
-                               if tr_cid == caller_id:
-                                       yield transaction
-                               else:
-                                       self.pending_transaction = transaction
-                                       self.dispatch_state = _WAIT_POLL
-                                       yield None
-                       elif self.dispatch_state == _WAIT_POLL and self.dispatch_caller == caller_id:
-                               self.dispatch_state = _WAIT_COMPLETE
-                               yield self.pending_transaction
-                       else:
-                               yield None