Documentation

This commit is contained in:
Matthias Koefferlein 2026-07-04 23:28:21 +02:00
parent 9b05f93fa7
commit 33678ff6d9
5 changed files with 430 additions and 48 deletions

View File

@ -107,29 +107,59 @@ See <a href="/about/drc_ref_layer.xml#drc">Layer#drc</a>, <a href="#bbox_height"
<p>Usage:</p>
<ul>
<li><tt>bjt3(name)</tt></li>
<li><tt>bjt3(name, class)</tt></li>
<li><tt>bjt3(device_class)</tt></li>
</ul>
<p>
Use this class with <a href="#extract_devices">extract_devices</a> to specify extraction of a
bipolar junction transistor
bipolar junction transistor without a substrate terminal.
If used with a name, the extractor will produce devices with device
class <class_doc href="DeviceClassBJT3Transistor">DeviceClassBJT3Transistor</class_doc>. If used with a specific device
class object, the extractor will produce devices with this class.
It is the responsibility of the user that this class is compatible with
the parameters and terminals the extractor will require.
</p><p>
See <class_doc href="DeviceExtractorBJT3Transistor">DeviceExtractorBJT3Transistor</class_doc> for more details
about this extractor.
</p>
<a name="bjt3_class"/><h2>"bjt3_class" - Supplies the device class for a 3-terminal bipolar junction transistor</h2>
<keyword name="bjt3_class"/>
<p>Usage:</p>
<ul>
<li><tt>bjt3_class(name)</tt></li>
</ul>
<p>
See <class_doc href="DeviceClassBJT3Transistor">DeviceClassBJT3Transistor</class_doc> for more details
about this device class.
</p>
<a name="bjt4"/><h2>"bjt4" - Supplies the BJT4 transistor extractor class</h2>
<keyword name="bjt4"/>
<p>Usage:</p>
<ul>
<li><tt>bjt4(name)</tt></li>
<li><tt>bjt4(name, class)</tt></li>
<li><tt>bjt4(device_class)</tt></li>
</ul>
<p>
Use this class with <a href="#extract_devices">extract_devices</a> to specify extraction of a
bipolar junction transistor with a substrate terminal
If used with a name, the extractor will produce devices with device
class <class_doc href="DeviceClassBJT4Transistor">DeviceClassBJT4Transistor</class_doc>. If used with a specific device
class object, the extractor will produce devices with this class.
It is the responsibility of the user that this class is compatible with
the parameters and terminals the extractor will require.
</p><p>
See <class_doc href="DeviceExtractorBJT4Transistor">DeviceExtractorBJT4Transistor</class_doc> for more details
about this extractor.
</p>
<a name="bjt4_class"/><h2>"bjt4_class" - Supplies the device class for a 4-terminal bipolar junction transistor</h2>
<keyword name="bjt4_class"/>
<p>Usage:</p>
<ul>
<li><tt>bjt4_class(name)</tt></li>
</ul>
<p>
See <class_doc href="DeviceClassBJT4Transistor">DeviceClassBJT4Transistor</class_doc> for more details
about this device class.
</p>
<a name="box"/><h2>"box" - Creates a box object</h2>
<keyword name="box"/>
<p>Usage:</p>
@ -145,30 +175,60 @@ This function creates a box object. The arguments are the same than for the
<p>Usage:</p>
<ul>
<li><tt>capacitor(name, area_cap)</tt></li>
<li><tt>capacitor(name, area_cap, class)</tt></li>
<li><tt>capacitor(device_class, area_cap)</tt></li>
</ul>
<p>
Use this class with <a href="#extract_devices">extract_devices</a> to specify extraction of a capacitor.
The area_cap argument is the capacitance in Farad per square micrometer.
If used with a name, the extractor will produce devices with device
class <class_doc href="DeviceClassCapacitor">DeviceClassCapacitor</class_doc>. If used with a specific device
class object, the extractor will produce devices with this class.
It is the responsibility of the user that this class is compatible with
the parameters and terminals the extractor will require.
</p><p>
See <class_doc href="DeviceExtractorCapacitor">DeviceExtractorCapacitor</class_doc> for more details
about this extractor.
</p>
<a name="capacitor_class"/><h2>"capacitor_class" - Supplies the device class for a capacitor</h2>
<keyword name="capacitor_class"/>
<p>Usage:</p>
<ul>
<li><tt>capacitor_class(name)</tt></li>
</ul>
<p>
See <class_doc href="DeviceClassCapacitor">DeviceClassCapacitor</class_doc> for more details
about this device class.
</p>
<a name="capacitor_with_bulk"/><h2>"capacitor_with_bulk" - Supplies the capacitor extractor class that includes a bulk terminal</h2>
<keyword name="capacitor_with_bulk"/>
<p>Usage:</p>
<ul>
<li><tt>capacitor_with_bulk(name, area_cap)</tt></li>
<li><tt>capacitor_with_bulk(name, area_cap, class)</tt></li>
<li><tt>capacitor_with_bulk(device_class, area_cap)</tt></li>
</ul>
<p>
Use this class with <a href="#extract_devices">extract_devices</a> to specify extraction of a capacitor
with a bulk terminal.
The area_cap argument is the capacitance in Farad per square micrometer.
If used with a name, the extractor will produce devices with device
class <class_doc href="DeviceClassCapacitorWithBulk">DeviceClassCapacitorWithBulk</class_doc>. If used with a specific device
class object, the extractor will produce devices with this class.
It is the responsibility of the user that this class is compatible with
the parameters and terminals the extractor will require.
</p><p>
See <class_doc href="DeviceExtractorCapacitorWithBulk">DeviceExtractorCapacitorWithBulk</class_doc> for more details
about this extractor.
</p>
<a name="capacitor_with_bulk_class"/><h2>"capacitor_with_bulk_class" - Supplies the device class for a capacitor that includes a bulk terminal</h2>
<keyword name="capacitor_with_bulk_class"/>
<p>Usage:</p>
<ul>
<li><tt>capacitor_with_bulk_class(name)</tt></li>
</ul>
<p>
See <class_doc href="DeviceClassCapacitorWithBulk">DeviceClassCapacitorWithBulk</class_doc> for more details
about this device class.
</p>
<a name="cell"/><h2>"cell" - Selects a cell for input on the default source</h2>
<keyword name="cell"/>
<p>Usage:</p>
@ -470,47 +530,92 @@ See <a href="/about/drc_ref_netter.xml#device_scaling">Netter#device_scaling</a>
<p>Usage:</p>
<ul>
<li><tt>diode(name)</tt></li>
<li><tt>diode(name, class)</tt></li>
<li><tt>diode(device_class)</tt></li>
</ul>
<p>
Use this class with <a href="#extract_devices">extract_devices</a> to specify extraction of a
planar diode
If used with a name, the extractor will produce devices with device
class <class_doc href="DeviceClassDiode">DeviceClassDiode</class_doc>. If used with a specific device
class object, the extractor will produce devices with this class.
It is the responsibility of the user that this class is compatible with
the parameters and terminals the extractor will require.
</p><p>
See <class_doc href="DeviceExtractorDiode">DeviceExtractorDiode</class_doc> for more details
about this extractor.
</p>
<a name="diode_class"/><h2>"diode_class" - Supplies the device class for a diode</h2>
<keyword name="diode_class"/>
<p>Usage:</p>
<ul>
<li><tt>diode_class(name)</tt></li>
</ul>
<p>
See <class_doc href="DeviceClassDiode">DeviceClassDiode</class_doc> for more details
about this device class.
</p>
<a name="dmos3"/><h2>"dmos3" - Supplies the DMOS3 transistor extractor class</h2>
<keyword name="dmos3"/>
<p>Usage:</p>
<ul>
<li><tt>dmos3(name)</tt></li>
<li><tt>dmos3(name, class)</tt></li>
<li><tt>dmos3(device_class)</tt></li>
</ul>
<p>
Use this class with <a href="#extract_devices">extract_devices</a> to specify extraction of a
three-terminal DMOS transistor. A DMOS transistor is essentially
the same than a MOS transistor, but source and drain are
separated.
If used with a name, the extractor will produce devices with device
class <class_doc href="DeviceClassMOS3Transistor">DeviceClassMOS3Transistor</class_doc>. If used with a specific device
class object, the extractor will produce devices with this class.
It is the responsibility of the user that this class is compatible with
the parameters and terminals the extractor will require.
</p><p>
See <class_doc href="DeviceExtractorMOS3Transistor">DeviceExtractorMOS3Transistor</class_doc> for more details
about this extractor (strict mode applies for 'dmos3').
</p>
<a name="dmos3_class"/><h2>"dmos3_class" - Supplies the device class for a three-terminal DMOS transistor</h2>
<keyword name="dmos3_class"/>
<p>Usage:</p>
<ul>
<li><tt>dmos3_class(name)</tt></li>
</ul>
<p>
See <class_doc href="DeviceClassMOS3Transistor">DeviceClassMOS3Transistor</class_doc> for more details
about this device class.
</p>
<a name="dmos4"/><h2>"dmos4" - Supplies the MOS4 transistor extractor class</h2>
<keyword name="dmos4"/>
<p>Usage:</p>
<ul>
<li><tt>dmos4(name)</tt></li>
<li><tt>dmos4(name, class)</tt></li>
<li><tt>dmos4(device_class)</tt></li>
</ul>
<p>
Use this class with <a href="#extract_devices">extract_devices</a> to specify extraction of a
four-terminal DMOS transistor. A DMOS transistor is essentially
the same than a MOS transistor, but source and drain are
separated.
If used with a name, the extractor will produce devices with device
class <class_doc href="DeviceClassMOS4Transistor">DeviceClassMOS4Transistor</class_doc>. If used with a specific device
class object, the extractor will produce devices with this class.
It is the responsibility of the user that this class is compatible with
the parameters and terminals the extractor will require.
</p><p>
See <class_doc href="DeviceExtractorMOS4Transistor">DeviceExtractorMOS4Transistor</class_doc> for more details
about this extractor (strict mode applies for 'dmos4').
</p>
<a name="dmos4_class"/><h2>"dmos4_class" - Supplies the device class for a four-terminal DMOS transistor</h2>
<keyword name="dmos4_class"/>
<p>Usage:</p>
<ul>
<li><tt>dmos4_class(name)</tt></li>
</ul>
<p>
See <class_doc href="DeviceClassMOS4Transistor">DeviceClassMOS4Transistor</class_doc> for more details
about this device class.
</p>
<a name="edge"/><h2>"edge" - Creates an edge object</h2>
<keyword name="edge"/>
<p>Usage:</p>
@ -1201,29 +1306,59 @@ argument, "middle" represents the bounding box center marker generator on primar
<p>Usage:</p>
<ul>
<li><tt>mos3(name)</tt></li>
<li><tt>mos3(name, class)</tt></li>
<li><tt>mos3(device_class)</tt></li>
</ul>
<p>
Use this class with <a href="#extract_devices">extract_devices</a> to specify extraction of a
three-terminal MOS transistor.
If used with a name, the extractor will produce devices with device
class <class_doc href="DeviceClassMOS3Transistor">DeviceClassMOS3Transistor</class_doc>. If used with a specific device
class object, the extractor will produce devices with this class.
It is the responsibility of the user that this class is compatible with
the parameters and terminals the extractor will require.
</p><p>
See <class_doc href="DeviceExtractorMOS3Transistor">DeviceExtractorMOS3Transistor</class_doc> for more details
about this extractor (non-strict mode applies for 'mos3').
</p>
<a name="mos3_class"/><h2>"mos3_class" - Supplies the device class for a three-terminal symmetric MOS transistor</h2>
<keyword name="mos3_class"/>
<p>Usage:</p>
<ul>
<li><tt>mos3_class(name)</tt></li>
</ul>
<p>
See <class_doc href="DeviceClassMOS3Transistor">DeviceClassMOS3Transistor</class_doc> for more details
about this device class.
</p>
<a name="mos4"/><h2>"mos4" - Supplies the MOS4 transistor extractor class</h2>
<keyword name="mos4"/>
<p>Usage:</p>
<ul>
<li><tt>mos4(name)</tt></li>
<li><tt>mos4(name, class)</tt></li>
<li><tt>mos4(device_class)</tt></li>
</ul>
<p>
Use this class with <a href="#extract_devices">extract_devices</a> to specify extraction of a
four-terminal MOS transistor.
If used with a name, the extractor will produce devices with device
class <class_doc href="DeviceClassMOS4Transistor">DeviceClassMOS4Transistor</class_doc>. If used with a specific device
class object, the extractor will produce devices with this class.
It is the responsibility of the user that this class is compatible with
the parameters and terminals the extractor will require.
</p><p>
See <class_doc href="DeviceExtractorMOS4Transistor">DeviceExtractorMOS4Transistor</class_doc> for more details
about this extractor (non-strict mode applies for 'mos4').
</p>
<a name="mos4_class"/><h2>"mos4_class" - Supplies the device class for a four-terminal symmetric MOS transistor</h2>
<keyword name="mos4_class"/>
<p>Usage:</p>
<ul>
<li><tt>mos4_class(name)</tt></li>
</ul>
<p>
See <class_doc href="DeviceClassMOS4Transistor">DeviceClassMOS4Transistor</class_doc> for more details
about this device class.
</p>
<a name="name"/><h2>"name" - Assigns a name to a layer for reference in the LVS database</h2>
<keyword name="name"/>
<p>Usage:</p>
@ -1666,6 +1801,26 @@ l1 = input(1, 0)
</p><p>
To remove this condition, call "region_touch" without any arguments.
</p>
<a name="register_device_class"/><h2>"register_device_class" - Registers a device class for device extraction and netlisting</h2>
<keyword name="register_device_class"/>
<p>Usage:</p>
<ul>
<li><tt>register_device_class(dc)</tt></li>
</ul>
<p>
Registers the device class for extraction and netlist input and output.
"dc" is an object of type <class_doc href="DeviceClass">DeviceClass</class_doc>.
</p><p>
Registers a device class for extraction and netlist output.
Registering a device class is optional. However, using registered
device classed simplify SPICE netlist writing, as device classes
can be configured with SPICE profiles to customize SPICE output.
In the LVS context, <a href="#register_device_class">register_device_class</a> also controls the way
schematic netlists are read from SPICE.
See <a href="/about/drc_ref_netter.xml#register_device_class">Netter#register_device_class</a> for a description of this function.
Also see <a href="/about/drc_ref_netter.xml#extract_devices">Netter#extract_devices</a> for how to use it with registered
device classes.
</p>
<a name="relative_height"/><h2>"relative_height" - Selects primary shapes based on the ratio of height and width of their bounding boxes</h2>
<keyword name="relative_height"/>
<p>Usage:</p>
@ -1718,37 +1873,65 @@ will also be written to the given file.
If a file name is given and "long" is true, a verbose
version of the L2N DB format will be used.
</p>
<a name="resistor"/><h2>"resistor" - Supplies the resistor extractor class</h2>
<a name="resistor"/><h2>"resistor" - Supplies the resistor extractor class.</h2>
<keyword name="resistor"/>
<p>Usage:</p>
<ul>
<li><tt>resistor(name, sheet_rho)</tt></li>
<li><tt>resistor(name, sheet_rho, class)</tt></li>
<li><tt>resistor(name, rho)</tt></li>
<li><tt>resistor(device_class, rho)</tt></li>
</ul>
<p>
Use this class with <a href="#extract_devices">extract_devices</a> to specify extraction of a resistor.
</p><p>
The sheet_rho value is the sheet resistance in ohms/square. It is used
to compute the resistance from the geometry.
"rho" is the sheet resistance in ohms/square.
If used with a name, the extractor will produce devices with device
class <class_doc href="DeviceClassResistor">DeviceClassResistor</class_doc>. If used with a specific device
class object, the extractor will produce devices with this class.
It is the responsibility of the user that this class is compatible with
the parameters and terminals the extractor will require.
</p><p>
See <class_doc href="DeviceExtractorResistor">DeviceExtractorResistor</class_doc> for more details
about this extractor.
</p>
<a name="resistor_class"/><h2>"resistor_class" - Supplies the device class for a resistor</h2>
<keyword name="resistor_class"/>
<p>Usage:</p>
<ul>
<li><tt>resistor_class(name)</tt></li>
</ul>
<p>
See <class_doc href="DeviceClassResistor">DeviceClassResistor</class_doc> for more details
about this device class.
</p>
<a name="resistor_with_bulk"/><h2>"resistor_with_bulk" - Supplies the resistor extractor class that includes a bulk terminal</h2>
<keyword name="resistor_with_bulk"/>
<p>Usage:</p>
<ul>
<li><tt>resistor_with_bulk(name, sheet_rho)</tt></li>
<li><tt>resistor_with_bulk(name, sheet_rho, class)</tt></li>
<li><tt>resistor_with_bulk(name, rho)</tt></li>
<li><tt>resistor_with_bulk(device_class, rho)</tt></li>
</ul>
<p>
Use this class with <a href="#extract_devices">extract_devices</a> to specify extraction of a resistor
with a bulk terminal.
The sheet_rho value is the sheet resistance in ohms/square.
"rho" is the sheet resistance in ohms/square.
If used with a name, the extractor will produce devices with device
class <class_doc href="DeviceClassResistorWithBulk">DeviceClassResistorWithBulk</class_doc>. If used with a specific device
class object, the extractor will produce devices with this class.
It is the responsibility of the user that this class is compatible with
the parameters and terminals the extractor will require.
</p><p>
See <class_doc href="DeviceExtractorResistorWithBulk">DeviceExtractorResistorWithBulk</class_doc> for more details
about this extractor.
</p>
<a name="resistor_with_bulk_class"/><h2>"resistor_with_bulk_class" - Supplies the device class for a resistor that includes a bulk terminal</h2>
<keyword name="resistor_with_bulk_class"/>
<p>Usage:</p>
<ul>
<li><tt>resistor_with_bulk_class(name)</tt></li>
</ul>
<p>
See <class_doc href="DeviceClassResistorWithBulk">DeviceClassResistorWithBulk</class_doc> for more details
about this device class.
</p>
<a name="rounded_corners"/><h2>"rounded_corners" - Applies corner rounding</h2>
<keyword name="rounded_corners"/>
<p>Usage:</p>
@ -2318,6 +2501,7 @@ shape.
<ul>
<li><tt>write_spice([ use_net_names [, with_comments ] ])</tt></li>
<li><tt>write_spice(writer_delegate [, use_net_names [, with_comments ] ])</tt></li>
<li><tt>write_spice(spice_profile [, use_net_names [, with_comments ] ])</tt></li>
</ul>
<p>
Use this option in <a href="#target_netlist">target_netlist</a> for the format parameter to
@ -2328,5 +2512,12 @@ information comments such as instance coordinates or pin names.
</p><p>
"writer_delegate" allows using a <class_doc href="NetlistSpiceWriterDelegate">NetlistSpiceWriterDelegate</class_doc> object to
control the actual writing.
</p><p>
To provide the name of a SPICE profile to use, include it the following way:
</p><p>
<pre>
# write SPICE files using profile "my_profile"
write_spice(spice_profile("my-profile"))
</pre>
</p>
</doc>

View File

@ -468,7 +468,6 @@ either save to OASIS, or use integer numbers for the property names.
<p>Usage:</p>
<ul>
<li><tt>extract_devices(extractor, layer_hash)</tt></li>
<li><tt>extract_devices(extractor_class, name, layer_hash)</tt></li>
</ul>
<p>
Runs the device extraction for given device extractor class. In the first
@ -608,6 +607,28 @@ layout analysis. Hence, all <a href="#connect">connect</a>, <a href="#connect_gl
calls must have been made before this method is used. Further <a href="#connect">connect</a>
statements will clear the netlist and re-extract it again.
</p>
<a name="register_device_class"/><h2>"register_device_class" - Registers a device class for device extraction and netlisting</h2>
<keyword name="register_device_class"/>
<p>Usage:</p>
<ul>
<li><tt>register_device_class(dc)</tt></li>
</ul>
<p>
Registers the given device class object ("dc" is of type <class_doc href="DeviceClass">DeviceClass</class_doc>)
for use inside device extraction and for reading and writing netlists.
Registering a device class allows utilizing SPICE profiles for reading and
writing SPICE files. Device classes need to be registered before "schematic"
or "extract_devices" is used.
</p><p>
Registering device classes simplifies implementation of custom SPICE
representations for devices. Usually it is not required then to provide
SPICE reader or write delegates, as the SPICE format can be configured
inside the device class through SPICE profiles.
</p><p>
When creating custom device extractors, it is no longer required to
register a device class inside the device extractor. Instead, pre-registered device
classes are identified with a device extractor class by name.
</p>
<a name="soft_connect"/><h2>"soft_connect" - Specifies a soft connection between two layers</h2>
<keyword name="soft_connect"/>
<p>Usage:</p>

View File

@ -172,6 +172,23 @@ See <a href="/about/lvs_ref_netter.xml">Netter</a> for more details
<p>
See <a href="/about/lvs_ref_netter.xml#no_lvs_hints">Netter#no_lvs_hints</a> for a description of that feature.
</p>
<a name="register_device_class"/><h2>"register_device_class" - Registers a device class for device extraction and netlisting</h2>
<keyword name="register_device_class"/>
<p>Usage:</p>
<ul>
<li><tt>register_device_class(dc)</tt></li>
</ul>
<p>
Registers the device class for extraction and netlist input and output.
"dc" is an object of type <class_doc href="DeviceClass">DeviceClass</class_doc>.
</p><p>
Registering a device class is optional. However, using registered
device classed simplify SPICE netlist reading and writing, as device classes
can be configured with SPICE profiles to customize SPICE input and output.
See <a href="/about/lvs_ref_netter.xml#register_device_class">Netter#register_device_class</a> for a description of this function.
Also see <a href="/about/lvs_ref_netter.xml#extract_devices">Netter#extract_devices</a> for how to use it with registered
device classes.
</p>
<a name="report_lvs"/><h2>"report_lvs" - Specifies an LVS report for output</h2>
<keyword name="report_lvs"/>
<p>Usage:</p>

View File

@ -473,6 +473,8 @@ same_nets!("ND2", "A", "B")
<ul>
<li><tt>schematic(filename)</tt></li>
<li><tt>schematic(filename, reader)</tt></li>
<li><tt>schematic(filename, spice_profile)</tt></li>
<li><tt>schematic(filename, spice_reader_delegate)</tt></li>
<li><tt>schematic(netlist)</tt></li>
<li><tt>schematic</tt></li>
</ul>
@ -480,9 +482,24 @@ same_nets!("ND2", "A", "B")
If no argument is given, the current schematic netlist is returned. nil is
returned if no schematic netlist is set yet.
</p><p>
If a filename is given (first two forms), the netlist is read from the given file.
If a filename is given, the netlist is read from the given file.
</p><p>
If no reader is provided, Spice format will be assumed. The reader object is a
<class_doc href="NetlistReader">NetlistReader</class_doc> object and allows detailed customization of the reader process.
Or you specify a <class_doc href="NetlistSpiceReaderDelegate">NetlistSpiceReaderDelegate</class_doc> object to customize a SPICE reader
with a delegate.
</p><p>
Instead of a reader or delegate, a SPICE profile can be specified. In that case, the device
classes need to be registered with <a href="#register_device_class">register_device_class</a> before the schematic
method is called. To use a SPICE profile with name "my-profile" use this code:
</p><p>
<pre>
# for a specific netter object
netter.schematic("netlist.cir", spice_profile("my-profile"))
# or globally
schematic("netlist.cir", spice_profile("my-profile"))
</pre>
</p><p>
Alternatively, a <class_doc href="Netlist">Netlist</class_doc> object can be given which is obtained from any other
source.

View File

@ -7,6 +7,7 @@
<keyword name="LVS"/>
<keyword name="LVS Input Output"/>
<keyword name="LVS SPICE"/>
<keyword name="SPICE delegates"/>
<h2-index/>
@ -40,6 +41,7 @@
You can write a netlist file to supply netlists for simulators for example.
Within LVS scripts, the global "target_netlist" statement triggers writing of a netlist
(see <a href="/about/drc_ref_global.xml#target_netlist">target_netlist</a> for details).
For example, this writes the extracted netlist to "output.cir" in SPICE format:
</p>
<pre>target_netlist("output.cir", write_spice, "Created by KLayout")</pre>
@ -55,19 +57,33 @@
</p>
<p>
The "write_spice" configuration function has two options:
The "write_spice" configuration function has these options:
</p>
<pre>write_spice(use_net_names, with_comments)</pre>
<pre>write_spice(use_net_names, with_comments)
write_spice(spice_profile(profile_name), use_net_names, with_comments)</pre>
<p>
Both options are boolean values. If true and present, the first option will make
"use_net_names" and "with_comments" are optional, boolean values. If true and present, the first option will make
the writer use the real net's names instead of numerical IDs. If true and present,
"with_comments" will embed debug comments into the netlist showing instance
locations, pin names etc.
</p>
<p>
For customizing SPICE output there are two possible
implementation paths: SPICE profiles and SPICE writer delegates.
While SPICE writer delegates are the most flexible way, SPICE
profiles are easier to use, but require a certain structure
in the LVS scripts.
</p>
<p>
For documentation on SPICE profiles see the corresponding section below.
</p>
<h3>SPICE writer delegates</h3>
<keyword name="SPICE writer delegates"/>
<p>
Further customization can be achieved by providing an explicit SPICE writer
@ -145,30 +161,6 @@ X$2 VSS IN OUT SUBSTRATE NMOS PARAMS: L=0.25 W=0.9 AS=0.405 AD=0.405 PS=2.7
this way, a single netlist can be written to multiple files in different flavours.
</p>
<h3>SPICE profiles</h3>
<p>
An easier way to customize SPICE output is through "SPICE profiles". SPICE profiles are
pieces of data attached to "device class". Every device inside a netlist is associated with a
device class. The device class is a named entity inside the netlist. In a SPICE netlist, the
model name is the name of that device class. Device classes are objects of type <class_doc href="DeviceClass"/>.
Device classes, among other properties, carry "SPICE profiles". A SPICE profile declares:
</p>
<ul>
<li>The element to use for the device (e.g. "M" or "X")</li>
<li>How the parameters are written</li>
<li>How the parameters are read</li>
</ul>
<p>
In most cases, the SPICE profiles will be enough to configure how devices are written
and read from SPICE files, so it is not required to implement a reader or writer delegate.
On the back side, it is required to declare and configure the device classes in the LVS
scripts.
</p>
<h2>Reading netlists</h2>
<p>
@ -187,6 +179,21 @@ X$2 VSS IN OUT SUBSTRATE NMOS PARAMS: L=0.25 W=0.9 AS=0.405 AD=0.405 PS=2.7
Capacitor device classes) and "D" (gives diode device classes).
</p>
<p>
For customizing SPICE input there are two possible
implementation paths: SPICE profiles and SPICE reader delegates.
While SPICE reader delegates are the most flexible way, SPICE
profiles are easier to use, but require a certain structure
in the LVS scripts.
</p>
<p>
For documentation on SPICE profiles see the corresponding section below.
</p>
<h3>SPICE reader delegates</h3>
<keyword name="SPICE reader delegates"/>
<p>
As for the SPICE reader, a delegate can be provided to customize the reader.
For doing so, subclass the <class_doc href="NetlistSpiceReaderDelegate"/>
@ -300,4 +307,133 @@ schematic("inv_xmodels.cir", reader)</pre>
Hence exchange of LVS reports is possible.
</p>
<h2>SPICE profiles</h2>
<keyword name="SPICE profiles"/>
<p>
An easier way to customize SPICE output is through "SPICE profiles". SPICE profiles are
pieces of data attached to a "device class". Every device inside a netlist is associated with a
device class. The device class is a named entity inside the netlist. In a SPICE netlist, the
model name is the name of that device class. Device classes are objects of type <class_doc href="DeviceClass"/>.
Device classes carry, among other properties, "SPICE profiles". A SPICE profile declares:
</p>
<ul>
<li>The element to use for the device (e.g. "M" or "X")</li>
<li>How the parameters are written</li>
<li>How the parameters are read</li>
</ul>
<p>
In most cases, the SPICE profiles will be enough to configure how devices are written
and read from SPICE files, so it is not required to implement a reader or writer delegate.
On the back side, it is required to declare and configure the device classes in the LVS
scripts.
</p>
<p>
To declare devices, you have to include their definitions before you use "schematic" to
read the schematic netlist and before you extract devices.
Definitions are made by creating a device class, either from the standard device classes
or using a custom one, and then configuring them. After you have configured them, they
need to be registered, so the SPICE reader and writer code knows they exist.
</p>
<p>
Convenience helpers are provided to create an instance of the standard classes:
<a href="/about/drc_ref_global.xml#mos4_class">mos4_class</a>,
<a href="/about/drc_ref_global.xml#dmos4_class">dmos4_class</a>,
<a href="/about/drc_ref_global.xml#mos3_class">mos3_class</a>,
<a href="/about/drc_ref_global.xml#dmos3_class">dmos3_class</a>,
<a href="/about/drc_ref_global.xml#diode_class">diode_class</a>,
<a href="/about/drc_ref_global.xml#bjt3_class">bjt3_class</a>,
<a href="/about/drc_ref_global.xml#bjt4_class">bjt4_class</a>,
<a href="/about/drc_ref_global.xml#resistor_class">resistor_class</a>,
<a href="/about/drc_ref_global.xml#resistor_with_bulk_class">resistor_with_bulk_class</a>,
<a href="/about/drc_ref_global.xml#capacitor_class">capacitor_class</a> and
<a href="/about/drc_ref_global.xml#capacitor_with_bulk_class">capacitor_with_bulk_class</a>.
The helpers create device class objects which are pre-filled with the corresponding
parameters and terminals. Also, the device combination rules are configured already.
</p>
<p>
Here is an example how to register custom device classes derived from the MOS4 class
(<class_doc href="DeviceClassMOS4Transistor"/>) and which bind to SPICE "X" elements:
</p>
<pre>...
# Creates a PMOS device derived from the MOS4 built-in type
# and configure the default SPICE profile to use element type "X"
pmos = mos4_class("PMOS")
pmos.spice_profile().element = "X"
# Same for NMOS
nmos = mos4_class("NMOS")
nmos.spice_profile().element = "X"
# Registers the two new device classes
# NOTE: this needs to come before the schematic netlist is read
# or devices are extracted
register_device_class(pmos)
register_device_class(nmos)
# Reads the schematic
schematic("schematic.cir")
...
# PMOS transistor device extraction
# NOTE: "mos4(pmos)" creates a device extractor for MOS4 devices which
# produces devices of "pmos" type.
extract_devices(mos4(pmos), { "SD" => psd, "G" => pgate, "W" => nwell,
"tS" => psd, "tD" => psd, "tG" => poly, "tW" => nwell })
# NMOS transistor device extraction
extract_devices(mos4(nmos), { "SD" => nsd, "G" => ngate, "W" => bulk,
"tS" => nsd, "tD" => nsd, "tG" => poly, "tW" => bulk })
...</pre>
<p>
For complete freedom of device configuration, you can also create
your own classes using the <class_doc href="DeviceClass"/> class.
Instead using the factories for pre-defined classes (such as "mos4_class" above),
you instantiate your own class.
</p>
<p>
For more information about how SPICE reading and writing can be configured
with SPICE profiles, see here: <class_doc href="DeviceClassSpiceProfile"/>.
Note that currently you can't modify the model name through SPICE profiles.
</p>
<p>
There can be multiple SPICE profiles for different purposes (e.g.
SPICE reading and writing. SPICE profiles are named. For example, you
can declare two profiles - one for reading (called "READ") and one
for writing (called "WRITE") and use them separately:
</p>
<pre>...
# Configures the target netlist to be written with SPICE profile "WRITE"
target_netlist("extracted.cir", write_spice(spice_profile("WRITE")), "Extracted by KLayout")
...
# Creates a device class for "PMOS" with two SPICE
# profiles. The one for reading uses the "X" element,
# the one for writing uses the "M" element:
pmos = mos4_class("PMOS")
pmos.spice_profile("READ").element = "X"
pmos.spice_profile("WRITE").element = "M"
...
# Reads the schematic using SPICE profile "READ"
schematic("schematic.cir", spice_profile("READ"))
...</pre>
</doc>