{"id":138,"date":"2011-05-14T21:59:40","date_gmt":"2011-05-14T21:59:40","guid":{"rendered":"https:\/\/blogs.mathworks.com\/seth\/2011\/05\/14\/asynchronous-function-call-inputs-to-models\/"},"modified":"2017-04-25T11:15:33","modified_gmt":"2017-04-25T16:15:33","slug":"asynchronous-function-call-inputs-to-models","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/simulink\/2011\/05\/14\/asynchronous-function-call-inputs-to-models\/","title":{"rendered":"Asynchronous Function-Call Inputs to Models"},"content":{"rendered":"<p>In Simulink R2011a, it is possible to pass asynchronous function-call signals through Inports of a model. This enables the asynchronous function call to cross the boundary of <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2011a\/toolbox\/simulink\/slref\/model.html\">Model block<\/a>. Such function-call signals are typically used in Simulink models to capture<a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2011a\/toolbox\/rtw\/ug\/f9432.html\"> interrupt-driven processing<\/a> that is asynchronous with the time-driven processing in that model.<\/p>\r\n\r\n<p>In this post I want to provide an overview of the effects this enhancement could have on your models.<\/p>\r\n\r\n<strong><p>Model Architecture Decomposition<\/p><\/strong>\r\n\r\n<p>Simulink models can be structured in multiple ways. If you work in the automotive industry your model probably looks like one of the 2 types shown in this image, taken from the <a href=\"https:\/\/www.mathworks.com\/solutions\/automotive\/standards\/maab.html\">MAAB Control Algorithm Modeling Guidelines<\/a>.\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2011Q2\/Maab_structure.png\" alt=\"Model Architecture proposed in MAAB guidelines\"><\/p>\r\n\r\n\r\n<strong><p>Type A<\/p><\/strong>\r\n\r\n<p>In type A, when you open a model you see a trigger layer. The trigger layer groups algorithmic components into common rates subgroups.  This trigger layer can be componentized using <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2011a\/toolbox\/simulink\/ug\/bqgb1jo.html\">Function-Call Model Reference<\/a>. When opening your model, what you see looks like this:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2011Q2\/trigger_layer_mdlRef.png\" alt=\"Type A model - Trigger Layer using Referenced models\"><\/p>\r\n\r\n<strong><p>Type B<\/p><\/strong>\r\n\r\n<p>When you open a model of type B, you see the functional structure of the model. In my opinion, type B has many advantages over type A, for instance type B accurately captures both the timing and data dependencies between components more explicitly.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2011Q2\/structural_layer.png\" alt=\"Type B model - Structural Layer\"><\/p>\r\n\r\n<p>Before R2011a, componentizing the structural layer of a type B model using referenced models was not possible if the model contains asynchronous events. Now that asynchronuous function-call can be passed through input ports of referenced models, this type of componentization becomes possible:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2011Q2\/structural_layer_mdlRef.png\" alt=\"Type B model - Structural Layer\"><\/p>\r\n\r\n<p>Converting the structural layer to use model reference has the benefit that you have more rigorous componentization of this layer.<\/p>\r\n\r\n<strong><p>How does that work?<\/p><\/strong>\r\n\r\n<p>To learn more on that topic, I recommend going through the documentation section titled <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2011a\/toolbox\/rtw\/ug\/f9432.html#bswaez9\">Converting an Asynchronous Subsystem into a Model Reference<\/a>. After you converted the subsystem into a referenced model and configured it properly, you need to insert the Asynchronous Task Specification block, set its priority to the same as the incoming function-call, and configure the Inport block to output a function call:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2011Q2\/SetupRefMdl.png\" alt=\"Type B model - Structural Layer\"><\/p>\r\n\r\n\r\n<strong><p>Now It's your turn!<\/p><\/strong>\r\n\r\n<p>Are you going to take advantage of the possibility to pass asynchronous function call through referenced models inputs? Leave a <a href=\"https:\/\/blogs.mathworks.com\/seth\/?p=138&amp;#comment\">comment here<\/a>.<\/p>\r\n\r\n\r\n","protected":false},"excerpt":{"rendered":"<p>In Simulink R2011a, it is possible to pass asynchronous function-call signals through Inports of a model. This enables the asynchronous function call to cross the boundary of Model block. Such... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/simulink\/2011\/05\/14\/asynchronous-function-call-inputs-to-models\/\">read more >><\/a><\/p>","protected":false},"author":41,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[66,24,128,16],"tags":[195,456,196],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/138"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/comments?post=138"}],"version-history":[{"count":1,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/138\/revisions"}],"predecessor-version":[{"id":6491,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/138\/revisions\/6491"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/media?parent=138"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/categories?post=138"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/tags?post=138"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}