From 48caf43af55a61991c0945ec6d086c668d78096d Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Mon, 28 Mar 2016 22:34:53 -0700 Subject: Allow invocation of printf without applying reset For internal purposes only. Avoids redundant code emission for assertions. --- src/main/scala/Chisel/CoreUtil.scala | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') 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))) + } } -- cgit v1.2.3