MultiplierEncoder constructor
- Logic multiplier,
- RadixEncoder radixEncoder, {
- Logic? selectSignedMultiplier,
- bool signedMultiplier = false,
Generate the Booth encoding of an input multiplier
using
radixEncoder
.
signedMultiplier
generates a fixed signed encoder versus using
selectSignedMultiplier
which is a runtime sign selection Logic
in which case signedMultiplier
must be false.
Implementation
MultiplierEncoder(this.multiplier, RadixEncoder radixEncoder,
{Logic? selectSignedMultiplier, bool signedMultiplier = false})
: _encoder = radixEncoder {
if (signedMultiplier && (selectSignedMultiplier != null)) {
throw RohdHclException('sign reconfiguration requires signed=false');
}
// Unsigned encoding wants to overlap past the multipler
if (signedMultiplier) {
rows = ((multiplier.width + (signedMultiplier ? 0 : 1)) /
log2Ceil(radixEncoder.radix))
.ceil();
} else {
rows = (((multiplier.width + 1) % (log2Ceil(radixEncoder.radix)) == 0)
? 0
: 1) +
((multiplier.width + 1) ~/ log2Ceil(radixEncoder.radix));
}
// slices overlap by 1 and start at -1a
if (selectSignedMultiplier == null) {
_extendedMultiplier = (signedMultiplier
? multiplier.signExtend(rows * (log2Ceil(radixEncoder.radix)))
: multiplier.zeroExtend(rows * (log2Ceil(radixEncoder.radix))));
} else {
final len = multiplier.width;
final sign = multiplier[len - 1];
final extension = [
for (var i = len - 1; i < (rows * (log2Ceil(radixEncoder.radix))); i++)
mux(selectSignedMultiplier, sign, Const(0))
];
_extendedMultiplier = (multiplier.elements + extension).rswizzle();
}
}