Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » DSDP - Real-Time Software Components (RTSC) » Is there a way to increase the size of array in instance_params at config time using cfg file
Is there a way to increase the size of array in instance_params at config time using cfg file [message #506355] Thu, 07 January 2010 09:06 Go to next message
Ravindranath  is currently offline Ravindranath Friend
Messages: 2
Registered: October 2009
Junior Member
I would like to increase the size of an array declared under instance_params to a new value at config time using applications cfg file. Confused
Re: Is there a way to increase the size of array in instance_params at config time using cfg file [message #506499 is a reply to message #506355] Thu, 07 January 2010 17:57 Go to previous message
Dave Russo is currently offline Dave RussoFriend
Messages: 172
Registered: July 2009
Senior Member
On 1/7/2010 1:06 AM, Ravindranath wrote:
> I would like to increase the size of an array declared under
> instance_params to a new value at config time using applications cfg
> file. :?

Can you be more specific? Is this question different from the previous
thread (copied below)?

-------- Original Message --------
Subject: Re: Issue with declaring structure variable and array under
instance label in xdc fi
Date: Thu, 27 Aug 2009 10:33:57 -0700
From: dave russo <d-russo@ti.com>
Organization: EclipseCorner
Newsgroups: eclipse.dsdp.rtsc
References: <af0eeffdd22dd9d969cfa88723e1d888$1@www.eclipse.org>
<h6kbon$kt2$1@build.eclipse.org>
<641bd53e8b727e928ea166726d70e0f7$1@www.eclipse.org>
<h747r8$25h$1@build.eclipse.org>
<30bf1791d54cc8e484e30860cad23198$1@www.eclipse.org>

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(&params);
for (i = 0; i < Mod_ARR_SIZE; i++) {
params.myArr[i] = i; /* ERROR: myArr has just 2 elements */
}
inst = Mod_create(&params, 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(&params);
inst = Mod_create(&params, 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
>
Previous Topic:XDCtools 3.16.02 is available
Next Topic:Adding non-RTSC types into XDC file
Goto Forum:
  


Current Time: Sat Apr 20 01:35:28 GMT 2024

Powered by FUDForum. Page generated in 0.02995 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top