Updating devices connections for ULL
diff --git a/ULL/klayout/lvs/gf180ull.lvs b/ULL/klayout/lvs/gf180ull.lvs
index 341633b..8612fd2 100644
--- a/ULL/klayout/lvs/gf180ull.lvs
+++ b/ULL/klayout/lvs/gf180ull.lvs
@@ -260,12 +260,6 @@
 # %include 'rule_decks/mos_derivations.lvs'
 
 #================================
-# ------ RES DERIVATIONS --------
-#================================
-
-# %include 'rule_decks/res_derivations.lvs'
-
-#================================
 # ------ DIODE DERIVATIONS --------
 #================================
 
@@ -314,12 +308,6 @@
 # %include 'rule_decks/mos_extraction.lvs'
 
 #================================
-# ------- RES EXTRACTION --------
-#================================
-
-# %include 'rule_decks/res_extraction.lvs'
-
-#================================
 # ------- Diode EXTRACTION ------
 #================================
 
diff --git a/ULL/klayout/lvs/rule_decks/bjt_connection.lvs b/ULL/klayout/lvs/rule_decks/bjt_connection.lvs
new file mode 100644
index 0000000..d0a894f
--- /dev/null
+++ b/ULL/klayout/lvs/rule_decks/bjt_connection.lvs
@@ -0,0 +1,98 @@
+################################################################################################
+# Copyright 2022 GlobalFoundries PDK Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+################################################################################################
+
+#================================
+# ------ BJT CONNECTIONS --------
+#================================
+logger.info('Starting LVS BJT CONNECTIONS')
+
+# ========================================
+# ---- VNPN (isolated collector) (5V) ----
+# ========================================
+
+# vnpn_5x5 nodes connections
+connect(npn_05p00x05p00_e, contact)
+connect(npn_05p00x05p00_b, contact)
+connect(npn_05p00x05p00_c, contact)
+
+# vnpn_0p54x16 nodes connections
+connect(npn_00p54x16p00_e, contact)
+connect(npn_00p54x16p00_b, contact)
+connect(npn_00p54x16p00_c, contact)
+
+# vnpn_0p54x8 nodes connections
+connect(npn_00p54x08p00_e, contact)
+connect(npn_00p54x08p00_b, contact)
+connect(npn_00p54x08p00_c, contact)
+
+# vnpn_0p54x2 nodes connections
+connect(npn_00p54x02p00_e, contact)
+connect(npn_00p54x02p00_b, contact)
+connect(npn_00p54x02p00_c, contact)
+
+# ===========================================
+# ---- VNPN (isolated collector) (3.3V) ----
+# ===========================================
+
+# vnpn_5x5_3p3 nodes connections
+connect(npn_05p00x05p00_e_3p3, contact)
+connect(npn_05p00x05p00_b_3p3, contact)
+connect(npn_05p00x05p00_c_3p3, contact)
+
+# vnpn_0p54x16_3p3 nodes connections
+connect(npn_00p54x16p00_e_3p3, contact)
+connect(npn_00p54x16p00_b_3p3, contact)
+connect(npn_00p54x16p00_c_3p3, contact)
+
+# vnpn_0p54x8_3p3 nodes connections
+connect(npn_00p54x08p00_e_3p3, contact)
+connect(npn_00p54x08p00_b_3p3, contact)
+connect(npn_00p54x08p00_c_3p3, contact)
+
+# vnpn_0p54x2_3p3 nodes connections
+connect(npn_00p54x02p00_e_3p3, contact)
+connect(npn_00p54x02p00_b_3p3, contact)
+connect(npn_00p54x02p00_c_3p3, contact)
+
+
+# ========================================
+# ---- VPNP (Psub as collector) (6V) ----
+# ========================================
+
+# vpnp_6p0_10x10 nodes connections
+connect(pnp_10p00x10p00_e, contact)
+connect(pnp_10p00x10p00_b, contact)
+connect(pnp_10p00x10p00_c, contact)
+
+# vpnp_6p0_5x5 nodes connections
+connect(pnp_05p00x05p00_e, contact)
+connect(pnp_05p00x05p00_b, contact)
+connect(pnp_05p00x05p00_c, contact)
+
+# vpnp_6p0_0p42x20 nodes connections
+connect(pnp_00p42x20p00_e, contact)
+connect(pnp_00p42x20p00_b, contact)
+connect(pnp_00p42x20p00_c, contact)
+
+# vpnp_6p0_0p42x10 nodes connections
+connect(pnp_00p42x10p00_e, contact)
+connect(pnp_00p42x10p00_b, contact)
+connect(pnp_00p42x10p00_c, contact)
+
+# vpnp_6p0_0p42x5 nodes connections
+connect(pnp_00p42x05p00_e, contact)
+connect(pnp_00p42x05p00_b, contact)
+connect(pnp_00p42x05p00_c, contact)
\ No newline at end of file
diff --git a/ULL/klayout/lvs/rule_decks/devices_connections.lvs b/ULL/klayout/lvs/rule_decks/devices_connections.lvs
index a0d119c..8910d83 100644
--- a/ULL/klayout/lvs/rule_decks/devices_connections.lvs
+++ b/ULL/klayout/lvs/rule_decks/devices_connections.lvs
@@ -90,172 +90,23 @@
 #================================
 # ----- MOSFET CONNECTIONS ------
 #================================
-logger.info('Starting LVS MOSFET CONNECTIONS')
 
-connect(psd_dw, contact)
-
+# %include mos_connection.lvs
 
 #================================
 # ------ BJT CONNECTIONS --------
 #================================
-logger.info('Starting LVS BJT CONNECTIONS')
 
-# ========================================
-# ---- VNPN (isolated collector) (5V) ----
-# ========================================
-
-# vnpn_5x5 nodes connections
-connect(npn_05p00x05p00_e, contact)
-connect(npn_05p00x05p00_b, contact)
-connect(npn_05p00x05p00_c, contact)
-
-# vnpn_0p54x16 nodes connections
-connect(npn_00p54x16p00_e, contact)
-connect(npn_00p54x16p00_b, contact)
-connect(npn_00p54x16p00_c, contact)
-
-# vnpn_0p54x8 nodes connections
-connect(npn_00p54x08p00_e, contact)
-connect(npn_00p54x08p00_b, contact)
-connect(npn_00p54x08p00_c, contact)
-
-# vnpn_0p54x2 nodes connections
-connect(npn_00p54x02p00_e, contact)
-connect(npn_00p54x02p00_b, contact)
-connect(npn_00p54x02p00_c, contact)
-
-# ===========================================
-# ---- VNPN (isolated collector) (3.3V) ----
-# ===========================================
-
-# vnpn_5x5_3p3 nodes connections
-connect(npn_05p00x05p00_e_3p3, contact)
-connect(npn_05p00x05p00_b_3p3, contact)
-connect(npn_05p00x05p00_c_3p3, contact)
-
-# vnpn_0p54x16_3p3 nodes connections
-connect(npn_00p54x16p00_e_3p3, contact)
-connect(npn_00p54x16p00_b_3p3, contact)
-connect(npn_00p54x16p00_c_3p3, contact)
-
-# vnpn_0p54x8_3p3 nodes connections
-connect(npn_00p54x08p00_e_3p3, contact)
-connect(npn_00p54x08p00_b_3p3, contact)
-connect(npn_00p54x08p00_c_3p3, contact)
-
-# vnpn_0p54x2_3p3 nodes connections
-connect(npn_00p54x02p00_e_3p3, contact)
-connect(npn_00p54x02p00_b_3p3, contact)
-connect(npn_00p54x02p00_c_3p3, contact)
-
-
-# ========================================
-# ---- VPNP (Psub as collector) (6V) ----
-# ========================================
-
-# vpnp_6p0_10x10 nodes connections
-connect(pnp_10p00x10p00_e, contact)
-connect(pnp_10p00x10p00_b, contact)
-connect(pnp_10p00x10p00_c, contact)
-
-# vpnp_6p0_5x5 nodes connections
-connect(pnp_05p00x05p00_e, contact)
-connect(pnp_05p00x05p00_b, contact)
-connect(pnp_05p00x05p00_c, contact)
-
-# vpnp_6p0_0p42x20 nodes connections
-connect(pnp_00p42x20p00_e, contact)
-connect(pnp_00p42x20p00_b, contact)
-connect(pnp_00p42x20p00_c, contact)
-
-# vpnp_6p0_0p42x10 nodes connections
-connect(pnp_00p42x10p00_e, contact)
-connect(pnp_00p42x10p00_b, contact)
-connect(pnp_00p42x10p00_c, contact)
-
-# vpnp_6p0_0p42x5 nodes connections
-connect(pnp_00p42x05p00_e, contact)
-connect(pnp_00p42x05p00_b, contact)
-connect(pnp_00p42x05p00_c, contact)
-
+# %include bjt_connection.lvs
 
 #================================
 # ----- DIODE CONNECTIONS -------
 #================================
 
-logger.info('Starting LVS DIODE CONNECTIONS')
-
-#================================
-# ---- LV DIODE DERIVATIONS ----
-#================================
-
-# diode_np_1p8 
-connect(diode_np_1p8_terminal_n, contact)
-
-# diode_np_1p8_dw
-connect(diode_np_1p8_dw_terminal_n, contact)
-
-# diode_pn_1p8
-connect(diode_pn_1p8_terminal_p, contact)
-
-# diode_pn_1p8_dw
-connect(diode_pn_1p8_dw_terminal_p, contact)
-
-#================================
-# ---- MV DIODE DERIVATIONS ----
-#================================
-
-# diode_np_3p3
-connect(diode_np_3p3_terminal_n, contact)
-
-# diode_pn_3p3
-connect(diode_pn_3p3_terminal_p, contact)
-
-# diode_np_3p3_dw
-connect(diode_np_3p3_dw_terminal_n, contact)
-
-# diode_pn_3p3_dw
-connect(diode_pn_3p3_dw_terminal_p, contact)
-
-# diode_np_6p0
-connect(diode_np_6p0_terminal_n, contact)
-
-# diode_pn_6p0
-connect(diode_pn_6p0_terminal_p, contact)
-
-# diode_np_6p0_dw
-connect(diode_np_6p0_dw_terminal_n, contact)
-
-# diode_pn_6p0_dw
-connect(diode_pn_6p0_dw_terminal_p, contact)
-
-# diode_nwp_6p0
-connect(diode_nwp_6p0_terminal_n, nwell)
-connect(diode_nwp_6p0_terminal_p, contact)
-
-# diode_dnwpw
-connect(diode_dnwpw_terminal_p, contact)
-
-# diode_dnwps
-connect(diode_dnwps_terminal_p, contact)
-
-
-
-#================================
-# ---- RESISTOR CONNECTIONS -----
-#================================
-
-logger.info('Starting LVS RESISTOR CONNECTIONS')
-
-connect(nplus_cont, contact)
-connect(pplus_cont, contact)
-connect(pplus_dw_cont, contact)
+# %include diode_connection.lvs
 
 #================================
 # ---- Varactor CONNECTIONS -----
 #================================
 
-connect(pn_varactor_1p8_tp ,contact)
-connect(pn_varactor_1p8_dw_tp ,contact)
-connect(pn_varactor_6p0_tp ,contact)
-connect(pn_varactor_6p0_dw_tp ,contact)
\ No newline at end of file
+# %include varactor_connection.lvs
\ No newline at end of file
diff --git a/ULL/klayout/lvs/rule_decks/diode_connection.lvs b/ULL/klayout/lvs/rule_decks/diode_connection.lvs
new file mode 100644
index 0000000..a8c8769
--- /dev/null
+++ b/ULL/klayout/lvs/rule_decks/diode_connection.lvs
@@ -0,0 +1,75 @@
+################################################################################################
+# Copyright 2022 GlobalFoundries PDK Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+################################################################################################
+
+#================================
+# ----- DIODE CONNECTIONS -------
+#================================
+
+logger.info('Starting LVS DIODE CONNECTIONS')
+
+#================================
+# ---- LV DIODE DERIVATIONS ----
+#================================
+
+# diode_np_1p8 
+connect(diode_np_1p8_terminal_n, contact)
+
+# diode_np_1p8_dw
+connect(diode_np_1p8_dw_terminal_n, contact)
+
+# diode_pn_1p8
+connect(diode_pn_1p8_terminal_p, contact)
+
+# diode_pn_1p8_dw
+connect(diode_pn_1p8_dw_terminal_p, contact)
+
+#================================
+# ---- MV DIODE DERIVATIONS ----
+#================================
+
+# diode_np_3p3
+connect(diode_np_3p3_terminal_n, contact)
+
+# diode_pn_3p3
+connect(diode_pn_3p3_terminal_p, contact)
+
+# diode_np_3p3_dw
+connect(diode_np_3p3_dw_terminal_n, contact)
+
+# diode_pn_3p3_dw
+connect(diode_pn_3p3_dw_terminal_p, contact)
+
+# diode_np_6p0
+connect(diode_np_6p0_terminal_n, contact)
+
+# diode_pn_6p0
+connect(diode_pn_6p0_terminal_p, contact)
+
+# diode_np_6p0_dw
+connect(diode_np_6p0_dw_terminal_n, contact)
+
+# diode_pn_6p0_dw
+connect(diode_pn_6p0_dw_terminal_p, contact)
+
+# diode_nwp_6p0
+connect(diode_nwp_6p0_terminal_n, nwell)
+connect(diode_nwp_6p0_terminal_p, contact)
+
+# diode_dnwpw
+connect(diode_dnwpw_terminal_p, contact)
+
+# diode_dnwps
+connect(diode_dnwps_terminal_p, contact)
\ No newline at end of file
diff --git a/ULL/klayout/lvs/rule_decks/general_derivations.lvs b/ULL/klayout/lvs/rule_decks/general_derivations.lvs
index 8e1dabe..70ecfbd 100644
--- a/ULL/klayout/lvs/rule_decks/general_derivations.lvs
+++ b/ULL/klayout/lvs/rule_decks/general_derivations.lvs
@@ -41,3 +41,16 @@
 nwell_con       = nwell.not(res_mk)
 lvpwell_con     = lvpwell.not(res_mk)
 poly2_con       = poly2.not(res_mk)
+
+
+# metal layers derivation 
+metal2_ncap     = metal2.not(cap_mk)
+
+if METAL_LEVEL != '2LM'
+    metal3_ncap = metal3.not(cap_mk)
+
+    if METAL_LEVEL != '3LM'
+      metal4_ncap = metal4.not(cap_mk)
+      metal5_ncap = metal5.not(cap_mk) if METAL_LEVEL != '4LM'
+    end  
+end
\ No newline at end of file
diff --git a/ULL/klayout/lvs/rule_decks/mos_connection.lvs b/ULL/klayout/lvs/rule_decks/mos_connection.lvs
new file mode 100644
index 0000000..862cda2
--- /dev/null
+++ b/ULL/klayout/lvs/rule_decks/mos_connection.lvs
@@ -0,0 +1,22 @@
+################################################################################################
+# Copyright 2022 GlobalFoundries PDK Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+################################################################################################
+
+#================================
+# ----- MOSFET CONNECTIONS ------
+#================================
+logger.info('Starting LVS MOSFET CONNECTIONS')
+
+connect(psd_dw, contact)
\ No newline at end of file
diff --git a/ULL/klayout/lvs/rule_decks/res_connection.lvs b/ULL/klayout/lvs/rule_decks/res_connection.lvs
new file mode 100644
index 0000000..8f716d5
--- /dev/null
+++ b/ULL/klayout/lvs/rule_decks/res_connection.lvs
@@ -0,0 +1,25 @@
+################################################################################################
+# Copyright 2022 GlobalFoundries PDK Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+################################################################################################
+
+#================================
+# ---- RESISTOR CONNECTIONS -----
+#================================
+
+logger.info('Starting LVS RESISTOR CONNECTIONS')
+
+connect(nplus_cont, contact)
+connect(pplus_cont, contact)
+connect(pplus_dw_cont, contact)
\ No newline at end of file
diff --git a/ULL/klayout/lvs/rule_decks/varactor_connection.lvs b/ULL/klayout/lvs/rule_decks/varactor_connection.lvs
new file mode 100644
index 0000000..68f3f08
--- /dev/null
+++ b/ULL/klayout/lvs/rule_decks/varactor_connection.lvs
@@ -0,0 +1,24 @@
+################################################################################################
+# Copyright 2022 GlobalFoundries PDK Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+################################################################################################
+
+#================================
+# ---- Varactor CONNECTIONS -----
+#================================
+
+connect(pn_varactor_1p8_tp ,contact)
+connect(pn_varactor_1p8_dw_tp ,contact)
+connect(pn_varactor_6p0_tp ,contact)
+connect(pn_varactor_6p0_dw_tp ,contact)
\ No newline at end of file