From 609fd97a7125d1f0adda089306fcd8e6d239d4e9 Mon Sep 17 00:00:00 2001 From: "Wesley W. Terpstra" Date: Thu, 6 Oct 2016 22:41:27 -0700 Subject: [PATCH] util: AsyncQueue detect power-down/reset of non-empty queue --- src/main/scala/util/AsyncQueue.scala | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/scala/util/AsyncQueue.scala b/src/main/scala/util/AsyncQueue.scala index 967fdc02..a613cefb 100644 --- a/src/main/scala/util/AsyncQueue.scala +++ b/src/main/scala/util/AsyncQueue.scala @@ -58,6 +58,9 @@ class AsyncQueueSource[T <: Data](gen: T, depth: Int, sync: Int) extends Module io.widx := widx_reg io.mem := mem + + // It is a fatal error to reset half a Queue while it still has data + assert (reset_n || widx === ridx) } class AsyncQueueSink[T <: Data](gen: T, depth: Int, sync: Int) extends Module { @@ -96,6 +99,9 @@ class AsyncQueueSink[T <: Data](gen: T, depth: Int, sync: Int) extends Module { val ridx_reg = AsyncResetReg(ridx) io.ridx := ridx_reg + + // It is a fatal error to reset half a Queue while it still has data + assert (reset_n || widx === ridx) } class AsyncQueue[T <: Data](gen: T, depth: Int = 8, sync: Int = 3) extends Crossing[T] {