From: Sebastien Bourdeauducq Date: Fri, 12 Oct 2012 19:54:48 +0000 (+0200) Subject: transform/unroll: support empty dictionaries X-Git-Tag: 24jan2021_ls180~2099^2~823 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9efc581bee2f4a6da6174a5e295021f0bbc75ed0;p=litex.git transform/unroll: support empty dictionaries --- diff --git a/migen/transform/unroll.py b/migen/transform/unroll.py index 6e517cd1..0d0ef9ee 100644 --- a/migen/transform/unroll.py +++ b/migen/transform/unroll.py @@ -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())