Ahmed Ghazy | e4c7ec5 | 2020-11-20 13:10:15 +0200 | [diff] [blame] | 1 | FILE_SIZE_LIMIT_MB = 10 |
Ahmed Ghazy | 5898e4a | 2020-11-13 22:28:55 +0200 | [diff] [blame] | 2 | LARGE_FILES := $(shell find . -type f -size +$(FILE_SIZE_LIMIT_MB)M -not -path "./.git/*") |
| 3 | |
| 4 | LARGE_FILES_GZ := $(addsuffix .gz, $(LARGE_FILES)) |
| 5 | |
| 6 | ARCHIVES := $(shell find . -type f -name "*.gz") |
| 7 | ARCHIVE_SOURCES := $(basename $(ARCHIVES)) |
| 8 | |
agorararmard | 212cd82 | 2020-11-26 22:40:17 +0200 | [diff] [blame] | 9 | # PDK setup configs |
| 10 | THREADS ?= $(shell nproc) |
| 11 | STD_CELL_LIBRARY ?= sky130_fd_sc_hd |
| 12 | SPECIAL_VOLTAGE_LIBRARY ?= sky130_fd_sc_hvl |
| 13 | IO_LIBRARY ?= sky130_fd_io |
| 14 | SKYWATER_COMMIT ?= ca58d58c07ab2dac53488df393da633fd5fb9a02 |
| 15 | OPEN_PDKS_COMMIT ?= b427e3bd10dcdc36891ae270a1ef0bd02602c553 |
Ahmed Ghazy | efdc529 | 2020-11-19 16:05:48 +0200 | [diff] [blame] | 16 | |
| 17 | .DEFAULT_GOAL := ship |
Ahmed Ghazy | efdc529 | 2020-11-19 16:05:48 +0200 | [diff] [blame] | 18 | # We need portable GDS_FILE pointers... |
| 19 | .PHONY: ship |
agorararmard | 212cd82 | 2020-11-26 22:40:17 +0200 | [diff] [blame] | 20 | ship: check-env uncompress |
Ahmed Ghazy | efdc529 | 2020-11-19 16:05:48 +0200 | [diff] [blame] | 21 | @echo "###############################################" |
| 22 | @echo "Generating Caravel GDS (sources are in the 'gds' directory)" |
| 23 | @sleep 1 |
Ahmed Ghazy | 0252f54 | 2020-11-25 14:45:38 +0200 | [diff] [blame] | 24 | @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] | 25 | |
| 26 | |
Ahmed Ghazy | e4c7ec5 | 2020-11-20 13:10:15 +0200 | [diff] [blame] | 27 | |
Ahmed Ghazy | 5898e4a | 2020-11-13 22:28:55 +0200 | [diff] [blame] | 28 | .PHONY: clean |
| 29 | clean: |
| 30 | echo "clean" |
| 31 | |
| 32 | |
| 33 | |
| 34 | .PHONY: verify |
| 35 | verify: |
| 36 | echo "verify" |
| 37 | |
| 38 | |
| 39 | |
| 40 | $(LARGE_FILES_GZ): %.gz: % |
Ahmed Ghazy | 0252f54 | 2020-11-25 14:45:38 +0200 | [diff] [blame] | 41 | @if ! [ $(suffix $<) == ".gz" ]; then\ |
Ahmed Ghazy | e4c7ec5 | 2020-11-20 13:10:15 +0200 | [diff] [blame] | 42 | gzip -n --best $< > /dev/null &&\ |
Ahmed Ghazy | 5898e4a | 2020-11-13 22:28:55 +0200 | [diff] [blame] | 43 | echo "$< -> $@";\ |
| 44 | fi |
| 45 | |
Ahmed Ghazy | e4c7ec5 | 2020-11-20 13:10:15 +0200 | [diff] [blame] | 46 | # This target compresses all files larger than $(FILE_SIZE_LIMIT_MB) MB |
Ahmed Ghazy | 5898e4a | 2020-11-13 22:28:55 +0200 | [diff] [blame] | 47 | .PHONY: compress |
| 48 | compress: $(LARGE_FILES_GZ) |
| 49 | @echo "Files larger than $(FILE_SIZE_LIMIT_MB) MBytes are compressed!" |
| 50 | |
| 51 | |
| 52 | |
| 53 | $(ARCHIVE_SOURCES): %: %.gz |
Ahmed Ghazy | e4c7ec5 | 2020-11-20 13:10:15 +0200 | [diff] [blame] | 54 | @gzip -d $< &&\ |
| 55 | echo "$< -> $@";\ |
Ahmed Ghazy | 5898e4a | 2020-11-13 22:28:55 +0200 | [diff] [blame] | 56 | |
| 57 | .PHONY: uncompress |
| 58 | uncompress: $(ARCHIVE_SOURCES) |
| 59 | @echo "All files are uncompressed!" |
agorararmard | 212cd82 | 2020-11-26 22:40:17 +0200 | [diff] [blame] | 60 | |
| 61 | .PHONY: pdk |
| 62 | pdk: skywater-pdk skywater-library open_pdks build-pdk |
| 63 | |
| 64 | $(PDK_ROOT)/skywater-pdk: |
| 65 | git clone https://github.com/google/skywater-pdk.git $(PDK_ROOT)/skywater-pdk |
| 66 | |
| 67 | .PHONY: skywater-pdk |
| 68 | skywater-pdk: check-env $(PDK_ROOT)/skywater-pdk |
| 69 | cd $(PDK_ROOT)/skywater-pdk && \ |
| 70 | git checkout -qf $(SKYWATER_COMMIT) |
| 71 | |
| 72 | .PHONY: skywater-library |
| 73 | skywater-library: check-env $(PDK_ROOT)/skywater-pdk |
| 74 | cd $(PDK_ROOT)/skywater-pdk && \ |
| 75 | git submodule update --init libraries/$(STD_CELL_LIBRARY)/latest && \ |
| 76 | git submodule update --init libraries/$(IO_LIBRARY)/latest && \ |
| 77 | git submodule update --init libraries/$(SPECIAL_VOLTAGE_LIBRARY)/latest && \ |
| 78 | $(MAKE) -j$(THREADS) timing |
| 79 | |
| 80 | ### OPEN_PDKS |
| 81 | $(PDK_ROOT)/open_pdks: |
| 82 | git clone https://github.com/RTimothyEdwards/open_pdks.git $(PDK_ROOT)/open_pdks |
| 83 | |
| 84 | .PHONY: open_pdks |
| 85 | open_pdks: check-env $(PDK_ROOT)/open_pdks |
| 86 | cd $(PDK_ROOT)/open_pdks && \ |
| 87 | git checkout -qf $(OPEN_PDKS_COMMIT) |
| 88 | |
| 89 | .PHONY: build-pdk |
| 90 | build-pdk: check-env $(PDK_ROOT)/open_pdks $(PDK_ROOT)/skywater-pdk |
| 91 | [ -d $(PDK_ROOT)/sky130A ] && \ |
| 92 | (echo "Warning: A sky130A build already exists under $(PDK_ROOT). It will be deleted first!" && \ |
| 93 | sleep 5 && \ |
| 94 | rm -rf $(PDK_ROOT)/sky130A) || \ |
| 95 | true |
| 96 | cd $(PDK_ROOT)/open_pdks && \ |
| 97 | ./configure --with-sky130-source=$(PDK_ROOT)/skywater-pdk/libraries --with-sky130-local-path=$(PDK_ROOT) && \ |
| 98 | cd sky130 && \ |
| 99 | $(MAKE) veryclean && \ |
| 100 | $(MAKE) && \ |
| 101 | $(MAKE) install-local |
| 102 | |
| 103 | check-env: |
| 104 | ifndef PDK_ROOT |
| 105 | $(error PDK_ROOT is undefined, please export it before running make) |
| 106 | endif |