CompressionTreeMultiplier constructor

CompressionTreeMultiplier(
  1. Logic a,
  2. Logic b,
  3. int radix, {
  4. Logic? clk,
  5. Logic? reset,
  6. Logic? enable,
  7. bool signedMultiplicand = false,
  8. bool signedMultiplier = false,
  9. Logic? selectSignedMultiplicand,
  10. Logic? selectSignedMultiplier,
  11. ParallelPrefix ppTree(
    1. List<Logic>,
    2. Logic (
      1. Logic,
      2. Logic
      )
    ) = KoggeStone.new,
  12. PartialProductGenerator ppGen(
    1. Logic,
    2. Logic,
    3. RadixEncoder, {
    4. Logic? selectSignedMultiplicand,
    5. Logic? selectSignedMultiplier,
    6. required bool signedMultiplicand,
    7. required bool signedMultiplier,
    }) = PartialProductGeneratorCompactRectSignExtension.new,
  13. 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);
}