I create a model by Simulink+Stateflow (aaa). Then create another model (bbb) that uses two instance of the previous one. Then I generate the code from the models to use it onto a phisical board. The problem is that I have 2 files from model aaa (aaa.c and aaa.h) and three files from the model bbb (bbb.c, bbb.h and aaa.h) because aaa is used in bbb. But the files aaa.h are different (there are some similarities, but each one is useful for aaa or bbb code). So it is impossible for me to use the models together.
Does it exist a best practice to integrate the generate code? Or does it exists a Simulink option to create directly all I need?
Thank you
As Phil said, if you are using Model Reference (it sounds like you are), then it should do incremental build and code generation. Generate code for the top-level model and all models that are referenced by it will automatically generate code as well. See http://www.mathworks.co.uk/help/simulink/examples/component-based-modeling-with-model-reference.html and http://blogs.mathworks.com/seth/2008/12/05/the-answer-for-large-scale-modeling-model-reference/ as examples.