Sklansky constructor
Sklansky constructor
Implementation
Sklansky(List<Logic> inps, Logic Function(Logic, Logic) op)
: super(inps, 'sklansky') {
final iseq = <Logic>[];
inps.forEachIndexed((i, el) {
iseq.add(addInput('i$i', el, width: el.width));
_oseq.add(addOutput('o$i', width: el.width));
});
if (iseq.length == 1) {
_oseq[0] <= iseq[0];
} else {
final n = iseq.length;
final m = largestPow2LessThan(n);
final u = Sklansky(iseq.getRange(0, m).toList(), op).val;
final v = Sklansky(iseq.getRange(m, n).toList(), op).val;
u.forEachIndexed((i, el) {
_oseq[i] <= el;
});
v.forEachIndexed((i, el) {
_oseq[m + i] <= op(u[m - 1], el);
});
}
}