Process definitions are emitted as subcircuit definitions, and can be instantiated with the SPICE X card.
Write the following HAC file, inv-def.hac:
defproc inv(bool x, y) { prs { x => y- } }
Compile the source to an object file as before. Since there are no top-level instances, you'll need to tell hacknet what type to emit as the top subcircuit.
$ hacknet -T 'inv' inv-def.haco-c
should produce:
.subckt inv<> !GND !Vdd x y My:dn:0 !GND x y !GND nch W=5u L=2u My:up:0 !Vdd x y !Vdd pch W=5u L=2u .ends
Use of single-quotes around the type argument is encouraged (in fact, only required for template parameters to protect the <> characters from being interpreted by the shell).
Finally, entire hierarchal netlists can be produced by instantiating subcircuit definitions. Write the following file invs.hac, and compile it into invs.haco-c:
import "inv-def.hac"; // pair of inverters defproc foo(bool a, b, c) { inv p(a, b), q(b, c); } foo bar;
Run hacknet:
$ hacknet invs.haco-c > invs.spice
to produce the following hierarchical netlist.
.subckt inv<> !GND !Vdd x y My:dn:0 !GND x y !GND nch W=5u L=2u My:up:0 !Vdd x y !Vdd pch W=5u L=2u .ends .subckt foo<> !GND !Vdd a b c xp !GND !Vdd a b inv<> xq !GND !Vdd b c inv<> .ends xbar !GND !Vdd bar.a bar.b bar.c foo<>
In this example, there is a top-level instance of type foo named bar.