Merge pull request #26 from efabless/PDK_variable

added PDK variable
diff --git a/.github/workflows/user_project_ci.yml b/.github/workflows/user_project_ci.yml
index f9fa46f..3317f6d 100644
--- a/.github/workflows/user_project_ci.yml
+++ b/.github/workflows/user_project_ci.yml
@@ -8,7 +8,7 @@
   workflow_dispatch:
 
 jobs:
-    mpw_precheck:
+    mpw_precheck_sky130A:
         timeout-minutes: 720
         runs-on: ubuntu-latest
         steps:
@@ -53,3 +53,48 @@
               path: |
                 /home/runner/work/caravel_user_project/caravel_user_project/mpw_precheck_result/logs/*
 
+  mpw_precheck_sky130B:
+        timeout-minutes: 720
+        runs-on: ubuntu-latest
+        steps:
+          - uses: actions/checkout@v2
+
+          - name: Set up QEMU
+            uses: docker/setup-qemu-action@v1
+
+          - name: Set up Docker Buildx
+            uses: docker/setup-buildx-action@v1
+
+          - name: Export PDK ROOT
+            run: |
+              echo "PDK_ROOT=/home/runner/work/pdk" >> $GITHUB_ENV
+
+          - name: Export PDKPATH
+            run: echo "PDKPATH=/home/runner/work/pdk/sky130B" >> $GITHUB_ENV
+
+          - name: Download PDK
+            run: |
+              MPW_TAG=main CARAVEL_LITE=0 make install
+              make pdk-with-volare
+          
+          - name: Run MPW-Precheck
+            run: |
+              export INPUT_DIRECTORY=$(pwd)
+              export PRECHECK_ROOT=$INPUT_DIRECTORY/mpw_precheck
+              export OUTPUT_DIRECTORY=$INPUT_DIRECTORY/mpw_precheck_result
+              export OUTPUT=$OUTPUT_DIRECTORY/logs/precheck.log
+              git clone --depth=1 -b mpw-7a https://github.com/efabless/mpw_precheck.git
+              docker run -v "$PRECHECK_ROOT":"$PRECHECK_ROOT" -v "$INPUT_DIRECTORY":"$INPUT_DIRECTORY" -v "${{ env.PDK_ROOT }}":"${{ env.PDK_ROOT }}" -e INPUT_DIRECTORY="$INPUT_DIRECTORY" -e PDK_ROOT="${{ env.PDK_ROOT }}" -e PDKPATH="${{ env.PDKPATH }}" -u $(id -u "$USER"):$(id -g "$USER") efabless/mpw_precheck:latest bash -c "cd $PRECHECK_ROOT; python3 mpw_precheck.py --input_directory $INPUT_DIRECTORY --pdk_path ${{ env.PDKPATH }} --output_directory $OUTPUT_DIRECTORY license makefile consistency xor magic_drc klayout_beol klayout_feol klayout_met_min_ca_density klayout_offgrid klayout_pin_label_purposes_overlapping_drawing klayout_zeroarea"
+              cnt=$(grep -c "All Checks Passed" "$OUTPUT")
+              if ! [[ $cnt ]]; then cnt=0; fi
+              if [[ $cnt -eq 1 ]]; then exit 0; fi
+              exit 2
+
+          - name: upload failure logs
+            if: failure()
+            uses: actions/upload-artifact@v2
+            with:
+              name: error
+              path: |
+                /home/runner/work/caravel_user_project/caravel_user_project/mpw_precheck_result/logs/*
+
diff --git a/Makefile b/Makefile
index b15b06f..5ba1de2 100644
--- a/Makefile
+++ b/Makefile
@@ -18,12 +18,13 @@
 PRECHECK_ROOT?=${HOME}/mpw_precheck
 SIM ?= RTL
 
-export OPEN_PDKS_COMMIT?=7519dfb04400f224f140749cda44ee7de6f5e095
-export PDKPATH?=$(PDK_ROOT)/sky130A
+export OPEN_PDKS_COMMIT?=41c0908b47130d5675ff8484255b43f66463a7d6
+export PDK?=sky130B
+export PDKPATH?=$(PDK_ROOT)/$(PDK)
 # Install lite version of caravel, (1): caravel-lite, (0): caravel
 CARAVEL_LITE?=1
 
-MPW_TAG ?= mpw-6c
+MPW_TAG ?= mpw-7a
 
 ifeq ($(CARAVEL_LITE),1)
 	CARAVEL_NAME := caravel-lite
diff --git a/mag/example_por.mag b/mag/example_por.mag
index 76d1d78..1b8c9ba 100644
--- a/mag/example_por.mag
+++ b/mag/example_por.mag
@@ -1,5 +1,5 @@
 magic
-tech sky130A
+tech $PDK
 magscale 1 2
 timestamp 1620310959
 << nwell >>
diff --git a/mag/sky130_fd_pr__cap_mim_m3_1_WRT4AW.mag b/mag/sky130_fd_pr__cap_mim_m3_1_WRT4AW.mag
index c4fedfd..f3164a4 100644
--- a/mag/sky130_fd_pr__cap_mim_m3_1_WRT4AW.mag
+++ b/mag/sky130_fd_pr__cap_mim_m3_1_WRT4AW.mag
@@ -1,5 +1,5 @@
 magic
-tech sky130A
+tech $PDK
 magscale 1 2
 timestamp 1606502073
 << metal3 >>
diff --git a/mag/sky130_fd_pr__cap_mim_m3_2_W5U4AW.mag b/mag/sky130_fd_pr__cap_mim_m3_2_W5U4AW.mag
index 59928eb..88818f6 100644
--- a/mag/sky130_fd_pr__cap_mim_m3_2_W5U4AW.mag
+++ b/mag/sky130_fd_pr__cap_mim_m3_2_W5U4AW.mag
@@ -1,5 +1,5 @@
 magic
-tech sky130A
+tech $PDK
 magscale 1 2
 timestamp 1606502073
 << metal4 >>
diff --git a/mag/sky130_fd_pr__nfet_g5v0d10v5_PKVMTM.mag b/mag/sky130_fd_pr__nfet_g5v0d10v5_PKVMTM.mag
index 7be65d4..508a2da 100644
--- a/mag/sky130_fd_pr__nfet_g5v0d10v5_PKVMTM.mag
+++ b/mag/sky130_fd_pr__nfet_g5v0d10v5_PKVMTM.mag
@@ -1,5 +1,5 @@
 magic
-tech sky130A
+tech $PDK
 timestamp 1606063140
 << pwell >>
 rect -154 -229 154 229
diff --git a/mag/sky130_fd_pr__nfet_g5v0d10v5_TGFUGS.mag b/mag/sky130_fd_pr__nfet_g5v0d10v5_TGFUGS.mag
index 0fc9bf5..dbb8180 100644
--- a/mag/sky130_fd_pr__nfet_g5v0d10v5_TGFUGS.mag
+++ b/mag/sky130_fd_pr__nfet_g5v0d10v5_TGFUGS.mag
@@ -1,5 +1,5 @@
 magic
-tech sky130A
+tech $PDK
 magscale 1 2
 timestamp 1606063140
 << pwell >>
diff --git a/mag/sky130_fd_pr__nfet_g5v0d10v5_ZK8HQC.mag b/mag/sky130_fd_pr__nfet_g5v0d10v5_ZK8HQC.mag
index eb312e6..64df388 100644
--- a/mag/sky130_fd_pr__nfet_g5v0d10v5_ZK8HQC.mag
+++ b/mag/sky130_fd_pr__nfet_g5v0d10v5_ZK8HQC.mag
@@ -1,5 +1,5 @@
 magic
-tech sky130A
+tech $PDK
 timestamp 1605994897
 << pwell >>
 rect -154 -229 154 229
diff --git a/mag/sky130_fd_pr__pfet_g5v0d10v5_3YBPVB.mag b/mag/sky130_fd_pr__pfet_g5v0d10v5_3YBPVB.mag
index e0b0219..cda05e3 100644
--- a/mag/sky130_fd_pr__pfet_g5v0d10v5_3YBPVB.mag
+++ b/mag/sky130_fd_pr__pfet_g5v0d10v5_3YBPVB.mag
@@ -1,5 +1,5 @@
 magic
-tech sky130A
+tech $PDK
 magscale 1 2
 timestamp 1606063140
 << nwell >>
diff --git a/mag/sky130_fd_pr__pfet_g5v0d10v5_YEUEBV.mag b/mag/sky130_fd_pr__pfet_g5v0d10v5_YEUEBV.mag
index 08a17b0..07202c9 100644
--- a/mag/sky130_fd_pr__pfet_g5v0d10v5_YEUEBV.mag
+++ b/mag/sky130_fd_pr__pfet_g5v0d10v5_YEUEBV.mag
@@ -1,5 +1,5 @@
 magic
-tech sky130A
+tech $PDK
 magscale 1 2
 timestamp 1606063140
 << nwell >>
diff --git a/mag/sky130_fd_pr__pfet_g5v0d10v5_YUHPBG.mag b/mag/sky130_fd_pr__pfet_g5v0d10v5_YUHPBG.mag
index eb421da..ceaf969 100644
--- a/mag/sky130_fd_pr__pfet_g5v0d10v5_YUHPBG.mag
+++ b/mag/sky130_fd_pr__pfet_g5v0d10v5_YUHPBG.mag
@@ -1,5 +1,5 @@
 magic
-tech sky130A
+tech $PDK
 magscale 1 2
 timestamp 1606063140
 << error_p >>
diff --git a/mag/sky130_fd_pr__pfet_g5v0d10v5_YUHPXE.mag b/mag/sky130_fd_pr__pfet_g5v0d10v5_YUHPXE.mag
index 19fe898..23ef875 100644
--- a/mag/sky130_fd_pr__pfet_g5v0d10v5_YUHPXE.mag
+++ b/mag/sky130_fd_pr__pfet_g5v0d10v5_YUHPXE.mag
@@ -1,5 +1,5 @@
 magic
-tech sky130A
+tech $PDK
 magscale 1 2
 timestamp 1606063140
 << error_p >>
diff --git a/mag/sky130_fd_pr__pfet_g5v0d10v5_ZEUEFZ.mag b/mag/sky130_fd_pr__pfet_g5v0d10v5_ZEUEFZ.mag
index b8eb64f..f094850 100644
--- a/mag/sky130_fd_pr__pfet_g5v0d10v5_ZEUEFZ.mag
+++ b/mag/sky130_fd_pr__pfet_g5v0d10v5_ZEUEFZ.mag
@@ -1,5 +1,5 @@
 magic
-tech sky130A
+tech $PDK
 magscale 1 2
 timestamp 1606063140
 << nwell >>
diff --git a/mag/sky130_fd_pr__res_xhigh_po_0p69_S5N9F3.mag b/mag/sky130_fd_pr__res_xhigh_po_0p69_S5N9F3.mag
index 5bd3cec..dbaae87 100644
--- a/mag/sky130_fd_pr__res_xhigh_po_0p69_S5N9F3.mag
+++ b/mag/sky130_fd_pr__res_xhigh_po_0p69_S5N9F3.mag
@@ -1,5 +1,5 @@
 magic
-tech sky130A
+tech $PDK
 magscale 1 2
 timestamp 1606074388
 << pwell >>
diff --git a/mag/user_analog_proj_example.mag b/mag/user_analog_proj_example.mag
index 7d27792..fcac6f8 100644
--- a/mag/user_analog_proj_example.mag
+++ b/mag/user_analog_proj_example.mag
@@ -1,5 +1,5 @@
 magic
-tech sky130A
+tech $PDK
 magscale 1 2
 timestamp 1639841760
 << error_p >>
diff --git a/mag/user_analog_project_wrapper.mag b/mag/user_analog_project_wrapper.mag
index a4f3d92..f1198f1 100644
--- a/mag/user_analog_project_wrapper.mag
+++ b/mag/user_analog_project_wrapper.mag
@@ -1,5 +1,5 @@
 magic
-tech sky130A
+tech $PDK
 magscale 1 2
 timestamp 1639841760
 << mvpsubdiff >>
diff --git a/mag/user_analog_project_wrapper_empty.mag b/mag/user_analog_project_wrapper_empty.mag
index 02dbe79..0dc5bd5 100644
--- a/mag/user_analog_project_wrapper_empty.mag
+++ b/mag/user_analog_project_wrapper_empty.mag
@@ -1,5 +1,5 @@
 magic
-tech sky130A
+tech $PDK
 timestamp 1632839657
 << checkpaint >>
 rect -680 351370 292680 352680
diff --git a/netgen/run_lvs_por.sh b/netgen/run_lvs_por.sh
index 1d1ad9f..be822b5 100755
--- a/netgen/run_lvs_por.sh
+++ b/netgen/run_lvs_por.sh
@@ -21,4 +21,4 @@
 # includes used by the testbench simulation are picked up.  Otherwise, the LVS
 # itself compares just the simple_por subcircuit from the testbench.
 #--------------------------------------------------------------------------------
-netgen -batch lvs "example_por.spice example_por" "../xschem/example_por_tb.spice example_por" /usr/share/pdk/sky130A/libs.tech/netgen/sky130A_setup.tcl comp.out
+netgen -batch lvs "example_por.spice example_por" "../xschem/example_por_tb.spice example_por" $PDK_ROOT/$PDK/libs.tech/netgen/$PDK\_setup.tcl comp.out
diff --git a/netgen/run_lvs_wrapper_verilog.sh b/netgen/run_lvs_wrapper_verilog.sh
index e54f6f6..5c63236 100755
--- a/netgen/run_lvs_wrapper_verilog.sh
+++ b/netgen/run_lvs_wrapper_verilog.sh
@@ -19,4 +19,4 @@
 # top-level verilog module.
 #
 #--------------------------------------------------------------------------------
-netgen -batch lvs "user_analog_project_wrapper.spice user_analog_project_wrapper" "../verilog/rtl/user_analog_project_wrapper.v user_analog_project_wrapper" /usr/share/pdk/sky130A/libs.tech/netgen/sky130A_setup.tcl comp.out
+netgen -batch lvs "user_analog_project_wrapper.spice user_analog_project_wrapper" "../verilog/rtl/user_analog_project_wrapper.v user_analog_project_wrapper" $PDK_ROOT/$PDK/libs.tech/netgen/$PDK\_setup.tcl comp.out
diff --git a/netgen/run_lvs_wrapper_xschem.sh b/netgen/run_lvs_wrapper_xschem.sh
index 2e5828c..2fa97c0 100755
--- a/netgen/run_lvs_wrapper_xschem.sh
+++ b/netgen/run_lvs_wrapper_xschem.sh
@@ -19,4 +19,4 @@
 # top-level xschem subcircuit from the wrapper testbench.
 #
 #--------------------------------------------------------------------------------
-netgen -batch lvs "user_analog_project_wrapper.spice user_analog_project_wrapper" "../xschem/analog_wrapper_tb.spice user_analog_project_wrapper" /usr/share/pdk/sky130A/libs.tech/netgen/sky130A_setup.tcl comp.out
+netgen -batch lvs "user_analog_project_wrapper.spice user_analog_project_wrapper" "../xschem/analog_wrapper_tb.spice user_analog_project_wrapper" $PDK_ROOT/$PDK/libs.tech/netgen/$PDK\_setup.tcl comp.out
diff --git a/verilog/dv/README.md b/verilog/dv/README.md
index 6be9cd3..f69808a 100644
--- a/verilog/dv/README.md
+++ b/verilog/dv/README.md
@@ -80,7 +80,8 @@
 First, you will need to export a number of environment variables: 
 
 ```bash
-export PDK_PATH=<pdk-location/sky130A>
+export PDK=sky130B
+export PDK_PATH=<pdk-location>/$PDK
 export CARAVEL_ROOT=<caravel_root>
 export UPRJ_ROOT=<user_project_root>
 ```
@@ -105,7 +106,8 @@
 
 ```bash
 export GCC_PATH=<gcc-installation-path>
-export PDK_PATH=<pdk-location/sky130A>
+export PDK=sky130B
+export PDK_PATH=<pdk-location>/$PDK
 ```
 
 Then, follow the instruction at [Both](#both) to run RTL/GL simulation.
diff --git a/verilog/dv/mprj_por/Makefile b/verilog/dv/mprj_por/Makefile
index 5d0825f..6d8e9c4 100644
--- a/verilog/dv/mprj_por/Makefile
+++ b/verilog/dv/mprj_por/Makefile
@@ -15,7 +15,7 @@
 # SPDX-License-Identifier: Apache-2.0
 
 ## PDK 
-PDK_PATH = $(PDK_ROOT)/sky130A
+PDK_PATH = $(PDK_ROOT)/$(PDK)
 
 ## Caravel Pointers
 CARAVEL_ROOT ?= ../../../caravel
@@ -77,14 +77,14 @@
 ifndef PDK_ROOT
 	$(error PDK_ROOT is undefined, please export it before running make)
 endif
-ifeq (,$(wildcard $(PDK_ROOT)/sky130A))
-	$(error $(PDK_ROOT)/sky130A not found, please install pdk before running make)
+ifeq (,$(wildcard $(PDK_ROOT)/$(PDK)))
+	$(error $(PDK_ROOT)/$(PDK) not found, please install pdk before running make)
 endif
 ifeq (,$(wildcard $(GCC_PATH)/$(GCC_PREFIX)-gcc ))
 	$(error $(GCC_PATH)/$(GCC_PREFIX)-gcc is not found, please export GCC_PATH and GCC_PREFIX before running make)
 endif
 # check for efabless style installation
-ifeq (,$(wildcard $(PDK_ROOT)/sky130A/libs.ref/*/verilog))
+ifeq (,$(wildcard $(PDK_ROOT)/$(PDK)/libs.ref/*/verilog))
 SIM_DEFINES := ${SIM_DEFINES} -DEF_STYLE
 endif