summaryrefslogtreecommitdiff
path: root/chiselFrontend/src/main/scala/chisel3/core/Printf.scala
diff options
context:
space:
mode:
authorJack Koenig2017-02-16 11:02:21 -0800
committerGitHub2017-02-16 11:02:21 -0800
commit563f348ca3e4a984ad23caba9e980dab8fa808bb (patch)
tree46dfe1e3a0a76b2f106a48332e55237ef237f441 /chiselFrontend/src/main/scala/chisel3/core/Printf.scala
parentd00a3fe9a3df5ce888b5c461181aadbd4a293bf3 (diff)
Add support for clock and reset scoping (#509)
withClockAndReset, withReset, and withClock allow changing the implicit clock and reset. Module.clock and Module.reset provide access to the current implicit clock and reset.
Diffstat (limited to 'chiselFrontend/src/main/scala/chisel3/core/Printf.scala')
-rw-r--r--chiselFrontend/src/main/scala/chisel3/core/Printf.scala9
1 files changed, 4 insertions, 5 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Printf.scala b/chiselFrontend/src/main/scala/chisel3/core/Printf.scala
index 4ec13751..81210f45 100644
--- a/chiselFrontend/src/main/scala/chisel3/core/Printf.scala
+++ b/chiselFrontend/src/main/scala/chisel3/core/Printf.scala
@@ -34,9 +34,8 @@ object printf { // scalastyle:ignore object.name
* reset). If your definition of reset is not the encapsulating Module's
* reset, you will need to gate this externally.
*
- * May be called outside of a Module (like defined in a function), so
- * functions using printf make the standard Module assumptions (single clock
- * and single reset).
+ * May be called outside of a Module (like defined in a function), uses
+ * whatever clock and reset are in scope.
*
* @param fmt printf format string
* @param data format string varargs containing data to print
@@ -56,13 +55,13 @@ object printf { // scalastyle:ignore object.name
* @param pable [[Printable]] to print
*/
def apply(pable: Printable)(implicit sourceInfo: SourceInfo): Unit = {
- when (!Builder.forcedModule.reset) {
+ when (!Builder.forcedReset) {
printfWithoutReset(pable)
}
}
private[chisel3] def printfWithoutReset(pable: Printable)(implicit sourceInfo: SourceInfo): Unit = {
- val clock = Builder.forcedModule.clock
+ val clock = Builder.forcedClock
pushCommand(Printf(sourceInfo, Node(clock), pable))
}
private[chisel3] def printfWithoutReset(fmt: String, data: Bits*)(implicit sourceInfo: SourceInfo): Unit =