c4brian Posted July 20, 2015 Report Share Posted July 20, 2015 I use SystemC models in a UVM environment, and am recently updating the reporting for the SysC model from cout -> SC_REPORT_INFO(MSGID,str); Simple question: how do I use this to return a value along with a message? Example, SC_REPORT_INFO(MSGID,fcn("The value is=%0d", myint)); Quote Link to comment Share on other sites More sharing options...
maehne Posted July 21, 2015 Report Share Posted July 21, 2015 The SC_REPORT_* macros take a C string as argument. To format the message and include runtime values in it, you will have to prepare this C string before passing it to SC_REPORT_*. Relying only on Standard C++, the string stream is a convenient and flexible way to do so: #include <sstream> ... int myint = 10; ... { std::ostringstream ostr; ostr << "The value is " << myint; SC_REPORT_INFO(MSGID, ostr.str().c_str()); } Quote Link to comment Share on other sites More sharing options...
c4brian Posted July 21, 2015 Author Report Share Posted July 21, 2015 That works; thanks Torsten. I was a little spoiled off SystemVerilog.. $sformatf("var= 0x%0h",var) Quote Link to comment Share on other sites More sharing options...
maehne Posted July 21, 2015 Report Share Posted July 21, 2015 You are welcome. If you are willing to drag in some additional dependencies, you may consider cppformat or the Boost.Format library, which provide functionality close to $sformatf of SystemVerilog. Quote Link to comment Share on other sites More sharing options...
c4brian Posted July 22, 2015 Author Report Share Posted July 22, 2015 I've seen boost mentioned several times; I always gravitate towards NOT adding in additional libraries because they seem "scary"; of course, until I hear them enough, and decide they arent scary anymore. I might just do this. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.