diff options
| author | Andrew Waterman | 2016-01-04 11:14:52 -0800 |
|---|---|---|
| committer | Andrew Waterman | 2016-01-04 11:14:52 -0800 |
| commit | a98dab0c5726434c2aaa457787ef32c380c5556d (patch) | |
| tree | ff9c2382dcc50b4290a105dead6679895adc15ce /src/main/scala/Chisel | |
| parent | 5e3f3977b3e25af21aa277d975836610a0df11d6 (diff) | |
| parent | c1ba2c90faeb764ff2baeadf5862e18dd3917933 (diff) | |
Merge pull request #83 from ucb-bar/bool-assert
Support Boolean assert()
Diffstat (limited to 'src/main/scala/Chisel')
| -rw-r--r-- | src/main/scala/Chisel/CoreUtil.scala | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/main/scala/Chisel/CoreUtil.scala b/src/main/scala/Chisel/CoreUtil.scala index aaca404b..7077c9c1 100644 --- a/src/main/scala/Chisel/CoreUtil.scala +++ b/src/main/scala/Chisel/CoreUtil.scala @@ -21,7 +21,7 @@ object assert { * @param cond condition, assertion fires (simulation fails) when false * @param message optional message to print when the assertion fires */ - def apply(cond: Bool, message: String="") { + def apply(cond: Bool, message: String) { when (!Builder.dynamicContext.currentModule.get.reset) { when(!cond) { if (message.isEmpty()) { @@ -33,6 +33,24 @@ object assert { } } } + + /** A workaround for default-value overloading problems in Scala, just + * 'assert(cond, "")' */ + def apply(cond: Bool) { + assert(cond, "") + } + + /** An elaboration-time assertion, otherwise the same as the above run-time + * assertion. */ + def apply(cond: Boolean, message: String) { + apply(Bool(cond), message) + } + + /** A workaround for default-value overloading problems in Scala, just + * 'assert(cond, "")' */ + def apply(cond: Boolean) { + apply(cond, "") + } } object printf { |
