Skip to content

Commit

Permalink
Bug fix for pipelined multiplication signals (#138)
Browse files Browse the repository at this point in the history
* fix signed operand mode in multiplier, added pipelining

* bug fix for pipeline signal addition

* format issue
  • Loading branch information
desmonddak authored Nov 15, 2024
1 parent 199bc7d commit f59dfee
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions lib/src/arithmetic/multiplier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,18 @@ class CompressionTreeMultiplier extends Multiplier {
ppGen = PartialProductGeneratorCompactRectSignExtension.new,
super.signed = false,
super.name = 'compression_tree_multiplier'}) {
final Logic? internalSelectSigned;
if (selectSigned != null) {
internalSelectSigned = addInput('selectSigned', selectSigned);
} else {
internalSelectSigned = null;
}
final internalSelectSigned =
(selectSigned != null) ? addInput('selectSigned', selectSigned) : null;
final iClk = (clk != null) ? addInput('clk', clk!) : null;
final iReset = (reset != null) ? addInput('reset', reset!) : null;
final iEnable = (enable != null) ? addInput('enable', enable!) : null;

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

final compressor =
ColumnCompressor(clk: clk, reset: reset, enable: enable, pp)
ColumnCompressor(clk: iClk, reset: iReset, enable: iEnable, pp)
..compress();
final adder = ParallelPrefixAdder(
compressor.extractRow(0), compressor.extractRow(1),
Expand Down Expand Up @@ -180,12 +179,12 @@ class CompressionTreeMultiplyAccumulate extends MultiplyAccumulate {
{required bool signed, Logic? selectSigned})
ppGen = PartialProductGeneratorCompactRectSignExtension.new,
super.name = 'compression_tree_mac'}) {
final Logic? internalSelectSigned;
if (selectSigned != null) {
internalSelectSigned = addInput('selectSigned', selectSigned);
} else {
internalSelectSigned = null;
}
final internalSelectSigned =
(selectSigned != null) ? addInput('selectSigned', selectSigned) : null;
final iClk = (clk != null) ? addInput('clk', clk!) : null;
final iReset = (reset != null) ? addInput('reset', reset!) : null;
final iEnable = (enable != null) ? addInput('enable', enable!) : null;

final accumulate = addOutput('accumulate', width: a.width + b.width + 1);
final pp = ppGen(a, b, RadixEncoder(radix),
selectSigned: internalSelectSigned, signed: signed);
Expand Down Expand Up @@ -213,7 +212,7 @@ class CompressionTreeMultiplyAccumulate extends MultiplyAccumulate {
pp.rowShift.insert(0, 0);

final compressor =
ColumnCompressor(clk: clk, reset: reset, enable: enable, pp)
ColumnCompressor(clk: iClk, reset: iReset, enable: iEnable, pp)
..compress();
final adder = ParallelPrefixAdder(
compressor.extractRow(0), compressor.extractRow(1),
Expand Down

0 comments on commit f59dfee

Please sign in to comment.