agorararmard | 3f79735 | 2020-12-10 18:24:42 +0200 | [diff] [blame] | 1 | # SPDX-FileCopyrightText: 2020 Efabless Corporation |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | # |
| 15 | # SPDX-License-Identifier: Apache-2.0 |
| 16 | |
agorararmard | 7eebfe4 | 2020-12-07 22:08:29 +0200 | [diff] [blame] | 17 | # cannot commit files larger than 100 MB to GitHub |
Ahmed Ghazy | 31c3465 | 2020-12-01 19:59:44 +0200 | [diff] [blame] | 18 | FILE_SIZE_LIMIT_MB = 100 |
| 19 | LARGE_FILES := $(shell find ./gds -type f -name "*.gds") |
Ahmed Ghazy | 0011f61 | 2020-12-02 22:53:33 +0200 | [diff] [blame] | 20 | LARGE_FILES += $(shell find . -type f -size +$(FILE_SIZE_LIMIT_MB)M -not -path "./.git/*" -not -path "./gds/*" -not -path "./openlane/*") |
Ahmed Ghazy | 5898e4a | 2020-11-13 22:28:55 +0200 | [diff] [blame] | 21 | |
| 22 | LARGE_FILES_GZ := $(addsuffix .gz, $(LARGE_FILES)) |
| 23 | |
| 24 | ARCHIVES := $(shell find . -type f -name "*.gz") |
| 25 | ARCHIVE_SOURCES := $(basename $(ARCHIVES)) |
| 26 | |
agorararmard | 212cd82 | 2020-11-26 22:40:17 +0200 | [diff] [blame] | 27 | # PDK setup configs |
| 28 | THREADS ?= $(shell nproc) |
| 29 | STD_CELL_LIBRARY ?= sky130_fd_sc_hd |
| 30 | SPECIAL_VOLTAGE_LIBRARY ?= sky130_fd_sc_hvl |
| 31 | IO_LIBRARY ?= sky130_fd_io |
agorararmard | fed74ec | 2020-12-01 18:03:46 +0200 | [diff] [blame] | 32 | SKYWATER_COMMIT ?= 3d7617a1acb92ea883539bcf22a632d6361a5de4 |
agorararmard | 011940a | 2020-12-11 23:10:04 +0200 | [diff] [blame] | 33 | OPEN_PDKS_COMMIT ?= 32cdb2097fd9a629c91e8ea33e1f6de08ab25946 |
Ahmed Ghazy | efdc529 | 2020-11-19 16:05:48 +0200 | [diff] [blame] | 34 | |
| 35 | .DEFAULT_GOAL := ship |
Ahmed Ghazy | efdc529 | 2020-11-19 16:05:48 +0200 | [diff] [blame] | 36 | # We need portable GDS_FILE pointers... |
| 37 | .PHONY: ship |
agorararmard | 212cd82 | 2020-11-26 22:40:17 +0200 | [diff] [blame] | 38 | ship: check-env uncompress |
Ahmed Ghazy | efdc529 | 2020-11-19 16:05:48 +0200 | [diff] [blame] | 39 | @echo "###############################################" |
| 40 | @echo "Generating Caravel GDS (sources are in the 'gds' directory)" |
| 41 | @sleep 1 |
agorararmard | f8e91c3 | 2020-11-30 23:59:58 +0200 | [diff] [blame] | 42 | @cp gds/caravel.gds gds/caravel.old.gds && echo "Copying old Caravel to gds/caravel.old.gds" || true |
Ahmed Ghazy | 0252f54 | 2020-11-25 14:45:38 +0200 | [diff] [blame] | 43 | @cd gds && MAGTYPE=mag magic -rcfile ${PDK_ROOT}/sky130A/libs.tech/magic/current/sky130A.magicrc -noc -dnull gen_caravel.tcl < /dev/null |
Ahmed Ghazy | efdc529 | 2020-11-19 16:05:48 +0200 | [diff] [blame] | 44 | |
| 45 | |
Ahmed Ghazy | e4c7ec5 | 2020-11-20 13:10:15 +0200 | [diff] [blame] | 46 | |
Ahmed Ghazy | 5898e4a | 2020-11-13 22:28:55 +0200 | [diff] [blame] | 47 | .PHONY: clean |
| 48 | clean: |
| 49 | echo "clean" |
| 50 | |
| 51 | |
| 52 | |
| 53 | .PHONY: verify |
| 54 | verify: |
| 55 | echo "verify" |
| 56 | |
| 57 | |
| 58 | |
| 59 | $(LARGE_FILES_GZ): %.gz: % |
Ahmed Ghazy | 0252f54 | 2020-11-25 14:45:38 +0200 | [diff] [blame] | 60 | @if ! [ $(suffix $<) == ".gz" ]; then\ |
Ahmed Ghazy | e4c7ec5 | 2020-11-20 13:10:15 +0200 | [diff] [blame] | 61 | gzip -n --best $< > /dev/null &&\ |
Ahmed Ghazy | 5898e4a | 2020-11-13 22:28:55 +0200 | [diff] [blame] | 62 | echo "$< -> $@";\ |
| 63 | fi |
| 64 | |
Ahmed Ghazy | e4c7ec5 | 2020-11-20 13:10:15 +0200 | [diff] [blame] | 65 | # This target compresses all files larger than $(FILE_SIZE_LIMIT_MB) MB |
Ahmed Ghazy | 5898e4a | 2020-11-13 22:28:55 +0200 | [diff] [blame] | 66 | .PHONY: compress |
| 67 | compress: $(LARGE_FILES_GZ) |
| 68 | @echo "Files larger than $(FILE_SIZE_LIMIT_MB) MBytes are compressed!" |
| 69 | |
| 70 | |
| 71 | |
| 72 | $(ARCHIVE_SOURCES): %: %.gz |
Ahmed Ghazy | e4c7ec5 | 2020-11-20 13:10:15 +0200 | [diff] [blame] | 73 | @gzip -d $< &&\ |
| 74 | echo "$< -> $@";\ |
Ahmed Ghazy | 5898e4a | 2020-11-13 22:28:55 +0200 | [diff] [blame] | 75 | |
| 76 | .PHONY: uncompress |
| 77 | uncompress: $(ARCHIVE_SOURCES) |
| 78 | @echo "All files are uncompressed!" |
agorararmard | 212cd82 | 2020-11-26 22:40:17 +0200 | [diff] [blame] | 79 | |
Ahmed Ghazy | fdda2cb | 2020-12-04 02:00:38 +0200 | [diff] [blame] | 80 | |
| 81 | # LVS |
Ahmed Ghazy | fdda2cb | 2020-12-04 02:00:38 +0200 | [diff] [blame] | 82 | BLOCKS = $(shell cd openlane && find * -maxdepth 0 -type d) |
| 83 | LVS_BLOCKS = $(foreach block, $(BLOCKS), lvs-$(block)) |
Ahmed Ghazy | 7f70d6f | 2020-12-05 23:05:31 +0200 | [diff] [blame] | 84 | $(LVS_BLOCKS): lvs-% : ./mag/%.mag ./verilog/gl/%.v |
Ahmed Ghazy | fdda2cb | 2020-12-04 02:00:38 +0200 | [diff] [blame] | 85 | echo "Extracting $*" |
| 86 | mkdir -p ./mag/tmp |
| 87 | echo "load $* -dereference;\ |
Ahmed Ghazy | d3ca6fe | 2020-12-16 20:48:17 +0200 | [diff] [blame^] | 88 | select top cell;\ |
| 89 | foreach cell [cellname list children] {\ |
| 90 | load \$$cell -dereference;\ |
| 91 | property LEFview TRUE;\ |
| 92 | };\ |
| 93 | load $* -dereference;\ |
| 94 | select top cell;\ |
Ahmed Ghazy | fdda2cb | 2020-12-04 02:00:38 +0200 | [diff] [blame] | 95 | extract no all;\ |
| 96 | extract do local;\ |
Ahmed Ghazy | d3ca6fe | 2020-12-16 20:48:17 +0200 | [diff] [blame^] | 97 | extract unique;\ |
Ahmed Ghazy | fdda2cb | 2020-12-04 02:00:38 +0200 | [diff] [blame] | 98 | extract;\ |
| 99 | ext2spice lvs;\ |
Ahmed Ghazy | d3ca6fe | 2020-12-16 20:48:17 +0200 | [diff] [blame^] | 100 | ext2spice $*.ext;\ |
Ahmed Ghazy | fdda2cb | 2020-12-04 02:00:38 +0200 | [diff] [blame] | 101 | feedback save extract_$*.log;\ |
| 102 | exit;" > ./mag/extract_$*.tcl |
Ahmed Ghazy | d3ca6fe | 2020-12-16 20:48:17 +0200 | [diff] [blame^] | 103 | cd mag && export MAGTYPE=maglef; magic -rcfile ${PDK_ROOT}/sky130A/libs.tech/magic/current/sky130A.magicrc -noc -dnull extract_$*.tcl < /dev/null |
Ahmed Ghazy | fdda2cb | 2020-12-04 02:00:38 +0200 | [diff] [blame] | 104 | mv ./mag/$*.spice ./spi/lvs |
Ahmed Ghazy | d3ca6fe | 2020-12-16 20:48:17 +0200 | [diff] [blame^] | 105 | rm ./mag/*.ext |
| 106 | mv -f ./mag/extract_$*.{tcl,log} ./mag/tmp |
Ahmed Ghazy | fdda2cb | 2020-12-04 02:00:38 +0200 | [diff] [blame] | 107 | #### |
| 108 | mkdir -p ./spi/lvs/tmp |
Ahmed Ghazy | d3ca6fe | 2020-12-16 20:48:17 +0200 | [diff] [blame^] | 109 | sh ./spi/lvs/run_lvs.sh ./spi/lvs/$*.spice ./verilog/gl/$*.v $* |
| 110 | @echo "" |
| 111 | python3 ./scripts/count_lvs.py -f ./verilog/gl/$*.v_comp.json |
| 112 | mv -f ./verilog/gl/*{.out,.json,.log} ./spi/lvs/tmp 2> /dev/null || true |
| 113 | @echo "Comparison result: ./spi/lvs/tmp/$*.v_comp.out" |
Ahmed Ghazy | fdda2cb | 2020-12-04 02:00:38 +0200 | [diff] [blame] | 114 | |
| 115 | |
| 116 | .PHONY: help |
| 117 | help: |
| 118 | @$(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 '^$@$$' |
| 119 | |
| 120 | |
| 121 | ########################################################################### |
agorararmard | 212cd82 | 2020-11-26 22:40:17 +0200 | [diff] [blame] | 122 | .PHONY: pdk |
| 123 | pdk: skywater-pdk skywater-library open_pdks build-pdk |
| 124 | |
| 125 | $(PDK_ROOT)/skywater-pdk: |
| 126 | git clone https://github.com/google/skywater-pdk.git $(PDK_ROOT)/skywater-pdk |
| 127 | |
| 128 | .PHONY: skywater-pdk |
| 129 | skywater-pdk: check-env $(PDK_ROOT)/skywater-pdk |
| 130 | cd $(PDK_ROOT)/skywater-pdk && \ |
agorararmard | 63e5672 | 2020-12-09 19:57:30 +0200 | [diff] [blame] | 131 | git checkout master && git pull && \ |
agorararmard | 212cd82 | 2020-11-26 22:40:17 +0200 | [diff] [blame] | 132 | git checkout -qf $(SKYWATER_COMMIT) |
| 133 | |
| 134 | .PHONY: skywater-library |
| 135 | skywater-library: check-env $(PDK_ROOT)/skywater-pdk |
| 136 | cd $(PDK_ROOT)/skywater-pdk && \ |
| 137 | git submodule update --init libraries/$(STD_CELL_LIBRARY)/latest && \ |
| 138 | git submodule update --init libraries/$(IO_LIBRARY)/latest && \ |
| 139 | git submodule update --init libraries/$(SPECIAL_VOLTAGE_LIBRARY)/latest && \ |
| 140 | $(MAKE) -j$(THREADS) timing |
| 141 | |
| 142 | ### OPEN_PDKS |
| 143 | $(PDK_ROOT)/open_pdks: |
agorararmard | 065a942 | 2020-12-05 00:24:07 +0200 | [diff] [blame] | 144 | git clone https://github.com/RTimothyEdwards/open_pdks.git $(PDK_ROOT)/open_pdks |
agorararmard | 212cd82 | 2020-11-26 22:40:17 +0200 | [diff] [blame] | 145 | |
| 146 | .PHONY: open_pdks |
| 147 | open_pdks: check-env $(PDK_ROOT)/open_pdks |
| 148 | cd $(PDK_ROOT)/open_pdks && \ |
agorararmard | 63e5672 | 2020-12-09 19:57:30 +0200 | [diff] [blame] | 149 | git checkout master && git pull && \ |
agorararmard | 212cd82 | 2020-11-26 22:40:17 +0200 | [diff] [blame] | 150 | git checkout -qf $(OPEN_PDKS_COMMIT) |
| 151 | |
| 152 | .PHONY: build-pdk |
| 153 | build-pdk: check-env $(PDK_ROOT)/open_pdks $(PDK_ROOT)/skywater-pdk |
| 154 | [ -d $(PDK_ROOT)/sky130A ] && \ |
| 155 | (echo "Warning: A sky130A build already exists under $(PDK_ROOT). It will be deleted first!" && \ |
| 156 | sleep 5 && \ |
| 157 | rm -rf $(PDK_ROOT)/sky130A) || \ |
| 158 | true |
| 159 | cd $(PDK_ROOT)/open_pdks && \ |
| 160 | ./configure --with-sky130-source=$(PDK_ROOT)/skywater-pdk/libraries --with-sky130-local-path=$(PDK_ROOT) && \ |
| 161 | cd sky130 && \ |
| 162 | $(MAKE) veryclean && \ |
| 163 | $(MAKE) && \ |
| 164 | $(MAKE) install-local |
| 165 | |
agorararmard | 7eebfe4 | 2020-12-07 22:08:29 +0200 | [diff] [blame] | 166 | .RECIPE: manifest |
| 167 | manifest: |
| 168 | cd verilog/rtl/ && \ |
agorararmard | bd78183 | 2020-12-08 21:09:44 +0200 | [diff] [blame] | 169 | find * -type f ! -name "user_*.v" ! -name "manifest" ! -name "README" ! -name "defines.v" -exec shasum {} \; > manifest && \ |
| 170 | cd ../../maglef/ && \ |
| 171 | shasum *.mag > manifest && \ |
| 172 | cd ../mag/ && \ |
| 173 | shasum caravel.mag .magicrc > manifest |
| 174 | |
agorararmard | 7eebfe4 | 2020-12-07 22:08:29 +0200 | [diff] [blame] | 175 | |
agorararmard | 212cd82 | 2020-11-26 22:40:17 +0200 | [diff] [blame] | 176 | check-env: |
| 177 | ifndef PDK_ROOT |
| 178 | $(error PDK_ROOT is undefined, please export it before running make) |
Ahmed Ghazy | 31c3465 | 2020-12-01 19:59:44 +0200 | [diff] [blame] | 179 | endif |