Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
intro_example:gates [2020/04/30 13:29] – [Simulation with irsim] rajit | intro_example:gates [2022/05/13 13:18] (current) – rajit | ||
---|---|---|---|
Line 3: | Line 3: | ||
The following specifies a number of combinational gates, where the process names correspond to the commonly used names for the gates. | The following specifies a number of combinational gates, where the process names correspond to the commonly used names for the gates. | ||
- | < | + | < |
defproc inverter (bool? i; bool! o) | defproc inverter (bool? i; bool! o) | ||
{ | { | ||
Line 30: | Line 30: | ||
If we wanted to create a two-input and gate, we could simply write: | If we wanted to create a two-input and gate, we could simply write: | ||
- | < | + | < |
defproc and2 (bool? a, b; bool! c) | defproc and2 (bool? a, b; bool! c) | ||
{ | { | ||
Line 39: | Line 39: | ||
</ | </ | ||
- | This would be accepted by ACT, and the production rule simulator [[tools: | + | This would be accepted by ACT, and the production rule simulator [[tools: |
- | 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: | + | |
- | < | + | < |
defproc and2 (bool? a, b; bool! c) | defproc and2 (bool? a, b; bool! c) | ||
{ | { | ||
Line 54: | Line 52: | ||
</ | </ | ||
- | In this example, we have introduced a local variable '' | + | In this example, we have introduced a local variable '' |
Since we already have defined '' | Since we already have defined '' | ||
- | < | + | < |
defproc and2 (bool? a, b; bool! c) | defproc and2 (bool? a, b; bool! c) | ||
{ | { | ||
Line 71: | Line 69: | ||
In terms of naming, the ports of '' | In terms of naming, the ports of '' | ||
- | ACT provides a very flexible mechanism for connecting signals. The following | + | ACT provides a very flexible mechanism for connecting signals. The following |
- | < | + | < |
defproc and2 (bool? a, b; bool! c) | defproc and2 (bool? a, b; bool! c) | ||
{ | { | ||
Line 89: | Line 87: | ||
The '' | The '' | ||
- | < | + | < |
defproc and2 (bool? a, b; bool! c) | defproc and2 (bool? a, b; bool! c) | ||
{ | { | ||
Line 105: | Line 103: | ||
To simulate a circuit, you need a top-level instance. Here is a small self-contained example. | To simulate a circuit, you need a top-level instance. Here is a small self-contained example. | ||
- | < | + | < |
defproc inverter (bool? i; bool! o) | defproc inverter (bool? i; bool! o) | ||
{ | { | ||
Line 123: | Line 121: | ||
{ | { | ||
nand2 n(.a=a, .b=b); | nand2 n(.a=a, .b=b); | ||
- | inverter i(.i=n.c, .o=c); | + | inverter i(.i=n.c, .o=c); |
} | } | ||
Line 135: | Line 133: | ||
</ | </ | ||
+ | Note that '' | ||
+ | A simple '' | ||
+ | |||
+ | < | ||
+ | % irsim scmos30 test.sim test.al | ||
+ | </ | ||
+ | |||
+ | (Note that you can run irsim from the terminal window as well as from the magic window. Please run irsim from the terminal window.) This starts the simulation environment, | ||
+ | |||
+ | There are irsim tutorials online. For the and gate, you can run a simple simulation by the following sequence of irsim commands: | ||
+ | |||
+ | < | ||
+ | % ana a/a | ||
+ | % ana a/b | ||
+ | % ana a/c | ||
+ | </ | ||
+ | |||
+ | This opens a waveform window, and displays the signals '' | ||
+ | |||
+ | < | ||
+ | % h Vdd! | ||
+ | % l GND! | ||
+ | </ | ||
+ | |||
+ | This says that Vdd! is high, and GND! is low. You need these commands to setup the power supplies. | ||
+ | |||
+ | < | ||
+ | % s | ||
+ | </ | ||
+ | |||
+ | '' | ||
+ | |||
+ | < | ||
+ | % h a/a | ||
+ | % h a/b | ||
+ | % s | ||
+ | % l a/a | ||
+ | % s | ||
+ | </ | ||
+ | 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 '' | ||