etemadi Posted May 20, 2013 Report Share Posted May 20, 2013 Hi I am providing a systemC model to another team that uses a non-systemC legacy model. The idea is to include systemC libraries and then replace the legacy main() function with systemC's sc_main() so that sc_start() command could be called. Here is an sketch: sc_main () { // legacy code here // instantiate/initial systemC modules // systemC code sc_start(sim_time); sc_stop(); // process systemC output with the legacy code } For various reasons, the other team is not willing to replace the main() function with sc_main(). One obvious way is to make the systemC portion an executable and call it from main(). But this requires file I/O that would slow down the sim. I was wondering if there is a way to accomplish this without replacing the main() function? Thanks Farzad Quote Link to comment Share on other sites More sharing options...
dakupoto Posted May 21, 2013 Report Share Posted May 21, 2013 It is not really clear what exactly the issue is. SystemC is basically ANSI C++ library, so one might start with an include directive as: #include "<my_legacy_code>.h" Then, use standard C++ techniques to get data from or pass data to the legacy code. However, the legacy code probably would not support concurrency or the other SystemC specific features. For example, to read in double numbers from the command line, one might have: int sc_main(int argc, char **argv) { double d0 = strtod(arggv[1], NULL); ...... return 0; } Hope that helps/ Quote Link to comment Share on other sites More sharing options...
etemadi Posted May 21, 2013 Author Report Share Posted May 21, 2013 The issue is that we cannot use sc_main() with the legacy code. We would like to use the main() function and communicate with systemC. Quote Link to comment Share on other sites More sharing options...
Philipp A Hartmann Posted May 21, 2013 Report Share Posted May 21, 2013 You can use the sc_elab_and_sim function (see Section 4.3.2 in 1666-2011): int main(int argc, char* argv[]) { // legacy code here int scresult = sc_core::sc_elab_and_sim( argc, argv ); // process systemC output with the legacy code } // still needed for SystemC part: int sc_main(int argc, char* argv[]) { // instantiate/initial SystemC modules // SystemC code sc_start(sim_time); sc_stop(); } Passing information between the legacy part and the SystemC part can then be done via a singleton class or by any other C++ means that fits your needs. Greetings from Oldenburg, Philipp etemadi and maehne 2 Quote Link to comment Share on other sites More sharing options...
etemadi Posted May 21, 2013 Author Report Share Posted May 21, 2013 Thanks Philipp, that worked! Quote Link to comment Share on other sites More sharing options...
dakupoto Posted May 22, 2013 Report Share Posted May 22, 2013 Suppose I have a SystemC model for a 3 bit adder, and I wish to execute that from pure C++ code as: int main(int argc, char **argv) { int scresult = sc_core::sc_elab_and_sim( argc, argv ); ..... return 0; } So what arguments would I pass to main at execution time ? 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.