added and wired floating gate
diff --git a/mag/user_analog_project_wrapper.mag b/mag/user_analog_project_wrapper.mag
index 28a8fc4..25451f5 100644
--- a/mag/user_analog_project_wrapper.mag
+++ b/mag/user_analog_project_wrapper.mag
@@ -1,7 +1,7 @@
 magic
 tech sky130B
 magscale 1 2
-timestamp 1647539797
+timestamp 1647621433
 << nwell >>
 rect 208506 659508 209222 659758
 rect 212242 659754 212610 659980
@@ -164,10 +164,29 @@
 rect 216304 681540 216308 682286
 rect 216120 680764 216308 681540
 rect 216120 680580 216310 680764
+rect 51438 666500 51708 666507
+rect 51438 666332 51446 666500
+rect 51700 666332 51708 666500
+rect 43033 663602 50280 663611
+rect 43033 663434 43042 663602
+rect 43190 663434 50280 663602
+rect 43033 663425 50280 663434
+rect 50094 661154 50280 663425
+rect 51438 661176 51708 666332
 rect 216126 666238 216310 680580
 rect 216126 665216 216312 666238
+rect 53452 663594 56384 663602
+rect 53452 663434 56256 663594
+rect 56376 663434 56384 663594
+rect 53452 663426 56384 663434
+rect 51830 661200 52004 661224
+rect 53452 661220 53628 663426
 rect 216128 662754 216312 665216
 rect 216128 662068 216314 662754
+rect 51830 661166 51858 661200
+rect 51976 661166 52004 661200
+rect 51830 660998 52004 661166
+rect 51839 657600 52002 660998
 rect 212270 659920 212576 659944
 rect 212270 659828 212344 659920
 rect 212522 659828 212576 659920
@@ -213,6 +232,9 @@
 rect 213982 658982 213994 659056
 rect 213890 658976 213994 658982
 rect 212290 658864 212696 658960
+rect 51839 657502 51858 657600
+rect 51982 657502 52002 657600
+rect 51839 657487 52002 657502
 rect 216120 642588 216298 659124
 rect 218946 659012 219312 659050
 rect 218946 658958 219014 659012
@@ -228,7 +250,11 @@
 rect 326572 684652 326878 684824
 rect 224872 683618 225178 683790
 rect 216126 681540 216304 682286
+rect 51446 666332 51700 666500
+rect 43042 663434 43190 663602
+rect 56256 663434 56376 663594
 rect 213902 658982 213982 659056
+rect 51858 657502 51982 657600
 rect 216126 641864 216292 642588
 << metal2 >>
 rect 512622 703358 513362 703376
@@ -331,7 +357,23 @@
 rect 172762 681190 217496 681240
 rect 122318 680910 217316 680994
 rect 122318 680908 123058 680910
+rect 51436 666500 51710 666510
+rect 51436 666332 51446 666500
+rect 51700 666332 51710 666500
+rect 51436 666322 51710 666332
+rect 43032 663602 43200 663612
+rect 43032 663434 43042 663602
+rect 43190 663434 43200 663602
+rect 43032 663424 43200 663434
+rect 56246 663594 56386 663604
+rect 56246 663434 56256 663594
+rect 56376 663434 56386 663594
+rect 56246 663424 56386 663434
 rect 213548 659820 213986 659884
+rect 51838 657602 52004 657616
+rect 51838 657502 51856 657602
+rect 51982 657502 52004 657602
+rect 51838 657486 52004 657502
 rect 4346 511652 4478 511670
 rect 213548 511652 213616 659820
 rect 340 511642 213616 511652
@@ -889,6 +931,12 @@
 rect 568942 702550 569254 702900
 rect 512642 686570 513342 687270
 rect 512642 684870 513342 685570
+rect 51446 666332 51700 666500
+rect 43042 663434 43190 663602
+rect 56256 663434 56376 663594
+rect 51856 657600 51982 657602
+rect 51856 657502 51858 657600
+rect 51858 657502 51982 657600
 rect 340 511530 480 511642
 rect 582730 681176 583036 681526
 rect 223537 646293 223646 646394
@@ -899,8 +947,10 @@
 rect 583534 583576 583636 583660
 rect 360 468320 462 468404
 << metal3 >>
-rect 16194 702300 21194 704800
-rect 68194 702300 73194 704800
+rect 16194 704789 21194 704800
+rect 16193 702300 21194 704789
+rect 68194 704458 73194 704800
+rect 68194 702300 73195 704458
 rect 120194 703270 125194 704800
 rect 120194 702570 122338 703270
 rect 123038 702570 125194 703270
@@ -937,6 +987,9 @@
 rect 566594 702550 568942 702900
 rect 569254 702550 571594 702900
 rect 566594 702300 571594 702550
+rect 16193 695290 21193 702300
+rect 16193 690290 54418 695290
+rect 68196 695160 73195 702300
 rect 165596 701002 170590 702300
 rect 175896 701002 180890 702300
 rect 165556 699814 180890 701002
@@ -956,11 +1009,21 @@
 rect 318994 697884 326344 698474
 rect 327056 697884 334288 698474
 rect 318994 697340 334288 697884
+rect -800 680242 44130 685242
+rect 39130 663602 44130 680242
+rect 49418 666500 54418 690290
+rect 49418 666332 51446 666500
+rect 51700 666332 54418 666500
+rect 49418 665316 54418 666332
+rect 56069 690161 73195 695160
+rect 39130 663434 43042 663602
+rect 43190 663434 44130 663602
+rect 39130 660904 44130 663434
+rect 56069 663594 61068 690161
 rect 512620 687270 513364 687278
 rect 512620 686570 512642 687270
 rect 513342 686570 513364 687270
 rect 512620 685570 513364 686570
-rect -800 680242 1700 685242
 rect 512620 684870 512642 685570
 rect 513342 684870 513364 685570
 rect 512620 684846 513364 684870
@@ -968,11 +1031,19 @@
 rect 582300 681176 582730 681526
 rect 583036 681176 584800 681526
 rect 582300 677984 584800 681176
+rect 56069 663434 56256 663594
+rect 56376 663434 61068 663594
+rect 56069 662793 61068 663434
+rect 49246 657602 54048 658227
+rect 49246 657502 51856 657602
+rect 51982 657502 54048 657602
 rect -800 643842 1660 648642
+rect -800 633842 1660 638642
+rect -800 564240 1660 564242
+rect 49246 564240 54048 657502
 rect 223525 646394 223657 646406
 rect 223525 646293 223537 646394
 rect 223646 646293 223657 646394
-rect -800 633842 1660 638642
 rect 223525 638402 223657 646293
 rect 582332 642580 584800 644584
 rect 582332 641880 582542 642580
@@ -997,7 +1068,9 @@
 rect 583520 583576 583534 583660
 rect 583636 583576 584800 583660
 rect 583520 583562 584800 583576
-rect -800 559442 1660 564242
+rect -800 559445 54048 564240
+rect -800 559442 1660 559445
+rect 49246 559441 54048 559445
 rect -800 549442 1660 554242
 rect 582340 550562 584800 555362
 rect 582340 540562 584800 545362
@@ -1174,18 +1247,22 @@
 rect -100 0 0 704000
 rect 584000 0 584100 704000
 rect -100 -100 584100 0
-use 1T1R_2x2  1T1R_2x2_0
-timestamp 1647533459
-transform 1 0 562058 0 1 685450
-box 0 0 864 800
-use sky130_sc_ams__comparator_1  sky130_sc_ams__comparator_1_1
-timestamp 1647467084
-transform 1 0 216584 0 1 659172
-box -38 -48 4914 592
+use FG_pfet  FG_pfet_0
+timestamp 1647621433
+transform 1 0 52313 0 1 660624
+box -2563 -40 1390 600
 use sky130_sc_ams__ota_1  sky130_sc_ams__ota_1_1
 timestamp 1647538073
 transform 1 0 209108 0 1 659172
 box -38 -48 6754 592
+use sky130_sc_ams__comparator_1  sky130_sc_ams__comparator_1_1
+timestamp 1647467084
+transform 1 0 216584 0 1 659172
+box -38 -48 4914 592
+use 1T1R_2x2  1T1R_2x2_0
+timestamp 1647533459
+transform 1 0 562058 0 1 685450
+box 0 0 864 800
 << labels >>
 flabel metal3 s 582300 677984 584800 682984 0 FreeSans 1120 0 0 0 io_analog[0]
 port 36 nsew signal bidirectional
diff --git a/xschem/FG_pfet.sch b/xschem/FG_pfet.sch
new file mode 100644
index 0000000..8918739
--- /dev/null
+++ b/xschem/FG_pfet.sch
@@ -0,0 +1,56 @@
+v {xschem version=2.9.9 file_version=1.2 }
+G {}
+K {}
+V {}
+S {}
+E {}
+N 130 -40 150 -40 { lab=vd}
+N 150 -90 150 -40 { lab=vd}
+N 130 -90 150 -90 { lab=vd}
+N 130 -90 130 -70 { lab=vd}
+N 130 -10 130 20 { lab=vsource}
+N -20 -40 90 -40 { lab=#net1}
+N 30 -100 30 -40 { lab=#net1}
+N 0 -170 -0 -140 { lab=vtun}
+N -0 -170 30 -170 { lab=vtun}
+N 30 -170 30 -140 { lab=vtun}
+N 60 -170 60 -140 { lab=vtun}
+N 30 -170 60 -170 { lab=vtun}
+N 30 -200 30 -170 { lab=vtun}
+N -80 -70 -60 -70 { lab=vin}
+N -80 -70 -80 -40 { lab=vin}
+N -80 -40 -60 -40 { lab=vin}
+N -80 -10 -60 -10 { lab=vin}
+N -80 -40 -80 -10 { lab=vin}
+C {sky130_fd_pr/pfet_g5v0d10v5.sym} 110 -40 0 0 {name=M1
+L=0.5
+W=2
+nf=1 mult=1
+model=pfet_g5v0d10v5
+spiceprefix=X
+}
+C {sky130_fd_pr/pfet_g5v0d10v5.sym} 30 -120 3 0 {name=M2
+L=0.5
+W=1
+nf=1 mult=1
+model=pfet_g5v0d10v5
+spiceprefix=X
+}
+C {sky130_fd_pr/pfet_g5v0d10v5.sym} -40 -40 2 0 {name=M3
+L=3
+W=2
+nf=1 mult=1
+model=pfet_g5v0d10v5
+spiceprefix=X
+}
+C {devices/lab_pin.sym} 130 -90 0 0 {name=l1 sig_type=std_logic lab=vd}
+C {devices/lab_pin.sym} 30 -200 0 0 {name=l2 sig_type=std_logic lab=vtun}
+C {devices/lab_pin.sym} -80 -50 0 0 {name=l3 sig_type=std_logic lab=vin}
+C {devices/lab_pin.sym} 130 20 0 0 {name=l4 sig_type=std_logic lab=vsource}
+C {devices/iopin.sym} -240 -140 0 0 {name=p1 lab=vtun
+}
+C {devices/iopin.sym} -240 -110 0 0 {name=p2 lab=vin
+}
+C {devices/iopin.sym} -240 -80 0 0 {name=p3 lab=vsource
+}
+C {devices/iopin.sym} -240 -60 0 0 {name=p4 lab=vd}
diff --git a/xschem/FG_pfet.sym b/xschem/FG_pfet.sym
new file mode 100644
index 0000000..ceb1862
--- /dev/null
+++ b/xschem/FG_pfet.sym
@@ -0,0 +1,37 @@
+v {xschem version=2.9.9 file_version=1.2 }
+G {}
+K {type=subcircuit
+format="@name @pinlist @symname"
+template="name=x1"
+}
+V {}
+S {}
+E {}
+L 4 -70 -30 -70 0 {}
+L 4 -60 -30 -60 -0 {}
+L 4 -60 -30 -40 -30 {}
+L 4 -60 0 -40 0 {}
+L 4 -40 -60 -40 -30 {}
+L 4 -40 0 -40 30 {}
+L 4 -110 -20 -70 -20 {}
+L 4 -110 -30 -110 -10 {}
+L 4 -120 -30 -120 -10 {}
+L 4 -90 -40 -90 -20 {}
+L 4 -100 -40 -80 -40 {}
+L 4 -100 -50 -80 -50 {}
+L 4 -90 -70 -90 -50 {}
+L 4 -130 -20 -120 -20 {}
+L 7 -90 -70 -70 -70 {}
+L 7 -150 -20 -130 -20 {}
+L 7 -40 -60 -20 -60 {}
+L 7 -40 30 -20 30 {}
+B 5 -72.5 -72.5 -67.5 -67.5 {name=vtun dir=inout }
+B 5 -152.5 -22.5 -147.5 -17.5 {name=vin dir=inout }
+B 5 -22.5 -62.5 -17.5 -57.5 {name=vsource dir=inout }
+B 5 -22.5 27.5 -17.5 32.5 {name=vd dir=inout }
+T {@symname} -39.5 -6 0 0 0.3 0.3 {}
+T {@name} -35 -22 0 0 0.2 0.2 {}
+T {vtun} -95 -74 0 1 0.2 0.2 {}
+T {vin} -175 -24 2 1 0.2 0.2 {}
+T {vsource} -25 -74 0 1 0.2 0.2 {}
+T {vd} -45 26 0 1 0.2 0.2 {}
diff --git a/xschem/sky130_fd_pr/pfet_g5v0d10v5.sym b/xschem/sky130_fd_pr/pfet_g5v0d10v5.sym
new file mode 100644
index 0000000..d9327bb
--- /dev/null
+++ b/xschem/sky130_fd_pr/pfet_g5v0d10v5.sym
@@ -0,0 +1,62 @@
+v {xschem version=3.0.0 file_version=1.2 
+
+* Copyright 2021 Stefan Frederik Schippers
+* 
+* 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.
+
+}
+G {}
+K {type=pmos
+format="@spiceprefix@name @pinlist sky130_fd_pr__@model L=@L W=@W
++ nf=@nf ad=@ad as=@as pd=@pd ps=@ps
++ nrd=@nrd nrs=@nrs sa=@sa sb=@sb sd=@sd 
++ mult=@mult m=@mult"
+template="name=M1
+L=0.5
+W=1
+nf=1
+mult=1
+ad=\\"'int((nf+1)/2) * W/nf * 0.29'\\" 
+pd=\\"'2*int((nf+1)/2) * (W/nf + 0.29)'\\"
+as=\\"'int((nf+2)/2) * W/nf * 0.29'\\" 
+ps=\\"'2*int((nf+2)/2) * (W/nf + 0.29)'\\"
+nrd=\\"'0.29 / W'\\" nrs=\\"'0.29 / W'\\"
+sa=0 sb=0 sd=0
+model=pfet_g5v0d10v5
+spiceprefix=X
+"}
+V {}
+S {}
+E {}
+L 4 20 -30 20 -17.5 {}
+L 4 20 17.5 20 30 {}
+L 4 7.5 17.5 20 17.5 {}
+L 4 12.5 -17.5 20 -17.5 {}
+L 4 -20 0 -12.5 0 {}
+L 4 7.5 -22.5 7.5 22.5 {}
+B 5 17.5 27.5 22.5 32.5 {name=D dir=inout}
+B 5 -22.5 -2.5 -17.5 2.5 {name=G dir=in}
+B 5 17.5 -32.5 22.5 -27.5 {name=S dir=inout}
+B 5 19.921875 -0.078125 20.078125 0.078125 {name=B dir=in}
+A 4 -7.5 0 5 180 360 {}
+P 4 4 12.5 -20 7.5 -17.5 12.5 -15 12.5 -20 {fill=true}
+P 4 5 -2.5 15 -2.5 -15 2.5 -15 2.5 15 -2.5 15 {}
+P 5 4 15 -2.5 20 0 15 2.5 15 -2.5 {fill=true}
+T {@name} 5 -30 0 1 0.2 0.2 {}
+T {D} 22.5 17.5 0 0 0.15 0.15 {layer=7}
+T {S} 22.5 -17.5 2 1 0.15 0.15 {layer=7}
+T {B} 20 -10 0 0 0.15 0.15 {layer=7}
+T {G} -11.875 -10 0 1 0.15 0.15 {layer=7}
+T {@model} 30 -8.75 2 1 0.2 0.2 {}
+T {@mult x @W / @L} 31.25 13.75 0 0 0.2 0.2 { layer=13}
+T {nf=@nf} 31.25 1.25 0 0 0.2 0.2 { layer=13}
diff --git a/xschem/sky130_tests/top.sch b/xschem/sky130_tests/top.sch
new file mode 100644
index 0000000..32106f3
--- /dev/null
+++ b/xschem/sky130_tests/top.sch
@@ -0,0 +1,7 @@
+v {xschem version=3.0.0 file_version=1.2 }
+G {}
+K {}
+V {}
+S {}
+E {}
+C {user_analog_project_wrapper.sym} -10 10 0 0 {name=x1}
diff --git a/xschem/user_analog_project_wrapper.sch b/xschem/user_analog_project_wrapper.sch
index 97c4382..cb3dda8 100644
--- a/xschem/user_analog_project_wrapper.sch
+++ b/xschem/user_analog_project_wrapper.sch
@@ -65,6 +65,10 @@
 lab=gpio_analog[7]}
 N 120 -320 210 -320 {
 lab=gpio_analog[8]}
+N -430 -1030 -380 -1030 { lab=vssa2}
+N -430 -940 -380 -940 { lab=io_analog[9]}
+N -610 -990 -560 -990 { lab=io_analog[8]}
+N -480 -1080 -480 -1040 { lab=io_analog[9]}
 C {devices/lab_pin.sym} -430 -540 2 0 {name=l1 lab=io_analog[1]}
 C {devices/lab_pin.sym} -510 -540 0 0 {name=l2 lab=io_analog[0]}
 C {devices/lab_pin.sym} -580 -380 0 0 {name=l3 lab=io_analog[4]}
@@ -126,3 +130,8 @@
 }
 C {devices/lab_pin.sym} 120 -320 0 0 {name=l18 sig_type=std_logic lab=gpio_analog[8]
 }
+C {FG_pfet.sym} -410 -970 0 0 {name=x4}
+C {devices/lab_pin.sym} -380 -1030 2 0 {name=l19 lab=vssa2}
+C {devices/lab_pin.sym} -380 -940 2 0 {name=l20 lab=io_analog[9]}
+C {devices/lab_pin.sym} -610 -990 0 0 {name=l21 lab=io_analog[8]}
+C {devices/lab_pin.sym} -480 -1080 1 0 {name=l22 lab=io_analog[10]}