-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2666 from chipsalliance/diplo-reset-sync
[prci] Add a pair of diplomatic reset synchronizers
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// See LICENSE for license details. | ||
package freechips.rocketchip.prci | ||
|
||
import freechips.rocketchip.config.{Parameters} | ||
import freechips.rocketchip.diplomacy._ | ||
import freechips.rocketchip.util.{ResetCatchAndSync} | ||
|
||
/** | ||
* Synchronizes the reset of a diplomatic clock-reset pair to its accompanying clock. | ||
*/ | ||
class ResetSynchronizer(implicit p: Parameters) extends LazyModule { | ||
val node = ClockIdentityNode() | ||
lazy val module = new LazyRawModuleImp(this) { | ||
(node.out zip node.in).map { case ((o, _), (i, _)) => | ||
o.clock := i.clock | ||
o.reset := ResetCatchAndSync(i.clock, i.reset.asBool) | ||
} | ||
} | ||
} | ||
|
||
object ResetSynchronizer { | ||
def apply()(implicit p: Parameters, valName: ValName) = LazyModule(new ResetSynchronizer()).node | ||
} | ||
|
||
|
||
/** | ||
* Instantiates a reset synchronizer on all clock-reset pairs in a clock group. | ||
*/ | ||
class ClockGroupResetSynchronizer(implicit p: Parameters) extends LazyModule { | ||
val node = ClockGroupIdentityNode() | ||
lazy val module = new LazyRawModuleImp(this) { | ||
(node.out zip node.in).map { case ((oG, _), (iG, _)) => | ||
(oG.member.data zip iG.member.data).foreach { case (o, i) => | ||
o.clock := i.clock | ||
o.reset := ResetCatchAndSync(i.clock, i.reset.asBool) | ||
} | ||
} | ||
} | ||
} | ||
|
||
object ClockGroupResetSynchronizer { | ||
def apply()(implicit p: Parameters, valName: ValName) = LazyModule(new ClockGroupResetSynchronizer()).node | ||
} |