ANKUR SAINI Posted December 24, 2017 Report Share Posted December 24, 2017 How "sc_main" works in SystemC ? I mean what I understood from library is that - there is a main function defined in library which calls the sc_elab_and_sim which in turns calls the sc_main function. But my question is SystemC library is distributed as source which user builds at his end; and links to his application. And if SystemC has main inside it then it should have got compiled into exe! Am I right ? Can somebody help me in understanding this flow ? Quote Link to comment Share on other sites More sharing options...
Philipp A Hartmann Posted December 24, 2017 Report Share Posted December 24, 2017 This question in mostly about how the linker works on your platform, and not really specific to SystemC. Let me try to give a short summary: Yes, the "main" symbol is needed by the final application For every needed symbol, the linker looks in your object files first If the symbol is present there, the linker picks it up If not, the linker looks in the libraries given by the user (order/lookup is platform-specific) Repeat this for all required symbols (including "sc_main") So, if you define your own "main" in your application, SystemC's "main" will not be picked. This is actually a feature, as you can call "sc_elab_and_sim" manually from your "main" as well, if you want. Hope that helps, Philipp maehne and ANKUR SAINI 1 1 Quote Link to comment Share on other sites More sharing options...
ANKUR SAINI Posted December 24, 2017 Author Report Share Posted December 24, 2017 @Philipp A Hartmann: Thanks for the short summary. It really gave me a good understanding from the top level. Quote Link to comment Share on other sites More sharing options...
David Black Posted December 24, 2017 Report Share Posted December 24, 2017 Just to add a bit to Philipp's excellent reply: In part this was done to support EDA tools that support co-simulation of SystemC with other languages (e.g. SystemVerilog and VHDL). The EDA tools themselves implement main and then they can dynamically link in your sc_main as needed. Of course if you really know how to control the linker, there are other means as well, but we don't need to go there. ANKUR SAINI 1 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.