blob: b01f148afe446d0bff2e102dba088d389cd3cf59 [file] [log] [blame]
agorararmard3f797352020-12-10 18:24:42 +02001# 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
agorararmard7eebfe42020-12-07 22:08:29 +020017# cannot commit files larger than 100 MB to GitHub
Ahmed Ghazy31c34652020-12-01 19:59:44 +020018FILE_SIZE_LIMIT_MB = 100
19LARGE_FILES := $(shell find ./gds -type f -name "*.gds")
Ahmed Ghazy0011f612020-12-02 22:53:33 +020020LARGE_FILES += $(shell find . -type f -size +$(FILE_SIZE_LIMIT_MB)M -not -path "./.git/*" -not -path "./gds/*" -not -path "./openlane/*")
Ahmed Ghazy5898e4a2020-11-13 22:28:55 +020021
22LARGE_FILES_GZ := $(addsuffix .gz, $(LARGE_FILES))
23
24ARCHIVES := $(shell find . -type f -name "*.gz")
25ARCHIVE_SOURCES := $(basename $(ARCHIVES))
26
agorararmard212cd822020-11-26 22:40:17 +020027# PDK setup configs
28THREADS ?= $(shell nproc)
29STD_CELL_LIBRARY ?= sky130_fd_sc_hd
30SPECIAL_VOLTAGE_LIBRARY ?= sky130_fd_sc_hvl
31IO_LIBRARY ?= sky130_fd_io
agorararmardfed74ec2020-12-01 18:03:46 +020032SKYWATER_COMMIT ?= 3d7617a1acb92ea883539bcf22a632d6361a5de4
agorararmard011940a2020-12-11 23:10:04 +020033OPEN_PDKS_COMMIT ?= 32cdb2097fd9a629c91e8ea33e1f6de08ab25946
Ahmed Ghazyefdc5292020-11-19 16:05:48 +020034
35.DEFAULT_GOAL := ship
Ahmed Ghazyefdc5292020-11-19 16:05:48 +020036# We need portable GDS_FILE pointers...
37.PHONY: ship
agorararmard212cd822020-11-26 22:40:17 +020038ship: check-env uncompress
Ahmed Ghazyefdc5292020-11-19 16:05:48 +020039 @echo "###############################################"
40 @echo "Generating Caravel GDS (sources are in the 'gds' directory)"
41 @sleep 1
agorararmardf8e91c32020-11-30 23:59:58 +020042 @cp gds/caravel.gds gds/caravel.old.gds && echo "Copying old Caravel to gds/caravel.old.gds" || true
Ahmed Ghazy0252f542020-11-25 14:45:38 +020043 @cd gds && MAGTYPE=mag magic -rcfile ${PDK_ROOT}/sky130A/libs.tech/magic/current/sky130A.magicrc -noc -dnull gen_caravel.tcl < /dev/null
Ahmed Ghazyefdc5292020-11-19 16:05:48 +020044
45
Ahmed Ghazye4c7ec52020-11-20 13:10:15 +020046
Ahmed Ghazy5898e4a2020-11-13 22:28:55 +020047.PHONY: clean
48clean:
49 echo "clean"
50
51
52
53.PHONY: verify
54verify:
55 echo "verify"
56
57
58
59$(LARGE_FILES_GZ): %.gz: %
Ahmed Ghazy0252f542020-11-25 14:45:38 +020060 @if ! [ $(suffix $<) == ".gz" ]; then\
Ahmed Ghazye4c7ec52020-11-20 13:10:15 +020061 gzip -n --best $< > /dev/null &&\
Ahmed Ghazy5898e4a2020-11-13 22:28:55 +020062 echo "$< -> $@";\
63 fi
64
Ahmed Ghazye4c7ec52020-11-20 13:10:15 +020065# This target compresses all files larger than $(FILE_SIZE_LIMIT_MB) MB
Ahmed Ghazy5898e4a2020-11-13 22:28:55 +020066.PHONY: compress
67compress: $(LARGE_FILES_GZ)
68 @echo "Files larger than $(FILE_SIZE_LIMIT_MB) MBytes are compressed!"
69
70
71
72$(ARCHIVE_SOURCES): %: %.gz
Ahmed Ghazye4c7ec52020-11-20 13:10:15 +020073 @gzip -d $< &&\
74 echo "$< -> $@";\
Ahmed Ghazy5898e4a2020-11-13 22:28:55 +020075
76.PHONY: uncompress
77uncompress: $(ARCHIVE_SOURCES)
78 @echo "All files are uncompressed!"
agorararmard212cd822020-11-26 22:40:17 +020079
Ahmed Ghazyfdda2cb2020-12-04 02:00:38 +020080
81# LVS
Ahmed Ghazyfdda2cb2020-12-04 02:00:38 +020082BLOCKS = $(shell cd openlane && find * -maxdepth 0 -type d)
83LVS_BLOCKS = $(foreach block, $(BLOCKS), lvs-$(block))
Ahmed Ghazy7f70d6f2020-12-05 23:05:31 +020084$(LVS_BLOCKS): lvs-% : ./mag/%.mag ./verilog/gl/%.v
Ahmed Ghazyfdda2cb2020-12-04 02:00:38 +020085 echo "Extracting $*"
86 mkdir -p ./mag/tmp
87 echo "load $* -dereference;\
Ahmed Ghazyd3ca6fe2020-12-16 20:48:17 +020088 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 Ghazyfdda2cb2020-12-04 02:00:38 +020095 extract no all;\
96 extract do local;\
Ahmed Ghazyd3ca6fe2020-12-16 20:48:17 +020097 extract unique;\
Ahmed Ghazyfdda2cb2020-12-04 02:00:38 +020098 extract;\
99 ext2spice lvs;\
Ahmed Ghazyd3ca6fe2020-12-16 20:48:17 +0200100 ext2spice $*.ext;\
Ahmed Ghazyfdda2cb2020-12-04 02:00:38 +0200101 feedback save extract_$*.log;\
102 exit;" > ./mag/extract_$*.tcl
Ahmed Ghazyd3ca6fe2020-12-16 20:48:17 +0200103 cd mag && export MAGTYPE=maglef; magic -rcfile ${PDK_ROOT}/sky130A/libs.tech/magic/current/sky130A.magicrc -noc -dnull extract_$*.tcl < /dev/null
Ahmed Ghazyfdda2cb2020-12-04 02:00:38 +0200104 mv ./mag/$*.spice ./spi/lvs
Ahmed Ghazyd3ca6fe2020-12-16 20:48:17 +0200105 rm ./mag/*.ext
106 mv -f ./mag/extract_$*.{tcl,log} ./mag/tmp
Ahmed Ghazyfdda2cb2020-12-04 02:00:38 +0200107 ####
108 mkdir -p ./spi/lvs/tmp
Ahmed Ghazyd3ca6fe2020-12-16 20:48:17 +0200109 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 Ghazyfdda2cb2020-12-04 02:00:38 +0200114
115
116.PHONY: help
117help:
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###########################################################################
agorararmard212cd822020-11-26 22:40:17 +0200122.PHONY: pdk
123pdk: 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
129skywater-pdk: check-env $(PDK_ROOT)/skywater-pdk
130 cd $(PDK_ROOT)/skywater-pdk && \
agorararmard63e56722020-12-09 19:57:30 +0200131 git checkout master && git pull && \
agorararmard212cd822020-11-26 22:40:17 +0200132 git checkout -qf $(SKYWATER_COMMIT)
133
134.PHONY: skywater-library
135skywater-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:
agorararmard065a9422020-12-05 00:24:07 +0200144 git clone https://github.com/RTimothyEdwards/open_pdks.git $(PDK_ROOT)/open_pdks
agorararmard212cd822020-11-26 22:40:17 +0200145
146.PHONY: open_pdks
147open_pdks: check-env $(PDK_ROOT)/open_pdks
148 cd $(PDK_ROOT)/open_pdks && \
agorararmard63e56722020-12-09 19:57:30 +0200149 git checkout master && git pull && \
agorararmard212cd822020-11-26 22:40:17 +0200150 git checkout -qf $(OPEN_PDKS_COMMIT)
151
152.PHONY: build-pdk
153build-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
agorararmard7eebfe42020-12-07 22:08:29 +0200166.RECIPE: manifest
167manifest:
168 cd verilog/rtl/ && \
agorararmardbd781832020-12-08 21:09:44 +0200169 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
agorararmard7eebfe42020-12-07 22:08:29 +0200175
agorararmard212cd822020-11-26 22:40:17 +0200176check-env:
177ifndef PDK_ROOT
178 $(error PDK_ROOT is undefined, please export it before running make)
Ahmed Ghazy31c34652020-12-01 19:59:44 +0200179endif