Permalink
Browse files

transform/unroll: support empty dictionaries

  • Loading branch information...
1 parent eacba52 commit 9efc581bee2f4a6da6174a5e295021f0bbc75ed0 @sbourdeauducq sbourdeauducq committed Oct 12, 2012
Showing with 14 additions and 3 deletions.
  1. +14 −3 migen/transform/unroll.py
View
@@ -1,3 +1,5 @@
+from itertools import repeat
+
from migen.fhdl.structure import *
from migen.fhdl.structure import _Operator, _Slice, _Assign, _ArrayProxy
@@ -60,6 +62,7 @@ def _replace(node, rin, rout, mode=_UNDETERMINED):
raise TypeError
def _list_step_dicts(d):
+ assert(d)
iterdict = dict((k, iter(v)) for k, v in d.items())
r = []
try:
@@ -78,11 +81,19 @@ def _variable_for(s, n):
return Signal(s.bv, name=name, variable=True)
def unroll_sync(sync, inputs, outputs):
- sd_in = _list_step_dicts(inputs)
- sd_out = _list_step_dicts(outputs)
+ assert(inputs or outputs)
+ if inputs:
+ sd_in = _list_step_dicts(inputs)
+ else:
+ sd_in = repeat({})
+ if outputs:
+ sd_out = _list_step_dicts(outputs)
+ io_var_dict = sd_out[-1].copy()
+ else:
+ sd_out = repeat({})
+ io_var_dict = {}
r = []
- io_var_dict = sd_out[-1].copy()
for n, (di, do) in enumerate(zip(sd_in, sd_out)):
do_var = dict((k, _variable_for(v, n)) for k, v in do.items())

0 comments on commit 9efc581

Please sign in to comment.