Maker Pro
Maker Pro

Developing a Circuit Simulator from Scratch

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.
 
H

Homer J Simpson

Jan 1, 1970
0
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?
 
S

Stuart Brorson

Jan 1, 1970
0
In sci.electronics.cad [email protected] 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
 
I

Ian Bell

Jan 1, 1970
0
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
 
H

habib.bouaziz-viallet

Jan 1, 1970
0
Le Mon, 12 Feb 2007 18:25:12 -0800, komminenibalaji a écrit :
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.
 
E

Eamon Skelton

Jan 1, 1970
0
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.
 
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.
 
The source code the spice 3f5 is readily available. That should give you a
few clues.

I have seen the source code for spice3f5,spice2g6 and xspice. But, all
those are really good simulators and thier source code is all too
complex to understand due to the lack of proper documentation. I have
also seen some of the other open source simulators such as
freeda,superspice and ngspice. But, even though they are well
documented they are also pretty complicated. I am just wondering if
there is no simple way of implementing a circuit simulator if all it
needs is a matrix based euation solver, newton rapson method and
numerical integration.

I have been looking at source codes for almost 5 months now. But,
could not find anything that is really simple. I don't want to write a
really fast or efficient but a simple simulator.

Thanx,
Balaji
 
C

Chuck Harris

Jan 1, 1970
0
I have seen the source code for spice3f5,spice2g6 and xspice. But, all
those are really good simulators and thier source code is all too
complex to understand due to the lack of proper documentation. I have
also seen some of the other open source simulators such as
freeda,superspice and ngspice. But, even though they are well
documented they are also pretty complicated. I am just wondering if
there is no simple way of implementing a circuit simulator if all it
needs is a matrix based euation solver, newton rapson method and
numerical integration.

I have been looking at source codes for almost 5 months now. But,
could not find anything that is really simple. I don't want to write a
really fast or efficient but a simple simulator.

Thanx,
Balaji


Well, then you have already gathered some important clues: A circuit
simulator is not a simple program!

Even writing a few very specialized circuit solvers can be a daunting
task to get right.

-Chuck
 
J

john jardine

Jan 1, 1970
0
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.
 
Hi,
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

Thanks for the book.
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.

The programming language does not matter as long as the author gives a
framework on which I can build on. That is the problem I am facing.
From the books I have read the authors explain the algorithms very
well but don't go into the details of how to build the intial matrix
equations and then how to do error checking and so on. That's the
difficult part for me. Anyways thanx a lot for the book.
 
H

Homer J Simpson

Jan 1, 1970
0
I want to develop the simulator from scratch out of intrest rather
than anything else.

Simulate one resistor. Then two in series. Then two in parallel. Continue as
needed.
 
J

Joel Kolstad

Jan 1, 1970
0
Can anyone give me some directions on how to develop a circuit
simulator from scratch.

There was a discussion of this just a month or two ago; Goole (groups) can
find it for you.

The other input you've gotten is some of the same information from that
discussion, and I'll repeat here what I said there: I took a quarter-long
course from this guy:
http://eecs.oregonstate.edu/research/members/mayaram/index.html ... to build a
SPICE-like simulator containing pretty much all the features you're looking
for. If you ask him nicely, he might be willing to send you a copy of the
course notes... or I might too. :)

As others have alluded, you'll find that getting passive device simulation
working is not particularly difficult. Once you start adding active devices,
transient simulation and even DC convergence become rather complex -- there
are many fancy academic papers over a handful of decades now trying to make
such simulations robust, but it's not a completely solved problem even today.

I disagree with the folks who say, "just join a group working on an
open-source simulator" -- you'll find that in many cases, only a couple of
people in the *entire group* really have an understanding of the "guts" of the
simulator, and the vast bulk of people working on such projects are doing
GUIs, netlist interfacing, etc. Many of these groups have started with, e.g.
Berkeley SPICE 3f5 code and have been improving it over time (note that many
*commercial* simulators used the same approach!). The likelihood that you
could get a good grip on exactly what's going on just by starring at SPICE 3f5
source code long enough is slim... you might as well try to figure out how a
method-of-moments electromagnetic simulator works while you're at it...

---Joel Kolstad
 
Hi Joel,
The other input you've gotten is some of the same information from that
discussion, and I'll repeat here what I said there: I took a quarter-long
course from this guy:http://eecs.oregonstate.edu/research/members/mayaram/index.html... to build a
SPICE-like simulator containing pretty much all the features you're looking
for. If you ask him nicely, he might be willing to send you a copy of the
course notes... or I might too. :)

Thanx for the information. Atleast now I know I am after something
that is practical over an year.
I disagree with the folks who say, "just join a group working on an
open-source simulator" -- you'll find that in many cases, only a couple of
people in the *entire group* really have an understanding of the "guts" of the
simulator,

That's what I want to do. Understand the core of a circuit simulator.
And while I am doing it I could as well code one and have fun doing
it.

Thanx a lot.

Regards,
Balaji.
 
J

Joel Kolstad

Jan 1, 1970
0
Thanx for the information. Atleast now I know I am after something
that is practical over an year.

Even Nagel had plenty of help with SPICE... Google "The Life of SPICE" and
read about it in his own words.

---Joel
 
K

Kevin Aylward

Jan 1, 1970
0
Hi Joel,


Thanx for the information. Atleast now I know I am after something
that is practical over an year.


That's what I want to do. Understand the core of a circuit simulator.
And while I am doing it I could as well code one and have fun doing
it.

Thanx a lot.

Regards,
Balaji.

I am going to repeat what already has been said. You are simple wasting your
time trying to write a simulater from scratch. Its way to big a project for
one person such that you could produce a usefull outcome. You can learn
about spice without reinventing the wheel. You only have to note the docs at
source forge. to wit..write one from sctratch...but uin the meantime... lets
use code whats available. Listen er...sonny...these old timers do actually
know what is worth doing...or not...sometimes.

Kevin Aylward
[email protected]
www.anasoft.co.uk
SuperSpice
 
J

Jim Douglas

Jan 1, 1970
0
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.
Good Luck and send me the URL when you are done so I can check it out.
 
Top