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.

Reply to
komminenibalaji
Loading thread data ...

How do you eat an elephant?

Reply to
Homer J Simpson

In sci.electronics.cad snipped-for-privacy@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

Reply to
Stuart Brorson

The source code the spice 3f5 is readily available. That should give you a few clues.

Ian

Reply to
Ian Bell

Le Mon, 12 Feb 2007 18:25:12 -0800, komminenibalaji a écrit :

Why don't you try fix some bugs in some spice engines. I think it'a the better way to start your own project.

Fortran ... "has been" language. See Spice C implementation like spice3f5.

Habib.

Reply to
habib.bouaziz-viallet

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.

formatting link

E.S.

--
Linux 2.6.18
Remove \'X\' to reply by E-Mail
Reply to
Eamon Skelton

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.

Reply to
komminenibalaji

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

Reply to
komminenibalaji

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

Reply to
Chuck Harris

On 13 Feb 2007 05:52:12 -0800 in sci.electronics.basics, snipped-for-privacy@gmail.com wrote,

Well, your initial post said that you did want it all. Meanwhile, read David Sager's explanation of the simplified approach:

formatting link

Reply to
David Harmon

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
Reply to
john jardine

approach:

formatting link

Thanx for the website I was looking for something like this. Is there a website which is a little more advanced? Thanks once again.

Reply to
komminenibalaji

Hi,

Thanks for the book.

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.

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.

Reply to
komminenibalaji

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

Reply to
Homer J Simpson

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:

formatting link
... 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

Reply to
Joel Kolstad

Stuart Brors>[...]rolling your own seems rather daft.

Next week's topic: Round wheels: Are they really best?

It seems so obvious.

Reply to
JeffM

Hi Joel,

guy:

formatting link
to build a

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.

Reply to
komminenibalaji

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

---Joel

Reply to
Joel Kolstad

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 snipped-for-privacy@anasoftEXTRACT.co.uk

formatting link
SuperSpice

Reply to
Kevin Aylward

Good Luck and send me the URL when you are done so I can check it out.

Reply to
Jim Douglas

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.