Problem with code reusabilty of inlined S-Function // multiple referencing
7 次查看(过去 30 天)
显示 更早的评论
Hello,
I'm trying to use model referencing in my project. Therefore, I need model references to models containing S-Functions. The S-Function is inlined using a tlc file and I have used
ssSetOptions(S,(SS_OPTION_USE_TLC_WITH_ACCELERATOR | SS_OPTION_WORKS_WITH_CODE_REUSE));
in the mdlInitializeSizes routine of the corresponding c file to make it reusable.
However, when trying to build the model, I keep getting the following error report:
'Configuration Parameters > Model Referencing > Total number of instances allowed per top model' is set to 'Multiple' for model 'Submodel'. S-Function block 'Submodel/Init_PWM/fcn_VentOn_uP1/fpga_interface' of this model does not support code reuse. This is not allowed in a model configured to be referenced multiple times.
To enable code reuse, the block must have a TLC implementation and the S-function's mdlInitializeSizes function must set the options 'SS_OPTION_USE_TLC_WITH_ACCELERATOR' and 'SS_OPTION_WORKS_WITH_CODE_REUSE'.
To configure the model to be referenced only once, change the configuration parameter 'Total number of instances allowed per top model' to 'One'.
Any suggestions about my point of failure?
A question closely related to the one above is: When will the mdlInitializeSizes c-routine be executed? Shouldn't it normally be ignored due to the existing tlc file?
0 个评论
回答(4 个)
Kaustubha Govind
2011-3-1
mdlInitializeSizes is run when the S-function's parent model is compiled by the Simulink Engine - in other words, right before code generation. The TLC file is used to generate code for the S-function. So, the S-function MEX file is ignored when the top-level model is calling into the referenced model's generated code.
2 个评论
Kaustubha Govind
2011-3-3
In my book, a device driver is any software that somehow accesses a hardware resource. It would not be suitable for re-use because it could result in multiple instances trying to access the same hardware resource (a bad idea in most situations, unless the resource can manage competing requests).
Could you try creating multiple instances of your S-function is a single model and try generating code from it? (Don't use model reference). Are you able to build code successfully? Is the S-function code generated as a reusable function?
Eike
2011-3-3
1 个评论
Kaustubha Govind
2011-3-3
FYI: I had seen your comment yesterday, but didn't have time to address it. :)
Eike
2011-3-4
2 个评论
Kaustubha Govind
2011-3-4
I'm glad you fixed the issue, but I agree that error reporting should be improved. I could create an internal change request to improve this error, but I will need an example model and S-function to reproduce the issue. Please let me know if it is possible for you to pare down your model to its bare minimum so we can use it for testing.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Target Language Compiler 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!