object RegInit
Utility for constructing hardware registers with an initialization value.
The register is set to the initialization value when the current implicit reset
is high
The two forms of RegInit
differ in how the type and width of the resulting Reg are
specified.
Single Argument
The single argument form uses the argument to specify both the type and reset value. For non-literal Bits, the width of the Reg 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 r1 = RegInit(1.U) // width will be inferred to be 1 val r2 = RegInit(1.U(8.W)) // width is set to 8
2. Non-Literal Element initializer - width will be inferred
val x = Wire(UInt()) val y = Wire(UInt(8.W)) val r1 = RegInit(x) // width will be inferred val r2 = RegInit(y) // width will be inferred
3. Aggregate initializer - width will be set to match the aggregate
class MyBundle extends Bundle { val unknown = UInt() val known = UInt(8.W) } val w1 = Reg(new MyBundle) val w2 = RegInit(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 Reg and the default connection to be specified independently.
The width inference semantics for RegInit
with two arguments match those of Reg. The
first argument to RegInit
is the type template which defines the width of the Reg
in
exactly the same way as the only argument to Wire.
More explicitly, you can reason about RegInit
with multiple arguments as if it were defined
as:
def RegInit[T <: Data](t: T, init: T): T = { val x = Reg(t) x := init x }
- Source
- Reg.scala
- Alphabetic
- By Inheritance
- RegInit
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def apply[T <: Data](init: T)(implicit sourceInfo: SourceInfo): T
Construct a Reg initialized on reset to the specified value.
Construct a Reg initialized on reset to the specified value.
- init
Initial value that serves as a type template and reset value
- def apply[T <: Data](t: T, init: T)(implicit sourceInfo: SourceInfo): T
Construct a Reg from a type template initialized to the specified value on reset
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()