Differences

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

Link to this comparison view

Next revision
Previous revision
intro_example:loops [2020/06/17 03:25] – created prafullintro_example:loops [2025/05/18 14:51] (current) – [Array, loops and selection] rajit
Line 1: Line 1:
 ====== Array, loops and selection ====== ====== Array, loops and selection ======
 +
 +
  
 Complex datapath designs are often designed with array of simpler cells. The following example show how to create array of simple cells and connect them using loop constructs in ACT. Complex datapath designs are often designed with array of simpler cells. The following example show how to create array of simple cells and connect them using loop constructs in ACT.
  
-<code>+<code act>
 import "adder.act"; import "adder.act";
  
Line 21: Line 23:
 Here are different ways of writing the same loop using another variant of signal connection. Here are different ways of writing the same loop using another variant of signal connection.
  
-<code>+<code act>
 (i : 8 : fa[i].a=a[i]; fa[i].b=b[i]; fa[i].ci=c[i]; fa[i].s=s[i]; fa[i].co=fa[i+1].ci; ) (i : 8 : fa[i].a=a[i]; fa[i].b=b[i]; fa[i].ci=c[i]; fa[i].s=s[i]; fa[i].co=fa[i+1].ci; )
 </code> </code>
-<code>+ 
 +This version makes all the connections to the ports explicitly using the connection syntax. Since it is common to connect a number of ports to the same circuit in close proximity in the ACT file, the following syntax is also supported. 
 + 
 +<code act>
 (i : 8 : fa[i](.a=a[i], .b=b[i], .ci=c[i], .s=s[i], .co=fa[i+1].ci) ) (i : 8 : fa[i](.a=a[i], .b=b[i], .ci=c[i], .s=s[i], .co=fa[i+1].ci) )
 </code> </code>
  
 An instance of this adder is then created in a separate file as: An instance of this adder is then created in a separate file as:
-<code>+<code act>
 import “adder8b.act”; import “adder8b.act”;
  
Line 69: Line 74:
 The example below shows how selection statement is used for conditional execution. The example below shows how selection statement is used for conditional execution.
  
-<code>+<code act>
 import "gates.act"; import "gates.act";
  
Line 81: Line 86:
 </code> </code>
  
-Depending on the value of index ''i'', input ''x0''/''x1'' are assigned to output ''y'' or ''z''. If ''i'' is even, ''x0'' is assigned to ''y'' and ''x1'' is assigned to ''z''. If ''i'' is odd, ''x0'' is assigned to ''z'' and ''x1'' is assigned to ''y''.+Depending on the value of index ''i'', input ''x0''/''x1'' are connected to output ''y'' or ''z''. If ''i'' is even, ''x0'' is connected to ''y'' and ''x1'' is connected to ''z''. If ''i'' is odd, ''x0'' is connected to ''z'' and ''x1'' is connected to ''y''.
  
-====== Checking library dependencies ======+====== General loops ======
  
-For hierarchical design with many imported libraries, it could be useful to get dependency information and see if all the libraries are present in the directories where ACT can find themThe command ''adepend'' is used to check dependencies.+The parenthesis-based syntax is compact way to describe simple loop-based replicationIf a more complex approach is needed, then a generalized while loop syntax is also availableThe selection example earlier could also be re-written as follows:
  
-<code> +<code act
-$ adepend adder8b.act +import "gates.act"; 
-adder8b.act:  adder.act   gates.act+ 
 +defproc select (bool x0[8], x1[8]; bool y[8], z[8]) 
 +
 +    pint i; 
 +    i = 0; 
 +    *[ i < 8 -> x0[i] = y[i]; x1[i] = z[i]; 
 +                x0[i+1] = z[i+1]; x1[i+1] = y[i+1]; 
 +                i = i + 2; 
 +    ] 
 +}                  
 </code> </code>
  
-Here, running adepend on ''adderb8.act'' shows that it depends on the ''adder.act'' and ''gates.act''.+