-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
154 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright (C) 2023 Intel Corporation | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// | ||
// previous_value_test.dart | ||
// Tests for Logic.previousValue | ||
// | ||
// 2023 June 16 | ||
// Author: Max Korbel <max.korbel@intel.com> | ||
|
||
import 'dart:async'; | ||
|
||
import 'package:rohd/rohd.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
tearDown(() async { | ||
await Simulator.reset(); | ||
}); | ||
|
||
test('sample on flop with listen', () async { | ||
final clk = SimpleClockGenerator(10).clk; | ||
|
||
final a = Logic()..put(0); | ||
|
||
final b = flop(clk, a); | ||
final c = flop(clk, b); | ||
|
||
Simulator.registerAction(11, () => a.put(1)); | ||
|
||
clk.posedge.listen((event) { | ||
if (Simulator.time == 25) { | ||
expect(c.previousValue!.toInt(), 0); | ||
expect(c.value.toInt(), 1); | ||
} | ||
}); | ||
|
||
Simulator.setMaxSimTime(200); | ||
await Simulator.run(); | ||
}); | ||
|
||
test('sample on flop with await', () async { | ||
final clk = SimpleClockGenerator(10).clk; | ||
|
||
final a = Logic()..put(0); | ||
|
||
final b = flop(clk, a); | ||
final c = flop(clk, b); | ||
|
||
Simulator.registerAction(11, () => a.put(1)); | ||
|
||
Future<void> clkLoop() async { | ||
while (!Simulator.simulationHasEnded) { | ||
await clk.nextPosedge; | ||
if (Simulator.time == 25) { | ||
expect(c.previousValue!.toInt(), 0); | ||
expect(c.value.toInt(), 1); | ||
} | ||
} | ||
} | ||
|
||
unawaited(clkLoop()); | ||
|
||
Simulator.setMaxSimTime(200); | ||
await Simulator.run(); | ||
}); | ||
} |