creating a simple digital logic circuit simulator

Hi,

Im in the process of writing a simple digital logic circuit simulator application (similar to B2Logic). What would be the best approach or design for a project like that? I mean should I use the object-oriented design: making gates as classes, and if so, should I make ALL gates as classes or should it be just the BASIC gates (AND, NOT, OR) and build all other components (XOR, NOR, NAND, FULLADDER, etc.) as C-style FUNCTIONS that use those basic classes?

I guess my questions should be: Whats the most common design in commercial applications (e.g. B2Logic)? Is it pure, C-Style code, or is it OOD? And how is it generally done (details are highly appreciated)???

Thank you.

Pete

Reply to
pete_abel
Loading thread data ...

Why?

Use the full XSpice source code, e.g,

formatting link
It us freely available and is a full digital-analogue mixed mode engine.

If you were going to go from scratch, I would certainly investigate using classes for each distinct component.

Ahhmmmm... using c functions that use classes would be rather strange to my mind. I cant say I have ever seen that done. Having classes with c funcuions is quite common though.

Its done in C-code, as B2Logic, as are most of the major vendors (EWB, CM etc) all use the same XSpice code, which is in C. However, if I were going from scratch, it most certainly would be in C++ as a core. Usually the *bulk* of any C++ code should be completely class based, noting that there are times when it makes no sense to put certain functions in a class, hence the use of some standard c functions called from a class.

You can email be direct if like.

Kevin Aylward snipped-for-privacy@anasoft.co.uk

formatting link
SuperSpice, a very affordable Mixed-Mode Windows Simulator with Schematic Capture, Waveform Display, FFT's and Filter Design.

Reply to
Kevin Aylward

pete snipped-for-privacy@hotmail.com wrote: : Hi,

: Im in the process of writing a simple digital logic circuit simulator : application (similar to B2Logic).

What a novel idea! But, ummm, why not contribute to an existing project such as TkGate:

formatting link

Or do a quick search on OpenCollector to see what other logic simulators are already out there:

formatting link

Why re-invent the wheel, unless you think the world needs yet another independent logic simulator?

: What would be the best approach or : design for a project like that?

Extend an existing project.

: I mean should I use the object-oriented : design: making gates as classes, and if so, should I make ALL gates as : classes or should it be just the BASIC gates (AND, NOT, OR) and build : all other components (XOR, NOR, NAND, FULLADDER, etc.) as C-style : FUNCTIONS that use those basic classes?

Welcome to software engineering 101. This is your first homework question.

: I guess my questions should be: Whats the most common design in : commercial applications (e.g. B2Logic)? Is it pure, C-Style code, or is : it OOD? And how is it generally done (details are highly : appreciated)???

I believe that it depends upon when the commercial simulators were written. Older programs tend be be C [1], whereas newer programs tend to be C++ or Java since the OO discipline is a relatively recent thing.

Personally, I would avoid C++ and Java altogether and do it in Python. C++ has all kinds of cross-platform quirks and has also inherited C's inherent memory bug pitfalls. Java is a cleaner language, but if you use it you are chained to a Java VM (unless you can get the GNU Java compiler to work). Python is an OO language with clean syntax and it handles garbage collection for you, so you don't have to worry about memory bugs.

But first I would look to see if a suitable logic simulator already exists, and then just add to it.

Stuart

[1] Really old stuff is written in Fortran. Real men don't need any foofy object oriented nonsense!
Reply to
Stuart Brorson

There is a nice approach to this in Structure and Interpretation of Computer Programs by Abelson and Sussman, written in the Scheme dialect of Lisp.

Leon

Reply to
Leon

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.