CompressionTreeMultiplier constructor

CompressionTreeMultiplier(
  1. Logic a,
  2. Logic b,
  3. int radix, {
  4. Logic? selectSigned,
  5. ParallelPrefix ppTree(
    1. List<Logic>,
    2. Logic (
      1. Logic,
      2. Logic
      )
    ) = KoggeStone.new,
  6. bool signed = false,
  7. 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.

a and b are the product terms and they can be different widths allowing for rectangular multiplication.

signed parameter configures the multiplier as a signed multiplier (default is unsigned).

Optional selectSigned allows for runtime configuration of signed or unsigned operation, overriding the signed static configuration.

Implementation

CompressionTreeMultiplier(super.a, super.b, int radix,
    {Logic? selectSigned,
    ParallelPrefix Function(List<Logic>, Logic Function(Logic, Logic))
        ppTree = KoggeStone.new,
    super.signed = false,
    super.name = 'compression_tree_multiplier'}) {
  if (selectSigned != null) {
    selectSigned = addInput('selectSigned', selectSigned);
  }

  final product = addOutput('product', width: a.width + b.width);
  final pp = PartialProductGeneratorCompactRectSignExtension(
      a, b, RadixEncoder(radix),
      selectSigned: selectSigned, signed: signed);

  final compressor = ColumnCompressor(pp)..compress();
  final adder = ParallelPrefixAdder(
      compressor.extractRow(0), compressor.extractRow(1),
      ppGen: ppTree);
  product <= adder.sum.slice(a.width + b.width - 1, 0);
}