Skip to content

Commit

Permalink
add test for all gated together
Browse files Browse the repository at this point in the history
  • Loading branch information
mkorbel1 committed Oct 22, 2024
1 parent c044dc6 commit d6bd34d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
1 change: 0 additions & 1 deletion lib/src/summation/gated_counter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ class GatedCounter extends Counter {
if (intf.hasEnable) {
intfIsIncrementing &= intf.enable!;
}
//TODO: doc instantiation of ROHD modules

anyIntfIncrementing |= intfIsIncrementing;
}
Expand Down
31 changes: 29 additions & 2 deletions test/summation/gated_counter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class ClockToggleCounter {
double get lowerActivity => lowerToggles / totalToggles;
}

//TODO: test gating the whole thing togethr (index <0, e.g.)

void main() {
tearDown(() async {
await Simulator.reset();
Expand Down Expand Up @@ -122,6 +120,35 @@ void main() {
expect(toggleCounter.upperActivity, greaterThan(0.95));
});

test(
'simple 1-counter incrementing sometimes, with rollover,'
' clock gating all together', () async {
final toggleCounter = await testCounter(
(clk, reset) {
final enable = Logic()..inject(0);
var count = 0;
clk.posedge.listen((_) {
enable.inject(count++ % 20 > 5);
});
return GatedCounter(
[
SumInterface(width: 1, hasEnable: true)
..enable!.gets(enable)
..amount.inject(1)
],
clk: clk,
reset: reset,
width: 6,
clkGatePartitionIndex: 6,
);
},
);

expect(toggleCounter.lowerActivity, greaterThan(0.65));
expect(toggleCounter.upperActivity, greaterThan(0.65));
expect(toggleCounter.lowerActivity, toggleCounter.upperActivity);
});

test('simple 1-counter incrementing always, with saturation', () async {
final toggleCounter = await testCounter(
(clk, reset) => GatedCounter(
Expand Down

0 comments on commit d6bd34d

Please sign in to comment.