diff options
Diffstat (limited to 'src/main/scala/Chisel/util')
| -rw-r--r-- | src/main/scala/Chisel/util/Counter.scala | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/main/scala/Chisel/util/Counter.scala b/src/main/scala/Chisel/util/Counter.scala index e4a8e95b..356cedc8 100644 --- a/src/main/scala/Chisel/util/Counter.scala +++ b/src/main/scala/Chisel/util/Counter.scala @@ -3,10 +3,14 @@ package Chisel /** A counter module - * @param n The maximum value of the counter, does not have to be power of 2 + * @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 */ class Counter(val n: Int) { val value = if (n == 1) UInt(0) else Reg(init=UInt(0, log2Up(n))) + /** Increment the counter this cycle. Returns whether the counter is at its + * maximum (and will wrap around on the next inc() call). + */ def inc(): Bool = { if (n == 1) { Bool(true) |
