summaryrefslogtreecommitdiff
path: root/src/main/scala/chisel3/util
diff options
context:
space:
mode:
authorducky2017-02-01 16:07:09 -0800
committerRichard Lin2017-02-07 16:24:17 -0800
commit8d2fff4eff3ba0f92437b290985b35afbb0ed565 (patch)
tree97b3f62d73c61ceb12ccb6bd684e63df5be8ed0d /src/main/scala/chisel3/util
parentad20406f301e04075e051147092cf9c12a6a6ca8 (diff)
Name all the things
Diffstat (limited to 'src/main/scala/chisel3/util')
-rw-r--r--src/main/scala/chisel3/util/Arbiter.scala3
-rw-r--r--src/main/scala/chisel3/util/CircuitMath.scala2
-rw-r--r--src/main/scala/chisel3/util/Counter.scala3
-rw-r--r--src/main/scala/chisel3/util/Decoupled.scala6
-rw-r--r--src/main/scala/chisel3/util/LFSR.scala2
-rw-r--r--src/main/scala/chisel3/util/Valid.scala3
6 files changed, 19 insertions, 0 deletions
diff --git a/src/main/scala/chisel3/util/Arbiter.scala b/src/main/scala/chisel3/util/Arbiter.scala
index 7e049c95..bbd8dd33 100644
--- a/src/main/scala/chisel3/util/Arbiter.scala
+++ b/src/main/scala/chisel3/util/Arbiter.scala
@@ -6,6 +6,7 @@
package chisel3.util
import chisel3._
+import chisel3.internal.naming.chiselName // can't use chisel3_ version because of compile order
// TODO: remove this once we have CompileOptions threaded through the macro system.
import chisel3.core.ExplicitCompileOptions.NotStrict
@@ -97,6 +98,7 @@ class LockingArbiter[T <: Data](gen: T, n: Int, count: Int, needsLock: Option[T
* consumer.io.in <> arb.io.out
* }}}
*/
+@chiselName
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.
@@ -109,6 +111,7 @@ class RRArbiter[T <: Data](gen:T, n: Int) extends LockingRRArbiter[T](gen, n, 1)
* consumer.io.in <> arb.io.out
* }}}
*/
+@chiselName
class Arbiter[T <: Data](gen: T, n: Int) extends Module {
val io = IO(new ArbiterIO(gen, n))
diff --git a/src/main/scala/chisel3/util/CircuitMath.scala b/src/main/scala/chisel3/util/CircuitMath.scala
index b5f491ef..53d47694 100644
--- a/src/main/scala/chisel3/util/CircuitMath.scala
+++ b/src/main/scala/chisel3/util/CircuitMath.scala
@@ -6,6 +6,7 @@
package chisel3.util
import chisel3._
+import chisel3.internal.naming.chiselName // can't use chisel3_ version because of compile order
/** Returns the base-2 integer logarithm of an UInt.
*
@@ -21,6 +22,7 @@ import chisel3._
object Log2 {
/** Returns the base-2 integer logarithm of the least-significant `width` bits of an UInt.
*/
+ @chiselName
def apply(x: Bits, width: Int): UInt = {
if (width < 2) {
0.U
diff --git a/src/main/scala/chisel3/util/Counter.scala b/src/main/scala/chisel3/util/Counter.scala
index 6d59eaaf..66dd1127 100644
--- a/src/main/scala/chisel3/util/Counter.scala
+++ b/src/main/scala/chisel3/util/Counter.scala
@@ -3,6 +3,7 @@
package chisel3.util
import chisel3._
+import chisel3.internal.naming.chiselName // can't use chisel3_ version because of compile order
//import chisel3.core.ExplicitCompileOptions.Strict
/** A counter module
@@ -10,6 +11,7 @@ import chisel3._
* @param n number of counts before the counter resets (or one more than the
* maximum output value of the counter), need not be a power of two
*/
+@chiselName
class Counter(val n: Int) {
require(n >= 0)
val value = if (n > 1) Reg(init=0.U(log2Up(n).W)) else 0.U
@@ -53,6 +55,7 @@ object Counter
* }
* }}}
*/
+ @chiselName
def apply(cond: Bool, n: Int): (UInt, Bool) = {
val c = new Counter(n)
var wrap: Bool = null
diff --git a/src/main/scala/chisel3/util/Decoupled.scala b/src/main/scala/chisel3/util/Decoupled.scala
index 2e874a1f..ba111bfc 100644
--- a/src/main/scala/chisel3/util/Decoupled.scala
+++ b/src/main/scala/chisel3/util/Decoupled.scala
@@ -6,6 +6,8 @@
package chisel3.util
import chisel3._
+import chisel3.internal.naming._ // can't use chisel3_ version because of compile order
+
// TODO: remove this once we have CompileOptions threaded through the macro system.
import chisel3.core.ExplicitCompileOptions.NotStrict
@@ -85,6 +87,7 @@ object Decoupled
*
* @note unsafe (and will error) on the producer (input) side of an IrrevocableIO
*/
+ @chiselName
def apply[T <: Data](irr: IrrevocableIO[T]): DecoupledIO[T] = {
require(irr.bits.flatten forall (_.dir == OUTPUT), "Only safe to cast produced Irrevocable bits to Decoupled.")
val d = Wire(new DecoupledIO(irr.bits))
@@ -164,6 +167,7 @@ class QueueIO[T <: Data](gen: T, entries: Int) extends Bundle
* consumer.io.in <> q.io.deq
* }}}
*/
+@chiselName
class Queue[T <: Data](gen: T,
val entries: Int,
pipe: Boolean = false,
@@ -240,6 +244,7 @@ extends Module(override_reset=override_reset) {
object Queue
{
/** Create a queue and supply a DecoupledIO containing the product. */
+ @chiselName
def apply[T <: Data](
enq: ReadyValidIO[T],
entries: Int = 2,
@@ -257,6 +262,7 @@ object Queue
* Irrevocable semantics; we didn't want to change the return type of
* apply() for backwards compatibility reasons.
*/
+ @chiselName
def irrevocable[T <: Data](
enq: ReadyValidIO[T],
entries: Int = 2,
diff --git a/src/main/scala/chisel3/util/LFSR.scala b/src/main/scala/chisel3/util/LFSR.scala
index 83dc907d..94c340c4 100644
--- a/src/main/scala/chisel3/util/LFSR.scala
+++ b/src/main/scala/chisel3/util/LFSR.scala
@@ -6,6 +6,7 @@
package chisel3.util
import chisel3._
+import chisel3.internal.naming.chiselName // can't use chisel3_ version because of compile order
//import chisel3.core.ExplicitCompileOptions.Strict
// scalastyle:off magic.number
@@ -15,6 +16,7 @@ object LFSR16 {
*
* @param increment optional control to gate when the LFSR updates.
*/
+ @chiselName
def apply(increment: Bool = true.B): UInt = {
val width = 16
val lfsr = Reg(init=1.U(width.W))
diff --git a/src/main/scala/chisel3/util/Valid.scala b/src/main/scala/chisel3/util/Valid.scala
index 0229b7f8..0bfe7cb3 100644
--- a/src/main/scala/chisel3/util/Valid.scala
+++ b/src/main/scala/chisel3/util/Valid.scala
@@ -6,6 +6,8 @@
package chisel3.util
import chisel3._
+import chisel3.internal.naming.chiselName // can't use chisel3_ version because of compile order
+
// TODO: remove this once we have CompileOptions threaded through the macro system.
import chisel3.core.ExplicitCompileOptions.NotStrict
@@ -34,6 +36,7 @@ object Valid {
*/
object Pipe
{
+ @chiselName
def apply[T <: Data](enqValid: Bool, enqBits: T, latency: Int): Valid[T] = {
if (latency == 0) {
val out = Wire(Valid(enqBits))