|
Prev: C++ Concepts
Next: getch() function in C++
From: Pete on 13 Oct 2005 09:18 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! ]
From: Catalin Marinas on 13 Oct 2005 19:04 "Pete" <pete_abel(a)hotmail.com> wrote: > 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! ]
From: Gene Bushuyev on 16 Oct 2005 05:45 "Pete" <pete_abel(a)hotmail.com> wrote in message news:1129167095.500019.89990(a)g43g2000cwa.googlegroups.com... > 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! ]
|
Pages: 1 Prev: C++ Concepts Next: getch() function in C++ |