wasim6691 Posted January 5, 2018 Report Share Posted January 5, 2018 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 Quote Link to comment Share on other sites More sharing options...
Roman Popov Posted January 5, 2018 Report Share Posted January 5, 2018 Depends on what you want. Global state is not synthesizable. Quote Link to comment Share on other sites More sharing options...
wasim6691 Posted January 5, 2018 Author Report Share Posted January 5, 2018 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 Quote Link to comment Share on other sites More sharing options...
Roman Popov Posted January 6, 2018 Report Share Posted January 6, 2018 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. Quote Link to comment Share on other sites More sharing options...
wasim6691 Posted January 6, 2018 Author Report Share Posted January 6, 2018 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 Quote Link to comment Share on other sites More sharing options...
Roman Popov Posted January 6, 2018 Report Share Posted January 6, 2018 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. Quote Link to comment Share on other sites More sharing options...
maehne Posted January 7, 2018 Report Share Posted January 7, 2018 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. 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.