summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Waterman2016-03-28 22:34:53 -0700
committerAndrew Waterman2016-03-28 22:34:53 -0700
commit48caf43af55a61991c0945ec6d086c668d78096d (patch)
tree7ccbdbc75893db51ce7ac87e3e7a4ffb44a528a0
parentd79b8bc8c741570fcc582f25ac8cfe6604cca970 (diff)
Allow invocation of printf without applying reset
For internal purposes only. Avoids redundant code emission for assertions.
-rw-r--r--src/main/scala/Chisel/CoreUtil.scala12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/main/scala/Chisel/CoreUtil.scala b/src/main/scala/Chisel/CoreUtil.scala
index c3c5214f..db3cf678 100644
--- a/src/main/scala/Chisel/CoreUtil.scala
+++ b/src/main/scala/Chisel/CoreUtil.scala
@@ -50,8 +50,8 @@ object assert {
def apply_impl_do(cond: Bool, line: String, message: Option[String]) {
when (!(cond || Builder.dynamicContext.currentModule.get.reset)) {
message match {
- case Some(str) => printf(s"Assertion failed: $str\n at $line\n")
- case None => printf(s"Assertion failed\n at $line\n")
+ case Some(str) => printf.printfWithoutReset(s"Assertion failed: $str\n at $line\n")
+ case None => printf.printfWithoutReset(s"Assertion failed\n at $line\n")
}
pushCommand(Stop(Node(Builder.dynamicContext.currentModule.get.clock), 1))
}
@@ -86,8 +86,12 @@ object printf {
*/
def apply(fmt: String, data: Bits*) {
when (!Builder.dynamicContext.currentModule.get.reset) {
- pushCommand(Printf(Node(Builder.dynamicContext.currentModule.get.clock),
- fmt, data.map((d: Bits) => d.ref)))
+ printfWithoutReset(fmt, data:_*)
}
}
+
+ private[Chisel] def printfWithoutReset(fmt: String, data: Bits*) {
+ val clock = Builder.dynamicContext.currentModule.get.clock
+ pushCommand(Printf(Node(clock), fmt, data.map((d: Bits) => d.ref)))
+ }
}