added support to 'div' builtin function
This commit is contained in:
parent
844fd93f92
commit
c087846c38
|
|
@ -3,7 +3,10 @@
|
|||
<!--
|
||||
$Id$
|
||||
$Log$
|
||||
Revision 1.11 2007-02-10 16:08:41 dwarning
|
||||
Revision 1.12 2007-05-11 07:19:57 r29173
|
||||
added support to 'div' builtin function
|
||||
|
||||
Revision 1.11 2007/02/10 16:08:41 dwarning
|
||||
unification for func and derivative
|
||||
|
||||
Revision 1.10 2006/03/07 10:12:12 r29173
|
||||
|
|
@ -205,6 +208,13 @@ if(isinf(var)) \\
|
|||
#define _pow(xy,x,y) xy = pow(x,y);
|
||||
#define _dx_pow(dx,xy,x,y) dx = (x==0.0)?0.0:((y/x)*xy);
|
||||
#define _dy_pow(dy,xy,x,y) dy = (x==0.0)?0.0:((log(x)/exp(0.0))*xy);
|
||||
|
||||
#define _div1(x,y) ((x)/(y))
|
||||
#define _div0(xy,x,y) xy=(x)/(y);
|
||||
#define _div(xy,dx,x,y) dx=1/(y); xy=(x)*dx;
|
||||
#define _dx_div(dx,xy,x,y)
|
||||
#define _dy_div(dy,dx,xy,x,y) dy = -xy*dx;
|
||||
|
||||
#define _limexp(val,arg) val = ((arg)<(80)) ? (exp(arg)) : (exp(80)*(1.0+(arg-80)));
|
||||
#define _d_limexp(val,dval,arg) val = ((arg)<(80)) ? (exp(arg)) : (exp(80)*(1.0+(arg-80))); dval = val;
|
||||
#define _fabs(val,arg) val = fabs(arg);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,10 @@
|
|||
<!--
|
||||
$Id$
|
||||
$Log$
|
||||
Revision 1.12 2007-05-07 09:01:18 r29173
|
||||
Revision 1.13 2007-05-11 07:19:58 r29173
|
||||
added support to 'div' builtin function
|
||||
|
||||
Revision 1.12 2007/05/07 09:01:18 r29173
|
||||
traverse blocks named 'noise' or 'initial_step' during guesstopology code creation
|
||||
|
||||
Revision 1.11 2007/05/04 14:48:09 r29173
|
||||
|
|
@ -67,6 +70,7 @@
|
|||
<!-- expression//function: mapping verilog-name == C-name of function -->
|
||||
<admst:template match="fname">
|
||||
<admst:choose>
|
||||
<admst:when test="[name='div']"><admst:return name="fname" value="_div1"/></admst:when>
|
||||
<admst:when test="[name='abs']"><admst:return name="fname" value="fabs"/></admst:when>
|
||||
<admst:when test="[name='\$shrinkl']"><admst:return name="fname" value="shrinkl"/></admst:when>
|
||||
<admst:when test="[name='\$shrinka']"><admst:return name="fname" value="shrinka"/></admst:when>
|
||||
|
|
|
|||
|
|
@ -5,7 +5,10 @@
|
|||
-->
|
||||
<!--
|
||||
$Log$
|
||||
Revision 1.17 2007-05-02 14:56:49 r29173
|
||||
Revision 1.18 2007-05-11 07:19:58 r29173
|
||||
added support to 'div' builtin function
|
||||
|
||||
Revision 1.17 2007/05/02 14:56:49 r29173
|
||||
changed required adms version to 2.2.6
|
||||
|
||||
Revision 1.16 2007/04/30 13:10:35 r29173
|
||||
|
|
@ -876,6 +879,49 @@
|
|||
<admst:apply-templates select="." match="function:getname"/>
|
||||
<admst:value-to select="/simulator/tmp" value="__%s_$index"/>
|
||||
</admst:when>
|
||||
<admst:when test="[name='div']">
|
||||
<admst:value-of select="index(./subexpression/expression/function,.)"/>
|
||||
<admst:variable name="index" select="%s"/>
|
||||
<admst:if test="/simulator/probe">
|
||||
<admst:for-each select="arguments">
|
||||
<admst:choose>
|
||||
<admst:when test="[position(.)=1]">
|
||||
<admst:apply-templates select="." match="subexpression:stringify:noprobe"/>
|
||||
<admst:variable name="x" select="%s"/>
|
||||
<admst:value-of select="/simulator/ddx"/>
|
||||
<admst:variable name="dx" select="%s"/>
|
||||
</admst:when>
|
||||
<admst:when test="[position(.)=2]">
|
||||
<admst:apply-templates select="." match="subexpression:stringify:noprobe"/>
|
||||
<admst:variable name="y" select="%s"/>
|
||||
<admst:value-of select="/simulator/ddx"/>
|
||||
<admst:variable name="dy" select="%s"/>
|
||||
</admst:when>
|
||||
<admst:otherwise>
|
||||
<admst:count select="../arguments"/>
|
||||
<admst:value-of select="../name"/>
|
||||
<admst:error format="%s(...): two arguments expected - %s found(s) \n"/>
|
||||
</admst:otherwise>
|
||||
</admst:choose>
|
||||
</admst:for-each>
|
||||
<admst:choose>
|
||||
<admst:when test="[$dx='0.0' and $dy='0.0']">
|
||||
<admst:value-to select="/simulator/ddx" value="0.0"/>
|
||||
</admst:when>
|
||||
<admst:when test="[$dx='0.0']">
|
||||
<admst:value-to select="/simulator/ddx" value="(__dFy_%(name)_$index*$dy)"/>
|
||||
</admst:when>
|
||||
<admst:when test="[$dy='0.0']">
|
||||
<admst:value-to select="/simulator/ddx" value="(__dFx_%(name)_$index*$dx)"/>
|
||||
</admst:when>
|
||||
<admst:otherwise>
|
||||
<admst:value-to select="/simulator/ddx" value="(__dFx_%(name)_$index*$dx+__dFy_%(name)_$index*$dy)"/>
|
||||
</admst:otherwise>
|
||||
</admst:choose>
|
||||
</admst:if>
|
||||
<admst:apply-templates select="." match="function:getname"/>
|
||||
<admst:value-to select="/simulator/tmp" value="__%s_$index"/>
|
||||
</admst:when>
|
||||
<admst:when test="[class='builtin']">
|
||||
<admst:value-of select="index(./subexpression/expression/function,.)"/>
|
||||
<admst:variable name="index" select="%s"/>
|
||||
|
|
@ -1216,7 +1262,9 @@
|
|||
<admst:value-of select="position(.)-1"/>
|
||||
<admst:apply-templates select="." match="function:getname"/>
|
||||
<admst:apply-templates select="." match="function:getname"/>
|
||||
<admst:text format="_%s(__%s_%s,"/>
|
||||
<admst:text format="_%s"/>
|
||||
<admst:text test="[name='div']" format="0"/>
|
||||
<admst:text format="(__%s_%s,"/>
|
||||
<admst:join select="arguments" separator=",">
|
||||
<admst:apply-templates select="." match="subexpression:stringify:noprobe"/>
|
||||
<admst:text format="%s"/>
|
||||
|
|
@ -1252,7 +1300,7 @@
|
|||
<admst:if test="arguments[count(.)=2]">
|
||||
<admst:for-each select="arguments">
|
||||
<admst:if test="[position(.)=1]">
|
||||
<admst:if test="math[dependency!='constant']">
|
||||
<admst:if test="[(../name='div') or (math/dependency!='constant')]">
|
||||
<admst:value-of select="../position(.)-1"/>
|
||||
<admst:apply-templates select=".." match="function:getname"/>
|
||||
<admst:text format="double __dFx_%s_%s=0.0;\n"/>
|
||||
|
|
@ -1303,6 +1351,7 @@
|
|||
<admst:apply-templates select="." match="function:getname"/>
|
||||
<admst:apply-templates select="." match="function:getname"/>
|
||||
<admst:text format="_%s(__%s_%s,"/>
|
||||
<admst:text test="[name='div']" format="__dFx_%(name)_%(position(.)-1),"/>
|
||||
<admst:join select="arguments" separator=",">
|
||||
<admst:apply-templates select="." match="subexpression:stringify:noprobe"/>
|
||||
<admst:text format="%s"/>
|
||||
|
|
@ -1334,7 +1383,9 @@
|
|||
<admst:value-of select="../position(.)-1"/>
|
||||
<admst:apply-templates select=".." match="function:getname"/>
|
||||
<admst:apply-templates select=".." match="function:getname"/>
|
||||
<admst:text format="_dy_%s(__dFy_%s_%s,__%s_%s,"/>
|
||||
<admst:text format="_dy_%s(__dFy_%s_%s,"/>
|
||||
<admst:text test="[../name='div']" format="__dFx_%(../name)_%(../position(.)-1),"/>
|
||||
<admst:text format="__%s_%s,"/>
|
||||
<admst:join select="../arguments" separator=",">
|
||||
<admst:apply-templates select="." match="subexpression:stringify:noprobe"/>
|
||||
<admst:text format="%s"/>
|
||||
|
|
|
|||
Loading…
Reference in New Issue