David Black Posted April 22, 2022 Report Share Posted April 22, 2022 [By 'expert', I am referring to those of you that write SystemC code regularly and have decent proficiency. This is not a newbie question.] Can anybody give me a specific example of when SC_HAS_PROCESS is needed outside the constructor? I personally cannot think of any reason to place it outside the constructor with one exception, multiple constructors. Multiple constructors are rare in my experience (use of default constructor parameters is more common). Even with multiple constructors, I suspect placing SC_HAS_PROCESS inside each one is not a huge overhead. The reason for my question for my question is because I think a strong recommendation for best practices is to move SC_HAS_PROCESS into the constructor where it is used. This has several advantages: If the constructor is implemented separately in a .cpp file, then the SC_HAS process clutter is removed from the header. It directs the implementor's/reviewer's attention to the real use of this macro: supporting SC_THREAD, SC_METHOD, etc. I realize this is a bit of a nit. I am not looking to change the standard, but I am looking to provide good recommendations for best practices. Quote Link to comment Share on other sites More sharing options...
Philipp A Hartmann Posted April 22, 2022 Report Share Posted April 22, 2022 Actually, SC_HAS_PROCESS will no longer be needed at all in future versions of SystemC when using C++11 (and maybe the next standard?). David Black and maehne 2 Quote Link to comment Share on other sites More sharing options...
David Black Posted April 23, 2022 Author Report Share Posted April 23, 2022 13 hours ago, Philipp A Hartmann said: Actually, SC_HAS_PROCESS will no longer be needed at all in future versions of SystemC when using C++11 (and maybe the next standard?). Excellent! But what about prior to C++11? (Inquisitive minds want to know.) Quote Link to comment Share on other sites More sharing options...
Philipp A Hartmann Posted April 23, 2022 Report Share Posted April 23, 2022 8 hours ago, David Black said: But what about prior to C++11? (Inquisitive minds want to know.) Keeping declarations in their smallest required scope is generally a good practice in C++. To me, this applies to SC_HAS_PROCESS as well, which currently is a typedef underneath. I agree, that a repetition in multiple constructors (or before_end_of_ekaboration()) is not a big concern. David Black 1 Quote Link to comment Share on other sites More sharing options...
whmmy Posted January 26, 2023 Report Share Posted January 26, 2023 On 4/22/2022 at 6:15 PM, Philipp A Hartmann said: Actually, SC_HAS_PROCESS will no longer be needed at all in future versions of SystemC when using C++11 (and maybe the next standard?). Hi, I'm a newbie to systemc, I was browsing about SC_HAS_PROCESS when I saw your answer. I wonder why we won't need SC_HAS_PROCESS in the future? I would be super grateful if you could clear up my confusion. Quote Link to comment Share on other sites More sharing options...
David Peng Posted March 5 Report Share Posted March 5 On 4/22/2022 at 6:15 PM, Philipp A Hartmann said: Actually, SC_HAS_PROCESS will no longer be needed at all in future versions of SystemC when using C++11 (and maybe the next standard?). systems 3.0.0 deprecated SC_HAS_PROCESS. May I ask what's the recommended coding style for C++ >11? Previously I use SC_HAS_PROCESS for constructor with customer arguments. Quote Link to comment Share on other sites More sharing options...
Philipp A Hartmann Posted March 15 Report Share Posted March 15 In IEEE 1666-2023 (i.e. SystemC 3.0), you can just skip SC_HAS_PROCESS entirely, the SC_THREAD, SC_METHOD macros no longer require it. Quote Link to comment Share on other sites More sharing options...
Philipp A Hartmann Posted March 15 Report Share Posted March 15 On 1/26/2023 at 11:43 AM, whmmy said: I wonder why we won't need SC_HAS_PROCESS in the future? Because current C++ features makes it possible to implement SC_THREAD etc. without the SC_HAS_PROCESS helper macro . 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.