KoggeStone constructor

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

KoggeStone constructor

Implementation

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

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

  var skip = 1;

  while (skip < inps.length) {
    for (var i = inps.length - 1; i >= skip; --i) {
      iseq[i] = op(iseq[i - skip], iseq[i]);
    }
    skip *= 2;
  }

  iseq.forEachIndexed((i, el) {
    _oseq[i] <= el;
  });
}