/module/instance
- Updated2026-03-24
- 1 minute(s) read
The /module command is used to define self-contained units which may internally contain all of the behaviour commands described about. This is useful in building hierarchical circuits and in simplifying designs that reuse a block of logic. Modules are analagous in function to subcircuits in SPICE. The /module command must be accompanied by an /endmodule command which signifies the end of scope.
The /instance statement is used to instantiate the modules into the logic.
Suppose you would like to describe the logical behavior of the following circuit.
One convenient way of doing so is to create a module for the NAND gate and instantiate it three times, as shown below. Note that because we need to create internal nodes, we must use the /wires command.
aU1 [in1 in2 in3 in4] [out] logic
.model logic d_chip(behaviour= "
+/inputs A B C D
+/outputs Y
+/wires node1 node2
+/module NAND
+/inputs in1 in2
+/outputs out
+/table 2
+L L H
+X X L
+/endmodule
+/instance NAND A B node1
+/instance NAND C D node2
+/instance NAND node1 node2 Y
+")