PopCount

chisel3.util.PopCount
object PopCount

Returns the number of bits set (value is 1 or true) in the input signal.

Attributes

Example
PopCount(Seq(true.B, false.B, true.B, true.B))  // evaluates to 3.U
PopCount(Seq(false.B, false.B, true.B, false.B))  // evaluates to 1.U
PopCount("b1011".U)  // evaluates to 3.U
PopCount("b0010".U)  // evaluates to 1.U
PopCount(myUIntWire)  // dynamic count
Source
Bitwise.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
PopCount.type

Members list

Value members

Concrete methods

def atLeast(n: Int, x: UInt)(implicit sourceInfo: SourceInfo): Bool

Implements PopCount(x)>=n with less deep circuitry in case n=0,1,2,x.width-1,x.width

Implements PopCount(x)>=n with less deep circuitry in case n=0,1,2,x.width-1,x.width

Value parameters

n

Int Static value that PopCount(x) is compared against

x

UInt to PopCount

Attributes

Returns

true.B when x has n or more bits set

Source
Bitwise.scala
def atLeast(n: Int, x: Iterable[Bool])(implicit sourceInfo: SourceInfo): Bool

Implements PopCount(x)>=n with less deep circuitry in case n=0,1,2,x.width-1,x.width

Implements PopCount(x)>=n with less deep circuitry in case n=0,1,2,x.width-1,x.width

Value parameters

n

Int Static value that PopCount(x) is compared against

x

Seq/Vec of Bool to PopCount

Attributes

Returns

true.B when x has n or more bits set

Source
Bitwise.scala
def equalTo(n: Int, x: UInt)(implicit sourceInfo: SourceInfo): Bool

Implements PopCount(x)==n with less deep circuitry in case n=0,1,x.width-1,x.width

Implements PopCount(x)==n with less deep circuitry in case n=0,1,x.width-1,x.width

Value parameters

n

Int Static value that PopCount(x) is compared against

x

UInt to PopCount

Attributes

Returns

true.B when x has exactly n bits set

Source
Bitwise.scala
def equalTo(n: Int, x: Iterable[Bool])(implicit sourceInfo: SourceInfo): Bool

Implements PopCount(x)==n with less deep circuitry in case n=0,1,x.width-1,x.width

Implements PopCount(x)==n with less deep circuitry in case n=0,1,x.width-1,x.width

Value parameters

n

Int Static value that PopCount(x) is compared against

x

Seq/Vec of Bool to PopCount

Attributes

Returns

true.B when x has exactly n bits set

Source
Bitwise.scala
def greaterThan(n: Int, x: UInt)(implicit sourceInfo: SourceInfo): Bool

Implements PopCount(x)>n with less deep circuitry in case n=0,1,x.width-1

Implements PopCount(x)>n with less deep circuitry in case n=0,1,x.width-1

Value parameters

n

Int Static value that PopCount(x) is compared against

x

UInt to PopCount

Attributes

Returns

true.B when x has more than n bits set

Source
Bitwise.scala
def greaterThan(n: Int, x: Iterable[Bool])(implicit sourceInfo: SourceInfo): Bool

Implements PopCount(x)>n with less deep circuitry in case n=0,1,x.width-1

Implements PopCount(x)>n with less deep circuitry in case n=0,1,x.width-1

Value parameters

n

Int Static value that PopCount(x) is compared against

x

Seq/Vec of Bool to PopCount

Attributes

Returns

true.B when x has more than n bits set

Source
Bitwise.scala

Inherited methods

def apply(in: Bits)(using SourceInfo): UInt

Attributes

Inherited from:
PopCount$Intf (hidden)
Source
BitwiseIntf.scala
def apply(in: Iterable[Bool])(using SourceInfo): UInt

Attributes

Inherited from:
PopCount$Intf (hidden)
Source
BitwiseIntf.scala