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:
- 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
- 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
- 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 Objecttrait Matchableclass Any
- Self type
-
WireDefault.type