chisel icon indicating copy to clipboard operation
chisel copied to clipboard

Chisel drops escaped % in printf if it is the last character in the format string and preceded by a space

Open jackkoenig opened this issue 7 months ago • 0 comments

Type of issue: Bug Report

Please provide the steps to reproduce the problem:

//> 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:

printf(clock, UInt<1>(0h1), " ")

What is the expected behavior?

The printf should be

printf(clock, UInt<1>(0h1), " %%")

jackkoenig avatar Mar 21 '25 02:03 jackkoenig