Skip to content

Commit

Permalink
Propagate dependencies into AF output args
Browse files Browse the repository at this point in the history
Per issue Qucs#67, the e:dependency template in adms.implicit.xml will
propagate probe and variable dependencies from analog function
arguments into the top-level expression in which the function is
called (generally the RHS of an assignment), but does NOT do the same
thing for any output arguments that might exist in the analog
function.

Some new CMC standard models (e.g. the MVSG-HV model) use analog
functions in this manner, and it would be good to fix it.

This commit augments the e:dependency template so that it completely
propagates all dependencies from function arguments into any output
variables that might exist.  It is a no-op if there are no such
function output arguments.

This commit also obsoletes pull request Qucs#68.
Unlike that PR, this one makes sure to perform dependency checking on
the input arguments before copying their probe dependencies, and
unlike that PR, it also copies their variable dependencies.  Also
unlike that code, it will correctly handle output arguments that are
not at the beginning of the argument list, because it selects all
arguments in the function definition in order and uses their position
in the global list rather than selecting only the output arguments and
using their position in the truncated list.

Issue Qucs#67
PR Qucs#68
  • Loading branch information
tvrusso committed Nov 28, 2022
1 parent cadf421 commit 94a0e27
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions admsXml/adms.implicit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
<admst:variable name="globalopdependent" string="no"/>
<admst:variable name="globalpartitionning"/>
<admst:variable name="globaltreenode"/>
<admst:variable name="globalhandleafoutputs" string="no"/>
<admst:variable name="globalaf"/>

<admst:template match="e:dependency">
<admst:choose>
Expand Down Expand Up @@ -71,6 +73,9 @@
<admst:when test="[datatypename='probe']">
<admst:value-to select="dependency" string="linear"/>
<admst:push into="$globalexpression/probe" select="." onduplicate="ignore"/>
<admst:if test="[$globalhandleafoutputs='yes']">
<admst:push into="$globalaf/@probe" select="." onduplicate="ignore"/>
</admst:if>
</admst:when>
<admst:when test="[datatypename='array']">
<admst:apply-templates select="variable" match="e:dependency"/>
Expand All @@ -81,6 +86,12 @@
<admst:push into="$globalexpression/variable" select="." onduplicate="ignore"/>
<admst:push into="$globaltreenode/@variable" select="." onduplicate="ignore"/>
<admst:value-to select="dependency" path="prototype/dependency"/>

<admst:if test="[$globalhandleafoutputs='yes']">
<admst:push into="$globalaf/@probe" select="probe" onduplicate="ignore"/>
<admst:push into="$globalaf/@variable" select="." onduplicate="ignore"/>
</admst:if>

</admst:when>
<admst:when test="[datatypename='mapply_unary']">
<admst:apply-templates select="arg1" match="e:dependency"/>
Expand Down Expand Up @@ -160,7 +171,32 @@
<admst:value-to select="dependency" string="constant"/>
</admst:when>
<admst:otherwise>
<!-- track dependencies of analog function output arguments -->
<admst:if test="[definition/datatypename='analogfunction']">
<admst:variable name="function" select="%(.)"/>
<admst:if test="[exists(definition/variable[(output='yes') and (name!=$function/name)])]">
<admst:variable name="globalhandleafoutputs" string="yes"/>
<admst:variable name="globalaf" path="."/>
</admst:if>
</admst:if>
<!-- process arguments normally -->
<admst:apply-templates select="arguments" match="e:dependency"/>
<!-- propagate dependencies into output arguments -->
<admst:if test="[$globalhandleafoutputs='yes']">
<admst:variable name="globalhandleafoutputs" string="no"/>
<admst:variable name="globalaf"/>
<admst:for-each select="definition/variable">
<admst:if test="[(output='yes') and (name!=$function/name)]">
<admst:variable name="position" select="%(position(.)-1)"/>
<admst:fatal test="[$function/arguments[position(.)=$position]/datatypename!='variable']"
format="%(function/name) output arg $position is %(.), must be a variable\n"/>
<admst:push into="$function/arguments[position(.)=$position]/probe" select="$function/@probe" onduplicate="ignore"/>
<admst:push into="$function/arguments[position(.)=$position]/variable" select="$function/@variable" onduplicate="ignore"/>
</admst:if>
</admst:for-each>
<admst:value-to select="$function/@probe"/>
<admst:value-to select="$function/@variable"/>
</admst:if>
<admst:choose>
<admst:when test="[(name='ddt' or name='\$ddt')or(name='idt' or name='\$idt')]">
<admst:value-to select="dependency" string="nonlinear"/>
Expand Down

0 comments on commit 94a0e27

Please sign in to comment.