CONSTANT EXPRESSIONS

In XCSB, constant expressions are expressions that contain only constants. By definition these expressions can only ever return the same result no mater how hany times they are evaluated.

e.g.

2 + 3 + 5

will always result in

10

Constant expressions can use manifest constants in place of numbers, that is named constants.

e.g.

const FRED = 2
const JACK = 3
const BERT = FRED + JACK

// here JACK will be assigned the result of 2 + 3

The result of some constant expressions is known early in the compilation process. While other constant expressions only produce a constant result late in the compilation process.

Constant expressions used to define the size of an array or a case label must be of the type that produce a constant result early in the compilation process.

Constant expressions that produce a constant result late in the compilation process are those that require the address of a variable (not a hardware port).