.H1 "Introduction"
.pp
.Id "CG, domain"
The \fBCG\fR domain and derivative domains are used to generate code rather 
than to run simulations. Only the derivative domains are of practical use 
for generating code. The stars in the \fBCG\fR domain itself can be thought 
of as ``comment generators''; they are useful for testing and debugging 
schedulers and for little else. The \fBCG\fR domain is intended as a model 
and a collection of base classes for derivative domains. This section, 
documents the common features and general structure of all code 
generation domains. 
.pp
The design goal of the code generation class hierachy is to save work
and to make the system more maintainable. Most of the work required
to allocate memory for buffers, constants, tables, and to
generate symbols that are required in code is completely
processor-independent; thus these facilities are provided in the generic
classes found in the $PTOLEMY/src/domains/cg/kernel directory.
.pp
.Ir "CG-DDF (Dynamic Dataflow Code Generation)"
.Ir "BDF (Boolean Dataflow, token-flow)"
All the code generation domains that are derived from the \fBCG\fR in this 
release obey \fBSDF\fR semantics and can thus be scheduled at compile time. 
Internally, however, the \fBCG\fR only assumes that stars obey data flow 
semantics. In the future, we will eventually implement two approaches for 
data-dependent execution, \fBCG-DDF\fR, which recognizes and implements certain 
commonly used programming constructs, and BDF ("boolean dataflow" or the 
token-flow model). Even when these are implemented, the vast majority of 
stars in any given application should obey the SDF rules to permit 
efficient multiprocessor code generation.
.pp
.Ir "target, code generation"
A key feature of code generation domains is the notion of a target 
architecture. Every application must have a user-specified target 
architecture, selected from a set of targets supported by the user-selected 
domain. Every target architecture is derived from the base class 
.c Target ,
and controls such operations as scheduling, compiling, 
assembling, and downloading code. Since it controls scheduling, 
multiprocessor architectures can be supported with automated task 
partitioning and synchronization. 
.pp
In the following sections, we will introduce the methods and data
structures needed to write new code generation stars and targets.  However,
we will not document what is needed to write a new code generation
domain.  We will first introduce what is needed to write a new
code generation star, introducing the concepts of \fIcode blocks\fR,
\fIcode streams\fR and \fIcode block macros\fR.  Next we will 
describe the various methods which will generally use the
.c addCode
method to piece together the code blocks into the code streams.
We will then go into what is required to write single-processor
and multiple-processor targets.  Finally we will document the various
schedulers available in the code generation domains.
