title: How to generate code for Simulink model which contains an export-function submodel?
body: <p>I'm using matlab 2019b to build this Simulink model: A function call generator calls an export-fuction submodel. <a href="https://i.stack.imgur.com/pbNkT.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pbNkT.jpg" alt="TopModel" /></a>
  An export-function model is a model with function call inputs.
  <a href="https://i.stack.imgur.com/Obn3f.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Obn3f.jpg" alt="SubModel" /></a></p>
  <p>I can generate code for the submodel using embedded coder, as well as run simulation of the top model. But generating code for the top model gives this error message:</p>
  <blockquote>
  <p>Model 'main' contains a reference model 'main/Model' that is set up as a multi-instance export-function, but model 'main' does not follow export-function rules.
  where 'main' is the top model name.</p>
  </blockquote>
  <p>The export-function model document <em><a href="https://www.mathworks.com/help/simulink/ug/export-function-models.html" rel="nofollow noreferrer">https://www.mathworks.com/help/simulink/ug/export-function-models.html</a></em> writes:</p>
  <blockquote>
  <p>For function-call Model blocks, Periodic sample time constraint for the referenced model set to Ensure sample time independent</p>
  </blockquote>
  <p>Following this rule throws another errors. If the top model's periodic sample time constraint is changed, the error is:</p>
  <blockquote>
  <p>This model will not inherit a sample time because the block 'main/Model' disallows it from doing so.  If this model does not need to inherit a sample time, change the &quot;Periodic sample time constraint&quot; to something other than &quot;Ensure sample time independent&quot; on the Solver tab of the Configuration Parameters dialog.</p>
  </blockquote>
  <p>And if the submodel's periodic sample time constraint is changed, the error is:</p>
  <blockquote>
  <p>The current diagnostic settings for model 'instance' are not valid because the model contains root-level Inport block 'instance/f' that outputs a function-call signal. See errors reported below for details.
  Caused by:
  In the export-function model 'instance', the parameter 'Periodic sample time constraint' in 'Configuration Parameters' &gt; 'Solver' &gt; 'Tasking and sample time options' must be set to 'Unconstrained'.
  Suggested Actions
  Set the 'Periodic sample time constraint' to 'Unconstrained' in 'instance'.</p>
  </blockquote>
  <p>How can I generate code for the top model?</p>