summaryrefslogtreecommitdiff
path: root/src/main/scala/chisel3/util/Reg.scala
diff options
context:
space:
mode:
authorJim Lawson2016-09-23 08:19:43 -0700
committerGitHub2016-09-23 08:19:43 -0700
commit785620b1403d827986bf60c2a001d8d6f71eed72 (patch)
tree1c1a0b14b041e544da3ff8176aba200604a131b3 /src/main/scala/chisel3/util/Reg.scala
parentb18e98ba2d058c7dd24f96f005486b70c856aeca (diff)
parentdecb2ee0f0bb8223f0b2b067b88ed90b71473a28 (diff)
Merge pull request #291 from ucb-bar/utilscaladocs
Scaladocs for utils
Diffstat (limited to 'src/main/scala/chisel3/util/Reg.scala')
-rw-r--r--src/main/scala/chisel3/util/Reg.scala38
1 files changed, 22 insertions, 16 deletions
diff --git a/src/main/scala/chisel3/util/Reg.scala b/src/main/scala/chisel3/util/Reg.scala
index 81de4754..80a3f43e 100644
--- a/src/main/scala/chisel3/util/Reg.scala
+++ b/src/main/scala/chisel3/util/Reg.scala
@@ -1,34 +1,40 @@
// See LICENSE for license details.
-/** Variations and helpers for registers.
- */
-
package chisel3.util
import chisel3._
object RegNext {
-
+ /** Returns a register with the specified next and no reset initialization.
+ *
+ * Essentially a 1-cycle delayed version of the input signal.
+ */
def apply[T <: Data](next: T): T = Reg[T](null.asInstanceOf[T], next, null.asInstanceOf[T])
+ /** Returns a register with the specified next and reset initialization.
+ *
+ * Essentially a 1-cycle delayed version of the input signal.
+ */
def apply[T <: Data](next: T, init: T): T = Reg[T](null.asInstanceOf[T], next, init)
-
}
object RegInit {
-
+ /** Returns a register pre-initialized (on reset) to the specified value.
+ */
def apply[T <: Data](init: T): T = Reg[T](null.asInstanceOf[T], null.asInstanceOf[T], init)
-
}
-/** A register with an Enable signal */
-object RegEnable
-{
+object RegEnable {
+ /** Returns a register with the specified next, update enable gate, and no reset initialization.
+ */
def apply[T <: Data](updateData: T, enable: Bool): T = {
val r = Reg(updateData)
when (enable) { r := updateData }
r
}
+
+ /** Returns a register with the specified next, update enable gate, and reset initialization.
+ */
def apply[T <: Data](updateData: T, resetData: T, enable: Bool): T = {
val r = RegInit(resetData)
when (enable) { r := updateData }
@@ -36,15 +42,15 @@ object RegEnable
}
}
-/** Returns the n-cycle delayed version of the input signal.
- */
object ShiftRegister
{
- /** @param in input to delay
+ /** Returns the n-cycle delayed version of the input signal.
+ *
+ * @param in input to delay
* @param n number of cycles to delay
- * @param en enable the shift */
- def apply[T <: Data](in: T, n: Int, en: Bool = Bool(true)): T =
- {
+ * @param en enable the shift
+ */
+ def apply[T <: Data](in: T, n: Int, en: Bool = Bool(true)): T = {
// The order of tests reflects the expected use cases.
if (n == 1) {
RegEnable(in, en)