Reply by Andrew Tweddle February 21, 20072007-02-21
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. > > 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. >
I went through the exercise of modifying a public domain simulator some years ago. It took about 5 years of spare time to get 5000 lines added to a 20000 line program (this was in turbo pascal,) my additions work but this had simple linear s-parameter internals. (Algorithmically very fast, unlike SPICE.) Doing the same thing in C++ would be a very difficult exercise. Their is the ASME (American Society of Mechanical Engineers) Website www.asme.org which has source and executables of various SPICE versions and other simpler simulators. Next question is what are you hoping to achieve? SPICE is a kludge of translated C from fortran which is pretty much unreadable by humans. Goodluck? Andrew
Reply by Joel Kolstad February 19, 20072007-02-19
"Kevin Aylward" <kevin_aylward@ntlworld.com> wrote in message 
news:CyzBh.7912$fa.668@newsfe1-win.ntli.net...
> I am going to repeat what already has been said. You are simple wasting your > time trying to write a simulater from scratch.
I don't agree with you, Kevin... the course I took teaches, I dunno, 40 or so students how to write a SPICE simulator every other year by having the students write their own (and I'm sure there are other such courses around the country), and I think the average student coming out of that 12-week course ends up with a much better understanding of how a SPICE simulator works than someone who just spent 12 weeks examining the source code for SPICE 3f5, reading Nagels' thesis, etc.
> Its way to big a project for one person such that you could produce a > usefull outcome.
Define "useful?" Our final projects were to implement some "interesting" extension to SPICE, and some of the students chose challenging projects, such as harmonic balance simulation, "shooting method" simulations, etc. Yes, obviously the results weren't anything you could start selling commercially, but in the span of 12 weeks going from knowing nothing about SPICE engines to being on the verge of being able to write a research paper on some improved method of simulation that could be implemented commercially or in an open-source program is pretty impressive, in my book. Keep in mind that our SPICEs were not very big -- maybe a few thousand lines at most; I expect commercial SPICEs are tens or hundreds of times larger for the "core."
> Listen er...sonny...these old timers do actually know what is worth > doing...or not...sometimes.
Oh yeah, absolutely. I'm suggesting that, just as many people are made to design their own op-amps in their EE courses (I took another 12 week course which was largely about building op-amps, starting from very simple-minded approaches and ending up with fancy fully-differntial folded-cascode topologies with specifications that, while not the fastest/lowest power/best in any particular leading-edge spec, were just as good as many "jellybean" commercial offerings), designing your own SPICE based on the traditional methods is a useful exercise. ---Joel
Reply by Jim Douglas February 17, 20072007-02-17
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. > > 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.
Reply by Kevin Aylward February 17, 20072007-02-17
komminenibalaji@gmail.com wrote:
> 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.
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 ka@anasoftEXTRACT.co.uk www.anasoft.co.uk SuperSpice
Reply by Joel Kolstad February 16, 20072007-02-16
<komminenibalaji@gmail.com> wrote in message 
news:1171583777.708570.47190@a34g2000cwb.googlegroups.com...
> 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
Reply by February 15, 20072007-02-15
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.
Reply by JeffM February 14, 20072007-02-14
>komminenibalaji@ gmail.com wrote: >>Can anyone give me some directions >>on how to develop a circuit simulator from scratch. >>
Stuart Brorson wrote:
>[...]rolling your own seems rather daft. >. . . >Do you think you can do better than what's already out >there? If so, then you're probably wrong. >
Next week's topic: Round wheels: Are they really best?
>[...]choose one of the open-source simulators and work on it. >
It seems so obvious.
Reply by Joel Kolstad February 14, 20072007-02-14
<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.
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
Reply by Homer J Simpson February 13, 20072007-02-13
<komminenibalaji@gmail.com> wrote in message 
news:1171374732.335419.16670@q2g2000cwa.googlegroups.com...

> 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.
Reply by February 13, 20072007-02-13
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.