5.7.2. Simulation with a debug server

A debug server with a CADI 2.0 interface can be started with the exported model. The initialization is done in the simulation phase before_end_of_elaboration(). The debug server is therefore ready to accept incoming requests after sc_start() is called. The scheduler executed for this case is shown in Figure 5.11.

After the simulation starts:

  1. The wait() callback is initiated with mode parameter set to SG_MODE_INIT.

  2. A check is made to determine whether a debugger command must be processed. Such commands are typically:

    • Run to changes the simulation state from stop to running

    • Stop to change the state from running to stop.

  3. The simulation state is tested to determine if the simulation is still running:

    Simulation running

    The following steps are executed. These steps are equivalent to the case where no debug server is started:

    1. If a previous quantum has executed, the start_of_quantum() callback is executed with parameter SG_MODE_RUN.

      If the previous quantum was interrupted by a breakpoint or stop command, the callback is not executed.

      Because a single step causes a breakpoint to be hit, the callback is not typically executed after a single step.

    2. The proceed_quantum() callback is executed before each execution of the Fast Models scheduler.

      This callback is especially useful for debugger integration that requires a notification before each start of simulation from the Fast Models subsystem.

    3. SG-platform is simulated for a time quantum equivalent to the number of simulation steps specified by set_quantum().

    4. The wait() callback is issued with the time parameter equal to the actual simulated time in Fast Models. This is typically used to issue a SystemC wait() to cause the SystemC model to simulate the same amount of time and synchronize the two models. This is the default implementation. A custom simulation environment can reimplement this callback.

    Simulation stopped

    The following steps are executed:

    1. A wait() callback is issued with the time parameter zero and the mode set to SG_MODE_STOP.

    2. The simulation is then suspended for 20ms to allow other simulators to catch up.

    3. The simulation resumes with the check for a pending debugger command that might have arrived.

    Note

    The following callback functions can be used to notify the end of simulation:

    simulation_quit()

    Called before the simulation quits because of a user event such as, for example, pushing the close button of the visualization component in the LinuxSystem example.

    The default implementation calls sc_stop(), but this can be overloaded by the SystemC user.

    simulation_stop()

    Called after the simulation stops because of, for example, application exit (_sys_exit).

    The default implementation does nothing, but this can be overloaded by the SystemC user.

    See also Simulation control functions.

Figure 5.11. Standalone simulation with a debug server


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