Skip to content

Commit

Permalink
Make uselessly public fields in utils private
Browse files Browse the repository at this point in the history
  • Loading branch information
jackkoenig committed Jan 27, 2017
1 parent df751cf commit 286696c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
20 changes: 10 additions & 10 deletions src/main/scala/chisel3/util/Arbiter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ private object ArbiterCtrl {
}

abstract class LockingArbiterLike[T <: Data](gen: T, n: Int, count: Int, needsLock: Option[T => Bool]) extends Module {
def grant: Seq[Bool]
def choice: UInt
protected def grant: Seq[Bool]
protected def choice: UInt
val io = IO(new ArbiterIO(gen, n))

io.chosen := choice
Expand Down Expand Up @@ -62,16 +62,16 @@ abstract class LockingArbiterLike[T <: Data](gen: T, n: Int, count: Int, needsLo

class LockingRRArbiter[T <: Data](gen: T, n: Int, count: Int, needsLock: Option[T => Bool] = None)
extends LockingArbiterLike[T](gen, n, count, needsLock) {
lazy val lastGrant = RegEnable(io.chosen, io.out.fire())
lazy val grantMask = (0 until n).map(_.asUInt > lastGrant)
lazy val validMask = io.in zip grantMask map { case (in, g) => in.valid && g }
private lazy val lastGrant = RegEnable(io.chosen, io.out.fire())
private lazy val grantMask = (0 until n).map(_.asUInt > lastGrant)
private lazy val validMask = io.in zip grantMask map { case (in, g) => in.valid && g }

override def grant: Seq[Bool] = {
override protected def grant: Seq[Bool] = {
val ctrl = ArbiterCtrl((0 until n).map(i => validMask(i)) ++ io.in.map(_.valid))
(0 until n).map(i => ctrl(i) && grantMask(i) || ctrl(i + n))
}

override lazy val choice = Wire(init=(n-1).asUInt)
override protected lazy val choice = Wire(init=(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)
Expand All @@ -80,9 +80,9 @@ class LockingRRArbiter[T <: Data](gen: T, n: Int, count: Int, needsLock: Option[

class LockingArbiter[T <: Data](gen: T, n: Int, count: Int, needsLock: Option[T => Bool] = None)
extends LockingArbiterLike[T](gen, n, count, needsLock) {
def grant: Seq[Bool] = ArbiterCtrl(io.in.map(_.valid))
protected def grant: Seq[Bool] = ArbiterCtrl(io.in.map(_.valid))

override lazy val choice = Wire(init=(n-1).asUInt)
override protected lazy val choice = Wire(init=(n-1).asUInt)
for (i <- n-2 to 0 by -1)
when (io.in(i).valid) { choice := i.asUInt }
}
Expand Down Expand Up @@ -121,7 +121,7 @@ class Arbiter[T <: Data](gen: T, n: Int) extends Module {
}
}

val grant = ArbiterCtrl(io.in.map(_.valid))
private val grant = ArbiterCtrl(io.in.map(_.valid))
for ((in, g) <- io.in zip grant)
in.ready := g && io.out.ready
io.out.valid := !grant.last || io.in.last.valid
Expand Down
20 changes: 10 additions & 10 deletions src/main/scala/chisel3/util/Decoupled.scala
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,16 @@ extends Module(override_reset=override_reset) {

val io = IO(new QueueIO(gen, entries))

val ram = Mem(entries, gen)
val enq_ptr = Counter(entries)
val deq_ptr = Counter(entries)
val maybe_full = Reg(init=false.B)
private val ram = Mem(entries, gen)
private val enq_ptr = Counter(entries)
private val deq_ptr = Counter(entries)
private val maybe_full = Reg(init=false.B)

val ptr_match = enq_ptr.value === deq_ptr.value
val empty = ptr_match && !maybe_full
val full = ptr_match && maybe_full
val do_enq = Wire(init=io.enq.fire())
val do_deq = Wire(init=io.deq.fire())
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())

when (do_enq) {
ram(enq_ptr.value) := io.enq.bits
Expand Down Expand Up @@ -214,7 +214,7 @@ extends Module(override_reset=override_reset) {
when (io.deq.ready) { io.enq.ready := true.B }
}

val ptr_diff = enq_ptr.value - deq_ptr.value
private val ptr_diff = enq_ptr.value - deq_ptr.value
if (isPow2(entries)) {
io.count := Cat(maybe_full && ptr_match, ptr_diff)
} else {
Expand Down

0 comments on commit 286696c

Please sign in to comment.