diff options
| author | Jim Lawson | 2015-08-27 10:01:29 -0700 |
|---|---|---|
| committer | Jim Lawson | 2015-08-27 10:01:29 -0700 |
| commit | ab63c2e7de4f91456f382e1d3090e13a7317c821 (patch) | |
| tree | 910b0d41fa64cb83cc58af9c944e3b4cb28f04d4 /src/main/scala/Chisel/Core.scala | |
| parent | 794a1230e61a9a358fcb852fca3b84cab237dcf9 (diff) | |
| parent | afca748efc63a074f1cc1943dda65616ace1ceac (diff) | |
Merge pull request #10 from ucb-bar/scaladoc
Scaladoc - 'when' and Utils
Diffstat (limited to 'src/main/scala/Chisel/Core.scala')
| -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) |
