Академический Документы
Профессиональный Документы
Культура Документы
A Description
Verilog-AMS interface
Introduction
Verilog-AMS is a hardware description language. It can be used to specify the analogue behaviour of compact device models. Usually these are C or C++ implementations in analogue simulators. The eort to implement modern compact models in C/C++ is quite high compared to the description in Verilog-AMS.
ADMS
The software ADMS (see http://mot-adms.sourceforge.net) allows Verilog-AMS descriptions to be translated into any other programming language. It generates a structured XML tree representing the compact device model description.
VerilogAMS source file admsXml: ADMS internal data tree
Documentation
Abbildung 1: ADMS data ow The internal XML tree is used to generate ready-to-compile C or C++ code which is specic to the simulators API. The code generator is able to produce evaluation of device equations (current and charge) including their derivatives, glue code for the simulator API, documentation and any other data described by the original Verilog-AMS input le.
From version 0.0.11 Qucs comes with the following Verilog-AMS transformers qucsMODULEcore.xml creating the actual analogue simulator implementation qucsMODULEdefs.xml creating the parameter descriptions for the analogue simulator qucsMODULEgui.xml creating the implementation for the GUI integration qucsVersion.xml basic admst library analogfunction.xml creating analogue function code In order to create admst scripts for a simulator it is necessary to understand both, the simulator specic API and how the ADMS data tree items which are based on the Verilog-AMS source le describing the model relate to the API. The command lines for transforming a Verilog-AMS source le into the appropiate Qucs C++ source les are
$ $ $ $ admsXml admsXml admsXml admsXml <device.va> <device.va> <device.va> <device.va> -e -e -e -e qucsVersion.xml -e qucsMODULEcore.xml qucsVersion.xml -e qucsMODULEgui.xml qucsVersion.xml -e qucsMODULEdefs.xml analogfunction.xml
each creating an appropriate *.cpp and *.h le. The admst language is used to traverse the internal tree. The trees root is dened by the Verilog-AMS module denition. module d e v i c e ( node1 , node2 , . . . ) // module d e f i n i t i o n s and code endmodule
the analogfunction.xml script produces the appropriate C/C++ and header les module.analogfunction.cpp module.analogfunction.h. The ADMS language transformer is aware of how analogue simlators solve a network of linear and non-linear devices. The general Newton-Raphson algorithm for a DC simulation used in SPICE-like simulators as well as in Qucs can be expressed as J (m) V (m+1) = J (m) V (m) f V (m) = Ilin + Inl Jnl V (m) whereas J denotes the Jacobian J (m) = f (V ) V (2)
V (m) (m) (m) (m)
(1)
There are basically two types of contributions supported by ADMS: currents and charges. The appropiate Jacobian matrices are J (m) = JI
(m)
+ JQ
(m)
I (V ) V
+
V (m)
Q (V ) V
=G+C
V (m)
(3)
static
dynamic
consisting of two real valued matrices G (conductance/transconductance matrix) and C (capacitance/transcapacitance matrix). In the Verilog-AMS desciptions only the current and charge contributions are mentioned. The appropriate derivatives are meant to be automatically formed by the language translator ADMS. I ( c i , e i ) <+ i t ; // c u r r e n t c o n t r i b u t i o n I ( s i , c i ) <+ ddt ( Qjs ) ; // c h a r g e c o n t r i b u t i o n The right-hand side of eq. (1) consists of the linear and non-linear currents of the network as well as the Jacobian matrix multiplied by the voltage vector. Since devices are usually uncorrelated both parts can be computed directly on a per device basis.
Example 1 There was a bug in the admst scripts. They failed to place the function calls of analogue functions correctly. This has been xed. module d i o d e ( a , c ) ; inout a , c ; electrical a, c; a n a l o g function r e a l c u r r e n t ; input i s , v ; begin c u r r e n t = i s ( exp ( v / 26 e 3) 1 ) ; end endfunction r e a l Vd ; r e a l Id ; analog Vd = Id = I (a , end begin V( a , c ) ; c u r r e n t ( 1 e 15 , Vd ) ; c ) <+ Id ;
endmodule Example 2 It is not allowed to mix current and charge contributions in assignments. Mixing both emits wrong C/C++ code. It accounts the current to be a charge in this case. module d i o d e ( a , c ) ; inout a , c ; electrical a, c; r e a l Vd , Id , I s , Cp ; analog Is = Cp = Vd = Id = begin 1e 15; 1e 12; V( a , c ) ; I s ( exp (Vd / 26 e 3) 1 ) ;
// not a l l o w e d i n ADMS I ( a , c ) <+ Id + ddt (CpV( a , c ) ) ; // a l l o w e d i n ADMS I ( a , c ) <+ Id ; I ( a , c ) <+ ddt (CpV( a , c ) ) ; end endmodule Example 3 The following example is rejected by the admst scripts with this error message.
[info] admsXml-2.2.4 Oct 18 2006 19:50:46 [fatal] qucsVersion.xml:1497:admst:if[lhs]: missing node source/insource
An immediate potential on the right hand side is not allowed embedded in a function. module d i o d e ( a , c ) ; inout a , c ; electrical a, c; r e a l Id , I s ; a n a l o g begin I s = 1e 15; Id = I s ( exp (V( a , c ) / 26 e 3) 1 ) ; // not a l l o w e d i n ADMS I ( a , c ) <+ I s ( exp (V( a , c ) / 26 e 3) 1 ) ; // a l l o w e d i n ADMS I ( a , c ) <+ Id ; end endmodule Example 4 Potentials on the left-hand side of contribution assignments are not allowed. This kind of assignment emits wrong C/C++ code.
Abbildung 2: component property dialog in the GUI In g. 2 the component property dialog of an implemented device is shown. In the schematic in g. 3 the symbol for the HICUM model is surrounded with a red circle. The GUI code is also responsible for the icons in the listview on the left hand side of the gure.
define a t t r ( txt ) ( txt ) module d i o d e ( a , c ) ; // d e v i c e t e r m i n a l s inout a , c ; electrical a, c; // i n t e r n a l node electrical ci ; // model p a r a m e t e r s parameter r e a l I s = 1E15 from [ 0 : 1 ] a t t r ( i n f o= s a t u r a t i o n c u r r e n t ) ; parameter r e a l Cp = 1E12 from [ 0 : 1 ] a t t r ( i n f o= p a r a l l e l c a p a c i t a n c e ) ; parameter r e a l Rs = 1.0 from ( 0 : i n f ) a t t r ( i n f o= s e r i e s r e s i s t a n c e ) ; parameter r e a l Temp = 300 from ( 0 : i n f ) a t t r ( i n f o=t e m p e r a t u r e ) ; r e a l Vd , Id , f o u r k t , twoq , Qp ; analog Vd = Id = Qp = begin V( a , c i ) ; I s ( exp (Vd / 26 e 3) 1 ) ; Cp Vd ;
I ( a , c i ) <+ Id ; I ( a , c i ) <+ ddt (Qp ) ; I ( c i , c ) <+ V( c i , c ) / Rs ; begin : n o i s e f o u r k t = 4 . 0 P K Temp ; twoq = 2 . 0 P Q ; I ( c i , c ) <+ w h i t e n o i s e ( f o u r k t /Rs , thermal ) ; I ( a , c i ) <+ w h i t e n o i s e ( twoq Id , s h o t ) ; end // n o i s e end // a n a l o g endmodule
11
The source trees of qucs (GUI) as well as qucs-core (simulator) are within the release tarballs available at http://qucs.sourceforge.net/download.html. During development of new Verilog-A models it is recommended to use CVS. Latest CVS trees of qucs and qucs-core can be obtained using the following command lines.
$ cvs -z3 -d:pserver:anonymous@qucs.cvs.sourceforge.net:/cvsroot/qucs \ co qucs-core $ cvs -z3 -d:pserver:anonymous@qucs.cvs.sourceforge.net:/cvsroot/qucs \ co qucs
Also the software adms must be installed. It is available at http://sourceforge.net/ projects/mot-adms. The le diode.va must be copied into the source tree.
$ cp diode.va qucs-core/src/components/verilog/
In this directory (qucs-core/src/components/verilog/) the Verilog model can be checked if it can be translated successfully using the following command lines.
$ admsXml diode.va -e qucsVersion.xml -e qucsMODULEcore.xml [info] admsXml-2.2.4 Oct 18 2006 19:50:46 [info] diode.core.cpp and diode.core.h: files created [info] elapsed time: 0.0339946 [info] admst iterations: 4146 (4146 freed) $ admsXml diode.va -e analogfunction.xml [info] admsXml-2.2.4 Oct 18 2006 19:50:46 [info] diode.analogfunction.h created [info] diode.analogfunction.cpp created [info] elapsed time: 0.0262961 [info] admst iterations: 3919 (3919 freed)
These command lines create the les for the model evaluation code. The le names (diode.*) are due to the name of the module contained in the Verilog-AMS source le. Additionally the source code must be changed in some more locations. src/components/component.h In this le it is necessary to add the line
#include "verilog/diode.core.h"
12
src/components/component_id.h The le contains unique component identiers. It is necessary to add the Verilog modules name.
enum circuit_type { CIR_UNKNOWN = -1, ... // verilog devices CIR_diode, ... };
src/input.cpp In order to be able to instantiate the new model the le must be modied as follows.
// The function creates components specified by the type of component. circuit * input::createCircuit (char * type) { if (!strcmp (type, "Pac")) return new pac (); ... else if (!strcmp (type, "diode")) return new diode (); logprint (LOG_ERROR, "no such circuit type %s\n", type); return NULL; }
src/qucsdefs.h Finally the properties including their range denitions must be added to this le. The appropiate le can be obtained using the following command line.
$ admsXml diode.va -e qucsVersion.xml -e qucsMODULEdefs.xml [info] admsXml-2.2.4 Oct 18 2006 19:50:46 [info] diode.defs.h: file created [info] elapsed time: 0.0335337 [info] admst iterations: 4294 (4294 freed)
13
{ PROP_NO_PROP } },
representing the parameters dened in the original Verilog-AMS le. This excerpt must be included in the src/qucsdefs.h le into this structure:
// List of available components. struct define_t qucs_definition_available[] = { ... /* end of list */ { NULL, 0, 0, 0, 0, { PROP_NO_PROP }, { PROP_NO_PROP } } };
Finally the Makele.am in the src/components/verilog/ directory must be adjusted to make the build-system aware of the new component. There must be added
libverilog_a_SOURCES = ... \ diode.analogfuncction.cpp diode.core.cpp noinst_HEADERS = ... \ diode.analogfuncction.h diode.core.h VERILOG_FILES = ... diode.va if MAINTAINER_MODE ... diode.analogfunction.cpp: analogfunction.xml diode.analogfunction.cpp: diode.va $(ADMSXML) $< -e analogfunction.xml diode.core.cpp: qucsVersion.xml qucsMODULEcore.xml diode.core.cpp: diode.va $(ADMSXML) $< -e qucsVersion.xml -e qucsMODULEcore.xml diode.defs.h: qucsVersion.xml qucsMODULEdefs.xml diode.defs.h: diode.va $(ADMSXML) $< -e qucsVersion.xml -e qucsMODULEdefs.xml diode.gui.cpp: qucsVersion.xml qucsMODULEgui.xml diode.gui.cpp: diode.va $(ADMSXML) $< -e qucsVersion.xml -e qucsMODULEgui.xml ... else
in order to create the correct build rules. If everything worked ne then the new Verilog-AMS model is now completely integrated into the analogue simulator. 14
Still in the qucs-core/src/components/verilog directory it is now necessary to create the C++ code for the GUI using the following command line.
$ admsXml diode.va -e qucsVersion.xml -e qucsMODULEgui.xml [info] admsXml-2.2.4 Oct 18 2006 19:50:46 [info] diode.gui.cpp and diode.gui.h: files created [info] elapsed time: 0.0345217 [info] admst iterations: 4146 (4146 freed)
Both the created les diode.gui.cpp and diode.gui.h should be copied to the qucs/qucs/components directory. Depending on the type of device several changes must be applied to these les. The constructor will basically contain the properties of the device as they are going to occur in the component property dialog as depicted in g. 2. Check these if they are complete or if some can be left.
diode : : diode () { D e s c r i p t i o n = QObject : : t r ( d i o d e v e r i l o g d e v i c e ) ; Props . append ( new P r o p e r t y ( I s , 1E15 , f a l s e , QObject : : t r ( s a t u r a t i o n c u r r e n t ) ) ) ; Props . append ( new P r o p e r t y ( Cp , 1E12 , f a l s e , QObject : : t r ( p a r a l l e l c a p a c i t a n c e ) ) ) ; Props . append ( new P r o p e r t y ( Rs , 1 . 0 , f a l s e , QObject : : t r ( s e r i e s r e s i s t a n c e ) ) ) ; Props . append ( new P r o p e r t y ( Temp , 300 , f a l s e , QObject : : t r ( t e m p e r a t u r e ) ) ) ; ... }
The diode::info function should be adapted to meet the devices requirements. The BitmapFile should be changed to represent a correct PNG le in the qucs/bitmaps directory. Both the Name and the bitmap are going to appear in the left-hand component tab as shown in g. 3.
Element d i o d e : : i n f o ( QString& Name , char &BitmapFile , bool getNewOne ) { Name = QObject : : t r ( Diode ) ;
15
The diode::info pnp() method can be completely deleted. It can be necessary for bipolar transistors where two types of devices could be displayed (npn and pnp type). The method must also be deleted from the header le. Also, in this case, the new diode class inherits Component instead of MultiViewComponent. The diode::createSymbol() method must be adapted to represent a valid schematic symbol. Anyway, the default code can be used as a template.
void d i o d e : : c r e a t e S y m b o l ( ) { // normal b i p o l a r L i n e s . append ( new L ine ( 10 , 15 , 10 , 1 5 ,QPen(QPen : : darkBlue L i n e s . append ( new L ine ( 30 , 0 , 10 , 0 ,QPen(QPen : : darkBlue L i n e s . append ( new L ine ( 10 , 5, 0 , 15 ,QPen(QPen : : darkBlue L i n e s . append ( new L ine ( 0 , 15 , 0 , 30 ,QPen(QPen : : darkBlue L i n e s . append ( new L ine ( 10 , 5 , 0 , 1 5 ,QPen(QPen : : darkBlue L i n e s . append ( new L ine ( 0 , 1 5 , 0 , 3 0 ,QPen(QPen : : darkBlue // s u b s t r a t e node L i n e s . append ( new L ine ( L i n e s . append ( new L ine (
9 , 0 , 30 , 9 , 7, 9 ,
// t h e r m a l node L i n e s . append ( new L ine ( 30 , 20 , 20 , 2 0 ,QPen(QPen : : darkBlue , 2 ) ) ) ; L i n e s . append ( new L ine ( 20 , 17 , 20 , 2 3 ,QPen(QPen : : darkBlue , 2 ) ) ) ; // arrow i f ( Props . g e t F i r s t ()> Value == npn ) L i n e s . append ( new L ine ( 6, 1 5 , 0 , L i n e s . append ( new L ine ( 0 , 9 , 0 , } else { L i n e s . append ( new L ine ( 5, 1 0 , 5, L i n e s . append ( new L ine ( 5, 1 0 , 1 , } // t e r m i n a l d e f i n i t i o n s P o r t s . append ( new Port ( 0 , 3 0 ) ) ; P o r t s . append ( new Port ( 30 , 0 ) ) ; P o r t s . append ( new Port ( 0 , 3 0 ) ) ; P o r t s . append ( new Port ( 3 0 , 0 ) ) ;
// // // //
16
In order to test the component in the GUI it is necessary to modify some more source code les. qucs/qucs.cpp In this le the new Verilog device will be made available to the component tab. If a new non-linear device is added then place it here:
pInfoFunc nonlinearComps[] = { ... &diode::info, 0};
qucs/components/component.cpp The new verilog device must be loadable in the GUI. So in the function getComponentFromName() add this:
Component* getComponentFromName(QString& Line) { ... case d : if(cstr == "iode") c = new diode(); break; ... return c; }
In order to make the build-sytem aware of the new Verilog model the le qucs/components/Makele.am must be modied in the following way.
libcomponents_a_SOURCES = ... \ diode.gui.cpp noinst_HEADERS = ... \ diode.gui.h
With these steps the component is now fully integrated into the GUI.
17
Implemented devices
The following sections presents the models already added in Qucs including some test schematics and simulation results.
The setup for the forward Gummel plot is depicted in g. 4. The base-emitter voltage is swept (VBE = 0.2 . . . 1.2) with a constant voltage across the second diode VBC = 0.
In g. 5 the logarithmic Gummel plot is shown including the ratio between the base current and collector current on the secondary axis. 18
P t a r m e r c p w 2 I s T h 1 0 t C V E = r c e = W 1 U S C iT D m = l b y p e n I V b a e h l P r e m a 0 2 t T r . V B E 1 o S = is e =U I i t i l i t q a o n u c m a o n u E d s 1 n C D V b 1 c e = B 2 7 e m p = T I./I
DC simulation
In g. 6 the schematic for the output characteristics of the HICUM model is shown. The 2-dimensional sweep describes the function IC = f (VCE , VBE )
0 . 1 3 e 0 1 4 5 6 1 7 e B 8 I . e c b 0 t a 9 5 0 1 e 2 3 0 4 1 e 5 0 4 0 6 0 8 2 .0 . . . . 1 1 b e V
Abbildung 5: forward Gummel plot for HICUM/L2 v2.11 model (4) 19
i l i P P t t t c m a o n a r m e r a r m e r u d s p p w w s s C D 1 W W 1 2 S S C i D i 1 m m = = T l T l y p e n y p e n b a c e a e P r V P r V 0 0 8 t t c . C E I 3 9 o o V S S c e i i 1 6 = s s = = U T 1 b B E I h 0 t V b r e = U
Abbildung 6: output characteristics schematic for HICUM/L2 v2.11 model Figure 7 shows the results of the DC simulations for the output characteristics of the bipolar transistor. 20
e 1 3 4 8 e 6 I . c 4 e 2 0 0 5 5 5 . . . 1 1 2 2 c e V3
21
Figures 8 and 9 depict the schematic and diagrams for an AC simulation in a given bias point. The current gains magnitude and phase are shown as well as the characteristics of the small signal base and collector current in the complex plane (polar plot).
0 6 f 9 1 0 8 . c r e q u n c y : e + I i 0 . b a c i 6 1 . 2 n : I i . g 3 in 0 a g 2 1 0 e 0 2 . 4 5 a 0 1 6 1 7 1 8 1 9 1 0 1 e e e e e e 0 f c r q u n c y a 1 6 1 7 1 8 1 9 1 0 1 e e e e e e f c r q u n c y a 0 5 0 e i . s 6 b c 0 0 0 6 0 8 a I h . . . . 2 4 p 1 0 6 6 1 7 1 8 1 9 1 0 1 e e e e e ea f c r q u n c y f c r e q u n c y a
Abbildung 8: AC simulation schematic for HICUM/L2 v2.11 model Abbildung 9: AC simulation plot for HICUM/L2 v2.11 model 22
d i l i i l i t t c s m a o n a c s m a o n u u 3 C C A 1 1 X D T l y p e o g = 6 t a S r G H 0 z i 5 n s P I c 2 X b I 1 3 2 T 5 V V V 1 y p e n = = = = U U U h 1 0 t r 5 c i i t q a o n q a o n u u E E 2 1 n n d B ( / b i ) h h ( i / b ) g p s e p s e = = . . I c I c 0 8 . 0 . 4 0 4
S-parameter simulation
In the gures 10 and 11 a two-port S-parameter simulation schematic (including noise) as well as the results are shown. The four S-parameters are displayed in two Polar-Smith combi diagrams. The noise gure as well as the minimal noise gure are displayed in a logarithmic Cartesian diagram.
i t i l i S t t q a o n u c m a o n p a r m e r u E d s i l i m o n u 1 s F * l ( F i ) 0 1 0 C 1 m g m n = N D ) 1 S P y p e o g X 2 = T t a r 0 G i 7 n s N X 1 1 P u m = N O h 5 0 m Z 2 2 1 2 T V V P y p e n 9 2 = = u m = .c U U 1 0Z th N O h 5 0 m r
23
Transient simulation
] ] S S 2 2 0 1 0 2 0 3 1 [ [ , , . . . 2 1 4 6 , , [4 [ 2 1 S S ] ] r e q u n c y r e q u n c y f f 0 in F 2 0 m N 0 1 1 0 1 0 1 3 1 1 5 1 1 7 1 8 1 9 1 0 1 e e e e e e e e e 4 6 r q u n c y f
Abbildung 11: S-parameter simulation plot for HICUM/L2 v2.11 model 24
In the schematic in g. 12 a current pulse is fed into the base of the transistor. Varying the input capacitance changes the response in the collector current as shown in g. 13.
1 3 0 . 1 5 I b c e . I 5 4 t 0 .5 0 0 9 9 9 9 9 9 9 9 e e e e e e e 1 2 3 4 5 6 7 8 ie t m
Abbildung 13: Transient simulation plot for HICUM/L2 v2.11 model 25
b 1 a s e T C j i J 0 e = c h t r 1 C V E I b 0 3 = = I U 2 m T n 5 1 r f = i t i q a o n u a n s e a r m e r E t t P t l m o n s p u w 1 n C V = H . I c I R W 1 1 T S i i R y p e = = n m T l 0 t a r y p e S n C J 5 o a r P 1 5 t s H PS 2 0 1 o is = e
The HBT (Hetero Bipolar Transistor) model developed by Matthias Rudolph at the FBH (Ferdinand-Braun-Institut f ur Hochfrequenztechnik) is available in the Internet at http: //www.designers-guide.org/VerilogAMS. DC simulation
DC simulation
P t a r m e r p w s W 1 1 S T C i D m = l C V B E V E y p e n T V b b b a r e e e = = P U U 0 4 t . 1 5 o S i 2 s = 0 1 . 1 0 i l i t c m a o n u d s e I 3 C D 1 4 8 5 1 6 i t 6 0 q a o n u 7 B E c b e I t 8 n e a I 4 b V B 9 = . I I /b1 e c 0 C c 2 0 2 e I 3 4 5 0 0 1 1 1 .0 .6 .8 .2 .4 V b e
Abbildung 14: forward Gummel plot schematic for HBT model 26
Output characteristics.
End Note
t t a r m e r a r m e r P P s p s p w w c S S W W 1 2 I C i i 1 m m = = C V E D l l y p e n y p e n c e T T = V V b U a r c e a r e P P 0 t t . b S S 5 2 o o B I i i 2 1 6 s s = = V b d l i t c m a o n u C 1 D S S H i t o n v e p r u r c e p n g = 0 5 . 4 3 0 2 . I c 1 0 .2 T 0 5 1 1 5 2 2 5 5 . . .5 .5 . 3 3 4 4 V c e
27
The preferred way to add a new Verilog model to Qucs is certainly to prepare a model, check if it is accepted by ADMS and nally ask the maintainers to integrate it. Until there is no possibility to load device modules dynamically (which is on the TODO list) too many hand-made changes have to be done to automate this process. The dynamic modules require changes in the simulator API as well in the GUI code. Furthermore work is going to be continued on ADMS itself as well as on the admst scripts. The authors would like to thank H el` ene Parruitte for the initial implementation of the Verilog-AMS interface in Qucs. Also thanks go to the company Xmod Technologies (see http://www.xmodtech.com) allowing her to work on such an interface and nally to share the outcome of her internship under the GPL.