Skip to content

Commit

Permalink
move test methods out of partialproductgen into extension
Browse files Browse the repository at this point in the history
  • Loading branch information
ganewto committed Dec 4, 2024
1 parent af79422 commit 2893517
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
16 changes: 16 additions & 0 deletions lib/src/arithmetic/evaluate_partial_product.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@
import 'package:rohd/rohd.dart';
import 'package:rohd_hcl/rohd_hcl.dart';

/// The following routines are useful only during testing
extension TestPartialProductSignage on PartialProductGenerator {
/// Return true if multiplicand is truly signed (fixed or runtime)
bool isSignedMultiplicand() => (selectSignedMultiplicand == null)
? signedMultiplicand
: !selectSignedMultiplicand!.value.isZero;

/// Return true if multiplier is truly signed (fixed or runtime)
bool isSignedMultiplier() => (selectSignedMultiplier == null)
? signedMultiplier
: !selectSignedMultiplier!.value.isZero;

/// Return true if accumulate result is truly signed (fixed or runtime)
bool isSignedResult() => isSignedMultiplicand() | isSignedMultiplier();
}

/// Debug routines for printing out partial product matrix during
/// simulation with live logic values
extension EvaluateLivePartialProduct on PartialProductGenerator {
Expand Down
10 changes: 0 additions & 10 deletions lib/src/arithmetic/partial_product_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -269,16 +269,6 @@ abstract class PartialProductGenerator extends PartialProductArray {
}
}

/// Return true if [multiplicand] is truly signed (fixed or runtime)
bool isSignedMultiplicand() => (selectSignedMultiplicand == null)
? signedMultiplicand
: !selectSignedMultiplicand!.value.isZero;

/// Return true if [multiplier] is truly signed (fixed or runtime)
bool isSignedMultiplier() => (selectSignedMultiplier == null)
? signedMultiplier
: !selectSignedMultiplier!.value.isZero;

/// Helper function for sign extension routines:
/// For signed operands, set the MSB to [sign], otherwise add this [sign] bit.
void addStopSign(List<Logic> addend, SignBit sign) {
Expand Down
4 changes: 2 additions & 2 deletions test/arithmetic/multiplier_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ extension TestMultiplierSignage on Multiplier {
/// Return true if multiplicand [a] is truly signed (fixed or runtime)
bool isSignedMultiplicand() => (selectSignedMultiplicand == null)
? signedMultiplicand
: selectSignedMultiplicand!.value.isZero;
: !selectSignedMultiplicand!.value.isZero;

/// Return true if multiplier [b] is truly signed (fixed or runtime)
bool isSignedMultiplier() => (selectSignedMultiplier == null)
? signedMultiplier
: selectSignedMultiplier!.value.isZero;
: !selectSignedMultiplier!.value.isZero;

/// Return true if accumulate result is truly signed (fixed or runtime)
bool isSignedResult() => isSignedMultiplicand() | isSignedMultiplier();
Expand Down

0 comments on commit 2893517

Please sign in to comment.