from fpbase import FPNumOut
from fpbase import FPState
from fpcommon.roundz import FPRoundData
+from singlepipe import Object
-class FPPackData:
+class FPPackData(Object):
def __init__(self, width, id_wid):
+ Object.__init__(self)
self.z = Signal(width, reset_less=True)
self.mid = Signal(id_wid, reset_less=True)
- def __iter__(self):
- yield self.z
- yield self.mid
-
- def eq(self, i):
- return [self.z.eq(i.z), self.mid.eq(i.mid)]
-
- def ports(self):
- return list(self)
-
class FPPackMod:
from queue import Queue
+class Object:
+ def __init__(self):
+ self.fields = {}
+
+ def __setattr__(self, k, v):
+ print ("kv", k, v)
+ if (k.startswith('_') or k in ["fields", "name", "src_loc"] or
+ k in dir(Object) or "fields" not in self.__dict__):
+ return object.__setattr__(self, k, v)
+ self.fields[k] = v
+
+ def __getattr__(self, k):
+ if k in self.fields:
+ return self.fields[k]
+ return object.__getattr__(self, k)
+
+ def __iter__(self):
+ for x in self.fields.values():
+ yield x
+
+ def eq(self, inp):
+ res = []
+ for (o, i) in zip(self, inp):
+ res.append(eq(o, i))
+ return res
+
+ def ports(self):
+ return list(self)
+
+
class RecordObject(Record):
def __init__(self, layout=None, name=None):
Record.__init__(self, layout=layout or [], name=None)