Access to internal variable in custom verilog model

43 views
Skip to first unread message

alg

unread,
Aug 18, 2022, 9:08:14 AM8/18/22
to xyce-users
Hello!

I am working on implementing a custom device model in Verilog-A. So far, I have converted it into a Xyce plugin and simulated it successfully.

I am interested in storing/monitoring the state of one of the internal model variables during the simulation. I noticed in the Xyce documentation that explicit support for the N() syntax in .PRINT commands has been given to some of the verilog models such as BSIM for monitoring gm, Vt, etc.

I also noticed in this thread that it seemed like it might be possible to do this with the N() syntax by declaring the variable as global with the (* desc OPdes *) syntax would do the trick, but I haven't been able to get it to work. Am I understanding this correctly? Does someone have a simple example of this functionality?

Thank you!

xyce-users

unread,
Aug 18, 2022, 11:42:12 AM8/18/22
to xyce-users

Thank you for asking the question, as I see it is inadequately documented in the Xyce/ADMS user's guide at https://xyce.sandia.gov/documentation-tutorials/xyce-adms-users-guide.  I will correct that for the next release.

Yes, you can do this by declaring a module-scoped variable with either a "desc" attribute or a "units" attribute attached (or both).  The correct syntax is "(* desc="description" *) or (* units="unit" *) added to the declaration line at the beginning of the line.

"Module-scoped variable" means a variable declared after the "module" line but before the "analog begin" block.

If you look in the Xyce/utils/ADMS/examples directory, many of the CMC standard models contained there have output variables like gm, vth, etc. and you can see how they're defined,but those are not "simple" examples.

I am attaching a simple modification of the "diode2.va" model included in the Xyce/utils/ADMS/example/toys directory.  This model has the "Qd" internal variable declaration modified so that it can be output via N() to view the capacitor charge.
If you would like to see it in action, follow the directions for building the "toys" plugin, but replace diode2.va in that directory with the attached version, and run the attached DiodeClipper.cir circuit which has had its .PRINT line modified to add the N(D1:Qd) variable to the output.
diode2.va
DiodeClipper.cir

alg

unread,
Aug 18, 2022, 1:53:03 PM8/18/22
to xyce-users
Thank you for the quick reply! The simple example was very helpful; I was able to get it working in my model.

xyce-users

unread,
Aug 18, 2022, 2:40:19 PM8/18/22
to xyce-users

Glad it helped.  And thank you for bringing to my attention that it is inadequately documented in the Xyce/ADMS guide.

Note that the Verilog-A spec describes the use of output variables in section 3.2.1, and we basically implement what they say.  The thread you linked to describes one odd Xyce quirk about the implementation that bit Neal, and which remains unaddressed (and likely will not be addressed anytime soon) --- your module scoped variable MUST be one that is not accessed in the @(initial_model) block if you are using such an ADMS-ism in your model.  The technical details are in the thread you linked to, and I won't rehash them.
Reply all
Reply to author
Forward
0 new messages