Qucs / ADMS

ADMS is a code generator for the Verilog-AMS language
GNU General Public License v3.0
94 stars 31 forks source link

on analogfunction args #68

Open felix-salfelder opened 7 years ago

felix-salfelder commented 7 years ago

perhaps required to fix #67

tvrusso commented 7 years ago

I checked out this branch and ran it over the "rlc_AF.va" file using the "html_params.xml" generator I'd included in issue #67. It threw some warnings about "probe" being an invalid attribute, and while it does mark the two output variables with probe dependence that had previously shown no probe dependence, it doesn't set the variables' "setininstance/setinmodel/setinevaluate" attributes.

Looking over the commit casually, I see that it executes very early in function processing, before the recursive setting of argument dependencies. So while this commit is a step in the right direction, I'm not sure it's exactly right.

I briefly tried to move the new block to a later portion of the function processing of "e:dependency" (after the "choose" block that immediately follows it in the current analogfunction branch) and also tried to add a similar block to set dependency on variables the same way that "probe" dependence is propagated but I then got even more warnings about invalid attributes and a few downstream errors.

felix-salfelder commented 7 years ago

thanks for trying

.. while it does mark the two output variables with probe depend

that was the only thing i knew was required.

the problem i ran into is variable declarations. in gnucap-adms, block variable declarations are ejected roughly for lhs of assignments in that block (inherited from old ngspice templates?). this is no longer sufficient for CapacitorCharge in your example.

i then noticed thar rhs/function does not list analoguefunction calls (maybe intentional?), so they are not easily accessible. if i push them in implicit.xml, adms crashes.

will need to get around that before i can possibly fix the original problem...

tvrusso commented 7 years ago

Yes, Xyce, too, only emits variable declarations for the LHS of assignments (precisely because we copied the approach used in ngspice templates back when the Earth was still cooling). Once all the other issues are worked out, we'll have to adapt that approach to emit declarations for variables that only get "assigned" to in analog function "output variable" slots.

As I remarked in #67, having variable dependence propagated, too, can be important if emitting code designed for sensitivity analysis.

tvrusso commented 7 years ago

Oh, and thank you for looking into this so quickly. I expected it would be difficult to fix.

felix-salfelder commented 7 years ago

Xyce, too, only emits variable declarations for the LHS of assignments

then, you might be interested in #69 (i dont know what the solution is).

for going further, your .xml scripts might come in handy. would you agree to include them with adms (under an appropriate license)?

tvrusso commented 7 years ago

The "xyceBasicTemplates.xml" and "html_params.xml" files are part of the open-source components of Xyce, and are therefore GPL'd. I had not realized that there are no comments in there indicating this, and will make sure that in future releases there will be.

If you add this text to comments at the top of the files, then there should be no reason you can't include them with ADMS if you feel they might be useful.

Copyright Notice

Copyright 2002 Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains certain rights in this software.

Xyce(TM) Parallel Electrical Simulator
Copyright (C) 2002-2017 Sandia Corporation

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>
tvrusso commented 5 years ago

Xyce, too, only emits variable declarations for the LHS of assignments

then, you might be interested in #69 (i dont know what the solution is).

for going further, your .xml scripts might come in handy. would you agree to include them with adms (under an appropriate license)?

@felix-salfelder : In PR #85 I have a fix for #67, and the "xyceBasicTemplates.xml" file included in the tarball I attached to that PR for verification also has a hack that we just started using in Xyce to handle declarations of variables that are used as output variables to analog functions. How I did it might interest you for gnucap. In that file, you can look for the template "collectAssignedVariables" which originally just recursively scanned a block looking for variables that appear on the LHS of assignments. In the version attached to PR#85, it also detects analog functions with output variables and adds them to the list of "assigned" variables it's creating.

I did not find that it was necessary for analog functions to appear in the "function" list of an expression to accomplish this, but it did take some recursive template trickery.