Differences

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

Link to this comparison view

Next revision Both sides next revision
intro_example:namespace [2020/06/16 23:24]
prafull created
intro_example:namespace [2020/06/19 07:25]
rajit [Creating a library of building blocks]
Line 105: Line 105:
 </code> </code>
  
 +
 +Finally, ACT supports another import format that is similar to those provided by object-oriented languages like Python and Java. Since ''gates.act'' defines the namespace ''gates'', it can be imported as follows:
 +
 +<code>
 +import gates;
 +
 +defproc adder (bool? a,b,ci; bool! s,co)
 +{
 +  bool y1,y2,y3;
 +  gates::xor2 X1(a, b, y1);
 +  gates::and2 A1(a,b,y2);
 +  gates::xor2 X2 (y1,ci,s);
 +  gates::and2 A2(y1,ci,y3);
 +  gates::or2 O1(y2,y3,co);
 +}
 +
 +adder FA;
 +</code>
 +
 +The ''import'' statement looks for ''gates.act'' (details are in [[language:namespaces|Namespaces]]), and imports it if it is found. It also checks that the namespace ''gates'' exists after the import.
 ===== Simulating with prsim script ===== ===== Simulating with prsim script =====
 Run simulation in prsim with script as: Run simulation in prsim with script as: