Added LVS tests, updated doc.

This commit is contained in:
Matthias Koefferlein 2021-07-29 22:56:11 +02:00
parent 9543cea952
commit 0f09dfe8eb
15 changed files with 948 additions and 18 deletions

View File

@ -236,13 +236,7 @@ tolerance("NMOS", "L", :absolute => 0.05, :relative => 0.01)</pre>
<p>
This has two effects: first, the "L" parameter is written into the Spice output netlist and second, it is compare against
the schematic "L" parameter, provided that one is given in the netlist. No compare happens if no "L" parameter is present in the
netlist.
</p>
<p>
This behavior is overridden by a "tolerance" or "ignore_parameter" specification for that parameter or if a customer
device comparer is installed.
the schematic "L" parameter.
</p>
<p>
@ -252,8 +246,10 @@ tolerance("NMOS", "L", :absolute => 0.05, :relative => 0.01)</pre>
<pre>disable_parameter("RES", "R")</pre>
<p>
As this will make the parameter to disappear from the netlist, it's often more useful to use "ignore_parameter" instead
which has the same effect on the compare step, but will keep it in the netlist.
This behavior is overridden by a "tolerance" or "ignore_parameter" specification for that parameter or if a customer
device comparer is installed. Netlisting is affected only for the elementary devices (R, C and L) and any Spice writer
delegate can choose to ignore the primary flag. A custom device comparer may also ignore this flag.
So after all, enabling or disabling a parameter is not a strong concept but rather a hint.
</p>
<h2>Pin swapping</h2>

View File

@ -191,13 +191,13 @@ module LVS
# %LVS%
# @name enable_parameter
# @brief Specifies whether to enable a parameter from a given device class for the netlisting and default compare
# @brief Specifies whether to enable a parameter from a given device class for netlisting and default compare
# @synopsis enable_parameter(device_class_name, parameter_name)
# See \Netter#enable_parameter for a description of that function.
# %LVS%
# @name disable_parameter
# @brief Specifies whether to disable a parameter from a given device class for the netlisting and default compare
# @brief Specifies whether to disable a parameter from a given device class for netlisting and default compare
# @synopsis disable_parameter(device_class_name, parameter_name)
# See \Netter#disable_parameter for a description of that function.

View File

@ -201,18 +201,24 @@ module LVS
# @name enable_parameter
# @brief Indicates whether to enable a specific parameter for a given device
# @synopsis enable_parameter(device_class_name, parameter_name)
# Enabling a parameter has two effects: first the parameter is netlisted and second
# the parameter is compared in the netlist compare - provided it is given in the schematic.
# Setting a tolerance or using a custom device comparer will override the last rule.
# The parameter is made "primary" which enables further applications - e.g. it is netlisted
# for some elements which normally would suppress additional parameters and the parameter
# is compared in the default device compare scheme during netlist matching.
# Enabling a parameter is rather a hint for the system and the effects can be controlled
# by other means, so this is not a strong concept. For example, once a \tolerance is
# specified for a parameter, the "primary" flag of the parameter is not considered anymore.
# The inverse the this function is \disable_parameter.
# %LVS%
# @name disable_parameter
# @brief Indicates whether to disable a specific parameter for a given device
# @synopsis disable_parameter(device_class_name, parameter_name)
# Disabling a parameter has two effects: first the parameter is not netlisted and second
# the parameter is compared in the netlist compare - provided it is given in the schematic.
# Setting a tolerance or using a custom device comparer will override the last rule.
# To disable a parameter for compare only, \ignore_parameter can be used.
# Disabling a parameter is the inverse of \enable_parameter. Disabling a parameter will
# reset the "primary" flag of the parameter. This has several effects - e.g. the parameter will not be
# used in device compare during netlist matching by default. This is not a strong concept but rather
# a hint for the system. Disabling a parameter for netlist compare without side effects
# is possible with the \ignore_parameter function. In the same way, \tolerance will enable a parameter for
# netlist compare regardless of the "primary" status of the parameter.
[ :enable_parameter, :disable_parameter ].each do |mn|
eval <<"CODE"

View File

@ -261,3 +261,10 @@ TEST(28_BlackBoxDevicesWithBlank)
run_test (_this, "bbdevices5b", "bbdevices5.gds");
run_test (_this, "bbdevices6b", "bbdevices6.gds");
}
TEST(29_DeviceCombineAndTolerances)
{
run_test (_this, "res_combine1", "res_combine.gds");
run_test (_this, "res_combine2", "res_combine.gds");
run_test (_this, "res_combine3", "res_combine.gds");
}

BIN
testdata/lvs/res_combine.gds vendored Normal file

Binary file not shown.

7
testdata/lvs/res_combine1.cir vendored Normal file
View File

@ -0,0 +1,7 @@
* Extracted by KLayout
* cell Res2
.SUBCKT Res2
* device instance $1 r0 *1 110.14,51.795 RPP1
R$1 1 2 95 RPP1 L=420U W=2.21052631579U
.ENDS Res2

96
testdata/lvs/res_combine1.lvs vendored Normal file
View File

@ -0,0 +1,96 @@
source($lvs_test_source)
report_lvs($lvs_test_target_lvsdb, true)
target_netlist($lvs_test_target_cir, write_spice, "Extracted by KLayout")
schematic("res_combine_schematic.cir")
deep
# -------------------------------------------------------------------
# Layers
pimp = input(7, 0)
poly_dg = input(13, 0)
cont = input(15, 0)
met1_dg = input(16, 0)
sblk = input(34, 0)
rp_1 = sblk & poly_dg
rpp1 = rp_1 & pimp
p1trm = poly_dg - rpp1
class ResistorExtractor < RBA::GenericDeviceExtractor
def initialize(name, sheet_rho)
self.name = name
@sheet_rho = sheet_rho
end
def setup
define_layer("C", "Conductor")
define_layer("R", "Resistor")
register_device_class(RBA::DeviceClassResistor::new)
end
def get_connectivity(layout, layers)
# this "connectivity" forms the shape clusters that make up the device
conn = RBA::Connectivity::new
conn.connect(layers[0], layers[1]) # collect touching contacts
conn.connect(layers[1], layers[1]) # combine resistor shapes into one area
conn
end
def extract_devices(layer_geometry)
# layer_geometry provides the input layers in the order they are defined with "define_layer"
conductor = layer_geometry[0]
resistor = layer_geometry[1]
resistor_regions = resistor.merged
resistor_regions.each do |r|
terminals = conductor.interacting(resistor)
if terminals.size != 2
error("Resistor shape does not touch marker border in exactly two places", r)
else
double_width = 0
(terminals.edges & resistor.edges).merged.each do |e|
double_width += e.length
end
# A = L*W
# -> L = A/W
a = r.area*dbu*dbu
w = (double_width / 2.0)*dbu
l = a / w
device = create_device
device.set_parameter(RBA::DeviceClassResistor::PARAM_R, @sheet_rho * l / w);
device.set_parameter(RBA::DeviceClassResistor::PARAM_A, a)
device.set_parameter(RBA::DeviceClassResistor::PARAM_L, l)
device.set_parameter(RBA::DeviceClassResistor::PARAM_P, 2*l+2*w)
device.set_parameter(RBA::DeviceClassResistor::PARAM_W, w)
define_terminal(device, RBA::DeviceClassResistor::TERMINAL_A, 0, terminals[0]);
define_terminal(device, RBA::DeviceClassResistor::TERMINAL_B, 0, terminals[1]);
end
end
end
end
# enable/disable
enable_parameter("RPP1", "L")
enable_parameter("RPP1", "W")
disable_parameter("RPP1", "R")
extract_devices(ResistorExtractor::new("RPP1", 0.5), # intentionally wrong: 1565.15/5
{ "C" => p1trm, "R" => rpp1 })
connect(met1_dg, cont)
connect(p1trm, cont)
netlist.flatten_circuit("Res1")
schematic.flatten_circuit("RES1")
schematic.simplify
# Netlist vs. netlist
align
netlist.simplify
compare

197
testdata/lvs/res_combine1.lvsdb vendored Normal file
View File

@ -0,0 +1,197 @@
#%lvsdb-klayout
# Layout
layout(
top(Res2)
unit(0.001)
# Layer section
# This section lists the mask layers (drawing or derived) and their connections.
# Mask layers
layer(l4 '15/0')
layer(l3 '16/0')
layer(l1)
# Mask layer connectivity
connect(l4 l4 l3 l1)
connect(l3 l4 l3)
connect(l1 l4 l1)
# Device class section
class(RPP1 RES
param(R 0 0)
param(L 1 0)
param(W 1 0)
)
# Device abstracts section
# Device abstracts list the pin shapes of the devices.
device(D$RPP1 RPP1
terminal(A
rect(l1 (0 0) (540 2000))
)
terminal(B
rect(l1 (10540 0) (540 2000))
)
)
# Circuit section
# Circuits are the hierarchical building blocks of the netlist.
circuit(Res2
# Circuit boundary
rect((8285 720) (117975 57350))
# Nets with their geometries
net(1
rect(l4 (120580 32490) (220 220))
rect(l4 (-220 -745) (220 220))
rect(l4 (-220 -745) (220 220))
rect(l4 (-220 -750) (220 220))
rect(l4 (-22355 1390) (220 220))
rect(l4 (-220 -745) (220 220))
rect(l4 (-220 -745) (220 220))
rect(l4 (-220 -750) (220 220))
rect(l4 (-21520 1755) (220 220))
rect(l4 (-220 -745) (220 220))
rect(l4 (-220 -745) (220 220))
rect(l4 (-220 -750) (220 220))
rect(l3 (0 -4795) (1065 5850))
rect(l3 (-5155 -6930) (52985 1475))
rect(l3 (-27585 -395) (1065 5850))
rect(l3 (20990 -5850) (1065 5850))
rect(l3 (-1275 -1760) (340 1920))
rect(l3 (-22475 -1890) (340 1920))
rect(l3 (-21640 -1525) (340 1920))
rect(l1 (42935 -2385) (540 2000))
rect(l1 (-22675 -1970) (540 2000))
rect(l1 (-21840 -1605) (540 2000))
)
net(2
rect(l4 (19795 5575) (220 220))
rect(l4 (-220 -745) (220 220))
rect(l4 (-220 -745) (220 220))
rect(l4 (-220 -750) (220 220))
rect(l3 (-195 -995) (2395 2500))
rect(l3 (-2480 -1785) (340 1920))
rect(l1 (-500 -1960) (540 2000))
)
# Devices and their connections
device(1 D$RPP1
device(D$RPP1 location(30 -3970))
device(D$RPP1 location(-65 -8175))
device(D$RPP1 location(-205 -12595))
device(D$RPP1 location(-225 -16825))
device(D$RPP1 location(-320 -20985))
device(D$RPP1 location(-22135 30))
device(D$RPP1 location(-22105 -3940))
device(D$RPP1 location(-22200 -8145))
device(D$RPP1 location(-22340 -12565))
device(D$RPP1 location(-22360 -16795))
device(D$RPP1 location(-22455 -20955))
device(D$RPP1 location(-43435 425))
device(D$RPP1 location(-43405 -3545))
device(D$RPP1 location(-43500 -7750))
device(D$RPP1 location(-43640 -12170))
device(D$RPP1 location(-43660 -16400))
device(D$RPP1 location(-43755 -20560))
device(D$RPP1 location(-100755 -30885))
device(D$RPP1 location(-100850 -35090))
device(D$RPP1 location(-100990 -39510))
device(D$RPP1 location(-101010 -43740))
device(D$RPP1 location(-101105 -47900))
device(D$RPP1 location(-81920 -3545))
device(D$RPP1 location(-82015 -7750))
device(D$RPP1 location(-82155 -12170))
device(D$RPP1 location(-82175 -16400))
device(D$RPP1 location(-63835 -30780))
device(D$RPP1 location(-63930 -34985))
device(D$RPP1 location(-64070 -39405))
device(D$RPP1 location(-64090 -43635))
device(D$RPP1 location(-82380 -26810))
device(D$RPP1 location(-82270 -20560))
device(D$RPP1 location(-82350 -30780))
device(D$RPP1 location(-82445 -34985))
device(D$RPP1 location(-82585 -39405))
device(D$RPP1 location(-82605 -43635))
device(D$RPP1 location(-82700 -47795))
device(D$RPP1 location(-64185 -47795))
device(D$RPP1 location(-63435 640))
device(D$RPP1 location(-63405 -3330))
device(D$RPP1 location(-63500 -7535))
device(D$RPP1 location(-63640 -11955))
device(D$RPP1 location(-63660 -16185))
device(D$RPP1 location(-63755 -20345))
device(D$RPP1 location(-63865 -26810))
device(D$RPP1 location(-100465 855))
device(D$RPP1 location(-81950 425))
device(D$RPP1 location(-100435 -3115))
device(D$RPP1 location(-100530 -7320))
device(D$RPP1 location(-100670 -11740))
device(D$RPP1 location(-100690 -15970))
device(D$RPP1 location(-100785 -20130))
device(D$RPP1 location(-100785 -26915))
connect(5 A B)
connect(11 A B)
connect(17 A B)
connect(22 B B)
location(110140 51795)
param(R 95)
param(L 420)
param(W 2.21052631579)
param(A 1080)
param(P 1296)
terminal(A 1)
terminal(B 2)
)
)
)
# Reference netlist
reference(
# Device class section
class(RPP1 RES)
# Circuit section
# Circuits are the hierarchical building blocks of the netlist.
circuit(RES2
# Nets
net(1 name(GND))
net(2 name(VDD))
# Outgoing pins and their connections to nets
pin(1 name(GND))
pin(2 name(VDD))
# Devices and their connections
device(1 RPP1
name(I0.I106.R0)
param(R 59475.7)
param(L 420)
param(W 2.21052631579)
param(A 0)
param(P 0)
terminal(A 2)
terminal(B 1)
)
)
)
# Cross reference
xref(
circuit(Res2 RES2 match
xref(
net(1 1 warning)
net(2 2 warning)
pin(() 0 match)
pin(() 1 match)
device(1 1 match)
)
)
)

7
testdata/lvs/res_combine2.cir vendored Normal file
View File

@ -0,0 +1,7 @@
* Extracted by KLayout
* cell Res2
.SUBCKT Res2
* device instance $1 r0 *1 110.14,51.795 RPP1
R$1 1 2 95 RPP1
.ENDS Res2

96
testdata/lvs/res_combine2.lvs vendored Normal file
View File

@ -0,0 +1,96 @@
source($lvs_test_source)
report_lvs($lvs_test_target_lvsdb, true)
target_netlist($lvs_test_target_cir, write_spice, "Extracted by KLayout")
schematic("res_combine_schematic.cir")
deep
# -------------------------------------------------------------------
# Layers
pimp = input(7, 0)
poly_dg = input(13, 0)
cont = input(15, 0)
met1_dg = input(16, 0)
sblk = input(34, 0)
rp_1 = sblk & poly_dg
rpp1 = rp_1 & pimp
p1trm = poly_dg - rpp1
class ResistorExtractor < RBA::GenericDeviceExtractor
def initialize(name, sheet_rho)
self.name = name
@sheet_rho = sheet_rho
end
def setup
define_layer("C", "Conductor")
define_layer("R", "Resistor")
register_device_class(RBA::DeviceClassResistor::new)
end
def get_connectivity(layout, layers)
# this "connectivity" forms the shape clusters that make up the device
conn = RBA::Connectivity::new
conn.connect(layers[0], layers[1]) # collect touching contacts
conn.connect(layers[1], layers[1]) # combine resistor shapes into one area
conn
end
def extract_devices(layer_geometry)
# layer_geometry provides the input layers in the order they are defined with "define_layer"
conductor = layer_geometry[0]
resistor = layer_geometry[1]
resistor_regions = resistor.merged
resistor_regions.each do |r|
terminals = conductor.interacting(resistor)
if terminals.size != 2
error("Resistor shape does not touch marker border in exactly two places", r)
else
double_width = 0
(terminals.edges & resistor.edges).merged.each do |e|
double_width += e.length
end
# A = L*W
# -> L = A/W
a = r.area*dbu*dbu
w = (double_width / 2.0)*dbu
l = a / w
device = create_device
device.set_parameter(RBA::DeviceClassResistor::PARAM_R, @sheet_rho * l / w);
device.set_parameter(RBA::DeviceClassResistor::PARAM_A, a)
device.set_parameter(RBA::DeviceClassResistor::PARAM_L, l)
device.set_parameter(RBA::DeviceClassResistor::PARAM_P, 2*l+2*w)
device.set_parameter(RBA::DeviceClassResistor::PARAM_W, w)
define_terminal(device, RBA::DeviceClassResistor::TERMINAL_A, 0, terminals[0]);
define_terminal(device, RBA::DeviceClassResistor::TERMINAL_B, 0, terminals[1]);
end
end
end
end
# tolerance/ignore
tolerance("RPP1", "W", 1e-5)
tolerance("RPP1", "L", 1e-5)
ignore_parameter("RPP1", "R")
extract_devices(ResistorExtractor::new("RPP1", 0.5), # intentionally wrong: 1565.15/5
{ "C" => p1trm, "R" => rpp1 })
connect(met1_dg, cont)
connect(p1trm, cont)
netlist.flatten_circuit("Res1")
schematic.flatten_circuit("RES1")
schematic.simplify
# Netlist vs. netlist
align
netlist.simplify
compare

193
testdata/lvs/res_combine2.lvsdb vendored Normal file
View File

@ -0,0 +1,193 @@
#%lvsdb-klayout
# Layout
layout(
top(Res2)
unit(0.001)
# Layer section
# This section lists the mask layers (drawing or derived) and their connections.
# Mask layers
layer(l4 '15/0')
layer(l3 '16/0')
layer(l1)
# Mask layer connectivity
connect(l4 l4 l3 l1)
connect(l3 l4 l3)
connect(l1 l4 l1)
# Device class section
class(RPP1 RES)
# Device abstracts section
# Device abstracts list the pin shapes of the devices.
device(D$RPP1 RPP1
terminal(A
rect(l1 (0 0) (540 2000))
)
terminal(B
rect(l1 (10540 0) (540 2000))
)
)
# Circuit section
# Circuits are the hierarchical building blocks of the netlist.
circuit(Res2
# Circuit boundary
rect((8285 720) (117975 57350))
# Nets with their geometries
net(1
rect(l4 (120580 32490) (220 220))
rect(l4 (-220 -745) (220 220))
rect(l4 (-220 -745) (220 220))
rect(l4 (-220 -750) (220 220))
rect(l4 (-22355 1390) (220 220))
rect(l4 (-220 -745) (220 220))
rect(l4 (-220 -745) (220 220))
rect(l4 (-220 -750) (220 220))
rect(l4 (-21520 1755) (220 220))
rect(l4 (-220 -745) (220 220))
rect(l4 (-220 -745) (220 220))
rect(l4 (-220 -750) (220 220))
rect(l3 (0 -4795) (1065 5850))
rect(l3 (-5155 -6930) (52985 1475))
rect(l3 (-27585 -395) (1065 5850))
rect(l3 (20990 -5850) (1065 5850))
rect(l3 (-1275 -1760) (340 1920))
rect(l3 (-22475 -1890) (340 1920))
rect(l3 (-21640 -1525) (340 1920))
rect(l1 (42935 -2385) (540 2000))
rect(l1 (-22675 -1970) (540 2000))
rect(l1 (-21840 -1605) (540 2000))
)
net(2
rect(l4 (19795 5575) (220 220))
rect(l4 (-220 -745) (220 220))
rect(l4 (-220 -745) (220 220))
rect(l4 (-220 -750) (220 220))
rect(l3 (-195 -995) (2395 2500))
rect(l3 (-2480 -1785) (340 1920))
rect(l1 (-500 -1960) (540 2000))
)
# Devices and their connections
device(1 D$RPP1
device(D$RPP1 location(30 -3970))
device(D$RPP1 location(-65 -8175))
device(D$RPP1 location(-205 -12595))
device(D$RPP1 location(-225 -16825))
device(D$RPP1 location(-320 -20985))
device(D$RPP1 location(-22135 30))
device(D$RPP1 location(-22105 -3940))
device(D$RPP1 location(-22200 -8145))
device(D$RPP1 location(-22340 -12565))
device(D$RPP1 location(-22360 -16795))
device(D$RPP1 location(-22455 -20955))
device(D$RPP1 location(-43435 425))
device(D$RPP1 location(-43405 -3545))
device(D$RPP1 location(-43500 -7750))
device(D$RPP1 location(-43640 -12170))
device(D$RPP1 location(-43660 -16400))
device(D$RPP1 location(-43755 -20560))
device(D$RPP1 location(-100755 -30885))
device(D$RPP1 location(-100850 -35090))
device(D$RPP1 location(-100990 -39510))
device(D$RPP1 location(-101010 -43740))
device(D$RPP1 location(-101105 -47900))
device(D$RPP1 location(-81920 -3545))
device(D$RPP1 location(-82015 -7750))
device(D$RPP1 location(-82155 -12170))
device(D$RPP1 location(-82175 -16400))
device(D$RPP1 location(-63835 -30780))
device(D$RPP1 location(-63930 -34985))
device(D$RPP1 location(-64070 -39405))
device(D$RPP1 location(-64090 -43635))
device(D$RPP1 location(-82380 -26810))
device(D$RPP1 location(-82270 -20560))
device(D$RPP1 location(-82350 -30780))
device(D$RPP1 location(-82445 -34985))
device(D$RPP1 location(-82585 -39405))
device(D$RPP1 location(-82605 -43635))
device(D$RPP1 location(-82700 -47795))
device(D$RPP1 location(-64185 -47795))
device(D$RPP1 location(-63435 640))
device(D$RPP1 location(-63405 -3330))
device(D$RPP1 location(-63500 -7535))
device(D$RPP1 location(-63640 -11955))
device(D$RPP1 location(-63660 -16185))
device(D$RPP1 location(-63755 -20345))
device(D$RPP1 location(-63865 -26810))
device(D$RPP1 location(-100465 855))
device(D$RPP1 location(-81950 425))
device(D$RPP1 location(-100435 -3115))
device(D$RPP1 location(-100530 -7320))
device(D$RPP1 location(-100670 -11740))
device(D$RPP1 location(-100690 -15970))
device(D$RPP1 location(-100785 -20130))
device(D$RPP1 location(-100785 -26915))
connect(5 A B)
connect(11 A B)
connect(17 A B)
connect(22 B B)
location(110140 51795)
param(R 95)
param(L 420)
param(W 2.21052631579)
param(A 1080)
param(P 1296)
terminal(A 1)
terminal(B 2)
)
)
)
# Reference netlist
reference(
# Device class section
class(RPP1 RES)
# Circuit section
# Circuits are the hierarchical building blocks of the netlist.
circuit(RES2
# Nets
net(1 name(GND))
net(2 name(VDD))
# Outgoing pins and their connections to nets
pin(1 name(GND))
pin(2 name(VDD))
# Devices and their connections
device(1 RPP1
name(I0.I106.R0)
param(R 59475.7)
param(L 420)
param(W 2.21052631579)
param(A 0)
param(P 0)
terminal(A 2)
terminal(B 1)
)
)
)
# Cross reference
xref(
circuit(Res2 RES2 match
xref(
net(1 1 warning)
net(2 2 warning)
pin(() 0 match)
pin(() 1 match)
device(1 1 match)
)
)
)

7
testdata/lvs/res_combine3.cir vendored Normal file
View File

@ -0,0 +1,7 @@
* Extracted by KLayout
* cell Res2
.SUBCKT Res2
* device instance $1 r0 *1 110.14,51.795 RPP1
R$1 1 2 95 RPP1
.ENDS Res2

91
testdata/lvs/res_combine3.lvs vendored Normal file
View File

@ -0,0 +1,91 @@
source($lvs_test_source)
report_lvs($lvs_test_target_lvsdb, true)
target_netlist($lvs_test_target_cir, write_spice, "Extracted by KLayout")
schematic("res_combine_schematic.cir")
deep
# -------------------------------------------------------------------
# Layers
pimp = input(7, 0)
poly_dg = input(13, 0)
cont = input(15, 0)
met1_dg = input(16, 0)
sblk = input(34, 0)
rp_1 = sblk & poly_dg
rpp1 = rp_1 & pimp
p1trm = poly_dg - rpp1
class ResistorExtractor < RBA::GenericDeviceExtractor
def initialize(name, sheet_rho)
self.name = name
@sheet_rho = sheet_rho
end
def setup
define_layer("C", "Conductor")
define_layer("R", "Resistor")
register_device_class(RBA::DeviceClassResistor::new)
end
def get_connectivity(layout, layers)
# this "connectivity" forms the shape clusters that make up the device
conn = RBA::Connectivity::new
conn.connect(layers[0], layers[1]) # collect touching contacts
conn.connect(layers[1], layers[1]) # combine resistor shapes into one area
conn
end
def extract_devices(layer_geometry)
# layer_geometry provides the input layers in the order they are defined with "define_layer"
conductor = layer_geometry[0]
resistor = layer_geometry[1]
resistor_regions = resistor.merged
resistor_regions.each do |r|
terminals = conductor.interacting(resistor)
if terminals.size != 2
error("Resistor shape does not touch marker border in exactly two places", r)
else
double_width = 0
(terminals.edges & resistor.edges).merged.each do |e|
double_width += e.length
end
# A = L*W
# -> L = A/W
a = r.area*dbu*dbu
w = (double_width / 2.0)*dbu
l = a / w
device = create_device
device.set_parameter(RBA::DeviceClassResistor::PARAM_R, @sheet_rho * l / w);
device.set_parameter(RBA::DeviceClassResistor::PARAM_A, a)
device.set_parameter(RBA::DeviceClassResistor::PARAM_L, l)
device.set_parameter(RBA::DeviceClassResistor::PARAM_P, 2*l+2*w)
device.set_parameter(RBA::DeviceClassResistor::PARAM_W, w)
define_terminal(device, RBA::DeviceClassResistor::TERMINAL_A, 0, terminals[0]);
define_terminal(device, RBA::DeviceClassResistor::TERMINAL_B, 0, terminals[1]);
end
end
end
end
extract_devices(ResistorExtractor::new("RPP1", 0.5), # intentionally wrong: 1565.15/5
{ "C" => p1trm, "R" => rpp1 })
connect(met1_dg, cont)
connect(p1trm, cont)
netlist.flatten_circuit("Res1")
schematic.flatten_circuit("RES1")
schematic.simplify
# Netlist vs. netlist
align
netlist.simplify
compare

196
testdata/lvs/res_combine3.lvsdb vendored Normal file
View File

@ -0,0 +1,196 @@
#%lvsdb-klayout
# Layout
layout(
top(Res2)
unit(0.001)
# Layer section
# This section lists the mask layers (drawing or derived) and their connections.
# Mask layers
layer(l4 '15/0')
layer(l3 '16/0')
layer(l1)
# Mask layer connectivity
connect(l4 l4 l3 l1)
connect(l3 l4 l3)
connect(l1 l4 l1)
# Device class section
class(RPP1 RES)
# Device abstracts section
# Device abstracts list the pin shapes of the devices.
device(D$RPP1 RPP1
terminal(A
rect(l1 (0 0) (540 2000))
)
terminal(B
rect(l1 (10540 0) (540 2000))
)
)
# Circuit section
# Circuits are the hierarchical building blocks of the netlist.
circuit(Res2
# Circuit boundary
rect((8285 720) (117975 57350))
# Nets with their geometries
net(1
rect(l4 (120580 32490) (220 220))
rect(l4 (-220 -745) (220 220))
rect(l4 (-220 -745) (220 220))
rect(l4 (-220 -750) (220 220))
rect(l4 (-22355 1390) (220 220))
rect(l4 (-220 -745) (220 220))
rect(l4 (-220 -745) (220 220))
rect(l4 (-220 -750) (220 220))
rect(l4 (-21520 1755) (220 220))
rect(l4 (-220 -745) (220 220))
rect(l4 (-220 -745) (220 220))
rect(l4 (-220 -750) (220 220))
rect(l3 (0 -4795) (1065 5850))
rect(l3 (-5155 -6930) (52985 1475))
rect(l3 (-27585 -395) (1065 5850))
rect(l3 (20990 -5850) (1065 5850))
rect(l3 (-1275 -1760) (340 1920))
rect(l3 (-22475 -1890) (340 1920))
rect(l3 (-21640 -1525) (340 1920))
rect(l1 (42935 -2385) (540 2000))
rect(l1 (-22675 -1970) (540 2000))
rect(l1 (-21840 -1605) (540 2000))
)
net(2
rect(l4 (19795 5575) (220 220))
rect(l4 (-220 -745) (220 220))
rect(l4 (-220 -745) (220 220))
rect(l4 (-220 -750) (220 220))
rect(l3 (-195 -995) (2395 2500))
rect(l3 (-2480 -1785) (340 1920))
rect(l1 (-500 -1960) (540 2000))
)
# Devices and their connections
device(1 D$RPP1
device(D$RPP1 location(30 -3970))
device(D$RPP1 location(-65 -8175))
device(D$RPP1 location(-205 -12595))
device(D$RPP1 location(-225 -16825))
device(D$RPP1 location(-320 -20985))
device(D$RPP1 location(-22135 30))
device(D$RPP1 location(-22105 -3940))
device(D$RPP1 location(-22200 -8145))
device(D$RPP1 location(-22340 -12565))
device(D$RPP1 location(-22360 -16795))
device(D$RPP1 location(-22455 -20955))
device(D$RPP1 location(-43435 425))
device(D$RPP1 location(-43405 -3545))
device(D$RPP1 location(-43500 -7750))
device(D$RPP1 location(-43640 -12170))
device(D$RPP1 location(-43660 -16400))
device(D$RPP1 location(-43755 -20560))
device(D$RPP1 location(-100755 -30885))
device(D$RPP1 location(-100850 -35090))
device(D$RPP1 location(-100990 -39510))
device(D$RPP1 location(-101010 -43740))
device(D$RPP1 location(-101105 -47900))
device(D$RPP1 location(-81920 -3545))
device(D$RPP1 location(-82015 -7750))
device(D$RPP1 location(-82155 -12170))
device(D$RPP1 location(-82175 -16400))
device(D$RPP1 location(-63835 -30780))
device(D$RPP1 location(-63930 -34985))
device(D$RPP1 location(-64070 -39405))
device(D$RPP1 location(-64090 -43635))
device(D$RPP1 location(-82380 -26810))
device(D$RPP1 location(-82270 -20560))
device(D$RPP1 location(-82350 -30780))
device(D$RPP1 location(-82445 -34985))
device(D$RPP1 location(-82585 -39405))
device(D$RPP1 location(-82605 -43635))
device(D$RPP1 location(-82700 -47795))
device(D$RPP1 location(-64185 -47795))
device(D$RPP1 location(-63435 640))
device(D$RPP1 location(-63405 -3330))
device(D$RPP1 location(-63500 -7535))
device(D$RPP1 location(-63640 -11955))
device(D$RPP1 location(-63660 -16185))
device(D$RPP1 location(-63755 -20345))
device(D$RPP1 location(-63865 -26810))
device(D$RPP1 location(-100465 855))
device(D$RPP1 location(-81950 425))
device(D$RPP1 location(-100435 -3115))
device(D$RPP1 location(-100530 -7320))
device(D$RPP1 location(-100670 -11740))
device(D$RPP1 location(-100690 -15970))
device(D$RPP1 location(-100785 -20130))
device(D$RPP1 location(-100785 -26915))
connect(5 A B)
connect(11 A B)
connect(17 A B)
connect(22 B B)
location(110140 51795)
param(R 95)
param(L 420)
param(W 2.21052631579)
param(A 1080)
param(P 1296)
terminal(A 1)
terminal(B 2)
)
)
)
# Reference netlist
reference(
# Device class section
class(RPP1 RES)
# Circuit section
# Circuits are the hierarchical building blocks of the netlist.
circuit(RES2
# Nets
net(1 name(GND))
net(2 name(VDD))
# Outgoing pins and their connections to nets
pin(1 name(GND))
pin(2 name(VDD))
# Devices and their connections
device(1 RPP1
name(I0.I106.R0)
param(R 59475.7)
param(L 420)
param(W 2.21052631579)
param(A 0)
param(P 0)
terminal(A 2)
terminal(B 1)
)
)
)
# Cross reference
xref(
circuit(Res2 RES2 nomatch
xref(
net(() 1 mismatch)
net(() 2 mismatch)
net(1 () mismatch)
net(2 () mismatch)
pin(() 0 match)
pin(() 1 match)
device(() 1 mismatch)
device(1 () mismatch)
)
)
)

31
testdata/lvs/res_combine_schematic.cir vendored Normal file
View File

@ -0,0 +1,31 @@
.SUBCKT res1 MINUS PLUS
*.PININFO MINUS:B PLUS:B
RR7 net5 net3 1565.15 RPP1 W=2u L=10u M=1
RR8 net3 net6 1565.15 RPP1 W=2u L=10u M=1
RR9 net6 net7 1565.15 RPP1 W=2u L=10u M=1
RR10 net7 MINUS 1565.15 RPP1 W=2u L=10u M=1
RR6 net4 net5 1565.15 RPP1 W=2u L=10u M=1
RR0 PLUS net4 1565.15 RPP1 W=2u L=10u M=1
.ENDS
.SUBCKT res2_ MINUS PLUS
*.PININFO MINUS:B PLUS:B
XI106 net3 PLUS res1
XI104 net7 net8 res1
XI100 net6 MINUS res1
XI105 net3 net7 res1
XI107 net3 PLUS res1
XI108 net3 PLUS res1
XI101 net9 net6 res1
XI102 net10 net9 res1
XI103 net8 net10 res1
.ENDS
.SUBCKT Res2 gnd vdd
*.PININFO gnd:B vdd:B
XI0 gnd vdd res2_
.ENDS