Merge branch 'develop' of https://github.com/efabless/caravel into develop
diff --git a/.travisCI/runPrecheck.sh b/.travisCI/runPrecheck.sh
index 4a09938..099f447 100644
--- a/.travisCI/runPrecheck.sh
+++ b/.travisCI/runPrecheck.sh
@@ -13,9 +13,11 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 export TARGET_PATH=$(pwd)
+cd ..
 export PDK_ROOT=$(pwd)/pdks
-cd open_mpw_precheck
-docker run -v $(pwd):/usr/local/bin -v $TARGET_PATH:$TARGET_PATH -v $PDK_ROOT:$PDK_ROOT -u $(id -u $USER):$(id -g $USER) open_mpw_prechecker:latest bash -c "python3 open_mpw_prechecker.py --skip_drc -p $PDK_ROOT -t $TARGET_PATH"
+cd $TARGET_PATH/open_mpw_precheck/
+
+docker run -v $(pwd):/usr/local/bin -v $TARGET_PATH:$TARGET_PATH -v $PDK_ROOT:$PDK_ROOT -u $(id -u $USER):$(id -g $USER) open_mpw_prechecker:latest bash -c "python3 open_mpw_prechecker.py -p $PDK_ROOT -t $TARGET_PATH"
 output=$TARGET_PATH/checks/full_log.log
 
 gzipped_file=$TARGET_PATH/checks/full_log.log.gz
@@ -24,8 +26,7 @@
     gzip -d $gzipped_file
 fi
 
-cnt=$(grep -c -i "All Checks PASSED" $output)
+cnt=$(grep -c -i "DRC violations" $output)
 if ! [[ $cnt ]]; then cnt=0; fi
-
-if [[ $cnt -eq 1 ]]; then exit 0; fi
-exit 2
+if [[ $cnt -eq 2 ]]; then exit 0; fi
+exit 2
\ No newline at end of file
diff --git a/.travisCI/travisBuild.sh b/.travisCI/travisBuild.sh
index a607592..68d3fb4 100644
--- a/.travisCI/travisBuild.sh
+++ b/.travisCI/travisBuild.sh
@@ -17,7 +17,10 @@
 git clone https://github.com/efabless/open_mpw_precheck.git
 cd open_mpw_precheck/dependencies
 sh build-docker.sh
-export PDK_ROOT=$TARGET_PATH/pdks
+cd $TARGET_PATH/..
+export PDK_ROOT=$(pwd)/pdks
+mkdir $PDK_ROOT
+cd $TARGET_PATH/open_mpw_precheck/dependencies
 sh build-pdk.sh
 cd $TARGET_DIR
 exit 0
diff --git a/Makefile b/Makefile
index cbc1c31..20b3d5a 100644
--- a/Makefile
+++ b/Makefile
@@ -8,13 +8,14 @@
 ARCHIVES := $(shell find . -type f -name "*.gz")
 ARCHIVE_SOURCES := $(basename $(ARCHIVES))
 
+
 # PDK setup configs
 THREADS ?= $(shell nproc)
 STD_CELL_LIBRARY ?= sky130_fd_sc_hd
 SPECIAL_VOLTAGE_LIBRARY ?= sky130_fd_sc_hvl
 IO_LIBRARY ?= sky130_fd_io
 SKYWATER_COMMIT ?= 3d7617a1acb92ea883539bcf22a632d6361a5de4
-OPEN_PDKS_COMMIT ?= 3959de867a4acb6867df376dac495e33bb0734f1
+OPEN_PDKS_COMMIT ?= b184e85de7629b8c87087a46b79eb45e7f7cd383
 
 .DEFAULT_GOAL := ship
 # We need portable GDS_FILE pointers...
@@ -61,6 +62,38 @@
 uncompress: $(ARCHIVE_SOURCES)
 	@echo "All files are uncompressed!"
 
+
+# LVS
+NETGEN_SETUP=$(PDK_ROOT)/sky130A/libs.tech/netgen/sky130A_setup.tcl
+
+BLOCKS = $(shell cd openlane && find * -maxdepth 0 -type d)
+LVS_BLOCKS = $(foreach block, $(BLOCKS), lvs-$(block))
+$(LVS_BLOCKS): lvs-% : ./mag/%.mag ./verilog/gl/%.v ./spi/lvs/%.spice
+	echo "Extracting $*"
+	mkdir -p ./mag/tmp
+	echo "load $* -dereference;\
+		extract no all;\
+		extract do local;\
+		extract;\
+		ext2spice lvs;\
+		ext2spice;\
+		feedback save extract_$*.log;\
+		exit;" > ./mag/extract_$*.tcl
+	cd mag && MAGTYPE=maglef magic -rcfile ${PDK_ROOT}/sky130A/libs.tech/magic/current/sky130A.magicrc -noc -dnull extract_$*.tcl
+	mv ./mag/$*.spice ./spi/lvs
+	mv -f ./mag/extract_$*.{tcl,log} ./mag/*.ext ./mag/tmp
+	####
+	mkdir -p ./spi/lvs/tmp
+	sh ./spi/lvs/run_lvs.sh ./verilog/gl/$*.v ./spi/lvs/$*.spice $*
+	mv -f ./spi/lvs/*{.out,.json,.log} ./spi/lvs/tmp
+	
+
+.PHONY: help
+help:
+	@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$'
+
+		
+###########################################################################
 .PHONY: pdk
 pdk: skywater-pdk skywater-library open_pdks build-pdk
 
diff --git a/README.md b/README.md
index 53d1508..198a4b2 100644
--- a/README.md
+++ b/README.md
@@ -31,7 +31,8 @@
 - Caravel User Project Features -- https://youtu.be/zJhnmilXGPo
 - Aboard Caravel -- How to put your design on Caravel? -- https://youtu.be/9QV8SDelURk
 - Things to Clarify About Caravel -- What versions to use with Caravel? -- https://youtu.be/-LZ522mxXMw
-
+    - You could only use openlane:rc5
+    - Make sure you have the commit hashes provided here inside the [Makefile](./Makefile)
 ## Aboard Caravel:
 
 Your area is the full user_project_wrapper, so feel free to add your project there or create a differnt macro and harden it seperately then insert it into the user_project_wrapper. For example, if your design is analog or you're using a different tool other than OpenLANE.
@@ -43,7 +44,7 @@
 - [Magic VLSI Layout Tool](http://opencircuitdesign.com/magic/index.html) installed on your machine. We may provide a Dockerized version later.\*
 - You have your user_project_wrapper.gds under `./gds/` in the Caravel directory.
 
- > \* **Note:** You can avoid the need for the magic prerequisite by using the openlane docker to run the make step. This [section](#running-make-using-openlane's-magic) shows how.
+ > \* **Note:** You can avoid the need for the magic prerequisite by using the openlane docker to run the make step. This [section](#running-make-using-openlane-magic) shows how.
 
 Run the following command:
 
@@ -54,7 +55,7 @@
 
 This should merge the GDSes using magic and you'll end up with your version of `./gds/caravel.gds`. You should expect hundred of thousands of magic DRC violations with the current "development" state of caravel.
 
-## Running Make using OpenLANE's Magic
+## Running Make using OpenLANE Magic
 
 To use the magic installed inside Openlane to complete the final GDS streaming out step, export the following:
 
@@ -80,6 +81,20 @@
 
 This should merge the GDSes using magic and you'll end up with your version of `./gds/caravel.gds`. You should expect hundred of thousands of magic DRC violations with the current "development" state of caravel.
 
+## Required Directory Structure
+
+- ./gds/ : includes all the gds files used or produced from the project.
+- ./def/ : includes all the def files used or produced from the project.
+- ./lef/ : includes all the lef files used or produced from the project.
+- ./mag/ : includes all the mag files used or produced from the project.
+- ./maglef/ : includes all the maglef files used or produced from the project.
+- ./spi/lvs/ : includes all the maglef files used or produced from the project.
+- ./verilog/dv/ : includes all the simulation test benches and how to run them. 
+- ./verilog/gl/ : includes all the synthesized/elaborated netlists. 
+- ./verilog/rtl/ : includes all the Verilog RTLs and source files.
+- ./openlane/`<macro>`/ : includes all configuration files used to run openlane on your project.
+- info.yaml: includes all the info required in [this example](info.yaml). Please make sure that you are pointing to an elaborated caravel netlist as well as a synthesized gate-level-netlist for the user_project_wrapper
+
 ## Managment SoC
 The managment SoC runs firmware that can be used to:
 - Configure User Project I/O pads
diff --git a/mag/.gitignore b/mag/.gitignore
new file mode 100644
index 0000000..a9a5aec
--- /dev/null
+++ b/mag/.gitignore
@@ -0,0 +1 @@
+tmp
diff --git a/maglef/digital_pll.mag b/maglef/digital_pll.mag
index 6db6f44..313db1f 100644
--- a/maglef/digital_pll.mag
+++ b/maglef/digital_pll.mag
@@ -205,7 +205,7 @@
 string LEFclass BLOCK
 string FIXED_BBOX 0 0 41136 41040
 string LEFview TRUE
-string GDS_FILE digital_pll.gds
+string GDS_FILE ../gds/digital_pll.gds
 string GDS_END 2654930
 string GDS_START 265824
 << end >>
diff --git a/maglef/gpio_control_block.mag b/maglef/gpio_control_block.mag
index d9036ce..352439b 100644
--- a/maglef/gpio_control_block.mag
+++ b/maglef/gpio_control_block.mag
@@ -135,7 +135,7 @@
 string LEFclass BLOCK
 string FIXED_BBOX 0 0 33934 18344
 string LEFview TRUE
-string GDS_FILE gpio_control_block.gds
+string GDS_FILE ../gds/gpio_control_block.gds
 string GDS_END 380356
 string GDS_START 138912
 << end >>
diff --git a/maglef/mgmt_core.mag b/maglef/mgmt_core.mag
index c508713..46c4a89 100644
--- a/maglef/mgmt_core.mag
+++ b/maglef/mgmt_core.mag
@@ -3291,7 +3291,7 @@
 string LEFclass BLOCK
 string FIXED_BBOX 0 0 430000 170000
 string LEFview TRUE
-string GDS_FILE mgmt_core.gds
+string GDS_FILE ../gds/mgmt_core.gds
 string GDS_END 169521478
 string GDS_START 2812312
 << end >>
diff --git a/maglef/simple_por.mag b/maglef/simple_por.mag
index cad6611..df5f40b 100644
--- a/maglef/simple_por.mag
+++ b/maglef/simple_por.mag
@@ -49,7 +49,7 @@
 string LEFclass BLOCK
 string FIXED_BBOX 0 0 11344 8338
 string LEFview TRUE
-string GDS_FILE simple_por.gds
+string GDS_FILE ../gds/simple_por.gds
 string GDS_END 386480
 string GDS_START 263388
 << end >>
diff --git a/maglef/storage.mag b/maglef/storage.mag
index ca6b712..f7edcd7 100644
--- a/maglef/storage.mag
+++ b/maglef/storage.mag
@@ -816,7 +816,7 @@
 string LEFclass BLOCK
 string FIXED_BBOX 0 0 88934 189234
 string LEFview TRUE
-string GDS_FILE storage.gds
+string GDS_FILE ../gds/storage.gds
 string GDS_END 15067618
 string GDS_START 13323184
 << end >>
diff --git a/openlane/Makefile b/openlane/Makefile
index 8d2e712..44e9415 100644
--- a/openlane/Makefile
+++ b/openlane/Makefile
@@ -47,7 +47,7 @@
 	@echo "Please export OPENLANE_ROOT"
 	@exit 1
 endif
-	git clone https://github.com/efabless/openlane.git --branch=develop $(OPENLANE_ROOT) && \
+	git clone https://github.com/efabless/openlane.git --branch=master $(OPENLANE_ROOT) && \
 		cd $(OPENLANE_ROOT) && \
 		make openlane
 
diff --git a/openlane/README.md b/openlane/README.md
index 9218d7d..82381e9 100644
--- a/openlane/README.md
+++ b/openlane/README.md
@@ -10,16 +10,16 @@
 
 **NOTE:** rc5 and caravel are still WIP so expect to run into some issues when using it.
 
-If you don't have openlane already, then you can get it from [here](https://github.com/efabless/openlane) and checkout out to `develop` branch. Alternatively, you can clone and build the openlane develop branch through:
+If you don't have openlane already, then you can get it from [here](https://github.com/efabless/openlane) and checkout out to `rc5` tag. Alternatively, you can clone and build openlane through:
 ```bash
     make openlane
 ```
 
-**NOTE:** We are developing caravel using openlane:rc5 which is the current develop branch. openlane:rc5 will be merged to master once the caravel chip is finalized.
+**NOTE:** We are developing caravel using openlane:rc5 which is the current master branch.
 
-**NOTE:** rc5 (current openlane develop) and rc4 (current openlane master) are using two different concepts of cell padding. rc4 is modifying the LEF, while rc5 is relying on openroad to handle the cell padding. Also, rc4 is using the standalone version of openDP while rc5 is using the one integrated in the openroad app. This affects the concept of PL_TARGET_DENSITY and while in rc4 it was preferred to have PL_TARGET_DENSITY=(FP_CORE_UTIL-(5\~10)/100). Now, in rc5 it is preferred to be  PL_TARGET_DENSITY=(FP_CORE_UTIL+(1\~5)/100).
+**NOTE:** rc5 (current openlane master) and rc4 (previous openlane master) are using two different concepts of cell padding. rc4 is modifying the LEF, while rc5 is relying on openroad to handle the cell padding. Also, rc4 is using the standalone version of openDP while rc5 is using the one integrated in the openroad app. This affects the concept of PL_TARGET_DENSITY and while in rc4 it was preferred to have PL_TARGET_DENSITY=(FP_CORE_UTIL-(5\~10)/100). Now, in rc5 it is preferred to be  PL_TARGET_DENSITY=(FP_CORE_UTIL+(1\~5)/100).
 FP_CORE_UTIL should be relaxed as well as it became more representative of the actual core utilization, which wasn't so much the case earlier. So, the perception of these two variables as well as CELL_PAD changed between rc4 and rc5 which necessitates a change in the configurations of almost every single design.
-CELL_PAD should be 4~6 for the skywater libraries in rc5 unlike rc4 which was 8.This will be included in the release notes when rc5 is released as well as the openlane wiki.
+CELL_PAD should be 4~6 for the skywater libraries in rc5 unlike rc4 which was 8.
 
 Then, you have two options:
 1. Create a macro for your design and harden it, then insert it into user_project_wrapper.
@@ -57,7 +57,7 @@
 
 Then, follow the instructions given in Option 2.
 
-**NOTE:** You might have other macros inside your design. In which case, you may need to have some special power configurations. This is covered [here](https://github.com/efabless/openlane/blob/develop/doc/hardening_macros.md#power-grid-pdn).
+**NOTE:** You might have other macros inside your design. In which case, you may need to have some special power configurations. This is covered [here](https://github.com/efabless/openlane/blob/master/doc/hardening_macros.md#power-grid-pdn).
 
 ## Option 2:
 
@@ -83,18 +83,25 @@
 ```
 **NOTE:** Don't change the size or the pin order!
 
-3. Remove this line `add_macro_placement mprj 1150 1700 N` from the interactive script [here](./user_project_wrapper/config.tcl) and replace it with the placement for your macro instances. Or, remove it entirely if you have no macros, along with this line `manual_macro_placement f`.
+3. If your design has standard cells then you need to replace `verilog_elaborate` with `run_synthesis` [here](./user_project_wrapper/interactive.tcl).
 
-4. Run your design through the flow: `make user_project_wrapper`
+4. If your design has standard cells then you need to replace `init_floorplan; place_io_ol;` with `run_floorplan` [here](./user_project_wrapper/interactive.tcl).
+ 
+5. If your design has standard cells then add `run_placement` after `manual_macro_placement f` [here](./user_project_wrapper/interactive.tcl).
 
-5. Re-iterate until you have what you want.
+6. Remove this line `add_macro_placement mprj 1150 1700 N` from the interactive script [here](./user_project_wrapper/interactive.tcl) and replace it with the placement for your macro instances. Or, remove it entirely if you have no macros, along with this line `manual_macro_placement f`.
 
-6. Go back to the main [README.md](../README.md) and continue the process of boarding the chip.
+7. Run your design through the flow: `make user_project_wrapper`
 
-**NOTE:** In both cases you might have other macros inside your design. In which case, you may need to have some special power configurations. This is covered [here](https://github.com/efabless/openlane/blob/develop/doc/hardening_macros.md#power-grid-pdn).
+8. You may want to take a look at the [Extra Pointers](#extra-pointers) to apply any necessary changes to the interactive script.
 
-## Extra Pointers:
+8. Re-iterate until you have what you want.
 
+9. Go back to the main [README.md](../README.md) and continue the process of boarding the chip.
+
+**NOTE:** In both cases you might have other macros inside your design. In which case, you may need to have some special power configurations. This is covered [here](https://github.com/efabless/openlane/blob/master/doc/hardening_macros.md#power-grid-pdn).
+
+## Extra Pointers
 
 - The OpenLANE documentation should cover everything you might need to create your design. You can find that [here](https://github.com/efabless/openlane/blob/master/README.md).
 - The OpenLANE [FAQs](https://github.com/efabless/openlane/wiki) can guide through your troubles.
@@ -102,4 +109,4 @@
 - [Here](https://github.com/efabless/openlane/blob/master/doc/advanced_readme.md) you can learn how to write an interactive script.
 - [Here](https://github.com/efabless/openlane/blob/master/doc/OpenLANE_commands.md) you can find a full documentation for all OpenLANE commands.
 - [This documentation](https://github.com/efabless/openlane/blob/master/regression_results/README.md) describes how to use the exploration script to achieve an LVS/DRC clean design.
-- [This documentation](https://github.com/efabless/openlane/blob/develop/doc/hardening_macros.md) walks you through hardening a macro and all the decisions you should make.
+- [This documentation](https://github.com/efabless/openlane/blob/master/doc/hardening_macros.md) walks you through hardening a macro and all the decisions you should make.
diff --git a/openlane/chip_io/interactive.tcl b/openlane/chip_io/interactive.tcl
index 76964a0..cea6f32 100755
--- a/openlane/chip_io/interactive.tcl
+++ b/openlane/chip_io/interactive.tcl
@@ -98,7 +98,7 @@
                  -gds_path $::env(magic_result_file_tag).gds \
                  -mag_path $::env(magic_result_file_tag).mag \
                  -maglef_path $::env(magic_result_file_tag).lef.mag \
-				 -verilog_path $::env(CURRENT_NETLIST) \
+				 -verilog_path $::env(TMP)/lvs.v \
                  -save_path $save_path \
                  -tag $::env(RUN_TAG)
 
diff --git a/spi/lvs/.gitignore b/spi/lvs/.gitignore
new file mode 100644
index 0000000..a9a5aec
--- /dev/null
+++ b/spi/lvs/.gitignore
@@ -0,0 +1 @@
+tmp
diff --git a/spi/lvs/run_lvs.sh b/spi/lvs/run_lvs.sh
new file mode 100644
index 0000000..77ff185
--- /dev/null
+++ b/spi/lvs/run_lvs.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+NETGEN_SETUP=$PDK_ROOT/sky130A/libs.tech/netgen/sky130A_setup.tcl
+
+netgen -batch lvs "$1 $3" "$2 $3" ${NETGEN_SETUP} $2_comp.out -json | tee $2_comp_lvs.log