Record.__init__(self, layout=layout or [], name=None)
def __setattr__(self, k, v):
- if k in dir(Record) or "fields" not in self.__dict__:
+ #print (dir(Record))
+ if (k.startswith('_') or k in ["fields", "name", "src_loc"] or
+ k in dir(Record) or "fields" not in self.__dict__):
return object.__setattr__(self, k, v)
self.fields[k] = v
+ #print ("RecordObject setattr", k, v)
if isinstance(v, Record):
newlayout = {k: (k, v.layout)}
- else:
+ elif isinstance(v, Value):
newlayout = {k: (k, v.shape())}
+ else:
+ newlayout = {k: (k, shape(v))}
self.layout.fields.update(newlayout)
def __iter__(self):
if not isinstance(i, Sequence):
i = [i]
for ai in i:
- print ("iterate", ai)
+ #print ("iterate", ai)
if isinstance(ai, Record):
- print ("record", list(ai.layout))
+ #print ("record", list(ai.layout))
yield from self.record_iter(ai)
elif isinstance(ai, ArrayProxy) and not isinstance(ai, Value):
yield from self.array_iter(ai)
val = getattr(val, field_name)
else:
val = val[field_name] # dictionary-style specification
- print ("recidx", idx, field_name, field_shape, val)
+ #print ("recidx", idx, field_name, field_shape, val)
yield from self.iterate(val)
def array_iter(self, ai):
def shape(i):
- print ("shape", i)
+ #print ("shape", i)
r = 0
for part in list(i):
- print ("shape?", part)
+ #print ("shape?", part)
s, _ = part.shape()
r += s
return r, False
fwft=True, pipe=False)
+"""
# this is *probably* SimpleHandshake (note: memory cell size=0)
class SimpleHandshake(FIFOControl):
def __init__(self, stage, in_multi=None, stage_ctl=False):
FIFOControl.__init__(self, 0, stage, in_multi, stage_ctl,
fwft=True, pipe=False)
+"""
from multipipe import CombMultiOutPipeline, CombMuxOutPipe
from multipipe import PriorityCombMuxInPipe
-from singlepipe import SimpleHandshake
+from singlepipe import SimpleHandshake, RecordObject
-class PassData: # (Value):
+class PassData2(RecordObject):
+ def __init__(self):
+ RecordObject.__init__(self)
+ self.mid = Signal(2, reset_less=True)
+ self.idx = Signal(8, reset_less=True)
+ self.data = Signal(16, reset_less=True)
+
+
+class PassData:
def __init__(self):
self.mid = Signal(2, reset_less=True)
self.idx = Signal(8, reset_less=True)