From 71fcec0e1245b1515da903b8d96dbd50e0a4dbb4 Mon Sep 17 00:00:00 2001 From: Wenting Zhang Date: Thu, 5 Jan 2023 14:52:03 -0500 Subject: [PATCH] Fix certain UART FFs not being initialized during reset --- src/main/scala/devices/uart/UARTRx.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/devices/uart/UARTRx.scala b/src/main/scala/devices/uart/UARTRx.scala index 60b90e6..c0c3b69 100755 --- a/src/main/scala/devices/uart/UARTRx.scala +++ b/src/main/scala/devices/uart/UARTRx.scala @@ -24,7 +24,7 @@ class UARTRx(c: UARTParams) extends Module { val debounce_max = (debounce === UInt(3)) val debounce_min = (debounce === UInt(0)) - val prescaler = Reg(UInt(width = c.divisorBits - c.oversample + 1)) + val prescaler = Reg(init = UInt(0, width = c.divisorBits - c.oversample + 1)) val start = Wire(init = Bool(false)) val pulse = (prescaler === UInt(0)) @@ -33,7 +33,7 @@ class UARTRx(c: UARTParams) extends Module { val data_count = Reg(UInt(width = dataCountBits)) val data_last = (data_count === UInt(0)) val parity_bit = (data_count === UInt(1)) && io.enparity.getOrElse(false.B) - val sample_count = Reg(UInt(width = c.oversample)) + val sample_count = Reg(init = UInt(0, width = c.oversample)) val sample_mid = (sample_count === UInt((c.oversampleFactor - c.nSamples + 1) >> 1)) val sample_last = (sample_count === UInt(0)) val countdown = Cat(data_count, sample_count) - UInt(1)