2.8.1. Enabling save/restore support

For a component to support the advanced save and restore feature:

  1. The component must be derived from CASISaveRestore:

    class MyModel : public CASIModule, public CASISaveRestore {
    
  2. The getProperty() function must return yes for the CASI_PROP_SAVE_RESTORE property. This informs the simulation environment about the save/restore capability of the component.

  3. The Save/Restore functionality of the component now exists but has not been initialized. If the initialization method is not called, it is not possible to save the component’s state. To initialize the Save/Restore functionality, call initStream(this) from the component’s constructor.

    Example 2.28. Initialization of save/restore functionality

    // Constructor for MyModel
    MyModel::MyModel( … )
    {
        // Create Component    
            ...
        
        // Call method inherited from CASISaveRestore
        // required to enable saving and restoring state information
        initStream( this );}
    
  4. Two pure virtual methods inherited from CASISaveRestore must be implemented. These methods must implement the details of saving and restoring of the component’s state information.

    Example 2.29. saveData and restoreData

    // Implementation of CASISaveRestore interface to save state
    bool MyModel::saveData( CASIODataStream &data )
    {
        // return save was successful
        return true;
    }
    
    // Implementation of CASISaveRestore interface to restore state
    bool MyModel::restoreData( CASIODataStream &data )
    {
        // return restore was successful
        return true;
    }
    

    The above two methods are valid for a component that has no state information to save, but is required to support this feature so more complex systems that include the model can use Save/Restore.

    It is not unusual for components to not have any state to save. For example, a Fan Out component (FOUT) that distributes a signal to several components, completes its task in one cycle and has no state that must be saved. But for more complex components, there might be a lot of information that must be remembered.

Copyright © 2007 ARM Limited. All rights reserved.ARM DUI 0359B
Non-Confidential