-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug where FSM may cause inferred latch
- Loading branch information
Showing
2 changed files
with
27 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,10 +8,10 @@ | |
/// Author: Shubham Kumar <[email protected]> | ||
/// | ||
import 'dart:collection'; | ||
import 'dart:io'; | ||
import 'dart:math'; | ||
|
||
import 'package:collection/collection.dart'; | ||
import 'package:rohd/rohd.dart'; | ||
|
||
/// Simple class for FSM [StateMachine]. | ||
|
@@ -91,7 +91,20 @@ class StateMachine<StateIdentifier> { | |
])) | ||
.toList(growable: false), | ||
conditionalType: ConditionalType.unique, | ||
defaultItem: [nextState < currentState]) | ||
defaultItem: [ | ||
nextState < currentState, | ||
|
||
// zero out all other receivers from state actions... | ||
// even though out-of-state is unreachable, | ||
// we don't want any inferred latches | ||
..._states | ||
.map((state) => state.actions) | ||
.flattened | ||
.map((conditional) => conditional.receivers) | ||
.flattened | ||
.toSet() | ||
.map((receiver) => receiver < 0) | ||
]) | ||
]); | ||
|
||
Sequential(clk, [ | ||
|
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