 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Pete Guest
|
Posted: Thu Oct 13, 2005 1:18 pm Post subject: creating 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
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Catalin Marinas Guest
|
Posted: Thu Oct 13, 2005 11:04 pm Post subject: Re: creating simple digital logic circuit simulator |
|
|
"Pete" <pete_abel (AT) hotmail (DOT) com> wrote:
| Quote: | 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)???
|
I'm not a hardware engineer but I noticed that a lot of people use
SystemC for building circuit simulators. Have a look at
http://www.systemc.org/. From their website:
SystemC provides hardware-oriented constructs within the context of
C++ as a class library implemented in standard C++. Its use spans
design and verification from concept to implementation in hardware
and software.
And a simple tutorial at
http://www.doulos.com/knowhow/systemc/tutorial/
--
Catalin
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Gene Bushuyev Guest
|
Posted: Sun Oct 16, 2005 9:45 am Post subject: Re: creating simple digital logic circuit simulator |
|
|
"Pete" <pete_abel (AT) hotmail (DOT) com> wrote
| Quote: | 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)???
|
Get SystemC and study it. Yes, it's rather ugly, not a great design at all. And
there was my fault as well since I couldn't overcome a huge resistance to using
STL and generic design. EDA industry is unfortunately pretty much in dark ages
when it comes to sotware design and also has a very big inertia.
General idea of an event-driven simulator is pretty simple. There is one (or
more) event queue(s). Events have a list of callback functions, usually member
functions of a common "module" class, from which all other modules are derived.
There are also threads (fibers) running in infinite loops waiting on events. The
simulator itself is a simple loop that pops events from the event queue and
executes callbacks or resume the threads. During execution new events are added
to the event queue, and so it goes until the event queue is empty or finish
signal is received. This is of course a very simplified view. I recommend you
study the SystemC source files, it will give you an idea how to design the event
queues, how the signals and channels work, how to work with thread loops, how to
work with bits and bit-vectors. Then you can write your own better and faster
simulator.
-- Gene Bushuyev
(formerly SystemC designer, now OA designer: g e n e b @ c a d e n c e )
----------------------------------------------------------------
There is no greatness where there is no simplicity, goodness and truth. ~ Leo
Tolstoy
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|