Add files via upload
diff --git a/utils/MAGIC.txt b/utils/MAGIC.txt
new file mode 100644
index 0000000..78b4d56
--- /dev/null
+++ b/utils/MAGIC.txt
@@ -0,0 +1,31 @@
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+#
+# SPDX-License-Identifier: Apache-2.0
+
+####
+
+1) You must set the PDK_ROOT variable
+
+export PDK_ROOT=~/foss/pdks/open_pdks/sky130;
+export PDKPATH=$PDK_ROOT/sky130A ;
+
+2) Useful misc utils
+
+
+
+load caravel -dereference
+drc style drc(full)
+drc why
+drc find 10 ; findbox zoom
diff --git a/utils/README.txt b/utils/README.txt
new file mode 100644
index 0000000..78b4d56
--- /dev/null
+++ b/utils/README.txt
@@ -0,0 +1,31 @@
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+#
+# SPDX-License-Identifier: Apache-2.0
+
+####
+
+1) You must set the PDK_ROOT variable
+
+export PDK_ROOT=~/foss/pdks/open_pdks/sky130;
+export PDKPATH=$PDK_ROOT/sky130A ;
+
+2) Useful misc utils
+
+
+
+load caravel -dereference
+drc style drc(full)
+drc why
+drc find 10 ; findbox zoom
diff --git a/utils/addmpwseal.tcl b/utils/addmpwseal.tcl
new file mode 100644
index 0000000..b562f93
--- /dev/null
+++ b/utils/addmpwseal.tcl
@@ -0,0 +1,25 @@
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+drc off
+gds readonly true
+gds rescale false
+gds read ../gds/sram_1rw1r_32_256_8_sky130_lp1.gds
+load ./caravel.mag
+select top cell
+move origin -7.165um -7.120um
+box position 0 0
+getcell advSeal_6um_gen
+gds write caravel.mpw.gds
diff --git a/utils/apply_caravel.sh b/utils/apply_caravel.sh
new file mode 100644
index 0000000..1a922cf
--- /dev/null
+++ b/utils/apply_caravel.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+# To use: sh apply_caravel.sh <target_project_path> <template_caravel_path>
+
+target_project=$1
+original_caravel=$2
+
+find $original_caravel/def/* -type f ! -name "user_project_wrapper.def" ! -name "user_proj_example.def" -exec cp {} $target_project/def \;
+find $original_caravel/lef/* -type f ! -name "user_project_wrapper.lef" ! -name "user_proj_example.lef" -exec cp {} $target_project/lef \;
+find $original_caravel/gds/* -type f ! -name "user_project_wrapper.gds.gz" ! -name "user_proj_example.gds.gz" ! -name "user_project_wrapper.gds" ! -name "user_proj_example.gds" -exec cp {} $target_project/gds \;
+find $original_caravel/mag/* -type f ! -name "user_project_wrapper.mag" ! -name "user_proj_example.mag" -exec cp {} $target_project/mag \;
+cp $original_caravel/mag/.magicrc $target_project/mag/
+mkdir -p $target_project/mag/hexdigits/
+mv $target_project/mag/alpha_*.mag $target_project/mag/hexdigits/
+cp $original_caravel/maglef/* $target_project/maglef
+cp -r $original_caravel/ngspice/digital_pll $target_project/ngspice/digital_pll
+cp -r $original_caravel/ngspice/simple_por $target_project/ngspice/simple_por
+cp -r $original_caravel/scripts $target_project/scripts
+find $original_caravel/spi/lvs/* -type f ! -name "user_project_wrapper.spice" ! -name "user_proj_example.spice" -exec cp {} $target_project/spi/lvs/ \;
+cp -r $original_caravel/utils $target_project/utils
+find $original_caravel/verilog/rtl/* -type f ! -name "user_project_wrapper.v" ! -name "user_proj_example.v" -exec cp {} $target_project/verilog/rtl/ \;
+find $original_caravel/verilog/gl/* -type f ! -name "user_project_wrapper.v" ! -name "user_proj_example.v" -exec cp {} $target_project/verilog/gl/ \;
+cp $original_caravel/verilog/stubs/*.v $target_project/verilog/stubs/
+cp -r $original_caravel/verilog/dv/caravel $target_project/verilog/dv/caravel
+cp -r $original_caravel/verilog/dv/wb_utests $target_project/verilog/dv/wb_utests
+cp $original_caravel/verilog/dv/dummy_slave.v $target_project/verilog/dv/dummy_slave.v
+
+echo "You'll have to manually copy the openlane/user_project_wrapper configs based on your preference."
+echo "You'll have to manually copy the openlane/Makefile based on your preference."
+echo "You'll have to manually copy the Makefile based on your preference."
\ No newline at end of file
diff --git a/utils/core_scripts/README.md b/utils/core_scripts/README.md
new file mode 100644
index 0000000..b14c1db
--- /dev/null
+++ b/utils/core_scripts/README.md
@@ -0,0 +1,20 @@
+<!---
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+#
+# SPDX-License-Identifier: Apache-2.0
+-->
+# What is this?
+
+Core scripts are doing the actual work, scripts under ../scripts are the ones that should be used.
\ No newline at end of file
diff --git a/utils/core_scripts/magic-drc.sh b/utils/core_scripts/magic-drc.sh
new file mode 100644
index 0000000..5f5068d
--- /dev/null
+++ b/utils/core_scripts/magic-drc.sh
@@ -0,0 +1,54 @@
+#!/bin/bash
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+# To call: ./magic-drc.sh <target_path> <design_name> <pdk-root> <target-type> <pdk-name> <output_path>
+
+export TARGET_DIR=$1
+export DESIGN_NAME=$2
+export PDK_ROOT=$3
+export TARGET_TYPE=$4
+export PDK=$5
+export OUT_DIR=$6
+export TCL_CALL_PATH=${7:-$(pwd)}
+
+echo "Running Magic..."
+export MAGIC_MAGICRC=$PDK_ROOT/$PDK/libs.tech/magic/sky130A.magicrc
+
+magic \
+    -noconsole \
+    -dnull \
+    -rcfile $MAGIC_MAGICRC \
+    $TCL_CALL_PATH/magic-drc.tcl \
+    </dev/null \
+    |& tee $OUT_DIR/magic_drc.log
+
+TEST=$OUT_DIR/$DESIGN_NAME.magic.drc
+
+crashSignal=$(find $TEST)
+if ! [[ $crashSignal ]]; then echo "DRC Check FAILED"; exit -1; fi
+
+
+Test_Magic_violations=$(grep "COUNT: " $TEST -s | tail -1 | sed -r 's/[^0-9]*//g')
+if ! [[ $Test_Magic_violations ]]; then Test_Magic_violations=-1; fi
+if [ $Test_Magic_violations -ne -1 ]; then Test_Magic_violations=$(((Test_Magic_violations+3)/4)); fi
+
+echo "Test # of DRC Violations:"
+echo $Test_Magic_violations
+
+if [ 0 -ne $Test_Magic_violations ]; then echo "DRC Check FAILED"; exit -1; fi
+
+echo "DRC Check Passed"
+exit 0
diff --git a/utils/core_scripts/magic-drc.tcl b/utils/core_scripts/magic-drc.tcl
new file mode 100644
index 0000000..6768d3c
--- /dev/null
+++ b/utils/core_scripts/magic-drc.tcl
@@ -0,0 +1,74 @@
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+if { $::env(TARGET_TYPE) == "gds"} {
+	gds read $::env(TARGET_DIR)/$::env(DESIGN_NAME).gds
+} else {
+	if { $::env(TARGET_TYPE) == "mag" } {
+		load $::env(TARGET_DIR)/$::env(DESIGN_NAME).mag
+	} else {
+		def read $::env(TARGET_DIR)/$::env(DESIGN_NAME).def
+	}
+}
+
+set fout [open $::env(OUT_DIR)/$::env(DESIGN_NAME).magic.drc w]
+set oscale [cif scale out]
+set cell_name $::env(DESIGN_NAME)
+magic::suspendall
+puts stdout "\[INFO\]: Loading $cell_name\n"
+flush stdout
+load $cell_name
+select top cell
+drc euclidean on
+drc style drc(full)
+drc check
+set drcresult [drc listall why]
+
+
+set count 0
+puts $fout "$cell_name"
+puts $fout "----------------------------------------"
+foreach {errtype coordlist} $drcresult {
+	puts $fout $errtype
+	puts $fout "----------------------------------------"
+	foreach coord $coordlist {
+	    set bllx [expr {$oscale * [lindex $coord 0]}]
+	    set blly [expr {$oscale * [lindex $coord 1]}]
+	    set burx [expr {$oscale * [lindex $coord 2]}]
+	    set bury [expr {$oscale * [lindex $coord 3]}]
+	    set coords [format " %.3f %.3f %.3f %.3f" $bllx $blly $burx $bury]
+	    puts $fout "$coords"
+	    set count [expr {$count + 1} ]
+	}
+	puts $fout "----------------------------------------"
+}
+
+puts $fout "\[INFO\]: COUNT: $count"
+puts $fout "\[INFO\]: Should be divided by 3 or 4"
+
+puts $fout ""
+close $fout
+
+puts stdout "\[INFO\]: COUNT: $count"
+puts stdout "\[INFO\]: Should be divided by 3 or 4"
+puts stdout "\[INFO\]: DRC Checking DONE ($::env(OUT_DIR)/$::env(DESIGN_NAME).magic.drc)"
+flush stdout
+
+puts stdout "\[INFO\]: Saving mag view with DRC errors($::env(OUT_DIR)/$::env(DESIGN_NAME).magic.drc.mag)"
+# WARNING: changes the name of the cell; keep as last step
+save $::env(OUT_DIR)/$::env(DESIGN_NAME).magic.drc.mag
+puts stdout "\[INFO\]: Saved"
+
+exit 0
diff --git a/utils/core_scripts/magic-ext.sh b/utils/core_scripts/magic-ext.sh
new file mode 100644
index 0000000..68bfc39
--- /dev/null
+++ b/utils/core_scripts/magic-ext.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+# To call: ./magic-ext.sh <target_path> <design_name> <pdk-root> <target-type> <pdk-name> <output_path>
+
+export TARGET_DIR=$1
+export DESIGN_NAME=$2
+export PDK_ROOT=$3
+export TARGET_TYPE=$4
+export PDK=$5
+export OUT_DIR=$6
+export TCL_CALL_PATH=${7:-$(pwd)}
+
+echo "Running Magic..."
+export MAGIC_MAGICRC=$PDK_ROOT/$PDK/libs.tech/magic/sky130A.magicrc
+
+magic \
+    -noconsole \
+    -dnull \
+    -rcfile $MAGIC_MAGICRC \
+    $TCL_CALL_PATH/magic-ext.tcl \
+    </dev/null \
+    |& tee $OUT_DIR/magic_ext.log
diff --git a/utils/core_scripts/magic-ext.tcl b/utils/core_scripts/magic-ext.tcl
new file mode 100644
index 0000000..5a05dcb
--- /dev/null
+++ b/utils/core_scripts/magic-ext.tcl
@@ -0,0 +1,44 @@
+#!/usr/bin/tclsh
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+
+puts "Performing Spice Extractions..."
+
+if { ![file isdirectory $::env(OUT_DIR)] } {
+	exec mkdir $::env(OUT_DIR)/
+}
+
+
+if { $::env(TARGET_TYPE) == "gds"} {
+	gds read $::env(TARGET_DIR)/$::env(DESIGN_NAME).gds
+} else {
+	if { $::env(TARGET_TYPE) == "mag" } {
+		load $::env(TARGET_DIR)/$::env(DESIGN_NAME).mag
+	} else {
+		def read $::env(TARGET_DIR)/$::env(DESIGN_NAME).def
+	}
+}
+
+load $::env(DESIGN_NAME) -dereference
+cd $::env(OUT_DIR)/
+extract do local
+# extract warn all
+extract
+ext2spice lvs
+ext2spice $::env(DESIGN_NAME).ext
+feedback save $::env(OUT_DIR)/magic_extraction_feedback.txt
+
+puts "Done!"
\ No newline at end of file
diff --git a/utils/draw_boundary.sh b/utils/draw_boundary.sh
new file mode 100644
index 0000000..582be75
--- /dev/null
+++ b/utils/draw_boundary.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+: ${1?"Usage: $0 file.mag llx lly urx ury"}
+: ${2?"Usage: $0 file.mag llx lly urx ury"}
+: ${3?"Usage: $0 file.mag llx lly urx ury"}
+: ${4?"Usage: $0 file.mag llx lly urx ury"}
+: ${5?"Usage: $0 file.mag llx lly urx ury"}
+: ${PDK_ROOT?"You need to export PDK_ROOT"}
+
+
+export PDK=sky130A
+
+export MAGIC_MAGICRC=$PDK_ROOT/$PDK/libs.tech/magic/$PDK.magicrc
+
+MAGTYPE=mag magic -rcfile $MAGIC_MAGICRC -dnull -noconsole $1 <<EOF
+echo $MAGTYPE
+## Draw Top Boundary
+box 0um $5um $4um 3520.5um
+paint comment
+## Draw Bottom Boundary
+box 0um -0.5um $4um 0um
+paint comment
+## Draw Left Boundary
+box -0.5um -0.5um 0um 3520.5um
+paint comment
+## Draw Right Boundary
+box $4um -0.5um 2920.5um 3520.5um
+paint comment
+## Save mag file
+save
+EOF
+ls $1
diff --git a/utils/drc-def-sky130A.sh b/utils/drc-def-sky130A.sh
new file mode 100644
index 0000000..671b14a
--- /dev/null
+++ b/utils/drc-def-sky130A.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+# To call: ./drc-def-sky130A.sh <target_path> <design_name> <pdk-root> [<output_path> default is <target_path>/results/]
+
+export TARGET_DIR=$1
+export DESIGN_NAME=$2
+export PDK_ROOT=$3
+export OUT_DIR=${4:-$TARGET_DIR/results/}
+export TCL_CALL_PATH=$(pwd)/core_scripts
+
+if ! [[ -d "$OUT_DIR" ]]
+then
+    mkdir $OUT_DIR
+fi
+bash ./core_scripts/magic-drc.sh $TARGET_DIR $DESIGN_NAME $PDK_ROOT "def" "sky130A" $OUT_DIR $TCL_CALL_PATH
diff --git a/utils/drc-gds-sky130A.sh b/utils/drc-gds-sky130A.sh
new file mode 100644
index 0000000..4c1d6d8
--- /dev/null
+++ b/utils/drc-gds-sky130A.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+# To call: ./drc-gds-sky130A.sh <target_path> <design_name> <pdk-root> [<output_path> default is <target_path>/results/]
+
+export TARGET_DIR=$1
+export DESIGN_NAME=$2
+export PDK_ROOT=$3
+export OUT_DIR=${4:-$TARGET_DIR/results/}
+export TCL_CALL_PATH=$(pwd)/core_scripts
+
+if ! [[ -d "$OUT_DIR" ]]
+then
+    mkdir $OUT_DIR
+fi
+
+bash ./core_scripts/magic-drc.sh $TARGET_DIR $DESIGN_NAME $PDK_ROOT "gds" "sky130A" $OUT_DIR $TCL_CALL_PATH
diff --git a/utils/drc-mag-sky130A.sh b/utils/drc-mag-sky130A.sh
new file mode 100644
index 0000000..2bbecd3
--- /dev/null
+++ b/utils/drc-mag-sky130A.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+# To call: ./drc-mag-sky130A.sh <target_path> <design_name> <pdk-root> [<output_path> default is <target_path>/results/]
+
+export TARGET_DIR=$1
+export DESIGN_NAME=$2
+export PDK_ROOT=$3
+export OUT_DIR=${4:-$TARGET_DIR/results/}
+export TCL_CALL_PATH=$(pwd)/core_scripts
+
+if ! [[ -d "$OUT_DIR" ]]
+then
+    mkdir $OUT_DIR
+fi
+bash ./core_scripts/magic-drc.sh $TARGET_DIR $DESIGN_NAME $PDK_ROOT "mag" "sky130A" $OUT_DIR $TCL_CALL_PATH
diff --git a/utils/erase_box.sh b/utils/erase_box.sh
new file mode 100644
index 0000000..7636e42
--- /dev/null
+++ b/utils/erase_box.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+: ${1?"Usage: $0 file.gds llx lly urx ury"}
+: ${2?"Usage: $0 file.gds llx lly urx ury"}
+: ${3?"Usage: $0 file.gds llx lly urx ury"}
+: ${4?"Usage: $0 file.gds llx lly urx ury"}
+: ${5?"Usage: $0 file.gds llx lly urx ury"}
+: ${PDK_ROOT?"You need to export PDK_ROOT"}
+
+
+export PDK=sky130A
+
+export MAGIC_MAGICRC=$PDK_ROOT/$PDK/libs.tech/magic/$PDK.magicrc
+
+MAGTYPE=mag magic -rcfile $MAGIC_MAGICRC -dnull -noconsole  <<EOF
+echo $MAGTYPE
+tech unlock *
+gds read $1
+box $2um $3um $4um $5um
+erase
+select area
+delete
+#### REVISE THIS:
+select top cell
+erase labels
+####
+gds write ${1%.*}_erased.gds
+EOF
+ls ${1%.*}_erased.gds
diff --git a/utils/examples/README.md b/utils/examples/README.md
new file mode 100644
index 0000000..10f7a37
--- /dev/null
+++ b/utils/examples/README.md
@@ -0,0 +1,19 @@
+<!---
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+#
+# SPDX-License-Identifier: Apache-2.0
+-->
+This folder contains miscelleneous useful scripts
+THIS IS STILL WORK IN PROGRESSS - SUGGESTIONS ARE WELCOME THROUGH ISSUES
diff --git a/utils/examples/addmpwseal.tcl b/utils/examples/addmpwseal.tcl
new file mode 100644
index 0000000..79e4b9e
--- /dev/null
+++ b/utils/examples/addmpwseal.tcl
@@ -0,0 +1,26 @@
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+drc off
+gds readonly true
+gds read ../gds/sram_1rw1r_32_256_8_sky130_lp1.gds
+load openram_tc_1kb.mag
+select top cell
+move origin -1015um -1272.5um
+box position 0 0
+getcell advSeal_6um_gen
+save
+gds write ../gds/openram_tc_1kb.gds
+
diff --git a/utils/examples/create-project.sh b/utils/examples/create-project.sh
new file mode 100644
index 0000000..5b5b69c
--- /dev/null
+++ b/utils/examples/create-project.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+cat <<'EOT' > .gitignore
+.DS_Store
+*.vcd
+*.raw
+*.vvp
+a.out
+EOT
+mkdir scripts		; echo "This folder contains miscelleneous useful scripts" > scripts/README.md 
+mkdir def		; echo "This folder contains *.def files related to this project" > def/README.md 
+mkdir gds		; echo "This folder contains *.gds files related to this project" > gds/README.md 
+mkdir verilog		; echo "This folder contains *.v   files related to this project" > verilog/README.md 
+mkdir mag		; echo "This folder contains *.mag files related to this project" > mag/README.md 
+mkdir lef		; echo "This folder contains *.lef files related to this project" > lef/README.md 
+mkdir macros		; echo "This folder contains subcell & macro files related to this project" > macros/README.md 
+mkdir doc		; echo "This folder contains documents related to this project" > doc/README.md 
+mkdir ngspice		; echo "This folder contains ngspice related files related to this project" > ngspice/README.md 
+mkdir openlane		; echo "This folder contains openlane related files related to this project" > openlane/README.md 
+mkdir pkg		; echo "This folder contains packaging-related files related to this project" > pkg/README.md
+mkdir test		; echo "This folder contains test-related files related to this project" > test/README.md
+mkdir xspice		; echo "This folder contains xspice files related to this project" > xspice/README.md
+mkdir spi		; echo "This folder contains *.spi files related to this project" > spi/README.md
+mkdir qflow		; echo "This folder contains qflow-related files related to this project" > qflow/README.md
diff --git a/utils/examples/dot.magicrc b/utils/examples/dot.magicrc
new file mode 100644
index 0000000..42f2fb2
--- /dev/null
+++ b/utils/examples/dot.magicrc
@@ -0,0 +1,65 @@
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+#
+# SPDX-License-Identifier: Apache-2.0
+
+puts stdout "Sourcing design .magicrc for technology sky130A ..."
+
+# Put grid on 0.005 pitch.  This is important, as some commands don't
+# rescale the grid automatically (such as lef read?).
+
+set scalefac [tech lambda]
+if {[lindex $scalefac 1] < 2} {
+    scalegrid 1 2
+}
+
+# drc off
+drc euclidean on
+
+# default pdk 
+# set SW_PDK_ROOT "/ef/tech/SW.2"
+set PDK "sky130A"
+set SCL_VARIANT "sky130_fd_sc_hd"
+set IO_VARIANT "sky130_fd_io"
+set PDKPATH "$::env(SW_PDK_ROOT)/$PDK"
+
+# loading technology
+tech load "$PDKPATH/libs.tech/magic/current/$PDK.tech"
+
+# load device generator
+source "$PDKPATH/libs.tech/magic/current/$PDK.tcl"
+
+
+# load bind keys (optional)
+source "$PDKPATH/libs.tech/magic/current/$PDK-BindKeys"
+
+# set units to lambda grid 
+snap lambda
+
+# add path to reference cells
+set MAGPATH "$PDKPATH/libs.ref/$SCL_VARIANT/mag/*.mag"
+
+
+addpath "$PDKPATH/libs.ref/sky130_fd_pr_base/mag"
+addpath "$PDKPATH/libs.ref/$IO_VARIANT/mag"
+addpath "$PDKPATH/libs.ref/$SCL_VARIANT/mag"
+
+# addpath ${MAGPATH}/s8fmlt
+
+# add path to GDS cells
+
+# add path to IP from catalog.  This procedure defined in the PDK script.
+catch {magic::query_mylib_ip}
+# add path to local IP from user design space.  Defined in the PDK script.
+catch {magic::query_my_projects}
diff --git a/utils/examples/drc-mag.sh b/utils/examples/drc-mag.sh
new file mode 100644
index 0000000..7229f45
--- /dev/null
+++ b/utils/examples/drc-mag.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+
+export MAGTYPE=mag ;
+export BASE=/home/mk/zooz/ ;
+export PDKPATH=$BASE/pdks/ef-skywater-s8/EFS8A ;
+
+magic -dnull -noconsole -rcfile $PDKPATH/libs.tech/magic/current/EFS8A.magicrc <<EOF
+gds polygon subcell true
+gds warning default
+gds read $1.gds
+load $1
+cellname delete \(UNNAMED\)
+writeall force
+select top cell
+expand
+drc on
+drc euclidean on
+drc check
+drc catchup
+drc listall 
+drc listall why
+drc count total
+drc count
+quit -noprompt
+EOF
diff --git a/utils/examples/drc-maglef.sh b/utils/examples/drc-maglef.sh
new file mode 100644
index 0000000..42f622f
--- /dev/null
+++ b/utils/examples/drc-maglef.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+
+export MAGTYPE=maglef ;
+export BASE=/home/mk/zooz/ ;
+export PDKPATH=$BASE/pdks/ef-skywater-s8/EFS8A ;
+
+magic -dnull -noconsole -rcfile $PDKPATH/libs.tech/magic/current/EFS8A.magicrc <<EOF
+gds polygon subcell true
+gds warning default
+gds read $1.gds
+load $1
+cellname delete \(UNNAMED\)
+writeall force
+select top cell
+expand
+drc on
+drc euclidean on
+drc check
+drc catchup
+drc listall 
+drc listall why
+drc count total
+drc count
+quit -noprompt
+EOF
diff --git a/utils/examples/drc.sh b/utils/examples/drc.sh
new file mode 100644
index 0000000..7229f45
--- /dev/null
+++ b/utils/examples/drc.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+
+export MAGTYPE=mag ;
+export BASE=/home/mk/zooz/ ;
+export PDKPATH=$BASE/pdks/ef-skywater-s8/EFS8A ;
+
+magic -dnull -noconsole -rcfile $PDKPATH/libs.tech/magic/current/EFS8A.magicrc <<EOF
+gds polygon subcell true
+gds warning default
+gds read $1.gds
+load $1
+cellname delete \(UNNAMED\)
+writeall force
+select top cell
+expand
+drc on
+drc euclidean on
+drc check
+drc catchup
+drc listall 
+drc listall why
+drc count total
+drc count
+quit -noprompt
+EOF
diff --git a/utils/examples/edit.tcl b/utils/examples/edit.tcl
new file mode 100644
index 0000000..f1766ad
--- /dev/null
+++ b/utils/examples/edit.tcl
@@ -0,0 +1,26 @@
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+drc off
+puts "Small delay..."
+set macro_mags "digital_pll.mag lvlshiftdown.mag striVe2_soc.mag striVe_clkrst.mag striVe_spi.mag"
+
+gds readonly yes
+gds rescale no
+gds read ../gds/sram_1rw1r_32_256_8_sky130.gds
+lef read ../lef/sram.abs.lef
+foreach ff $macro_mags { drc off; load $ff -dereference; after 1000; select top cell; property LEFview TRUE }
+load striVe2 -dereference
+select top cell
diff --git a/utils/examples/ext-gds.sh b/utils/examples/ext-gds.sh
new file mode 100644
index 0000000..c3efd7e
--- /dev/null
+++ b/utils/examples/ext-gds.sh
@@ -0,0 +1,43 @@
+#!/bin/bash
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+
+export MAGTYPE=maglef ;
+export BASE=/home/mk/zooz/ ;
+export PDKPATH=$BASE/pdks/ef-skywater-s8/EFS8A ;
+
+magic -dnull -noconsole -rcfile $PDKPATH/libs.tech/magic/current/EFS8A.magicrc <<EOF
+gds polygon subcell true
+gds warning default
+gds read $1.gds
+load $1.mag
+save $1.mag
+writeall force
+select top cell
+extract style ngspice(si)
+extract
+ext2spice hierarchy on
+ext2spice format ngspice
+ext2spice cthresh infinite
+ext2spice rthresh infinite
+ext2spice renumber offS
+ext2spice scale off
+ext2spice blackbox on
+ext2spice subcircuit top auto
+ext2spice global off
+ext2spice $1.ext
+quit -noprompt
+EOF
diff --git a/utils/examples/ext-mag.sh b/utils/examples/ext-mag.sh
new file mode 100644
index 0000000..a62a831
--- /dev/null
+++ b/utils/examples/ext-mag.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+
+export MAGTYPE=mag ;
+export BASE=/home/mk/zooz/ ;
+export PDKPATH=$BASE/pdks/ef-skywater-s8/EFS8A ;
+
+magic -dnull -noconsole -rcfile $PDKPATH/libs.tech/magic/current/EFS8A.magicrc <<EOF
+load $1.mag
+save $1.mag
+writeall force
+select top cell
+extract style ngspice(si)
+extract
+ext2spice hierarchy on
+ext2spice format ngspice
+ext2spice cthresh infinite
+ext2spice rthresh infinite
+ext2spice renumber offS
+ext2spice scale off
+ext2spice blackbox on
+ext2spice subcircuit top auto
+ext2spice global off
+ext2spice $1.ext
+quit -noprompt
+EOF
diff --git a/utils/examples/ext.sh b/utils/examples/ext.sh
new file mode 100644
index 0000000..b414e8b
--- /dev/null
+++ b/utils/examples/ext.sh
@@ -0,0 +1,43 @@
+#!/bin/bash
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+
+export MAGTYPE=maglef ;
+export BASE=/home/mk/zooz/ ;
+export PDKPATH=$BASE/pdks/ef-skywater-s8/EFS8A ;
+
+magic -dnull -noconsole -rcfile $PDKPATH/libs.tech/magic/current/EFS8A.magicrc <<EOF
+gds polygon subcell true
+gds warning default
+gds read $1.gds
+load $1.mag
+save $1.mag
+writeall force
+select top cell
+extract style ngspice(si)
+extract
+ext2spice hierarchy on
+ext2spice format ngspice
+ext2spice cthresh infinite
+ext2spice rthresh infinite
+ext2spice renumber off
+ext2spice scale off
+ext2spice blackbox on
+ext2spice subcircuit top auto
+ext2spice global off
+ext2spice $1.ext
+quit -noprompt
+EOF
diff --git a/utils/examples/extract.tcl b/utils/examples/extract.tcl
new file mode 100644
index 0000000..a38c9cb
--- /dev/null
+++ b/utils/examples/extract.tcl
@@ -0,0 +1,31 @@
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+lef read $::env(PDKPATH)/libs.ref/techLEF/scs8hd/scs8hd_tech.lef
+set macro_mags "openram_tc_core.mag"
+
+# lef read ../lef/sram_1rw1r_32_256_8_sky130_lp1.lef
+
+foreach ff $macro_mags { drc off; after 500; load $ff -dereference; select top cell; property LEFview TRUE }
+
+load openram_tc_1kb -dereference
+
+select top cell
+extract do local
+extract
+ext2spice lvs
+ext2spice openram_tc_1kb.ext
+feedback save extract.tcl.log
+exit
diff --git a/utils/examples/lvs.sh b/utils/examples/lvs.sh
new file mode 100644
index 0000000..3a5043e
--- /dev/null
+++ b/utils/examples/lvs.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+/ef/apps/bin/netgen -noconsole << EOF
+readnet spice $1.spice
+readnet spice $1.sp
+lvs {$1.spice sram_2_16_sky130} {sram_2_16_sky130.sp sram_2_16_sky130} setup.tcl sram_2_16_sky130.lvs.report
+quit
+EOF
diff --git a/utils/examples/mag2gds.tcl b/utils/examples/mag2gds.tcl
new file mode 100644
index 0000000..8d7057d
--- /dev/null
+++ b/utils/examples/mag2gds.tcl
@@ -0,0 +1,33 @@
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+# assumes an /ef tree or at least a symlink
+drc off
+gds readonly true
+gds rescale false
+set ::env(MAGTYPE) mag
+
+# gds read <hard macros read as-is.gds>
+gds read ../gds/sram_1rw1r_32_256_8_sky130_lp1.gds
+
+load sram_1rw1r_32_256_8_sky130 -dereference
+load openram_tc_core -dereference
+load openram_tc_1kb -dereference
+
+select top cell
+
+cif *hier write disable
+
+gds write openram_tc_1kb.gds
diff --git a/utils/examples/magic_drc.tcl b/utils/examples/magic_drc.tcl
new file mode 100644
index 0000000..554a4c6
--- /dev/null
+++ b/utils/examples/magic_drc.tcl
@@ -0,0 +1,71 @@
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+set ::env(DESIGN_NAME) openram_tc_1kb
+drc off
+lef read ../lef/sram_1rw1r_32_256_8_sky130_lp1.lef
+load sram_1rw1r_32_256_8_sky130 -dereference
+load openram_tc_core -dereference
+load openram_tc_1kb -dereference
+
+drc style drc(full)
+drc euclidean on
+
+set fout [open drc.log w]
+set oscale [cif scale out]
+set cell_name $::env(DESIGN_NAME)
+magic::suspendall
+puts stdout "\[INFO\]: Loading $cell_name\n"
+flush stdout
+load $cell_name
+select top cell
+drc check
+set drcresult [drc listall why]
+
+
+set count 0
+puts $fout "$cell_name"
+puts $fout "----------------------------------------"
+foreach {errtype coordlist} $drcresult {
+	puts $fout $errtype
+	puts $fout "----------------------------------------"
+	foreach coord $coordlist {
+	    set bllx [expr {$oscale * [lindex $coord 0]}]
+	    set blly [expr {$oscale * [lindex $coord 1]}]
+	    set burx [expr {$oscale * [lindex $coord 2]}]
+	    set bury [expr {$oscale * [lindex $coord 3]}]
+	    set coords [format " %.3f %.3f %.3f %.3f" $bllx $blly $burx $bury]
+	    puts $fout "$coords"
+	    set count [expr {$count + 1} ]
+	}
+	puts $fout "----------------------------------------"
+}
+
+puts $fout "\[INFO\]: COUNT: $count"
+puts $fout "\[INFO\]: Should be divided by 3 or 4"
+
+puts $fout ""
+close $fout
+
+puts stdout "\[INFO\]: COUNT: $count"
+puts stdout "\[INFO\]: Should be divided by 3 or 4"
+puts stdout "\[INFO\]: DRC Checking DONE ($::env(DESIGN_NAME).drc)"
+flush stdout
+
+puts stdout "\[INFO\]: Saving mag view with DRC errors($::env(DESIGN_NAME).drc.mag)"
+# WARNING: changes the name of the cell; keep as last step
+save $::env(DESIGN_NAME).drc.mag
+puts stdout "\[INFO\]: Saved"
+
+exit 0
diff --git a/utils/examples/pfg.sh b/utils/examples/pfg.sh
new file mode 100644
index 0000000..9d8def1
--- /dev/null
+++ b/utils/examples/pfg.sh
@@ -0,0 +1,38 @@
+#!/bin/bash
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+
+export PDKPATH=/home/mk/zooz/pdks/ef-skywater-s8/EFS8A
+export MAGTYPE=mag 
+
+padring \
+-L $PDKPATH/libs.ref/lef/s8iom0s8/s8iom0s8.lef \
+-L $PDKPATH/libs.ref/lef/s8iom0s8/power_pads_lib.lef \
+--def padframe.def padframe.cfg 
+
+magic -rcfile $PDKPATH/libs.tech/magic/current/EFS8A.magicrc -noc -dnull <<EOF
+def read padframe.def
+save padframe
+select top cell
+lef write padframe.lef
+gds write padframe.gds
+exit
+EOF
+
+
+
+
+
diff --git a/utils/examples/run_openram_tc_1kb.sh b/utils/examples/run_openram_tc_1kb.sh
new file mode 100644
index 0000000..408ce96
--- /dev/null
+++ b/utils/examples/run_openram_tc_1kb.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+#
+# Run netgen on striVe (top level)
+#
+
+NETGEN_SETUP=$PDK_ROOT/EFS8A/libs.tech/netgen/EFS8A_setup.tcl
+
+netgen -batch lvs "../spi/openram_tc_1kb.spice openram_tc_1kb" "../verilog/gl/openram_tc_1kb.synthesis.v openram_tc_1kb" ${NETGEN_SETUP} openram_tc_1kb_comp.out -json | tee openram_tc_1kb_comp_lvs.log
diff --git a/utils/examples/setup.tcl b/utils/examples/setup.tcl
new file mode 100644
index 0000000..193dd2f
--- /dev/null
+++ b/utils/examples/setup.tcl
@@ -0,0 +1,27 @@
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+# We must flatten these because the ports are disconnected
+flatten class {-circuit1 dummy_cell_6t}
+flatten class {-circuit1 dummy_cell_1rw_1r}
+flatten class {-circuit1 dummy_cell_1w_1r}
+flatten class {-circuit1 bitcell_array_0}
+flatten class {-circuit1 pbitcell_0}
+flatten class {-circuit1 pbitcell_1}
+property {-circuit1 nshort} remove as ad ps pd
+property {-circuit1 pshort} remove as ad ps pd
+property {-circuit2 nshort} remove as ad ps pd
+property {-circuit2 pshort} remove as ad ps pd
+permute transistors
diff --git a/utils/examples/wrap.tcl b/utils/examples/wrap.tcl
new file mode 100644
index 0000000..fc2c87e
--- /dev/null
+++ b/utils/examples/wrap.tcl
@@ -0,0 +1,28 @@
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+drc off
+gds readonly yes
+gds rescale no
+
+gds read ../macros/sram/riscv-sky130/sram_1rw1r_32_256_8_sky130.gds
+load sram_1rw1r_32_256_8_sky130
+
+select top cell
+property LEFview "TRUE"
+
+save pk_sram_1rw1r_32_256_8_sky130.mag
+
+# exec sed -i -E "/^.*GDS_END.*$/d" sram_1rw1r_32_256_8_sky130_original.mag
diff --git a/utils/examples/wrap2.tcl b/utils/examples/wrap2.tcl
new file mode 100644
index 0000000..db1db3c
--- /dev/null
+++ b/utils/examples/wrap2.tcl
@@ -0,0 +1,36 @@
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+drc off
+gds readonly yes
+gds rescale no
+
+lef read ../lef/sram.abs.con.lef
+load sram_1rw1r_32_256_8_sky130
+
+select top cell
+expand
+property LEFview ""
+property LEFsymmetry ""
+property LEFclass ""
+
+box position 5um 5um
+getcell pk_sram_1rw1r_32_256_8_sky130
+
+save sram_1rw1r_32_256_8_sky130.mag
+
+gds write output.gds
+
+save
diff --git a/utils/examples/xor.drc b/utils/examples/xor.drc
new file mode 100644
index 0000000..14896ee
--- /dev/null
+++ b/utils/examples/xor.drc
@@ -0,0 +1,42 @@
+# A general XOR script
+# (https://www.klayout.de/forum/discussion/100/xor-vs-diff-tool)
+# This script uses KLayout's DRC language to implement a generic
+# XOR between two layouts. The name of the layouts is given
+# in $a and $b.
+
+# For layout-to-layout XOR with multiple cores, run this script with
+#   ./klayout -r xor.drc -rd thr=NUM_CORES -rd top_cell=TOP_CELL_NAME -rd a=a.gds -rd b=b.gds -rd ol=xor.gds -zz
+# (replace NUM_CORES by the desired number of cores to utilize
+
+# enable timing output
+verbose
+
+# set up input a
+a = source($a, $top_cell)
+
+# set up input b
+b = source($b, $top_cell)
+
+$o && report("XOR #{$a} vs. #{$b}", $o)
+$ol && target($ol, $co || "XOR")
+
+$thr && threads($thr) || threads(2)
+
+# collect all common layers
+layers = {}
+[ a.layout, b.layout ].each do |ly|
+  ly.layer_indices.each do |li|
+    i = ly.get_info(li)
+    layers[i.to_s] = i
+  end
+end
+
+# perform the XOR's
+layers.keys.sort.each do |l|
+  i = layers[l]
+  info("--- Running XOR for #{l} ---")
+  x = a.input(l) ^ b.input(l)
+  info("XOR differences: #{x.data.size}")
+  $o && x.output(l, "XOR results for layer #{l}")
+  $ol && x.output(i.layer, i.datatype, i.name)
+end
diff --git a/utils/examples/xor.sh b/utils/examples/xor.sh
new file mode 100644
index 0000000..6911062
--- /dev/null
+++ b/utils/examples/xor.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+
+: ${1?"Usage: $0 file1.gds file2.gds <top_level_module_name>"}
+: ${2?"Usage: $0 file1.gds file2.gds <top_level_module_name>"}
+: ${3?"Usage: $0 file1.gds file2.gds <top_level_module_name>"}
+
+klayout -r $(dirname $0)/xor.drc -rd top_cell=$3 -rd a=$1 -rd b=$2 -rd thr=$(nproc) -rd ol=xor.gds -zz
diff --git a/utils/export_pin_labels.sh b/utils/export_pin_labels.sh
new file mode 100644
index 0000000..c31de09
--- /dev/null
+++ b/utils/export_pin_labels.sh
@@ -0,0 +1,51 @@
+#!/bin/bash
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+: ${1?"Usage: $0 file.mag llx_top lly_top urx_top ury_top llx_bottom lly_bottom urx_bottom ury_bottom"}
+: ${2?"Usage: $0 file.mag llx_top lly_top urx_top ury_top llx_bottom lly_bottom urx_bottom ury_bottom"}
+: ${3?"Usage: $0 file.mag llx_top lly_top urx_top ury_top llx_bottom lly_bottom urx_bottom ury_bottom"}
+: ${4?"Usage: $0 file.mag llx_top lly_top urx_top ury_top llx_bottom lly_bottom urx_bottom ury_bottom"}
+: ${5?"Usage: $0 file.mag llx_top lly_top urx_top ury_top llx_bottom lly_bottom urx_bottom ury_bottom"}
+: ${6?"Usage: $0 file.mag llx_top lly_top urx_top ury_top llx_bottom lly_bottom urx_bottom ury_bottom"}
+: ${7?"Usage: $0 file.mag llx_top lly_top urx_top ury_top llx_bottom lly_bottom urx_bottom ury_bottom"}
+: ${8?"Usage: $0 file.mag llx_top lly_top urx_top ury_top llx_bottom lly_bottom urx_bottom ury_bottom"}
+: ${9?"Usage: $0 file.mag llx_top lly_top urx_top ury_top llx_bottom lly_bottom urx_bottom ury_bottom"}
+: ${PDK_ROOT?"You need to export PDK_ROOT"}
+
+export PDK=sky130A
+
+export MAGIC_MAGICRC=$PDK_ROOT/$PDK/libs.tech/magic/$PDK.magicrc
+ls $1
+echo $1
+MAGTYPE=mag magic -rcfile $MAGIC_MAGICRC -dnull -noconsole $1  <<EOF
+echo $MAGTYPE
+select top cell 
+select area label
+setlabel font FreeSans
+setlabel size 0.7um
+setlabel justify c
+### Rotate Top Labels
+box $2um $3um $4um $5um
+select area
+setlabel size 1.2um
+setlabel rotate 180
+### Rotate Bottom Labels
+box $6um $7um $8um $9um
+select area
+setlabel rotate 90
+###
+save
+EOF
+ls $1
diff --git a/utils/ext-def-sky130A.sh b/utils/ext-def-sky130A.sh
new file mode 100644
index 0000000..51ec955
--- /dev/null
+++ b/utils/ext-def-sky130A.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+# To call: ./ext-def-sky130A.sh <target_path> <design_name> <pdk-root> [<output_path> default is <target_path>/results/]
+
+export TARGET_DIR=$1
+export DESIGN_NAME=$2
+export PDK_ROOT=$3
+export OUT_DIR=${4:-$TARGET_DIR/results/}
+export TCL_CALL_PATH=$(pwd)/core_scripts
+
+if ! [[ -d "$OUT_DIR" ]]
+then
+    mkdir $OUT_DIR
+fi
+
+bash ./core_scripts/magic-ext.sh $TARGET_DIR $DESIGN_NAME $PDK_ROOT "def" "sky130A" $OUT_DIR $TCL_CALL_PATH
diff --git a/utils/ext-gds-sky130A.sh b/utils/ext-gds-sky130A.sh
new file mode 100644
index 0000000..35071b8
--- /dev/null
+++ b/utils/ext-gds-sky130A.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+# To call: ./ext-gds-sky130A.sh <target_path> <design_name> <pdk-root> [<output_path> default is <target_path>/results/]
+
+export TARGET_DIR=$1
+export DESIGN_NAME=$2
+export PDK_ROOT=$3
+export OUT_DIR=${4:-$TARGET_DIR/results/}
+export TCL_CALL_PATH=$(pwd)/core_scripts
+
+if ! [[ -d "$OUT_DIR" ]]
+then
+    mkdir $OUT_DIR
+fi
+
+bash ./core_scripts/magic-ext.sh $TARGET_DIR $DESIGN_NAME $PDK_ROOT "gds" "sky130A" $OUT_DIR $TCL_CALL_PATH
diff --git a/utils/ext-mag-sky130A.sh b/utils/ext-mag-sky130A.sh
new file mode 100644
index 0000000..b57ec31
--- /dev/null
+++ b/utils/ext-mag-sky130A.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+# To call: ./ext-mag-sky130A.sh <target_path> <design_name> <pdk-root> [<output_path> default is <target_path>/results/]
+
+export TARGET_DIR=$1
+export DESIGN_NAME=$2
+export PDK_ROOT=$3
+export OUT_DIR=${4:-$TARGET_DIR/results/}
+export TCL_CALL_PATH=$(pwd)/core_scripts
+
+if ! [[ -d "$OUT_DIR" ]]
+then
+    mkdir $OUT_DIR
+fi
+
+bash ./core_scripts/magic-ext.sh $TARGET_DIR $DESIGN_NAME $PDK_ROOT "mag" "sky130A" $OUT_DIR $TCL_CALL_PATH
diff --git a/utils/gds2mag-mag.local.sh b/utils/gds2mag-mag.local.sh
new file mode 100644
index 0000000..110358b
--- /dev/null
+++ b/utils/gds2mag-mag.local.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+export PDK_ROOT=~/foss/pdks/open_pdks/sky130;
+export MAGTYPE=mag ; 
+export PDKPATH=$PDK_ROOT/sky130A ;
+export MAGIC=magic
+
+
+$MAGIC  -dnull -noconsole << EOF
+#------------------------------------------------------
+drc off
+#---------------------------------gds polygon subcell true
+gds warning default
+gds readonly true
+gds rescale false
+#---------------------------------tech unlock *
+gds read $1
+load ${1%.gds}
+#---------------------------------readspice ${1%.gds}.sp
+cellname delete "(UNNAMED)"
+save ${1%.gds}.mag
+quit -noprompt
+EOF
diff --git a/utils/gds2mag-mag.sh b/utils/gds2mag-mag.sh
new file mode 100644
index 0000000..d53b156
--- /dev/null
+++ b/utils/gds2mag-mag.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+export PDK_ROOT=~/foss/pdks/open_pdks/sky130;
+export MAGTYPE=mag ; 
+export PDKPATH=$PDK_ROOT/sky130A ;
+export MAGIC=magic
+
+
+$MAGIC -rcfile $PDKPATH/libs.tech/magic/current/sky130A.magicrc -dnull -noconsole << EOF
+#------------------------------------------------------
+drc off
+#---------------------------------gds polygon subcell true
+gds warning default
+gds readonly true
+gds rescale false
+#---------------------------------tech unlock *
+gds read $1
+load ${1%.gds}
+#---------------------------------readspice ${1%.gds}.sp
+cellname delete "(UNNAMED)"
+save ${1%.gds}.mag
+quit -noprompt
+EOF
diff --git a/utils/lef2maglef.sh b/utils/lef2maglef.sh
new file mode 100644
index 0000000..455c4a6
--- /dev/null
+++ b/utils/lef2maglef.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+
+export PDK_ROOT=~/foss/pdks/open_pdks/sky130;
+export MAGTYPE=mag ; 
+export PDKPATH=$PDK_ROOT/sky130A ;
+export MAGIC=magic
+
+
+$MAGIC -rcfile $PDKPATH/libs.tech/magic/current/sky130A.magicrc -dnull -noconsole << EOX 
+drc off
+lef read $1.lef
+load $1
+save $1.lef.mag
+#writeall force $1.lef.mag
+
+		# copy GDS properties from the MAG view into the MAGLEF view
+		set gds_properties [list]
+		set fp [open $1.mag r]
+			set mag_lines [split [read \$fp] "\n"]
+			foreach line \$mag_lines {
+				if { [string first "string GDS_" \$line] != -1 } {
+					lappend gds_properties \$line
+				}
+			}
+		close \$fp
+		set fp [open $1.lef.mag r]
+			set mag_lines [split [read \$fp] "\n"]
+			set new_mag_lines [list]
+			foreach line \$mag_lines {
+				if { [string first "<< end >>" \$line] != -1 } {
+					lappend new_mag_lines [join \$gds_properties "\n"]
+				}
+				lappend new_mag_lines \$line
+			}
+		close \$fp
+		set fp [open $1.lef.mag w]
+			puts \$fp [join \$new_mag_lines "\n"]
+		close \$fp
+
+
+quit
+EOX
+
+mv -f $1.lef.mag ../maglef/$1.mag
+rm -f $1.lef
diff --git a/utils/mag2maglef-mag.sh b/utils/mag2maglef-mag.sh
new file mode 100644
index 0000000..2934887
--- /dev/null
+++ b/utils/mag2maglef-mag.sh
@@ -0,0 +1,68 @@
+#!/bin/bash
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+
+export PDK_ROOT=~/foss/pdks/open_pdks/sky130;
+export MAGTYPE=mag ; 
+export PDKPATH=$PDK_ROOT/sky130A ;
+export MAGIC=magic
+
+$MAGIC -rcfile $PDKPATH/libs.tech/magic/current/sky130A.magicrc -dnull -noconsole  <<EOF
+drc off
+load $1.mag
+select top cell
+expand
+lef write $1.lef -hide 
+quit -noprompt
+EOF
+
+$MAGIC -rcfile $PDKPATH/libs.tech/magic/current/sky130A.magicrc -dnull -noconsole << EOX 
+drc off
+lef read $1.lef
+load $1
+save $1.lef.mag
+#writeall force $1.lef.mag
+
+		# copy GDS properties from the MAG view into the MAGLEF view
+		set gds_properties [list]
+		set fp [open $1.mag r]
+			set mag_lines [split [read \$fp] "\n"]
+			foreach line \$mag_lines {
+				if { [string first "string GDS_" \$line] != -1 } {
+					lappend gds_properties \$line
+				}
+			}
+		close \$fp
+		set fp [open $1.lef.mag r]
+			set mag_lines [split [read \$fp] "\n"]
+			set new_mag_lines [list]
+			foreach line \$mag_lines {
+				if { [string first "<< end >>" \$line] != -1 } {
+					lappend new_mag_lines [join \$gds_properties "\n"]
+				}
+				lappend new_mag_lines \$line
+			}
+		close \$fp
+		set fp [open $1.lef.mag w]
+			puts \$fp [join \$new_mag_lines "\n"]
+		close \$fp
+
+
+quit
+EOX
+
+mv -f $1.lef.mag ../maglef/$1.mag
+rm -f $1.lef
diff --git a/utils/mag2maglef-maglef.localrc.sh b/utils/mag2maglef-maglef.localrc.sh
new file mode 100644
index 0000000..f167252
--- /dev/null
+++ b/utils/mag2maglef-maglef.localrc.sh
@@ -0,0 +1,68 @@
+#!/bin/bash
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+
+export PDK_ROOT=~/foss/pdks/open_pdks/sky130;
+export MAGTYPE=maglef ; 
+export PDKPATH=$PDK_ROOT/sky130A ;
+export MAGIC=magic
+
+$MAGIC -dnull -noconsole  <<EOF
+drc off
+load $1.mag
+select top cell
+expand
+lef write $1.lef -hide
+quit -noprompt
+EOF
+
+$MAGIC -dnull -noconsole << EOX 
+drc off
+lef read $1.lef
+load $1
+save $1.lef.mag
+#writeall force $1.lef.mag
+
+		# copy GDS properties from the MAG view into the MAGLEF view
+		set gds_properties [list]
+		set fp [open $1.mag r]
+			set mag_lines [split [read \$fp] "\n"]
+			foreach line \$mag_lines {
+				if { [string first "string GDS_" \$line] != -1 } {
+					lappend gds_properties \$line
+				}
+			}
+		close \$fp
+		set fp [open $1.lef.mag r]
+			set mag_lines [split [read \$fp] "\n"]
+			set new_mag_lines [list]
+			foreach line \$mag_lines {
+				if { [string first "<< end >>" \$line] != -1 } {
+					lappend new_mag_lines [join \$gds_properties "\n"]
+				}
+				lappend new_mag_lines \$line
+			}
+		close \$fp
+		set fp [open $1.lef.mag w]
+			puts \$fp [join \$new_mag_lines "\n"]
+		close \$fp
+
+
+quit
+EOX
+
+mv -f $1.lef.mag ../maglef/$1.mag
+rm -f $1.lef
diff --git a/utils/mag2maglef-maglef.sh b/utils/mag2maglef-maglef.sh
new file mode 100644
index 0000000..e70fbd3
--- /dev/null
+++ b/utils/mag2maglef-maglef.sh
@@ -0,0 +1,68 @@
+#!/bin/bash
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+
+export PDK_ROOT=~/foss/pdks/open_pdks/sky130;
+export MAGTYPE=maglef ; 
+export PDKPATH=$PDK_ROOT/sky130A ;
+export MAGIC=magic
+
+$MAGIC -rcfile $PDKPATH/libs.tech/magic/current/sky130A.magicrc -dnull -noconsole  <<EOF
+drc off
+load $1.mag
+select top cell
+expand
+lef write $1.lef 
+quit -noprompt
+EOF
+
+$MAGIC -rcfile $PDKPATH/libs.tech/magic/current/sky130A.magicrc -dnull -noconsole << EOX 
+drc off
+lef read $1.lef
+load $1
+save $1.lef.mag
+#writeall force $1.lef.mag
+
+		# copy GDS properties from the MAG view into the MAGLEF view
+		set gds_properties [list]
+		set fp [open $1.mag r]
+			set mag_lines [split [read \$fp] "\n"]
+			foreach line \$mag_lines {
+				if { [string first "string GDS_" \$line] != -1 } {
+					lappend gds_properties \$line
+				}
+			}
+		close \$fp
+		set fp [open $1.lef.mag r]
+			set mag_lines [split [read \$fp] "\n"]
+			set new_mag_lines [list]
+			foreach line \$mag_lines {
+				if { [string first "<< end >>" \$line] != -1 } {
+					lappend new_mag_lines [join \$gds_properties "\n"]
+				}
+				lappend new_mag_lines \$line
+			}
+		close \$fp
+		set fp [open $1.lef.mag w]
+			puts \$fp [join \$new_mag_lines "\n"]
+		close \$fp
+
+
+quit
+EOX
+
+mv -f $1.lef.mag ../maglef/$1.mag
+rm -f $1.lef
diff --git a/utils/magicDrc b/utils/magicDrc
new file mode 100644
index 0000000..fa6f783
--- /dev/null
+++ b/utils/magicDrc
@@ -0,0 +1,888 @@
+#!/bin/bash
+# SPDX-FileCopyrightText: 2015, 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+#
+# SPDX-License-Identifier: Apache-2.0
+# Copyright (C) 2015, 2020 efabless Corporation. All Rights Reserved.
+# filter out most options, so magic Natively sees/handles *only* -T <file>.
+# for-bash\
+  declare -a C ; declare -a N ; export _CE= _NE= _M0=           ;\
+  for i in "$@" ; do _M0="$_M0${_M0:+ }\"${i//\"/\\\"}\""; done ;\
+  while getopts "NFT:S:l:P:" o; do                      \
+    : echo got "optchar $o, with optarg $OPTARG" ;\
+    case "$o" in S)                               \
+      C+=(-${o} "$OPTARG")                       ;\
+       continue ; esac                           ;\
+    case "$o" in P)                               \
+      C+=(-${o} "$OPTARG")                       ;\
+       continue ; esac                           ;\
+    case "$o" in F|N)                             \
+      C+=(-${o})                                 ;\
+       continue ; esac                           ;\
+    case "$o" in l)                               \
+      C+=(-${o} "$OPTARG")                       ;\
+       continue ; esac                           ;\
+    case "$o" in T)                               \
+      N+=(-${o} "$OPTARG")                       ;\
+       continue ; esac                           ;\
+  done                ;\
+  shift $((OPTIND-1)) ;\
+  for i in "${C[@]}" ; do _CE="$_CE${_CE:+ }\"${i//\"/\\\"}\""; done ;\
+  for i in "${N[@]}" ; do _NE="$_NE${_NE:+ }\"${i//\"/\\\"}\""; done ;\
+  exec magic -dnull -noconsole "${N[@]}" <"$0"
+# for-magic:
+# magicDrc: run magic-DRC in batch on a .mag file, tabulate/pareto the error counts.
+#
+# magicDrc [-T <techfilePath>] [-S <drcStyleName>] [-P <N> ] [-l FILE_NAME] <magFileName>
+#  -T name specific techfile (def .tech extension), passed to magic itself only, overrides tech implied by magFileName
+#  -S if given, changes from techfile's default drc style (perhaps "drc(fast)") to named style, for example: -S "drc(full)"
+#  -l if given, enumerates EVERY individual error bbox to the FILE_NAME
+#  -N if given, do Not use -dereference option of load for topcell (not available in older magics)
+#  -F flatten top cell in-memory only, not saved (experimental)
+#  -P do crude drc performance measurement. At top-cell, do 'drc find' <N> times and report time per call.
+#   Stdout will log a pareto of error type by count regardless.
+#
+# <magFileName>: names a .mag file, the toplevel of the hier. to DRC/pareto
+#
+# Normal magic init. files are STILL sourced: ~/.magicrc and either $CWD/.magicrc or $CWD/magic_setup.
+# (This would NOT happen if -rcfile magic cmd-line option were used).
+#
+# WARNING: Before 8.1.70, *.mag on cmd-line that was only found in cell search path set by .magicrc inits,
+# would FAIL to determine the default tech-file.
+#
+# rb@ef 2015-06-30 author
+# rb 2020-03-11 embed some library functions, to standalone from efabless-opengalaxy env, test via magic-8.2.194
+#
+# magic itself outputs following usage message though -rcfile doesn't appear to work (in some versions):
+#   Usage:  magic [-g gPort] [-d devType] [-m monType] [-i tabletPort] [-D] [-F objFile saveFile]
+#   [-T technology] [-rcfile startupFile | -norcfile][-noconsole] [-nowindow] [-wrapper] [file]
+#
+set Prog "magicDrc"
+
+set argv  [eval "list $env(_M0)"] ;# orig. mix of native plus custom args, for logging all args to script
+
+proc usage {args} {
+    if {[llength $args] > 0} {
+	puts "ERROR: ${::Prog}: [join $args]"
+    }
+    puts {usage: [ -T <techfilePath> ] [-S <drcStyleName>] [-N] [-l FILE_NAME] <magFileName>}
+    puts "  -T name specific techfile, passed to magic itself only, overrides tech implied by magFileName"
+    puts "  -S if given, changes from techfile's default drc style (perhaps \"drc(fast)\") to named style, for example: -S \"drc(full)\""
+    puts "  -l if given, enumerates EVERY individual error bbox to the FILE_NAME"
+    puts "  -N if given, do not use -dereference option of load for topcell (not available in older magics)"
+    puts "  Stdout will log a pareto of error type by count regardless."
+    puts ""
+    puts "  Recommend to run in dir with a ./.magicrc (or ./magic_setup) to configure magic's"
+    puts "  cell search path, thru addpath statements, to locate all cells."
+}
+
+# optionally hardcode library proc-s (part of site-wide extensions - always available - in context of efabless/open-galaxy)
+# This is to make the script more standalone from efabless environment; but these capabilities should be native to magic.
+
+if {[info command scratchWritable] == {}} {
+    puts "${::Prog}: hardcoding library proc-s..."
+# Replacement for 'cellname list exists CELLNAME', to fix ambiguity for cell "0".
+# For cell "0" test for membership in 'cellname list allcells'.
+#
+# Instead of returning 0 for (non-existent) and cellname for exists,
+# returns regular 0/1 instead for non-existent/exists.
+#
+# Therefore NOT direct replacement for uses of 'cellname list exists CELL'.
+# Requires code changes.
+proc cellnameExists {cell} {
+    expr {$cell ne "0" && [cellname list exists $cell] eq $cell ||
+	  $cell eq "0" && [lsearch -exact [cellname list allcells] $cell] > -1}
+}
+
+#
+# scratchWritable [-cleanup] [cellname1 ...] --
+#
+# Turn readonly cells writable in-memory, via redirect to scratch dir.
+# No cellname args: default is to process just all non-writable cells.
+# Explicit cellname arguments: ARE scatchified EVEN if ALREADY writable.
+# Limitation: Explicit named cell created in-mem, never saved, won't scratchify.
+# If just -cleanup: default is to only do cleanup: don't scratchify
+# any cells.
+#
+# -cleanup: Last scratch-dir, if any, and contents are deleted first.
+# No restoring old filepath of cells, save after cleanup will fail.
+#
+# Caller strongly recommended to first do: 'select top cell; expand'
+# to force whole hier. of a topcell to be loaded from disk into memory.
+#
+# This proc does not force expand cells. Before expanded, cells cannot be
+# checked whether writable, and cannot have filepath changed.
+#
+# For batch DRC, for 'drc listall count', every cell in-memory must
+# appear writable.  This is the work-around (caller to 1st ensure
+# hier. is loaded): Reset filepath of readonly cells to a scratch dir,
+# make a dummy/empty .mag in scratch dir for each cell. Change cell's
+# writeable flag.
+#
+# Skipped cells:
+# In all cases, cells are skipped if
+#   'cellname filepath' matches ::scratchWritableDir (already scratchified),
+# This proc does NOT try and force expand; it presumes caller forced an expand
+# thus cells are skipped if:
+#   'cellname filepath' is "default" (can mean not expanded yet, or created never saved),
+#   'cellname filepath' is <CELLNAME>.mag, indicates failed expand (unbound).
+# Note: when filepath gives "default" or <CELLNAME>.mag, the writeable check not meaningful.
+#
+# How to scratchify all in-memory cells (still subject to internal skipping):
+#     scratchWritable {*}[cellname list allcells]
+#
+# TODO: use a combo of filepath & flags likely can detect created in-mem,
+# and could redirect those too scratch dir if named explicitly.
+#
+# Side-effects:
+#   Runs zero or one subprocess, '/bin/mktemp -d' to make a scratch dir.
+#   Redirects where newly modified cells would be saved, if they ever are saved.
+#   Make's a scratch dir that needs to be cleaned-up.
+#   Leaves empty *.mag files in that scratch dir.
+#
+# Uses/requires proc cellnameExists.
+#
+# Same scratch-dir is reused if called multiple times, until next -cleanup.
+#
+# return value: list of cells not processed (skipped) for reasons cited above.
+# Non-existent cells are also skipped but not included in the return list.
+#
+if {![info exists ::scratchWritableDir]} {set ::scratchWritableDir {}}
+if {![info exists ::scratchWritableVerb]} {set ::scratchWritableVerb 0}
+proc scratchWritable {args} {
+    # parse -cleanup option
+    set clean [expr {[lindex $args 0] eq {-cleanup}}]
+    if {$clean} {
+	set args [lrange $args 1 end]
+    }
+
+    # If explicit cells given: don't limit to processing just readOnly cells.
+    set onlyReadonly [expr {$args == {}}]
+
+    # only if no -cleanup, does empty cell list imply all cells
+    set allcell [cellname list allcells]
+    if {!$clean && $args == {}} {
+	set args $allcell
+    }
+
+    # do cleanup
+    if {$clean} {
+	if {$::scratchWritableDir != {} && [file isdir $::scratchWritableDir]} {
+	    set files [glob -dir $::scratchWritableDir -- {*.ext} {*.mag}]
+	    lappend files $::scratchWritableDir
+	    if {$::scratchWritableVerb} {
+		puts "scratchWritable: running, file delete $files"
+	    }
+	    eval {file delete} $files
+	    set ::scratchWritableDir {}
+	}
+    }
+
+    # Filter out non-existent or unbound cells.
+    # Optionally filter already writable cells.
+    #
+    # Unbounds result from placements of cells that now don't exist:
+    # fail to expand.  This proc does not try and force expand; it
+    # presumes a forced expand was already done by caller (if caller
+    # wished).
+    #
+    # Referenced/used cells are initially unexpanded, not yet even located
+    # located in the search path, 'cellname filepath' returns "default".
+    # If expand fails (not found in search path), then 'cellname filepath'
+    # returns <CELLNAME>.mag, if expand worked, the directory containing
+    # the cell.
+    #
+    # If cell was 'cellname create' made, but never saved also "default".
+    # Such a cell is writable. So filter "default" and <CELLNAME>.mag.
+    set skipped {}
+    set ercell1 {}
+    set docells {}
+    foreach cell $args {
+	# filter (without recording as skipped) non-existent cells.
+	if {![cellnameExists $cell]} { continue }
+
+	# filepath = "default": unexpanded (not loaded from disk),
+	# or created in-mem and never saved (is writable already
+	# though flags won't say so): skip both.
+	# TODO: use a combo of filepath & flags likely can detect created in-mem,
+	# and might be able to redirect them too to scratch dir if named explicitly.
+	set tmppath [cellname list filepath $cell]
+	if {$tmppath eq "default"} {
+	    lappend skipped $cell
+	    continue
+	}
+
+	# flags not meaningful, until expanded or expand attempted.
+	# After expand attempt (filepath != "default"), and flags
+	# can now be used to determine cell unbound: not available.
+	set flags   [cellname list flags    $cell]
+	if {[lsearch -exact $flags available] < 0} {
+	    lappend ercell1 $cell
+	    continue
+	}
+
+	if {$onlyReadonly &&
+	    [cellname list writeable $cell] eq "writeable"} {
+	    lappend skipped $cell
+	    continue
+	}
+	lappend docells $cell
+    }
+
+    if {$::scratchWritableVerb} {
+	puts "scratchWritable: skipped cells: $skipped"
+    }
+    
+    # don't make a scratch dir if no work to do
+    if {$docells == {}} {
+	if {$::scratchWritableVerb} {
+	    puts "scratchWritable: scratch-directed 0 cells"
+	}
+	return $skipped
+    }
+
+    # make a scratch dir if needed
+    if {$::scratchWritableDir == {}} {
+	if {[catch {set dir [string trimright [exec /bin/mktemp -d]]} msg]} {
+	    error "ERROR: scratchWritable, '/bin/mktemp -d' failed, $msg"
+	}
+	if {![file isdir $dir] || ![file writable $dir]} {
+	    error "ERROR: scratchWritable, mktemp gave $dir, not a writable dir"
+	}
+	set ::scratchWritableDir $dir
+    }
+
+    set ercell2 {}
+    set okcell {}
+    set madef 0
+    foreach cell $docells {
+	# Relocate if needed: filepath doesn't already point to the scratch dir).
+	# 'cellname list filepath <cellNm>' -> appears to omit .mag extension,
+	# but disk-file needs the .mag in the path.
+	set trgr [file join $::scratchWritableDir "$cell"]      ;# expected "lookup" path
+	set trgw [file join $::scratchWritableDir "$cell.mag"]  ;# true "write" disk path
+	set src [cellname list filepath $cell]
+	if {[cellname list filepath $cell] ne $trgr && [cellname list filepath $cell] ne $trgw} {
+
+	    # make empty .mag for the cell
+	    if {[catch {set outmag [open $trgw w]} msg]} {
+		lappend ercell2 $cell
+		continue
+	    }
+	    incr madef
+	    close $outmag
+
+	    # relocate cell to new file
+	    cellname list filepath $cell $::scratchWritableDir
+	}
+
+	# make cell writable
+	cellname list writeable $cell true
+	lappend okcell $cell
+    }
+
+    if {$::scratchWritableVerb} {
+	puts "scratchWritable: scratch-directed $madef cells"
+    }
+    if {$ercell1 != {} || $ercell2 != {}} {
+	set pre "ERROR: scratchWritable, "
+	set msg {}
+	if {$ercell1 != {}} {
+	    lappend msg "$pre unbound cell(s): $ercell1"
+	}
+	if {$ercell2 != {}} {
+	    lappend msg "$pre failed to make .mag for cell(s): $ercell2"
+	}
+	error [join $msg "\n"]
+    }
+    set skipped
+} ;# end proc scratchWritable
+}
+
+# without top-level proc around bulk of script, intermediate error statements don't abort script.
+proc main {argv} {
+
+# process name-value pair options, if any
+set nbrErr 0
+set ndx 0
+set max [llength $argv]
+set extTechOpt {} ;# -T ...
+set enumFilel  {} ;# -l ... enum output file
+set variant {}    ;# -S ... non-default drc style
+set flatten 0
+set perfN   0     ;# -P <N> do crude DRC perf. test
+set noderef 0     ;# -N disable dereference option of: 'load ... -dereference'
+
+while {$ndx < $max && [string match "-*" [lindex $argv $ndx]]} {
+    set opt [lindex $argv $ndx]
+    incr ndx
+    switch -exact -- $opt {
+	-T {
+	    if {$ndx == $max} {
+		usage "missing tech-file argument for -T option"
+		exit 1
+	    }
+	    set extTechOpt [lindex $argv $ndx]
+	    incr ndx
+	}
+	-S {
+	    if {$ndx == $max} {
+		usage "missing drcStyle argument for -S option"
+		exit 1
+	    }
+	    set variant [lindex $argv $ndx]
+	    incr ndx
+	}
+	-P {
+	    if {$ndx == $max} {
+		usage "missing count argument for -P option"
+		exit 1
+	    }
+	    set perfN [lindex $argv $ndx]
+	    incr ndx
+	}
+	-F {
+	    set flatten 1
+	}
+	-N {
+	    set noderef 1
+	}
+	-l {
+	    if {$ndx == $max} {
+		usage "missing outputFile argument for -l option"
+		exit 1
+	    }
+	    set enumFilel [lindex $argv $ndx]
+	    incr ndx
+	    if {[catch {set enumOut [open $enumFilel w]} msg]} {
+		error "ERROR: ${::Prog}: failed to open-for-write '$enumFilel' threw error, $msg"
+	    }
+	    puts "${::Prog}: enumerating each error bbox to: $enumFilel"
+	}
+	default {
+	    usage "unknown option: $opt"
+	    exit 1
+	}
+    }
+}
+
+if {$ndx == $max} {
+    usage "missing magFileName argument, the topcell"
+    exit 1
+}
+
+# get cmd-line topcell, minus dir-path; and minus extension IFF ext is .mag
+set topc [file tail [lindex $argv $ndx]] ; incr ndx
+if {[file extension $topc] eq ".mag"} {
+    set topc [file rootname $topc]
+}
+set topcStr $topc
+
+# abort if user supplies extra args.
+if {$ndx != $max} {
+    usage "extra/unspported arg past magFileName, '[lindex $argv $ndx]'"
+    exit 1
+}
+
+# load the techfile
+if {$extTechOpt != ""} {
+    if {![file readable $extTechOpt]} {
+	error "ERROR: ${::Prog}: tech-file \"$extTechOpt\" is not readable."
+    }
+
+    tech load $extTechOpt
+    
+    # Verify the cmd-line -T option (if any) is still the current 'tech filename'. If we didn't
+    # explicitly 'tech load' ourselves, the .magicrc or magic.setup might 'tech load' something else.
+    # The 'file join [pwd] ...' makes relative path absolute, but without resolving
+    # all symlinks (which 'file normalize' would do).
+    set techf2 [file join [pwd] [tech filename]]
+    set techf1 [file join [pwd]     $extTechOpt]
+    if {$techf1 != $techf2} {
+	error "ERROR: ${::Prog}: failed tech-load \"$techf1\" (tech-filename=\"$techf2\" not a match)"
+    }
+}
+
+# if mag-cell were passed natively on magic cmd-line, this is too late:
+if {$noderef} {
+    load $topc
+} else {
+    load $topc -dereference
+}
+
+# error checks: ensure (1st) cmd-line cellname now in-memory, and is now the current cell
+
+set topcells [cellname list top]
+# filter (UNNAMED)
+set topcells [lsearch -exact -not -all -inline $topcells "(UNNAMED)"]
+# puts "cellname-list-top is: $topcells"
+
+# could use [cellname list flags $topc] and ensure non-null result (list with available),
+# but if it fails (cell not found), it generates unwanted stdout.
+if {[lsearch -exact [cellname list allcells] $topc] < 0} {
+    error "ERROR: ${::Prog}: cmd-line topcell \"$topc\" not in magic's list of allcells."
+}
+
+if {[lsearch -exact $topcells $topc] < 0} {
+    puts "WARNING: ${::Prog}: cmd-line topcell \"$topc\" not in magic's list of topcells: $topcells"
+}
+
+# crude way even in batch to determine the "current" cell; perhaps not yet the "Edit" cell
+# WARNING, if topcell locked elsewhere or not writable, it can't become the "Edit" cell.
+set topcw [cellname list window]
+if {$topcw ne $topc} {
+    error "ERROR: ${::Prog}: cmd-line topcell, $topc, is not the current cell, 'cellname list window'=$topcw"
+}
+
+# for topcell, filepath==default doesn't change by expand,
+# indicates unknown cell created in-memory by magic's startup sequence.
+if {[cellnameExists         $topc] &&
+    [cellname list filepath $topc] eq "default"} {
+    puts "Search path for cells is \"[path search]\""
+    error "ERROR: ${::Prog}: cmd-line topcell, $topc, auto-created in-memory: not found in cell search path"
+}
+
+if {$flatten} {
+    # delete (UNNAMED) if any.
+    set trg "(UNNAMED)"
+    if {[cellnameExists $trg]} {cellname delete $trg}
+
+    # rename top cell to (UNNAMED)
+    cellname rename $topc $trg
+
+    # now Edit Cell contents are original top cell, but under name (UNNAMED)
+    # flatten Edit-Cell into original top cell name
+    puts "${::Prog}: flattening..."
+    flatten $topc
+
+    # load and edit new version of top cell. This is from in-memory, just making it current-cell.
+    # (So with or without -dereference is expected would have discernable effect by now;
+    # and since it's flattened there are no subcell instances either).
+    if {$noderef} {
+	load $topc
+    } else {
+	load $topc -dereference
+    }
+
+    # crude way even in batch to determine the "current" cell; perhaps not yet the "Edit" cell
+    # WARNING, if topcell locked elsewhere or not writable, it can't become the "Edit" cell.
+    set topcw [cellname list window]
+    if {$topcw ne $topc} {
+	error "ERROR: ${::Prog}: assertion failed, post-flatten, $topc, is not the current cell, 'cellname list window'=$topcw"
+    }
+
+    # should not be necessary:
+    select top cell
+    edit
+
+    # crude way even in batch to determine the "current" cell; perhaps not yet the "Edit" cell
+    # WARNING, if topcell locked elsewhere or not writable, it can't become the "Edit" cell.
+    set topcw [cellname list window]
+    if {$topcw ne $topc} {
+	error "ERROR: ${::Prog}: assertion-2 failed, post-flatten, $topc, is not the current cell, 'cellname list window'=$topcw"
+    }
+}
+
+# todo: Need a check for non-existent topcell (though magic reported not-found and auto-created it).
+# todo: We should locate fullpath to topcell on disk to record this in the log.
+#
+# WARNING, magic junkCell, or magic junkDir/junkCell (passing paths to cells that don't exist),
+# generate startup error messages (could not open cell), but magic creates the new cell in memory.
+# No simple way to detect this after the fact. Can walk the cell search path to verify it's on disk.
+# For the non-existent cell, magic also discards the dirpath from the cmd-line arg.
+# If it did exist at that path, magic opens it successfully, despite that dir not in search path.
+# A proper check for implicit create of non-existent cell should account for this effect too.
+
+# write a line with timestamp and all arguments to stdout (log)
+# (magic renames the TCL clock command)
+set clockp clock
+if {[info command $clockp] == {} && [info command orig_clock] != {}} {
+    set clockp orig_clock
+}
+set nowSec [$clockp seconds]
+set timestamp [$clockp format $nowSec -format "%Y-%m-%d.%T.%Z"]
+# Show quoted logged argv here so it's machine readable for replay purposes.
+puts "${::Prog}: timestamp: $timestamp, arguments: $::env(_M0)"
+
+puts "${::Prog}: running drc on topcell: $topcStr"
+puts "${::Prog}: tech-name: [tech name] -version: [tech version] -filename: [tech filename] -lambda [tech lambda]"
+
+# log the cell search path for this run. Emulates format output by plain "path" (but which prints more than one the cell search path).
+puts "Search path for cells is \"[path search]\""
+
+set res {}
+if {$variant != {}} {
+    if {[catch {set res [drc list style $variant]} msg]} {
+	puts "ERROR: ${::Prog}: but CONTINUING, 'drc style $variant' threw error, $msg"
+    }
+} else {
+    if {[catch {set res [drc list style]} msg]} {
+	puts "ERROR: ${::Prog}: but CONTINUING, 'drc list style' threw error, $msg"
+    }
+}
+if {$res != {}} {
+    puts "drc style reports:\n$res"
+}
+
+# just Manhattan is default, turn on euclidean, and log new mode
+drc euclidean on
+drc euclidean
+
+# 1st "select top cell": without it drc-list-count is blank, and error count reduced.
+# May be unnecessary in some cases.
+# WARNING: if topcell locked by another process, default box is NOT set to full top cell without this (as of 8.1.70 or earlier)
+select top cell
+# expand cell cells: scratchify step requires this up front else can't force all cells writable.
+expand
+
+# The expand triggered load of all subcells. Till then allcells may be incomplete.
+set allcells [cellname list allcells]
+# filter (UNNAMED)
+set allcells [lsearch -exact -not -all -inline $allcells "(UNNAMED)"]
+set nbrAllCells [llength $allcells]
+# puts "DEBUG: cellname-list-allcells are: $allcells"
+
+# TODO: do explicit separate unbound check here (don't rely on scratchWritable for this)
+
+# make allcells writable. Can error out:
+# if are unbounds, or couldn't make scratch dir or .mag files.
+set scratch [expr {!$flatten}]
+if {$scratch && [catch {scratchWritable} msg]} {
+    puts stderr "ERROR: ${::Prog}: aborting at scratchWritable due error(s):"
+    error $msg
+}
+
+# Erase all preexisting *.drtcl first. Else when cell transitions from
+# dirty in previous run (leaving *.drtcl), to clean, the old *.drtcl
+# remains.
+# TODO: only delete *.drtcl of cells in 'cellname list allcells'?
+# TODO: move this up, before scratchWritable?
+set files [glob -nocomplain -types {f} -- ./*.drtcl]
+if {$files != {}} {
+    # TODO: detect/report failure details better here?
+    puts "${::Prog}: deleting preexisting *.drtcl"
+    set msg {}
+    set delfail [catch {eval {file delete} $files} msg]
+    set files [glob -nocomplain -types {f} -- ./*.drtcl]
+    if {$delfail || $files != {}} {
+	puts "ERROR: ${::Prog}: failed to clean old ./*.drtcl files. $msg"
+	incr nbrErr
+    }
+}
+
+edit ;# Fails if topcell not writable, should not be not needed post scratchWritable
+
+set outScale [cif scale out]
+
+# "select top cell" and box [view bbox] should be equivalent in
+# placing a box around whole cell extent.
+# The box cmd ALSO prints lambda and micron user-friendly box data,
+# but it prints microns with not enough resolution,
+# (and no option to disable that flawed print out).
+#
+# todo: emulate box output in full, except for higher resolution,
+# here we only scale/print the overall bbox in microns.
+# select top cell       ;# paranoid, reset the box to data extents post-expand
+# set bbox [view bbox]
+# set bbs {}
+# foreach oord $bbox {
+#     lappend bbs [format "%.3f" [expr {$outScale * $oord}]]
+# }
+# puts "outScale: $outScale, view-bbox: $bbox"
+# puts "Root cell box2: ([lindex $bbs 0]  [lindex $bbs 1]), ([lindex $bbs 2]  [lindex $bbs 3])"
+
+# shouldn't need:
+# drc on
+
+# Want to use 'drc list count' to tell us which cells have errors, so we can
+# run 'drc listall why' on just those cells to enumerate details (which reruns
+# drc again unfortunately).
+
+# For accurate DRC (as of 8.1.70), specifically 'drc list count', need:
+# all-writable cells, then run: 'drc check' & 'drc catchup'.
+# Now we have all writable cells.
+set timeRepeat 1
+if {$perfN > 0} {
+    set timeRepeat $perfN
+}
+set timeres [time {
+    set drcCheckTime1 [time {drc check}]
+    set drcCheckTime2 [time {drc catchup}] } $timeRepeat]
+
+if {$perfN > 0} {
+    puts "perf: ${perfN}X 'drc check','drc catchup': $timeres"
+    puts "perf: last 'drc check' time: $drcCheckTime1"
+    puts "perf: last 'drc catchup' time: $drcCheckTime2"
+    drc statistics
+    drc rulestats
+}
+
+# todo: this 2nd select was in GDS version, test if needed in mag version:
+# 2nd select top cell needed else error count may be reduced (why? bbox does not change due to DRC)
+select top cell
+set outScale [cif scale out]
+set bbox [view bbox]
+set bbs {}
+foreach oord $bbox {
+    lappend bbs [format "%.3f" [expr {$outScale * $oord}]]
+}
+puts "outScale(ostyle=[cif list ostyle]): $outScale, view-bbox: $bbox"
+puts "Root cell box: ([lindex $bbs 0]  [lindex $bbs 1]), ([lindex $bbs 2]  [lindex $bbs 3])"
+# print several native bbox representations:
+box
+
+# listall vs list appear same as of 8.1.70 or earlier.
+# warning: celllist order is not stable, not repeatable; run to run on same data.
+# puts "DEBUG: (drc listall count total) is $drcListCountTot"
+set celllist [drc listall count]
+set celllist [lsearch -not -all -inline -index 0 -exact $celllist "(UNNAMED)"]
+# puts "DEBUG: (drc listall count) is [drc listall count]"
+set drcListCountTot [drc list count total]
+set nbrErrCells [llength $celllist]
+
+# TODO: major problem: 'drc listall why' repeated an every cell, will do subcells
+# multiple times, as many times as their depth in the hier.
+
+# canonicalize order of celllist, move topc to last (if present whatsoever).
+# force our own artificial entry for topc (zero errors) if not present (was clean)
+# puts "DEBUG: celllist before: $celllist"
+set topcPair [lsearch           -inline -index 0 -exact $celllist $topc]
+set celllist [lsearch -not -all -inline -index 0 -exact $celllist $topc]
+set celllist [lsort -index 0 -dictionary $celllist]
+if {$topcPair == {}} {
+    # puts "DEBUG: $topc clean, forcing celllist entry for it"
+    set topcPair [list $topc 0]
+}
+lappend celllist $topcPair
+# puts "DEBUG: celllist after: $celllist"
+# puts "DEBUG: adjusted celllist(drc list count) is $celllist"
+
+# loop over celllist
+set doFeedback 1 ;# TODO: add cmd-line option to control this
+
+# collect 'dry listall why' for the cells in 'cell list count' with non-zero errors
+# If 'drc listall why' does report zero (shouldn't since we're only processing cells
+# with non-zero counts), it unavoidably writes to console a No drc errors found message.
+# We don't want such polluting our list of per-cell pareto's, so don't risk running
+# drc why in-line, in-between per-cell paretos.
+array set cell2why [list $topc {}] ;# default at least empty topcell why list
+foreach pair $celllist {
+    if {[lindex $pair 1] < 1} {continue} ;# only happens for topcell if topcell clean
+    set acell [lindex $pair 0]
+
+    # TODO: magic needs a useful error checkable load command.
+    # The 'load' writes errors to console/stdout, but never throws an error,
+    # nor gives a useful return value. i.e. These catch never catch.
+    if {$noderef} {
+	if {[catch {set res [load $acell]} msg]} {
+	    puts "ERROR: ${::Prog}: 'load $acell' threw error, $msg"
+	    exit 1
+	}
+    } else {
+	if {[catch {set res [load $acell -dereference]} msg]} {
+	    puts "ERROR: ${::Prog}: 'load $acell -dereference' threw error, $msg"
+	    exit 1
+	}
+    }
+    select top cell ;# paranoid, that without it, drc's are reduced
+
+    # optionally do crude DRC perf. analysis here. Only for top-cell, only if -P <N> option given.
+    set timeRepeat 1
+    if {$perfN > 0 && $topc eq $acell} {
+	set timeRepeat $perfN
+    }
+    set timeres [time {set cell2why($acell) [drc listall why]} $timeRepeat]
+    if {$perfN > 0 && $topc eq $acell} {
+	puts "perf: ${::Prog}: for '$acell', ${perfN}X 'drc listall why': $timeres"
+    }
+}
+
+# done with all magic-specifics here. Shouldn't need scratch dir any longer.
+# If this prints something (generally does), don't want it after the pareto table.
+
+# clean/remove the tmp scratch dir and contents
+# TODO: all fatal errors need to call a cleanup proc that includes this before abort
+if {$scratch && [catch {scratchWritable -cleanup} msg]} {
+    puts "ERROR: ${::Prog}: 'scratchWritable -cleanup' threw error, $msg"
+    incr nbrErr
+}
+
+set gtotal 0
+set gcells 0
+foreach pair $celllist {
+    puts ""
+    set acell [lindex $pair 0]
+    if {![info exists cell2why($acell)]} {
+	puts "ERROR: ${::Prog}: cell: $acell, assertion failed, no drc-why list for 'drc list count' pair: $pair"
+	# exit 1
+	continue
+    }
+    set whys $cell2why($acell)
+
+    # enumerate errors under box, plain "drc why" only reports unique types, no quantities
+    # as-yet-undocumented "drc listall why" gives: {errStr1 {errBox1 ...} errStr2 {errBox1 ...} ... }
+    set pareto {}
+    set total 0
+    set enumTotal 0
+    set types 0
+    set typeDup 0
+    set dups 0
+
+    set fbOut {}
+    # file path for feedback, keep in CWD
+    if {$doFeedback && $fbOut == {}} {
+	set fbOut "./$acell.drtcl"
+	if {![file writable $fbOut] &&
+	    ([file exists $fbOut] || ![file writable [file dir $fbOut]])} {
+	    puts stderr "ERROR: ${::Prog}: feedback output not writable, $fbOut"
+	    incr nbrErr
+	    set fbOut {}
+	} elseif {[catch {set outfb [open $fbOut w]} msg]} {
+	    puts stderr "ERROR: ${::Prog}: failed to truncate previous feedback output, $fbOut : $msg"
+	    incr nbrErr
+	    set fbOut {}
+	}
+    }
+    foreach {str boxes} $whys {
+	# sort errors
+	set boxes [lsort -dictionary $boxes]
+
+	# for our pareto, gather data
+	set this [llength $boxes]
+	incr total $this
+	incr types
+	lappend pareto [list $this $str]
+
+	# for enumOut, emulate formatting of $CAD_ROOT/magic/tcl/drc.tcl, which is
+	# not tk pure: fails with complaint about winfo
+	# note: we walk these errors also in order to count/report stats on duplicates, even if not outputing enumerations
+	if {[info exists enumOut]} {
+	    if {$types == 1} {
+		puts $enumOut "[join $pair]\n----------------------------------------"
+	    }
+	    puts $enumOut "${str}\n----------------------------------------"
+	}
+	set lastq {}
+	set thisDup 0
+	foreach quad $boxes {
+	    set quadUM {}
+	    foreach coord $quad {
+		set valum [expr {$coord * $outScale}]
+		set valumf [format "%.3f" $valum]
+		lappend quadUM "${valumf}um"
+	    }
+	    set dup [expr {$quad == $lastq}]
+	    incr thisDup $dup
+	    set line $quadUM
+	    if {[info exists enumOut]} {
+		if {$dup} {
+		    puts $enumOut "[join $line] #dup"
+		} else {
+		    puts $enumOut [join $line]
+		}
+	    }
+	    if {$fbOut != {}} {
+		set line [join $quadUM]
+		regsub -all -- "(\[\[\"\$\\\\])" $str {\\\1} strdq
+		puts $outfb "[concat box $line]"                nonewline
+		puts $outfb " ; feedback add \"$strdq\" medium" nonewline
+		if {$dup} {
+		    puts $outfb " ;#dup"
+		} else {
+		    puts $outfb ""
+		}
+	    }
+
+	    incr enumTotal
+	    set lastq $quad
+	}
+	if {$thisDup} {
+	    incr typeDup
+	    incr dups $thisDup
+	}
+	if {[info exists enumOut]} {
+	    puts $enumOut "----------------------------------------\n"
+	}
+    }
+
+    if {$fbOut != {}} {
+	close $outfb
+	set outfb {}
+    }
+
+    set pareto [lsort -integer -decreasing -index 0 $pareto]
+    if {$total > 0} {
+	puts "--- #err|description, table for cell: $acell"
+    }
+    foreach pair $pareto {
+	puts "[format {%8d} [lindex $pair 0]] [lindex $pair 1]"
+    }
+    if {$typeDup} {
+	puts "[format {%8d} $dups] total duplicate error(s) among $typeDup error type(s), cell: $acell"
+    }
+    puts "[format {%8d} $total] total error(s) among $types error type(s), cell: $acell"
+    # add to grand-totals
+    incr gcells
+    incr gtotal $total
+
+    # always compare the total from the enum to the pareto as error check
+    if {$total != $enumTotal} {
+	puts "ERROR: ${::Prog}: cell: $acell, assertion failed, pareto vs enum count mismatch: $total != $enumTotal"
+	incr nbrErr
+    }
+}
+
+# TODO: in the summary echo also techfile-full-path and drc-style name?
+# grand totals
+puts "[format {%8d} $nbrErrCells] of $nbrAllCells cell(s) report error(s)"
+puts "[format {%8d} $gtotal] grand-total error(s) across $gcells cell(s)"
+
+# wish to compare the drc-list-count-total to the pareto total.
+# Per te 2014-08-27 : it is not an error.
+# if {$total != $drcListCountTot} {
+#   puts "info: ${::Prog}: drc-list-count-total vs drc-listall-why mismatch {drc list count total} gave $drcListCountTot, but {drc listall why} gave $total"
+# }
+
+if {[info exists enumOut]} {
+    close $enumOut
+}
+
+# set celllist4 [drc list count]
+# puts "DEBUG: drc list count0: $celllist0"
+# puts "DEBUG: drc list count1: $celllist1"
+# puts "DEBUG: drc list count2: $celllist2"
+# puts "DEBUG: drc list count3: $celllist3"
+# puts "DEBUG: native (drc list count) is $celllistn"
+# puts "DEBUG: drc list count4: $celllist4"
+
+# todo: implement super-pareto, ranked table of SUM of all DRC errs/counts from ALL cells.
+# (It still would not reflect as-if-flat hierarchical expansion due to repetition of instances).
+
+set nbrErr
+}
+
+# non-zero exit-status on errors, either if thrown by main, or counted and returned by main
+set nbrErr 0
+if {[catch {set nbrErr [main $argv]} msg]} {
+    puts stderr $msg
+    set nbrErr 1
+} elseif {$nbrErr > 0} {
+    puts "ERROR: ${::Prog}: script terminated with errors reported above."
+}
+exit $nbrErr
+
+# for emacs syntax-mode:
+# Local Variables:
+# mode:tcl
+# End:
diff --git a/utils/magicGdrc b/utils/magicGdrc
new file mode 100644
index 0000000..88280ee
--- /dev/null
+++ b/utils/magicGdrc
@@ -0,0 +1,911 @@
+#!/bin/sh
+# SPDX-FileCopyrightText: 2014, 2015, 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+#
+# SPDX-License-Identifier: Apache-2.0
+# Copyright (C) 2014, 2015, 2020 efabless Corporation. All Rights Reserved.
+# send a very-first -T FILE to magic's startup, hide all other args from magic-startup
+# for-bash\
+  export _M0= ;\
+  for i in "$@" ; do _M0="$_M0${_M0:+ }\"${i//\"/\\\"}\""; done ;\
+  case "$1" in -T) tch="$2"; shift; shift; _MARGS="$*" exec magic -dnull -noconsole -T "$tch" <"$0" ;; esac
+# hide next line from magic(tclsh):\
+_MARGS="$*" exec magic -dnull -noconsole <"$0"
+#
+# magicDRC: run magic-DRC in batch on a GDS file, tabulate/pareto the error counts.
+# 
+# rb@ef 2014-08-28 author
+# rb 2020-02-19 embed some library functions, to standalone from efabless-opengalaxy env, test via magic-8.2.188
+#
+# todo: support "-" as GDS file arg, to mean GDS from stdin
+#
+
+set ::Prog "magicGdrc"
+set argv  [eval "list $env(_M0)"] ;# orig. mix of native plus custom args, for logging all args to script
+# set argv [split $env(_MARGS)]   ;# (currently unused)
+
+proc usage {args} {
+    if {[llength $args] > 0} {
+	puts "ERROR: ${::Prog}: [join $args]"
+    }
+    puts {usage: [ -T techfilePath ] [-S <drcStyleName>]  [-I <cifIStyleName>] [-km FILE_NAME] [-l FILE_NAME] [-L FILE_NAME] gdsFileName [topCellName]}
+    puts "  -T if given, must be very first"
+    puts "  -S if given, changes from techfile's default/1st drc style (perhaps \"drc(fast)\") to named style, for example: -S \"drc(full)\""
+    puts "  -I if given, changes from techfile's default/1st cifinput style (perhaps \"vendorimport\" or \"import(exact)\") to named style, for example: -I \"import(magic)\""
+    puts "  -path-sub do 'gds path    subcell yes' (default:no). Make unique subcell for each path: cut #tiles cost of angles."
+    puts "  -poly-sub do 'gds polygon subcell yes' (default:no). Make unique subcell for each polygon: cut #tiles cost of angles."
+# gds polygon subcell [yes|no]
+    puts "  -pps  Short hand, equivalent to giving both: -path-sub -poly-sub"
+    puts ""
+    puts "  Error tabulation: By default (slowest, most detail): Report table of counts-by-errorString for all cells."
+    puts "  Stdout logs a pareto of error-type by count unless disabled for some/all cells by below; topcell last."
+    puts "  -tt Table of counts-by-errorString for ONLY topcell; and just lumped total error count per subcell."
+    puts "  -tc Just lumped error counts per cell including topcell (fastest, least detail)."
+    puts "  Cells NOT tabulating count-by-errorString can't appear in other output error files: feedback(*.drtcl), -l, -km."
+    puts "  For lumped error counts, overlapped error shapes from unique error-types are merged further reducing count."
+    puts ""
+    puts "  cell-type +--    (default)     --+--  option -tt      --+--   option -tc"
+    puts "    subcell | count-by-errorString |   lumped-error-count | lumped-error-count"
+    puts "    topcell | count-by-errorString | count-by-errorString | lumped-error-count"
+    puts ""
+    puts "  -km if given, write to FILE_NAME EVERY individual error bbox (MICRONS) in klayout Marker database(XML) format (suggest *.lyrdb)"
+    puts "  -l if given, enumerates EVERY individual error bbox (MICRONS) to FILE_NAME, emulates $::CAD_ROOT/magic/tcl/drc.tcl"
+    puts "  -L same as -l above, but outputs bbox-es in LAMBDA coordinates, not microns"
+    puts "  -nf  Do NOT write *.drtcl per-cell feedback files. Can be source-ed in magic and step thru: feedback find."
+    puts ""
+    puts "  NOTES: Without explicit tech-file option: the ./.magicrc or ./magic_setup and ~/.magicrc may load a default tech-file."
+    puts "  Therefore the tech-file used CAN depend on whether your CWD is ~/design/<CURRENT_DESIGN>/mag when running this script."
+    puts "  Since no *.mag are loaded by this script: the cell search path defined by any init files has no impact."
+    puts "  Since about 8.3.68, magic may generate error-type \"See error definition in the subcell\". There typically are"
+    puts "  redundancies of errors across the hierarchy anyway (but with tech-file err-strings), this seems another form."
+    puts ""
+    puts "example, just list all styles: by causing an error which provokes usage report:"
+    puts "    magicGdrc -T /ef/tech/XFAB/EFXH035B/libs.tech/magic/current/EFXH035B.tech"
+    puts "example, same but run in a ~/design/*/mag/ dir, so techfile set by ./.magicrc (else magic's builtin minimum.tech):"
+    puts "    magicGdrc"
+    puts "example, run GDS drc, explicit: tech, cif-istyle, drc-style:"
+    puts "    magicGdrc -T /ef/tech/SW/EFS8A/libs.tech/magic/current/EFS8A.tech -I vendorimport -S 'drc(full)' /tmp/mytop.gds mytopcell"
+    puts "example, run GDS drc, default tech & styles, write klayout marker database, no per-cell *.drtcl feedback files:"
+    puts "    magicGdrc -km /tmp/mytop.lyrdb -nf /tmp/mytop.gds mytopcell"
+    puts "example, same but make subcells for paths & polygons"
+    puts "    magicGdrc -km /tmp/mytop.lyrdb -nf -pps /tmp/mytop.gds mytopcell"
+    puts "example, run GDS drc, no feedback (*.drtcl), only lumped/merged err-count for all cells"
+    puts "    magicGdrc -tc /tmp/mytop.gds mytopcell"
+    puts "example, run GDS drc, no feedback (*.drtcl), lumped/merged err-count for subcells, detail errors for topcell"
+    puts "    magicGdrc -nf -tt /tmp/mytop.gds mytopcell"
+    puts ""
+
+    reportTechFile
+    reportAllStyles
+    puts ""
+
+    if {[llength $args] > 0} {
+	puts "ERROR: ${::Prog}: [join $args]"
+    }
+}
+proc gdsChk {file} {
+    foreach suffix {"" ".gds" ".gds2" ".strm"} {
+	if {[file readable "${file}${suffix}"]} {return 1}
+    }
+    puts "ERROR: ${::Prog}: Cannot open (as-is or with .gds, .gds2, or .strm) to read GDS-II stream from: $file"
+    exit 1
+}
+
+proc reportTechFile {} {
+    puts "${::Prog}: tech-name: [tech name] -version: [tech version] -filename: [tech filename] -lambda [tech lambda]"
+}
+
+# query currently loaded tech-file for styles the user might need for -I -S options
+# Suggest a bad tech-file if none are found or errors thrown.
+# Used after finding error in -I -S options, and probably should add it to the usage.
+proc reportAllStyles {} {
+    set errs {}
+    if {[catch {set allstyle [cif listall istyle]} msg]} {
+	lappend errs "ERROR: ${::Prog}: bad tech-file? failed to 'cif listall istyle', $msg"
+    } elseif {$allstyle == {}} {
+	lappend errs "ERROR: ${::Prog}: bad tech-file? no cifinput styles found by 'cif listall istyle'"
+    } else {
+	puts "info: ${::Prog}: cifinput styles available: $allstyle"
+    }
+    if {[catch {set allstyle [drc listall style]} msg]} {
+	lappend errs "ERROR: ${::Prog}: bad tech-file? failed to 'drc listall style', $msg"
+    } elseif {$allstyle == {}} {
+	lappend errs "ERROR: ${::Prog}: bad tech-file? no drc styles found by 'drc listall style'"
+    } else {
+	puts "info: ${::Prog}: drc styles available: $allstyle"
+    }
+    if {$errs != {}} {
+
+    }
+    return [llength $errs]
+}
+
+# optionally hardcode library proc-s (part of site-wide extensions - always available - in context of efabless/open-galaxy)
+# This is to make the script more standalone from efabless environment; but these capabilities should be native to magic.
+
+if {[info command unbounds] == {}} {
+    puts "${::Prog}: hardcoding library proc-s..."
+# Replacement for 'cellname list exists CELLNAME', to fix ambiguity for cell "0".
+# For cell "0" test for membership in 'cellname list allcells'.
+#
+# Instead of returning 0 for (non-existent) and cellname for exists,
+# returns regular 0/1 instead for non-existent/exists.
+#
+# Therefore NOT direct replacement for uses of 'cellname list exists CELL'.
+# Requires code changes.
+proc cellnameExists {cell} {
+    expr {$cell ne "0" && [cellname list exists $cell] eq $cell ||
+	  $cell eq "0" && [lsearch -exact [cellname list allcells] $cell] > -1}
+}
+
+# Walk allcells to get/return list of cellNames that are unbound.
+# Only use this after: 'select top cell; expand' to expand whole hierarchy.
+#
+# foreach CELL in 'cellname list allcells':
+#   if flags says available : it's Bound, goto next cell.
+#   if filepath is "default", try to expand the cell.
+#   if still "default"**: cell made by "cellname create", never saved, goto next.
+#   if filepath is CELL.mag, check for "available" flags, if none: Unbound.
+#   else cell is bound.
+#   **: should never get there
+proc unbounds {} {
+    set allcells [cellname list allcells]
+    # filter (UNNAMED)
+    set allcells [lsearch -exact -not -all -inline $allcells "(UNNAMED)"]
+    # set nbrAllCells [llength $allcells]
+    set ercell {}
+    foreach cell $allcells {
+	# filter (without recording as skipped) non-existent cells.
+	if {![cellnameExists $cell]} { continue }
+
+	# filepath = "default": unexpanded (not loaded from disk),
+	# or created in-mem and never saved (is writable already
+	# though flags won't say so): skip both.
+	# TODO: use a combo of filepath & flags likely can detect created in-mem
+	set tmppath [cellname list filepath $cell]
+	if {$tmppath eq "default"} {
+	    lappend skipped $cell
+	    continue
+	}
+
+	# flags not meaningful, until expanded or expand attempted.
+	# After expand attempt (filepath != "default"), and flags
+	# can now be used to determine cell unbound: not available.
+	set flags   [cellname list flags    $cell]
+	if {[lsearch -exact $flags available] < 0} {
+	    lappend ercell $cell
+	    continue
+	}
+    }
+    set ercell ;# return list of unbound cells, if any
+}
+}
+
+# without top-level proc around bulk of script, intermediate error statements don't abort script.
+proc main {argv} {
+
+set mlen [llength $argv]
+
+# process name-value pair options, if any
+set nbrErr 0
+set ndx 0
+set max [llength $argv]
+set extTechOpt {} ;# -T ... but not used here
+set enumFilel  {} ;# -l ... enum output file
+set enumFileL  {} ;# -L ... enum output file
+set enumFileKm {} ;# -km ... enum output file
+set variant {}    ;# -S ... non-default drc style
+set istyle  {}    ;# -I ... non-default cifinput style
+set doFeedback 1  ;# -nf sets to 0: Do not write *.drtcl per-cell feedback files.
+set pathSub 0     ;# -path-sub ... do 'gds path    subcell yes'
+set polySub 0     ;# -poly-sub ... do 'gds polygon subcell yes'
+set subcellTab 1  ;# -tt, -tc both turn OFF subcell count-by-error report
+set topcellTab 1  ;#      -tc     turns OFF topcell count-by-error report
+set flatten 0
+while {$ndx < $max && [string match "-*" [lindex $argv $ndx]]} {
+    set opt [lindex $argv $ndx]
+    incr ndx
+    switch -exact -- $opt {
+	-T {
+	    if {$ndx != 1} {
+		usage "-T option must very 1st (here was #$ndx)"
+		exit 1
+	    }
+	    if {$ndx == $max} {
+		usage "missing tech-file argument for -T option"
+		exit 1
+	    }
+	    set extTechOpt [lindex $argv $ndx] ;# unused
+	    incr ndx
+	}
+	-S {
+	    if {$ndx == $max} {
+		usage "missing drcStyle argument for -S option"
+		exit 1
+	    }
+	    set variant [lindex $argv $ndx]
+	    incr ndx
+	}
+	-I {
+	    if {$ndx == $max} {
+		usage "missing cifinput-style argument for -I option"
+		exit 1
+	    }
+	    set istyle [lindex $argv $ndx]
+	    incr ndx
+	}
+	-F        { set flatten     1}
+	-nf       { set doFeedback 0 }
+	-path-sub { set pathSub     1}
+	-poly-sub { set polySub     1}
+	-pps      { set pathSub     1; set polySub     1}
+	-tt       { set subcellTab 0 ; set topcellTab  1}
+	-tc       { set subcellTab 0 ; set topcellTab 0 }
+	-km {
+	    if {$ndx == $max} {
+		usage "missing outputFile argument for -km option"
+		exit 1
+	    }
+	    set enumFileKm [lindex $argv $ndx]
+	    incr ndx
+	}
+	-l {
+	    if {$ndx == $max} {
+		usage "missing outputFile argument for -l option"
+		exit 1
+	    }
+	    set enumFilel [lindex $argv $ndx]
+	    incr ndx
+	    if {[catch {set enumOut [open $enumFilel w]} msg]} {
+		error "ERROR: ${::Prog}: failed to open-for-write '$enumFilel' threw error, $msg"
+	    }
+	    puts "${::Prog}: enumerating each error bbox to: $enumFilel"
+	}
+	-L {
+	    if {$ndx == $max} {
+		usage "missing outputFile argument for -L option"
+		exit 1
+	    }
+	    set enumFileL [lindex $argv $ndx]
+	    incr ndx
+	    if {[catch {set enumOutL [open $enumFileL w]} msg]} {
+		error "ERROR: ${::Prog}: failed to open-for-write '$enumFileL' threw error, $msg"
+	    }
+	    puts "${::Prog}: enumerating each error bbox to: $enumFileL"
+	}
+	default {
+	    usage "unknown option: $opt"
+	    exit 1
+	}
+    }
+}
+
+if {$ndx == $max} {
+    usage {Insufficient number of arguments, need gdsFileName [topCellName]}
+    exit 1
+}
+
+set gdsf [lindex $argv $ndx] ; incr ndx
+set topc {}
+set topcStr "(AUTO)"
+if {$ndx < $max} {
+    set topc [lindex $argv $ndx] ; incr ndx
+    set topcStr $topc
+}
+# error if extra options (not understood, something is wrong):
+if {$ndx < $max} {
+    error "ERROR: ${::Prog}: after gdsFile=\"$gdsf\", topcell=\"$topc\" found unsupported extra arguments: [lrange $argv $ndx end]"
+}
+# ndx no longer used for argv position from here
+
+gdsChk $gdsf
+
+# warning on combo of -tc & -km. If -km ok, open its output file.
+if {$enumFileKm ne {}} {
+    if {! $topcellTab} {
+	    puts "WARNING: ${::Prog}: with -tc cannot (-km) write klayout-marker-db"
+    } else {	
+	if {[catch {set enumOutKm [open $enumFileKm w]} msg]} {
+	    error "ERROR: ${::Prog}: failed to open-for-write '$enumFileKm' threw error, $msg"
+	}
+	puts "${::Prog}: enumerating each error bbox to: $enumFileKm"
+    }
+}
+
+# write a line with timestamp and all arguments to stdout (log)
+# (magic renames the TCL clock command)
+set clockp clock
+if {[info command $clockp] == {} && [info command orig_clock] != {}} {
+    set clockp orig_clock
+}
+set nowSec [$clockp seconds]
+set timestamp [$clockp format $nowSec -format "%Y-%m-%d.%T.%Z"]
+# TODO: quote logged argv here as needed so it's machine readable for replay purposes.
+puts "${::Prog}: timestamp: $timestamp, arguments: $argv"
+
+# just Manhattan is default, turn on euclidean, and log new mode
+drc euclidean on
+drc euclidean
+
+# 8.1.83 this worked:
+#    drc off; gds drccheck no;  gds read ... ; load topcell; select top cell; expand; drc check; drc update; drc listall count
+# By 8.2.64, that fails, the 'drc listall count' reports errors only in the top-cell, no subcells.
+# 8.1.83 & 8.2.193 this works (gds drccheck defaults to on anyway):
+#    drc off; gds drccheck yes; gds read ... ; load topcell; select top cell; expand; drc check; drc update; drc listall count
+#
+# But are we properly avoiding redundant drc runs?
+#
+# turn off background checker. We'll invoke checks explicitly.
+drc off
+gds drccheck yes
+puts "drc status (whether background checking enabled) is: [drc status]"
+puts "gds drccheck (whether gds-read marks new cells as need-drc) is: [gds drccheck]"
+
+# set user's drc style; set user's cifinput istyle
+# These are back-to-back without intervening status messages.
+# If both wrong their errors are back-to-back.
+set res {}
+set res [drc list style]
+if {$variant != {}} {
+    set allstyle [drc listall style]
+    set ndx [lsearch -exact $allstyle $variant]
+    if {$ndx < 0} {
+	puts "ERROR: ${::Prog}: drc style '$variant' not one of those available: $allstyle"
+	incr nbrErr
+    } else {
+	set res [drc list style $variant]
+    }
+}
+set res2 [cif list istyle]
+if {$istyle != {}} {
+    set allstyle [cif listall istyle]
+    set ndx [lsearch -exact $allstyle $istyle]
+    if {$ndx < 0} {
+	puts "ERROR: ${::Prog}: istyle '$istyle' not one of those available: $allstyle"
+	incr nbrErr
+    } else {
+	set res2 [cif istyle $istyle]
+    }
+}
+if {$res != {}} {
+    puts "drc style reports:\n$res"
+}
+if {$res2 != {}} {
+    puts "cif istyle reports:\n$res2"
+}
+
+# gds {path,polygon} subcell yes
+if         {$pathSub != 0} { gds    path subcells yes }
+puts "gds    path subcells: [gds    path subcells]"
+if      {$polySub != 0}    { gds polygon subcells yes }
+puts "gds polygon subcells: [gds polygon subcells]"
+
+# todo: this catch never happens. Need nicer error check of 'gds read' somehow. Can check for zero-sized file?
+# if use /dev/null for example, it prints its own error message, but no throw, no useful return value.
+puts         "doing: gds read $gdsf ..."
+if {[catch {set res [gds read $gdsf]} msg]} {
+    puts "ERROR: ${::Prog}: 'gds read $gdsf' threw error, $msg"
+    incr nbrErr
+}
+# nothing useful:
+# puts "gds-read res: $res"
+
+set topcells [cellname list top]
+set allcells [cellname list allcells]
+# puts "cellname-list-top from GDS is: $topcells"
+# puts "cellname-list-allcells from GDS are: $allcells"
+# filter (UNNAMED)
+set topcells [lsearch -exact -not -all -inline $topcells "(UNNAMED)"]
+set allcells [lsearch -exact -not -all -inline $allcells "(UNNAMED)"]
+set nbrAllCells [llength $allcells]
+
+if {$topcells == {}} {
+    puts "ERROR: ${::Prog}: GDS-read did not report any useful cell name(s) found."
+    incr nbrErr
+}
+
+if {$nbrErr > 0} {
+    return $nbrErr ;# outside of main, we print termination with errors message
+}
+
+if {$topc == {}} {
+    # try and infer topcell from cellname-list-top.
+    # presume its list of cells not placed anywhere else.
+    # todo: test with "library" GDS having more than one topcell
+    # here we just take the last entry
+    set topc [lindex $topcells end]
+    set topcStr $topc
+    puts "WARNING: auto-picked top-cell \"$topc\"; the topcells inferred from GDS are: $topcells"
+} else {
+    # verify input topc argument exists in GDS read result
+    set ndx [lsearch -exact $allcells $topc]
+    if {$ndx < 0} {
+	puts "ERROR: ${::Prog}: top-cell name: $topc, not found in GDS"
+	puts "info: top cells inferred from GDS are: $topcells"
+	puts "info: all cells inferred from GDS are: $allcells"
+	return [incr nbrErr] ;# outside of main, we print termination with errors message
+    }
+}
+
+puts "${::Prog}: running drc on -gds: $gdsf -topcell: $topcStr"
+reportTechFile
+
+# todo: need to error check load command somehow (no useful return value).
+# it can fail with error message (in log) like:
+#   File dne.mag couldn't be found
+#   Creating new cell
+if {[catch {set res [load $topc]} msg]} {
+    puts "ERROR: ${::Prog}: 'load $topc' threw error (maybe cellName not found in GDS?), $msg"
+    return [incr nbrErr] ;# outside of main, we print termination with errors message
+}
+# nothing useful:
+# puts "load $topc res: $res"
+
+if {$flatten} {
+    # delete (UNNAMED) if any.
+    set trg "(UNNAMED)"
+    if {[cellnameExists $trg]} {cellname delete $trg}
+
+    # rename top cell to (UNNAMED)
+    cellname rename $topc $trg
+
+    # now Edit Cell contents are original top cell, but under name (UNNAMED)
+    # flatten Edit-Cell into original top cell name
+    puts "${::Prog}: flattening..."
+    flatten $topc
+
+    # load and edit new version of top cell
+    load $topc
+
+    # crude way even in batch to determine the "current" cell; perhaps not yet the "Edit" cell
+    # WARNING, if topcell locked elsewhere or not writable, it can't become the "Edit" cell.
+    set topcw [cellname list window]
+    if {$topcw ne $topc} {
+	puts "ERROR: ${::Prog}: assertion failed, post-flatten, $topc, is not the current cell, 'cellname list window'=$topcw"
+	return [incr nbrErr] ;# outside of main, we print termination with errors message
+    }
+
+    # should not be necessary:
+    select top cell
+    edit
+
+    # crude way even in batch to determine the "current" cell; perhaps not yet the "Edit" cell
+    # WARNING, if topcell locked elsewhere or not writable, it can't become the "Edit" cell.
+    set topcw [cellname list window]
+    if {$topcw ne $topc} {
+	puts "ERROR: ${::Prog}: assertion-2 failed, post-flatten, $topc, is not the current cell, 'cellname list window'=$topcw"
+	return [incr nbrErr] ;# outside of main, we print termination with errors message
+    }
+}
+
+# Erase all preexisting *.drtcl first. Else when cell transitions from
+# dirty in previous run (leaving *.drtcl), to clean, the old *.drtcl
+# remains.
+# TODO: only delete *.drtcl of cells in 'cellname list allcells'?
+if {$doFeedback} {
+    set files [glob -nocomplain -types {f} -- ./*.drtcl]
+    if {$flatten} {
+	# only delete topcell's .drtcl in flatten mode, if there is one
+	set files [lsearch -all -inline -exact $files ./$topc.drtcl]
+    }
+    if {$files != {}} {
+	# TODO: detect/report failure details better here?
+	puts "${::Prog}: deleting preexisting *.drtcl"
+	set msg {}
+	set delfail [catch {eval {file delete} $files} msg]
+	set files [glob -nocomplain -types {f} -- ./*.drtcl]
+	if {$delfail || $files != {}} {
+	    puts "ERROR: ${::Prog}: failed to clean old ./*.drtcl files. $msg"
+	    incr nbrErr
+	}
+    }
+}
+
+# 1st "select top cell": without it drc-list-count is blank, and error count reduced.
+select top cell
+
+set bbox0 [view bbox]
+set outScale [cif scale out]
+
+# set bbox1 [view bbox]
+
+# "select top cell" and box [view bbox] should be equivalent in
+# placing a box around whole cell extent.
+# The box cmd ALSO prints lambda and micron user-friendly box data,
+# but it prints microns with not enough resolution,
+# (and no option to disable that flawed print out).
+#
+# todo: emulate box output in full, except for higher resolution,
+# here we only scale/print the overall bbox in microns.
+set bbs {}
+foreach oord $bbox0 {
+    lappend bbs [format "%.3f" [expr {$outScale * $oord}]]
+}
+puts "info: outScale: [format "%.6f" $outScale], view-bbox: $bbox0"
+puts "info: Root cell box: ([lindex $bbs 0]  [lindex $bbs 1]), ([lindex $bbs 2]  [lindex $bbs 3])"
+
+drc check
+drc catchup
+drc statistics
+drc rulestats
+# puts "doing plain: drc count"
+drc count
+
+# 2nd select top cell needed else error count may be reduced (why? bbox does not change due to DRC)
+select top cell
+
+set celllist        [drc listall count]
+set drcListCountTot [drc list count total]
+# puts stdout "(drc listall count)       is << " nonewline; puts stdout [list $celllist]                 nonewline; puts " >>"
+# puts stdout "(drc list count)          is << " nonewline; puts stdout [list [drc list count]]          nonewline; puts " >>"
+# puts stdout "(drc list    count total) is << " nonewline; puts stdout [list $drcListCountTot]          nonewline; puts " >>"
+# puts stdout "(drc listall count total) is << " nonewline; puts stdout [list [drc listall count total]] nonewline; puts " >>"
+# puts stdout "(drc list why)            is << " nonewline; puts stdout [list [drc list why]]            nonewline; puts " >>"
+# puts stdout "(drc listall why)         is << " nonewline; puts stdout [list [drc listall why]]         nonewline; puts " >>"
+
+set bbox2 [view bbox]
+if {$bbox2 != $bbox0} {
+    set bbs {}
+    foreach oord $bbox2 {
+	lappend bbs [format "%.3f" [expr {$outScale * $oord}]]
+    }
+    puts "info: outScale: [format "%.6f" $outScale], view-bbox: $bbox2"
+    puts "info: Root cell box2: ([lindex $bbs 0]  [lindex $bbs 1]), ([lindex $bbs 2]  [lindex $bbs 3])"
+}
+
+
+# canonicalize order of celllist, move topc to last (if present whatsoever).
+# force our own artificial entry for topc (zero errors) if not present (was clean)
+# puts "celllist before: $celllist"
+set nbrErrCells [llength $celllist]
+set topcPair [lsearch           -inline -index 0 -exact $celllist $topc]
+set celllist [lsearch -not -all -inline -index 0 -exact $celllist $topc]
+set celllist [lsort -index 0 -dictionary $celllist]
+if {$topcPair == {}} {
+    # puts "info: ${::Prog}: $topc clean, forcing celllist entry for it"
+    set topcPair [list $topc 0]
+}
+lappend celllist $topcPair
+# puts stdout "adjusted celllist(drc list count) is << " nonewline; puts stdout $celllist nonewline; puts " >>"
+
+array set kmErr2catNm {}
+array set kmErr2catDesc {}
+array set kmCell2item {}
+if {$celllist != {} && [info exists enumOutKm]} {
+    # Header example of .lyrdb klayout Marker format
+    # <?xml version="1.0" encoding="utf-8"?>
+    # <report-database>
+    # <description>Diff of 'x.gds, Cell RINGO' vs. 'x.gds[1], Cell INV2'</description>
+    # <original-file/>
+    # <generator/>
+    # <top-cell>RINGO</top-cell>
+    # <tags>
+    # <tag>
+    # <name>red</name>
+    # <description>Red flag</description>
+    # </tag>
+    # ... 
+    # </tags>
+
+    puts $enumOutKm {<?xml version="1.0" encoding="utf-8"?><report-database>}
+    puts $enumOutKm "<description>$topc DRC timestamp: $timestamp, arguments: $argv</description>"
+    puts $enumOutKm {<original-file/><generator/>}
+    puts $enumOutKm "<top-cell>$topc</top-cell>"
+    puts $enumOutKm {<tags/>}
+    puts $enumOutKm {<cells>}
+
+    # multiple <cells>...</cells> sections do accumulate, but cells and categories need
+    # to be defined before use in an item (specific error), and we know cell names here,
+    # so declare all cells to klayout here.
+    #
+    # Cell-specific header of klayout marker file
+    #  <cell>
+    #   <name>CELLNAME1</name>
+    #   <variant>1</variant>               (don't need)
+    #  </cell>
+    #
+    foreach pair $celllist {
+	set acell [lindex $pair 0]
+
+	# for -tt, no subcell error-detail: don't write subcells in <cells>...</cells> section.
+	if {$acell ne $topc && ! $subcellTab} { continue }
+
+	puts $enumOutKm "  <cell><name>$acell</name></cell>"
+	set kmCell2item($acell) {}
+    }
+    puts $enumOutKm {</cells>}
+}
+
+# loop over celllist
+set gtotal 0
+set gcells 0
+set lumpedHeader 0
+foreach pair $celllist {
+    set acell [lindex $pair 0]
+    set acount [lindex $pair 1]
+
+    if {$acell ne $topc && ! $subcellTab} {
+	if {! $lumpedHeader} {
+	    puts "--- #err|cell, lumped total counts"
+	    set lumpedHeader 1
+	}
+	puts "[format {%8d} $acount] $acell"
+	incr gcells
+	incr gtotal $acount
+	continue
+    }
+    if {$acell eq $topc && ! $topcellTab} {
+	if {! $lumpedHeader} {
+	    puts "--- #err|cell, lumped total counts"
+	    set lumpedHeader 1
+	}
+	puts "[format {%8d} $acount] $acell"
+	incr gcells
+	incr gtotal $acount
+	continue
+    }
+    puts ""
+
+    # todo: need useful error check of load command
+    if {[catch {set res [load $acell]} msg]} {
+	puts "ERROR: ${::Prog}: 'load $acell' threw error, $msg"
+	return [incr nbrErr] ;# outside of main, we print termination with errors message
+    }
+
+    # instead use quiet version for per-cell selects
+    select top cell
+
+    set drcListCountTot [drc listall count total]
+
+    # enumerate errors under box, plain "drc why" only reports unique types, no quantities
+    # as-yet-undocumented "drc listall why" will give: {errStr1 {errBox1 ...} errStr2 {errBox1 ...} ... }
+    set pareto {}
+    set total 0
+    set enumTotal 0
+    set types 0
+    set typeDup 0
+    set dups 0
+
+    set fbOut {}
+    if {$acount != 0} {
+	# file path for feedback, keep in CWD
+	if {$doFeedback && $fbOut == {}} {
+	    set fbOut "./$acell.drtcl"
+	    if {![file writable $fbOut] &&
+		([file exists $fbOut] || ![file writable [file dir $fbOut]])} {
+		puts stderr "ERROR: ${::Prog}: feedback output not writable, $fbOut"
+		incr nbrErr
+		set fbOut {}
+	    } elseif {[catch {set outfb [open $fbOut w]} msg]} {
+		puts stderr "ERROR: ${::Prog}: failed to truncate previous feedback output, $fbOut : $msg"
+		incr nbrErr
+		set fbOut {}
+	    }
+	}
+
+	foreach {str boxes} [drc listall why] {
+	    # sort errors
+	    set boxes [lsort -dictionary $boxes]
+	    # for our pareto, gather data
+	    set this [llength $boxes]
+	    incr total $this
+	    incr types
+	    lappend pareto [list $this $str]
+
+	    # for enumOut, emulate formatting of $CAD_ROOT/magic/tcl/drc.tcl, which is
+	    # not tk pure: fails with complaint about winfo
+	    # note: we walk these errors also in order to count/report stats on duplicates, even if not outputing enumerations
+	    if {[info exists enumOut]} {
+		if {$types == 1} {
+		    puts $enumOut "[join $pair]\n----------------------------------------"
+		}
+		puts $enumOut "${str}\n----------------------------------------"
+	    }
+	    if {[info exists enumOutL]} {
+		if {$types == 1} {
+		    puts $enumOutL "[join $pair]\n----------------------------------------"
+		}
+		puts $enumOutL "${str}\n----------------------------------------"
+	    }
+	    if {[info exists enumOutKm]} {
+		# category names must be declared all together up front before use in items
+		# so we only store their names (error strings) and error detail (items)
+		# to dump after all cells and errors are processed.
+		# TODO: Only quote catName in item if embeds dot, instead of full-time
+		# TODO: test klayout handles literal (non-entity) single-quote in double-quoted name
+		set strKmNm   $str
+		set strKmDesc $str
+		regsub -all -- {&} $strKmDesc {\&amp;} strKmDesc  ;# perhaps not needed; just in case
+		regsub -all -- {<} $strKmDesc {\&lt;}  strKmDesc  ;# description does not have such bug, so use correct entity
+		regsub -all -- {>} $strKmDesc {\&gt;}  strKmDesc  ;# perhaps not needed; just in case
+		regsub -all -- {&}  $strKmNm  {-and-} strKmNm    ;# perhaps not needed; just in case
+		regsub -all -- {>}  $strKmNm  {-gt-}  strKmNm    ;# perhaps not needed; just in case
+		regsub -all -- {<}  $strKmNm  {-lt-}  strKmNm    ;# catName klayout bug: info win truncates at '<' as &lt; entity
+		regsub -all -- "\"" $strKmNm  {'}     strKmNm    ;# we dqoute each catNm in item, so change embedded double to single
+		set kmErr2catNm($str)   $strKmNm
+		set kmErr2catDesc($str) $strKmDesc
+		#
+		# example klayout Marker format, header of one item (one error instance)
+		#  <item>
+		#   <tags/>               (don't need?)
+		#   <image/>               (don't need?)
+		#   <category>'DRC-MSG-STR'</category>       (cat1.cat2 path delimit by dot: names with dot need single|double quotes)
+		#   <cell>RINGO:1</cell>                     (don't need :N variant suffix)
+		#   <visited>false</visited>                  (optional? start with false?)
+		#   <multiplicity>1</multiplicity>           (not boolean, if error "represents" more that are NOT enumerated)
+		#   <values> ... </values>
+		#  </item>
+
+		set itemStr "<item><category>\"$strKmNm\"</category><cell>$acell</cell><values>"
+	    }
+	    set lastq {}
+	    set thisDup 0
+	    foreach quad $boxes {
+		set quadUM {}
+		set kmBoxUM {}
+		foreach coord $quad {
+		    set valum [expr {$coord * $outScale}]
+		    set valumf [format "%.3f" $valum]
+		    lappend quadUM "${valumf}um"
+		    lappend kmBoxUM ${valumf}
+		}
+		set dup [expr {$quad == $lastq}]
+		incr thisDup $dup
+		set line $quadUM
+		if {[info exists enumOut]} {
+		    if {$dup} {
+			puts $enumOut "[join $line] #dup"
+		    } else {
+			puts $enumOut [join $line]
+		    }
+		}
+		if {[info exists enumOutL]} {
+		    if {$dup} {
+			puts $enumOutL "$quad #dup"
+		    } else {
+			puts $enumOutL $quad
+		    }
+		}
+		if {[info exists enumOutKm]} {
+		    #    <value>text: 'item: polygon'</value>                          (text is optional? Repeat the box coordinates here in um?)
+		    #    <value>polygon: (1.4,1.8;-1.4,1.8;-1.4,3.8;1.4,3.8)</value>
+		    #    <value>box: (1.4,1.8;-1.4,3.8)</value>
+		    #   </values>
+		    set kmItem $itemStr
+		    append kmItem " <value>box: ([lindex $kmBoxUM 0],[lindex $kmBoxUM 1];[lindex $kmBoxUM 2],[lindex $kmBoxUM 3])</value>"
+		    if {$dup} {
+			append kmItem " <value>text: 'dup'</value>"
+		    }
+		    append kmItem " </values></item>"
+		    lappend kmCell2item($acell) $kmItem
+		}
+		if {$fbOut != {}} {
+		    set line [join $quadUM]
+		    regsub -all -- "(\[\[\"\$\\\\])" $str {\\\1} strdq
+		    puts $outfb "[concat box $line]"                nonewline
+		    puts $outfb " ; feedback add \"$strdq\" medium" nonewline
+		    if {$dup} {
+			puts $outfb " ;#dup"
+		    } else {
+			puts $outfb ""
+		    }
+		}
+
+		incr enumTotal
+		set lastq $quad
+	    }
+	    if {$thisDup} {
+		incr typeDup
+		incr dups $thisDup
+	    }
+	    if {[info exists enumOut]} {
+		puts $enumOut "----------------------------------------\n"
+	    }
+	    if {[info exists enumOutL]} {
+		puts $enumOutL "----------------------------------------\n"
+	    }
+	}
+    }
+
+    if {$fbOut != {}} {
+	close $outfb
+	set outfb {}
+    }
+
+    set pareto [lsort -integer -decreasing -index 0 $pareto]
+    if {$total > 0} {
+	puts "--- #err|description, table for cell: $acell"
+    }
+    foreach pair $pareto {
+	puts "[format {%8d} [lindex $pair 0]] [lindex $pair 1]"
+    }
+    if {$typeDup} {
+	puts "[format {%8d} $dups] total duplicate error(s) among $typeDup error type(s), cell: $acell"
+    }
+    puts "[format {%8d} $total] total error(s) among $types error type(s), cell: $acell"
+    # add to grand-totals
+    incr gcells
+    incr gtotal $total
+
+    # always compare the total from the enum to the pareto as error check
+    if {$total != $enumTotal} {
+	puts "ERROR: ${::Prog}: cell: $acell, internal error, pareto vs enum count mismatch: $total != $enumTotal"
+	incr nbrErr
+    }
+    # wish to compare the drc-list-count-total to the pareto total.
+    # Per te 2014-08-27 : it is not an error.
+    if {$total != $drcListCountTot} {
+	# puts "info: ${::Prog}: cell: $acell, drc-list-count-total vs drc-listall-why mismatch {drc list count total} gave $drcListCountTot, but {drc listall why} gave $total"
+    }
+}
+
+# grand totals
+puts "[format {%8d} $nbrErrCells] of $nbrAllCells cell(s) report error(s)"
+puts "[format {%8d} $gtotal] grand-total error(s) across $gcells cell(s)"
+
+if {[info exists enumOut]} {
+    close $enumOut
+}
+if {[info exists enumOutL]} {
+    close $enumOutL
+}
+if {[info exists enumOutKm]} {
+    # declare all category names and descriptions, note '<' in name vs description are represented differently
+    #
+    # <categories><category><name>layerN width -lt- 1.0um</name>
+    # <description>layerN width &lt; 1.0um</description></category>
+    # <category> ... </category></categories>
+    #
+    puts $enumOutKm "<categories>"
+    foreach errStr [array names kmErr2catNm] {
+	set nm   $kmErr2catNm($errStr)
+	set desc $kmErr2catDesc($errStr)
+	puts $enumOutKm "  <category><name>$nm</name><description>$desc</description></category>"
+    }
+    puts $enumOutKm "</categories>"
+
+    # dump all items (after all cells and all categories have been defined up front)
+    puts $enumOutKm "<items>"
+    foreach {acell items} [array get kmCell2item] {
+	foreach item $items {
+	    puts $enumOutKm $item
+	}
+    }
+    puts $enumOutKm "</items>"
+
+    # footer example .lyrdb klayout Marker file
+    # </report-database>
+    puts $enumOutKm {</report-database>}
+    close $enumOutKm
+}
+# todo: implement super-pareto, ranked table of SUM of all DRC errs/counts from ALL cells.
+# (It still would not reflect as-if-flat hierarchical expansion due to repetition of instances).
+
+set nbrErr ;# return value
+} ;# end main
+
+# non-zero exit-status on errors, either if thrown by main, or counted and returned by main
+set nbrErr 0
+if {[catch {set nbrErr [main $argv]} msg]} {
+    puts stderr $msg
+    set nbrErr 1
+} elseif {$nbrErr > 0} {
+    puts "ERROR: ${::Prog}: script terminated with errors reported above."
+}
+exit $nbrErr
+
+# for emacs syntax-mode:
+# Local Variables:
+# mode:tcl
+# End:
diff --git a/utils/parse_klayout_xor_log.py b/utils/parse_klayout_xor_log.py
new file mode 100644
index 0000000..d93fb2c
--- /dev/null
+++ b/utils/parse_klayout_xor_log.py
@@ -0,0 +1,43 @@
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+import argparse
+import re
+
+parser = argparse.ArgumentParser(
+    description='extracts the total xor differnces from an xor log')
+
+parser.add_argument('--log_file', '-l',required=True,
+                    help='log file')
+
+parser.add_argument('--output', '-o', required=True,
+                    help='output file to store results')
+
+args = parser.parse_args()
+log_file_name = args.log_file
+out_file_name = args.output
+
+string = "XOR differences:"
+pattern = re.compile(r'\s*%s\s*([\d+]+)' % string)
+tot_cnt = 0
+with open(log_file_name, "r") as f:
+    for line in f:
+        m = pattern.match(line)
+        if m:
+            tot_cnt += int(m.group(1))
+
+outFileOpener = open(out_file_name, "w")
+outFileOpener.write("Total XOR differences = "+ str(tot_cnt))
+outFileOpener.close()
diff --git a/utils/rename_pins.sh b/utils/rename_pins.sh
new file mode 100644
index 0000000..165b4b3
--- /dev/null
+++ b/utils/rename_pins.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+#!/bin/bash
+
+# : ${1?"Usage: $0 file.def pin_name new_name"}
+# : ${2?"Usage: $0 file.def pin_name new_name"}
+# : ${3?"Usage: $0 file.def pin_name new_name"}
+
+IFS=', ' read -r -a pin_name <<< $2
+IFS=', ' read -r -a new_name <<< $3
+
+for i in "${!pin_name[@]}"; do
+    sed -i "s/${pin_name[i]}/${new_name[i]}/g" $1
+done 
diff --git a/utils/scrotLayout.py b/utils/scrotLayout.py
new file mode 100644
index 0000000..6eb282e
--- /dev/null
+++ b/utils/scrotLayout.py
@@ -0,0 +1,59 @@
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+import pya
+import re
+import os
+
+WIDTH = 2048
+HEIGHT = 2048
+
+app = pya.Application.instance()
+win = app.main_window()
+
+# Load technology file
+print('[INFO] Reading tech file: ' + str(tech_file))
+tech = pya.Technology()
+tech.load(tech_file)
+
+layoutOptions = tech.load_layout_options
+
+# Load def file in the main window
+print('[INFO] Reading Layout file: ' + str(input_layout))
+cell_view = win.load_layout(input_layout, layoutOptions, 0)
+layout_view = cell_view.view()
+
+layout_view.load_layer_props(os.path.splitext(tech_file)[0]+'.lyp')
+
+layout_view.max_hier()
+# layout_view.clear_layers()
+
+# Hide layers with these purposes
+hidden_purposes = [0, 4, 5]
+
+li = layout_view.begin_layers()
+while not li.at_end():
+    lp = li.current()
+    if lp.source_datatype in hidden_purposes:
+        new_lp = lp.dup()
+        new_lp.visible = False
+        layout_view.set_layer_properties(li, new_lp)
+
+    li.next()
+
+print("[INFO] Writing out PNG screenshot '{0}'".format(input_layout+".png"))
+layout_view.save_image(input_layout+".png", WIDTH, HEIGHT)
+print("Done")
+app.exit(0)
diff --git a/utils/scrotLayout.sh b/utils/scrotLayout.sh
new file mode 100644
index 0000000..3b81a3f
--- /dev/null
+++ b/utils/scrotLayout.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+set -e
+
+: ${1?"Usage: $0 tech_file input"}
+: ${2?"Usage: $0 tech_file input"}
+
+echo "Using Techfile: $1"
+echo "Using layout file: $2"
+
+# The -a here is necessary to handle race conditions.
+# This limits the max number of possible jobs to 100.
+xvfb-run -a klayout -z \
+    -rd input_layout=$2 \
+    -rd tech_file=$1 \
+    -rm $(dirname $0)/scrotLayout.py
+
+exit 0
diff --git a/utils/xor.drc b/utils/xor.drc
new file mode 100644
index 0000000..6caee91
--- /dev/null
+++ b/utils/xor.drc
@@ -0,0 +1,42 @@
+# A general XOR script
+# (https://www.klayout.de/forum/discussion/100/xor-vs-diff-tool)
+# This script uses KLayout's DRC language to implement a generic
+# XOR between two layouts. The name of the layouts is given
+# in $a and $b.
+
+# For layout-to-layout XOR with multiple cores, run this script with
+#   ./klayout -r xor.drc -rd thr=NUM_CORES -rd top_cell=TOP_CELL_NAME -rd a=a.gds -rd b=b.gds -rd ol=xor.gds -zz
+# (replace NUM_CORES by the desired number of cores to utilize
+
+# enable timing output
+verbose
+
+# set up input a
+a = source($a, $top_cell)
+
+# set up input b
+b = source($b, $top_cell)
+
+$o && $ext != "gds" && report("XOR #{$a} vs. #{$b}", $o)
+$ol && $ext == "gds" && target($ol, $co || "XOR")
+
+$thr && threads($thr) || threads(2)
+
+# collect all common layers
+layers = {}
+[ a.layout, b.layout ].each do |ly|
+  ly.layer_indices.each do |li|
+    i = ly.get_info(li)
+    layers[i.to_s] = i
+  end
+end
+
+# perform the XOR's
+layers.keys.sort.each do |l|
+  i = layers[l]
+  info("--- Running XOR for #{l} ---")
+  x = a.input(l) ^ b.input(l)
+  info("XOR differences: #{x.data.size}")
+  $o && $ext != "gds" && x.output(l, "XOR results for layer #{l} #{i.name}")
+  $ol && $ext == "gds" && x.output(i.layer, i.datatype, i.name)
+end
diff --git a/utils/xor.sh b/utils/xor.sh
new file mode 100644
index 0000000..44800d6
--- /dev/null
+++ b/utils/xor.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+# SPDX-FileCopyrightText: 2020 Efabless Corporation
+#
+# 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
+#
+#      http://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.
+# SPDX-License-Identifier: Apache-2.0
+
+: ${1?"Usage: $0 file1.gds file2.gds <top_level_module_name> output.gds|markers.xml"}
+: ${2?"Usage: $0 file1.gds file2.gds <top_level_module_name> output.gds|markers.xml"}
+: ${3?"Usage: $0 file1.gds file2.gds <top_level_module_name> output.gds|markers.xml"}
+: ${4?"Usage: $0 file1.gds file2.gds <top_level_module_name> output.gds|markers.xml"}
+
+
+echo "First Layout: $1"
+echo "Second Layout: $2"
+echo "Design Name: $3"
+echo "Output GDS will be: $4"
+
+xvfb-run -a klayout -r $(dirname $0)/xor.drc \
+    -rd top_cell=$3 \
+    -rd a=$1 \
+    -rd b=$2 \
+    -rd thr=$(nproc) \
+    -rd ol=$4 \
+    -rd o=$4 \
+    -rd ext=${4##*.} \
+    -zz