endpoint: add _i/_o suffix on signal names
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Sat, 7 Jan 2012 20:21:46 +0000 (21:21 +0100)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Sat, 7 Jan 2012 20:21:46 +0000 (21:21 +0100)
migen/fhdl/structure.py
migen/flow/actor.py

index 532098ddbc2c01386c532af11fab0e96a8e4e3b3..90b6e416e6b1321762d51052d5fb2c06d6a3dd91 100644 (file)
@@ -152,16 +152,17 @@ def _try_module_name(frame):
        else:
                return None
        
-def _make_signal_name():
+def _make_signal_name(name=None):
        frame = inspect.currentframe().f_back.f_back
        
-       line = inspect.getframeinfo(frame).code_context[0]
-       m = re.match('[\t ]*([0-9A-Za-z_\.]+)[\t ]*=', line)
-       if m is None:
-               name = "anonymous"
-       else:
-               names = m.group(1).split('.')
-               name = names[len(names)-1]
+       if name is None:
+               line = inspect.getframeinfo(frame).code_context[0]
+               m = re.match('[\t ]*([0-9A-Za-z_\.]+)[\t ]*=', line)
+               if m is None:
+                       name = "anonymous"
+               else:
+                       names = m.group(1).split('.')
+                       name = names[len(names)-1]
        
        prefix = _try_class_name(frame)
        if prefix is None:
@@ -174,12 +175,12 @@ def _make_signal_name():
        return prefix + name
 
 class Signal(Value):
-       def __init__(self, bv=BV(), name=None, variable=False, reset=0):
+       def __init__(self, bv=BV(), name=None, variable=False, reset=0, namer=None):
                self.bv = bv
                self.variable = variable
                self.name = name
                if self.name is None:
-                       self.name = _make_signal_name()
+                       self.name = _make_signal_name(namer)
                self.reset = Constant(reset, bv)
 
        def __hash__(self):
index 15eb512f931e33db589939ad0b64f0c1cf6ee79a..6110c406d65d1d4b5330d308302f73b641ff3923 100644 (file)
@@ -22,9 +22,12 @@ class SchedulingModel:
 class Endpoint:
        def __init__(self, token):
                self.token = token
-               self.stb = Signal()
-               self.ack = Signal()
-       
+               if isinstance(self, Sink):
+                       self.stb = Signal(namer="stb_i")
+                       self.ack = Signal(namer="ack_o")
+               else:
+                       self.stb = Signal(namer="stb_o")
+                       self.ack = Signal(namer="ack_i")
        def __hash__(self):
                return id(self)