Merge branch 'caravel_user_project_analog' into main
diff --git a/.github/workflows/user_project_ci.yml b/.github/workflows/user_project_ci.yml
index 330d845..3317f6d 100644
--- a/.github/workflows/user_project_ci.yml
+++ b/.github/workflows/user_project_ci.yml
@@ -8,74 +8,93 @@
   workflow_dispatch:
 
 jobs:
-  precheck:
-    runs-on: ubuntu-latest
-    timeout-minutes: 720
-    steps:
-      - uses: actions/checkout@v2
+    mpw_precheck_sky130A:
+        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 QEMU
+            uses: docker/setup-qemu-action@v1
 
-      - name: Set up Docker Buildx
-        uses: docker/setup-buildx-action@v1
+          - name: Set up Docker Buildx
+            uses: docker/setup-buildx-action@v1
 
-      - name: Install Magic
-        run: bash ${GITHUB_WORKSPACE}/.github/scripts/install_magic.sh
+          - name: Export PDK ROOT
+            run: |
+              echo "PDK_ROOT=/home/runner/work/pdk" >> $GITHUB_ENV
 
-      - name: Build PDK
-        run: bash ${GITHUB_WORKSPACE}/.github/scripts/build_pdk.sh
+          - name: Export PDKPATH
+            run: echo "PDKPATH=/home/runner/work/pdk/sky130A" >> $GITHUB_ENV
 
-      - name: Install The Precheck
-        run: git clone --depth=1 https://github.com/efabless/mpw_precheck.git ${GITHUB_WORKSPACE}/mpw_precheck
+          - 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: Run The Precheck
-        run: bash ${GITHUB_WORKSPACE}/.github/scripts/run_precheck.sh
+          - 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/*
 
-  # dv_rtl:
-  #   runs-on: ubuntu-latest
-  #   steps:
-  #     - uses: actions/checkout@v2
+  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 QEMU
+            uses: docker/setup-qemu-action@v1
 
-  #     - name: Set up Docker Buildx
-  #       uses: docker/setup-buildx-action@v1
+          - name: Set up Docker Buildx
+            uses: docker/setup-buildx-action@v1
 
-  #     - name: Install Magic
-  #       run: bash ${GITHUB_WORKSPACE}/.github/scripts/install_magic.sh
+          - name: Export PDK ROOT
+            run: |
+              echo "PDK_ROOT=/home/runner/work/pdk" >> $GITHUB_ENV
 
-  #     - name: Build PDK
-  #       run: bash ${GITHUB_WORKSPACE}/.github/scripts/build_pdk.sh
+          - name: Export PDKPATH
+            run: echo "PDKPATH=/home/runner/work/pdk/sky130B" >> $GITHUB_ENV
 
-  #     - name: Install The Dockerized DV Setup
-  #       run: docker pull efabless/dv_setup:latest
+          - 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: Run DV tests
-  #       # Run test number 0,1,2,3,4 in one job                            <test-ids>   <sim-mode>
-  #       run: bash ${GITHUB_WORKSPACE}/.github/scripts/dv/run-dv-wrapper.sh 0             RTL
+          - 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/*
 
-  # dv_gl:
-  #   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: Install Magic
-  #       run: bash ${GITHUB_WORKSPACE}/.github/scripts/install_magic.sh
-
-  #     - name: Build PDK
-  #       run: bash ${GITHUB_WORKSPACE}/.github/scripts/build_pdk.sh
-
-  #     - name: Install The Dockerized DV Setup
-  #       run: docker pull efabless/dv_setup:latest
-
-  #     - name: Run DV tests
-  #       # Run test number 0,1,2,3,4 in one job                             <test-ids>   <sim-mode>
-  #       run: bash ${GITHUB_WORKSPACE}/.github/scripts/dv/run-dv-wrapper.sh 0              GL
diff --git a/.gitignore b/.gitignore
index 08e4b1d..d1f0d9e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
-precheck_results
+/.idea/
+/precheck_results/
 */tmp
 */*/tmp
 
diff --git a/Makefile b/Makefile
index 37b341c..bc049d4 100644
--- a/Makefile
+++ b/Makefile
@@ -18,10 +18,13 @@
 PRECHECK_ROOT?=${HOME}/mpw_precheck
 SIM ?= RTL
 
+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-5c
+MPW_TAG ?= mpw-7a
 
 ifeq ($(CARAVEL_LITE),1)
 	CARAVEL_NAME := caravel-lite
@@ -109,8 +112,15 @@
 run-precheck: check-pdk check-precheck
 	$(eval INPUT_DIRECTORY := $(shell pwd))
 	cd $(PRECHECK_ROOT) && \
-	docker run -v $(PRECHECK_ROOT):$(PRECHECK_ROOT) -v $(INPUT_DIRECTORY):$(INPUT_DIRECTORY) -v $(PDK_ROOT):$(PDK_ROOT) -e INPUT_DIRECTORY=$(INPUT_DIRECTORY) -e PDK_ROOT=$(PDK_ROOT) \
-	-u $(shell id -u $(USER)):$(shell id -g $(USER)) efabless/mpw_precheck:latest bash -c "cd $(PRECHECK_ROOT) ; python3 mpw_precheck.py --input_directory $(INPUT_DIRECTORY) --pdk_root $(PDK_ROOT)"
+	docker run -v $(PRECHECK_ROOT):$(PRECHECK_ROOT) \
+	-v $(INPUT_DIRECTORY):$(INPUT_DIRECTORY) \
+	-v $(PDK_ROOT):$(PDK_ROOT) \
+	-e INPUT_DIRECTORY=$(INPUT_DIRECTORY) \
+	-e PDK_PATH=$(PDK_ROOT)/$(PDK) \
+	-e PDK_ROOT=$(PDK_ROOT) \
+	-e PDKPATH=$(PDKPATH) \
+	-u $(shell id -u $(USER)):$(shell id -g $(USER)) \
+	efabless/mpw_precheck:latest bash -c "cd $(PRECHECK_ROOT) ; python3 mpw_precheck.py --input_directory $(INPUT_DIRECTORY) --pdk_path $(PDK_ROOT)/$(PDK)"
 
 # Clean 
 .PHONY: clean
diff --git a/docs/source/index.rst b/docs/source/index.rst
index 0a7c0c7..1467d4c 100644
--- a/docs/source/index.rst
+++ b/docs/source/index.rst
@@ -128,18 +128,16 @@
 Building the PDK 
 ================
 
-Make sure you have `Magic VLSI Layout Tool <http://opencircuitdesign.com/magic/index.html>`__   `version 8.3.265 <https://github.com/RTimothyEdwards/magic/tree/8.3.265>`__ installed on your machine before building the pdk. 
+For more information about volare click `here <https://github.com/efabless/volare>`__
 
 .. code:: bash
 
     # set PDK_ROOT to the path you wish to use for the pdk
-    export PDK_ROOT=<pdk-installation-path>
+    export PDK_ROOT=<pdk-installation-path
 
-    # you can optionally specify skywater-pdk and open-pdks commit used
-    # by setting and exporting SKYWATER_COMMIT and OPEN_PDKS_COMMIT
-    # if you do not set them, they default to the last verfied commits tested for this project
-
-    make pdk
+    # use volare to download the pdk
+    # To change the default pdk version you can export OPEN_PDKS_COMMIT=<pdk_commit>
+    make pdk-with-volare 
 
 
 
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