From 20c8c6bdaadfc8a417c470227a67505390e022ea Mon Sep 17 00:00:00 2001
From: Matthias Koefferlein
+ LVS (and also DRC as far as netlist extraction is concerned) provides
+
+
+ KLayout implements a variety of standard device classes. These device classes
+ are the basis for forming particular incarnations of device classes.
+ For example, the MOS4 class is the basis for the specific device classes
+ for NMOS and PMOS transistors.
+
+
+ The plain resistor has two terminals, A and B. It features the following
+ parameters:
+
+ Resistors can combine in parallel or serial fashion.
+
+ In SPICE, plain resistors are represented by the "R" element.
+ The API class is
+
+ The resistor with bulk terminal is an extension of the plain resistor.
+ If has the same parameters, but one additional terminal (W) which connects to
+ the area the resistor sits in (e.g. well or substrate).
+
+ Resistors with bulk can combine in parallel or serial fashion if their
+ bulk terminals are connected to the same net.
+
+ The API class of the resistor with bulk is
+
+ The plain capacitor has two terminals, A and B. It features the following
+ parameters:
+
+ In SPICE, plain capacitors are represented by the "C" element.
+ The API class is
+
+ The capacitor with bulk terminal is an extension of the plain capacitor.
+ If has the same parameters, but one additional terminal (W) which connects to
+ the area the capacitor sits in (e.g. well or substrate).
+
+ Capacitors with bulk can combine in parallel or serial fashion if their
+ bulk terminals are connected to the same net.
+
+ The API class of the capacitor with bulk is
+
+ Diodes have two terminals, A and C for anode and cathode. Diodes
+ feature the following parameters:
+
+ Diodes combine in parallel (A to A and C to C). In this case
+ their areas and perimeters will add.
+
+ In SPICE, diodes are represented by the "D" element using the
+ device class name as the model name.
+ The API class is
+
+ Three-terminal MOS transistors have terminals S, G and D for source, gate and drain.
+ S and D are commutable. They feature the following parameters:
+
+ MOS3 transistors combine in parallel when the source/drains and gates are connected
+ and their gate lengths are identical.
+ In this case their widths, areas and perimeters will add.
+
+ The API class of the three-terminal MOS transistor is
+
+ The four-terminal transistor is an extension of the three-terminal one and
+ offers an additional bulk terminal (B). It is probably the most prominent
+ transistor device as the four-terminal version is compatible with the SPICE
+ "M" element.
+
+ MOS transistors with bulk can combine in parallel the same way the three-terminal
+ versions do if their bulk terminals are connected to the same net.
+
+ In SPICE, MOS4 devices are represented by the "M" element with the
+ device class name as the model name.
+ The API class is
+
+ The three-terminal bipolar transistor can be either NPN or PNP type.
+ In KLayout, this device type can represent both lateral and vertical
+ types.
+ The parameters are:
+
+ Upon extraction, multi-emitter versions are extracted as multiple devices - one
+ for each emitter area - and NE = 1. Bipolar transistors combine when in parallel.
+ In this case, their emitter parameters AE, PE and NE are added.
+
+ In SPICE, BJT3 devices are represented by the "Q" element with the
+ device class name as the model name.
+ The API class is
+
+ The four-terminal transistor is an extension of the three-terminal one and
+ offers an additional bulk terminal (S).
+
+ Bipolar transistors with bulk can combine in parallel the same way the three-terminal
+ versions do if their bulk terminals are connected to the same net.
+
+ In SPICE, BJT4 devices are represented by the "Q" element with four nodes and the
+ device class name as the model name.
+ The API class is
+ Device extractors and the actual "workers" of the device extraction process.
+ KLayout comes with a variety of pre-built device extractors. It's possible to
+ implement custom device extractors in the framework of LVS scripts (speaking
+ Ruby).
+
+ The resistor extractor assumes a layout which consists of a resistor "wire"
+ and two caps (contacts). The wire is specified with the layer symbol "R",
+ the caps are specified with the layer symbol "C":
+
+
+ The extractor will compute the resistance from the number of squares
+ and the sheet resistance. The sheet resistance needs to be given
+ when creating the extractor:
+
+ The plain resistor offers two terminals which it outputs on "tA" and "tB" terminal layers.
+ If "tA" or "tB" is not specified, "A" or "B" terminals will be written on the "C" layer.
+ respectively.
+
+
+
+ For the resistor with bulk, the wire area is output on the "tW" terminal layer as
+ the "W" terminal:
+
+
+ Capacitors are assumed to consist of two "plates" (vertical capacitors).
+ The plates are on layers P1 and P2. The capacitor is extracted from the area where
+ these two layers overlap.
+
+
+ The extractor will compute the capacitance from the area of the
+ overlap and the capacitance per area (F/µm²) value.
+
+ The plain capacitor offers two terminals which it outputs on "tA" and "tB" terminal layers.
+ If "tA" or "tB" is not specified, "A" or "B" terminals will be written on the "P1" and "P2" layers
+ respectively.
+
+
+
+ For the capacitor with bulk, the capacitor area is output on the "tW" terminal layer as
+ the "W" terminal:
+
+
+ Diodes are assumed to consist of two vertical implant regions (wells, diffusion).
+ One of the regions is p type ("P" layer) and the other "n" type ("N" layer).
+ These layers also form the anode (p) and cathode (n) of the diode.
+
+
+ The extractor will compute the capacitance from the area of the
+ overlap and the capacitance per area (F/µm²) value.
+
+ The diode offers two terminals which it outputs on "tA" and "tC" terminal layers.
+ If "tA" is not specified, "A" terminals will be written on the "P" layer.
+ If "tC" is not specified, "C" terminals will be written on the "N" layer.
+
+
+
+ MOS transistors are recognized by their gate ("G" input) and source/drain ("SD" input) regions.
+ Source and drain needs to be separated from the gate shape. The touching edges of gate and
+ source/drain regions define the width of the device, the perpendicular dimension the gate length.
+ Because the separation of source/drain, the computation of gates and the separation of
+ these for NMOS and PMOS devices, the "G" and "SD" layers are usually derived layers.
+ As these usually won't participate in the connectivity, it's important to specify the
+ "tS", "tD", "tG" and "tB" (for MOS4) layers explicitly and redirect the terminal shapes
+ to layers that really participate in connections.
+
+
+ The MOS3 device produces three terminals which it outputs on "tS", "tG" and "tD" terminal layers (source,
+ gate and drain respectively):
+
+
+
+
+ The MOS4 device offers one more terminal (bulk) which it writes on "tB".
+
+
+ There are basically two kind of bipolar transistors: vertical and lateral ones.
+
+ Lateral transistors are formed by implant or diffusion wells creating a intermittent
+ n/p structure on the wafer. The basic recognition region is the base region. The collector
+ and emitter regions are inside or overlapping the base region and use the opposite doping
+ than base: if the base region is n doped, then
+ collector and emitter regions have to be p doped. The structure then forms a PNP transistor.
+ KLayout recognizes lateral transistors when the base is partially covered by the collector region.
+ For lateral transistors, the emitter is defined by the emitter region inside base. The
+ collector region is defined by collector inside base and outside emitter.
+
+
+ Vertical transistors are formed by a stack of n/p wells. Sometimes vertical transistors
+ are formed as parasitic devices in standard CMOS processes. A PNP transistor can be formed
+ by taking the collector as the substrate, nwell for the base and pplus implant for the emitter.
+ KLayout recognizes a vertical bipolar transistor when the base is covered entirely by the
+ collector or has no collector at all - this means the collector
+ region can be empty (e.g. bulk).
+
+
+ In both cases, there can be multiple emitter regions inside a base island. In this
+ case, one transistor is extracted for each emitter region.
+
+ Vertical bipolar transistors take their inputs from "B" (base), "C" (collector)
+ and "E" (emitter). "C" is optional:
+
+
+ Especially for bipolar devices it's important to device useful terminal output
+ layers. Typically, the wells and diffusion areas will be connected through "contact",
+ (not considering the Schottky diodes for now).
+ So it's a good idea to send the terminals to the contact layer:
+
+ The BJT3 device produces three terminals which it outputs on "tC", "tB" and "tE" terminal layers (collector,
+ base and emitter respectively):
+
+
+
+
+ If the collector region is empty (e.g. p substrate), the base shape is copied to the "tC" output layer
+ for the collector terminal.
+
+ The BJT4 device offers one more terminal (substrate) which it writes on "tS". "tS" is
+ a copy of the emitter shape but connected to the substrate terminal:
+
+
+ Lateral bipolar transistors also take their inputs from "B" (base), "C" (collector)
+ and "E" (emitter). For lateral transistors, "C" is not optional and must not fully cover
+ the base region. Apart from this, the use model for BJT3 and BJT4 extractors is
+ identical for vertical and lateral transistors.
+
+ A typical lateral transistor is formed by a collector ring and emitter
+ island inside the base region:
+
+
+ The terminals produced by the bipolar transistor extractor in the lateral case are
+ the same than for the vertical case, but with a different geometry:
+
+
+
+
+ Again, for BJT4, "tS" is a copy of the emitter shape but connected to the substrate terminal:
+
+ Resistor
+
+
+
+
+
+ Resistor with bulk terminal
+
+
+ Capacitor
+
+
+
+
+
+ Capacitor with bulk terminal
+
+
+ Diode
+
+
+
+
+
+ MOS transistor
+
+
+
+
+
+ MOS transistor with bulk
+
+
+ Bipolar transistor
+
+
+
+
+
+ Bipolar transistor with substrate
+
+
+ Resistor extractors (resistor
+ and resistor_with_bulk)
+
+
+ sheet_rho = 0.5
+model_name = "RES"
+extract_devices(resistor(model_name, sheet_rho), { "R" => res_layer, "C" => cap_layer })
+
+
+
+
+ Capacitor extractors (capacitor
+ and capacitor_with_bulk)
+
+
+ area_cap = 1.5e-15
+model_name = "CAP"
+extract_devices(capacitor(model_name, area_cap), { "P1" => metal1, "P2" => metal2 })
+
+
+
+
+ Diode extractor (diode)
+
+
+ model_name = "DIODE"
+extract_devices(diode(model_name), { "P" => pplus, "N" => nwell })
+
+
+
+ MOS transistor extractor (mos3 and mos4)
+
+
+ model_name = "PMOS"
+extract_devices(mos4(model_name), { "SD" => (active - poly) & pplus, "G" => (active & poly), "W" => nwell,
+ "tS" => active, "tD" => active, "tG" => poly, "tB" => nwell })
+
+
+
+
+
+ Bipolar transistor extractor (bjt3 and bjt4)
+
+
(lateral PNP transistor)
+
(vertical PNP transistor)
+ Vertical bipolar transistors
+
+
+ model_name = "PNP"
+extract_devices(bjt3(model_name), { "C" => collector, "B" => base, "E" => emitter,
+ "tC" => contact, "tB" => contact, "tE" => contact })
+
+
+
+
+
+ Lateral bipolar transistors
+
+
+
+
+
+
+ Device extractors and device classes
@@ -15,555 +13,22 @@
KLayout provides two concepts for handling device variety:
-
-
- The plain resistor has two terminals, A and B. It features the following - parameters: -
- -- Resistors can combine in parallel or serial fashion. -
- -
- In SPICE, plain resistors are represented by the "R" element.
- The API class is
-
-
- The resistor with bulk terminal is an extension of the plain resistor. - If has the same parameters, but one additional terminal (W) which connects to - the area the resistor sits in (e.g. well or substrate). -
- -- Resistors with bulk can combine in parallel or serial fashion if their - bulk terminals are connected to the same net. -
- -
- The API class of the resistor with bulk is
-
-
- The plain capacitor has two terminals, A and B. It features the following - parameters: -
- -
- In SPICE, plain capacitors are represented by the "C" element.
- The API class is
-
-
- The capacitor with bulk terminal is an extension of the plain capacitor. - If has the same parameters, but one additional terminal (W) which connects to - the area the capacitor sits in (e.g. well or substrate). -
- -- Capacitors with bulk can combine in parallel or serial fashion if their - bulk terminals are connected to the same net. -
- -
- The API class of the capacitor with bulk is
-
-
- Diodes have two terminals, A and C for anode and cathode. Diodes - feature the following parameters: -
- -- Diodes combine in parallel (A to A and C to C). In this case - their areas and perimeters will add. -
- -
- In SPICE, diodes are represented by the "D" element using the
- device class name as the model name.
- The API class is
-
-
- Three-terminal MOS transistors have terminals S, G and D for source, gate and drain. - S and D are commutable. They feature the following parameters: -
- -- MOS3 transistors combine in parallel when the source/drains and gates are connected - and their gate lengths are identical. - In this case their widths, areas and perimeters will add. -
- -
- The API class of the three-terminal MOS transistor is
-
-
Device classes are documented here: .
- The four-terminal transistor is an extension of the three-terminal one and - offers an additional bulk terminal (B). It is probably the most prominent - transistor device as the four-terminal version is compatible with the SPICE - "M" element. + Device extractors are the actual worker objects that analyze layout and produce devices. + As for device classes, there are general device extractors. Each device extractor produces + devices from a specific class.
-- MOS transistors with bulk can combine in parallel the same way the three-terminal - versions do if their bulk terminals are connected to the same net. -
- -
- In SPICE, MOS4 devices are represented by the "M" element with the
- device class name as the model name.
- The API class is
-
-
- The three-terminal bipolar transistor can be either NPN or PNP type. - In KLayout, this device type can represent both lateral and vertical - types. - The parameters are: -
- -- Upon extraction, multi-emitter versions are extracted as multiple devices - one - for each emitter area - and NE = 1. Bipolar transistors combine when in parallel. - In this case, their emitter parameters AE, PE and NE are added. -
- -
- In SPICE, BJT3 devices are represented by the "Q" element with the
- device class name as the model name.
- The API class is
-
-
- The four-terminal transistor is an extension of the three-terminal one and - offers an additional bulk terminal (S). -
- -- Bipolar transistors with bulk can combine in parallel the same way the three-terminal - versions do if their bulk terminals are connected to the same net. -
- -
- In SPICE, BJT4 devices are represented by the "Q" element with four nodes and the
- device class name as the model name.
- The API class is
- The resistor extractor assumes a layout which consists of a resistor "wire" - and two caps (contacts). The wire is specified with the layer symbol "R", - the caps are specified with the layer symbol "C": -
- -
-
-
- The extractor will compute the resistance from the number of squares - and the sheet resistance. The sheet resistance needs to be given - when creating the extractor: -
- -sheet_rho = 0.5
-model_name = "RES"
-extract_devices(resistor(model_name, sheet_rho), { "R" => res_layer, "C" => cap_layer })
-
- - The plain resistor offers two terminals which it outputs on "tA" and "tB" terminal layers. - If "tA" or "tB" is not specified, "A" or "B" terminals will be written on the "C" layer. - respectively. -
- -
-
-
-
-
- For the resistor with bulk, the wire area is output on the "tW" terminal layer as - the "W" terminal: -
- -
-
-
- Capacitors are assumed to consist of two "plates" (vertical capacitors). - The plates are on layers P1 and P2. The capacitor is extracted from the area where - these two layers overlap. -
- -
-
-
- The extractor will compute the capacitance from the area of the - overlap and the capacitance per area (F/µm²) value. -
- -area_cap = 1.5e-15
-model_name = "CAP"
-extract_devices(capacitor(model_name, area_cap), { "P1" => metal1, "P2" => metal2 })
-
- - The plain capacitor offers two terminals which it outputs on "tA" and "tB" terminal layers. - If "tA" or "tB" is not specified, "A" or "B" terminals will be written on the "P1" and "P2" layers - respectively. -
- -
-
-
-
-
- For the capacitor with bulk, the capacitor area is output on the "tW" terminal layer as - the "W" terminal: -
- -
-
-
- Diodes are assumed to consist of two vertical implant regions (wells, diffusion). - One of the regions is p type ("P" layer) and the other "n" type ("N" layer). - These layers also form the anode (p) and cathode (n) of the diode. -
- -
-
-
- The extractor will compute the capacitance from the area of the - overlap and the capacitance per area (F/µm²) value. -
- -model_name = "DIODE"
-extract_devices(diode(model_name), { "P" => pplus, "N" => nwell })
-
- - The diode offers two terminals which it outputs on "tA" and "tC" terminal layers. - If "tA" is not specified, "A" terminals will be written on the "P" layer. - If "tC" is not specified, "C" terminals will be written on the "N" layer. -
- -
-
-
-
-
- MOS transistors are recognized by their gate ("G" input) and source/drain ("SD" input) regions. - Source and drain needs to be separated from the gate shape. The touching edges of gate and - source/drain regions define the width of the device, the perpendicular dimension the gate length. - Because the separation of source/drain, the computation of gates and the separation of - these for NMOS and PMOS devices, the "G" and "SD" layers are usually derived layers. - As these usually won't participate in the connectivity, it's important to specify the - "tS", "tD", "tG" and "tB" (for MOS4) layers explicitly and redirect the terminal shapes - to layers that really participate in connections. -
- -
-
-
model_name = "PMOS"
-extract_devices(mos4(model_name), { "SD" => (active - poly) & pplus, "G" => (active & poly), "W" => nwell,
- "tS" => active, "tD" => active, "tG" => poly, "tB" => nwell })
-
- - The MOS3 device produces three terminals which it outputs on "tS", "tG" and "tD" terminal layers (source, - gate and drain respectively): -
- -
-
-
-
-
-
-
- The MOS4 device offers one more terminal (bulk) which it writes on "tB". -
- -
-
-
- There are basically two kind of bipolar transistors: vertical and lateral ones. -
- -- Lateral transistors are formed by implant or diffusion wells creating a intermittent - n/p structure on the wafer. The basic recognition region is the base region. The collector - and emitter regions are inside or overlapping the base region and use the opposite doping - than base: if the base region is n doped, then - collector and emitter regions have to be p doped. The structure then forms a PNP transistor. - KLayout recognizes lateral transistors when the base is partially covered by the collector region. - For lateral transistors, the emitter is defined by the emitter region inside base. The - collector region is defined by collector inside base and outside emitter. -
- -
-
(lateral PNP transistor)
-
- Vertical transistors are formed by a stack of n/p wells. Sometimes vertical transistors - are formed as parasitic devices in standard CMOS processes. A PNP transistor can be formed - by taking the collector as the substrate, nwell for the base and pplus implant for the emitter. - KLayout recognizes a vertical bipolar transistor when the base is covered entirely by the - collector or has no collector at all - this means the collector - region can be empty (e.g. bulk). -
- -
-
(vertical PNP transistor)
-
- In both cases, there can be multiple emitter regions inside a base island. In this - case, one transistor is extracted for each emitter region. -
- -- Vertical bipolar transistors take their inputs from "B" (base), "C" (collector) - and "E" (emitter). "C" is optional: -
- -
-
-
- Especially for bipolar devices it's important to device useful terminal output - layers. Typically, the wells and diffusion areas will be connected through "contact", - (not considering the Schottky diodes for now). - So it's a good idea to send the terminals to the contact layer: -
- -model_name = "PNP"
-extract_devices(bjt3(model_name), { "C" => collector, "B" => base, "E" => emitter,
- "tC" => contact, "tB" => contact, "tE" => contact })
-
- - The BJT3 device produces three terminals which it outputs on "tC", "tB" and "tE" terminal layers (collector, - base and emitter respectively): -
- -
-
-
-
-
-
-
- If the collector region is empty (e.g. p substrate), the base shape is copied to the "tC" output layer - for the collector terminal. -
- -- The BJT4 device offers one more terminal (substrate) which it writes on "tS". "tS" is - a copy of the emitter shape but connected to the substrate terminal: -
- -
-
-
- Lateral bipolar transistors also take their inputs from "B" (base), "C" (collector) - and "E" (emitter). For lateral transistors, "C" is not optional and must not fully cover - the base region. Apart from this, the use model for BJT3 and BJT4 extractors is - identical for vertical and lateral transistors. -
- -- A typical lateral transistor is formed by a collector ring and emitter - island inside the base region: -
- -
-
-
- The terminals produced by the bipolar transistor extractor in the lateral case are - the same than for the vertical case, but with a different geometry: -
- -
-
-
-
-
-
-
- Again, for BJT4, "tS" is a copy of the emitter shape but connected to the substrate terminal: -
- -
-
-
Device extractors are documented here: .
diff --git a/src/lay/lay/doc/manual/lvs_io.xml b/src/lay/lay/doc/manual/lvs_io.xml new file mode 100644 index 000000000..a5a76e174 --- /dev/null +++ b/src/lay/lay/doc/manual/lvs_io.xml @@ -0,0 +1,240 @@ + + + ++ LVS (and also DRC as far as netlist extraction is concerned) provides interfaces + to write and read netlists/schematics, annotated layout and LVS results. + There are three major categories of I/O: +
+ ++ You can write a netlist file to supply netlists for (functional) simulators for example. + Within LVS scripts, the global "target_netlist" statement triggers writing of a netlist + (see target_netlist for details). +
+ +target_netlist("output.cir", write_spice, "Created by KLayout")
+
+ + This statement can basically appear anywhere in the LVS script. The netlist will + written after the script has executed successfully. The first argument is + the file's path (by default relative to the original layout file). The second + argument is the "writer". "write_spice" creates a netlist writer writing SPICE + format with a limited degree of flexbility. See below for customizing the writer. + The third argument finally is an (optional) comment which will be written into + the netlist as a header. +
+ ++ The "write_spice" configuration function has two options: +
+ +write_spice(use_net_names, with_comments)+ +
+ Both options are 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. +
+ +
+ Further customization can be achieved by providing an explicit SPICE writer
+ with a delegate (see
+ Here is an example that supplied subcircuit models rather than + device elements: +
+ +# Write extracted netlist to extracted.cir using a special
+# writer delegate
+
+# This delegate makes the writer emit subcicuit calls instead of
+# standard elements for the devices
+class SubcircuitModels < RBA::NetlistSpiceWriterDelegate
+
+ def write_header
+ emit_line(".INCLUDE 'models.cir'")
+ end
+
+ def write_device(device)
+ str = "X" + device.expanded_name
+ device_class = device.device_class
+ device_class.terminal_definitions.each do |td|
+ str += " " + net_to_string(device.net_for_terminal(td.id))
+ end
+ str += " " + device_class.name
+ str += " PARAMS:"
+ device_class.parameter_definitions.each do |pd|
+ str += " " + pd.name + ("=%.12g" % device.parameter(pd.id))
+ end
+ emit_line(str)
+ end
+
+end
+
+# Prepare a writer using the new delegate
+custom_spice_writer = RBA::NetlistSpiceWriter::new(SubcircuitModels::new)
+custom_spice_writer.use_net_names= true
+custom_spice_writer.with_comments = false
+
+# The declaration of netlist production using the new custom writer
+target_netlist("extracted.cir", custom_spice_writer, "Extracted by KLayout")
+
+ + This script will produce the following netlist for the simple inverter + from the LVS introduction. Instead of printing "M" elements - which is the + default - subcircuit calls are produced. This allows putting more elaborate + models into subcircuits. The device class name addresses these model + subcircuits: +
+ +* Extracted by KLayout +.INCLUDE 'models.cir' + +.SUBCKT INVERTER +X$1 VDD IN OUT NWELL PMOS PARAMS: L=0.25 W=1.5 AS=0.675 AD=0.675 PS=3.9 PD=3.9 +X$2 VSS IN OUT SUBSTRATE NMOS PARAMS: L=0.25 W=0.9 AS=0.405 AD=0.405 PS=2.7 ++ PD=2.7 +.ENDS INVERTER+ +
+ Netlists can be written directly from the netlist object. Within the script, the
+ netlist object can be obtained with the netlist function.
+ This function will first trigger a netlist extraction unless this was done already and
+ return a
+ The main use case for reading netlists is for comparison in LVS. + Reference netlists are read with the "schematic" function + (see schematic): +
+ +schematic("inverter.cir")
+
+ + Currently SPICE is understood with some limitations: +
+ +
+ As for the SPICE reader, a delegate can be provided to customize the reader.
+ For doing so, subclass the
+ This example customizes a reader to pull MOS devices from + subcircuit models rather than from "M" elements. Basically this + customization does the opposite part of the writer customization + before (only for MOS devices). +
+ +# Provides a SPICE netlist reader delegate which turns
+# some subcircuit models (for subcircuits NMOS and PMOS)
+# into devices
+
+class SubcircuitModelsReader < RBA::NetlistSpiceReaderDelegate
+
+ # says we want to catch these subcircuits as devices
+ def wants_subcircuit(name)
+ name == "NMOS" || name == "PMOS"
+ end
+
+ # translate the element
+ def element(circuit, el, name, model, value, nets, params)
+
+ if el != "X"
+ # all other elements are left to the standard implementation
+ return super
+ end
+
+ if nets.size != 4
+ error("Subcircuit #{model} needs four nodes")
+ end
+
+ # provide a device class
+ cls = circuit.netlist.device_class_by_name(model)
+ if ! cls
+ cls = RBA::DeviceClassMOS4Transistor::new
+ cls.name = model
+ circuit.netlist.add(cls)
+ end
+
+ # create a device
+ device = circuit.create_device(cls, name)
+
+ # and configure the device
+ [ "S", "G", "D", "B" ].each_with_index do |t,index|
+ device.connect_terminal(t, nets[index])
+ end
+ params.each do |p,value|
+ device.set_parameter(p, value)
+ end
+
+ end
+
+end
+
+# Instantiate a reader using the new delegate
+reader = RBA::NetlistSpiceReader::new(SubcircuitModelsReader::new)
+
+# Import the schematic with this reader
+schematic("inv_xmodels.cir", reader)
+
+
+
++ LVS (and also DRC as far as netlist extraction is concerned) provides + +
+ +