Both sides previous revision
Previous revision
Next revision
|
Previous revision
Last revision
Both sides next revision
|
intro_example:gates [2020/04/30 09:43] rajit [Simulation with irsim] |
intro_example:gates [2020/12/02 01:00] 127.0.0.1 external edit |
</code> | </code> |
| |
This would be accepted by ACT, and the production rule simulator [[tools:prsim|prsim]] can simulate such rules without difficulty. However, | This would be accepted by ACT, and the production rule simulator [[tools:prsim|prsim]] can simulate such rules without difficulty. However, a CMOS circuit designer would observe that one cannot implement this directly using a single pull-up and pull-down network in static CMOS. Instead, someone used to circuit design would write: |
a circuit designer would look at this and point out that we cannot implement this directly using a single pull-up and pull-down network in | |
static CMOS. Instead, someone used to circuit design would write: | |
| |
<code> | <code> |
</code> | </code> |
| |
In this example, we have introduced a local variable ''_c''. This variable is only visible within the process in the ACT language((Simulators typically give you access to any signal you wish to see to simplify debugging)). ''_c'' is the output of a nand operation, and then it is inverted to generate the output ''c''. | In this example, we have introduced a local variable ''_c''. This variable is only visible within the process in the ACT language((Simulators typically give you access to any signal you wish to see to simplify debugging)). This scoping rule is useful because it narrows down the section of the ACT file that can influence the particular variable/signal. ''_c'' is the output of a nand operation, and then it is inverted to generate the output ''c''. |
| |
Since we already have defined ''nand2'' as well as ''inverter'', an alternative approach would be to re-use those circuits as follows: | Since we already have defined ''nand2'' as well as ''inverter'', an alternative approach would be to re-use those circuits as follows: |
In terms of naming, the ports of ''n'' are ''n.a'', ''n.b'', and ''n.c''; similarly the ports for ''i'' are ''i.i'' and ''i.o''. ACT uses the dot as a hierarchy separator. This version of an ''and2'' contains one level of hierarchy. | In terms of naming, the ports of ''n'' are ''n.a'', ''n.b'', and ''n.c''; similarly the ports for ''i'' are ''i.i'' and ''i.o''. ACT uses the dot as a hierarchy separator. This version of an ''and2'' contains one level of hierarchy. |
| |
ACT provides a very flexible mechanism for connecting signals. The following a variants that correspond to the same connections. | ACT provides a very flexible mechanism for connecting signals. The following are variants that correspond to the same connections. |
| |
<code> | <code> |
{ | { |
nand2 n(.a=a, .b=b); | nand2 n(.a=a, .b=b); |
inverter i(.i=n.c, .o=c); // note that we don't need the intermediate _c | inverter i(.i=n.c, .o=c); // note that we don't need the intermediate name _c |
} | } |
| |
</code> | </code> |
| |
''s'' runs the simulation for one step (you can set the step size with the stepsize command). Now you can use ''h''/''l'' to set the input and watch the output change. | ''s'' runs the simulation for one step (you can set the step size with the stepsize command). Now you can use ''h''/''l'' to set the input and watch the output change, for example, as follows: |
| |
| <code> |
| % h a/a |
| % h a/b |
| % s |
| % l a/a |
| % s |
| </code> |
| |
You can also create a text file of irsim commands (highly recommended as a general practice), and then read it in to irsim with the ''@'' command. | You can also create a text file of irsim commands (highly recommended as a general practice), and then read it in to irsim with the ''@'' command. |
| |