Corrected the MOSFET generated cell drawing routine in magic for
sky130 so that unchecking the "top gate contact" and "bottom gate
contact" options works in the case of a narrow gate for which the
drawing routine uses alternating contacts.  Previously, unchecking
these options would have no effect on the drawn layout.
diff --git a/VERSION b/VERSION
index 2248e45..5726fec 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.0.506
+1.0.507
diff --git a/sky130/magic/sky130.tcl b/sky130/magic/sky130.tcl
index 64b689d..30aa321 100644
--- a/sky130/magic/sky130.tcl
+++ b/sky130/magic/sky130.tcl
@@ -6446,6 +6446,11 @@
         set $key [dict get $parameters $key]
     }
 
+    # "topc" and "botc" may be modified for alternating top-bottom gate
+    # contacts.  If so, original values are in "oldtopc" and "oldbotc".
+    if {![dict exists $parameters oldtopc]} {set oldtopc $topc}
+    if {![dict exists $parameters oldbotc]} {set oldbotc $botc}
+
     # Draw the diffusion and poly
     pushbox
     box size 0 0
@@ -6680,7 +6685,7 @@
 	popbox
     }
     # Top poly contact
-    if {$topc} {
+    if {$topc && $oldtopc} {
        pushbox
        box move n ${hw}um
        box move n ${gate_to_polycont}um
@@ -6718,7 +6723,7 @@
        popbox
     }
     # Bottom poly contact
-    if {$botc} {
+    if {$botc && $oldbotc} {
        pushbox
        box move s ${hw}um
        box move s ${gate_to_polycont}um
@@ -6852,6 +6857,8 @@
     if {$nf > 1 && $l < $min_allc} {
 	set intc 1
 	set evenodd 1
+	dict set parameters oldtopc $topc
+	dict set parameters oldbotc $botc
 	set topc 1
 	set botc 1
 	dict set parameters topc 1