diff options
| author | Richard Lin | 2017-08-17 17:24:02 -0700 |
|---|---|---|
| committer | Jack Koenig | 2017-08-17 17:24:02 -0700 |
| commit | 6e12ed9fd7a771eb30f44b8e1c4ab33f6ad8e0a6 (patch) | |
| tree | 0ff452193d515adc32ecccacb2b58daa9a1d95cb /src/main/scala/chisel3/util | |
| parent | 802cfc4405c28ae212a955a92c7a6ad2d2b6f0c2 (diff) | |
More of the bindings refactor (#635)
Rest of the binding refactor
Diffstat (limited to 'src/main/scala/chisel3/util')
| -rw-r--r-- | src/main/scala/chisel3/util/Arbiter.scala | 4 | ||||
| -rw-r--r-- | src/main/scala/chisel3/util/BitPat.scala | 9 | ||||
| -rw-r--r-- | src/main/scala/chisel3/util/Decoupled.scala | 21 |
3 files changed, 25 insertions, 9 deletions
diff --git a/src/main/scala/chisel3/util/Arbiter.scala b/src/main/scala/chisel3/util/Arbiter.scala index b99397e2..ba257b41 100644 --- a/src/main/scala/chisel3/util/Arbiter.scala +++ b/src/main/scala/chisel3/util/Arbiter.scala @@ -70,7 +70,7 @@ class LockingRRArbiter[T <: Data](gen: T, n: Int, count: Int, needsLock: Option[ (0 until n).map(i => ctrl(i) && grantMask(i) || ctrl(i + n)) } - override protected lazy val choice = Wire(init=(n-1).asUInt) + override protected lazy val choice = WireInit((n-1).asUInt) for (i <- n-2 to 0 by -1) when (io.in(i).valid) { choice := i.asUInt } for (i <- n-1 to 1 by -1) @@ -81,7 +81,7 @@ class LockingArbiter[T <: Data](gen: T, n: Int, count: Int, needsLock: Option[T extends LockingArbiterLike[T](gen, n, count, needsLock) { protected def grant: Seq[Bool] = ArbiterCtrl(io.in.map(_.valid)) - override protected lazy val choice = Wire(init=(n-1).asUInt) + override protected lazy val choice = WireInit((n-1).asUInt) for (i <- n-2 to 0 by -1) when (io.in(i).valid) { choice := i.asUInt } } diff --git a/src/main/scala/chisel3/util/BitPat.scala b/src/main/scala/chisel3/util/BitPat.scala index 54ded155..c962813d 100644 --- a/src/main/scala/chisel3/util/BitPat.scala +++ b/src/main/scala/chisel3/util/BitPat.scala @@ -94,13 +94,16 @@ sealed class BitPat(val value: BigInt, val mask: BigInt, width: Int) { @deprecated("Use '=/=', which avoids potential precedence problems", "chisel3") def != (that: UInt): Bool = macro SourceInfoTransform.thatArg - def do_=== (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = { // scalastyle:ignore method.name + def do_=== (that: UInt) // scalastyle:ignore method.name + (implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = { value.asUInt === (that & mask.asUInt) } - def do_=/= (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = { // scalastyle:ignore method.name + def do_=/= (that: UInt) // scalastyle:ignore method.name + (implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = { !(this === that) } - def do_!= (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = { // scalastyle:ignore method.name + def do_!= (that: UInt) // scalastyle:ignore method.name + (implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = { this =/= that } } diff --git a/src/main/scala/chisel3/util/Decoupled.scala b/src/main/scala/chisel3/util/Decoupled.scala index b9e1e7ed..5b4ed19d 100644 --- a/src/main/scala/chisel3/util/Decoupled.scala +++ b/src/main/scala/chisel3/util/Decoupled.scala @@ -184,6 +184,7 @@ class Queue[T <: Data](gen: T, val entries: Int, pipe: Boolean = false, flow: Boolean = false) + (implicit compileOptions: chisel3.core.CompileOptions) extends Module() { @deprecated("Module constructor with override _reset deprecated, use withReset", "chisel3") def this(gen: T, entries: Int, pipe: Boolean, flow: Boolean, override_reset: Option[Bool]) = { @@ -196,9 +197,21 @@ class Queue[T <: Data](gen: T, this.override_reset = Some(_reset) } - val io = IO(new QueueIO(gen, entries)) + val genType = if (compileOptions.declaredTypeMustBeUnbound) { + experimental.requireIsChiselType(gen) + gen + } else { + if (DataMirror.internal.isSynthesizable(gen)) { + println("WARNING: gen in new Queue(gen, ...) must be a Chisel type, not hardware") + gen.chiselCloneType + } else { + gen + } + } + + val io = IO(new QueueIO(genType, entries)) - private val ram = Mem(entries, gen) + private val ram = Mem(entries, genType) private val enq_ptr = Counter(entries) private val deq_ptr = Counter(entries) private val maybe_full = RegInit(false.B) @@ -206,8 +219,8 @@ class Queue[T <: Data](gen: T, private val ptr_match = enq_ptr.value === deq_ptr.value private val empty = ptr_match && !maybe_full private val full = ptr_match && maybe_full - private val do_enq = Wire(init=io.enq.fire()) - private val do_deq = Wire(init=io.deq.fire()) + private val do_enq = WireInit(io.enq.fire()) + private val do_deq = WireInit(io.deq.fire()) when (do_enq) { ram(enq_ptr.value) := io.enq.bits |
