Subcircuits
When you look at different functions of an electrical circuit, they are easier to understand by hiding information in a block, or a subcircuit.
The main syntax for a subcircuit is "subckt myckt ... ends ckt".
A basic example
To understand the syntax for a subcircuit take a look at voltage divider.
Enter the following lines in a file vdiv.ckt:
In Gnucap this subcircuit can be loaded with:
Now you can check that the netlist is loaded:
Now enter a circuit that uses the subcircuit:
Then calculate the DC operating points:
to be removed
As you can see, the voltage on node 2 is half of voltage on node 1. This calculation took 27 internal steps (Todo: check the meaning of # 27.)
And sweep the input voltage for example:
run DC sweep
width out=80
You can plot the results with:
If you would do the process by reading the content of a file where everything is written inside, you would append a dot before each command(except for build) and pass the name of the file with the -b option
the content of the file would be:
Note that a there's a end command. It simple tells the program that it have done his job.
Last updated