Skip to content

Commit

Permalink
Change warning to error
Browse files Browse the repository at this point in the history
Update a callsite. Rename function in Printf.scala to match the naming
convention in the file. Undo call by name change to preserve binary compatibility.
  • Loading branch information
adkian-sifive committed Sep 28, 2022
1 parent 03dbe54 commit 9a8d90d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 24 deletions.
28 changes: 14 additions & 14 deletions core/src/main/scala/chisel3/Printf.scala
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ object printf {
* @param fmt printf format string
* @param data format string varargs containing data to print
*/
def apply(fmt: String, data: Bits*)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Printf =
macro _applyMacroWithInterpolatorCheck

def _applyMacroWithInterpolatorCheck(
c: blackbox.Context
)(fmt: c.Tree,
Expand All @@ -86,19 +89,16 @@ object printf {
import c.universe._
fmt match {
case q"scala.StringContext.apply(..$_).s(..$_)" =>
c.warning(
c.error(
c.enclosingPosition,
"s-interpolators for Chisel assert, assume and printf statements will be deprecated in 3.5; use p or cf interpolators instead"
"s-interpolators for Chisel assert, assume and printf statements are deprecated (since 3.5); use p or cf interpolators instead"
)
case _ =>
}
val apply_impl_do = symbolOf[this.type].asClass.module.info.member(TermName("_applyWithReset"))
val apply_impl_do = symbolOf[this.type].asClass.module.info.member(TermName("printfWithReset"))
q"$apply_impl_do(_root_.chisel3.Printable.pack($fmt, ..$data))($sourceInfo, $compileOptions)"
}

def apply(fmt: String, data: Bits*)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Printf =
macro _applyMacroWithInterpolatorCheck

/** Prints a message in simulation
*
* Prints a message every cycle. If defined within the scope of a [[when]] block, the message
Expand All @@ -113,15 +113,15 @@ object printf {
* @see [[Printable]] documentation
* @param pable [[Printable]] to print
*/
def apply(pable: Printable)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Printf = {
var printfId: Printf = null
when(!Module.reset.asBool) {
printfId = printfWithoutReset(pable)
}
printfId
}
def apply(pable: Printable)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Printf =
printfWithReset(pable)(sourceInfo, compileOptions)

def _applyWithReset(pable: Printable)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Printf = {
private[chisel3] def printfWithReset(
pable: Printable
)(
implicit sourceInfo: SourceInfo,
compileOptions: CompileOptions
): Printf = {
var printfId: Printf = null
when(!Module.reset.asBool) {
printfId = printfWithoutReset(pable)
Expand Down
10 changes: 5 additions & 5 deletions core/src/main/scala/chisel3/VerificationStatement.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ object assert extends VerifPrintMacrosDoc {
// Macros currently can't take default arguments, so we need two functions to emulate defaults.
def apply(
cond: Bool,
message: => String,
message: String,
data: Bits*
)(
implicit sourceInfo: SourceInfo,
Expand Down Expand Up @@ -93,9 +93,9 @@ object assert extends VerifPrintMacrosDoc {
import c.universe._
message match {
case q"scala.StringContext.apply(..$_).s(..$_)" =>
c.warning(
c.error(
c.enclosingPosition,
"s-interpolators for Chisel assert, assume and printf statements will be deprecated in 3.5; use p or cf interpolators instead"
"s-interpolators for Chisel assert, assume and printf statements are deprecated (since 3.5); use p or cf interpolators instead"
)
case _ =>
}
Expand Down Expand Up @@ -289,9 +289,9 @@ object assume extends VerifPrintMacrosDoc {
import c.universe._
message match {
case q"scala.StringContext.apply(..$_).s(..$_)" =>
c.warning(
c.error(
c.enclosingPosition,
"s-interpolators for Chisel assert, assume and printf statements will be deprecated in 3.5; use p or cf interpolators instead"
"s-interpolators for Chisel assert, assume and printf statements are deprecated (since 3.5); use p or cf interpolators instead"
)
case _ =>
}
Expand Down
7 changes: 2 additions & 5 deletions src/test/scala/chiselTests/IntervalSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class ClipSqueezeWrapDemo(
val wrapped = counter.wrap(0.U.asInterval(targetRange))

when(counter === startValue) {
printf(s"Target range is $range\n")
printf(cf"Target range is $range\n")
printf("value clip squeeze wrap\n")
}

Expand Down Expand Up @@ -245,10 +245,7 @@ class SqueezeFunctionalityTester(range: IntervalRange, startNum: BigDecimal, end
squeezeTemplate := toSqueeze.squeeze(squeezeInterval)

printf(
s"SqueezeTest %d %d.squeeze($range) => %d\n",
counter,
toSqueeze.asSInt(),
squeezeTemplate.asSInt()
cf"SqueezeTest %d${counter} %d${toSqueeze.asSInt()}.squeeze($range) => %d${squeezeTemplate.asSInt()}\n"
)
}

Expand Down

0 comments on commit 9a8d90d

Please sign in to comment.