chipsalliance / chipsalliance/chisel
Chisel drops escaped % in printf if it is the last character in the format string and preceded by a space
- Dominant language
- Scala
- Stars
- 4.8k
- Forks
- 658
- Avg merge
- 18h 59m
- Merged PRs (30d)
- 14
Description
**Type of issue**: Bug Report
**Please provide the steps to reproduce the problem:**
```scala
//> using repository "sonatype-s01:snapshots"
//> using scala "2.13.16"
//> using dep "org.chipsalliance::chisel:7.0.0-M2+618-2ce6ab30-SNAPSHOT"
//> using plugin "org.chipsalliance:::chisel-plugin:7.0.0-M2+618-2ce6ab30-SNAPSHOT"
//> using options "-unchecked", "-deprecation", "-language:reflectiveCalls", "-feature", "-Xcheckinit", "-Xfatal-warnings", "-Ywarn-dead-code", "-Ywarn-unused", "-Ymacro-annotations"
import chisel3._
// _root_ disambiguates from package chisel3.util.circt if user imports chisel3.util._
import _root_.circt.stage.ChiselStage
class Foo extends Module {
val foo, bar = IO(Input(UInt(8.W)))
val out = IO(Output(UInt(8.W)))
out := foo + bar
printf(cf" %%")
}
object Main extends App {
println(ChiselStage.emitCHIRRTL(gen = new Foo))
}
```
**What is the current behavior?**
The printf in the FIRRTL will be:
```firrtl
printf(clock, UInt<1>(0h1), " ")
```
**What is the expected behavior?**
The printf should be
```firrtl
printf(clock, UInt<1>(0h1), " %%")
```
Contributor guide
Research direction
Start with the minimal Scala reproducer in the issue and trace how the cf-string printf is lowered into FIRRTL. Verify the current and expected FIRRTL output shown in the report; done means the trailing escaped percent is preserved when it follows a space.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100