Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| language:syntacticreplication [2025/08/25 12:28] – [The core ACT language] rajit | language: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 |
| <code act> | <code act> | ||
| (sym id : range : body(id) ) | (sym id : range : body(id) ) | ||
| </ | </ | ||
| - | The '' | + | The '' |
| <code act> | <code act> | ||
| | | ||
| </ | </ | ||
| where '' | where '' | ||
| + | |||
| + | |||
| ===== 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; | ||
| </ | </ | ||
| + | In this particular case, the separator is empty. | ||
| Another example is: | Another example is: | ||
| Line 54: | Line 57: | ||
| ] | ] | ||
| </ | </ | ||
| + | In this scenario, the separator is the '' | ||
| - | ===== 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, | ||
| + | Sequential composition: | ||
| + | <code act> | ||
| + | (; i : 5 : x.d[i]-; y := y + 1 ) | ||
| + | </ | ||
| + | Parallel composition: | ||
| + | <code act> | ||
| + | (, i : 5 : x.d[i]-) | ||
| + | </ | ||
| + | |||
| + | 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]) | ||
| + | </ | ||
| + | |||
| + | ===== 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]) | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ===== 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]-) | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | Expressions to create a single N-input NAND gate: | ||
| + | <code act> | ||
| + | prs { | ||
| + | | ||
| + | (|i : N : ~x[i]) -> y+ | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ===== Sizing ===== | ||
| + | |||
| + | The sizing body also supports syntactic replication. | ||
| + | <code act> | ||
| + | sizing { | ||
| + | ... | ||
| + | (; i : 5 : out[i] {-1}); | ||
| + | ... | ||
| + | } | ||
| + | </ | ||