contents.gifindex.gif

= Constant Declarations

Syntax

id [,id]... = expr [,expr]... ;

id - The id is an identifier that names a constant to be used within a module.

expr - The expr is an expression that defines the constant value.

Use

A constant declaration defines constants used in a module.


Note: The equal sign (=) used for constant declarations in the Declarations section is also used for equations in the Equations section. See Operators.


The identifiers on the left side of the equals sign are assigned the values listed on the right side. There is a one-to-one correspondence between the identifiers and the listed expressions. There must be one expression for each identifier.

The ending semicolon is required after each declaration.

Constants are useful when a value is repeated many times in a module, especially when the value may be changed during the design process. Rather than changing the value throughout the module, the value can be changed once in the declaration of the constant.

Constant declarations may not be self-referencing; for example:

X = X;

will cause errors, as will the declarations

a = b;
b = a;

An include file, constants.inc, is supplied with ABEL and contains definitions for the most frequently used ABEL-HDL constants. This file may be included in your design with the command:

Library 'constants' ;

Examples:

ABC = 3 * 17; " ABC is assigned the value 51
Y = 'Bc' ; " Y = + H4263 ;
X =.X.; " X means 'don't care'
ADDR = [1,0,15]; " ADDR is a set with 3 elements
A,B,C = 5,[1,0],6; " 3 constants declared here

D pin 6; " see next line
E = [5 * 7,D]; " signal names can be included
G = [1,2]+[3,4]; " set operations are legal
A = B & C; " operations on identifiers are valid
A = [!B,C]; " set and identifiers on right


See Also

Using Intermediate Expressions