Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
language:syntacticreplication [2025/08/25 12:54] – [CHP] rajitlanguage:syntacticreplication [2025/09/04 11:12] (current) – [The core ACT language] rajit
Line 1: Line 1:
 ====== Syntactic Replication ====== ====== 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:+Syntactic replication (sometimes called a syntactic loop construct) is a useful construct that can be used in a variety of places. The syntactic replication construct is written as follows:
 <code act> <code act>
 (sym id : range : body(id) ) (sym id : range : body(id) )
 </code> </code>
-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+The ''sym'' (symbol) might be empty. ''id'' is a variable that can be used in the ''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 integer value of "id" is substituted into "body(id)" when the replication construct is expanded out. The result of the replication is
 <code act> <code act>
  body(lo) sym body(lo+1) sym ... sym body(hi)  body(lo) sym body(lo+1) sym ... sym body(hi)
 </code> </code>
 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. 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 ===== ===== The core ACT language =====
Line 21: Line 23:
   b[0].R = b[1].L; b[1].R = b[2].L; ... b[8].R = b[9].L;   b[0].R = b[1].L; b[1].R = b[2].L; ... b[8].R = b[9].L;
 </code> </code>
 +In this particular case, the separator is empty.
  
 Another example is: Another example is:
Line 54: Line 57:
 ] ]
 </code> </code>
 +In this scenario, the separator is the ''[]'' operator that is used to separate guarded actions.
  
  
Line 71: Line 74:
 (, i : 5 : x.d[i]-) (, i : 5 : x.d[i]-)
 </code> </code>
- 
-==== Expressions ==== 
  
 CHP expressions also support some forms of syntactic replication. The following binary operators allow syntactic replication: CHP expressions also support some forms of syntactic replication. The following binary operators allow syntactic replication:
Line 111: Line 112:
    (&i : N : x[i]) -> y-    (&i : N : x[i]) -> y-
    (|i : N : ~x[i]) -> y+    (|i : N : ~x[i]) -> y+
 +}
 +</code>
 +
 +===== Sizing =====
 +
 +The sizing body also supports syntactic replication.
 +<code act>
 +sizing {
 +   ...
 +   (; i : 5 : out[i] {-1});
 +   ...
 } }
 </code> </code>