Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add requirements to Queue class #1176

Merged
merged 3 commits into from
Sep 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/main/scala/chisel3/util/Decoupled.scala
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ class Queue[T <: Data](gen: T,
flow: Boolean = false)
(implicit compileOptions: chisel3.CompileOptions)
extends Module() {

require(entries > -1, "Queue must have non-negative number of entries")
require(entries != 0, "Use companion object Queue.apply for zero entries")
val genType = if (compileOptions.declaredTypeMustBeUnbound) {
requireIsChiselType(gen)
gen
Expand Down Expand Up @@ -283,7 +284,6 @@ object Queue
enq.ready := deq.ready
deq
} else {
require(entries > 0)
val q = Module(new Queue(chiselTypeOf(enq.bits), entries, pipe, flow))
q.io.enq.valid := enq.valid // not using <> so that override is allowed
q.io.enq.bits := enq.bits
Expand All @@ -302,9 +302,9 @@ object Queue
enq: ReadyValidIO[T],
entries: Int = 2,
pipe: Boolean = false,
flow: Boolean = false): IrrevocableIO[T] = {
require(entries > 0) // Zero-entry queues don't guarantee Irrevocability
flow: Boolean = false): IrrevocableIO[T] = {
val deq = apply(enq, entries, pipe, flow)
require(entries > 0, "Zero-entry queues don't guarantee Irrevocability")
val irr = Wire(new IrrevocableIO(deq.bits))
irr.bits := deq.bits
irr.valid := deq.valid
Expand Down