Jump to content
wasim6691

DEFINING GLOBAL IN SYSTEMC and Member Function

Recommended Posts

 

Hi 

I have written a sample code in SystemC. I am defining some typedefs and global variable outside SC_MODULE. Is that fine? and plus I am also defining the member function as static. Please correct my code. Thanks

Share this post


Link to post
Share on other sites
2 hours ago, wasim6691 said:

In my code the code lines above the SC_MODULE are not synthesizeable ? I have to synthesize the code so which changes would You suggest me in the code. Thanks

Hard to say without processes source code. But if you use global variables like inp_image in your processes, this would not be synthesizable. 

Share this post


Link to post
Share on other sites
 

I am Using the inp_image in the Process as well as inside the member function. But I am also using the send_pixel member function inside another MODULE. That's why I was using it as global. What else can I do to make the inp_image array to be accessible inside another MODULE if I do not make it global?. Thanks

Share this post


Link to post
Share on other sites

Some synthesis tools support shared arrays between modules. So this is vendor-specific.

But in general you will need to create a multiport memory module to share memory between multiple consumers.

Share this post


Link to post
Share on other sites

Some comments to your code snippets:

  • Prefer to #include "systemc" instead of "systemc.h" to avoid namespace pollution. You'll then have to prefix SystemC symbols with the appropriate namespace prefix (recommended in most cases, especially headers). In the context of functions and implementation files, you can selectively import symbols from the SystemC namespaces with appropriate using statements.
  • Consider also to put your own classes, functions, typedefs and other declarations and definitions in a dedicated namespace to facilitate future code reuse!
  • #include "iomanip" -> #include <iomanip> (because it is a system header)
  • Initialization of global variables should not happen in the header file, but in the .cpp implementation file! To this end, you have to inp_image as extern.
  • Try to avoid using preprocessor macros as much as possible! They are only rarely needed in C++. Your NBITS*() macros could be replaced by inline functions, which are optionally templatized to an arbitrary argument type T. Starting from C++'11, you could even declare them as constexpr, so that a compiler may evaluate them already at compile time.
  • If your tool supports C++'11+, you may also declare your constants as constexpr.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×