Maker Pro
Maker Pro

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
 
K

Kevin Aylward

Jan 1, 1970
0
Hi,

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

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

Use the full XSpice source code, e.g, http://ngspice.sourceforge.net/.
It us freely available and is a full digital-analogue mixed mode engine.
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?

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.
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)???

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
[email protected]
http://www.anasoft.co.uk
SuperSpice, a very affordable Mixed-Mode
Windows Simulator with Schematic Capture,
Waveform Display, FFT's and Filter Design.
 
S

Stuart Brorson

Jan 1, 1970
0
[email protected] 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:

http://www.tkgate.org/index.html

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

http://www.opencollector.org/

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!
 
L

Leon

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