This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

module$use issue



I am attempting to set a config value in the module$use function in one of my modules. This particular config value I'm setting to the length of a config vector, which I'm treating as a constant in my C code. Multiple other modules use this particular module, and add values to the vector. By the end of the config process, the length config value, does not match param.length.

moda:

module$use()

{

   moda.numVals = moda.Vals.length;

}

modb:

module$use()

{

moda = xdc.usemodule('moda');

moda.Vals.length++:

moda.Vals[moda.Vals.length] = 5;

}

modc:

module$use()

{

moda = xdc.usemodule('moda');

moda.Vals.length++:

moda.Vals[moda.Vals.length] = modc.something;

}

The docs on rtsc-pedia make is sound like moda's use function should be re-evaluated after modb and modc's functions.

Is there perhaps a better way to do this (looking to keep the final value a constant so it lands in ROM)

Thanks!

  • norton256,
    the relevant documentation for your question is at http://rtsc.eclipse.org/docs-tip/Creating_Configurable_Content. You can see there that the order of module$use functions is not guaranteed. Also, the important property of module$use functions is that they execute only once within a configuration. Finally, in the closing phase, a call to useModule() causes an immediate execution of module$use, unless it was executed earlier.
    All that taken together means that as soon as you call xdc.useModule(ModA) from either ModB or ModC, ModA's module$use gets executed immediately for the first useModule(ModA), and then the second call is ignored. That's the opposite of what you need to happen, which is that ModA's module$use gets executed after the second call.

    So, you need a different solution. You can set up a setter on a config parameter, including a vector length, which will run whenever a change is made to the underlying config parameter. Putting a setter on a vector length is a little bit more complicated than the example in the link.

    var GetSet = xdc.module("xdc.services.getset.GetSet");

    GetSet.onSet(ModA.Vals, "length", function(sel, val, oldVal) {
            ModA.numVals = val;
    });

    I haven't tested this, but try it and let me know if you have some problems.

  • That is a pretty awesome feature! Thanks for pointing me to it. It worked great