Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| intro_example:namespace [2020/06/19 11:25] – [Creating a library of building blocks] rajit | intro_example:namespace [2025/05/17 11:51] (current) – [Creating a library of building blocks] rajit | ||
|---|---|---|---|
| Line 7: | Line 7: | ||
| (a) For simple projects, design files containing building blocks can be imported using keyword '' | (a) For simple projects, design files containing building blocks can be imported using keyword '' | ||
| - | < | + | < |
| defproc nand2 (bool? a,b; bool! y) | defproc nand2 (bool? a,b; bool! y) | ||
| { | { | ||
| Line 36: | Line 36: | ||
| This file can be imported in a new ACT file '' | This file can be imported in a new ACT file '' | ||
| - | < | + | < |
| import " | import " | ||
| Line 54: | Line 54: | ||
| The following example creates a namespace gates in file '' | The following example creates a namespace gates in file '' | ||
| - | < | + | < |
| namespace gates | namespace gates | ||
| { | { | ||
| Line 86: | Line 86: | ||
| } | } | ||
| </ | </ | ||
| + | |||
| + | Note the use of the '' | ||
| As shown below, this library is imported in a new ACT file '' | As shown below, this library is imported in a new ACT file '' | ||
| - | < | + | < |
| import " | import " | ||
| Line 102: | Line 104: | ||
| } | } | ||
| - | adder FA; | + | adder fa; |
| </ | </ | ||
| Line 108: | Line 110: | ||
| Finally, ACT supports another import format that is similar to those provided by object-oriented languages like Python and Java. Since '' | Finally, ACT supports another import format that is similar to those provided by object-oriented languages like Python and Java. Since '' | ||
| - | < | + | < |
| import gates; | import gates; | ||
| Line 121: | Line 123: | ||
| } | } | ||
| - | adder FA; | + | adder fa; |
| </ | </ | ||
| The '' | The '' | ||
| + | |||
| + | |||
| + | Finally, if you are going to be using the '' | ||
| + | |||
| + | <code act> | ||
| + | import gates; | ||
| + | open gates; | ||
| + | |||
| + | defproc adder (bool? a,b,ci; bool! s,co) | ||
| + | { | ||
| + | bool y1,y2,y3; | ||
| + | xor2 X1(a, b, y1); | ||
| + | and2 A1(a,b,y2); | ||
| + | xor2 X2 (y1,ci,s); | ||
| + | and2 A2(y1, | ||
| + | or2 O1(y2, | ||
| + | } | ||
| + | |||
| + | adder fa; | ||
| + | </ | ||
| + | |||
| + | |||
| ===== Simulating with prsim script ===== | ===== Simulating with prsim script ===== | ||
| Run simulation in prsim with script as: | Run simulation in prsim with script as: | ||
| < | < | ||
| - | prsim adder.act < adder.scr | + | $ aflat adder.act |
| + | $ prsim adder.prs | ||
| </ | </ | ||
| Line 135: | Line 160: | ||
| < | < | ||
| - | prsim adder.act | + | $ prsim adder.prs |
| (Prsim) source adder.scr | (Prsim) source adder.scr | ||
| </ | </ | ||