ShiftRegInit: use the rocket-chip version since it is there now
[sifive-blocks.git] / src / main / scala / devices / mockaon / MockAONPeriphery.scala
index 8b6303e2ffb32f03abe1e8cecfe88aef2548216c..b20bee24e35cc3abc6b2a676ace53ca6dde3f590 100644 (file)
@@ -3,6 +3,7 @@ package sifive.blocks.devices.mockaon
 
 import Chisel._
 import freechips.rocketchip.config.Field
+import freechips.rocketchip.util.SynchronizerShiftReg
 import freechips.rocketchip.coreplex.{HasPeripheryBus, HasInterruptBus}
 import freechips.rocketchip.devices.debug.HasPeripheryDebug
 import freechips.rocketchip.devices.tilelink.HasPeripheryClint
@@ -42,7 +43,12 @@ trait HasPeripheryMockAONModuleImp extends LazyMultiIOModuleImp with HasPeripher
   outer.aon.module.clock := Bool(false).asClock
   outer.aon.module.reset := Bool(true)
 
-  outer.clint.module.io.rtcTick := outer.aon.module.io.rtc.asUInt.toBool
+  // Synchronize the external toggle into the clint
+  val rtc_sync = SynchronizerShiftReg(outer.aon.module.io.rtc.asUInt.toBool, 3, Some("rtc"))
+  val rtc_last = Reg(init = Bool(false), next=rtc_sync)
+  val rtc_tick = Reg(init = Bool(false), next=(rtc_sync & (~rtc_last)))
+
+  outer.clint.module.io.rtcTick := rtc_tick
 
   outer.aon.module.io.ndreset := outer.debug.module.io.ctrl.ndreset
 }