| |||
| Home > Introduction > Checklist for components > The component class |
This section contains the check list for the component class.
Derive your component class from CASIModule:
class MyModel : public CASIModule
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.
Declare all slave ports as friend:
friend class MySlavePort;
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"
Create all ports in the component constructor:
if you are creating a slave port, register it in the port list:
registerPort(new MySlavePort(…), "irq");
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");
register the clock slave port if the component is clocked:
registerPort(dynamic_cast<CASIClockSlaveIF*>(this), "clk_in");
If the component class is clocked, call casi_clocked() function:
casi_clocked();
You can register the clock in the interconnect stage instead of in the constructor. See The interconnect() function.
Define all parameters in the component constructor.
Delete only what has been created in the constructor. This includes the created ports.
Return the model-name defined in the component header file.
Ensure that this name is equivalent to the name used in the component factory’s constructor.
This function must be implemented for all models.
For CASI_PROP_COMPONENT_TYPE,
use the CASIComponentTypes array to return the
type of your component.
For CASI_PROP_COMPONENT_VERSION,
return the version number of your component.
For CASI_PROP_DESCRIPTION, return
a brief description of your component and its key features.
If your component has its own loader, use CASI_PROP_LOADFILE_EXTENSION identify the
types of files to look for.
Implement this function if your component is configurable.
Distinguish initialization time parameters and runtime parameters.
If possible, do not access resources directly but instead set flags to control resource allocation.
Do not access resources that are allocated during init().
setParameter() is called before the init() function.
For initialization time parameters, defer the parameter evaluation to the init stage.
Call CASIModule::setParameter() to
ensure that the parameter changes are registered in the parameter
list.
Implement this function only if your component has subcomponents.
Do not define this function with an empty behavior,
call CASIModule::configure() instead.
After calling CASIModule::configure(),
set the parameters of all of your subcomponents here if necessary.
Allocate all resources necessary for simulation here.
Call CASIModule::init().
Allow for parameters that might have been set during the configure stage.
If your component has subcomponents, connect your subcomponents here.
If your component is clocked, register it with the clockMaster.
getClockMaster()->registerClockSlave(this);
Use this function if the clocks were not registered by calling casi_clocked() in
the constructor stage. See The component constructor.
Call CASIModule::interconnect().
Implement your reset behavior here.
Check the reset level to distinguish hard and soft reset if applicable.
If your model supports loading of object code, retrieve the filename for your model from the file list only during a hard reset.
Call CASIModule::reset().
You must implement this
function if you allocate memory in the init() function.
Delete all objects created in init().
If your component is clocked these functions must be defined.
All communication with other components must be
done in the communicate() function.
Updating of resources must be done in the update() function.
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.