PrintableHelper

chisel3.`package`.PrintableHelper
final implicit class PrintableHelper(val sc: StringContext) extends AnyVal

Implicit for custom Printable string interpolator

Attributes

Source
package.scala
Graph
Supertypes
class AnyVal
trait Matchable
class Any

Members list

Value members

Concrete methods

def cf(args: Any*): Printable

Custom string interpolator for generating formatted Printables : cf"..."

Custom string interpolator for generating formatted Printables : cf"..."

Enhanced version of scala's f interpolator. Each expression (argument) referenced within the string is converted to a particular Printable depending on the format specifier and type.

==== For Chisel types referenced within the String ====

==== For Printable type: ==== No explicit format specifier supported - just return the Printable.

==== For regular scala types ==== Call String.format with the argument and specifier. Default is %s if no specifier is given. Wrap the result in PString Printable.

==== For the parts of the StringContext ==== Remove format specifiers and if literal percents (need to be escaped with %) are present convert them into Percent Printable. Rest of the string will be wrapped in PString Printable.

Attributes

Example
val w1  = 20.U // Chisel UInt type (which extends Bits)
val f1 = 30.2 // Scala float type.
val pable = cf"w1 = $w1%x f1 = $f1%2.2f. This is 100%% clear"
// the val `pable` is equivalent to the following
// Printables(List(PString(w1 = ), Hexadecimal(UInt<5>(20)), PString( f1 = ), PString(30.20), PString(. This is 100), Percent, PString( clear)))

throws UnknownFormatConversionException if literal percent not escaped with % or if the format specifier is not supported for the specific type throws StringContext.InvalidEscapeException if a parts string contains a backslash (\) character that does not start a valid escape sequence. throws IllegalArgumentException if the number of parts in the enclosing StringContext does not exceed the number of arguments arg by exactly 1.

Source
package.scala
def p(args: Any*): Printable

Custom string interpolator for generating Printables: p"..." mimicks s"..." for non-Printable data)

Custom string interpolator for generating Printables: p"..." mimicks s"..." for non-Printable data)

Attributes

Source
package.scala

Concrete fields

val sc: StringContext

Attributes

Source
package.scala