From c51fcfea32b6c73e623657442460fb782ff0733b Mon Sep 17 00:00:00 2001 From: Aditya Naik Date: Thu, 10 Nov 2022 13:41:00 -0800 Subject: Warn on S-interpolator usage for assert, assume and printf (backport #2751) (#2757) * Add internal methods to maintain binary compatibility Co-authored-by: Megan Wachs Co-authored-by: Jack Koenig --- docs/src/explanations/printing.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'docs/src') diff --git a/docs/src/explanations/printing.md b/docs/src/explanations/printing.md index 71a6f5cf..80e9ec70 100644 --- a/docs/src/explanations/printing.md +++ b/docs/src/explanations/printing.md @@ -13,11 +13,23 @@ 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 in Chisel constructs and will issue a compile-time warning: ```scala mdoc:invisible import chisel3._ ``` + +```scala mdoc:warn +class MyModule extends Module { + val in = IO(Input(UInt(8.W))) + printf(s"in = $in\n") +} +``` + +Instead, use Chisel's `cf` interpolator as in the following examples: + ```scala mdoc:compile-only val myUInt = 33.U printf(cf"myUInt = $myUInt") // myUInt = 33 -- cgit v1.2.3