CompressionTreeMultiplier constructor
- Logic a,
- Logic b,
- int radix, {
- Logic? clk,
- Logic? reset,
- Logic? enable,
- bool signedMultiplicand = false,
- bool signedMultiplier = false,
- Logic? selectSignedMultiplicand,
- Logic? selectSignedMultiplier,
- Adder adderGen(}) = NativeAdder.new,
- PartialProductSignExtension seGen(
- PartialProductGeneratorBase pp, {
- String name,
- String name = 'compression_tree_multiplier',
Construct a compression tree integer multiplier with a given radix
and an Adder generator functor adderGen
for the final adder.
Sign extension methodology is defined by the partial product generator
supplied via seGen
.
a
multiplicand and b
multiplier are the product terms and they can
be different widths allowing for rectangular multiplication.
signedMultiplicand
parameter configures the multiplicand a
as a signed
multiplier (default is unsigned).
signedMultiplier
parameter configures the multiplier b
as a signed
multiplier (default is unsigned).
Optional selectSignedMultiplicand
allows for runtime configuration of
signed or unsigned operation, overriding the signedMultiplicand
static
configuration.
Optional selectSignedMultiplier
allows for runtime configuration of
signed or unsigned operation, overriding the signedMultiplier
static
configuration.
If clk
is not null then a set of flops are used to latch the output
after compression. reset
and enable
are optional
inputs to control these flops when clk
is provided. If clk
is null,
the ColumnCompressor is built as a combinational tree of compressors.
Implementation
CompressionTreeMultiplier(super.a, super.b, int radix,
{super.clk,
super.reset,
super.enable,
super.signedMultiplicand = false,
super.signedMultiplier = false,
super.selectSignedMultiplicand,
super.selectSignedMultiplier,
Adder Function(Logic a, Logic b, {Logic? carryIn}) adderGen =
NativeAdder.new,
PartialProductSignExtension Function(PartialProductGeneratorBase pp,
{String name})
seGen = CompactRectSignExtension.new,
super.name = 'compression_tree_multiplier'})
: super(
definitionName: 'CompressionTreeMultiplier_W${a.width}x'
'${b.width}_'
'${signedMultiplicand ? 'SD_' : ''}'
'${signedMultiplier ? 'SM_' : ''}'
'${selectSignedMultiplicand != null ? 'SSD_' : ''}'
'${selectSignedMultiplier != null ? 'SSM_' : ''}'
'with${adderGen(a, b).definitionName}') {
// Should be done in base TODO(desmonddak):
final product = addOutput('product', width: a.width + b.width);
final pp = PartialProductGenerator(
a,
b,
RadixEncoder(radix),
selectSignedMultiplicand: selectSignedMultiplicand,
signedMultiplicand: signedMultiplicand,
selectSignedMultiplier: selectSignedMultiplier,
signedMultiplier: signedMultiplier,
);
seGen(pp).signExtend();
final compressor =
ColumnCompressor(clk: clk, reset: reset, enable: enable, pp)
..compress();
final adder = adderGen(compressor.extractRow(0), compressor.extractRow(1));
product <= adder.sum.slice(a.width + b.width - 1, 0);
}