Packages

c

chisel3

Bits

sealed abstract class Bits extends Element with ToBoolable

A data type for values represented by a single bitvector. This provides basic bitwise operations.

Source
Bits.scala
Linear Supertypes
ToBoolable, Element, Data, SourceInfoDoc, NamedComponent, HasId, internal.InstanceId, AnyRef, Any
Known Subclasses
Ordering
  1. Grouped
  2. Alphabetic
  3. By Inheritance
Inherited
  1. Bits
  2. ToBoolable
  3. Element
  4. Data
  5. SourceInfoDoc
  6. NamedComponent
  7. HasId
  8. InstanceId
  9. AnyRef
  10. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def do_<<(that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bits

  2. abstract def do_<<(that: Int)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bits

  3. abstract def do_<<(that: BigInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bits

  4. abstract def do_>>(that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bits

  5. abstract def do_>>(that: Int)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bits

  6. abstract def do_>>(that: BigInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bits

  7. abstract def do_asSInt(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt

  8. abstract def do_asUInt(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt

    Definition Classes
    Data
  9. abstract def do_unary_~(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bits

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final macro def ##(that: Bits): UInt

    Concatenation operator

    Concatenation operator

    that

    a hardware component

    returns

    this Bits concatenated to the most significant end of that

    Note

    The width of the returned Bits is width of this + width of that.

  3. final def ##(): Int
    Definition Classes
    AnyRef → Any
  4. final def :=(that: ⇒ Data)(implicit sourceInfo: SourceInfo, connectionCompileOptions: CompileOptions): Unit

    Connect this data to that data mono-directionally and element-wise.

    Connect this data to that data mono-directionally and element-wise.

    This uses the MonoConnect algorithm.

    that

    the data to connect to

    Definition Classes
    Data
  5. final macro def <<(that: UInt): Bits

    Dynamic left shift operator

    Dynamic left shift operator

    that

    a hardware component

    returns

    this Bits dynamically shifted left by that many places, shifting in zeros from the right

    Note

    The width of the returned Bits is width of this + pow(2, width of that) - 1.

  6. final macro def <<(that: Int): Bits

    Static left shift operator

    Static left shift operator

    that

    an amount to shift by

    returns

    this Bits with that many zeros concatenated to its least significant end

    Note

    The width of the returned Bits is width of this + that.

  7. final macro def <<(that: BigInt): Bits

    Static left shift operator

    Static left shift operator

    that

    an amount to shift by

    returns

    this Bits with that many zeros concatenated to its least significant end

    Note

    The width of the returned Bits is width of this + that.

  8. final def <>(that: ⇒ Data)(implicit sourceInfo: SourceInfo, connectionCompileOptions: CompileOptions): Unit

    Connect this data to that data bi-directionally and element-wise.

    Connect this data to that data bi-directionally and element-wise.

    This uses the BiConnect algorithm.

    that

    the data to connect to

    Definition Classes
    Data
  9. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  10. final macro def >>(that: UInt): Bits

    Dynamic right shift operator

    Dynamic right shift operator

    that

    a hardware component

    returns

    this Bits dynamically shifted right by the value of that component, inserting zeros into the most significant bits.

    Note

    The width of the returned Bits is unchanged, i.e., the width of this.

  11. final macro def >>(that: Int): Bits

    Static right shift operator

    Static right shift operator

    that

    an amount to shift by

    returns

    this Bits with that many least significant bits truncated

    Note

    The width of the returned Bits is unchanged, i.e., the width of this.

  12. final macro def >>(that: BigInt): Bits

    Static right shift operator

    Static right shift operator

    that

    an amount to shift by

    returns

    this Bits with that many least significant bits truncated

    Note

    The width of the returned Bits is unchanged, i.e., the width of this.

  13. final macro def apply(x: BigInt, y: BigInt): UInt

    Returns a subset of bits on this Bits from hi to lo (inclusive), statically addressed.

    Returns a subset of bits on this Bits from hi to lo (inclusive), statically addressed.

    x

    the high bit

    y

    the low bit

    returns

    a hardware component contain the requested bits

    Example:
    1. myBits = 0x5 = 0b101
      myBits(1,0) => 0b01  // extracts the two least significant bits
  14. final macro def apply(x: Int, y: Int): UInt

    Returns a subset of bits on this Bits from hi to lo (inclusive), statically addressed.

    Returns a subset of bits on this Bits from hi to lo (inclusive), statically addressed.

    x

    the high bit

    y

    the low bit

    returns

    a hardware component contain the requested bits

    Example:
    1. myBits = 0x5 = 0b101
      myBits(1,0) => 0b01  // extracts the two least significant bits
  15. final macro def apply(x: UInt): Bool

    Returns the specified bit on this wire as a Bool, dynamically addressed.

    Returns the specified bit on this wire as a Bool, dynamically addressed.

    x

    a hardware component whose value will be used for dynamic addressing

    returns

    the specified bit

  16. final macro def apply(x: Int): Bool

    Returns the specified bit on this Bits as a Bool, statically addressed.

    Returns the specified bit on this Bits as a Bool, statically addressed.

    x

    an index

    returns

    the specified bit

    Note

    convenience method allowing direct use of scala.Int without implicits

  17. final macro def apply(x: BigInt): Bool

    Returns the specified bit on this Bits as a Bool, statically addressed.

    Returns the specified bit on this Bits as a Bool, statically addressed.

    x

    an index

    returns

    the specified bit

  18. final macro def asBool(): Bool

    Casts this Bits to a Bool

    Casts this Bits to a Bool

    Definition Classes
    ToBoolable
    Note

    The width must be known and equal to 1

  19. final macro def asBools(): Seq[Bool]

    Returns the contents of this wire as a scala.collection.Seq of Bool.

  20. final macro def asFixedPoint(that: BinaryPoint): FixedPoint

    Reinterpret this Bits as a FixedPoint.

    Reinterpret this Bits as a FixedPoint.

    Note

    The value is not guaranteed to be preserved. For example, a UInt of width 3 and value 7 (0b111) would become a FixedPoint with value -1. The interpretation of the number is also affected by the specified binary point. Caution is advised!

  21. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  22. final macro def asInterval(that: IntervalRange): Interval

    Reinterpret cast as a Interval.

    Reinterpret cast as a Interval.

    Note

    value not guaranteed to be preserved: for example, an UInt of width 3 and value 7 (0b111) would become a FixedInt with value -1, the interpretation of the number is also affected by the specified binary point. Caution advised

  23. final macro def asSInt(): SInt

    Reinterpret this Bits as an SInt

    Reinterpret this Bits as an SInt

    Note

    The arithmetic value is not preserved if the most-significant bit is set. For example, a UInt of width 3 and value 7 (0b111) would become an SInt of width 3 and value -1.

  24. macro def asTypeOf[T <: Data](that: T): T

    Does a reinterpret cast of the bits in this node into the format that provides.

    Does a reinterpret cast of the bits in this node into the format that provides. Returns a new Wire of that type. Does not modify existing nodes.

    x.asTypeOf(that) performs the inverse operation of x := that.toBits.

    Definition Classes
    Data
    Note

    bit widths are NOT checked, may pad or drop bits from input

    ,

    that should have known widths

  25. final macro def asUInt(): UInt

    Reinterpret cast to UInt.

    Reinterpret cast to UInt.

    Definition Classes
    Data
    Note

    value not guaranteed to be preserved: for example, a SInt of width 3 and value -1 (0b111) would become an UInt with value 7

    ,

    Aggregates are recursively packed with the first element appearing in the least-significant bits of the result.

  26. def autoSeed(name: String): Bits.this.type

    Takes the last seed suggested.

    Takes the last seed suggested. Multiple calls to this function will take the last given seed, unless this HasId is a module port (see overridden method in Data.scala).

    If the final computed name conflicts with the final name of another signal, the final name may get uniquified by appending a digit at the end of the name.

    Is a lower priority than suggestName, in that regardless of whether autoSeed was called, suggestName will always take precedence if it was called.

    returns

    this object

    Definition Classes
    Data → HasId
  27. def binding: Option[Binding]
    Attributes
    protected[chisel3]
    Definition Classes
    Data
  28. def bindingToString: String
    Attributes
    protected
    Definition Classes
    Data
  29. def binding_=(target: Binding): Unit
    Attributes
    protected
    Definition Classes
    Data
  30. def circuitName: String
    Attributes
    protected
    Definition Classes
    HasId
  31. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  32. def cloneType: Bits.this.type

    Internal API; Chisel users should look at chisel3.chiselTypeOf(...).

    Internal API; Chisel users should look at chisel3.chiselTypeOf(...).

    cloneType must be defined for any Chisel object extending Data. It is responsible for constructing a basic copy of the object being cloned.

    returns

    a copy of the object.

    Definition Classes
    BitsData
  33. def computeName(defaultPrefix: Option[String], defaultSeed: Option[String]): Option[String]

    Computes the name of this HasId, if one exists

    Computes the name of this HasId, if one exists

    defaultPrefix

    Optionally provide a default prefix for computing the name

    defaultSeed

    Optionally provide default seed for computing the name

    returns

    the name, if it can be computed

    Definition Classes
    HasId
  34. def do_##(that: Bits)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt

  35. final def do_apply(x: BigInt, y: BigInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt

  36. final def do_apply(x: Int, y: Int)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt

  37. final def do_apply(x: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool

  38. final def do_apply(x: Int)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool

  39. final def do_apply(x: BigInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool

  40. final def do_asBool(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool

    Definition Classes
    Bits → ToBoolable
  41. def do_asBools(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Seq[Bool]

  42. def do_asFixedPoint(that: BinaryPoint)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): FixedPoint

  43. def do_asInterval(that: IntervalRange)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Interval
  44. def do_asTypeOf[T <: Data](that: T)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): T

    Definition Classes
    Data
  45. def do_head(n: Int)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt

  46. def do_pad(that: Int)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bits.this.type

  47. def do_tail(n: Int)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt

  48. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  49. def equals(that: Any): Boolean
    Definition Classes
    HasId → AnyRef → Any
  50. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  51. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  52. final def getWidth: Int

    Returns the width, in bits, if currently known.

    Returns the width, in bits, if currently known.

    Definition Classes
    Data
  53. def hasSeed: Boolean

    returns

    Whether either autoName or suggestName has been called

    Definition Classes
    HasId
  54. def hashCode(): Int
    Definition Classes
    HasId → AnyRef → Any
  55. final macro def head(n: Int): UInt

    Head operator

    Head operator

    n

    the number of bits to take

    returns

    The n most significant bits of this Bits

  56. def instanceName: String
    Definition Classes
    HasId → InstanceId
  57. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  58. def isLit(): Boolean
    Definition Classes
    Data
  59. final def isWidthKnown: Boolean

    Returns whether the width is currently known.

    Returns whether the width is currently known.

    Definition Classes
    Data
  60. def litOption(): Option[BigInt]

    If this is a literal that is representable as bits, returns the value as a BigInt.

    If this is a literal that is representable as bits, returns the value as a BigInt. If not a literal, or not representable as bits (for example, is or contains Analog), returns None.

    Definition Classes
    ElementData
  61. def litValue(): BigInt

    Returns the literal value if this is a literal that is representable as bits, otherwise crashes.

    Returns the literal value if this is a literal that is representable as bits, otherwise crashes.

    Definition Classes
    Data
  62. def name: String
    Definition Classes
    Element
  63. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  64. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  65. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  66. final macro def pad(that: Int): Bits.this.type

    Pad operator

    Pad operator

    that

    the width to pad to

    returns

    this @coll zero padded up to width that. If that is less than the width of the original component, this method returns the original component.

    Note

    For SInts only, this will do sign extension.

  67. def parentModName: String
    Definition Classes
    HasId → InstanceId
  68. def parentPathName: String
    Definition Classes
    HasId → InstanceId
  69. def pathName: String
    Definition Classes
    HasId → InstanceId
  70. def suggestName(seed: ⇒ String): Bits.this.type

    Takes the first seed suggested.

    Takes the first seed suggested. Multiple calls to this function will be ignored. If the final computed name conflicts with another name, it may get uniquified by appending a digit at the end.

    Is a higher priority than autoSeed, in that regardless of whether autoSeed was called, suggestName will always take precedence.

    seed

    The seed for the name of this component

    returns

    this object

    Definition Classes
    HasId
  71. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  72. final macro def tail(n: Int): UInt

    Tail operator

    Tail operator

    n

    the number of bits to remove

    returns

    This Bits with the n most significant bits removed.

  73. final def toAbsoluteTarget: ReferenceTarget

    Returns a FIRRTL IsMember that refers to the absolute path to this object in the elaborated hardware graph

    Returns a FIRRTL IsMember that refers to the absolute path to this object in the elaborated hardware graph

    Definition Classes
    NamedComponent → InstanceId
  74. final macro def toBool(): Bool

    Casts this Bits to a Bool

    Casts this Bits to a Bool

    Definition Classes
    ToBoolable
    Note

    The width must be known and equal to 1

  75. final macro def toBools(): Seq[Bool]

    Returns the contents of this wire as a scala.collection.Seq of Bool.

  76. final def toNamed: ComponentName

    Returns a FIRRTL ComponentName that references this object

    Returns a FIRRTL ComponentName that references this object

    Definition Classes
    NamedComponent → InstanceId
    Note

    Should not be called until circuit elaboration is complete

  77. final def toPrintable: Printable

    Default print as Decimal

    Default print as Decimal

    Definition Classes
    BitsData
  78. def toString(): String
    Definition Classes
    AnyRef → Any
  79. final def toTarget: ReferenceTarget

    Returns a FIRRTL ReferenceTarget that references this object

    Returns a FIRRTL ReferenceTarget that references this object

    Definition Classes
    NamedComponent → InstanceId
    Note

    Should not be called until circuit elaboration is complete

  80. final macro def unary_~(): Bits

    Bitwise inversion operator

    Bitwise inversion operator

    returns

    this Bits with each bit inverted

  81. final def validateShiftAmount(x: Int): Int
    Attributes
    protected
  82. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  83. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  84. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  85. def widthKnown: Boolean
    Definition Classes
    Element
  86. final def widthOption: Option[Int]

    Returns Some(width) if the width is known, else None.

    Returns Some(width) if the width is known, else None.

    Definition Classes
    Data

Deprecated Value Members

  1. final def do_toBool(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool

    Definition Classes
    Bits → ToBoolable
    Annotations
    @chiselRuntimeDeprecated() @deprecated
    Deprecated

    (Since version 3.2) Use asBool instead

  2. def do_toBools(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Seq[Bool]

    Annotations
    @chiselRuntimeDeprecated() @deprecated
    Deprecated

    (Since version 3.2) Use asBools instead

  3. def litArg(): Option[LitArg]
    Definition Classes
    Data
    Annotations
    @chiselRuntimeDeprecated() @deprecated
    Deprecated

    (Since version 3.2) litArg is deprecated, use litOption or litTo*Option

Inherited from ToBoolable

Inherited from Element

Inherited from Data

Inherited from SourceInfoDoc

Inherited from NamedComponent

Inherited from HasId

Inherited from internal.InstanceId

Inherited from AnyRef

Inherited from Any

Bitwise

Bitwise hardware operators

Connect

Utilities for connecting hardware components

Ungrouped

SourceInfoTransformMacro

These internal methods are not part of the public-facing API!

The equivalent public-facing methods do not have the do_ prefix or have the same name. Use and look at the documentation for those. If you want left shift, use <<, not do_<<. If you want conversion to a Seq of Bools look at the asBools above, not the one below. Users can safely ignore every method in this group!

🐉🐉🐉 Here be dragons... 🐉🐉🐉

These do_X methods are used to enable both implicit passing of SourceInfo and chisel3.CompileOptions while also supporting chained apply methods. In effect all "normal" methods that you, as a user, will use in your designs, are converted to their "hidden", do_*, via macro transformations. Without using macros here, only one of the above wanted behaviors is allowed (implicit passing and chained applies)---the compiler interprets a chained apply as an explicit 'implicit' argument and will throw type errors.

The "normal", public-facing methods then take no SourceInfo. However, a macro transforms this public-facing method into a call to an internal, hidden do_* that takes an explicit SourceInfo by inserting an implicitly[SourceInfo] as the explicit argument.