PROGRAM STRUCTURE

EasyHDL consists of declarations, assignments and commands. Declarations are used to declare the names of variables, and possibly to initialise them. Assignments are used to assign the result of an expression to a variable. Commands are used to control the flow of the program script.

Declaration Order

All declarations must appear before the first executable statement of the script. The compiler reports an error for a declaration that follows a command, because a declaration made part way through a script would suggest a local variable and EasyHDL has no such thing. Within the block of declarations the order does not matter, and a declaration may refer to a name declared later.

The same rule applies to the ALIAS command and to the property declarations IPROP, NPROP and TPROP, so a well formed script opens with its aliases, properties and variables and only then begins work.

Assignments

An assignment may be introduced by the LET keyword, but the keyword is optional. Any statement whose leading token is not a recognised EasyHDL keyword is treated as an assignment, which is why the following two lines mean the same thing:

LET j = 1

j = 1

One consequence is worth remembering: a misspelled command name is not reported as an unknown command. It is read as the name of a variable being assigned to, and the error you see is that the variable does not exist.

Command Syntax

Each declaration or command has one or more keywords associated with it, though not all the keywords need necessarily be specified; that is some parts of the command are optional. For example the FOR...TO...STEP...NEXT command has four keywords, of which only the keywords FOR, TO and NEXT are essential (the STEP keyword and the expression that follows it being optional).

Some commands have both a block syntax and an inline syntax. A block syntax allows several commands to be nested between the start of the command and its end keyword. An inline syntax only allows other commands to be specified on the same line as the command itself; there is no need to specify the end keyword of the command as the end of the line is assumed to be the end of command. The following example shows the IF...ELSE...ENDIF command in both its block and inline formats:

IF i=0 THEN

   j=1         // IF... BLOCK

   k=2

ELSE

   j=3         // ELSE... BLOCK

   k=4

ENDIF

IF i=0 THEN j=1:k=2 ELSE j=3:k=4 // No need for an ENDIF

See Also:

Explanation of Syntax Layout

Variables

The LET Command

Command Reference