New Sparse Matrix Ordering Techniques for Computer Simulation of Electronics Circuits
Total Page:16
File Type:pdf, Size:1020Kb
Recent Advances in Communications, Circuits and Technological Innovation New Sparse Matrix Ordering Techniques for Computer Simulation Of Electronics Circuits DAVID CERNY JOSEF DOBES Czech Technical University in Prague Czech Technical University in Prague Department of Radio Engineering Department of Radio Engineering Technicka 2, 166 27 Praha 6 Technicka 2, 166 27 Praha 6 Czech Republic Czech Republic [email protected] [email protected] Abstract: Engineers and technicians rely on many computer tools, which help them in the development of new devices. Especially in the electronic circuit design, there is required advantageous and complex equipment. This paper makes a brief introduction to the basic problematic of electronic circuit’s simulation. It proposes the key principles for developing modern simulators and possible further steps in computer simulation and circuit design. Main part of the article presents a novel sparse matrix ordering techniques specially developed for solving LU factorization. LU factorization is critical part of any electronic circuit simulation. This paper also presents complete description of backward and forward conversion of the new sparse matrix ordering techniques. The comparison of performance of standard matrix storages and novel sparse matrix ordering techniques is summarized at the end of this article. Key–Words: Computer simulation, SPICE, Sparse Matrix Ordering Techniques, LU factorization 1 Introduction nally come? To better understanding the problematic we must a little investigate SPICE core algorithms. Simulation program SPICE (Simulation Program with The entire program and especially its simulation core Integrated Circuit Emphasis) [1, 2] has dominated in algorithms were written in Fortran, program core al- the field of electronics simulation for several decades. gorithms were lately converted to C language [3]. De- An enormous impact of significance of SPICE simu- spite its age Fortran (and especially its modern ver- lator can be easily seen on division of simulation pro- sion) allows extremely precise memory allocation and grams for electronic circuit into two groups: Spice- produces very efficient machine code. It is a very dif- like simulators which use for simulation same princi- ficult task (even impossible) to make a program with ples as SPICE and others based on a different pro- competitive computation core in recent programming gramming paradigm. The first version of the pro- languages as C++,Java, C#. gram was introduced to public in 70’s in the Uni- versity of California in Berkeley. Although count- In the paper [4], a new program architecture is less number of other programs for computer-aided proposed for simulators of electronics circuits, which design (CAD) and analyzing have been developed, will possibly overcome SPICE. The idea is based on SPICE is the most-used program for circuit simula- a use of functional programming language LISP [5]. tion. SPICE computation core can be found in many Selection of functional language is not a coincidence. professional programs as PSPICE (Cadence), Spec- Functional languages are getting more on their sig- tre (Cadence), HSPICE (Synopsys), ELDO (Men- nificance nowadays. As an example we can mention tor Graphics), SmartSPICE(Simucad), NgSpice and that new version of C++11 (approved by ISO in Au- many others. gust 2011) comes with the ability of creation of un- named function so-called lambda function principle. This is absolutely fundamental principle to functional 2 Future of Electronics Simulation languages. The efficiency and modularity of written code Nearly 40 years have passed since SPICE simulator have started to be taken very seriously recently. A was developed, but still we are facing very difficult huge drawback of SPICE simulator (and practically decision. Will it be the most-used computer simulator every simulator based on same architecture) is its for the next 40 years or the time for a change has fi- models. It is very difficult and requires high level pro- ISBN: 978-1-61804-138-8 247 Recent Advances in Communications, Circuits and Technological Innovation gramming skills of the users to create own models. It for real magic which comes with mapping function. is possible to modify various parameters of existing Following (very self explanatory) LISP code is com- models, but it is time-consuming and difficult to cre- plete mapping function for previously defined Zener ate own one from scratch. Electronics engineers are diode. forced to deal with memory management, complex algorithms and many redundant optimization param- (defmethod map−d e v i c e − eters if they need to do so. Moreover, this is possible ( ( d c l a s s d io d e ) (m c l a s s −matrix −system ) ) only in a case when the users can recompile simulator source codes. Otherwise it is very difficult to change (let((v+ (make−var−node ’v (node+ d))) anything or check, whether computation algorithms ( v− ( make−var−node ’v (node− d ) ) ) are correct. ( i ( make−var−name ’i (name d)))) ( s e t −g−value mv+ i #’+ 1) 3 Power of Fuctionals ( s e t −g−v a l u e m v− i # ’+ −1) Turning simulation program to functional style gives ( s e t −g−value m i i #’+ −1) an opportunity to create environment, which could change itself during its run [6]. Functions could be ( s e t −e q u a t i o n s −v a l u e m i created and mapped to variables at any time of the ( diode −current d v+ v −)) program run. This gives us very powerful tool to cre- ate special input syntax, which turns, for example, ( s e t −d−v a l u e m i v+ − − − mathematical equations to functions. It is not parsing. ( diode c u r r e n t dva d v+ v )) ( s e t −d−v a l u e m i v− Specific property of functional languages is a possibil- ( diode −c u r r e n t −dvc d v+ v − )))) ity of language syntax redefinition to special one [7]. This allows, for example, in electronics simulation to One of the main advantages of functionals is that specify arbitrary complex device model just by defi- they can be handled in a same way as values. They nition by its mathematical circuit equations. To clear can be dynamically created with different parameters, this statement, the implementation of a diode model stored in variable or array. This allows to them to be in the functional language Common LISP (CL) will used as circuit device templates and so significantly be illustrated. enhance device redefinition speed. There is no more We are going to rewrite well known Shockley’s need to incorporate device definition into simulation equation of a diode to LISP code: algorithms. Simulation program should be able to au- tomatically assign defined device functionals to cor- VD=(nVT) ID = IS e − 1 ; (1) rect positions in simulation chain and invoke them in the right order and time when they are needed. where ID is diode current, IS is saturation current, VD = Vp − Vn is voltage across the diode, VT is ther- mal voltage, and n is emission coefficient. Definition 4 Performance of Computer Simula- of this mathematical equation in functional language Common LISP will look as tions (DEFUN DIODE−CURRENT (VP VN) One important fact must be pointed out about func- # ’(LAMBDA ( ) tional languages. And actually about any other pro- (∗ 10e−12 gramming language higher than C. No matter, how (− (EXP many optimization algorithms given compiler will (/(− (EVAL VP) (EVAL VN) ) use, resulting binary will be in any case slower than − 26e 3)) C or Fortran compilation. The result can differ only 1 ) ) ) ) in several instructions, but this will get on significance −12 −3 where IS = 10 A, VT = 26x10 V and n = 1, when it is performed thousand times over. To compete e.g. in performance with other simulators, all its computa- This function (DIODE-CURRENT) with param- tion demanding tasks must delegated to C language, eters (VP VN) returns another function (it is actually Fortran or even lower language. functional), defined by LAMBDA operator, which In CL, it is possible though so-called Foreign Ar- computes current ID through the diode. It could be ray Interface mechanism. It allows to CL to use, create mentioned that it is only trivial redefinition of mathe- and call functions and variables from other program- matical equation in LISP code. It is only introduction ming languages, for example C. All demanding tasks ISBN: 978-1-61804-138-8 248 Recent Advances in Communications, Circuits and Technological Innovation can be passed and evaluated by code written in C lan- dex vectors. Vectors u and l are both value vectors, guage. It proved to be good approach to use GNU which are accompanied by two indexes vector iu, il. Scientific Library (GSL) [8]. It offers many mathe- Index vectors iu and il combine the best of the row matical functions and is very fast. Disadvantage of and column sparse matrix techniques. The index vec- this solution is that GSL does not support sparse ma- tor in iu uses up to down, left to right organization trix storage. This fact could be very problematic in scheme, vector il works with a left to right, up to down electronic circuit simulation because high sparsity is scheme. Vector d holds diagonal matrix values and characteristic property of circuit equations. therefore, non-zero values. After successful pivoting there should be no zero values in vector d. Therefore, 5 Sparse Matrix Storage it will have full length in any case, and does not need to be accompanied by any index vector. Visual exam- In the classical electronic network application, we can ple of the transformation of the matrix M to MPSLS be sure that system equations of the simulated circuit sparse matrix ordering technique follows: will produce a highly sparse matrix.