From c1ba2c90faeb764ff2baeadf5862e18dd3917933 Mon Sep 17 00:00:00 2001 From: Palmer Dabbelt Date: Thu, 31 Dec 2015 20:38:49 -0800 Subject: 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. --- src/main/scala/Chisel/CoreUtil.scala | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src') 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 { -- cgit v1.2.3