projects
/
ieee754fpu.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
25a0ec5
)
replace flatten with iterator
author
Luke Kenneth Casson Leighton
<lkcl@lkcl.net>
Fri, 19 Apr 2019 14:31:22 +0000
(15:31 +0100)
committer
Luke Kenneth Casson Leighton
<lkcl@lkcl.net>
Fri, 19 Apr 2019 14:31:22 +0000
(15:31 +0100)
src/add/singlepipe.py
patch
|
blob
|
history
diff --git
a/src/add/singlepipe.py
b/src/add/singlepipe.py
index fe052be72a3e70fde85e56058cf708ea9e7cd341..374904f16a1b11cd6c6303a41c51248706f7afc4 100644
(file)
--- a/
src/add/singlepipe.py
+++ b/
src/add/singlepipe.py
@@
-1,6
+1,10
@@
""" Pipeline and BufferedHandshake implementation, conforming to the same API.
For multi-input and multi-output variants, see multipipe.
""" Pipeline and BufferedHandshake implementation, conforming to the same API.
For multi-input and multi-output variants, see multipipe.
+ Associated development bugs:
+ * http://bugs.libre-riscv.org/show_bug.cgi?id=64
+ * http://bugs.libre-riscv.org/show_bug.cgi?id=57
+
eq:
--
eq:
--
@@
-358,7
+362,7
@@
class Visitor:
for p in ai.ports():
op = getattr(ao, p.name)
#print (op, p, p.name)
for p in ai.ports():
op = getattr(ao, p.name)
#print (op, p, p.name)
- res.append(fn(op, p))
+ res.append(
act.
fn(op, p))
return res
return res
@@
-384,14
+388,13
@@
def eq(o, i):
return Eq()(o, i)
return Eq()(o, i)
-def
flatten
(i):
- """
flattens a compound structure recursively using Cat
+def
iterate
(i):
+ """
iterate a compound structure recursively and yield data
"""
if not isinstance(i, Sequence):
i = [i]
"""
if not isinstance(i, Sequence):
i = [i]
- res = []
for ai in i:
for ai in i:
- print ("
flatten
", ai)
+ print ("
iterate
", ai)
if isinstance(ai, Record):
print ("record", list(ai.layout))
rres = []
if isinstance(ai, Record):
print ("record", list(ai.layout))
rres = []
@@
-405,28
+408,21
@@
def flatten(i):
else:
val = val[field_name] # dictionary-style specification
print ("recidx", idx, field_name, field_shape, val)
else:
val = val[field_name] # dictionary-style specification
print ("recidx", idx, field_name, field_shape, val)
- val = flatten(val)
- print ("recidx flat", idx, val)
- if isinstance(val, Sequence):
- rres += val
- else:
- rres.append(val)
+ yield from flatten(val)
elif isinstance(ai, ArrayProxy) and not isinstance(ai, Value):
elif isinstance(ai, ArrayProxy) and not isinstance(ai, Value):
- rres = []
for p in ai.ports():
for p in ai.ports():
- op = getattr(ai, p.name)
- #print (op, p, p.name)
- rres.append(flatten(p))
+ yield from iterate(p)
else:
else:
- rres = ai
- if not isinstance(rres, Sequence):
- rres = [rres]
- res += rres
- print ("flatten res", res)
- return Cat(*res)
+ yield ai
+def flatten(i):
+ """ flattens a compound structure recursively using Cat
+ """
+ res = list(iterate(i))
+ return Cat(*res)
+
class StageCls(metaclass=ABCMeta):
""" Class-based "Stage" API. requires instantiation (after derivation)
class StageCls(metaclass=ABCMeta):
""" Class-based "Stage" API. requires instantiation (after derivation)
@@
-1189,8
+1185,10
@@
class BufferedHandshake(FIFOControl):
fwft=True, pipe=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)
# 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)
+"""