summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPalmer Dabbelt2015-12-31 20:38:49 -0800
committerPalmer Dabbelt2015-12-31 20:38:49 -0800
commitc1ba2c90faeb764ff2baeadf5862e18dd3917933 (patch)
treeff9c2382dcc50b4290a105dead6679895adc15ce /src
parent5e3f3977b3e25af21aa277d975836610a0df11d6 (diff)
Add assert(Boolean), assert(Boolean, String)
This overload exists for Chisel 2 compatibility (Rocket uses it). I tried to just add a single extra method ('apply(Boolean, String="")') but Scala complained about having overloads with implicit arguments. Instead I just went ahead and added 4 overloads that do the same thing as the implicit arguments, just a bit less cleanly.
Diffstat (limited to 'src')
-rw-r--r--src/main/scala/Chisel/CoreUtil.scala20
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 {