Jump to content
Aaron0127

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?

Share this post


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

Share this post


Link to post
Share on other sites

Hello @AmeyaVS,

Thanks for reply, does this mean that I only need to use sc_main function. I manually changed the entry point of the project in Visual Studio from main()to sc_main(), and I get this compiling error "a subsystem can't be inferred and must be defined".

Share this post


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.

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

×