diff options
Diffstat (limited to 'src/main/scala/Chisel')
| -rw-r--r-- | src/main/scala/Chisel/Utils.scala | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/src/main/scala/Chisel/Utils.scala b/src/main/scala/Chisel/Utils.scala index 1340e037..4193031e 100644 --- a/src/main/scala/Chisel/Utils.scala +++ b/src/main/scala/Chisel/Utils.scala @@ -451,14 +451,22 @@ class QueueIO[T <: Data](gen: T, entries: Int) extends Bundle val count = UInt(OUTPUT, log2Up(entries + 1)) } -/** A hardware module implmenting a Queue - * @param gen the type of data to queue - * @param entries the max number of entries in the queue - * @param pipe - * @param flow - * @param _reset +/** A hardware module implementing a Queue + * @param gen The type of data to queue + * @param entries The max number of entries in the queue + * @param pipe True if a single entry queue can run at full throughput (like a pipeline). The ''ready'' signals are combinationally coupled. + * @param flow True if the inputs can be consumed on the same cycle +(the inputs "flow" through the queue immediately). The ''valid'' signals are coupled. + * + * Example usage: + * {{{ val q = new Queue(UInt(), 16) + * q.io.enq <> producer.io.out + * consumer.io.in <> q.io.deq }}} */ -class Queue[T <: Data](gen: T, val entries: Int, pipe: Boolean = false, flow: Boolean = false, _reset: Bool = null) extends Module(_reset=_reset) +class Queue[T <: Data](gen: T, val entries: Int, + pipe: Boolean = false, + flow: Boolean = false, + _reset: Bool = null) extends Module(_reset=_reset) { val io = new QueueIO(gen, entries) @@ -494,7 +502,11 @@ class Queue[T <: Data](gen: T, val entries: Int, pipe: Boolean = false, flow: Bo if (isPow2(entries)) { io.count := Cat(maybe_full && ptr_match, ptr_diff) } else { - io.count := Mux(ptr_match, Mux(maybe_full, UInt(entries), UInt(0)), Mux(deq_ptr.value > enq_ptr.value, UInt(entries) + ptr_diff, ptr_diff)) + io.count := Mux(ptr_match, + Mux(maybe_full, + UInt(entries), UInt(0)), + Mux(deq_ptr.value > enq_ptr.value, + UInt(entries) + ptr_diff, ptr_diff)) } } @@ -503,9 +515,9 @@ class Queue[T <: Data](gen: T, val entries: Int, pipe: Boolean = false, flow: Bo from the inputs. Example usage: - val q = new Queue(UInt(), 16) - q.io.enq <> producer.io.out - consumer.io.in <> q.io.deq + {{{ val q = Queue(Decoupled(UInt()), 16) + q.io.enq <> producer.io.out + consumer.io.in <> q.io.deq }}} */ object Queue { |
