[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.dsdp.rtsc] Re: Issue with declaring structure variable and array under instance label in xdc fi
|
- From: dave russo <d-russo@xxxxxx>
- Date: Thu, 27 Aug 2009 10:33:57 -0700
- Newsgroups: eclipse.dsdp.rtsc
- Organization: EclipseCorner
- User-agent: Thunderbird 2.0.0.23 (Windows/20090812)
If I understand what you're looking for, I don't believe it's possible.
It sounds like you want specify the size of a module instance's creation
parameters at configuration time. For example
Mod.xdc:
module Mod {
config Int ARR_SIZE = 2;
instance:
config Int myArr[ARR_SIZE] = [0, 0];
}
User's .cfg script:
var Mod = xdc.useModule("...Mod");
Mod.ARR_SIZE = 10;
User's .c code:
main() {
Mod_Params params;
Mod_Handle inst;
Mod_Params_init(¶ms);
for (i = 0; i < Mod_ARR_SIZE; i++) {
params.myArr[i] = i; /* ERROR: myArr has just 2 elements */
}
inst = Mod_create(¶ms, NULL);
}
But the .c file is, in general, compiled before the configuration script
is run. As a result, the space allocated by the compiler on the stack
for params (i.e., sizeof(Mod_Params)), can't change as the result of
configuration.
An alternative might be to "allocate" the array in the instance object
itself and allow the user to initialize this array via an instance
method, say Mod_initArray(). The params structure can be initialized to
a default array whose size and values are controlled by config
parameters. This makes the instance usable even if the user does not
call Mod_initArray().
User's .c code:
Int myArr[10] = [1, ...];
main() {
Mod_Params params;
Mod_Handle inst;
Mod_Params_init(¶ms);
inst = Mod_create(¶ms, NULL);
Mod_initArray(inst, myArr, sizeof(arr));
}
Ravindranath wrote:
dave,
For example i have the following configuration in xdc file
config UInt32 ARR_SIZE = 2;
instance:
config UInt32 myArr[ARR_SIZE ]= [0,0] /* here normal procedure is to
initialize all the 2 elements. Suppose if ARR_SIZE is changed to a
higher value through the cfg file static initialization of myArr gives
error. To avoid this static initialization of myArr needs to be done
some how either in xs file or some other place.
why we need this type of declaration is application users does not
like to have pointers to which they have to declare variables and
assign them to pointers in Params.
Regards,
Ravindranath Andela