Skip to content

Commit 62c23c7

Browse files
committed
setattr method of function is updated.
1 parent b66b6f0 commit 62c23c7

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

veriloggen/function.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ class Function(vtypes.VeriloggenNode):
1111
def __init__(self, name, width=1):
1212
self.name = name
1313
self.width = width
14+
self.width_msb = None
15+
self.width_lsb = None
1416
self.io_variable = collections.OrderedDict()
1517
self.variable = collections.OrderedDict()
1618
self.statement = None
17-
self.width_msb = None
18-
self.width_lsb = None
1919
self.subst = []
2020

2121
#---------------------------------------------------------------------------
@@ -40,22 +40,30 @@ def Body(self, *statement):
4040
self.statement = tuple(statement)
4141
return self
4242

43+
# function call
44+
def call(self, *args):
45+
return FunctionCall(self, *args)
46+
47+
def next(self, r):
48+
return self.__call__(r)
49+
4350
def add_subst(self, s):
4451
self.subst.append(s)
4552

4653
def set_raw_width(self, msb, lsb):
4754
self.width_msb = msb
4855
self.width_lsb = lsb
4956

57+
def __setattr__(self, attr, value):
58+
# when width or length is overwritten, msb and lsb values are reset.
59+
if attr == 'width':
60+
object.__setattr__(self, 'width_msb', None)
61+
object.__setattr__(self, 'width_lsb', None)
62+
object.__setattr__(self, attr, value)
63+
5064
def __call__(self, r):
5165
return vtypes.Subst(self, r)
5266

53-
def next(self, r):
54-
return self.__call__(r)
55-
56-
def call(self, *args):
57-
return FunctionCall(self, *args)
58-
5967
class FunctionCall(vtypes._Numeric):
6068
def __init__(self, func, *args):
6169
self.func = func

0 commit comments

Comments
 (0)