Skip to content

Commit

Permalink
multiplier doc and configurator update
Browse files Browse the repository at this point in the history
  • Loading branch information
ganewto committed Dec 4, 2024
1 parent ee51e5a commit af79422
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 9 deletions.
20 changes: 13 additions & 7 deletions doc/components/multiplier.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,14 @@ digital signal processing.
The parameters of the
`CompressionTreeMultiplier` are:

- Two input terms `a` and `b` which can be different widths
- The radix used for Booth encoding (2, 4, 8, and 16 are currently supported)
- The type of `ParallelPrefix` tree used in the final `ParallelPrefixAdder` (optional)
- `signed` parameter: whether the operands should be treated as signed (2s complement) or unsigned
- Two input terms `a` and `b` which can be different widths.
- The radix used for Booth encoding (2, 4, 8, and 16 are currently supported).
- The type of `ParallelPrefix` tree used in the final `ParallelPrefixAdder` (optional).
- `ppGen` parameter: the type of `PartialProductGenerator` to use which has derived classes for different styles of sign extension. In some cases this adds an extra row to hold a sign bit.
- An optional `selectSigned` control signal which overrides the `signed` configuration allowing for runtime control of signed or unsigned operation with the same hardware. `signed` must be false if using this control signal.
- `signedMultiplicand` parameter: whether the multiplicand (first arg) should be treated as signed (2s complement) or unsigned.
- `signedMultiplier` parameter: whether the multiplier (second arg) should be treated as signed (2s complement) or unsigned.
- An optional `selectSignedMultiplicand` control signal which overrides the `signedMultiplicand` parameter allowing for runtime control of signed or unsigned operation with the same hardware. `signedMultiplicand` must be false if using this control signal.
- An optional `selectSignedMultiplier` control signal which overrides the `signedMultiplier` parameter allowing for runtime control of signed or unsigned operation with the same hardware. `signedMultiplier` must be false if using this control signal.
- An optional `clk`, as well as `enable` and `reset` that are used to add a pipestage in the `ColumnCompressor` to allow for pipelined operation.

Here is an example of use of the `CompressionTreeMultiplier`:
Expand Down Expand Up @@ -123,9 +125,13 @@ The parameters of the
- The accumulate input term `c` which must have width as sum of the two operand widths + 1.
- The radix used for Booth encoding (2, 4, 8, and 16 are currently supported)
- The type of `ParallelPrefix` tree used in the final `ParallelPrefixAdder` (default Kogge-Stone).
- `signed` parameter: whether the operands should be treated as signed (2s complement) or unsigned
- `ppGen` parameter: the type of `PartialProductGenerator` to use which has derived classes for different styles of sign extension. In some cases this adds an extra row to hold a sign bit (default `PartialProductGeneratorCompactRectSignExtension`).
- An optional `selectSigned` control signal which overrides the `signed` configuration allowing for runtime control of signed or unsigned operation with the same hardware. `signed` must be false if using this control signal.
- `signedMultiplicand` parameter: whether the multiplicand (first arg) should be treated as signed (2s complement) or unsigned
- `signedMultiplier` parameter: whether the multiplier (second arg) should be treated as signed (2s complement) or unsigned
- `signedAddend` parameter: whether the addend (third arg) should be treated as signed (2s complement) or unsigned
- An optional `selectSignedMultiplicand` control signal which overrides the `signedMultiplicand` parameter allowing for runtime control of signed or unsigned operation with the same hardware. `signedMultiplicand` must be false if using this control signal.
- An optional `selectSignedMultiplier` control signal which overrides the `signedMultiplier` parameter allowing for runtime control of signed or unsigned operation with the same hardware. `signedMultiplier` must be false if using this control signal.
- An optional `selectSignedAddend` control signal which overrides the `signedAddend` parameter allowing for runtime control of signed or unsigned operation with the same hardware. `signedAddend` must be false if using this control signal.
- An optional `clk`, as well as `enable` and `reset` that are used to add a pipestage in the `ColumnCompressor` to allow for pipelined operation.

Here is an example of using the `CompressionTreeMultiplyAccumulate`:
Expand Down
38 changes: 36 additions & 2 deletions test/configurator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ void main() {
test('should return both Int knobs to be configured', () {
final multiplier = CarrySaveMultiplierConfigurator();
expect(multiplier.knobs.values.whereType<IntConfigKnob>().length, 1);
expect(
multiplier.knobs.values.whereType<ConfigKnob<dynamic>>().length, 1);
});

test('should return rtl code when invoke generate() with default value',
Expand All @@ -160,6 +158,42 @@ void main() {
});
});

group('compression_tree_multiplier', () {
test('should return Compression Tree Multiplier for component name', () {
final multiplier = CompressionTreeMultiplierConfigurator();
expect(multiplier.name, 'Comp. Tree Multiplier');
});

test('should return both Int knobs to be configured', () {
final multiplier = CompressionTreeMultiplierConfigurator();
expect(multiplier.knobs.values.whereType<IntConfigKnob>().length, 2);
expect(
multiplier.knobs.values.whereType<ChoiceConfigKnob<dynamic>>().length,
4);
expect(multiplier.knobs.values.whereType<ToggleConfigKnob>().length, 1);
});

test('should return rtl code when invoke generate() with default value',
() async {
final multiplier = CompressionTreeMultiplierConfigurator();
expect(
await multiplier.generateSV(), contains('CompressionTreeMultiplier'));
});

test('should return rtl code when invoke generate() with custom value',
() async {
final multiplierDefault = CompressionTreeMultiplierConfigurator();
final multiplierCustom = CompressionTreeMultiplierConfigurator();
multiplierCustom.knobs.values.toList()[1].value = 4;

final multiplierDefaultRTL = await multiplierDefault.generateSV();
final multiplierCustomRTL = await multiplierCustom.generateSV();

expect(multiplierDefaultRTL.length > multiplierCustomRTL.length,
equals(false));
});
});

group('fifo configurator', () {
test('should generate FIFO', () async {
final cfg = FifoConfigurator()
Expand Down

0 comments on commit af79422

Please sign in to comment.