diff options
Diffstat (limited to 'src/main/scala/Chisel')
| -rw-r--r-- | src/main/scala/Chisel/internal/firrtl/IR.scala | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/main/scala/Chisel/internal/firrtl/IR.scala b/src/main/scala/Chisel/internal/firrtl/IR.scala index beb32e6c..4c039e9a 100644 --- a/src/main/scala/Chisel/internal/firrtl/IR.scala +++ b/src/main/scala/Chisel/internal/firrtl/IR.scala @@ -167,16 +167,15 @@ case class Port(id: Data, dir: Direction) case class Printf(clk: Arg, formatIn: String, ids: Seq[Arg]) extends Command { require(formatIn.forall(c => c.toInt > 0 && c.toInt < 128), "format strings must comprise non-null ASCII values") def format: String = { - def escaped(x: Char) = - if (x == '"' || x == '\\' || x == '?') { - "\\" + x - } else if (x == '\n') { - "\\n" - } else if (x.toInt < 32) { - s"\\x${BigInt(x.toInt).toString(16)}" - } else { + def escaped(x: Char) = { + require(x.toInt >= 0) + if (x == '"' || x == '\\') s"\\${x}" + else if (x == '\n') "\\n" + else { + require(x.toInt >= 32) // TODO \xNN once FIRRTL issue #59 is resolved x } + } formatIn.map(escaped _).mkString } } |
