diff --git a/core/src/main/scala/chisel3/Printf.scala b/core/src/main/scala/chisel3/Printf.scala index 5f5384d8193..6233d53e2ea 100644 --- a/core/src/main/scala/chisel3/Printf.scala +++ b/core/src/main/scala/chisel3/Printf.scala @@ -91,7 +91,7 @@ object printf { case q"scala.StringContext.apply(..$_).s(..$_)" => c.error( c.enclosingPosition, - "s-interpolators for Chisel assert, assume and printf statements are deprecated (since 3.5); use p or cf interpolators instead" + "The s-interpolator for Chisel assert, assume and printf statements are deprecated (since 3.5); use the cf interpolator instead" ) case _ => } diff --git a/core/src/main/scala/chisel3/VerificationStatement.scala b/core/src/main/scala/chisel3/VerificationStatement.scala index a6cafa182f1..b122d24fa06 100644 --- a/core/src/main/scala/chisel3/VerificationStatement.scala +++ b/core/src/main/scala/chisel3/VerificationStatement.scala @@ -95,7 +95,7 @@ object assert extends VerifPrintMacrosDoc { case q"scala.StringContext.apply(..$_).s(..$_)" => c.error( c.enclosingPosition, - "s-interpolators for Chisel assert, assume and printf statements are deprecated (since 3.5); use p or cf interpolators instead" + "The s-interpolator for Chisel assert, assume and printf statements are deprecated (since 3.5); use the cf interpolator instead" ) case _ => } @@ -292,7 +292,7 @@ object assume extends VerifPrintMacrosDoc { case q"scala.StringContext.apply(..$_).s(..$_)" => c.error( c.enclosingPosition, - "s-interpolators for Chisel assert, assume and printf statements are deprecated (since 3.5); use p or cf interpolators instead" + "The s-interpolator for Chisel assert, assume and printf statements are deprecated (since 3.5); use the cf interpolator instead" ) case _ => } diff --git a/docs/src/explanations/printing.md b/docs/src/explanations/printing.md index a199a514aa5..f0519380059 100644 --- a/docs/src/explanations/printing.md +++ b/docs/src/explanations/printing.md @@ -13,11 +13,21 @@ Chisel provides the `printf` function for debugging purposes. It comes in two fl ### Scala-style -Chisel also supports printf in a style similar to [Scala's String Interpolation](http://docs.scala-lang.org/overviews/core/string-interpolation.html). Chisel provides a custom string interpolator `cf` which follows C-style format specifiers (see section [C-style](#c-style) below). Here's a few examples of using the `cf` interpolator: +Chisel also supports printf in a style similar to [Scala's String Interpolation](http://docs.scala-lang.org/overviews/core/string-interpolation.html). Chisel provides a custom string interpolator `cf` which follows C-style format specifiers (see section [C-style](#c-style) below). Note that the Scala s-interpolator is not supported and will throw an error: ```scala mdoc:invisible import chisel3._ ``` + +```scala mdoc:fail +class MyModule extends Module { + val in = IO(Input(UInt(8.W))) + printf(s"in = $in\n") +} +``` + +Here's a few examples of using the `cf` interpolator: + ```scala mdoc:compile-only val myUInt = 33.U printf(cf"myUInt = $myUInt") // myUInt = 33 @@ -103,8 +113,6 @@ Message: Notice the use of `+` between `cf` interpolated "strings". The results of `cf` interpolation can be concatenated by using the `+` operator. -> :warning: The Scala s-interpolator is deprecated since 3.5 and will output the warning: "s-interpolators for Chisel assert, assume and printf statements are deprecated (since 3.5); use p or cf interpolators instead" - ### C-Style Chisel provides `printf` in a similar style to its C namesake. It accepts a double-quoted format string and a variable number of arguments which will then be printed on rising clock edges. Chisel supports the following format specifiers: