Counter

chisel3.util.Counter
See theCounter companion object

Used to generate an inline (logic directly in the containing Module, no internal Module is created) hardware counter.

Typically instantiated with apply methods in object Counter

Does not create a new Chisel Module

Attributes

Example
 val countOn = true.B // increment counter every clock cycle
 val (counterValue, counterWrap) = Counter(countOn, 4)
 when (counterValue === 3.U) {
   ...
 }
 // Using Scala Range API
 val (counterValue, counterWrap) = Counter(0 until 10 by 2)
 when (counterValue === 4.U) {
   ...
 }
Companion
object
Source
Counter.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Constructors

def this(n: Int)

Creates a counter with the specified number of steps.

Creates a counter with the specified number of steps.

Value parameters

n

number of steps before the counter resets

Attributes

Source
Counter.scala

Concrete methods

def inc(): Bool

Increments the counter by a step.

Increments the counter by a step.

Attributes

Returns

whether the counter will wrap on the next clock cycle

Note

The incremented value is registered and will be visible on the next clock cycle

Source
Counter.scala
def n: Int

Number of counts before the counter resets

Number of counts before the counter resets

Attributes

Note

Only defined for ranges starting at zero with steps of size 1. Use range for other use cases.

Source
Counter.scala
def range: Range

The range of the counter values.

The range of the counter values.

Attributes

Source
Counter.scala
def reset(): Unit

Resets the counter to its initial value

Resets the counter to its initial value

Attributes

Source
Counter.scala

Concrete fields

val value: UInt

The current value of the counter.

The current value of the counter.

Attributes

Source
Counter.scala