7.1  Architecture

7.1.1  File organization

Gnucap source files are organized into groups by the name prefix as follows:
ap
“Argparse”. Generic parser and lexical analysis library.
bm
Behavioral modeling.
c
Commands.
d
Devices and models.
e
Device and model base classes. (“e” comes from “electrical” and is retained because of inertia.)
io
Input and output library, raw, generic.
l
Library. General purpose functions and classes that do not fit elsewhere.
m
Math library.
plot
Obsolete plotting that should be replaced.
s
Simulation engine.
u
Utility functions and classes. Gnucap Specific.
The files ap_*, io_*, l_*, m_* are not Gnucap specific. Although they were created for Gnucap, they are public domain and may be used by anyone for any purpose.

The remaining files bm_*, c_*, d_*, e_*, s_*, u_* are Gnucap specific, and reuse is subject to the Gnu Public License.

Some of the d_* files are automatically generated during compilation. Do not change them, because your changes may be lost in a recompile. For licensing and distribution legal purposes, these files are considered to be “object” code, even though they are readable C++.

The files d_*.model, where present, contain the actual model descriptions as input for modelgen, the model compiler. These files are the source that is used to generate the corresponding .cc and .h files. All changes should be done to the .model file. For GPL purposes, these files are considered to be “source”.

7.1.2  Building, Makefiles

Gnucap uses a 4 part Makefile, designed for simultaneous builds on several systems. A true Makefile is built by selecting and catenating the four pieces. A master Makefile switches to a subdirectory and builds a specialized Makefile there.
Make1
The file list. Specific to this program.
Make2
Compiler and system dependencies. Specific to the compiler. In some cases, hardware dependencies are here. There are several provided. Choose the one that matches your system.
Make3
Basic “make” targets. Generic.
Make.depend
List of dependencies.

7.1.3  Program flow

It all starts at “main”, in main.cc. The function “main” has a loop that gets input and calls “CMD::cmdproc” to dispatch the command.

Batch mode is done in “process_cmd_line”, by using “CMD::cmdproc” to execute the commands “get” or “<” which is passed to “CMD::cmdproc” as text.

The function “CMD::cmdproc” dispatches the command to its handler. The handlers are located in the “CMD” namespace, and the “c_*” files.