Jump to content

define sc_main in VS 2017


Recommended Posts

Hi,

I am new to SystemC, I have installed SystemC 2.3.2 successfully in Visual Studio 2017. The only problem that I have is with sc_main() function. The compiler complained the entry point cannot be found. I understand that the default entry point in VS is int main(). I have read  IEEE Std 1666-2011 clause 4.3 about sc_main() and sc_elab_and_sim(). I tried to use following code to start simulation. But it failed. The compiler showed error message: "identifier "sc_eabl_and_sim" is undefined".

int main(int arg, char* argv[])
{
	sc_elab_and_sim(arg, argv);
	//The rest code for simulation and testbench
	...
}

How do I make sc_main(int arg, char* argv[]) function work in VS 2017? If not possible, how to properly call sc_eabl_and_sim(int arg, char* argv[]) in an int main(int arg, char* argv[]) to start a simulation?

Link to post
Share on other sites

Hello @Aaron0127,

The entry point for creating the simulation models and starting simulation is supposed to be implemented within sc_main function.

This was done to support the EDA tools vendors to support extensive debugging capability with their tools.

In the available open source implementation the main function is provided by the SystemC library itself.

Only the sc_main function implementation has to be provided by you.

Hope it helps.

Regards,

Ameya Vikram Singh

Link to post
Share on other sites

It is correct that your SystemC application compiles and runs correct if you leave the default entry point at main() and provide yourself only sc_main(). This is by design, as you can read up in clauses 4.2 and 4.3 of IEEE Std 1666-2011. Subclause 4.3.2 states:

Quote

The function main that is the entry point of the C++ program may be provided by the implementation or by the application. If function main is provided by the implementation, function main shall initiate the mechanisms for elaboration and simulation as described in this subclause. If function main is provided by the application, function main shall call the function sc_elab_and_sim, which is the entry point into the SystemC implementation.

The SystemC library provides a main() function, which calls sc_elab_and_sim(), and which in turn then calls the sc_main(), which you have to provide to set up your model and control elaboration and simulation.

Link to post
Share on other sites
  • 4 weeks later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...