1.11.1. The component class

This section contains the check list for the component class.

Defining your component class

  1. Derive your component class from CASIModule:

    class MyModel : public CASIModule 
    

    Note

    CASIModule has the public virtual function ObtainInterface(). All components deriving from CASIModule implement the CAInterface class. with at least revision 0 for the interface named CAInterface. The CAInterface class enables extending the ESL API interfaces with custom interfaces. The default implementation is sufficient if your component only uses the standard ESL API interfaces.

  2. Declare all slave ports as friend:

    friend class MySlavePort;
    
  3. Define a constant for the component name. This constant is used in the getName() function and in the component factory:

    #define MODEL_NAME "DLX_Core"
    

The component constructor

  1. Create all ports in the component constructor:

    1. if you are creating a slave port, register it in the port list:

      registerPort(new MySlavePort(…), "irq");
      
    2. if you are creating a master port, keep a pointer to it for fast access:

      ext_mem = createPort(CASI_TRANSACTION_MASTER, "ext_mem");
      

      then register it in the port list:

      registerPort(ext_mem, "ext_mem");
      
    3. register the clock slave port if the component is clocked:

      registerPort(dynamic_cast<CASIClockSlaveIF*>(this), "clk_in");
      
  2. If the component class is clocked, call casi_clocked() function:

    casi_clocked();
    

    Note

    You can register the clock in the interconnect stage instead of in the constructor. See The interconnect() function.

  3. Define all parameters in the component constructor.

The component destructor

  1. Delete only what has been created in the constructor. This includes the created ports.

The getName() function

  1. Return the model-name defined in the component header file.

  2. Ensure that this name is equivalent to the name used in the component factory’s constructor.

The getProperty() function

Note

This function must be implemented for all models.

  1. For CASI_PROP_COMPONENT_TYPE, use the CASIComponentTypes array to return the type of your component.

  2. For CASI_PROP_COMPONENT_VERSION, return the version number of your component.

  3. For CASI_PROP_DESCRIPTION, return a brief description of your component and its key features.

  4. If your component has its own loader, use CASI_PROP_LOADFILE_EXTENSION identify the types of files to look for.

The setParameter() function

  1. Implement this function if your component is configurable.

  2. Distinguish initialization time parameters and runtime parameters.

  3. If possible, do not access resources directly but instead set flags to control resource allocation.

  4. Do not access resources that are allocated during init().

    Note

    setParameter() is called before the init() function.

  5. For initialization time parameters, defer the parameter evaluation to the init stage.

  6. Call CASIModule::setParameter() to ensure that the parameter changes are registered in the parameter list.

The configure() function

  1. Implement this function only if your component has subcomponents.

  2. Do not define this function with an empty behavior, call CASIModule::configure() instead.

  3. After calling CASIModule::configure(), set the parameters of all of your subcomponents here if necessary.

The init() function

  1. Allocate all resources necessary for simulation here.

  2. Call CASIModule::init().

  3. Allow for parameters that might have been set during the configure stage.

The interconnect() function

  1. If your component has subcomponents, connect your subcomponents here.

  2. If your component is clocked, register it with the clockMaster.

    getClockMaster()->registerClockSlave(this);
    

    Note

    Use this function if the clocks were not registered by calling casi_clocked() in the constructor stage. See The component constructor.

  3. Call CASIModule::interconnect().

The reset() function

  1. Implement your reset behavior here.

  2. Check the reset level to distinguish hard and soft reset if applicable.

  3. If your model supports loading of object code, retrieve the filename for your model from the file list only during a hard reset.

  4. Call CASIModule::reset().

The terminate() function

  1. You must implement this function if you allocate memory in the init() function.

  2. Delete all objects created in init().

The communicate() and update() functions

  1. If your component is clocked these functions must be defined.

  2. All communication with other components must be done in the communicate() function.

  3. Updating of resources must be done in the update() function.

    Note

    It is technically possible to perform updating during the communicate phase, but this is not recommended because it can cause side effects or difficult to diagnose errors.

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