This is an old revision of the document!


Syntactic Replication

Syntactic replication is a useful construct that can be used in a variety of places. The syntactic replication construct is written as follows:

(sym id : range : body(id) )

The sym (symbol) might be empty. id is a variable that can be used in body(id), and takes the range specified by range. range can be either an integer-valued expression or start .. end to indicate a start and end index. The result of the replication is

 body(lo) sym body(lo+1) sym ... sym body(hi)

where lo is the starting index of the range, and hi is the ending index. What follows are different forms of the same construct that can be used in ACT.

The core ACT language

Within the core ACT language (i.e. outside the sublanguage braces), the most common use of syntactic replication is a parameterized list of connections. The statement

   (i : 9 : b[i].R = b[i+1].L;)

is syntactic sugar for:

  b[0].R = b[1].L; b[1].R = b[2].L; ... b[8].R = b[9].L;

Another example is:

(i : 1..8 : register r[i..i]; r[i](in[i],out[i],control); )

This would be equivalent to:

register r[1..1]; r[1](in[1],out[1],control);
register r[2..2]; r[2](in[2],out[2],control);
...
register r[8..8]; r[8](in[8],out[8],control);

The second place the construct can be used is in guards of selection statements:

[ x = 0 -> inst i1;
[] ( [] i : 1..3 -> x = i -> inst i2;)
[] x = 4 -> inst i3;
]

This would be turned into:

[ x = 0 -> inst i1;
[] x = 1 > inst i2;
[] x = 2 -> inst i2;
[] x = 3 -> inst i2;
[] x = 4 -> inst i3;
]