@Begin
Header
The header information section of the source file identifies the file for revision and archival purposes. Normally place it
at the beginning of the file. CUPL provides 10 keywords to use in header information statements. Begin each statement with a
keyword which can be followed by any valid ASCII characters, including spaces and special characters. End each statement with
a semicolon.
@End


@Begin
Pin
Pin declaration statements declare the pin numbers and assign them symbolic variable names. The format for a pin declaration
is as follows:

PIN pin_n=[!]var ;

where
*  PIN is a keyword to declare the pin numbers and assign them variable names.
*  pin_n is a decimal pin number or a list of pin numbers grouped using the list notation;
that is,[pin_n 1, pin_n 2 ... pin_nn]
@End


@Begin
Node
Some devices contain functions that are not available on external pins, but logic equations must be written for these
capabilities. For example, the 82S105 contains both buried state registers (flip-flops) and a mechanism for inverting any
transition term through a complement array. Before writing equations for these flip-flops (or complement arrays), they must
be assigned variable names. Since there are no pins associated with these functions, the PIN keyword cannot be used. Use the
NODE keyword to declare variable names for buried functions.
The format for node declarations is as follows:

NODE [!] var ;

where
*  NODE is a keyword to declare a variable name for a buried function.
*  ! is an optional exclamation point to define the polarity of the internal signal.
*  var is a single variable name or list of variables grouped using the list notation.
*  ; is a semicolon to mark the end of the statement.
@End


@Begin
BitField
A bit field declaration assigns a single variable name to a group of bits. The format is as follows:

FIELD var = [var, var, ... var] ;

where
*  FIELD is a keyword.
*  var is any valid variable name.
*  [var, var, ... var] is a list of variable names in list notation.
*  = is the assignment operator.
;  is a semicolon used to mark the end of the statement.
@End


@Begin
Min
This declaration statement overrides, for specified variables, the minimization level specified in the Configure Advanced
PLD dialog box. The format is as follows:

MIN var [.ext] = level ;

where
*  MIN is a keyword to override the minimization level specified in the Configure Advanced PLD dialog box.
*  var is a single variable declared in the file or a list of variables grouped using the list notation; that is,
*  [var, var, ... var]
*  .ext is an optional extension that identifies the function of the variable.
*  level is an integer between 0 and 4, corresponding to the minimization levels.
*  ; is a semicolon to mark the end of the statement.
@End


@Begin
Fuse
This statement provides for special cases where it is necessary to blow TURBO or MISER bits. This statement should be
used with utmost care, as it can lead to unpredictable results if used incorrectly.  the format is as follows:

FUSE (fusenumber, x)

where
*  fusenumber is the fuse number corresponding to the MISER Bit or TURBO Bit that must be blown.
*  x is either 0 or 1.  Specify 0 if the bit must not be blown. Specify 1 to blow the bit.
@End


@Begin
Define
This command replaces a character string by another specified operator, number, or symbol. The format is as follows:

$DEFINE argument1 argument2

where
*  argument1 is a variable name or special ASCII character.
*  argument2 is a valid operator, a number, or a variable name.
@End


@Begin
UnDefine
This command reverses a $DEFINE command. The format is as follows:

$UNDEF argument

where
*  argument is an argument previously used in a $DEFINE command.
@End


@Begin
Include
This command includes a specified file in the source to be processed by the Compiler. The format is as follows:

$INCLUDE filename

*  File inclusion allows standardizing a portion of a commonly used specification. It is also useful for keeping a separate
parameter file that defines constants that are commonly used in many source specifications. The files that are included may
also contain $INCLUDE commands, allowing for "nested" include files. The named file is included at the location of the
$INCLUDE command.
@End


@Begin
IfDef/EndIf
This command conditionally compiles sections of a source file. The format is as follows:

$IFDEF argument
statements
$ENDIF

where
*  argument may or may not have previously been defined with a $DEFINE command.
*  statements following the $IFDEF command are compiled until the $ENDIF command if the argument has been defined.  When
the argument has not previously been defined, the source statements following the $IFDEF command are ignored.
*  $ENDIF command ends a conditional compilation started with the $IFDEF or $IFNDEF commands. The statements following the
$ENDIF command are compiled in the same way as the statements preceding the $IFDEF or $IFNDEF commands.
Conditional compilation may be nested, and for each level of nesting of the $IFDEF or $IFNDEF command, an associated $ENDIF must be used.
@End


@Begin
IfNDef/EndIf
This command sets conditions for compiling sections of the source file.  The format is as follows:

$IFNDEF argument
statements
$ENDIF

where
*  argument may or may not have previously been defined with a $DEFINE command.
*  The $IFNDEF command works in the opposite manner of the $IFDEF command. When the argument has not previously been defined,
the source statements following the $IFNDEF command are compiled until the occurrence of an $ELSE or $ENDIF command. If the
argument has previously been defined, the source statements following the $IFNDEF command are ignored. No additional source
statements are compiled until the occurrence of the $ENDIF command.
*  $ENDIF command ends a conditional compilation started with the $IFDEF or $IFNDEF commands.  The statements following the
$ENDIF command are compiled in the same way as the statements preceding the $IFDEF or $IFNDEF commands. Conditional 
compilation may be nested, and for each level of nesting of the $IFDEF or $IFNDEF command, an associated $ENDIF must be used.
@End


@Begin
IfDef/Else/End If
This command sets conditions for compiling sections of the source file.  The format is as follows:

$IFDEF argument
statements
$ELSE
statements
$ENDIF

This command reverses the state of conditional compilation as defined with $IFDEF or $IFNDEF. If the tested condition of the
$IFDEF or $IFNDEF commands is true (that is, the statements following the command are compiled), then any source statements
between an $ELSE and $ENDIF command are ignored.  If the tested condition is false, then any source statements between the
$IFDEF or $IFNDEF and $ELSE command are ignored, and statements following $ELSE are compiled.
@End


@Begin
Repeat/Repend
This command is similar to the FOR statement in C language and DO statements in FORTRAN language. It allows the user to
duplicate repeat body by index. The format is as follows:

$REPEAT	index=[number1,number2,_numbern]
	repeat body
$REPEND

*  where n can be any number in the range 0 to 1023
*  $REPEND  This command ends a repeat body that was started with $REPEAT. The format is as follows:

In preprocessing, the repeat body will be duplicated from number1 to numbern. The index number can be written in short form
as [number1..numbern] if the number is consecutive. The repeat body can be any CUPL statement. Arithmetic operations can be
performed in the repeat body. The arithmetic expression must be enclosed by braces { }.  The statements following the $REPEND
command are compiled in the same way as the statements preceding the $REPEAT command. For each $REPEAT command, an associated
$REPEND command must be used.
@End


@Begin
Macro/Mend
This command creates user-defined macros. The format is as follows:

$MACRO name argument1 argument2...argumentn
macro function body
$MEND

*  The macro function body will not be compiled until the macro name is called. The function is called by stating function
name and passing the parameters to the function.  Like the $REPEAT command, the arithmetic operation can be used inside the
macro function body and must be enclosed in braces.
*  $MEND command ends a macro function body started with $MACRO. The statements following the $MEND command are compiled in
the same way as the statements preceding the $MACRO command. For each $MACRO command, an associated $MEND command must be used.
@End


@Begin
Append
In standard logic equations, normally only one expression is assigned to a variable. The APPEND statement enables multiple
expressions to be assigned to a single variable. The format is as follows.

APPEND [!]var[.ext] = expr ;

where
*  ! is the complement operator to optionally define the polarity of the variable.
*  var is a single variable or a list of indexed or non-indexed variables in standard list format.
*  .ext is an optional extension that defines the function of the variable.
*  = is the assignment operator.
*  expr is a valid expression.
*  ; is a semicolon to mark the end of the statement.

The expression that results from multiple APPEND statements is the logical OR of all the APPEND statements. If an expression
has not already been assigned to the variable, the first APPEND statement is treated as the first assignment.
@End


@Begin
Truth Table
Sometimes the clearest way to express logic descriptions is in tables of information. CUPL provides the TABLE keyword
to create tables of information. The format for using TABLE is as follows:

TABLE var_list_1 => var_list_2
{
input_n => output_n ;
	.
	.
input_n => output_n ;
}

where
*  var_list_1 defines the input variables.
*  var_list_2 defines the output variables.
*  input_n is a decoded value (hex by default) or a list of decoded values of var_list_1.
*  output_n is a decoded value (hex by default) of var_list_2.
*  { } are braces to begin and end the assignment block.
*  => specifies a one-to-one assignment between variable lists, and between input and output numbers.

First, define relevant input and output variable lists, and then specify one-to-one assignments between decoded values
of the input and output variable lists. Don’t-care values are supported for the input decode value, but not for the
output decode  value.
@End


@Begin
Blank Line
Inserts a blank line.
@End


@Begin
Title Block
Comments decribing the project are usually enclosed in a block of comment markers.  This will add a row of comment markers
(using the '*' character) followed by a blank line and then another row of comment markers.
@End


@Begin
Pinnode
An alternative for assigning buried functions instead of allowing CUPL to automatically assign them via the NODE keyword,
is to use the PINNODE keyword. The PINNODE keyword is used for explicitly defining buried nodes by assigning a node number
to a symbolic variable name. This is similar to the way the pin declaration statements work. The format for a pinnode
declaration is as follows:

PINNODE node_n = [!]var;

where
*  PINNODE is a keyword to declare the node numbers and assign them variable names.
*  node_n is a decimal node number or a list of node numbers grouped using the list notation; that is, [node_n1,node_n2 ... node_nn]
*  ! is an optional exclamation point to define the polarity of the internal signal.
*  = is the assignment operator.
*  var is a single variable name or list of variables grouped using the list notation; that is, [var,var ... var]
*  ; is a semicolon used to mark the end of the statement.
@End



@Begin
Condition
This  syntax provides a higher-level approach to specifying logic functions than does writing standard Boolean logic
equations for combinatorial logic. The format is as follows:

CONDITION  {
	IF expr0 OUT  var ;
	    .
	    .
	IF exprn OUT  var ;
	DEFAULT  OUT  var ;
	}

where
*  expr is any valid expression.
*  var is a variable name declared in the pin declaration. It can also be a list of indexed or non-indexed variables in list notation.
*  ; is a semicolon used to mark the end of a statement.

The CONDITION syntax is equivalent to the asynchronous conditional output statements of the state machine syntax, except
that there is no reference to any particular state. The variable is logically asserted whenever the expression or DEFAULT
condition is met.  The variable cannot be logically negated in this format.  Be careful when using the DEFAULT statement.
Because it is the complement of all the conditional statements, the DEFAULT statement can generate an expression complex
enough to greatly slow Compiler operation. In most applications, one or two conditional statements may be specified instead
of the DEFAULT statement.
@End


@Begin
Function
This keyword permits the creating of personal keywords by encapsulating some logic as a function and giving it a
name. This name can then be used in a logic equation to represent the function. The format for user-defined functions is as
follows:

FUNCTION name ([parameter0,....,parametern])
{     body     }

where
*  name is any group of valid symbols used to reference the function. Do not use any of the CUPL reserved keywords.
*  parameter is an optional variable used to reference variables when the function is used in a logic equation. It cannot be
an expression.
*  body is any combination of logic equations, truth tables, state-machine syntax, condition syntax, or user function.
*  (  ) are parentheses used to enclose the parameter list.
*  {  } are braces used to enclose the body of the function.
*  The square brackets indicate optional items.

The statements in the body may assign an expression to the function, or may be unrelated equations.  When using optional
parameters, the number of parameters in the function definition and in the reference must be identical. The parameters defined
in the body of the function are substituted for the parameters referenced in the logic equation.
@End


@Begin
Sequence
To implement the state machine model, CUPL supplies a syntax that allows the describing of any function in the state machine.
The SEQUENCE keyword identifies the outputs of a state machine and is followed by statements that define the function of the
state machine. The format for the SEQUENCE syntax is as follows:

SEQUENCE state_var_list {
PRESENT  state_n0 statements ;
	.
	.
	.
PRESENT  state_nn statements ;
}

where
*  state_var_list is a list of the state bit variables used in the state machine block. The variable list can be represented
by a field variable.
*  state_n is the state number and is a decoded value of the state_variable_list and must be unique for each PRESENT statement.
statements are any of the conditional, next, or output statements described in the following subsections of this section.
*  ; is a semicolon used to mark the end of a statement.
*  {  } are braces to mark the beginning and end of the state machine description.

Symbolic names defined with the $DEFINE command may be used to represent state_numbers.
The SEQUENCE keyword causes the storage registers and registered output types generated to be the default type for the target
device. For example, by using the SEQUENCE keyword in a design with a P16R8 target device, the state storage registers and
registered outputs will be generated as D-type flip-flops.
@End
@Begin
Sequenced
The storage registers for certain devices can be programmed as more than one type. In the case of the F159 (Signetics PLS159),
they can be either D or J-K type flip-flops. By default, using the SEQUENCE statement with a design for the F159 will cause
the state storage registers and registered outputs to be generated as J-K type flip-flops. To override this default, the SEQUENCED
keyword would be used in place of the SEQUENCE keyword. This would cause the state registers and registered outputs to be generated
as D-type flip-flops.
@End



@Begin
SequenceJK
Along with the SEQUENCE and SEQUENCED keywords are the SEQUENCEJK, SEQUENCERS, and SEQUENCET keywords. Respectively, they cause
the state registers and registered outputs to be generated as J-K, S-R, and T-type flip-flops.
@End

@Begin
Sequencers
Along with the SEQUENCE and SEQUENCED keywords are the SEQUENCEJK, SEQUENCERS, and SEQUENCET keywords. Respectively, they cause
the state registers and registered outputs to be generated as J-K, S-R, and T-type flip-flops.
@End


@Begin
SequenceT
Along with the SEQUENCE and SEQUENCED keywords are the SEQUENCEJK, SEQUENCERS, and SEQUENCET keywords. Respectively, they cause
the state registers and registered outputs to be generated as J-K, S-R, and T-type flip-flops.
@End



