Electronics-Related.com
Forums

Developing a Circuit Simulator from Scratch

Started by Unknown February 12, 2007
Hi,

Can anyone give me some directions on how to develop a circuit
simulator from scratch. I need to develop a simple spice compatible
simulator,that can read in spice netlists. I will be using C++ to code
the simulator. I need to support only simple R,L,C, diode and mosfet
devices and DC,AC and transient analyses. I would be using the Ebbers
- Moll models. The problem is that I could not find any guidelines on
how to actually go about writing a simulator from sctrach. I found
several books that explain the different types of analysis but none of
the books give a frame work to develop a circuit simulator.

I am right now going through "Computer Simulation Of Electronic
Circuits" by R Raghuram and "SPICE2: A Computer Program To Simulate
Semiconductor Circuits" by Laurence W.Nagel. But, these are very old
books and are based on FORTRAN.

If anyone could suggest a website or a book it would be great help.

Thanx,
Balaji.

<komminenibalaji@gmail.com> wrote in message 
news:1171333512.832396.290130@h3g2000cwc.googlegroups.com...

> Can anyone give me some directions on how to develop a circuit > simulator from scratch. I need to develop a simple spice compatible > simulator,that can read in spice netlists. I will be using C++ to code > the simulator.
How do you eat an elephant?
In sci.electronics.cad komminenibalaji@gmail.com wrote:
: Can anyone give me some directions on how to develop a circuit
: simulator from scratch. 

My question is:  Why on earth do you want to do that?  There are
enough open-source simulators out there already which you can hack on
that rolling your own seems rather daft.  Is there a reason you need
to roll your own?   

Do you think you can do better than what's already out
there?  If so, then you're probably wrong.   

Is your reason that you want to learn about circuit simulation so as
to get a job in the glamorous EDA industry?  In that case, choose one
of the open-source simulators and work on it. 

Stuart 
komminenibalaji@gmail.com wrote:

> Hi, > > Can anyone give me some directions on how to develop a circuit > simulator from scratch. I need to develop a simple spice compatible > simulator,that can read in spice netlists. I will be using C++ to code > the simulator. I need to support only simple R,L,C, diode and mosfet > devices and DC,AC and transient analyses. I would be using the Ebbers > - Moll models. The problem is that I could not find any guidelines on > how to actually go about writing a simulator from sctrach. I found > several books that explain the different types of analysis but none of > the books give a frame work to develop a circuit simulator. >
The source code the spice 3f5 is readily available. That should give you a few clues. Ian
Le Mon, 12 Feb 2007 18:25:12 -0800, komminenibalaji a &#4294967295;crit&#4294967295;:

> Hi, > > Can anyone give me some directions on how to develop a circuit > simulator from scratch. I need to develop a simple spice compatible > simulator,that can read in spice netlists. I will be using C++ to code
Why don't you try fix some bugs in some spice engines. I think it'a the better way to start your own project.
> the simulator. I need to support only simple R,L,C, diode and mosfet > devices and DC,AC and transient analyses. I would be using the Ebbers - > Moll models. The problem is that I could not find any guidelines on how > to actually go about writing a simulator from sctrach. I found several > books that explain the different types of analysis but none of the books > give a frame work to develop a circuit simulator. > > I am right now going through "Computer Simulation Of Electronic > Circuits" by R Raghuram and "SPICE2: A Computer Program To Simulate > Semiconductor Circuits" by Laurence W.Nagel. But, these are very old > books and are based on FORTRAN.
Fortran ... "has been" language. See Spice C implementation like spice3f5.
> > If anyone could suggest a website or a book it would be great help. > > Thanx, > Balaji.
Habib.
On Mon, 12 Feb 2007 18:25:12 -0800, komminenibalaji wrote:

> Hi, > > Can anyone give me some directions on how to develop a circuit > simulator from scratch. I need to develop a simple spice compatible > simulator,that can read in spice netlists. I will be using C++ to code > the simulator. I need to support only simple R,L,C, diode and mosfet > devices and DC,AC and transient analyses. I would be using the Ebbers > - Moll models. The problem is that I could not find any guidelines on > how to actually go about writing a simulator from sctrach. I found > several books that explain the different types of analysis but none of > the books give a frame work to develop a circuit simulator.
One of the existing open-source simulators might provide the framework you are looking for. QUCS is one of my favourite programs. I'm sure they would welcome your contribution. http://qucs.sourceforge.net/ E.S. -- Linux 2.6.18 Remove 'X' to reply by E-Mail
Hi,

I want to develop the simulator from scratch out of intrest rather
than anything else. I don't want to develop a fancy high end
simulation system like hspice or anyother spice based simulator out
there. I was wondering if I could write a C++ simulator from scratch
which could do simple transient,ac and dc analysis for basic circuits.
I was inspired by the fact that the original SPICE2 was a class room
project done by 6 students at berkeley.

I have all the time in the world as it does not have a deadline. It
can be something I can do over an year or more. But, I want the
simulator to be developed from the scratch. I hope all of you would
understand what I am trying to do even if it is stupid and
meaningless. I would love to do it.

Thanx,
Balaji.

On 13 Feb 2007 05:52:12 -0800 in sci.electronics.basics,
komminenibalaji@gmail.com wrote,
>I want to develop the simulator from scratch out of intrest rather >than anything else. I don't want to develop a fancy high end >simulation system like hspice
Well, your initial post said that you did want it all. Meanwhile, read David Sager's explanation of the simplified approach: http://home.comcast.net/~stager21/Circuits.html
<komminenibalaji@gmail.com> wrote in message
news:1171333512.832396.290130@h3g2000cwc.googlegroups.com...
> Hi, > > Can anyone give me some directions on how to develop a circuit > simulator from scratch. I need to develop a simple spice compatible > simulator,that can read in spice netlists. I will be using C++ to code > the simulator. I need to support only simple R,L,C, diode and mosfet > devices and DC,AC and transient analyses. I would be using the Ebbers > - Moll models. The problem is that I could not find any guidelines on > how to actually go about writing a simulator from sctrach. I found > several books that explain the different types of analysis but none of > the books give a frame work to develop a circuit simulator. > > I am right now going through "Computer Simulation Of Electronic > Circuits" by R Raghuram and "SPICE2: A Computer Program To Simulate > Semiconductor Circuits" by Laurence W.Nagel. But, these are very old > books and are based on FORTRAN. > > If anyone could suggest a website or a book it would be great help. > > Thanx, > Balaji. >
The book "Applied Circuit Design, matrix and computer methods" ISBN 0-470-26908-1 is a tour de force if you wish to write your spice from absolute scratch. First half of the book will get you to the filled nodal admittance matrix stage. Then programme your options for transfer function, 2 port, state variable, sensitivity, tolerance etc. Problem is, that the author supplies sample programming in a beginners all purpose language called 'Basic', which is very similar to Fortran. Both languages though are ideal for this kind of complex mathematical processing, as they offer clarity of structure, simplicity and built in matrix operations. -- Posted via a free Usenet account from http://www.teranews.com
> Well, your initial post said that you did want it all. Meanwhile, > read David Sager's explanation of the simplified approach:http://home.comcast.net/~stager21/Circuits.html
Thanx for the website I was looking for something like this. Is there a website which is a little more advanced? Thanks once again.