I donβt think that what you offer will reduce compilation time, since you seem to imply that most of the time is spent collecting the generated source files, i.e. itβs a C compiler that slows down, not Simulink.
If you create a mex (S-Function) file from this subsystem, your options should either be inlined S-Function, or non-inlined one. If the subsystem you are converting is rather trivial (and I assume that it is not), you will want to choose the former option, since the latter is very limited. However, in both cases, your C compiler will still compile the source files. In the inlined case, these will be the source files written by the TLC that you wrote, and in the other, the source files that you compiled to create the S-function itself.
The solution I can think of is to duplicate the functionality of the falling subsystem in C and use the built-in target compiler to create a static library. In addition, create a built-in S-function that mimics this subsystem in a simulation. In the TLC file for this S function, you simply ask Simulink to include the corresponding header file for the static library, and then make function calls that reference the library. This eliminates the need for the compiler to recompile the source during each build of the model.
You also need to figure out how to pass the linker a directive to link to the static library when building the model (assuming that the code generation process automatically calls the built-in compiler to build the code).
source share