Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| language:introduction [2022/05/13 12:27] – rajit | language:introduction [2025/09/04 11:09] (current) – [Loops and conditionals] rajit | ||
|---|---|---|---|
| Line 92: | Line 92: | ||
| parser was expecting. Error messages are accompanied by the file name, | parser was expecting. Error messages are accompanied by the file name, | ||
| line number, and column number of the item that resulted in the error. | line number, and column number of the item that resulted in the error. | ||
| + | |||
| + | The variable names '' | ||
| + | ACT language features like functions and user-defined types. | ||
| The names in the port list of a user-defined type are the only parts of | The names in the port list of a user-defined type are the only parts of | ||
| Line 98: | Line 101: | ||
| consider the following definition of '' | consider the following definition of '' | ||
| - | < | + | < |
| defproc bitbucket(a1of2 d) | defproc bitbucket(a1of2 d) | ||
| { | { | ||
| Line 114: | Line 117: | ||
| result in the following message: | result in the following message: | ||
| - | < | + | < |
| bitbucket b; | bitbucket b; | ||
| a1of2 c; | a1of2 c; | ||
| b.p = c.d0; | b.p = c.d0; | ||
| + | </ | ||
| + | < | ||
| -[ERROR]-> | -[ERROR]-> | ||
| </ | </ | ||
| Line 143: | Line 148: | ||
| circuits. The simplest way to create an array is shown below. | circuits. The simplest way to create an array is shown below. | ||
| - | < | + | < |
| bool x[10]; | bool x[10]; | ||
| a1of2 y[5][3]; | a1of2 y[5][3]; | ||
| Line 155: | Line 160: | ||
| be specified as shown below | be specified as shown below | ||
| - | < | + | < |
| bool w[4..7]; // create Booleans w[4], ..., w[7] | bool w[4..7]; // create Booleans w[4], ..., w[7] | ||
| </ | </ | ||
| Line 164: | Line 169: | ||
| block. Consider the following instantiation: | block. Consider the following instantiation: | ||
| - | < | + | < |
| bool x[10]; | bool x[10]; | ||
| bool x[12..14]; | bool x[12..14]; | ||
| Line 174: | Line 179: | ||
| following, on the other hand, is not valid. | following, on the other hand, is not valid. | ||
| - | < | + | < |
| bool x[10]; | bool x[10]; | ||
| bool x[9..14]; | bool x[9..14]; | ||
| Line 191: | Line 196: | ||
| below. | below. | ||
| - | < | + | < |
| bool x[10]; | bool x[10]; | ||
| bool x[12..14]; | bool x[12..14]; | ||
| Line 205: | Line 210: | ||
| succeed, and their shapes also have to be compatible. | succeed, and their shapes also have to be compatible. | ||
| - | < | + | < |
| bool x[12]; | bool x[12]; | ||
| bool w[4][3]; | bool w[4][3]; | ||
| x=w; | x=w; | ||
| + | </ | ||
| + | < | ||
| -[ERROR]-> | -[ERROR]-> | ||
| Types `bool[12]' | Types `bool[12]' | ||
| Line 215: | Line 222: | ||
| The following are examples of valid connections: | The following are examples of valid connections: | ||
| - | < | + | < |
| bool x[10]; | bool x[10]; | ||
| bool x[10..12]; | bool x[10..12]; | ||
| Line 235: | Line 242: | ||
| carry chain for a ten bit ripple-carry adder. | carry chain for a ten bit ripple-carry adder. | ||
| - | < | + | < |
| fulladder fa[10]; | fulladder fa[10]; | ||
| (i : 9 : fa[i].co=fa[i+1].ci; | (i : 9 : fa[i].co=fa[i+1].ci; | ||
| Line 242: | Line 249: | ||
| The parentheses are used to group the body of the loop. '' | The parentheses are used to group the body of the loop. '' | ||
| the dummy variable, and it ranges from zero to eight in this | the dummy variable, and it ranges from zero to eight in this | ||
| - | example. | + | example. In general if only one integer is specified for |
| - | the body of the loop. | + | |
| the range, the variable ranges from zero to one less than the integer. | the range, the variable ranges from zero to one less than the integer. | ||
| + | This is a special case of a more general [[syntacticreplication|syntactic replication]] construct | ||
| + | that can be used in many contexts. | ||
| The conditional statement uses the guarded command notation. They are | The conditional statement uses the guarded command notation. They are | ||
| Line 253: | Line 261: | ||
| indices are connected to '' | indices are connected to '' | ||
| - | < | + | < |
| bool x[10], y[10], z[10]; | bool x[10], y[10], z[10]; | ||
| Line 284: | Line 292: | ||
| instance, ACT files will tend to begin with | instance, ACT files will tend to begin with | ||
| - | < | + | < |
| bool Reset, | bool Reset, | ||
| </ | </ | ||
| Line 306: | Line 314: | ||
| within the namespace. | within the namespace. | ||
| - | < | + | < |
| namespace lib { | namespace lib { | ||
| export defchan a1of2 <: chan(bool) (bool d0,d1,a) { ... } | export defchan a1of2 <: chan(bool) (bool d0,d1,a) { ... } | ||
| Line 329: | Line 337: | ||
| Namespaces can be nested. For instance, we could have: | Namespaces can be nested. For instance, we could have: | ||
| - | < | + | < |
| namespace processor { | namespace processor { | ||
| namespace lib { | namespace lib { | ||
| - | | + | |
| } | } | ||
| Line 347: | Line 355: | ||
| '' | '' | ||
| - | < | + | < |
| namespace processor { | namespace processor { | ||
| namespace lib { | namespace lib { | ||
| - | | + | |
| } | } | ||
| Line 357: | Line 365: | ||
| processor:: | processor:: | ||
| + | </ | ||
| + | < | ||
| -[ERROR]-> | -[ERROR]-> | ||
| | | ||
| Line 365: | Line 375: | ||
| exporting the namespace itself. | exporting the namespace itself. | ||
| - | < | + | < |
| namespace processor { | namespace processor { | ||
| export namespace lib { | export namespace lib { | ||
| - | | + | |
| } | } | ||
| Line 404: | Line 414: | ||
| '' | '' | ||
| - | < | + | < |
| import " | import " | ||
| ... | ... | ||
| Line 426: | Line 436: | ||
| the namespaces, and could create naming conflicts (e.g. multiple | the namespaces, and could create naming conflicts (e.g. multiple | ||
| definition of types having the same name---an error). To solve this | definition of types having the same name---an error). To solve this | ||
| - | problem, one can do the following: | + | problem, one can do the following: |
| - | < | + | < |
| import " | import " | ||
| open lib -> lib1; | open lib -> lib1; | ||
| Line 448: | Line 458: | ||
| because not all types might be exported! In this case we can say: | because not all types might be exported! In this case we can say: | ||
| - | < | + | < |
| import " | import " | ||
| open processor:: | open processor:: | ||
| Line 469: | Line 479: | ||
| hierarchy. The import statement | hierarchy. The import statement | ||
| - | < | + | < |
| import processor:: | import processor:: | ||
| </ | </ | ||
| Line 475: | Line 485: | ||
| is equivalent to the following: | is equivalent to the following: | ||
| - | < | + | < |
| import " | import " | ||
| </ | </ | ||