WireDefault

chisel3.WireDefault
object WireDefault

Utility for constructing hardware wires with a default connection

The two forms of WireDefault differ in how the type and width of the resulting Wire are specified.

==Single Argument== The single argument form uses the argument to specify both the type and default connection. For non-literal Bits, the width of the Wire will be inferred. For literal Bits and all non-Bits arguments, the type will be copied from the argument. See the following examples for more details:

  1. Literal Bits initializer: width will be set to match
val w1 = WireDefault(1.U) // width will be inferred to be 1
val w2 = WireDefault(1.U(8.W)) // width is set to 8
  1. Non-Literal Element initializer - width will be inferred
val x = Wire(UInt())
val y = Wire(UInt(8.W))
val w1 = WireDefault(x) // width will be inferred
val w2 = WireDefault(y) // width will be inferred
  1. Aggregate initializer - width will be set to match the aggregate
class MyBundle {
 val unknown = UInt()
 val known   = UInt(8.W)
}
val w1 = Wire(new MyBundle)
val w2 = WireDefault(w1)
// Width of w2.unknown is inferred
// Width of w2.known is set to 8

==Double Argument== The double argument form allows the type of the Wire and the default connection to be specified independently.

The width inference semantics for WireDefault with two arguments match those of Wire. The first argument to WireDefault is the type template which defines the width of the Wire in exactly the same way as the only argument to Wire.

More explicitly, you can reason about WireDefault with multiple arguments as if it were defined as:

def WireDefault[T <: Data](t: T, init: T): T = {
 val x = Wire(t)
 x := init
 x
}

Attributes

Source
Data.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Inherited methods

def apply[T <: Data](init: T)(implicit sourceInfo: SourceInfo): T

Construct a Wire with a default connection

Construct a Wire with a default connection

Value parameters

init

The hardware value that will serve as a type template and default value

Attributes

Inherited from:
WireDefaultImpl (hidden)
Source
Data.scala
def apply[T <: Data](t: T, init: T)(implicit sourceInfo: SourceInfo): T

Construct a Wire with a type template and a default connection

Construct a Wire with a type template and a default connection

Value parameters

init

The hardware value that will serve as the default value

t

The type template used to construct this Wire

Attributes

Inherited from:
WireDefaultImpl (hidden)
Source
Data.scala
def apply[T <: Data](t: T, init: DontCare.type)(implicit sourceInfo: SourceInfo): T

Construct a Wire with a type template and a chisel3.DontCare default

Construct a Wire with a type template and a chisel3.DontCare default

Value parameters

init

The default connection to this Wire, can only be DontCare

t

The type template used to construct this Wire

Attributes

Note

This is really just a specialized form of apply[T <: Data](t: T, init: T): T with DontCare as init

Inherited from:
WireDefaultImpl (hidden)
Source
Data.scala