Supplementing Generated C : Implementation of Primitive Activities

Implementation of Primitive Activities

The file user_activities.c contains templates for every primitive activity that is to be implemented in the compilation profile’s activity-stub options. Each selected primitive activity contains a stub with the following format:

void user_code_for_<activity_name>()
{
/* Parameters :
Output <output data-elements>;
Input <input data-elements>;
Input/Output <Inout data-elements>;
*/
}
 

The parameters list describes the interface of the activity to the rest of the model. Note that these are not parameters in the programming-language sense. The parameters list is actually a reference list that shows the context of the activity to be implemented in the model.

void user_code_for_FFT()
{
/* Parameters
-- Input double sonar_datal;
-- Input double sonar_data2;
-- Output double processed_data;
/*
}
 

The previous example shows a primitive activity that represents an FFT filter. The data-items sonar_data1, sonar_data2 are flowing into FFT, and the processed_data is flowing outside. This is actually the interface of the FFT activity with the rest of the model. Mathematical processing functions such as an FFT filter, are typical cases where something is implemented as a primitive activity, and the algorithm could be taken from an existing library.

Once the user_activities.c file is generated, it is not overwritten when the code is regenerated. In subsequent generations of the code, a user_activities.c_temp file is generated. If new templates are generated, they should be merged from user_activities.c_temp into user_activities.c.

Note: Empty stubs stop right after activation and the sp (activity) event is generated in the next step.