endpoint: add _i/_o suffix on signal names

This commit is contained in:
Sebastien Bourdeauducq 2012-01-07 21:21:46 +01:00
parent cdd9977a40
commit 34c69db14a
2 changed files with 17 additions and 13 deletions

View File

@ -152,16 +152,17 @@ def _try_module_name(frame):
else: else:
return None return None
def _make_signal_name(): def _make_signal_name(name=None):
frame = inspect.currentframe().f_back.f_back frame = inspect.currentframe().f_back.f_back
line = inspect.getframeinfo(frame).code_context[0] if name is None:
m = re.match('[\t ]*([0-9A-Za-z_\.]+)[\t ]*=', line) line = inspect.getframeinfo(frame).code_context[0]
if m is None: m = re.match('[\t ]*([0-9A-Za-z_\.]+)[\t ]*=', line)
name = "anonymous" if m is None:
else: name = "anonymous"
names = m.group(1).split('.') else:
name = names[len(names)-1] names = m.group(1).split('.')
name = names[len(names)-1]
prefix = _try_class_name(frame) prefix = _try_class_name(frame)
if prefix is None: if prefix is None:
@ -174,12 +175,12 @@ def _make_signal_name():
return prefix + name return prefix + name
class Signal(Value): 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.bv = bv
self.variable = variable self.variable = variable
self.name = name self.name = name
if self.name is None: if self.name is None:
self.name = _make_signal_name() self.name = _make_signal_name(namer)
self.reset = Constant(reset, bv) self.reset = Constant(reset, bv)
def __hash__(self): def __hash__(self):

View File

@ -22,9 +22,12 @@ class SchedulingModel:
class Endpoint: class Endpoint:
def __init__(self, token): def __init__(self, token):
self.token = token self.token = token
self.stb = Signal() if isinstance(self, Sink):
self.ack = Signal() 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): def __hash__(self):
return id(self) return id(self)