5.6.3. Simulation control functions

The time to pass to SystemC wait() after the Fast Models system has been simulated for a quantum is determined by:

break_quantum()

void break_quantum(unsigned long delta = 0)

Note

This function is deprecated. Use break_ quantum_seconds() instead.

break_quantum_seconds()

Note

This function is a convenience function for break_quantum(). The parameter is time in seconds instead of simulation ticks.

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_time

specifies 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.

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().

get_callbacks()

This function returns the callback object registered within the Fast Models simulation. The format is:

sc_sg_callbacks * get_callbacks() const

get_cycle_count()

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()

get_freq()

Note

This function is deprecated. Use get_frequency() instead.

get_frequency()

Use this function to retrieve the simulation frequency of the exported Fast Models system. The format is:

unsigned long long get_frequency() const

get_global_quantum()

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;

Note

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.

get_quantum_seconds()

If including headers of a previous TLM version, this function retrieves time in seconds per simulation quantum. The format is:

double get_quantum_seconds() const;

Note

If this function is called with TLM 2.0 final headers included, it falls back to using get_global_quantum().

The frequency must have been set with the set_frequency() API call before using the quantum API functions.

get_quantum()

This function is deprecated. Use get_global_quantum() instead. (See get_global_quantum().)

Note

If this function is called with TLM 2.0 final headers included, it falls back to using get_global_quantum().The frequency must have been set with the set_frequency() API call before using the quantum API functions.

get_rate()

Note

This function has been deprecated. Use get_clock_rate() instead for equivalent results.

get_slot()

Note

This function is deprecated. Use get_global_quantum() instead. (See get_global_quantum().)

sc_sg_break_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_time

specifies the number of seconds from now to when the simulation quantum is to be broken.

set_callbacks()

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:

cb

specifies a pointer to an instance of an sc_sg_callbacks derived class that defines these virtual methods. See Example 5.7.

Example 5.7. 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 System Generator simulation 
            *at the start of each quantum.
            *This default implementation does nothing.
            *mode - one of:
            *SC_SG_MODE_INIT
            *SC_SG_MODE_STOP
            *SC_SG_MODE_RUN
            *SC_SG_MODE_BPT */
        
        virtual void wait(double time, int mode);  
           /*Called by the System Generator simulation 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:
            *SC_SG_MODE_INIT
            *SC_SG_MODE_STOP
            *SC_SG_MODE_RUN
            *SC_SG_MODE_BPT*/ 
        virtual void proceed_quantum(int /* mode */){}; 
           /* Called by the System Generator simulation 
            *before executing the System Generator scheduler
            *This default implementation does nothing.
            *mode - one of:
            *SC_SG_MODE_INIT
            *SC_SG_MODE_STOP
            *SC_SG_MODE_RUN
            *SC_SG_MODE_BPT */
        virtual void simulation_quit(int /* mode */ );
           /* Called by the System Generator simulation 
            *before simulation quits.
            *This default implementation calls sc_stop().
            *mode - one of:
            *SC_SG_MODE_INIT
            *SC_SG_MODE_STOP
            *SC_SG_MODE_RUN
            *SC_SG_MODE_BPT */
        virtual void simulation_stop(int /* mode */ ){};
           /* Called by the System Generator simulation 
            *after simulation stops, e.g. after application exit.
            *This default implementation does nothing.
            *mode - one of:
            *SC_SG_MODE_INIT
            *SC_SG_MODE_STOP
            *SC_SG_MODE_RUN
            *SC_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.

set_freq()

Note

This function has been deprecated. Use set_frequency() instead.

set_frequency()

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 the set to the highest frequency connected to one of the CPUs. The format is:

void set_frequency(unsigned long long freq)

where:

freq

specifies the simulation frequency.

Note

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.

set_global_quantum()

If including TLM 2.0 final headers, 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);

Note

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.

If this function is called without including TLM 2.0 final headers, it falls back to using set_quantum_seconds().

The frequency must have been set with set_frequency() API call before using the quantum API functions.

set_quantum_seconds()

If including headers from a TLM version before 2.0, 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_quantum_seconds(double interval);

Note

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.

If this function is called with TLM 2.0 final headers included, it falls back to using set_global_quantum().

The frequency must have been set with the set_frequency() API call before using the quantum API functions.

set_quantum()

Note

This function is deprecated. Use set_global_quantum() instead.

If this function is called with TLM 2.0 final headers included, it falls back to using set_global_quantum(). (See get_global_quantum().)

The frequency must have been set with the set_frequency() API call before using the quantum API functions.

set_rate()

Note

This function is deprecated. Use set_frequency() instead for equivalent results. (See get_frequency().)

set_slot()

Note

This function is deprecated. Use set_global_quantum() instead. (See get_global_quantum().)

stop()

Note

This function is deprecated. Use the SystemC function sc_stop() instead.

Copyright © 2007-2009 ARM Limited. All rights reserved.ARM DUI 0370H
Non-Confidential