diff options
| author | Jim Lawson | 2015-08-27 09:59:40 -0700 |
|---|---|---|
| committer | Jim Lawson | 2015-08-27 09:59:40 -0700 |
| commit | afca748efc63a074f1cc1943dda65616ace1ceac (patch) | |
| tree | 910b0d41fa64cb83cc58af9c944e3b4cb28f04d4 /src | |
| parent | f00ac5617083285d2ffa9dc0b84fcf8c8b4895f2 (diff) | |
Add chisel2 scaladoc for 'when'.
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/scala/Chisel/Core.scala | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/main/scala/Chisel/Core.scala b/src/main/scala/Chisel/Core.scala index 987569e9..d04d55bf 100644 --- a/src/main/scala/Chisel/Core.scala +++ b/src/main/scala/Chisel/Core.scala @@ -865,16 +865,31 @@ abstract class BlackBox(_clock: Clock = null, _reset: Bool = null) extends Modul def setVerilogParameters(s: String): Unit = {} } +/** An object to create conditional logic. + * @example + * {{{ + * when ( myData === UInt(3) ) { + * ... // Some logic + * } .elsewhen ( myData === UInt(1) ) { + * ... // Some logic + * } .otherwise { + * ... // Some logic + * } }}} + */ object when { + /** @param cond condition to execute upon + * @param block a section of logic to enable if cond is true */ def apply(cond: => Bool)(block: => Unit): WhenContext = { new WhenContext(cond)(block) } } class WhenContext(cond: => Bool)(block: => Unit) { + /** execute block when alternative cond is true */ def elsewhen (cond: => Bool)(block: => Unit): WhenContext = doOtherwise(when(cond)(block)) + /** execute block by default */ def otherwise(block: => Unit): Unit = doOtherwise(block) |
