| |||
| Home > SystemC Export > SystemC component API > Simulation control functions | |||
The time to pass to SystemC wait() after
the Fast Models system has been simulated for a quantum is determined
by:
the parameter value specified in
the set_global_quantum() method
the Fast Models simulation frequency specified by
the parameter value used in the set_frequency() method.
void break_quantum(unsigned long delta = 0)
This function is deprecated. Use break_ quantum_seconds() instead.
Use this function to instruct the Fast Models simulation to break its current simulation quantum. The format is:
void break_quantum_seconds(double intr_time = 0)
where:
intr_timespecifies the number of seconds from now to when the simulation quantum is to be broken.
If break_quantum_seconds() is called,
the Fast Models system simulation stops intr_time seconds
from the method call. The SystemC wait() callback
is called, with an sc_time value corresponding
to the fraction of the quantum simulated so far, to enable simulating
other SystemC components. If intr_time is zero,
the simulation quantum is broken immediately, that is, as soon as
the callee returns control to the simulation.
break_quantum_seconds() can be called
more than once per simulation quantum. The simulation quantum is
broken as many times as break_quantum_seconds() is
called. After the quantum has been broken, the next quantum is a
new/full quantum.
However, distinct calls to break_quantum_seconds() are
merged if they refer to the same simulation timing point. This is
done even though the calls might have come from within distinct
quantums.
It is the responsibility of the SystemC scheduler, or any
other component of the SystemC environment, to call break_quantum_seconds() with
the appropriate parameter.
To synchronize Fast Models and SystemC environments, ARM recommends
using break_quantum_seconds() instead of SystemC wait().
See also sc_sg_break_quantum().
This function returns the callback object registered within the Fast Models simulation. The format is:
sc_sg_callbacks * get_callbacks() const
This function returns the total number of cycles simulated by the Fast Models system since the start of the simulation. The format is:
unsigned long long get_cycle_count()
Use this function to retrieve the simulation frequency of the exported Fast Models system. The format is:
unsigned long long get_frequency() const
This function retrieves the global simulation quantum time
in seconds as stored in the TLM 2.0 final class tlm_global_quantum.
The format is:
double get_global_quantum() const;
If this function is called without including TLM 2.0 final
headers, it falls back to using get_quantum_seconds().
The frequency must have been set with the set_frequency() API
call before using the quantum API functions.
This function retrieves the time in seconds per local simulation quantum of the exported Fast Models subsystem. The format is:
double get_quantum_seconds() const;
The frequency must have been set with the set_frequency() API
call before using the quantum API functions.
This function retrieves the local quantum of the exported Fast Models subsystem in simulation clock ticks. The format is:
unsigned long get_quantum()
This function is deprecated. Use get_quantum_seconds() instead.
(See get_quantum_seconds()). The
frequency must have been set with the set_frequency() API
call before using the quantum API functions.
This function has been deprecated. Use get_clock_rate() instead
for equivalent results.
This function is deprecated. Use get_global_quantum() instead.
(See get_global_quantum().)
Use this function to pass a time value in seconds to the break_quantum_seconds function
of the wrapper component. It there is no wrapper instance, SystemC wait() is called.
The format is:
void sc_sg_break_quantum(double intr_time = 0)
where:
intr_timespecifies the number of seconds from now to when the simulation quantum is to be broken.
This is a convenience function for break_quantum_seconds(). It can be replaced by the following call in the SystemC component:
sc::sc_sg_wrapper_base::get_instance()->break_quantum_seconds(intr_time);
Use this function to register a callback object within the Fast Models simulation. The format is:
void set_callbacks(sc::sc_sg_callbacks * cb)
where:
cbspecifies a pointer to an instance of an sc_sg_callbacks derived
class that defines these virtual methods. See Example 5.8.
Example 5.8. sc_sg_callbacks class
namespace sc
{
class sc_sg_callbacks
{
public:
virtual ~sc_sg_callbacks(){};
// the callbacks
public:
virtual void start_of_quantum(int /* mode */){};
/*Called by the EVS
*at the start of each quantum.
*This default implementation does nothing.
*mode - one of:
*SG_MODE_INIT
*SG_MODE_STOP
*SG_MODE_RUN
*SG_MODE_BPT */
virtual void wait(double time, int mode);
/*Called by the EVS to
*synchronize with SystemC.
*This default implementation calls sc_wait() with the
*appropriate sc_time argument.
*t - time to wait in seconds
*mode - one of:
*SG_MODE_INIT
*SG_MODE_STOP
*SG_MODE_RUN
*SG_MODE_BPT*/
virtual void proceed_quantum(int /* mode */){};
/* Called by the EVS
*before executing the System Generator scheduler
*This default implementation does nothing.
*mode - one of:
*SG_MODE_INIT
*SG_MODE_STOP
*SG_MODE_RUN
*SG_MODE_BPT */
virtual void simulation_quit(int /* mode */ );
/* Called by the EVS
*before simulation quits.
*This default implementation calls sc_stop().
*mode - one of:
*SG_MODE_INIT
*SG_MODE_STOP
*SG_MODE_RUN
*SG_MODE_BPT */
virtual void simulation_stop(int /* mode */ ){};
/* Called by the EVS
*after simulation stops, e.g. after application exit.
*This default implementation does nothing.
*mode - one of:
*SG_MODE_INIT
*SG_MODE_STOP
*SG_MODE_RUN
*SG_MODE_BPT */
};
};
The callback object defines a set of methods that the Fast Models simulation calls at a predefined simulation time point.
The Fast Models simulator has its own predefined callbacks, with default implementations. The callbacks object given to the method can override the default implementations.
Use this function to specify the simulation frequency of the exported Fast Models system. The specified frequency must be the same as the master clock rate of the CPU component in the Fast Models system. If multiple CPUs are present, it must be set to the highest frequency connected to one of the CPUs. The format is:
void set_frequency(unsigned long long freq)
where:
freqspecifies the simulation frequency.
The set_frequency() method can be called
before sc_start() or at any time during simulation.
If called after sc_start(), the new simulation
frequency is taken into account at the next simulation quantum.
Use this function to define the global simulation quantum
time in seconds. The System Generator system is simulated for the
specified time before calling SystemC wait() to allow
simulating other SystemC components. The format is:
void set_global_quantum(double interval);
This method can be called before sc_start() or
at any time during simulation. If called after sc_start(),
the number of seconds per simulation slot is taken into account
at the next simulation slot. It is highly recommended to call this
function or set_quantum_seconds() before sc_start() to
set a reasonable high quantum to achieve high simulation performance.
The frequency must have been set with set_frequency() API
call before using the quantum API functions. If a quantum of 100000
is set the call looks like
/* Simulation quantum, i.e. seconds to run per quantum */ <instance>.set_global_quantum(100000.0 / <instance>.get_frequency());
where <instance> refers to the name
of the EVS instance.
Use this function to define the local simulation quantum time
of the exported Fast Models subsystem in seconds. The Fast Models
system is simulated for the specified time before calling SystemC wait() to
allow simulating other SystemC components. The format is:
void set_quantum_seconds(double interval);
This method can be called before sc_start() or
at any time during simulation. If called after sc_start(),
the number of seconds per simulation slot is taken into account
at the next simulation slot.The frequency must have been set with
the set_frequency() API call before using the quantum
API functions. Once one of the local quantum setting API functions
has been called, the global tlm quantum is no longer queried during
simulation to update the local simulation quantum of the exported
Fast Models subsystem.
If a quantum of 100000 is set the call looks like
/* Simulation quantum, i.e. seconds to run per quantum */ <instance>.set_global_quantum(100000.0 / <instance>.get_frequency());
where <instance> refers to the name
of the EVS instance.
This function is deprecated. Use set_frequency() instead
for equivalent results. (See get_frequency().)
This function is deprecated. Use set_global_quantum() instead.
(See get_global_quantum().)