Changes between Version 17 and Version 18 of ObjectDeveloperGuide
- Timestamp:
- 11/28/09 14:06:57 (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ObjectDeveloperGuide
v17 v18 17 17 18 18 ||'''Directory'''||'''Files'''||'''Comment'''|| 19 ||''myobj''/platform_make/||...||One directory for each platform it can be compiled. For example:[[BR]]''lnx_make'' shall contain the Makefile, ''c6000_make'' shall contain CCS' .pjt files, etc.|| 19 20 ||''myobj''/interfaces/||inputs.h[[BR]]outputs.h[[BR]]stats.h||Definition of input/output interfaces, statistics variables and initialization parameters|| 20 ||''myobj''/src/||m yobj.c[[BR]]myobj_imp.c[[BR]]xxx.c||Implementation (myobj_imp.c + xxx.c) of the algorithm and main skeleton (myobj.c)[[BR]][[BR]]See below for more information||21 ||''myobj''/src/||module.c[[BR]]module_imp.c[[BR]]myobj.c||myobj.c: Standalone function implementing the algorithm.[[BR]]module.c and module_imp.c is the skeleton[[BR]]See below for more information|| 21 22 ||''myobj''/bin/||myobj||Binaries after compilation and linking are placed here.|| 22 23 … … 65 66 In order to facilitate objects programming an skeleton implementing some common functionalities has been defined. In this sense, the user will only have to define the interfaces in a constant structure and provide some functions to process data. The initialization and buffer management will be done by the skeleton. 66 67 67 This skeleton is provided in the m yobj.c file and is exactly the same for any object (so you can copy anyone provided by the example objects). The skeleton needs three header files: inputs.h, outputs.h and stats.h. Interfaces and statistics are defined in structures (defined in swapi_utils.h) which name has to be mantained (input_itfs, output_itfs, params and stats). The following figure describe these structures:68 This skeleton is provided in the module.c file and is exactly the same for any object (so you can copy anyone provided by the example objects). The skeleton needs three header files: inputs.h, outputs.h and stats.h. Interfaces and statistics are defined in structures (defined in swapi_utils.h) which name has to be mantained (input_itfs, output_itfs, params and stats). The following figure describe these structures: 68 69 69 70 '''Figure 2 – Structure definitions (swapi_utils.h)''' … … 155 156 156 157 }}} 157 You can read more of how to use these structures in the example objects. If you downloaded the source, they are in the example directory. 158 159 Finally, the following figure shows the file where the processing code should be written. Note that in the configuration of the structure we have provided a function to process (or generate) data for every interface. Now, the only thing we have to do is to code these functions: 160 161 '''Figure 3 – Object implementation (myobj_imp.c)''' 158 159 The other skeleton file, module_imp.c, is the bridge between the skeleton and the algorithm functions. It implements de functions called after a packet is received or must be generated. Although the algorithm could be implemented here, good coding practices recommend to do it in another file so the implementation shall be used in other contexts. 160 161 '''Figure 3 – Object implementation (module_imp.c)''' 162 162 163 163 {{{ … … 165 165 */ 166 166 #include <phal_sw_api.h> 167 #include <math.h>168 167 #include <swapi_utils.h> 169 168 170 169 #include <phal_hw_api.h> 171 170 #include <sys/resource.h> 172 173 #define PI 3.1415174 171 175 172 #include "inputs.h" … … 199 196 200 197 /* generate sinusoid */ 198 generate_sinusoid(output_data,fsin,fsamp); 199 200 SetStatsValue(stat_signal, output_data, len); 201 202 return 1; 203 } 204 205 int InitCustom() 206 { 207 return 1; 208 } 209 210 int RunCustom() 211 { 212 return 1; 213 } 214 215 216 }}} 217 The last two functions ({{{InitCustom()}}} and {{{RunCustom()}}}) have also to be defined. The {{{InitCustom}}} function is used to implement custom initialization routines not related with interface or statistics initialization. For example, if an object has to compute a set of filter coeficients given an initialization parameter, it can be done in this function. The skeleton will get the parameter(s) value if we define it in the specific structure. After that, the {{{InitCustom}}} function will be called and we will perform the computations. 218 219 Analogously, the {{{RunCustom}}} function might be useful to perform some background tasks not related directly with data processing (more formally, asyncrhonous with data flow). An example of this may be updating an internal state. 220 221 Finally, the actual algorithm will be implemented in a standalone file, for example, myobj.c: 222 {{{ 223 /** ALOE headers 224 */ 225 #include <phal_sw_api.h> 226 #include <math.h> 227 228 #define PI 3.1415 229 230 void generate_sinusoid(int *output_data, float fsin, float fsamp) 231 { 232 int i; 201 233 for (i=0;i<len;i++) { 202 234 output_data[i] = (int) ((float) 1000.0*cosf((double) 2.0*PI*fsin*i/freq)); 203 235 } 204 205 SetStatsValue(stat_signal, output_data, len); 206 207 return 1; 208 } 209 210 int InitCustom() 211 { 212 return 1; 213 } 214 215 int RunCustom() 216 { 217 return 1; 218 } 219 220 221 }}} 222 The last two functions ({{{InitCustom()}}} and {{{RunCustom()}}}) have also to be defined. The {{{InitCustom}}} function is used to implement custom initialization routines not related with interface or statistics initialization. For example, if an object has to compute a set of filter coeficients given an initialization parameter, it can be done in this function. The skeleton will get the parameter(s) value if we define it in the specific structure. After that, the {{{InitCustom}}} function will be called and we will perform the computations. 223 224 Analogously, the {{{RunCustom}}} function might be useful to perform some background tasks not related directly with data processing (more formally, asyncrhonous with data flow). An example of this may be updating an internal state. 236 } 237 }}} 225 238 226 239 == Compiling and Linking == 227 240 Compiling an ALOE objects does not need any other consideration rather than linking with the ALOE SW Library and HW Library. Obviously, we have to pick the HW library of our system. Under linux, and once we have installed ALOE (binary or source), the libraries should appear at /usr/local/lib with the names libsw_api.a and libhw_api.a. 228 241 229 If your prefer to use autoconf/automake tools the following attached files might be useful: 230 231 * sample configure.in 232 * sample Makefile.am 242 If your prefer to use autoconf/automake tools you might find useful the example Makefile.am included in the sample modules shipped in the ALOE distribution (under lnx_make). 243 233 244 234 245 [wiki:ALOE "[Back to ALOE]"]