2

I would like to report what the time is at the end of a simulation. I thought that I would use the end_of_simulation routine, and just do a sc_timestamp in the routine to do this.

The problem is that the kernel has terminated before end_of_simulation, and I get a bogus timestamp.

I can't really use a thread to determine this because what pulls me out of the simulation is that all of the threads are waiting on events. There is no "master thread" that I could just store the timestamp.

any thoughts?

Chris
  • 483
  • 3
  • 14

3 Answers3

1

You could use something like:

cout << "Start of simulation is " << sc_time_stamp() << endl;
sc_start (); // sc_start (-1);
cout << "End of simulation is " << sc_time_stamp() << endl;

Hope it helps.

Pvs
  • 11
  • 1
0

I'm not sure if I understand your question.

For the simulation to run is necessary to stipulate the time that it must take in total. sc_start(total_time, SC_NS).

total_time is the final time of simulation.

slayra
  • 106
  • 2
  • 9
  • 1
    He is starting his sim with sc_start() or sc_start(-1) which tells the simulator to run until there are no more events to service rather than running for a specific length of time. When you use this method the time is advanced to a very large number to make sure no more events need to be serviced. It talks a little bit about it here: http://www.scribd.com/doc/53124102/27/sc-start – stephenmm Jul 21 '12 at 01:18
0

This seems a little hackish but you could update a global time variable with sc_time_stamp() at key points in your code that might be the end of a sim, like before waits or before you return from a time consuming function? Then after returning from sc_start() you would have the last time value from the code you care about.

stephenmm
  • 2,640
  • 3
  • 30
  • 48