Jump to content
carter

what is sc_initialize()?

Recommended Posts

Hi

As i know, sc_initialize() is just work for systemc scheduler initialize.

But i 'm not sure about what for use exactly?

Would you please let me know what (why/when) i have to use this?

Share this post


Link to post
Share on other sites

You should not use sc_initialize().  It's deprecated and not part of the IEEE 1666 SystemC standard.

 

If you want to prepare the simulation without running it yet, your can complete the elaboration and run the initialization via

sc_start( SC_ZERO_TIME );

from within your sc_main() function. Afterwards, you can call sc_start multiple times again, e.g. with non-zero duration arguments, to perform the simulation itself.

/Philipp

Share this post


Link to post
Share on other sites

You should not use sc_initialize().  It's deprecated and not part of the IEEE 1666 SystemC standard.

 

If you want to prepare the simulation without running it yet, your can complete the elaboration and run the initialization via

sc_start( SC_ZERO_TIME );
from within your sc_main() function. Afterwards, you can call sc_start multiple times again, e.g. with non-zero duration arguments, to perform the simulation itself.

/Philipp

Thanks philipp

Share this post


Link to post
Share on other sites

You should not use sc_initialize(). It's deprecated and not part of the IEEE 1666 SystemC standard.

If you want to prepare the simulation without running it yet, your can complete the elaboration and run the initialization via

sc_start( SC_ZERO_TIME );
from within your sc_main() function. Afterwards, you can call sc_start multiple times again, e.g. with non-zero duration arguments, to perform the simulation itself.

/Philipp

Hi philipp.

I'm not sure about "If you want to prepare the simulation without running it yet".

Would you please let me know above case? I don't know the case about" to prepare the simulation without running" for what?

Share this post


Link to post
Share on other sites

See the IEEE 1666-2011 standard, chapter 4 for details about the SystemC elaboration and simulation semantics.

 

If you don't "need" to run the initialization phase separately, you don't need to worry about this detail.  The first invocation of sc_start will take care of completing the elaboration and initialization automatically.

There is an example in the SystemC standard (in section 4.5.7), which shows a simulation running in individual steps:
 

The function sc_pending_activity may return false at the end of elaboration. Therefore, care should be taken when calling sc_start in a loop conditional on any of the functions that detect pending activity.

Example:

int sc_main( int argc, char* argv[] )
{
  // Instantiate top-level module
  ...
  sc_start( SC_ZERO_TIME );        // Run the initialization phase to create pending activity
  
  while( sc_pending_activity() ) {
    sc_start( sc_time_to_pending_activity() ); // Run up to the next activity
  } 
  return 0;
}

 

In this example, you need the explicit initialization call.

/Philipp

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

×