CompressionTreeMultiplier constructor
- Logic a,
- Logic b,
- int radix, {
- Logic? clk,
- Logic? reset,
- Logic? enable,
- bool signedMultiplicand = false,
- bool signedMultiplier = false,
- Logic? selectSignedMultiplicand,
- Logic? selectSignedMultiplier,
- ParallelPrefix ppTree() = KoggeStone.new,
- PartialProductGenerator ppGen(
- Logic,
- Logic,
- RadixEncoder, {
- Logic? selectSignedMultiplicand,
- Logic? selectSignedMultiplier,
- required bool signedMultiplicand,
- required bool signedMultiplier,
- String name = 'compression_tree_multiplier',
Construct a compression tree integer multiplier with a given radix
and prefix tree functor ppTree
for the compressor and final adder.
Sign extension methodology is defined by the partial product generator
supplied via ppGen
.
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,
{this.clk,
this.reset,
this.enable,
super.signedMultiplicand = false,
super.signedMultiplier = false,
super.selectSignedMultiplicand,
super.selectSignedMultiplier,
ParallelPrefix Function(List<Logic>, Logic Function(Logic, Logic))
ppTree = KoggeStone.new,
PartialProductGenerator Function(Logic, Logic, RadixEncoder,
{required bool signedMultiplier,
required bool signedMultiplicand,
Logic? selectSignedMultiplier,
Logic? selectSignedMultiplicand})
ppGen = PartialProductGeneratorCompactRectSignExtension.new,
super.name = 'compression_tree_multiplier'}) {
clk = (clk != null) ? addInput('clk', clk!) : null;
reset = (reset != null) ? addInput('reset', reset!) : null;
enable = (enable != null) ? addInput('enable', enable!) : null;
final product = addOutput('product', width: a.width + b.width);
final pp = ppGen(
a,
b,
RadixEncoder(radix),
selectSignedMultiplicand: selectSignedMultiplicand,
signedMultiplicand: signedMultiplicand,
selectSignedMultiplier: selectSignedMultiplier,
signedMultiplier: signedMultiplier,
);
final compressor =
ColumnCompressor(clk: clk, reset: reset, enable: enable, pp)
..compress();
final adder = ParallelPrefixAdder(
compressor.extractRow(0), compressor.extractRow(1),
ppGen: ppTree);
product <= adder.sum.slice(a.width + b.width - 1, 0);
}