diff options
| author | ducky | 2016-11-17 13:01:03 -0800 |
|---|---|---|
| committer | ducky | 2016-11-21 13:31:12 -0800 |
| commit | 54d3f8dc054e55dfbd01d1aa034169a3dabe89f2 (patch) | |
| tree | 7f6f9de04de6eb08878ac46be339fefc2a71395f /src/main/scala/chisel3/util/Counter.scala | |
| parent | cd904da0aa0e96ba679906a3ee5dbdc068eace48 (diff) | |
Restyle a lot of test code, mainly with regex
Diffstat (limited to 'src/main/scala/chisel3/util/Counter.scala')
| -rw-r--r-- | src/main/scala/chisel3/util/Counter.scala | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/main/scala/chisel3/util/Counter.scala b/src/main/scala/chisel3/util/Counter.scala index ba66d667..6d59eaaf 100644 --- a/src/main/scala/chisel3/util/Counter.scala +++ b/src/main/scala/chisel3/util/Counter.scala @@ -12,7 +12,7 @@ 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=0.U(log2Up(n).W)) else 0.U /** Increment the counter, returning whether the counter currently is at the * maximum and will wrap. The incremented value is registered and will be @@ -20,14 +20,14 @@ class Counter(val n: Int) { */ def inc(): Bool = { if (n > 1) { - val wrap = value === UInt(n-1) - value := value + UInt(1) + val wrap = value === (n-1).asUInt + value := value + 1.U if (!isPow2(n)) { - when (wrap) { value := UInt(0) } + when (wrap) { value := 0.U } } wrap } else { - Bool(true) + true.B } } } @@ -46,9 +46,9 @@ object Counter * maximum and the condition is true). * * @example {{{ - * val countOn = Bool(true) // increment counter every clock cycle + * val countOn = true.B // increment counter every clock cycle * val (counterValue, counterWrap) = Counter(countOn, 4) - * when (counterValue === UInt(3)) { + * when (counterValue === 3.U) { * ... * } * }}} |
