Error: cf is not a member of StringContext

5 views
Skip to first unread message

Varun Gandhi

unread,
Nov 8, 2022, 4:56:20 PM11/8/22
to chisel-users
Hi,

I'm trying to print a Vec object and replicate the code as described in this post:

val myVec = VecInit(5.U, 10.U, 13.U) 
printf(cf"myVec = $myVec")

But I'm getting the following error: 
/home/centos/chipyard/generators/rocket-chip/src/main/scala/tilelink/Arbiter.scala:118:14: value cf is not a member of StringContext
[error]       printf(cf"myVec = $myVec")
[error]              ^

I would appreciate some pointers on this. 

Thanks,
Varun

Jack Koenig

unread,
Nov 8, 2022, 6:49:11 PM11/8/22
to chisel...@googlegroups.com
Hello,

What version of Chisel are you using? cf"..." was released as part of Chisel 3.5.4 (the most recent release of Chisel). See the release notes: https://github.com/chipsalliance/chisel3/releases/tag/v3.5.4

~Jack

--
You received this message because you are subscribed to the Google Groups "chisel-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chisel-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/chisel-users/bf489640-cd5e-480f-b88c-3d8eb256a190n%40googlegroups.com.

Varun Gandhi

unread,
Nov 8, 2022, 7:06:47 PM11/8/22
to chisel...@googlegroups.com
Hi Jack,

I’m using chipyard. According to this link: https://github.com/ucb-bar/chipyard/pull/1216 — It appears that the chisel version I’m using is 3.5.2. What approach can I follow to generate printfs in 3.5.2?

Best,
Varun

You received this message because you are subscribed to a topic in the Google Groups "chisel-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/chisel-users/ruynT40IZCM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to chisel-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/chisel-users/CAFooY_STWhFhwWP0WxC_9iyOpZfrj67k2_TXLxn5a%3DYG2JODiQ%40mail.gmail.com.

Edward Wang

unread,
Nov 8, 2022, 7:10:18 PM11/8/22
to chisel...@googlegroups.com
Hi Varun,

You can use something along the lines of: printf("out is %d\n", io.out)

This should be valid in older versions of Chisel too.

https://stackoverflow.com/a/53484936

Thanks,
Edward
> To view this discussion on the web visit https://groups.google.com/d/msgid/chisel-users/61B0685F-E233-423E-B89E-864C6CFF52C5%40g.harvard.edu.

Varun Gandhi

unread,
Nov 8, 2022, 7:13:49 PM11/8/22
to chisel...@googlegroups.com
Thanks, Edward. I guess my question was specific to printing aggregate datatypes. If I understand this correctly — there are no scala-style printfs in chisel versions < 3.5.4?

Best,
Varun
> To view this discussion on the web visit https://groups.google.com/d/msgid/chisel-users/CAPKm5OU%3DsDcXOpcbtC%2By%3DKMgt3MQS%3D-D385zExrAQ98CdVG1zw%40mail.gmail.com.

Edward Wang

unread,
Nov 8, 2022, 7:15:37 PM11/8/22
to chisel...@googlegroups.com
I don't believe so - you could always write your own function for an
aggregate datatype which calls the standard printf()?

Thanks,
Edward
> To view this discussion on the web visit https://groups.google.com/d/msgid/chisel-users/70ABA6C4-3954-4822-A1A4-8802B2C62F99%40g.harvard.edu.

Jack Koenig

unread,
Nov 8, 2022, 7:16:38 PM11/8/22
to chisel...@googlegroups.com
You can use p"..." which still exists in Chisel 3.5.4 but existed in earlier versions as well. The main difference is that `cf"..."` also supports format specifiers (which p"...") does not.

Reply all
Reply to author
Forward
0 new messages