summaryrefslogtreecommitdiff
path: root/src/main/scala/chisel3/util/Counter.scala
diff options
context:
space:
mode:
authorJim Lawson2016-07-20 14:49:35 -0700
committerJim Lawson2016-07-20 14:49:35 -0700
commit2dce378deda1cc33833eb378c89a1c5415817bae (patch)
treee3bc5361030d63e017d065491e9e7e4cf788fe3c /src/main/scala/chisel3/util/Counter.scala
parent28e80311f172ae4d1d477e8bb47ca3719c9a8fc5 (diff)
Distinguish between ?Int.Lit and ?Int.width
Diffstat (limited to 'src/main/scala/chisel3/util/Counter.scala')
-rw-r--r--src/main/scala/chisel3/util/Counter.scala10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/main/scala/chisel3/util/Counter.scala b/src/main/scala/chisel3/util/Counter.scala
index 40615769..05d8fba8 100644
--- a/src/main/scala/chisel3/util/Counter.scala
+++ b/src/main/scala/chisel3/util/Counter.scala
@@ -10,17 +10,17 @@ import chisel3._
*/
class Counter(val n: Int) {
require(n >= 0)
- val value = if (n > 1) Reg(init=UInt(0, log2Up(n))) else UInt(0)
+ val value = if (n > 1) Reg(init=UInt(0, log2Up(n))) else UInt.Lit(0)
/** Increment the counter, returning whether the counter currently is at the
* maximum and will wrap. The incremented value is registered and will be
* visible on the next cycle.
*/
def inc(): Bool = {
if (n > 1) {
- val wrap = value === UInt(n-1)
- value := value + UInt(1)
+ val wrap = value === UInt.Lit(n-1)
+ value := value + UInt.Lit(1)
if (!isPow2(n)) {
- when (wrap) { value := UInt(0) }
+ when (wrap) { value := UInt.Lit(0) }
}
wrap
} else {
@@ -33,7 +33,7 @@ class Counter(val n: Int) {
* Example Usage:
* {{{ val countOn = Bool(true) // increment counter every clock cycle
* val myCounter = Counter(countOn, n)
- * when ( myCounter.value === UInt(3) ) { ... } }}}*/
+ * when ( myCounter.value === UInt.Lit(3) ) { ... } }}}*/
object Counter
{
def apply(n: Int): Counter = new Counter(n)