Ripple constructor

Ripple(
  1. List<Logic> inps,
  2. Logic op(
    1. Logic,
    2. Logic
    )
)

Ripple constructor

Implementation

Ripple(List<Logic> inps, Logic Function(Logic, Logic) op)
    : super(inps, 'ripple') {
  final iseq = <Logic>[];

  inps.forEachIndexed((i, el) {
    iseq.add(addInput('i$i', el, width: el.width));
    _oseq.add(addOutput('o$i', width: el.width));
  });

  for (var i = 0; i < iseq.length; ++i) {
    if (i == 0) {
      _oseq[i] <= iseq[i];
    } else {
      _oseq[i] <= op(_oseq[i - 1], iseq[i]);
    }
  }
}