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:28] – [The core ACT language] 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.
  
  
-===== Expressions =====+===== CHP =====
  
 +CHP also supports syntactic replication for guards like the core language((CHP is more strict about placement of semicolons. The language uses semicolons as a separator unlike software languages like C/C++, so please keep this in mind!)). In addition, CHP permits
 +syntactic replication for sequential and parallel composition, as illustrated in the following examples:
  
 +Sequential composition:
 +<code act>
 +(; i : 5 : x.d[i]-; y := y + 1 )
 +</code>
  
 +Parallel composition:
 +<code act>
 +(, i : 5 : x.d[i]-)
 +</code>
 +
 +CHP expressions also support some forms of syntactic replication. The following binary operators allow syntactic replication:
 +   * Logical or bitwise and (''&'')
 +   * Logical or bitwise or (''|'')
 +   * Bitwise exclusive or (''^'')
 +   * Addition (''+'')
 +   * Multiplication (''*'')
 +
 +This means you can write statements like:
 +<code act>
 +  x := (+ i : 5 : a[i])
 +</code>
 +
 +===== Dataflow =====
 +
 +Split and merge operators in the dataflow language can use syntactic replication. This is primarily through comma-separated operators, as in the following parameterized N-way split:
 +<code act>
 +dataflow {
 +  {ctrl} l -> (, i : N : out[i])
 + }
 +</code>
 +
 +===== PRS =====
 +
 +Production rules support both simple syntactic replication as well as syntactic replication in expressions.
 +
 +Simple replication:
 +<code act>
 +prs {
 +   (i : 5 : Reset -> x[i]-)   // simple replication of production rule
 +}
 +</code>
 +
 +Expressions to create a single N-input NAND gate:
 +<code act>
 +prs {
 +   (&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>