summaryrefslogtreecommitdiff
path: root/src/main/scala/chisel3/util/Arbiter.scala
diff options
context:
space:
mode:
authorJim Lawson2016-09-23 08:19:43 -0700
committerGitHub2016-09-23 08:19:43 -0700
commit785620b1403d827986bf60c2a001d8d6f71eed72 (patch)
tree1c1a0b14b041e544da3ff8176aba200604a131b3 /src/main/scala/chisel3/util/Arbiter.scala
parentb18e98ba2d058c7dd24f96f005486b70c856aeca (diff)
parentdecb2ee0f0bb8223f0b2b067b88ed90b71473a28 (diff)
Merge pull request #291 from ucb-bar/utilscaladocs
Scaladocs for utils
Diffstat (limited to 'src/main/scala/chisel3/util/Arbiter.scala')
-rw-r--r--src/main/scala/chisel3/util/Arbiter.scala45
1 files changed, 26 insertions, 19 deletions
diff --git a/src/main/scala/chisel3/util/Arbiter.scala b/src/main/scala/chisel3/util/Arbiter.scala
index eb541977..58ba1188 100644
--- a/src/main/scala/chisel3/util/Arbiter.scala
+++ b/src/main/scala/chisel3/util/Arbiter.scala
@@ -7,16 +7,21 @@ package chisel3.util
import chisel3._
-/** An I/O bundle for the Arbiter */
+/** IO bundle definition for an Arbiter, which takes some number of ready-valid inputs and outputs
+ * (selects) at most one.
+ *
+ * @param gen data type
+ * @param n number of inputs
+ */
class ArbiterIO[T <: Data](gen: T, n: Int) extends Bundle {
val in = Vec(n, Decoupled(gen)).flip
val out = Decoupled(gen)
val chosen = UInt(OUTPUT, log2Up(n))
}
-/** Arbiter Control determining which producer has access */
-private object ArbiterCtrl
-{
+/** Arbiter Control determining which producer has access
+ */
+private object ArbiterCtrl {
def apply(request: Seq[Bool]): Seq[Bool] = request.length match {
case 0 => Seq()
case 1 => Seq(Bool(true))
@@ -81,25 +86,27 @@ class LockingArbiter[T <: Data](gen: T, n: Int, count: Int, needsLock: Option[T
}
/** Hardware module that is used to sequence n producers into 1 consumer.
- Producers are chosen in round robin order.
-
- Example usage:
- val arb = new RRArbiter(2, UInt())
- arb.io.in(0) <> producer0.io.out
- arb.io.in(1) <> producer1.io.out
- consumer.io.in <> arb.io.out
+ * Producers are chosen in round robin order.
+ *
+ * @example {{{
+ * val arb = new RRArbiter(2, UInt())
+ * arb.io.in(0) <> producer0.io.out
+ * arb.io.in(1) <> producer1.io.out
+ * consumer.io.in <> arb.io.out
+ * }}}
*/
class RRArbiter[T <: Data](gen:T, n: Int) extends LockingRRArbiter[T](gen, n, 1)
/** Hardware module that is used to sequence n producers into 1 consumer.
- Priority is given to lower producer
-
- Example usage:
- val arb = Module(new Arbiter(2, UInt()))
- arb.io.in(0) <> producer0.io.out
- arb.io.in(1) <> producer1.io.out
- consumer.io.in <> arb.io.out
- */
+ * Priority is given to lower producer.
+ *
+ * @example {{{
+ * val arb = Module(new Arbiter(2, UInt()))
+ * arb.io.in(0) <> producer0.io.out
+ * arb.io.in(1) <> producer1.io.out
+ * consumer.io.in <> arb.io.out
+ * }}}
+ */
class Arbiter[T <: Data](gen: T, n: Int) extends Module {
val io = new ArbiterIO(gen, n)