Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
intro_example:gates [2020/05/01 16:34] rajit |
intro_example:gates [2022/05/13 09:18] 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 41: | Line 41: | ||
This would be accepted by ACT, and the production rule simulator [[tools: | This would be accepted by ACT, and the production rule simulator [[tools: | ||
- | < | + | < |
defproc and2 (bool? a, b; bool! c) | defproc and2 (bool? a, b; bool! c) | ||
{ | { | ||
Line 56: | Line 56: | ||
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 69: | 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 87: | Line 87: | ||
The '' | The '' | ||
- | < | + | < |
defproc and2 (bool? a, b; bool! c) | defproc and2 (bool? a, b; bool! c) | ||
{ | { | ||
Line 103: | 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 121: | 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); |
} | } | ||